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