@antv/g-canvas 1.1.7 → 1.1.8-alpha.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.
@@ -6,7 +6,7 @@ export declare class Canvas2DContextService implements ContextService<CanvasRend
6
6
  private dpr;
7
7
  private context;
8
8
  private canvasConfig;
9
- init(): void;
9
+ init(): Promise<void>;
10
10
  getContext(): CanvasRenderingContext2D;
11
11
  getDomElement(): CanvasLike;
12
12
  getDPR(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas2DContextService.d.ts","sourceRoot":"","sources":["../src/Canvas2DContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAgB,cAAc,EAAmC,MAAM,SAAS,CAAC;AAGxF,qBACa,sBAAuB,YAAW,cAAc,CAAC,wBAAwB,CAAC;IACrF,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAAsE;IAGrF,OAAO,CAAC,YAAY,CAAe;IAEnC,IAAI;IAoCJ,UAAU;IAIV,aAAa;IAIb,MAAM;IAIN,qBAAqB;IAMrB,OAAO;IASP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAgBpC,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
1
+ {"version":3,"file":"Canvas2DContextService.d.ts","sourceRoot":"","sources":["../src/Canvas2DContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAgB,cAAc,EAAmC,MAAM,SAAS,CAAC;AAGxF,qBACa,sBAAuB,YAAW,cAAc,CAAC,wBAAwB,CAAC;IACrF,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAAsE;IAGrF,OAAO,CAAC,YAAY,CAAe;IAE7B,IAAI;IAoCV,UAAU;IAIV,aAAa;IAIb,MAAM;IAIN,qBAAqB;IAMrB,OAAO;IASP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAgBpC,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import type { RendererConfig } from '@antv/g';
2
2
  import { AbstractRenderer } from '@antv/g';
3
- import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
- import * as CanvasRenderer from '@antv/g-plugin-canvas-renderer';
5
- import * as CanvasPicker from '@antv/g-plugin-canvas-picker';
6
- import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
7
- export { DomInteraction, CanvasRenderer, CanvasPicker, HTMLRenderer };
8
3
  export declare class Renderer extends AbstractRenderer {
9
4
  constructor(config?: Partial<RendererConfig>);
10
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAEtE,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;CAc7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAS3C,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;CAgB7C"}
package/dist/index.esm.js CHANGED
@@ -1,19 +1,394 @@
1
- import { CanvasConfig, ContextService, isString, setDOMSize, isBrowser, AbstractRenderer } from '@antv/g';
2
- import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
3
- import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
- export { DomInteraction };
5
- import { Plugin } from '@antv/g-plugin-canvas-renderer';
6
- import * as CanvasRenderer from '@antv/g-plugin-canvas-renderer';
7
- export { CanvasRenderer };
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
 
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];
33
+ }
34
+
35
+ try {
36
+ define({}, "");
37
+ } catch (err) {
38
+ define = function (obj, key, value) {
39
+ return obj[key] = value;
40
+ };
41
+ }
42
+
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
+ }
56
+
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;
88
+ }
89
+
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
+ };
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;
116
+ });
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
+ }
129
+
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
+ }
147
+
148
+ reject(record.arg);
149
+ }
150
+
151
+ var previousPromise;
152
+
153
+ this._invoke = function (method, arg) {
154
+ function callInvokeWithMethodAndArg() {
155
+ return new PromiseImpl(function (resolve, reject) {
156
+ invoke(method, arg, resolve, reject);
157
+ });
158
+ }
159
+
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;
192
+ }
193
+
194
+ function Context(tryLocsList) {
195
+ this.tryEntries = [{
196
+ tryLoc: "root"
197
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
198
+ }
199
+
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;
354
+ }
355
+
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;
363
+ }
364
+
365
+ if (info.done) {
366
+ resolve(value);
367
+ } else {
368
+ Promise.resolve(value).then(_next, _throw);
369
+ }
370
+ }
371
+
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);
378
+
379
+ function _next(value) {
380
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
381
+ }
382
+
383
+ function _throw(err) {
384
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
385
+ }
386
+
387
+ _next(undefined);
388
+ });
389
+ };
390
+ }
391
+
17
392
  function _inheritsLoose(subClass, superClass) {
18
393
  subClass.prototype = Object.create(superClass.prototype);
19
394
  subClass.prototype.constructor = subClass;
@@ -41,45 +416,63 @@ var Canvas2DContextService = /*#__PURE__*/function () {
41
416
 
42
417
  var _proto = Canvas2DContextService.prototype;
43
418
 
44
- _proto.init = function init() {
45
- var _this$canvasConfig = this.canvasConfig,
46
- container = _this$canvasConfig.container,
47
- canvas = _this$canvasConfig.canvas,
48
- devicePixelRatio = _this$canvasConfig.devicePixelRatio;
49
-
50
- if (canvas) {
51
- this.$canvas = canvas;
52
-
53
- if (container && canvas.parentElement !== container) {
54
- container.appendChild(canvas);
55
- }
56
-
57
- this.$container = canvas.parentElement;
58
- this.canvasConfig.container = this.$container;
59
- } else if (container) {
60
- // create container
61
- this.$container = isString(container) ? document.getElementById(container) : container;
62
-
63
- if (this.$container) {
64
- // create canvas
65
- var $canvas = document.createElement('canvas');
66
- this.$container.appendChild($canvas);
67
-
68
- if (!this.$container.style.position) {
69
- this.$container.style.position = 'relative';
419
+ _proto.init = /*#__PURE__*/function () {
420
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
421
+ var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
422
+
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;
428
+
429
+ if (canvas) {
430
+ this.$canvas = canvas;
431
+
432
+ if (container && canvas.parentElement !== container) {
433
+ container.appendChild(canvas);
434
+ }
435
+
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;
441
+
442
+ if (this.$container) {
443
+ // create canvas
444
+ $canvas = document.createElement('canvas');
445
+ this.$container.appendChild($canvas);
446
+
447
+ if (!this.$container.style.position) {
448
+ this.$container.style.position = 'relative';
449
+ }
450
+
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
+ }
70
466
  }
467
+ }, _callee, this);
468
+ }));
71
469
 
72
- this.$canvas = $canvas;
73
- }
470
+ function init() {
471
+ return _init.apply(this, arguments);
74
472
  }
75
473
 
76
- this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
77
-
78
- var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
79
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
80
- this.dpr = dpr;
81
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
82
- };
474
+ return init;
475
+ }();
83
476
 
84
477
  _proto.getContext = function getContext() {
85
478
  return this.context;
@@ -169,18 +562,22 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
169
562
 
170
563
  _this = _AbstractRenderer.call(this, config) || this; // register Canvas2DContext
171
564
 
172
- _this.registerPlugin(new ContextRegisterPlugin()); // enable rendering with Canvas2D API
173
-
565
+ _this.registerPlugin(new ContextRegisterPlugin());
174
566
 
175
567
  _this.registerPlugin(new Plugin());
176
568
 
177
- _this.registerPlugin(new Plugin$1()); // enable picking with Canvas2D API
569
+ _this.registerPlugin(new Plugin$1()); // enable rendering with Canvas2D API
570
+
571
+
572
+ _this.registerPlugin(new Plugin$2());
573
+
574
+ _this.registerPlugin(new Plugin$3()); // enable picking with Canvas2D API
178
575
 
179
576
 
180
- _this.registerPlugin(new Plugin$2()); // render HTML component
577
+ _this.registerPlugin(new Plugin$4()); // render HTML component
181
578
 
182
579
 
183
- _this.registerPlugin(new Plugin$3());
580
+ _this.registerPlugin(new Plugin$5());
184
581
 
185
582
  return _this;
186
583
  }