blob: 91162543fec88456cc78a4057c2298f584263fde [file] [log] [blame]
Kevin Lubick11194ab2018-08-17 13:52:56 -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 PathKit.
7 *
8 * Emscripten does not support automatically generating an externs file, so we
9 * do it by hand. The general process is to write some JS code, and then put any
10 * calls to PathKit or related things in here. Running ./compile.sh and then
11 * looking at the minified results or running the Release-PathKit trybot should
12 * verify nothing was missed. Optionally, looking directly at the minified
13 * pathkit.js can be useful when developing locally.
14 *
15 * Docs:
16 * https://github.com/cljsjs/packages/wiki/Creating-Externs
17 * https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System
18 *
19 * Example externs:
20 * https://github.com/google/closure-compiler/tree/master/externs
21 */
22
23var PathKit = {
24 SkBits2FloatUnsigned: function(num) {},
25 _malloc: function(size) {},
26 onRuntimeInitialized: function() {},
Kevin Lubickd9936482018-08-24 10:44:16 -040027 _FromCmds: function(ptr, size) {},
28 loadCmdsTypedArray: function(arr) {},
29 FromCmds: function(arr) {},
Kevin Lubick11194ab2018-08-17 13:52:56 -040030
31 HEAPF32: {},
32
33 SkPath: {
34 _addPath: function(path, scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
35 _arc: function(x, y, radius, startAngle, endAngle, ccw) {},
36 _arcTo: function(x1, y1, x2, y2, radius) {},
37 _dash: function(on, off, phase) {},
38 _close: function() {},
39 _conicTo: function(x1, y1, x2, y2, w) {},
40 copy: function() {},
41 _cubicTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {},
42 _ellipse: function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {},
43 _lineTo: function(x1, y1) {},
44 _moveTo: function(x1, y1) {},
45 _op: function(otherPath, op) {},
Kevin Lubickd9936482018-08-24 10:44:16 -040046 _quadTo: function(cpx, cpy, x, y) {},
Kevin Lubick11194ab2018-08-17 13:52:56 -040047 _rect: function(x, y, w, h) {},
48 _simplify: function() {},
49 _stroke: function(opts) {},
50 _trim: function(startT, stopT, isComplement) {},
51 _transform: function() {}, // takes 1 or 9 params
52 },
53
54 StrokeCap: {
55 BUTT: {},
56 ROUND: {},
57 SQUARE: {},
58 },
59 StrokeJoin: {
60 MITER: {},
61 ROUND: {},
62 BEVEL: {},
63 }
64};
65
66// Define StrokeOpts object
67var StrokeOpts = {};
68StrokeOpts.prototype.width;
69StrokeOpts.prototype.miter_limit;
70StrokeOpts.prototype.cap;
71StrokeOpts.prototype.join;
72
73
74
75// For whatever reason, the closure compiler thinks it can rename some of our
76// prototype methods. Not entirely sure why.
77// Listing them here prevents that.
78PathKit.SkPath.prototype.addPath = function() {};
79PathKit.SkPath.prototype.arc = function(x, y, radius, startAngle, endAngle, ccw) {};
80PathKit.SkPath.prototype.arcTo = function(x1, y1, x2, y2, radius) {};
81PathKit.SkPath.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
82PathKit.SkPath.prototype.close = function() {};
83PathKit.SkPath.prototype.closePath = function() {};
84PathKit.SkPath.prototype.conicTo = function(x1, y1, x2, y2, w) {};
85PathKit.SkPath.prototype.cubicTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
86PathKit.SkPath.prototype.dash = function(on, off, phase) {};
87PathKit.SkPath.prototype.ellipse = function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {};
88PathKit.SkPath.prototype.lineTo = function(x, y) {};
89PathKit.SkPath.prototype.moveTo = function(x, y) {};
90PathKit.SkPath.prototype.op = function(otherPath, op) {};
91PathKit.SkPath.prototype.quadTo = function(x1, y1, x2, y2) {};
92PathKit.SkPath.prototype.quadraticCurveTo = function(x1, y1, x2, y2) {};
93PathKit.SkPath.prototype.rect = function(x, y, w, h) {};
94PathKit.SkPath.prototype.simplify = function() {};
95PathKit.SkPath.prototype.stroke = function(opts) {};
96PathKit.SkPath.prototype.transform = function() {};
97PathKit.SkPath.prototype.trim = function(startT, stopT, isComplement) {};
98// The following was taken from https://github.com/google/closure-compiler/blob/master/contrib/externs/svg.js
99
100/**
101 * @constructor
102 */
103function SVGMatrix(){}
104
105
106/**
107 * @type {number}
108 */
109SVGMatrix.prototype.a;
110
111
112/**
113 * @type {number}
114 */
115SVGMatrix.prototype.b;
116
117
118/**
119 * @type {number}
120 */
121SVGMatrix.prototype.c;
122
123
124/**
125 * @type {number}
126 */
127SVGMatrix.prototype.d;
128
129
130/**
131 * @type {number}
132 */
133SVGMatrix.prototype.e;
134
135
136/**
137 * @type {number}
138 */
139SVGMatrix.prototype.f;