blob: c6c5fc902c30366df1cd2e828844ed1f51bd6eab [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 Lubick774be5a2018-09-07 14:00:41 -040030 _SkCubicMap: function(cp1, cp2) {},
31 cubicYFromX: function(cpx1, cpy1, cpx2, cpy2, X) {},
32 cubicPtFromT: function(cpx1, cpy1, cpx2, cpy2, T) {},
Kevin Lubick11194ab2018-08-17 13:52:56 -040033
34 HEAPF32: {},
35
36 SkPath: {
37 _addPath: function(path, scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
38 _arc: function(x, y, radius, startAngle, endAngle, ccw) {},
39 _arcTo: function(x1, y1, x2, y2, radius) {},
40 _dash: function(on, off, phase) {},
41 _close: function() {},
42 _conicTo: function(x1, y1, x2, y2, w) {},
43 copy: function() {},
44 _cubicTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {},
45 _ellipse: function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {},
46 _lineTo: function(x1, y1) {},
47 _moveTo: function(x1, y1) {},
48 _op: function(otherPath, op) {},
Kevin Lubickd9936482018-08-24 10:44:16 -040049 _quadTo: function(cpx, cpy, x, y) {},
Kevin Lubick11194ab2018-08-17 13:52:56 -040050 _rect: function(x, y, w, h) {},
51 _simplify: function() {},
52 _stroke: function(opts) {},
53 _trim: function(startT, stopT, isComplement) {},
54 _transform: function() {}, // takes 1 or 9 params
55 },
56
57 StrokeCap: {
58 BUTT: {},
59 ROUND: {},
60 SQUARE: {},
61 },
62 StrokeJoin: {
63 MITER: {},
64 ROUND: {},
65 BEVEL: {},
66 }
67};
68
69// Define StrokeOpts object
70var StrokeOpts = {};
71StrokeOpts.prototype.width;
72StrokeOpts.prototype.miter_limit;
73StrokeOpts.prototype.cap;
74StrokeOpts.prototype.join;
75
Kevin Lubick774be5a2018-09-07 14:00:41 -040076// Define CubicMap object
77var CubicMap = {};
78CubicMap.prototype.computeYFromX = function(x) {};
79CubicMap.prototype.computePtFromT = function(t) {};
Kevin Lubick11194ab2018-08-17 13:52:56 -040080
81
82// For whatever reason, the closure compiler thinks it can rename some of our
83// prototype methods. Not entirely sure why.
84// Listing them here prevents that.
85PathKit.SkPath.prototype.addPath = function() {};
86PathKit.SkPath.prototype.arc = function(x, y, radius, startAngle, endAngle, ccw) {};
87PathKit.SkPath.prototype.arcTo = function(x1, y1, x2, y2, radius) {};
88PathKit.SkPath.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
89PathKit.SkPath.prototype.close = function() {};
90PathKit.SkPath.prototype.closePath = function() {};
91PathKit.SkPath.prototype.conicTo = function(x1, y1, x2, y2, w) {};
92PathKit.SkPath.prototype.cubicTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
93PathKit.SkPath.prototype.dash = function(on, off, phase) {};
94PathKit.SkPath.prototype.ellipse = function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {};
95PathKit.SkPath.prototype.lineTo = function(x, y) {};
96PathKit.SkPath.prototype.moveTo = function(x, y) {};
97PathKit.SkPath.prototype.op = function(otherPath, op) {};
98PathKit.SkPath.prototype.quadTo = function(x1, y1, x2, y2) {};
99PathKit.SkPath.prototype.quadraticCurveTo = function(x1, y1, x2, y2) {};
100PathKit.SkPath.prototype.rect = function(x, y, w, h) {};
101PathKit.SkPath.prototype.simplify = function() {};
102PathKit.SkPath.prototype.stroke = function(opts) {};
103PathKit.SkPath.prototype.transform = function() {};
104PathKit.SkPath.prototype.trim = function(startT, stopT, isComplement) {};
105// The following was taken from https://github.com/google/closure-compiler/blob/master/contrib/externs/svg.js
106
107/**
108 * @constructor
109 */
110function SVGMatrix(){}
111
112
113/**
114 * @type {number}
115 */
116SVGMatrix.prototype.a;
117
118
119/**
120 * @type {number}
121 */
122SVGMatrix.prototype.b;
123
124
125/**
126 * @type {number}
127 */
128SVGMatrix.prototype.c;
129
130
131/**
132 * @type {number}
133 */
134SVGMatrix.prototype.d;
135
136
137/**
138 * @type {number}
139 */
140SVGMatrix.prototype.e;
141
142
143/**
144 * @type {number}
145 */
146SVGMatrix.prototype.f;