@antv/g-canvas 1.1.6 → 1.1.8-alpha.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/dist/Canvas2DContextService.d.ts +1 -1
- package/dist/Canvas2DContextService.d.ts.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +485 -199
- package/dist/index.js +475 -210
- package/dist/index.umd.js +5069 -5544
- package/dist/index.umd.min.js +9 -5
- package/package.json +9 -6
package/dist/index.esm.js
CHANGED
|
@@ -1,132 +1,412 @@
|
|
|
1
|
-
import { CanvasConfig, ContextService,
|
|
2
|
-
import { Plugin as Plugin$1 } from '@antv/g-plugin-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { Plugin } from '@antv/g-plugin-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { Plugin as Plugin$2 } from '@antv/g-plugin-canvas-picker';
|
|
9
|
-
import * as CanvasPicker from '@antv/g-plugin-canvas-picker';
|
|
10
|
-
export { CanvasPicker };
|
|
11
|
-
import { Plugin as Plugin$3 } from '@antv/g-plugin-html-renderer';
|
|
12
|
-
import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
|
|
13
|
-
export { HTMLRenderer };
|
|
1
|
+
import { CanvasConfig, ContextService, setDOMSize, isString, isBrowser, AbstractRenderer } from '@antv/g';
|
|
2
|
+
import { Plugin as Plugin$1 } from '@antv/g-plugin-canvas-path-generator';
|
|
3
|
+
import { Plugin as Plugin$4 } from '@antv/g-plugin-canvas-picker';
|
|
4
|
+
import { Plugin as Plugin$2 } from '@antv/g-plugin-canvas-renderer';
|
|
5
|
+
import { Plugin as Plugin$3 } from '@antv/g-plugin-dom-interaction';
|
|
6
|
+
import { Plugin as Plugin$5 } from '@antv/g-plugin-html-renderer';
|
|
7
|
+
import { Plugin } from '@antv/g-plugin-image-loader';
|
|
14
8
|
import { inject, singleton, Module } from 'mana-syringe';
|
|
15
9
|
import { __decorate, __metadata } from 'tslib';
|
|
16
10
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
function _regeneratorRuntime() {
|
|
12
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
13
|
+
|
|
14
|
+
_regeneratorRuntime = function () {
|
|
15
|
+
return exports;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var exports = {},
|
|
19
|
+
Op = Object.prototype,
|
|
20
|
+
hasOwn = Op.hasOwnProperty,
|
|
21
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
22
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
23
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
24
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
25
|
+
|
|
26
|
+
function define(obj, key, value) {
|
|
27
|
+
return Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: !0,
|
|
30
|
+
configurable: !0,
|
|
31
|
+
writable: !0
|
|
32
|
+
}), obj[key];
|
|
20
33
|
}
|
|
21
|
-
}
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
35
|
+
try {
|
|
36
|
+
define({}, "");
|
|
37
|
+
} catch (err) {
|
|
38
|
+
define = function (obj, key, value) {
|
|
39
|
+
return obj[key] = value;
|
|
40
|
+
};
|
|
30
41
|
}
|
|
31
|
-
}
|
|
32
42
|
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
44
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
45
|
+
generator = Object.create(protoGenerator.prototype),
|
|
46
|
+
context = new Context(tryLocsList || []);
|
|
47
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
48
|
+
var state = "suspendedStart";
|
|
49
|
+
return function (method, arg) {
|
|
50
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
51
|
+
|
|
52
|
+
if ("completed" === state) {
|
|
53
|
+
if ("throw" === method) throw arg;
|
|
54
|
+
return doneResult();
|
|
55
|
+
}
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
for (context.method = method, context.arg = arg;;) {
|
|
58
|
+
var delegate = context.delegate;
|
|
59
|
+
|
|
60
|
+
if (delegate) {
|
|
61
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
62
|
+
|
|
63
|
+
if (delegateResult) {
|
|
64
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
65
|
+
return delegateResult;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
70
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
71
|
+
context.dispatchException(context.arg);
|
|
72
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
73
|
+
state = "executing";
|
|
74
|
+
var record = tryCatch(innerFn, self, context);
|
|
75
|
+
|
|
76
|
+
if ("normal" === record.type) {
|
|
77
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
78
|
+
return {
|
|
79
|
+
value: record.arg,
|
|
80
|
+
done: context.done
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}(innerFn, self, context), generator;
|
|
45
88
|
}
|
|
46
89
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
90
|
+
function tryCatch(fn, obj, arg) {
|
|
91
|
+
try {
|
|
92
|
+
return {
|
|
93
|
+
type: "normal",
|
|
94
|
+
arg: fn.call(obj, arg)
|
|
95
|
+
};
|
|
96
|
+
} catch (err) {
|
|
97
|
+
return {
|
|
98
|
+
type: "throw",
|
|
99
|
+
arg: err
|
|
100
|
+
};
|
|
52
101
|
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.wrap = wrap;
|
|
105
|
+
var ContinueSentinel = {};
|
|
106
|
+
|
|
107
|
+
function Generator() {}
|
|
108
|
+
|
|
109
|
+
function GeneratorFunction() {}
|
|
110
|
+
|
|
111
|
+
function GeneratorFunctionPrototype() {}
|
|
112
|
+
|
|
113
|
+
var IteratorPrototype = {};
|
|
114
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
115
|
+
return this;
|
|
53
116
|
});
|
|
54
|
-
Object.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
117
|
+
var getProto = Object.getPrototypeOf,
|
|
118
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
119
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
120
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
121
|
+
|
|
122
|
+
function defineIteratorMethods(prototype) {
|
|
123
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
124
|
+
define(prototype, method, function (arg) {
|
|
125
|
+
return this._invoke(method, arg);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
59
129
|
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
130
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
131
|
+
function invoke(method, arg, resolve, reject) {
|
|
132
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
133
|
+
|
|
134
|
+
if ("throw" !== record.type) {
|
|
135
|
+
var result = record.arg,
|
|
136
|
+
value = result.value;
|
|
137
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
138
|
+
invoke("next", value, resolve, reject);
|
|
139
|
+
}, function (err) {
|
|
140
|
+
invoke("throw", err, resolve, reject);
|
|
141
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
142
|
+
result.value = unwrapped, resolve(result);
|
|
143
|
+
}, function (error) {
|
|
144
|
+
return invoke("throw", error, resolve, reject);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
66
147
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
o.__proto__ = p;
|
|
70
|
-
return o;
|
|
71
|
-
};
|
|
148
|
+
reject(record.arg);
|
|
149
|
+
}
|
|
72
150
|
|
|
73
|
-
|
|
74
|
-
}
|
|
151
|
+
var previousPromise;
|
|
75
152
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
153
|
+
this._invoke = function (method, arg) {
|
|
154
|
+
function callInvokeWithMethodAndArg() {
|
|
155
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
156
|
+
invoke(method, arg, resolve, reject);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
80
159
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
160
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
165
|
+
var method = delegate.iterator[context.method];
|
|
166
|
+
|
|
167
|
+
if (undefined === method) {
|
|
168
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
169
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
170
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return ContinueSentinel;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
177
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
178
|
+
var info = record.arg;
|
|
179
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function pushTryEntry(locs) {
|
|
183
|
+
var entry = {
|
|
184
|
+
tryLoc: locs[0]
|
|
185
|
+
};
|
|
186
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function resetTryEntry(entry) {
|
|
190
|
+
var record = entry.completion || {};
|
|
191
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
86
192
|
}
|
|
87
|
-
}
|
|
88
193
|
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
194
|
+
function Context(tryLocsList) {
|
|
195
|
+
this.tryEntries = [{
|
|
196
|
+
tryLoc: "root"
|
|
197
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
92
198
|
}
|
|
93
199
|
|
|
94
|
-
|
|
200
|
+
function values(iterable) {
|
|
201
|
+
if (iterable) {
|
|
202
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
203
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
204
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
205
|
+
|
|
206
|
+
if (!isNaN(iterable.length)) {
|
|
207
|
+
var i = -1,
|
|
208
|
+
next = function next() {
|
|
209
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
210
|
+
|
|
211
|
+
return next.value = undefined, next.done = !0, next;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
return next.next = next;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
next: doneResult
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function doneResult() {
|
|
224
|
+
return {
|
|
225
|
+
value: undefined,
|
|
226
|
+
done: !0
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
231
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
232
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
233
|
+
}, exports.mark = function (genFun) {
|
|
234
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
235
|
+
}, exports.awrap = function (arg) {
|
|
236
|
+
return {
|
|
237
|
+
__await: arg
|
|
238
|
+
};
|
|
239
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
240
|
+
return this;
|
|
241
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
242
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
243
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
244
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
245
|
+
return result.done ? result.value : iter.next();
|
|
246
|
+
});
|
|
247
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
248
|
+
return this;
|
|
249
|
+
}), define(Gp, "toString", function () {
|
|
250
|
+
return "[object Generator]";
|
|
251
|
+
}), exports.keys = function (object) {
|
|
252
|
+
var keys = [];
|
|
253
|
+
|
|
254
|
+
for (var key in object) keys.push(key);
|
|
255
|
+
|
|
256
|
+
return keys.reverse(), function next() {
|
|
257
|
+
for (; keys.length;) {
|
|
258
|
+
var key = keys.pop();
|
|
259
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return next.done = !0, next;
|
|
263
|
+
};
|
|
264
|
+
}, exports.values = values, Context.prototype = {
|
|
265
|
+
constructor: Context,
|
|
266
|
+
reset: function (skipTempReset) {
|
|
267
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
268
|
+
},
|
|
269
|
+
stop: function () {
|
|
270
|
+
this.done = !0;
|
|
271
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
272
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
273
|
+
return this.rval;
|
|
274
|
+
},
|
|
275
|
+
dispatchException: function (exception) {
|
|
276
|
+
if (this.done) throw exception;
|
|
277
|
+
var context = this;
|
|
278
|
+
|
|
279
|
+
function handle(loc, caught) {
|
|
280
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
284
|
+
var entry = this.tryEntries[i],
|
|
285
|
+
record = entry.completion;
|
|
286
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
287
|
+
|
|
288
|
+
if (entry.tryLoc <= this.prev) {
|
|
289
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
290
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
291
|
+
|
|
292
|
+
if (hasCatch && hasFinally) {
|
|
293
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
294
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
295
|
+
} else if (hasCatch) {
|
|
296
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
297
|
+
} else {
|
|
298
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
299
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
abrupt: function (type, arg) {
|
|
305
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
306
|
+
var entry = this.tryEntries[i];
|
|
307
|
+
|
|
308
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
309
|
+
var finallyEntry = entry;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
315
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
316
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
317
|
+
},
|
|
318
|
+
complete: function (record, afterLoc) {
|
|
319
|
+
if ("throw" === record.type) throw record.arg;
|
|
320
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
321
|
+
},
|
|
322
|
+
finish: function (finallyLoc) {
|
|
323
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
324
|
+
var entry = this.tryEntries[i];
|
|
325
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
catch: function (tryLoc) {
|
|
329
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
330
|
+
var entry = this.tryEntries[i];
|
|
331
|
+
|
|
332
|
+
if (entry.tryLoc === tryLoc) {
|
|
333
|
+
var record = entry.completion;
|
|
334
|
+
|
|
335
|
+
if ("throw" === record.type) {
|
|
336
|
+
var thrown = record.arg;
|
|
337
|
+
resetTryEntry(entry);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return thrown;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
throw new Error("illegal catch attempt");
|
|
345
|
+
},
|
|
346
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
347
|
+
return this.delegate = {
|
|
348
|
+
iterator: values(iterable),
|
|
349
|
+
resultName: resultName,
|
|
350
|
+
nextLoc: nextLoc
|
|
351
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
352
|
+
}
|
|
353
|
+
}, exports;
|
|
95
354
|
}
|
|
96
355
|
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
356
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
357
|
+
try {
|
|
358
|
+
var info = gen[key](arg);
|
|
359
|
+
var value = info.value;
|
|
360
|
+
} catch (error) {
|
|
361
|
+
reject(error);
|
|
362
|
+
return;
|
|
102
363
|
}
|
|
103
364
|
|
|
104
|
-
|
|
365
|
+
if (info.done) {
|
|
366
|
+
resolve(value);
|
|
367
|
+
} else {
|
|
368
|
+
Promise.resolve(value).then(_next, _throw);
|
|
369
|
+
}
|
|
105
370
|
}
|
|
106
371
|
|
|
107
|
-
function
|
|
108
|
-
|
|
372
|
+
function _asyncToGenerator(fn) {
|
|
373
|
+
return function () {
|
|
374
|
+
var self = this,
|
|
375
|
+
args = arguments;
|
|
376
|
+
return new Promise(function (resolve, reject) {
|
|
377
|
+
var gen = fn.apply(self, args);
|
|
109
378
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
379
|
+
function _next(value) {
|
|
380
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
381
|
+
}
|
|
113
382
|
|
|
114
|
-
|
|
115
|
-
|
|
383
|
+
function _throw(err) {
|
|
384
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
385
|
+
}
|
|
116
386
|
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
387
|
+
_next(undefined);
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function _inheritsLoose(subClass, superClass) {
|
|
393
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
394
|
+
subClass.prototype.constructor = subClass;
|
|
395
|
+
|
|
396
|
+
_setPrototypeOf(subClass, superClass);
|
|
397
|
+
}
|
|
121
398
|
|
|
122
|
-
|
|
399
|
+
function _setPrototypeOf(o, p) {
|
|
400
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
401
|
+
o.__proto__ = p;
|
|
402
|
+
return o;
|
|
123
403
|
};
|
|
404
|
+
|
|
405
|
+
return _setPrototypeOf(o, p);
|
|
124
406
|
}
|
|
125
407
|
|
|
126
408
|
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
127
409
|
function Canvas2DContextService() {
|
|
128
|
-
_classCallCheck(this, Canvas2DContextService);
|
|
129
|
-
|
|
130
410
|
this.$container = void 0;
|
|
131
411
|
this.$canvas = void 0;
|
|
132
412
|
this.dpr = void 0;
|
|
@@ -134,102 +414,112 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
134
414
|
this.canvasConfig = void 0;
|
|
135
415
|
}
|
|
136
416
|
|
|
137
|
-
|
|
138
|
-
key: "init",
|
|
139
|
-
value: function init() {
|
|
140
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
141
|
-
container = _this$canvasConfig.container,
|
|
142
|
-
canvas = _this$canvasConfig.canvas,
|
|
143
|
-
devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
417
|
+
var _proto = Canvas2DContextService.prototype;
|
|
144
418
|
|
|
145
|
-
|
|
146
|
-
|
|
419
|
+
_proto.init = /*#__PURE__*/function () {
|
|
420
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
421
|
+
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
147
422
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
423
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
424
|
+
while (1) {
|
|
425
|
+
switch (_context.prev = _context.next) {
|
|
426
|
+
case 0:
|
|
427
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
151
428
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
} else if (container) {
|
|
155
|
-
// create container
|
|
156
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
429
|
+
if (canvas) {
|
|
430
|
+
this.$canvas = canvas;
|
|
157
431
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.$container.appendChild($canvas);
|
|
432
|
+
if (container && canvas.parentElement !== container) {
|
|
433
|
+
container.appendChild(canvas);
|
|
434
|
+
}
|
|
162
435
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
436
|
+
this.$container = canvas.parentElement;
|
|
437
|
+
this.canvasConfig.container = this.$container;
|
|
438
|
+
} else if (container) {
|
|
439
|
+
// create container
|
|
440
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
166
441
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
442
|
+
if (this.$container) {
|
|
443
|
+
// create canvas
|
|
444
|
+
$canvas = document.createElement('canvas');
|
|
445
|
+
this.$container.appendChild($canvas);
|
|
170
446
|
|
|
171
|
-
|
|
447
|
+
if (!this.$container.style.position) {
|
|
448
|
+
this.$container.style.position = 'relative';
|
|
449
|
+
}
|
|
172
450
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
451
|
+
this.$canvas = $canvas;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
|
|
456
|
+
|
|
457
|
+
dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
458
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
459
|
+
this.dpr = dpr;
|
|
460
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
461
|
+
|
|
462
|
+
case 7:
|
|
463
|
+
case "end":
|
|
464
|
+
return _context.stop();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}, _callee, this);
|
|
468
|
+
}));
|
|
469
|
+
|
|
470
|
+
function init() {
|
|
471
|
+
return _init.apply(this, arguments);
|
|
192
472
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
473
|
+
|
|
474
|
+
return init;
|
|
475
|
+
}();
|
|
476
|
+
|
|
477
|
+
_proto.getContext = function getContext() {
|
|
478
|
+
return this.context;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
_proto.getDomElement = function getDomElement() {
|
|
482
|
+
return this.$canvas;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
_proto.getDPR = function getDPR() {
|
|
486
|
+
return this.dpr;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
490
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
491
|
+
return this.$canvas.getBoundingClientRect();
|
|
199
492
|
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
_proto.destroy = function destroy() {
|
|
496
|
+
// @ts-ignore
|
|
497
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
498
|
+
// destroy context
|
|
203
499
|
// @ts-ignore
|
|
204
|
-
|
|
205
|
-
// destroy context
|
|
206
|
-
// @ts-ignore
|
|
207
|
-
this.$container.removeChild(this.$canvas);
|
|
208
|
-
}
|
|
500
|
+
this.$container.removeChild(this.$canvas);
|
|
209
501
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
_proto.resize = function resize(width, height) {
|
|
505
|
+
if (this.$canvas) {
|
|
506
|
+
// set canvas width & height
|
|
507
|
+
this.$canvas.width = this.dpr * width;
|
|
508
|
+
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
509
|
+
|
|
510
|
+
setDOMSize(this.$canvas, width, height);
|
|
511
|
+
var dpr = this.getDPR(); // scale all drawing operations by the dpr
|
|
512
|
+
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
513
|
+
|
|
514
|
+
this.context.scale(dpr, dpr);
|
|
224
515
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
519
|
+
if (this.$container && this.$container.style) {
|
|
520
|
+
this.$container.style.cursor = cursor;
|
|
231
521
|
}
|
|
232
|
-
}
|
|
522
|
+
};
|
|
233
523
|
|
|
234
524
|
return Canvas2DContextService;
|
|
235
525
|
}();
|
|
@@ -248,55 +538,51 @@ var containerModule = Module(function (register) {
|
|
|
248
538
|
});
|
|
249
539
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
250
540
|
function ContextRegisterPlugin() {
|
|
251
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
252
|
-
|
|
253
541
|
this.name = 'canvas-context-register';
|
|
254
542
|
}
|
|
255
543
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
}]);
|
|
544
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
545
|
+
|
|
546
|
+
_proto.init = function init(container) {
|
|
547
|
+
container.load(containerModule, true);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
_proto.destroy = function destroy(container) {
|
|
551
|
+
container.unload(containerModule);
|
|
552
|
+
};
|
|
267
553
|
|
|
268
554
|
return ContextRegisterPlugin;
|
|
269
555
|
}();
|
|
270
556
|
|
|
271
557
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var _super = _createSuper(Renderer);
|
|
558
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
275
559
|
|
|
276
560
|
function Renderer(config) {
|
|
277
561
|
var _this;
|
|
278
562
|
|
|
279
|
-
|
|
563
|
+
_this = _AbstractRenderer.call(this, config) || this; // register Canvas2DContext
|
|
564
|
+
|
|
565
|
+
_this.registerPlugin(new ContextRegisterPlugin());
|
|
280
566
|
|
|
281
|
-
_this
|
|
567
|
+
_this.registerPlugin(new Plugin());
|
|
282
568
|
|
|
283
|
-
_this.registerPlugin(new
|
|
569
|
+
_this.registerPlugin(new Plugin$1()); // enable rendering with Canvas2D API
|
|
284
570
|
|
|
285
571
|
|
|
286
|
-
_this.registerPlugin(new Plugin());
|
|
572
|
+
_this.registerPlugin(new Plugin$2());
|
|
287
573
|
|
|
288
|
-
_this.registerPlugin(new Plugin$
|
|
574
|
+
_this.registerPlugin(new Plugin$3()); // enable picking with Canvas2D API
|
|
289
575
|
|
|
290
576
|
|
|
291
|
-
_this.registerPlugin(new Plugin$
|
|
577
|
+
_this.registerPlugin(new Plugin$4()); // render HTML component
|
|
292
578
|
|
|
293
579
|
|
|
294
|
-
_this.registerPlugin(new Plugin$
|
|
580
|
+
_this.registerPlugin(new Plugin$5());
|
|
295
581
|
|
|
296
582
|
return _this;
|
|
297
583
|
}
|
|
298
584
|
|
|
299
|
-
return
|
|
585
|
+
return Renderer;
|
|
300
586
|
}(AbstractRenderer);
|
|
301
587
|
|
|
302
588
|
export { Renderer };
|