@jbrowse/core 1.6.7 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseFeatureWidget/BaseFeatureDetail.d.ts +2 -2
- package/PluginLoader.d.ts +11 -3
- package/PluginLoader.js +37 -89
- package/PluginManager.d.ts +2 -2
- package/PluginManager.js +4 -6
- package/ReExports/modules.d.ts +2 -2
- package/assemblyManager/assemblyManager.d.ts +21 -21
- package/configuration/util.js +1 -5
- package/data_adapters/BaseAdapter.js +70 -108
- package/package.json +5 -8
- package/pluggableElementTypes/WidgetType.d.ts +1 -2
- package/pluggableElementTypes/models/BaseViewModel.js +1 -1
- package/pluggableElementTypes/models/InternetAccountModel.js +51 -69
- package/pluggableElementTypes/renderers/FeatureRendererType.js +14 -19
- package/rpc/BaseRpcDriver.d.ts +7 -8
- package/rpc/BaseRpcDriver.js +35 -44
- package/rpc/BaseRpcDriver.test.js +2 -2
- package/rpc/RpcManager.js +29 -11
- package/rpc/WebWorkerRpcDriver.d.ts +2 -6
- package/rpc/WebWorkerRpcDriver.js +6 -5
- package/rpc/configSchema.js +14 -6
- package/ui/App.js +13 -17
- package/ui/AssemblySelector.d.ts +4 -1
- package/ui/AssemblySelector.js +69 -8
- package/ui/PrerenderedCanvas.js +1 -26
- package/ui/ViewContainer.d.ts +5 -5
- package/ui/ViewContainer.js +12 -7
- package/util/index.d.ts +12 -5
- package/util/index.js +47 -26
- package/util/io/index.js +3 -1
- package/util/layouts/BaseLayout.d.ts +1 -0
- package/util/layouts/GranularRectLayout.js +2 -0
- package/util/layouts/PrecomputedLayout.js +2 -1
- package/util/offscreenCanvas/Canvas2DContextShim/Canvas2DContextShim.test.d.ts +1 -0
- package/util/offscreenCanvas/Canvas2DContextShim/Canvas2DContextShim.test.js +15 -0
- package/util/offscreenCanvas/Canvas2DContextShim/context.d.ts +56 -0
- package/util/offscreenCanvas/Canvas2DContextShim/context.js +356 -0
- package/util/offscreenCanvas/Canvas2DContextShim/index.d.ts +2 -0
- package/util/offscreenCanvas/Canvas2DContextShim/index.js +13 -0
- package/util/offscreenCanvas/Canvas2DContextShim/svg.d.ts +3 -0
- package/util/offscreenCanvas/Canvas2DContextShim/svg.js +210 -0
- package/util/offscreenCanvas/Canvas2DContextShim/types.d.ts +50 -0
- package/util/offscreenCanvas/Canvas2DContextShim/types.js +59 -0
- package/util/offscreenCanvas/Canvas2DContextShim/util.d.ts +12 -0
- package/util/offscreenCanvas/Canvas2DContextShim/util.js +91 -0
- package/util/offscreenCanvas/CanvasShim.d.ts +11 -0
- package/util/offscreenCanvas/CanvasShim.js +54 -0
- package/util/offscreenCanvas/index.d.ts +14 -0
- package/util/offscreenCanvas/index.js +170 -0
- package/util/offscreenCanvas/ponyfill.d.ts +6 -0
- package/util/offscreenCanvas/ponyfill.js +145 -0
- package/util/offscreenCanvas/types.d.ts +16 -0
- package/util/offscreenCanvas/types.js +14 -0
- package/util/offscreenCanvasPonyfill.d.ts +1 -58
- package/util/offscreenCanvasPonyfill.js +10 -815
- package/util/offscreenCanvasUtils.d.ts +1 -13
- package/util/offscreenCanvasUtils.js +12 -124
- package/util/simpleFeature.d.ts +1 -0
- package/util/tracks.js +4 -1
- package/ui/NewSessionCards.d.ts +0 -14
- package/ui/NewSessionCards.js +0 -136
|
@@ -1,823 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.createImageBitmap = exports.createCanvas = exports.PonyfillOffscreenContext = exports.PonyfillOffscreenCanvas = exports.ImageBitmapType = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
-
|
|
18
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
19
|
-
|
|
20
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
21
|
-
|
|
22
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
23
|
-
|
|
24
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
25
|
-
|
|
26
|
-
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _svgPathGenerator = _interopRequireDefault(require("svg-path-generator"));
|
|
29
|
-
|
|
30
|
-
var _color = _interopRequireDefault(require("color"));
|
|
31
|
-
|
|
32
|
-
var _detectNode = _interopRequireDefault(require("detect-node"));
|
|
33
|
-
|
|
34
|
-
/* eslint-disable no-restricted-globals */
|
|
35
|
-
// This is a ponyfill for the HTML5 OffscreenCanvas API.
|
|
36
|
-
var createCanvas;
|
|
37
|
-
exports.createCanvas = createCanvas;
|
|
38
|
-
var createImageBitmap;
|
|
39
|
-
exports.createImageBitmap = createImageBitmap;
|
|
40
|
-
var ImageBitmapType;
|
|
41
|
-
exports.ImageBitmapType = ImageBitmapType;
|
|
42
|
-
var weHave = {
|
|
43
|
-
realOffscreenCanvas: typeof OffscreenCanvas === 'function',
|
|
44
|
-
node: _detectNode.default
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var PonyfillOffscreenContext = /*#__PURE__*/function () {
|
|
48
|
-
function PonyfillOffscreenContext(width, height) {
|
|
49
|
-
(0, _classCallCheck2.default)(this, PonyfillOffscreenContext);
|
|
50
|
-
this.width = width;
|
|
51
|
-
this.height = height;
|
|
52
|
-
this.commands = [];
|
|
53
|
-
this.currentFont = '12px Courier New, monospace';
|
|
54
|
-
} // setters (no getters working)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(0, _createClass2.default)(PonyfillOffscreenContext, [{
|
|
58
|
-
key: "strokeStyle",
|
|
59
|
-
set: function set(style) {
|
|
60
|
-
if (style !== this.currentStrokeStyle) {
|
|
61
|
-
this.commands.push({
|
|
62
|
-
type: 'strokeStyle',
|
|
63
|
-
style: style
|
|
64
|
-
});
|
|
65
|
-
this.currentStrokeStyle = style;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "fillStyle",
|
|
70
|
-
set: function set(style) {
|
|
71
|
-
if (style !== this.currentFillStyle) {
|
|
72
|
-
this.commands.push({
|
|
73
|
-
type: 'fillStyle',
|
|
74
|
-
style: style
|
|
75
|
-
});
|
|
76
|
-
this.currentFillStyle = style;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "font",
|
|
81
|
-
set: function set(style) {
|
|
82
|
-
this.currentFont = style;
|
|
83
|
-
this.commands.push({
|
|
84
|
-
type: 'font',
|
|
85
|
-
style: style
|
|
86
|
-
});
|
|
87
|
-
} // methods
|
|
88
|
-
|
|
89
|
-
}, {
|
|
90
|
-
key: "arc",
|
|
91
|
-
value: function arc() {
|
|
92
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
93
|
-
args[_key] = arguments[_key];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.commands.push({
|
|
97
|
-
type: 'arc',
|
|
98
|
-
args: args
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "arcTo",
|
|
103
|
-
value: function arcTo() {
|
|
104
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
105
|
-
args[_key2] = arguments[_key2];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
this.commands.push({
|
|
109
|
-
type: 'arcTo',
|
|
110
|
-
args: args
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "bezierCurveTo",
|
|
115
|
-
value: function bezierCurveTo() {
|
|
116
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
117
|
-
args[_key3] = arguments[_key3];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
this.commands.push({
|
|
121
|
-
type: 'bezierCurveTo',
|
|
122
|
-
args: args
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "beginPath",
|
|
127
|
-
value: function beginPath() {
|
|
128
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
129
|
-
args[_key4] = arguments[_key4];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.commands.push({
|
|
133
|
-
type: 'beginPath',
|
|
134
|
-
args: args
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "clearRect",
|
|
139
|
-
value: function clearRect() {
|
|
140
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
141
|
-
args[_key5] = arguments[_key5];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this.commands.push({
|
|
145
|
-
type: 'clearRect',
|
|
146
|
-
args: args
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "clip",
|
|
151
|
-
value: function clip() {
|
|
152
|
-
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
153
|
-
args[_key6] = arguments[_key6];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this.commands.push({
|
|
157
|
-
type: 'clip',
|
|
158
|
-
args: args
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
key: "closePath",
|
|
163
|
-
value: function closePath() {
|
|
164
|
-
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
165
|
-
args[_key7] = arguments[_key7];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.commands.push({
|
|
169
|
-
type: 'closePath',
|
|
170
|
-
args: args
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "createLinearGradient",
|
|
175
|
-
value: function createLinearGradient() {
|
|
176
|
-
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
177
|
-
args[_key8] = arguments[_key8];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this.commands.push({
|
|
181
|
-
type: 'createLinearGradient',
|
|
182
|
-
args: args
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}, {
|
|
186
|
-
key: "createPattern",
|
|
187
|
-
value: function createPattern() {
|
|
188
|
-
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
189
|
-
args[_key9] = arguments[_key9];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
this.commands.push({
|
|
193
|
-
type: 'createPattern',
|
|
194
|
-
args: args
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}, {
|
|
198
|
-
key: "createRadialGradient",
|
|
199
|
-
value: function createRadialGradient() {
|
|
200
|
-
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
201
|
-
args[_key10] = arguments[_key10];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
this.commands.push({
|
|
205
|
-
type: 'createRadialGradient',
|
|
206
|
-
args: args
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}, {
|
|
210
|
-
key: "drawFocusIfNeeded",
|
|
211
|
-
value: function drawFocusIfNeeded() {
|
|
212
|
-
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
213
|
-
args[_key11] = arguments[_key11];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
this.commands.push({
|
|
217
|
-
type: 'drawFocusIfNeeded',
|
|
218
|
-
args: args
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}, {
|
|
222
|
-
key: "drawImage",
|
|
223
|
-
value: function drawImage() {
|
|
224
|
-
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
225
|
-
args[_key12] = arguments[_key12];
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
this.commands.push({
|
|
229
|
-
type: 'drawImage',
|
|
230
|
-
args: args
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
key: "ellipse",
|
|
235
|
-
value: function ellipse() {
|
|
236
|
-
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
237
|
-
args[_key13] = arguments[_key13];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
this.commands.push({
|
|
241
|
-
type: 'ellipse',
|
|
242
|
-
args: args
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "fill",
|
|
247
|
-
value: function fill() {
|
|
248
|
-
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
249
|
-
args[_key14] = arguments[_key14];
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
this.commands.push({
|
|
253
|
-
type: 'fill',
|
|
254
|
-
args: args
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}, {
|
|
258
|
-
key: "fillRect",
|
|
259
|
-
value: function fillRect() {
|
|
260
|
-
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
261
|
-
args[_key15] = arguments[_key15];
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
var x = args[0],
|
|
265
|
-
y = args[1],
|
|
266
|
-
w = args[2],
|
|
267
|
-
h = args[3]; // avoid rendering offscreen contents
|
|
268
|
-
|
|
269
|
-
if (x > this.width || x + w < 0) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
var nx = Math.max(x, 0);
|
|
274
|
-
var nw = w - (nx - x);
|
|
275
|
-
this.commands.push({
|
|
276
|
-
type: 'fillRect',
|
|
277
|
-
args: [nx, y, nw, h]
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}, {
|
|
281
|
-
key: "fillText",
|
|
282
|
-
value: function fillText() {
|
|
283
|
-
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
284
|
-
args[_key16] = arguments[_key16];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// if (x > this.width || x + 1000 < 0) {
|
|
288
|
-
// return
|
|
289
|
-
// }
|
|
290
|
-
this.commands.push({
|
|
291
|
-
type: 'fillText',
|
|
292
|
-
args: args
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
}, {
|
|
296
|
-
key: "lineTo",
|
|
297
|
-
value: function lineTo() {
|
|
298
|
-
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
299
|
-
args[_key17] = arguments[_key17];
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
this.commands.push({
|
|
303
|
-
type: 'lineTo',
|
|
304
|
-
args: args
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}, {
|
|
308
|
-
key: "measureText",
|
|
309
|
-
value: function measureText(text) {
|
|
310
|
-
var height = +this.currentFont.match(/\d+/)[0];
|
|
311
|
-
return {
|
|
312
|
-
width: height / 2 * text.length,
|
|
313
|
-
height: height
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
}, {
|
|
317
|
-
key: "moveTo",
|
|
318
|
-
value: function moveTo() {
|
|
319
|
-
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
|
320
|
-
args[_key18] = arguments[_key18];
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
this.commands.push({
|
|
324
|
-
type: 'moveTo',
|
|
325
|
-
args: args
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
}, {
|
|
329
|
-
key: "quadraticCurveTo",
|
|
330
|
-
value: function quadraticCurveTo() {
|
|
331
|
-
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
332
|
-
args[_key19] = arguments[_key19];
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
this.commands.push({
|
|
336
|
-
type: 'quadraticCurveTo',
|
|
337
|
-
args: args
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}, {
|
|
341
|
-
key: "rect",
|
|
342
|
-
value: function rect() {
|
|
343
|
-
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
344
|
-
args[_key20] = arguments[_key20];
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
this.commands.push({
|
|
348
|
-
type: 'rect',
|
|
349
|
-
args: args
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}, {
|
|
353
|
-
key: "restore",
|
|
354
|
-
value: function restore() {
|
|
355
|
-
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
356
|
-
args[_key21] = arguments[_key21];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
this.commands.push({
|
|
360
|
-
type: 'restore',
|
|
361
|
-
args: args
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}, {
|
|
365
|
-
key: "rotate",
|
|
366
|
-
value: function rotate() {
|
|
367
|
-
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
368
|
-
args[_key22] = arguments[_key22];
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
this.commands.push({
|
|
372
|
-
type: 'rotate',
|
|
373
|
-
args: args
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}, {
|
|
377
|
-
key: "save",
|
|
378
|
-
value: function save() {
|
|
379
|
-
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
380
|
-
args[_key23] = arguments[_key23];
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
this.commands.push({
|
|
384
|
-
type: 'save',
|
|
385
|
-
args: args
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}, {
|
|
389
|
-
key: "setLineDash",
|
|
390
|
-
value: function setLineDash() {
|
|
391
|
-
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
|
392
|
-
args[_key24] = arguments[_key24];
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
this.commands.push({
|
|
396
|
-
type: 'setLineDash',
|
|
397
|
-
args: args
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
}, {
|
|
401
|
-
key: "setTransform",
|
|
402
|
-
value: function setTransform() {
|
|
403
|
-
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
|
404
|
-
args[_key25] = arguments[_key25];
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
this.commands.push({
|
|
408
|
-
type: 'setTransform',
|
|
409
|
-
args: args
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}, {
|
|
413
|
-
key: "scale",
|
|
414
|
-
value: function scale() {
|
|
415
|
-
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
|
416
|
-
args[_key26] = arguments[_key26];
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
this.commands.push({
|
|
420
|
-
type: 'scale',
|
|
421
|
-
args: args
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
}, {
|
|
425
|
-
key: "stroke",
|
|
426
|
-
value: function stroke() {
|
|
427
|
-
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
|
|
428
|
-
args[_key27] = arguments[_key27];
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
this.commands.push({
|
|
432
|
-
type: 'stroke',
|
|
433
|
-
args: args
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
}, {
|
|
437
|
-
key: "strokeRect",
|
|
438
|
-
value: function strokeRect() {
|
|
439
|
-
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
|
|
440
|
-
args[_key28] = arguments[_key28];
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
this.commands.push({
|
|
444
|
-
type: 'strokeRect',
|
|
445
|
-
args: args
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}, {
|
|
449
|
-
key: "strokeText",
|
|
450
|
-
value: function strokeText() {
|
|
451
|
-
for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
|
|
452
|
-
args[_key29] = arguments[_key29];
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
this.commands.push({
|
|
456
|
-
type: 'strokeText',
|
|
457
|
-
args: args
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
}, {
|
|
461
|
-
key: "transform",
|
|
462
|
-
value: function transform() {
|
|
463
|
-
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
|
|
464
|
-
args[_key30] = arguments[_key30];
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
this.commands.push({
|
|
468
|
-
type: 'transform',
|
|
469
|
-
args: args
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
}, {
|
|
473
|
-
key: "translate",
|
|
474
|
-
value: function translate() {
|
|
475
|
-
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
|
|
476
|
-
args[_key31] = arguments[_key31];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
this.commands.push({
|
|
480
|
-
type: 'translate',
|
|
481
|
-
args: args
|
|
482
|
-
});
|
|
483
|
-
} // unsupported
|
|
484
|
-
// putImageData(...args)
|
|
485
|
-
// createImageData(...args)
|
|
486
|
-
// getImageData(...args)
|
|
487
|
-
// getLineDash(...args)
|
|
488
|
-
// getTransform(...args)
|
|
489
|
-
|
|
490
|
-
}]);
|
|
491
|
-
return PonyfillOffscreenContext;
|
|
492
|
-
}();
|
|
493
|
-
|
|
494
|
-
exports.PonyfillOffscreenContext = PonyfillOffscreenContext;
|
|
495
|
-
|
|
496
|
-
function splitColor(color) {
|
|
497
|
-
var fill = (0, _color.default)(color);
|
|
498
|
-
return {
|
|
499
|
-
hex: fill.hex(),
|
|
500
|
-
opacity: fill.alpha()
|
|
501
|
-
};
|
|
502
|
-
} // https://stackoverflow.com/a/5620441/2129219
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
function parseFont(font) {
|
|
506
|
-
var fontFamily = null;
|
|
507
|
-
var fontSize = null;
|
|
508
|
-
var fontStyle = 'normal';
|
|
509
|
-
var fontWeight = 'normal';
|
|
510
|
-
var fontVariant = 'normal';
|
|
511
|
-
var lineHeight = 'normal';
|
|
512
|
-
var elements = font.split(/\s+/);
|
|
513
|
-
var element;
|
|
514
|
-
|
|
515
|
-
outer: while (element = elements.shift()) {
|
|
516
|
-
switch (element) {
|
|
517
|
-
case 'normal':
|
|
518
|
-
break;
|
|
519
|
-
|
|
520
|
-
case 'italic':
|
|
521
|
-
case 'oblique':
|
|
522
|
-
fontStyle = element;
|
|
523
|
-
break;
|
|
524
|
-
|
|
525
|
-
case 'small-caps':
|
|
526
|
-
fontVariant = element;
|
|
527
|
-
break;
|
|
528
|
-
|
|
529
|
-
case 'bold':
|
|
530
|
-
case 'bolder':
|
|
531
|
-
case 'lighter':
|
|
532
|
-
case '100':
|
|
533
|
-
case '200':
|
|
534
|
-
case '300':
|
|
535
|
-
case '400':
|
|
536
|
-
case '500':
|
|
537
|
-
case '600':
|
|
538
|
-
case '700':
|
|
539
|
-
case '800':
|
|
540
|
-
case '900':
|
|
541
|
-
fontWeight = element;
|
|
542
|
-
break;
|
|
543
|
-
|
|
544
|
-
default:
|
|
545
|
-
if (!fontSize) {
|
|
546
|
-
var parts = element.split('/');
|
|
547
|
-
fontSize = parts[0];
|
|
548
|
-
|
|
549
|
-
if (parts.length > 1) {
|
|
550
|
-
lineHeight = parts[1];
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
break;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
fontFamily = element;
|
|
557
|
-
|
|
558
|
-
if (elements.length) {
|
|
559
|
-
fontFamily += " ".concat(elements.join(' '));
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
break outer;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return {
|
|
567
|
-
fontStyle: fontStyle,
|
|
568
|
-
fontVariant: fontVariant,
|
|
569
|
-
fontWeight: fontWeight,
|
|
570
|
-
fontSize: fontSize,
|
|
571
|
-
lineHeight: lineHeight,
|
|
572
|
-
fontFamily: fontFamily
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
var PonyfillOffscreenCanvas = /*#__PURE__*/function () {
|
|
577
|
-
function PonyfillOffscreenCanvas(width, height) {
|
|
578
|
-
(0, _classCallCheck2.default)(this, PonyfillOffscreenCanvas);
|
|
579
|
-
this.width = width;
|
|
580
|
-
this.height = height;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
(0, _createClass2.default)(PonyfillOffscreenCanvas, [{
|
|
584
|
-
key: "getContext",
|
|
585
|
-
value: function getContext(type) {
|
|
586
|
-
if (type !== '2d') {
|
|
587
|
-
throw new Error("unknown type ".concat(type));
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
this.context = new PonyfillOffscreenContext(this.width, this.height);
|
|
591
|
-
return this.context;
|
|
592
|
-
}
|
|
593
|
-
}, {
|
|
594
|
-
key: "getSerializedSvg",
|
|
595
|
-
value: function getSerializedSvg() {
|
|
596
|
-
var currentFill;
|
|
597
|
-
var currentStroke;
|
|
598
|
-
var currentPath = [];
|
|
599
|
-
var rotation;
|
|
600
|
-
var font;
|
|
601
|
-
var nodes = [];
|
|
602
|
-
this.context.commands.forEach(function (command, index) {
|
|
603
|
-
if (command.type === 'font') {
|
|
604
|
-
if (command.style) {
|
|
605
|
-
// stackoverflow.com/questions/5618676
|
|
606
|
-
// skip lineHeight in the final usage
|
|
607
|
-
var _parseFont = parseFont(command.style),
|
|
608
|
-
fontStyle = _parseFont.fontStyle,
|
|
609
|
-
fontFamily = _parseFont.fontFamily,
|
|
610
|
-
fontSize = _parseFont.fontSize;
|
|
611
|
-
|
|
612
|
-
font = {
|
|
613
|
-
fontStyle: fontStyle,
|
|
614
|
-
fontFamily: fontFamily,
|
|
615
|
-
fontSize: fontSize
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (command.type === 'fillStyle') {
|
|
621
|
-
if (command.style) {
|
|
622
|
-
currentFill = command.style;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
if (command.type === 'strokeStyle') {
|
|
627
|
-
if (command.style) {
|
|
628
|
-
currentStroke = command.style;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
6
|
|
|
632
|
-
|
|
633
|
-
var _command$args = (0, _slicedToArray2.default)(command.args, 4),
|
|
634
|
-
x = _command$args[0],
|
|
635
|
-
y = _command$args[1],
|
|
636
|
-
w = _command$args[2],
|
|
637
|
-
h = _command$args[3];
|
|
7
|
+
var _ponyfill = require("./offscreenCanvas/ponyfill");
|
|
638
8
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
key: index,
|
|
647
|
-
fill: hex,
|
|
648
|
-
fillOpacity: opacity !== 1 ? opacity : undefined,
|
|
649
|
-
x: x.toFixed(3),
|
|
650
|
-
y: ny.toFixed(3),
|
|
651
|
-
width: w.toFixed(3),
|
|
652
|
-
height: nh.toFixed(3)
|
|
653
|
-
}));
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (command.type === 'fillText') {
|
|
657
|
-
var _command$args2 = (0, _slicedToArray2.default)(command.args, 3),
|
|
658
|
-
text = _command$args2[0],
|
|
659
|
-
_x = _command$args2[1],
|
|
660
|
-
_y = _command$args2[2];
|
|
661
|
-
|
|
662
|
-
var _splitColor2 = splitColor(currentFill),
|
|
663
|
-
_hex = _splitColor2.hex,
|
|
664
|
-
_opacity = _splitColor2.opacity;
|
|
665
|
-
|
|
666
|
-
nodes.push( /*#__PURE__*/_react.default.createElement("text", (0, _extends2.default)({
|
|
667
|
-
key: index,
|
|
668
|
-
fill: _hex,
|
|
669
|
-
fillOpacity: _opacity !== 1 ? _opacity : undefined,
|
|
670
|
-
x: _x.toFixed(3),
|
|
671
|
-
y: _y.toFixed(3)
|
|
672
|
-
}, font), text));
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (command.type === 'beginPath') {
|
|
676
|
-
currentPath = [];
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
if (command.type === 'moveTo') {
|
|
680
|
-
currentPath.push(command.args);
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
if (command.type === 'lineTo') {
|
|
684
|
-
currentPath.push(command.args);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
if (command.type === 'closePath') {
|
|
688
|
-
/* do nothing */
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (command.type === 'fill') {
|
|
692
|
-
var _Path;
|
|
693
|
-
|
|
694
|
-
var path = (_Path = (0, _svgPathGenerator.default)()).moveTo.apply(_Path, (0, _toConsumableArray2.default)(currentPath[0]));
|
|
695
|
-
|
|
696
|
-
for (var i = 1; i < currentPath.length; i++) {
|
|
697
|
-
var _path;
|
|
698
|
-
|
|
699
|
-
path = (_path = path).lineTo.apply(_path, (0, _toConsumableArray2.default)(currentPath[i]));
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
path.end();
|
|
703
|
-
|
|
704
|
-
var _splitColor3 = splitColor(currentFill),
|
|
705
|
-
_hex2 = _splitColor3.hex,
|
|
706
|
-
_opacity2 = _splitColor3.opacity;
|
|
707
|
-
|
|
708
|
-
nodes.push( /*#__PURE__*/_react.default.createElement("path", {
|
|
709
|
-
key: index,
|
|
710
|
-
fill: _hex2,
|
|
711
|
-
d: path,
|
|
712
|
-
fillOpacity: _opacity2 !== 1 ? _opacity2 : undefined
|
|
713
|
-
}));
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
if (command.type === 'stroke') {
|
|
717
|
-
var _Path2;
|
|
718
|
-
|
|
719
|
-
var _path2 = (_Path2 = (0, _svgPathGenerator.default)()).moveTo.apply(_Path2, (0, _toConsumableArray2.default)(currentPath[0]));
|
|
720
|
-
|
|
721
|
-
for (var _i = 1; _i < currentPath.length; _i++) {
|
|
722
|
-
var _path3;
|
|
723
|
-
|
|
724
|
-
_path2 = (_path3 = _path2).lineTo.apply(_path3, (0, _toConsumableArray2.default)(currentPath[_i]));
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
_path2.end();
|
|
728
|
-
|
|
729
|
-
var _splitColor4 = splitColor(currentStroke),
|
|
730
|
-
_hex3 = _splitColor4.hex,
|
|
731
|
-
_opacity3 = _splitColor4.opacity;
|
|
732
|
-
|
|
733
|
-
nodes.push( /*#__PURE__*/_react.default.createElement("path", {
|
|
734
|
-
key: index,
|
|
735
|
-
fill: "none",
|
|
736
|
-
stroke: _hex3,
|
|
737
|
-
fillOpacity: _opacity3 !== 1 ? _opacity3 : undefined,
|
|
738
|
-
d: _path2
|
|
739
|
-
}));
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
if (command.type === 'rotate') {
|
|
743
|
-
rotation = command.args[0] * 180 / Math.PI;
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
return rotation ? /*#__PURE__*/_react.default.createElement("g", {
|
|
747
|
-
transform: "rotate(".concat(rotation, ")")
|
|
748
|
-
}, [].concat(nodes)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, [].concat(nodes));
|
|
9
|
+
Object.keys(_ponyfill).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _ponyfill[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ponyfill[key];
|
|
749
16
|
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
}();
|
|
753
|
-
|
|
754
|
-
exports.PonyfillOffscreenCanvas = PonyfillOffscreenCanvas;
|
|
755
|
-
|
|
756
|
-
if (weHave.realOffscreenCanvas) {
|
|
757
|
-
exports.createCanvas = createCanvas = function createCanvas(width, height) {
|
|
758
|
-
return new OffscreenCanvas(width, height);
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
exports.createImageBitmap = createImageBitmap = window.createImageBitmap || self.createImageBitmap;
|
|
762
|
-
exports.ImageBitmapType = ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
|
|
763
|
-
} else if (weHave.node) {
|
|
764
|
-
// use node-canvas if we are running in node (i.e. automated tests)
|
|
765
|
-
var _require = require('canvas'),
|
|
766
|
-
nodeCreateCanvas = _require.createCanvas,
|
|
767
|
-
Image = _require.Image;
|
|
768
|
-
|
|
769
|
-
exports.createCanvas = createCanvas = nodeCreateCanvas;
|
|
770
|
-
|
|
771
|
-
exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
|
|
772
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(canvas) {
|
|
773
|
-
var dataUri,
|
|
774
|
-
img,
|
|
775
|
-
_args = arguments;
|
|
776
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
777
|
-
while (1) {
|
|
778
|
-
switch (_context.prev = _context.next) {
|
|
779
|
-
case 0:
|
|
780
|
-
if (!(_args.length <= 1 ? 0 : _args.length - 1)) {
|
|
781
|
-
_context.next = 2;
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
|
|
786
|
-
|
|
787
|
-
case 2:
|
|
788
|
-
dataUri = canvas.toDataURL();
|
|
789
|
-
img = new Image();
|
|
790
|
-
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
791
|
-
img.onload = function () {
|
|
792
|
-
return resolve(img);
|
|
793
|
-
};
|
|
794
|
-
|
|
795
|
-
img.onerror = reject;
|
|
796
|
-
img.src = dataUri;
|
|
797
|
-
}));
|
|
798
|
-
|
|
799
|
-
case 5:
|
|
800
|
-
case "end":
|
|
801
|
-
return _context.stop();
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}, _callee);
|
|
805
|
-
}));
|
|
806
|
-
|
|
807
|
-
return function createImageBitmap(_x2) {
|
|
808
|
-
return _ref.apply(this, arguments);
|
|
809
|
-
};
|
|
810
|
-
}();
|
|
811
|
-
|
|
812
|
-
exports.ImageBitmapType = ImageBitmapType = Image;
|
|
813
|
-
} else {
|
|
814
|
-
exports.createCanvas = createCanvas = function createCanvas(width, height) {
|
|
815
|
-
return new PonyfillOffscreenCanvas(width, height);
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
exports.createImageBitmap = createImageBitmap = function createImageBitmap(canvas) {
|
|
819
|
-
return canvas.context;
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
exports.ImageBitmapType = ImageBitmapType = (0, _typeof2.default)('StringArray');
|
|
823
|
-
}
|
|
17
|
+
});
|
|
18
|
+
});
|