blob: 5d07f0deda1f114dff834bc68e1dc0698211911f [file] [log] [blame]
Kevin Lubick217056c2018-09-20 17:39:31 -04001/*
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 CanvasKit 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 CanvasKit = {
26 // public API (i.e. things we declare in the pre-js file)
27 Color: function(r, g, b, a) {},
28 currentContext: function() {},
29 getWebGLSurface: function(htmlID) {},
30 MakeSkDashPathEffect: function(intervals, phase) {},
31 setCurrentContext: function() {},
32 LTRBRect: function(l, t, r, b) {},
33
34 // private API (i.e. things declared in the bindings that we use
35 // in the pre-js file)
36 _getWebGLSurface: function(htmlID, w, h) {},
37 _malloc: function(size) {},
38 onRuntimeInitialized: function() {},
39 _MakeSkDashPathEffect: function(ptr, len, phase) {},
40
41 // Objects and properties on CanvasKit
42
43 HEAPF32: {}, // only needed for TypedArray mallocs
44
45 SkPath: {
46 // public API should go below because closure still will
47 // remove things declared here and not on the prototype.
48
49 // private API
50 _addPath: function(path, scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
51 _arcTo: function(x1, y1, x2, y2, radius) {},
52 _close: function() {},
53 _conicTo: function(x1, y1, x2, y2, w) {},
54 _cubicTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {},
55 _lineTo: function(x1, y1) {},
56 _moveTo: function(x1, y1) {},
57 _op: function(otherPath, op) {},
58 _quadTo: function(cpx, cpy, x, y) {},
59 _rect: function(x, y, w, h) {},
60 _simplify: function() {},
61 _transform: function(scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
62 }
63}
64
65// Path public API
66CanvasKit.SkPath.prototype.addPath = function() {};
67CanvasKit.SkPath.prototype.arcTo = function(x1, y1, x2, y2, radius) {};
68CanvasKit.SkPath.prototype.close = function() {};
69CanvasKit.SkPath.prototype.conicTo = function(x1, y1, x2, y2, w) {};
70CanvasKit.SkPath.prototype.cubicTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
71CanvasKit.SkPath.prototype.lineTo = function(x, y) {};
72CanvasKit.SkPath.prototype.moveTo = function(x, y) {};
73CanvasKit.SkPath.prototype.op = function(otherPath, op) {};
74CanvasKit.SkPath.prototype.quadTo = function(x1, y1, x2, y2) {};
75CanvasKit.SkPath.prototype.rect = function(x, y, w, h) {};
76CanvasKit.SkPath.prototype.simplify = function() {};
77CanvasKit.SkPath.prototype.transform = function() {};
78
79// Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.
80function loadWebAssemblyModule() {}