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