@jbrowse/core 1.6.8 → 1.7.1
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.js +4 -6
- package/package.json +8 -10
- package/pluggableElementTypes/WidgetType.d.ts +1 -2
- package/pluggableElementTypes/models/BaseViewModel.js +1 -1
- package/pluggableElementTypes/models/InternetAccountModel.js +51 -69
- package/rpc/WebWorkerRpcDriver.d.ts +2 -6
- package/rpc/WebWorkerRpcDriver.js +6 -5
- package/tsconfig.build.tsbuildinfo +1 -0
- 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 +7 -1
- package/util/index.js +25 -5
- 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.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/BaseFeatureWidget/SequenceFeatureDetails.test.d.ts +0 -1
- package/BaseFeatureWidget/index.test.d.ts +0 -1
- package/TextSearch/BaseResults.test.d.ts +0 -1
- package/configuration/configurationSchema.test.d.ts +0 -1
- package/configuration/configurationSlot.test.d.ts +0 -1
- package/configuration/util.test.d.ts +0 -1
- package/data_adapters/BaseAdapter.test.d.ts +0 -1
- package/pluggableElementTypes/RpcMethodType.test.d.ts +0 -4
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.d.ts +0 -1
- package/rpc/BaseRpcDriver.test.d.ts +0 -9
- package/ui/FatalErrorDialog.test.d.ts +0 -1
- package/ui/NewSessionCards.d.ts +0 -14
- package/ui/NewSessionCards.js +0 -136
- package/ui/SanitizedHTML.test.d.ts +0 -1
- package/ui/theme.test.d.ts +0 -1
- package/util/Base1DViewModel.test.d.ts +0 -1
- package/util/calculateDynamicBlocks.test.d.ts +0 -1
- package/util/calculateStaticBlocks.test.d.ts +0 -1
- package/util/formatFastaStrings.test.d.ts +0 -1
- package/util/index.test.d.ts +0 -1
- package/util/jexlStrings.test.d.ts +0 -1
- package/util/layouts/GranularRectLayout.test.d.ts +0 -1
- package/util/range.test.d.ts +0 -1
- package/util/simpleFeature.test.d.ts +0 -1
- package/util/stats.test.d.ts +0 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
exports.replayCommandsOntoContext = replayCommandsOntoContext;
|
|
10
|
+
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
|
|
13
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
+
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
var _svg = require("./svg");
|
|
18
|
+
|
|
19
|
+
var _types = require("./types");
|
|
20
|
+
|
|
21
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
22
|
+
|
|
23
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
24
|
+
|
|
25
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
26
|
+
|
|
27
|
+
/** decode all the commands in the given buffer and replay them onto the given context */
|
|
28
|
+
function replayCommandsOntoContext(targetContext, encodedCommands) {
|
|
29
|
+
var _iterator = _createForOfIteratorHelper(encodedCommands),
|
|
30
|
+
_step;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
34
|
+
var command = _step.value;
|
|
35
|
+
|
|
36
|
+
if ((0, _types.isMethodCall)(command)) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
// eslint-disable-next-line prefer-spread
|
|
39
|
+
targetContext[command.name].apply(targetContext, command.args);
|
|
40
|
+
} else {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
targetContext[command.name] = command.args[0];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_iterator.e(err);
|
|
47
|
+
} finally {
|
|
48
|
+
_iterator.f();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var OffscreenCanvasRenderingContext2DShim = /*#__PURE__*/function () {
|
|
53
|
+
function OffscreenCanvasRenderingContext2DShim(width, height) {
|
|
54
|
+
(0, _classCallCheck2.default)(this, OffscreenCanvasRenderingContext2DShim);
|
|
55
|
+
(0, _defineProperty2.default)(this, "width", void 0);
|
|
56
|
+
(0, _defineProperty2.default)(this, "height", void 0);
|
|
57
|
+
(0, _defineProperty2.default)(this, "currentFont", '12px Courier New, monospace');
|
|
58
|
+
(0, _defineProperty2.default)(this, "currentStrokeStyle", '');
|
|
59
|
+
(0, _defineProperty2.default)(this, "currentFillStyle", '');
|
|
60
|
+
(0, _defineProperty2.default)(this, "recordedCommands", []);
|
|
61
|
+
this.width = width;
|
|
62
|
+
this.height = height;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
(0, _createClass2.default)(OffscreenCanvasRenderingContext2DShim, [{
|
|
66
|
+
key: "pushMethodCall",
|
|
67
|
+
value: function pushMethodCall(name, args) {
|
|
68
|
+
this.recordedCommands.push({
|
|
69
|
+
name: name,
|
|
70
|
+
args: args
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "pushSetterCall",
|
|
75
|
+
value: function pushSetterCall(name, arg) {
|
|
76
|
+
this.recordedCommands.push({
|
|
77
|
+
name: name,
|
|
78
|
+
args: [arg]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "getSerializedCommands",
|
|
83
|
+
value: function getSerializedCommands() {
|
|
84
|
+
return this.recordedCommands;
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "getSerializedSvg",
|
|
88
|
+
value: function getSerializedSvg() {
|
|
89
|
+
return (0, _svg.getSerializedSvg)(this);
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getCommands",
|
|
93
|
+
value: function getCommands() {
|
|
94
|
+
return this.recordedCommands;
|
|
95
|
+
} // setters (no getters working)
|
|
96
|
+
|
|
97
|
+
}, {
|
|
98
|
+
key: "strokeStyle",
|
|
99
|
+
set: function set(style) {
|
|
100
|
+
if (style !== this.currentStrokeStyle) {
|
|
101
|
+
this.pushSetterCall('strokeStyle', style);
|
|
102
|
+
this.currentStrokeStyle = style;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "fillStyle",
|
|
107
|
+
set: function set(style) {
|
|
108
|
+
if (style !== this.currentFillStyle) {
|
|
109
|
+
this.pushSetterCall('fillStyle', style);
|
|
110
|
+
this.currentFillStyle = style;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "font",
|
|
115
|
+
set: function set(style) {
|
|
116
|
+
this.currentFont = style;
|
|
117
|
+
this.pushSetterCall('font', style);
|
|
118
|
+
} // methods
|
|
119
|
+
|
|
120
|
+
}, {
|
|
121
|
+
key: "arc",
|
|
122
|
+
value: function arc() {
|
|
123
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
124
|
+
args[_key] = arguments[_key];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.pushMethodCall('arc', args);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "arcTo",
|
|
131
|
+
value: function arcTo() {
|
|
132
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
133
|
+
args[_key2] = arguments[_key2];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.pushMethodCall('arcTo', args);
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "beginPath",
|
|
140
|
+
value: function beginPath() {
|
|
141
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
142
|
+
args[_key3] = arguments[_key3];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.pushMethodCall('beginPath', args);
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "clearRect",
|
|
149
|
+
value: function clearRect() {
|
|
150
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
151
|
+
args[_key4] = arguments[_key4];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.pushMethodCall('clearRect', args);
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "closePath",
|
|
158
|
+
value: function closePath() {
|
|
159
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
160
|
+
args[_key5] = arguments[_key5];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.pushMethodCall('closePath', args);
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "ellipse",
|
|
167
|
+
value: function ellipse() {
|
|
168
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
169
|
+
args[_key6] = arguments[_key6];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.pushMethodCall('ellipse', args);
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "fill",
|
|
176
|
+
value: function fill() {
|
|
177
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
178
|
+
args[_key7] = arguments[_key7];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.pushMethodCall('fill', args);
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "fillRect",
|
|
185
|
+
value: function fillRect() {
|
|
186
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
187
|
+
args[_key8] = arguments[_key8];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var x = args[0],
|
|
191
|
+
y = args[1],
|
|
192
|
+
w = args[2],
|
|
193
|
+
h = args[3];
|
|
194
|
+
|
|
195
|
+
if (x > this.width || x + w < 0) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var nx = Math.max(x, 0);
|
|
200
|
+
var nw = w - (nx - x);
|
|
201
|
+
this.pushMethodCall('fillRect', [nx, y, nw, h]);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "fillText",
|
|
205
|
+
value: function fillText() {
|
|
206
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
207
|
+
args[_key9] = arguments[_key9];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// if (x > this.width || x + 1000 < 0) {
|
|
211
|
+
// return
|
|
212
|
+
// }
|
|
213
|
+
this.pushMethodCall('fillText', args);
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "lineTo",
|
|
217
|
+
value: function lineTo() {
|
|
218
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
219
|
+
args[_key10] = arguments[_key10];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this.pushMethodCall('lineTo', args);
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "measureText",
|
|
226
|
+
value: function measureText() {
|
|
227
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
228
|
+
args[_key11] = arguments[_key11];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
var text = args[0];
|
|
232
|
+
var height = Number((this.currentFont.match(/\d+/) || [])[0]);
|
|
233
|
+
return {
|
|
234
|
+
width: height / 2 * text.length,
|
|
235
|
+
height: height
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "moveTo",
|
|
240
|
+
value: function moveTo() {
|
|
241
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
242
|
+
args[_key12] = arguments[_key12];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
this.pushMethodCall('moveTo', args);
|
|
246
|
+
}
|
|
247
|
+
}, {
|
|
248
|
+
key: "quadraticCurveTo",
|
|
249
|
+
value: function quadraticCurveTo() {
|
|
250
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
251
|
+
args[_key13] = arguments[_key13];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
this.pushMethodCall('quadraticCurveTo', args);
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "rect",
|
|
258
|
+
value: function rect() {
|
|
259
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
260
|
+
args[_key14] = arguments[_key14];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this.pushMethodCall('rect', args);
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "restore",
|
|
267
|
+
value: function restore() {
|
|
268
|
+
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
269
|
+
args[_key15] = arguments[_key15];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
this.pushMethodCall('restore', args);
|
|
273
|
+
}
|
|
274
|
+
}, {
|
|
275
|
+
key: "rotate",
|
|
276
|
+
value: function rotate() {
|
|
277
|
+
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
278
|
+
args[_key16] = arguments[_key16];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
this.pushMethodCall('rotate', args);
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "save",
|
|
285
|
+
value: function save() {
|
|
286
|
+
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
287
|
+
args[_key17] = arguments[_key17];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.pushMethodCall('save', args);
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
key: "setTransform",
|
|
294
|
+
value: function setTransform() {
|
|
295
|
+
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
|
296
|
+
args[_key18] = arguments[_key18];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
this.pushMethodCall('setTransform', args);
|
|
300
|
+
}
|
|
301
|
+
}, {
|
|
302
|
+
key: "scale",
|
|
303
|
+
value: function scale() {
|
|
304
|
+
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
305
|
+
args[_key19] = arguments[_key19];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
this.pushMethodCall('scale', args);
|
|
309
|
+
} //* shim does not support passing a Path2D object */
|
|
310
|
+
|
|
311
|
+
}, {
|
|
312
|
+
key: "stroke",
|
|
313
|
+
value: function stroke() {
|
|
314
|
+
this.pushMethodCall('stroke', []);
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
key: "strokeRect",
|
|
318
|
+
value: function strokeRect() {
|
|
319
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
320
|
+
args[_key20] = arguments[_key20];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
this.pushMethodCall('strokeRect', args);
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
key: "strokeText",
|
|
327
|
+
value: function strokeText() {
|
|
328
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
329
|
+
args[_key21] = arguments[_key21];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
this.pushMethodCall('strokeText', args);
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
key: "transform",
|
|
336
|
+
value: function transform() {
|
|
337
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
338
|
+
args[_key22] = arguments[_key22];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
this.pushMethodCall('transform', args);
|
|
342
|
+
}
|
|
343
|
+
}, {
|
|
344
|
+
key: "translate",
|
|
345
|
+
value: function translate() {
|
|
346
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
347
|
+
args[_key23] = arguments[_key23];
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.pushMethodCall('translate', args);
|
|
351
|
+
}
|
|
352
|
+
}]);
|
|
353
|
+
return OffscreenCanvasRenderingContext2DShim;
|
|
354
|
+
}();
|
|
355
|
+
|
|
356
|
+
exports.default = OffscreenCanvasRenderingContext2DShim;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _context = _interopRequireDefault(require("./context"));
|
|
11
|
+
|
|
12
|
+
var _default = _context.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getSerializedSvg = getSerializedSvg;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _svgPathGenerator = _interopRequireDefault(require("svg-path-generator"));
|
|
19
|
+
|
|
20
|
+
var _util = require("./util");
|
|
21
|
+
|
|
22
|
+
var _types = require("./types");
|
|
23
|
+
|
|
24
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
25
|
+
|
|
26
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
+
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
+
|
|
30
|
+
function getSerializedSvg(ctx) {
|
|
31
|
+
var currentFill;
|
|
32
|
+
var currentStroke;
|
|
33
|
+
var currentPath = [];
|
|
34
|
+
var rotation;
|
|
35
|
+
var font;
|
|
36
|
+
var nodes = [];
|
|
37
|
+
var index = 0;
|
|
38
|
+
|
|
39
|
+
var _iterator = _createForOfIteratorHelper(ctx.getCommands()),
|
|
40
|
+
_step;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
44
|
+
var command = _step.value;
|
|
45
|
+
|
|
46
|
+
if ((0, _types.isSetterCall)(command)) {
|
|
47
|
+
if (command.name === 'font') {
|
|
48
|
+
if (command.args) {
|
|
49
|
+
// stackoverflow.com/questions/5618676
|
|
50
|
+
// skip lineHeight in the final usage
|
|
51
|
+
var _parseFont = (0, _util.parseFont)(command.args[0]),
|
|
52
|
+
fontStyle = _parseFont.fontStyle,
|
|
53
|
+
fontFamily = _parseFont.fontFamily,
|
|
54
|
+
fontSize = _parseFont.fontSize;
|
|
55
|
+
|
|
56
|
+
font = {
|
|
57
|
+
fontStyle: fontStyle,
|
|
58
|
+
fontFamily: fontFamily,
|
|
59
|
+
fontSize: fontSize
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (command.name === 'fillStyle') {
|
|
65
|
+
if (command.args) {
|
|
66
|
+
currentFill = command.args[0];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (command.name === 'strokeStyle') {
|
|
71
|
+
if (command.args) {
|
|
72
|
+
currentStroke = command.args[0];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} else if ((0, _types.isMethodCall)(command)) {
|
|
76
|
+
if (command.name === 'fillRect') {
|
|
77
|
+
var _ref = command.args,
|
|
78
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 4),
|
|
79
|
+
x = _ref2[0],
|
|
80
|
+
y = _ref2[1],
|
|
81
|
+
w = _ref2[2],
|
|
82
|
+
h = _ref2[3];
|
|
83
|
+
|
|
84
|
+
var _splitColor = (0, _util.splitColor)(currentFill),
|
|
85
|
+
hex = _splitColor.hex,
|
|
86
|
+
opacity = _splitColor.opacity;
|
|
87
|
+
|
|
88
|
+
var ny = Math.min(y, y + h);
|
|
89
|
+
var nh = Math.abs(h);
|
|
90
|
+
nodes.push( /*#__PURE__*/_react.default.createElement("rect", {
|
|
91
|
+
key: index,
|
|
92
|
+
fill: hex,
|
|
93
|
+
fillOpacity: opacity !== 1 ? opacity : undefined,
|
|
94
|
+
x: x.toFixed(3),
|
|
95
|
+
y: ny.toFixed(3),
|
|
96
|
+
width: w.toFixed(3),
|
|
97
|
+
height: nh.toFixed(3)
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (command.name === 'fillText') {
|
|
102
|
+
var _ref3 = command.args,
|
|
103
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 3),
|
|
104
|
+
text = _ref4[0],
|
|
105
|
+
_x = _ref4[1],
|
|
106
|
+
_y = _ref4[2];
|
|
107
|
+
|
|
108
|
+
var _splitColor2 = (0, _util.splitColor)(currentFill),
|
|
109
|
+
_hex = _splitColor2.hex,
|
|
110
|
+
_opacity = _splitColor2.opacity;
|
|
111
|
+
|
|
112
|
+
nodes.push( /*#__PURE__*/_react.default.createElement("text", (0, _extends2.default)({
|
|
113
|
+
key: index,
|
|
114
|
+
fill: _hex,
|
|
115
|
+
fillOpacity: _opacity !== 1 ? _opacity : undefined,
|
|
116
|
+
x: _x.toFixed(3),
|
|
117
|
+
y: _y.toFixed(3)
|
|
118
|
+
}, font), text));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (command.name === 'beginPath') {
|
|
122
|
+
currentPath = [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (command.name === 'moveTo') {
|
|
126
|
+
currentPath.push(command.args);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (command.name === 'lineTo') {
|
|
130
|
+
currentPath.push(command.args);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (command.name === 'closePath') {
|
|
134
|
+
/* do nothing */
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (command.name === 'fill') {
|
|
138
|
+
var _Path;
|
|
139
|
+
|
|
140
|
+
var path = (_Path = (0, _svgPathGenerator.default)()).moveTo.apply(_Path, (0, _toConsumableArray2.default)(currentPath[0]));
|
|
141
|
+
|
|
142
|
+
for (var i = 1; i < currentPath.length; i++) {
|
|
143
|
+
var _path;
|
|
144
|
+
|
|
145
|
+
path = (_path = path).lineTo.apply(_path, (0, _toConsumableArray2.default)(currentPath[i]));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
path.end();
|
|
149
|
+
|
|
150
|
+
var _splitColor3 = (0, _util.splitColor)(currentFill),
|
|
151
|
+
_hex2 = _splitColor3.hex,
|
|
152
|
+
_opacity2 = _splitColor3.opacity;
|
|
153
|
+
|
|
154
|
+
nodes.push( /*#__PURE__*/_react.default.createElement("path", {
|
|
155
|
+
key: index,
|
|
156
|
+
fill: _hex2,
|
|
157
|
+
d: path,
|
|
158
|
+
fillOpacity: _opacity2 !== 1 ? _opacity2 : undefined
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (command.name === 'stroke') {
|
|
163
|
+
var _Path2;
|
|
164
|
+
|
|
165
|
+
var _path2 = (_Path2 = (0, _svgPathGenerator.default)()).moveTo.apply(_Path2, (0, _toConsumableArray2.default)(currentPath[0]));
|
|
166
|
+
|
|
167
|
+
for (var _i = 1; _i < currentPath.length; _i++) {
|
|
168
|
+
var _path3;
|
|
169
|
+
|
|
170
|
+
_path2 = (_path3 = _path2).lineTo.apply(_path3, (0, _toConsumableArray2.default)(currentPath[_i]));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_path2.end();
|
|
174
|
+
|
|
175
|
+
var _splitColor4 = (0, _util.splitColor)(currentStroke),
|
|
176
|
+
_hex3 = _splitColor4.hex,
|
|
177
|
+
_opacity3 = _splitColor4.opacity;
|
|
178
|
+
|
|
179
|
+
nodes.push( /*#__PURE__*/_react.default.createElement("path", {
|
|
180
|
+
key: index,
|
|
181
|
+
fill: "none",
|
|
182
|
+
stroke: _hex3,
|
|
183
|
+
fillOpacity: _opacity3 !== 1 ? _opacity3 : undefined,
|
|
184
|
+
d: _path2
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (command.name === 'rotate') {
|
|
189
|
+
var _ref5 = command.args,
|
|
190
|
+
_ref6 = (0, _slicedToArray2.default)(_ref5, 1),
|
|
191
|
+
radians = _ref6[0];
|
|
192
|
+
|
|
193
|
+
rotation = radians * 180 / Math.PI;
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
throw new Error('invalid call');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
index++;
|
|
200
|
+
}
|
|
201
|
+
} catch (err) {
|
|
202
|
+
_iterator.e(err);
|
|
203
|
+
} finally {
|
|
204
|
+
_iterator.f();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return rotation ? /*#__PURE__*/_react.default.createElement("g", {
|
|
208
|
+
transform: "rotate(".concat(rotation, ")")
|
|
209
|
+
}, [].concat(nodes)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, [].concat(nodes));
|
|
210
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface Command {
|
|
2
|
+
name: string;
|
|
3
|
+
args: unknown[];
|
|
4
|
+
}
|
|
5
|
+
export declare enum CallSchemaField {
|
|
6
|
+
STRING = 0,
|
|
7
|
+
FLOAT = 1,
|
|
8
|
+
BOOL = 2,
|
|
9
|
+
FOLLOWING_ARGUMENTS_OPTIONAL = 3
|
|
10
|
+
}
|
|
11
|
+
export declare const setterDataTypes: {
|
|
12
|
+
strokeStyle: CallSchemaField[];
|
|
13
|
+
font: CallSchemaField[];
|
|
14
|
+
fillStyle: CallSchemaField[];
|
|
15
|
+
};
|
|
16
|
+
export declare const methodSignatures: {
|
|
17
|
+
arc: CallSchemaField[];
|
|
18
|
+
arcTo: CallSchemaField[];
|
|
19
|
+
beginPath: never[];
|
|
20
|
+
clearRect: CallSchemaField[];
|
|
21
|
+
closePath: never[];
|
|
22
|
+
ellipse: CallSchemaField[];
|
|
23
|
+
fill: CallSchemaField[];
|
|
24
|
+
fillRect: CallSchemaField[];
|
|
25
|
+
fillText: CallSchemaField[];
|
|
26
|
+
lineTo: CallSchemaField[];
|
|
27
|
+
moveTo: CallSchemaField[];
|
|
28
|
+
quadraticCurveTo: CallSchemaField[];
|
|
29
|
+
rect: CallSchemaField[];
|
|
30
|
+
restore: never[];
|
|
31
|
+
rotate: CallSchemaField[];
|
|
32
|
+
save: never[];
|
|
33
|
+
setTransform: CallSchemaField[];
|
|
34
|
+
scale: CallSchemaField[];
|
|
35
|
+
stroke: never[];
|
|
36
|
+
strokeRect: CallSchemaField[];
|
|
37
|
+
strokeText: CallSchemaField[];
|
|
38
|
+
transform: CallSchemaField[];
|
|
39
|
+
translate: CallSchemaField[];
|
|
40
|
+
};
|
|
41
|
+
export declare type SetterName = keyof typeof setterDataTypes;
|
|
42
|
+
export declare type MethodName = keyof typeof methodSignatures;
|
|
43
|
+
export interface SetterCall extends Command {
|
|
44
|
+
name: SetterName;
|
|
45
|
+
}
|
|
46
|
+
export interface MethodCall extends Command {
|
|
47
|
+
name: MethodName;
|
|
48
|
+
}
|
|
49
|
+
export declare function isMethodCall(call: Command): call is MethodCall;
|
|
50
|
+
export declare function isSetterCall(call: Command): call is SetterCall;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CallSchemaField = void 0;
|
|
7
|
+
exports.isMethodCall = isMethodCall;
|
|
8
|
+
exports.isSetterCall = isSetterCall;
|
|
9
|
+
exports.setterDataTypes = exports.methodSignatures = void 0;
|
|
10
|
+
var CallSchemaField;
|
|
11
|
+
exports.CallSchemaField = CallSchemaField;
|
|
12
|
+
|
|
13
|
+
(function (CallSchemaField) {
|
|
14
|
+
CallSchemaField[CallSchemaField["STRING"] = 0] = "STRING";
|
|
15
|
+
CallSchemaField[CallSchemaField["FLOAT"] = 1] = "FLOAT";
|
|
16
|
+
CallSchemaField[CallSchemaField["BOOL"] = 2] = "BOOL";
|
|
17
|
+
CallSchemaField[CallSchemaField["FOLLOWING_ARGUMENTS_OPTIONAL"] = 3] = "FOLLOWING_ARGUMENTS_OPTIONAL";
|
|
18
|
+
})(CallSchemaField || (exports.CallSchemaField = CallSchemaField = {}));
|
|
19
|
+
|
|
20
|
+
var setterDataTypes = {
|
|
21
|
+
strokeStyle: [CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.STRING],
|
|
22
|
+
font: [CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.STRING],
|
|
23
|
+
fillStyle: [CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.STRING]
|
|
24
|
+
};
|
|
25
|
+
exports.setterDataTypes = setterDataTypes;
|
|
26
|
+
var methodSignatures = {
|
|
27
|
+
arc: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.BOOL],
|
|
28
|
+
arcTo: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
29
|
+
beginPath: [],
|
|
30
|
+
clearRect: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
31
|
+
closePath: [],
|
|
32
|
+
ellipse: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.BOOL],
|
|
33
|
+
fill: [CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.STRING],
|
|
34
|
+
fillRect: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
35
|
+
fillText: [CallSchemaField.STRING, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.FLOAT],
|
|
36
|
+
lineTo: [CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
37
|
+
moveTo: [CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
38
|
+
quadraticCurveTo: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
39
|
+
rect: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
40
|
+
restore: [],
|
|
41
|
+
rotate: [CallSchemaField.FLOAT],
|
|
42
|
+
save: [],
|
|
43
|
+
setTransform: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
44
|
+
scale: [CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
45
|
+
stroke: [],
|
|
46
|
+
strokeRect: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
47
|
+
strokeText: [CallSchemaField.STRING, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FOLLOWING_ARGUMENTS_OPTIONAL, CallSchemaField.FLOAT],
|
|
48
|
+
transform: [CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT, CallSchemaField.FLOAT],
|
|
49
|
+
translate: [CallSchemaField.FLOAT, CallSchemaField.FLOAT]
|
|
50
|
+
};
|
|
51
|
+
exports.methodSignatures = methodSignatures;
|
|
52
|
+
|
|
53
|
+
function isMethodCall(call) {
|
|
54
|
+
return Boolean(call.name in methodSignatures);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isSetterCall(call) {
|
|
58
|
+
return Boolean(call.name in setterDataTypes);
|
|
59
|
+
}
|