• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * This externs file prevents the Closure JS compiler from minifying away
3 * names of objects created by Emscripten.
4 * Basically, by defining empty objects and functions here, Closure will
5 * know not to rename them.  This is needed because of our pre-js files,
6 * that is, the JS we hand-write to bundle into the output. That JS will be
7 * hit by the closure compiler and thus needs to know about what functions
8 * have special names and should not be minified.
9 *
10 * Emscripten does not support automatically generating an externs file, so we
11 * do it by hand. The general process is to write some JS code, and then put any
12 * calls to SkottieKit or related things in here. Running ./compile.sh and then
13 * looking at the minified results or running the Release trybot should
14 * verify nothing was missed. Optionally, looking directly at the minified
15 * pathkit.js can be useful when developing locally.
16 *
17 * Docs:
18 *   https://github.com/cljsjs/packages/wiki/Creating-Externs
19 *   https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System
20 *
21 * Example externs:
22 *   https://github.com/google/closure-compiler/tree/master/externs
23 */
24
25var SkottieKit = {
26  // public API (i.e. things we declare in the pre-js file or in the cpp bindings)
27  Color: function() {},
28  Color4f: function() {},
29
30  GetWebGLContext: function() {},
31  MakeCanvasSurface: function() {},
32  MakeGrContext: function() {},
33  MakeInMemorySurface: function() {},
34  MakeManagedAnimation: function() {},
35  MakeOnScreenGLSurface: function() {},
36  MakeSWCanvasSurface: function() {},
37  MakeWebGLCanvasSurface: function() {},
38  currentContext: function() {},
39  setCurrentContext: function() {},
40
41  _MakeManagedAnimation: function() {},
42  _getRasterDirectSurface: function() {},
43
44  GrContext: {
45    // public API (from C++ bindings)
46    getResourceCacheLimitBytes: function() {},
47    getResourceCacheUsageBytes: function() {},
48    releaseResourcesAndAbandonContext: function() {},
49    setResourceCacheLimitBytes: function() {},
50  },
51
52  SkCanvas: {
53    // public API (from C++ bindings)
54    clear: function() {},
55
56    prototype: {
57      requestAnimationFrame: function() {},
58    }
59  },
60
61  SkSurface: {
62    // public API (from C++ bindings)
63    flush: function() {},
64    getCanvas: function() {},
65
66    // private API
67    _clear: function() {},
68
69    prototype: {
70      clear: function() {},
71    }
72  },
73
74  // Constants and Enums
75  gpu: {},
76  skottie: {},
77  managed_skottie: {},
78
79  TRANSPARENT: {},
80  BLACK: {},
81  WHITE: {},
82
83  AlphaType: {
84    Opaque: {},
85    Premul: {},
86    Unpremul: {},
87  },
88
89  ColorType: {
90    RGBA_8888: {},
91  },
92
93  // Things Emscripten adds for us
94
95  /**
96   * @type {Float32Array}
97   */
98  HEAPF32: {},
99  /**
100   * @type {Float64Array}
101   */
102  HEAPF64: {},
103  /**
104   * @type {Uint8Array}
105   */
106  HEAPU8: {},
107  /**
108   * @type {Uint16Array}
109   */
110  HEAPU16: {},
111  /**
112   * @type {Uint32Array}
113   */
114  HEAPU32: {},
115  /**
116   * @type {Int8Array}
117   */
118  HEAP8: {},
119  /**
120   * @type {Int16Array}
121   */
122  HEAP16: {},
123  /**
124   * @type {Int32Array}
125   */
126  HEAP32: {},
127
128  _malloc: function() {},
129  _free: function() {},
130  onRuntimeInitialized: function() {},
131};
132
133// Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.
134function loadWebAssemblyModule() {};
135