@antv/g-webgpu 1.7.71 → 1.7.72

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/index.umd.js CHANGED
@@ -6899,6 +6899,7 @@
6899
6899
  * Render Graph builder at each frame
6900
6900
  */
6901
6901
  this.builder = void 0;
6902
+ this.pendingDisplayObjects = [];
6902
6903
  this.enableCapture = void 0;
6903
6904
  this.captureOptions = void 0;
6904
6905
  this.capturePromise = void 0;
@@ -6940,7 +6941,11 @@
6940
6941
  // object.entity.addComponent(Material3D);
6941
6942
  // @ts-ignore
6942
6943
  object.renderable3D = renderable3D;
6943
- _this.batchManager.add(object);
6944
+ if (_this.swapChain) {
6945
+ _this.batchManager.add(object);
6946
+ } else {
6947
+ _this.pendingDisplayObjects.push(object);
6948
+ }
6944
6949
  };
6945
6950
  var handleUnmounted = function handleUnmounted(e) {
6946
6951
  var object = e.target;
@@ -6951,7 +6956,9 @@
6951
6956
  _this.lightPool.removeFog(object);
6952
6957
  return;
6953
6958
  }
6954
- _this.batchManager.remove(object);
6959
+ if (_this.swapChain) {
6960
+ _this.batchManager.remove(object);
6961
+ }
6955
6962
  // @ts-ignore
6956
6963
  delete object.renderable3D;
6957
6964
  // entity.removeComponent(Geometry3D, true);
@@ -6960,56 +6967,67 @@
6960
6967
  };
6961
6968
 
6962
6969
  var handleAttributeChanged = function handleAttributeChanged(e) {
6963
- var object = e.target;
6964
- var attrName = e.attrName,
6965
- newValue = e.newValue;
6966
- if (attrName === 'zIndex') {
6967
- object.parentNode.forEach(function (child) {
6968
- _this.batchManager.changeRenderOrder(child, child.sortable.renderOrder);
6969
- });
6970
- } else {
6971
- _this.batchManager.updateAttribute(object, attrName, newValue);
6970
+ if (_this.swapChain) {
6971
+ var object = e.target;
6972
+ var attrName = e.attrName,
6973
+ newValue = e.newValue;
6974
+ if (attrName === 'zIndex') {
6975
+ object.parentNode.forEach(function (child) {
6976
+ _this.batchManager.changeRenderOrder(child, child.sortable.renderOrder);
6977
+ });
6978
+ } else {
6979
+ _this.batchManager.updateAttribute(object, attrName, newValue);
6980
+ }
6972
6981
  }
6973
6982
  };
6974
6983
  var handleBoundsChanged = function handleBoundsChanged(e) {
6975
- var object = e.target;
6976
- _this.batchManager.updateAttribute(object, 'modelMatrix', null);
6984
+ if (_this.swapChain) {
6985
+ var object = e.target;
6986
+ _this.batchManager.updateAttribute(object, 'modelMatrix', null);
6987
+ }
6977
6988
  };
6978
- renderingService.hooks.init.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
6979
- var $canvas, _this$context$config, width, height;
6980
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
6981
- while (1) switch (_context.prev = _context.next) {
6982
- case 0:
6983
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
6984
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
6985
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
6986
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
6987
- _this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
6988
- $canvas = _this.context.contextService.getDomElement();
6989
- _this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
6990
- _this.context.contextService.resize(width, height);
6991
- // create swap chain and get device
6992
- // @ts-ignore
6993
- _context.next = 10;
6994
- return _this.context.deviceContribution.createSwapChain($canvas);
6995
- case 10:
6996
- _this.swapChain = _context.sent;
6997
- _this.device = _this.swapChain.getDevice();
6998
- _this.renderHelper.setDevice(_this.device);
6999
- _this.renderHelper.renderInstManager.disableSimpleMode();
7000
- _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7001
- canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
6989
+ renderingService.hooks.init.tap(RenderGraphPlugin.tag, function () {
6990
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
6991
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
6992
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
6993
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
6994
+ _this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
6995
+ var $canvas = _this.context.contextService.getDomElement();
6996
+ var _this$context$config = _this.context.config,
6997
+ width = _this$context$config.width,
6998
+ height = _this$context$config.height;
6999
+ _this.context.contextService.resize(width, height);
7000
+ _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7001
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7002
+ while (1) switch (_context.prev = _context.next) {
7003
+ case 0:
7004
+ _context.next = 2;
7005
+ return _this.context.deviceContribution.createSwapChain($canvas);
7006
+ case 2:
7007
+ _this.swapChain = _context.sent;
7008
+ _this.device = _this.swapChain.getDevice();
7009
+ _this.renderHelper.setDevice(_this.device);
7010
+ _this.renderHelper.renderInstManager.disableSimpleMode();
7002
7011
  _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7003
- });
7004
- _this.batchManager.attach(_extends({
7005
- device: _this.device
7006
- }, context));
7007
- case 17:
7008
- case "end":
7009
- return _context.stop();
7010
- }
7011
- }, _callee);
7012
- })));
7012
+ canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
7013
+ _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7014
+ });
7015
+ _this.batchManager.attach(_extends({
7016
+ device: _this.device
7017
+ }, context));
7018
+ _this.pendingDisplayObjects.forEach(function (object) {
7019
+ _this.batchManager.add(object);
7020
+ });
7021
+ _this.pendingDisplayObjects = [];
7022
+ // trigger rerender
7023
+ _this.context.renderingService.dirtify();
7024
+ case 12:
7025
+ case "end":
7026
+ return _context.stop();
7027
+ }
7028
+ }, _callee);
7029
+ }))();
7030
+ });
7013
7031
  renderingService.hooks.destroy.tap(RenderGraphPlugin.tag, function () {
7014
7032
  _this.renderHelper.destroy();
7015
7033
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
@@ -7021,9 +7039,9 @@
7021
7039
  * build frame graph at the beginning of each frame
7022
7040
  */
7023
7041
  renderingService.hooks.beginFrame.tap(RenderGraphPlugin.tag, function () {
7024
- // if (renderingContext.renderListCurrentFrame.length === 0) {
7025
- // return;
7026
- // }
7042
+ if (!_this.swapChain) {
7043
+ return;
7044
+ }
7027
7045
  var canvas = _this.swapChain.getCanvas();
7028
7046
  var renderInstManager = _this.renderHelper.renderInstManager;
7029
7047
  _this.builder = _this.renderHelper.renderGraph.newGraphBuilder();
@@ -7061,9 +7079,9 @@
7061
7079
  _this.builder.resolveRenderTargetToExternalTexture(mainColorTargetID, _this.swapChain.getOnscreenTexture());
7062
7080
  });
7063
7081
  renderingService.hooks.endFrame.tap(RenderGraphPlugin.tag, function () {
7064
- // if (renderingContext.renderListCurrentFrame.length === 0) {
7065
- // return;
7066
- // }
7082
+ if (!_this.swapChain) {
7083
+ return;
7084
+ }
7067
7085
  var renderInstManager = _this.renderHelper.renderInstManager;
7068
7086
  // TODO: time for GPU Animation
7069
7087
  // const timeInMilliseconds = window.performance.now();
@@ -7209,17 +7227,9 @@
7209
7227
  renderable3D.encodedPickingColor = _this.pickingIdGenerator.encodePickingColor(pickingId);
7210
7228
  }
7211
7229
  };
7212
- renderingService.hooks.init.tapPromise(PickingPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7213
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7214
- while (1) switch (_context.prev = _context.next) {
7215
- case 0:
7216
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7217
- case 1:
7218
- case "end":
7219
- return _context.stop();
7220
- }
7221
- }, _callee);
7222
- })));
7230
+ renderingService.hooks.init.tap(PickingPlugin.tag, function () {
7231
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7232
+ });
7223
7233
  renderingService.hooks.destroy.tap(PickingPlugin.tag, function () {
7224
7234
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7225
7235
  });
@@ -7230,19 +7240,19 @@
7230
7240
  return _this.pick(result);
7231
7241
  });
7232
7242
  renderingService.hooks.pick.tapPromise(PickingPlugin.tag, /*#__PURE__*/function () {
7233
- var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(result) {
7234
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7235
- while (1) switch (_context2.prev = _context2.next) {
7243
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
7244
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7245
+ while (1) switch (_context.prev = _context.next) {
7236
7246
  case 0:
7237
- return _context2.abrupt("return", _this.pick(result));
7247
+ return _context.abrupt("return", _this.pick(result));
7238
7248
  case 1:
7239
7249
  case "end":
7240
- return _context2.stop();
7250
+ return _context.stop();
7241
7251
  }
7242
- }, _callee2);
7252
+ }, _callee);
7243
7253
  }));
7244
7254
  return function (_x) {
7245
- return _ref2.apply(this, arguments);
7255
+ return _ref.apply(this, arguments);
7246
7256
  };
7247
7257
  }());
7248
7258
  };
@@ -12729,381 +12739,50 @@
12729
12739
  vertexAttributeDescriptorEquals: vertexAttributeDescriptorEquals
12730
12740
  });
12731
12741
 
12732
- function _regeneratorRuntime$2() {
12733
- _regeneratorRuntime$2 = function _regeneratorRuntime() {
12734
- return exports;
12742
+ function _inheritsLoose$2(subClass, superClass) {
12743
+ subClass.prototype = Object.create(superClass.prototype);
12744
+ subClass.prototype.constructor = subClass;
12745
+ _setPrototypeOf$2(subClass, superClass);
12746
+ }
12747
+ function _setPrototypeOf$2(o, p) {
12748
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
12749
+ o.__proto__ = p;
12750
+ return o;
12735
12751
  };
12736
- var exports = {},
12737
- Op = Object.prototype,
12738
- hasOwn = Op.hasOwnProperty,
12739
- defineProperty = Object.defineProperty || function (obj, key, desc) {
12740
- obj[key] = desc.value;
12741
- },
12742
- $Symbol = "function" == typeof Symbol ? Symbol : {},
12743
- iteratorSymbol = $Symbol.iterator || "@@iterator",
12744
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
12745
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
12746
- function define(obj, key, value) {
12747
- return Object.defineProperty(obj, key, {
12748
- value: value,
12749
- enumerable: !0,
12750
- configurable: !0,
12751
- writable: !0
12752
- }), obj[key];
12752
+ return _setPrototypeOf$2(o, p);
12753
+ }
12754
+
12755
+ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
12756
+ /**
12757
+ * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
12758
+ */
12759
+ var DOMInteractionPlugin = /*#__PURE__*/function () {
12760
+ function DOMInteractionPlugin() {
12761
+ this.context = void 0;
12753
12762
  }
12754
- try {
12755
- define({}, "");
12756
- } catch (err) {
12757
- define = function define(obj, key, value) {
12758
- return obj[key] = value;
12763
+ var _proto = DOMInteractionPlugin.prototype;
12764
+ _proto.apply = function apply(context, runtime) {
12765
+ var _this = this;
12766
+ var renderingService = context.renderingService,
12767
+ renderingContext = context.renderingContext,
12768
+ config = context.config;
12769
+ this.context = context;
12770
+ var canvas = renderingContext.root.ownerDocument.defaultView;
12771
+ // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
12772
+ var onPointerMove = function onPointerMove(ev) {
12773
+ renderingService.hooks.pointerMove.call(ev);
12759
12774
  };
12760
- }
12761
- function wrap(innerFn, outerFn, self, tryLocsList) {
12762
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
12763
- generator = Object.create(protoGenerator.prototype),
12764
- context = new Context(tryLocsList || []);
12765
- return defineProperty(generator, "_invoke", {
12766
- value: makeInvokeMethod(innerFn, self, context)
12767
- }), generator;
12768
- }
12769
- function tryCatch(fn, obj, arg) {
12770
- try {
12771
- return {
12772
- type: "normal",
12773
- arg: fn.call(obj, arg)
12774
- };
12775
- } catch (err) {
12776
- return {
12777
- type: "throw",
12778
- arg: err
12779
- };
12780
- }
12781
- }
12782
- exports.wrap = wrap;
12783
- var ContinueSentinel = {};
12784
- function Generator() {}
12785
- function GeneratorFunction() {}
12786
- function GeneratorFunctionPrototype() {}
12787
- var IteratorPrototype = {};
12788
- define(IteratorPrototype, iteratorSymbol, function () {
12789
- return this;
12790
- });
12791
- var getProto = Object.getPrototypeOf,
12792
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
12793
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
12794
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
12795
- function defineIteratorMethods(prototype) {
12796
- ["next", "throw", "return"].forEach(function (method) {
12797
- define(prototype, method, function (arg) {
12798
- return this._invoke(method, arg);
12799
- });
12800
- });
12801
- }
12802
- function AsyncIterator(generator, PromiseImpl) {
12803
- function invoke(method, arg, resolve, reject) {
12804
- var record = tryCatch(generator[method], generator, arg);
12805
- if ("throw" !== record.type) {
12806
- var result = record.arg,
12807
- value = result.value;
12808
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
12809
- invoke("next", value, resolve, reject);
12810
- }, function (err) {
12811
- invoke("throw", err, resolve, reject);
12812
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
12813
- result.value = unwrapped, resolve(result);
12814
- }, function (error) {
12815
- return invoke("throw", error, resolve, reject);
12816
- });
12817
- }
12818
- reject(record.arg);
12819
- }
12820
- var previousPromise;
12821
- defineProperty(this, "_invoke", {
12822
- value: function value(method, arg) {
12823
- function callInvokeWithMethodAndArg() {
12824
- return new PromiseImpl(function (resolve, reject) {
12825
- invoke(method, arg, resolve, reject);
12826
- });
12827
- }
12828
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
12829
- }
12830
- });
12831
- }
12832
- function makeInvokeMethod(innerFn, self, context) {
12833
- var state = "suspendedStart";
12834
- return function (method, arg) {
12835
- if ("executing" === state) throw new Error("Generator is already running");
12836
- if ("completed" === state) {
12837
- if ("throw" === method) throw arg;
12838
- return doneResult();
12839
- }
12840
- for (context.method = method, context.arg = arg;;) {
12841
- var delegate = context.delegate;
12842
- if (delegate) {
12843
- var delegateResult = maybeInvokeDelegate(delegate, context);
12844
- if (delegateResult) {
12845
- if (delegateResult === ContinueSentinel) continue;
12846
- return delegateResult;
12847
- }
12848
- }
12849
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
12850
- if ("suspendedStart" === state) throw state = "completed", context.arg;
12851
- context.dispatchException(context.arg);
12852
- } else "return" === context.method && context.abrupt("return", context.arg);
12853
- state = "executing";
12854
- var record = tryCatch(innerFn, self, context);
12855
- if ("normal" === record.type) {
12856
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
12857
- return {
12858
- value: record.arg,
12859
- done: context.done
12860
- };
12861
- }
12862
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
12863
- }
12775
+ var onPointerUp = function onPointerUp(ev) {
12776
+ renderingService.hooks.pointerUp.call(ev);
12864
12777
  };
12865
- }
12866
- function maybeInvokeDelegate(delegate, context) {
12867
- var methodName = context.method,
12868
- method = delegate.iterator[methodName];
12869
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
12870
- var record = tryCatch(method, delegate.iterator, context.arg);
12871
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
12872
- var info = record.arg;
12873
- 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);
12874
- }
12875
- function pushTryEntry(locs) {
12876
- var entry = {
12877
- tryLoc: locs[0]
12778
+ var onPointerDown = function onPointerDown(ev) {
12779
+ renderingService.hooks.pointerDown.call(ev);
12878
12780
  };
12879
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
12880
- }
12881
- function resetTryEntry(entry) {
12882
- var record = entry.completion || {};
12883
- record.type = "normal", delete record.arg, entry.completion = record;
12884
- }
12885
- function Context(tryLocsList) {
12886
- this.tryEntries = [{
12887
- tryLoc: "root"
12888
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
12889
- }
12890
- function values(iterable) {
12891
- if (iterable) {
12892
- var iteratorMethod = iterable[iteratorSymbol];
12893
- if (iteratorMethod) return iteratorMethod.call(iterable);
12894
- if ("function" == typeof iterable.next) return iterable;
12895
- if (!isNaN(iterable.length)) {
12896
- var i = -1,
12897
- next = function next() {
12898
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
12899
- return next.value = undefined, next.done = !0, next;
12900
- };
12901
- return next.next = next;
12902
- }
12903
- }
12904
- return {
12905
- next: doneResult
12781
+ var onPointerOver = function onPointerOver(ev) {
12782
+ renderingService.hooks.pointerOver.call(ev);
12906
12783
  };
12907
- }
12908
- function doneResult() {
12909
- return {
12910
- value: undefined,
12911
- done: !0
12912
- };
12913
- }
12914
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
12915
- value: GeneratorFunctionPrototype,
12916
- configurable: !0
12917
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
12918
- value: GeneratorFunction,
12919
- configurable: !0
12920
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
12921
- var ctor = "function" == typeof genFun && genFun.constructor;
12922
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
12923
- }, exports.mark = function (genFun) {
12924
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
12925
- }, exports.awrap = function (arg) {
12926
- return {
12927
- __await: arg
12928
- };
12929
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
12930
- return this;
12931
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
12932
- void 0 === PromiseImpl && (PromiseImpl = Promise);
12933
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
12934
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
12935
- return result.done ? result.value : iter.next();
12936
- });
12937
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
12938
- return this;
12939
- }), define(Gp, "toString", function () {
12940
- return "[object Generator]";
12941
- }), exports.keys = function (val) {
12942
- var object = Object(val),
12943
- keys = [];
12944
- for (var key in object) keys.push(key);
12945
- return keys.reverse(), function next() {
12946
- for (; keys.length;) {
12947
- var key = keys.pop();
12948
- if (key in object) return next.value = key, next.done = !1, next;
12949
- }
12950
- return next.done = !0, next;
12951
- };
12952
- }, exports.values = values, Context.prototype = {
12953
- constructor: Context,
12954
- reset: function reset(skipTempReset) {
12955
- 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);
12956
- },
12957
- stop: function stop() {
12958
- this.done = !0;
12959
- var rootRecord = this.tryEntries[0].completion;
12960
- if ("throw" === rootRecord.type) throw rootRecord.arg;
12961
- return this.rval;
12962
- },
12963
- dispatchException: function dispatchException(exception) {
12964
- if (this.done) throw exception;
12965
- var context = this;
12966
- function handle(loc, caught) {
12967
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
12968
- }
12969
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
12970
- var entry = this.tryEntries[i],
12971
- record = entry.completion;
12972
- if ("root" === entry.tryLoc) return handle("end");
12973
- if (entry.tryLoc <= this.prev) {
12974
- var hasCatch = hasOwn.call(entry, "catchLoc"),
12975
- hasFinally = hasOwn.call(entry, "finallyLoc");
12976
- if (hasCatch && hasFinally) {
12977
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
12978
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
12979
- } else if (hasCatch) {
12980
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
12981
- } else {
12982
- if (!hasFinally) throw new Error("try statement without catch or finally");
12983
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
12984
- }
12985
- }
12986
- }
12987
- },
12988
- abrupt: function abrupt(type, arg) {
12989
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
12990
- var entry = this.tryEntries[i];
12991
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
12992
- var finallyEntry = entry;
12993
- break;
12994
- }
12995
- }
12996
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
12997
- var record = finallyEntry ? finallyEntry.completion : {};
12998
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
12999
- },
13000
- complete: function complete(record, afterLoc) {
13001
- if ("throw" === record.type) throw record.arg;
13002
- 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;
13003
- },
13004
- finish: function finish(finallyLoc) {
13005
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13006
- var entry = this.tryEntries[i];
13007
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
13008
- }
13009
- },
13010
- catch: function _catch(tryLoc) {
13011
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13012
- var entry = this.tryEntries[i];
13013
- if (entry.tryLoc === tryLoc) {
13014
- var record = entry.completion;
13015
- if ("throw" === record.type) {
13016
- var thrown = record.arg;
13017
- resetTryEntry(entry);
13018
- }
13019
- return thrown;
13020
- }
13021
- }
13022
- throw new Error("illegal catch attempt");
13023
- },
13024
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
13025
- return this.delegate = {
13026
- iterator: values(iterable),
13027
- resultName: resultName,
13028
- nextLoc: nextLoc
13029
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13030
- }
13031
- }, exports;
13032
- }
13033
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
13034
- try {
13035
- var info = gen[key](arg);
13036
- var value = info.value;
13037
- } catch (error) {
13038
- reject(error);
13039
- return;
13040
- }
13041
- if (info.done) {
13042
- resolve(value);
13043
- } else {
13044
- Promise.resolve(value).then(_next, _throw);
13045
- }
13046
- }
13047
- function _asyncToGenerator$2(fn) {
13048
- return function () {
13049
- var self = this,
13050
- args = arguments;
13051
- return new Promise(function (resolve, reject) {
13052
- var gen = fn.apply(self, args);
13053
- function _next(value) {
13054
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
13055
- }
13056
- function _throw(err) {
13057
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
13058
- }
13059
- _next(undefined);
13060
- });
13061
- };
13062
- }
13063
- function _inheritsLoose$2(subClass, superClass) {
13064
- subClass.prototype = Object.create(superClass.prototype);
13065
- subClass.prototype.constructor = subClass;
13066
- _setPrototypeOf$2(subClass, superClass);
13067
- }
13068
- function _setPrototypeOf$2(o, p) {
13069
- _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
13070
- o.__proto__ = p;
13071
- return o;
13072
- };
13073
- return _setPrototypeOf$2(o, p);
13074
- }
13075
-
13076
- // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
13077
- /**
13078
- * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
13079
- */
13080
- var DOMInteractionPlugin = /*#__PURE__*/function () {
13081
- function DOMInteractionPlugin() {
13082
- this.context = void 0;
13083
- }
13084
- var _proto = DOMInteractionPlugin.prototype;
13085
- _proto.apply = function apply(context, runtime) {
13086
- var _this = this;
13087
- var renderingService = context.renderingService,
13088
- renderingContext = context.renderingContext,
13089
- config = context.config;
13090
- this.context = context;
13091
- var canvas = renderingContext.root.ownerDocument.defaultView;
13092
- // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
13093
- var onPointerMove = function onPointerMove(ev) {
13094
- renderingService.hooks.pointerMove.call(ev);
13095
- };
13096
- var onPointerUp = function onPointerUp(ev) {
13097
- renderingService.hooks.pointerUp.call(ev);
13098
- };
13099
- var onPointerDown = function onPointerDown(ev) {
13100
- renderingService.hooks.pointerDown.call(ev);
13101
- };
13102
- var onPointerOver = function onPointerOver(ev) {
13103
- renderingService.hooks.pointerOver.call(ev);
13104
- };
13105
- var onPointerOut = function onPointerOut(ev) {
13106
- renderingService.hooks.pointerOut.call(ev);
12784
+ var onPointerOut = function onPointerOut(ev) {
12785
+ renderingService.hooks.pointerOut.call(ev);
13107
12786
  };
13108
12787
  var onPointerCancel = function onPointerCancel(ev) {
13109
12788
  renderingService.hooks.pointerCancel.call(ev);
@@ -13155,43 +12834,35 @@
13155
12834
  $el.removeEventListener('mouseover', onPointerOver, true);
13156
12835
  runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
13157
12836
  };
13158
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
13159
- var $el;
13160
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
13161
- while (1) switch (_context.prev = _context.next) {
13162
- case 0:
13163
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
13164
- if (runtime.globalThis.navigator.msPointerEnabled) {
13165
- // @ts-ignore
13166
- $el.style.msContentZooming = 'none';
13167
- // @ts-ignore
13168
- $el.style.msTouchAction = 'none';
13169
- } else if (canvas.supportsPointerEvents) {
13170
- $el.style.touchAction = 'none';
13171
- }
13172
- if (canvas.supportsPointerEvents) {
13173
- addPointerEventListener($el);
13174
- } else {
13175
- addMouseEventListener($el);
13176
- }
13177
- if (canvas.supportsTouchEvents) {
13178
- addTouchEventListener($el);
13179
- }
13180
- if (config.useNativeClickEvent) {
13181
- $el.addEventListener('click', onClick, true);
13182
- }
13183
- // use passive event listeners
13184
- // @see https://zhuanlan.zhihu.com/p/24555031
13185
- $el.addEventListener('wheel', onPointerWheel, {
13186
- passive: true,
13187
- capture: true
13188
- });
13189
- case 6:
13190
- case "end":
13191
- return _context.stop();
13192
- }
13193
- }, _callee);
13194
- })));
12837
+ renderingService.hooks.init.tap(DOMInteractionPlugin.tag, function () {
12838
+ var $el = _this.context.contextService.getDomElement();
12839
+ // @ts-ignore
12840
+ if (runtime.globalThis.navigator.msPointerEnabled) {
12841
+ // @ts-ignore
12842
+ $el.style.msContentZooming = 'none';
12843
+ // @ts-ignore
12844
+ $el.style.msTouchAction = 'none';
12845
+ } else if (canvas.supportsPointerEvents) {
12846
+ $el.style.touchAction = 'none';
12847
+ }
12848
+ if (canvas.supportsPointerEvents) {
12849
+ addPointerEventListener($el);
12850
+ } else {
12851
+ addMouseEventListener($el);
12852
+ }
12853
+ if (canvas.supportsTouchEvents) {
12854
+ addTouchEventListener($el);
12855
+ }
12856
+ if (config.useNativeClickEvent) {
12857
+ $el.addEventListener('click', onClick, true);
12858
+ }
12859
+ // use passive event listeners
12860
+ // @see https://zhuanlan.zhihu.com/p/24555031
12861
+ $el.addEventListener('wheel', onPointerWheel, {
12862
+ passive: true,
12863
+ capture: true
12864
+ });
12865
+ });
13195
12866
  renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
13196
12867
  var $el = _this.context.contextService.getDomElement();
13197
12868
  // @ts-ignore
@@ -13246,976 +12917,306 @@
13246
12917
  Plugin: Plugin$1
13247
12918
  });
13248
12919
 
13249
- function _regeneratorRuntime$3() {
13250
- _regeneratorRuntime$3 = function _regeneratorRuntime() {
13251
- return exports;
12920
+ function _inheritsLoose$3(subClass, superClass) {
12921
+ subClass.prototype = Object.create(superClass.prototype);
12922
+ subClass.prototype.constructor = subClass;
12923
+ _setPrototypeOf$3(subClass, superClass);
12924
+ }
12925
+ function _setPrototypeOf$3(o, p) {
12926
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
12927
+ o.__proto__ = p;
12928
+ return o;
13252
12929
  };
13253
- var exports = {},
13254
- Op = Object.prototype,
13255
- hasOwn = Op.hasOwnProperty,
13256
- defineProperty = Object.defineProperty || function (obj, key, desc) {
13257
- obj[key] = desc.value;
13258
- },
13259
- $Symbol = "function" == typeof Symbol ? Symbol : {},
13260
- iteratorSymbol = $Symbol.iterator || "@@iterator",
13261
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
13262
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
13263
- function define(obj, key, value) {
13264
- return Object.defineProperty(obj, key, {
13265
- value: value,
13266
- enumerable: !0,
13267
- configurable: !0,
13268
- writable: !0
13269
- }), obj[key];
13270
- }
13271
- try {
13272
- define({}, "");
13273
- } catch (err) {
13274
- define = function define(obj, key, value) {
13275
- return obj[key] = value;
13276
- };
13277
- }
13278
- function wrap(innerFn, outerFn, self, tryLocsList) {
13279
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
13280
- generator = Object.create(protoGenerator.prototype),
13281
- context = new Context(tryLocsList || []);
13282
- return defineProperty(generator, "_invoke", {
13283
- value: makeInvokeMethod(innerFn, self, context)
13284
- }), generator;
13285
- }
13286
- function tryCatch(fn, obj, arg) {
13287
- try {
13288
- return {
13289
- type: "normal",
13290
- arg: fn.call(obj, arg)
13291
- };
13292
- } catch (err) {
13293
- return {
13294
- type: "throw",
13295
- arg: err
13296
- };
13297
- }
13298
- }
13299
- exports.wrap = wrap;
13300
- var ContinueSentinel = {};
13301
- function Generator() {}
13302
- function GeneratorFunction() {}
13303
- function GeneratorFunctionPrototype() {}
13304
- var IteratorPrototype = {};
13305
- define(IteratorPrototype, iteratorSymbol, function () {
13306
- return this;
13307
- });
13308
- var getProto = Object.getPrototypeOf,
13309
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
13310
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
13311
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
13312
- function defineIteratorMethods(prototype) {
13313
- ["next", "throw", "return"].forEach(function (method) {
13314
- define(prototype, method, function (arg) {
13315
- return this._invoke(method, arg);
13316
- });
13317
- });
13318
- }
13319
- function AsyncIterator(generator, PromiseImpl) {
13320
- function invoke(method, arg, resolve, reject) {
13321
- var record = tryCatch(generator[method], generator, arg);
13322
- if ("throw" !== record.type) {
13323
- var result = record.arg,
13324
- value = result.value;
13325
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
13326
- invoke("next", value, resolve, reject);
13327
- }, function (err) {
13328
- invoke("throw", err, resolve, reject);
13329
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
13330
- result.value = unwrapped, resolve(result);
13331
- }, function (error) {
13332
- return invoke("throw", error, resolve, reject);
13333
- });
13334
- }
13335
- reject(record.arg);
13336
- }
13337
- var previousPromise;
13338
- defineProperty(this, "_invoke", {
13339
- value: function value(method, arg) {
13340
- function callInvokeWithMethodAndArg() {
13341
- return new PromiseImpl(function (resolve, reject) {
13342
- invoke(method, arg, resolve, reject);
13343
- });
13344
- }
13345
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
13346
- }
13347
- });
13348
- }
13349
- function makeInvokeMethod(innerFn, self, context) {
13350
- var state = "suspendedStart";
13351
- return function (method, arg) {
13352
- if ("executing" === state) throw new Error("Generator is already running");
13353
- if ("completed" === state) {
13354
- if ("throw" === method) throw arg;
13355
- return doneResult();
13356
- }
13357
- for (context.method = method, context.arg = arg;;) {
13358
- var delegate = context.delegate;
13359
- if (delegate) {
13360
- var delegateResult = maybeInvokeDelegate(delegate, context);
13361
- if (delegateResult) {
13362
- if (delegateResult === ContinueSentinel) continue;
13363
- return delegateResult;
13364
- }
13365
- }
13366
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
13367
- if ("suspendedStart" === state) throw state = "completed", context.arg;
13368
- context.dispatchException(context.arg);
13369
- } else "return" === context.method && context.abrupt("return", context.arg);
13370
- state = "executing";
13371
- var record = tryCatch(innerFn, self, context);
13372
- if ("normal" === record.type) {
13373
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
13374
- return {
13375
- value: record.arg,
13376
- done: context.done
13377
- };
13378
- }
13379
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
13380
- }
13381
- };
13382
- }
13383
- function maybeInvokeDelegate(delegate, context) {
13384
- var methodName = context.method,
13385
- method = delegate.iterator[methodName];
13386
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
13387
- var record = tryCatch(method, delegate.iterator, context.arg);
13388
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
13389
- var info = record.arg;
13390
- 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);
13391
- }
13392
- function pushTryEntry(locs) {
13393
- var entry = {
13394
- tryLoc: locs[0]
13395
- };
13396
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
13397
- }
13398
- function resetTryEntry(entry) {
13399
- var record = entry.completion || {};
13400
- record.type = "normal", delete record.arg, entry.completion = record;
13401
- }
13402
- function Context(tryLocsList) {
13403
- this.tryEntries = [{
13404
- tryLoc: "root"
13405
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
13406
- }
13407
- function values(iterable) {
13408
- if (iterable) {
13409
- var iteratorMethod = iterable[iteratorSymbol];
13410
- if (iteratorMethod) return iteratorMethod.call(iterable);
13411
- if ("function" == typeof iterable.next) return iterable;
13412
- if (!isNaN(iterable.length)) {
13413
- var i = -1,
13414
- next = function next() {
13415
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
13416
- return next.value = undefined, next.done = !0, next;
13417
- };
13418
- return next.next = next;
13419
- }
13420
- }
13421
- return {
13422
- next: doneResult
13423
- };
13424
- }
13425
- function doneResult() {
13426
- return {
13427
- value: undefined,
13428
- done: !0
13429
- };
13430
- }
13431
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
13432
- value: GeneratorFunctionPrototype,
13433
- configurable: !0
13434
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
13435
- value: GeneratorFunction,
13436
- configurable: !0
13437
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
13438
- var ctor = "function" == typeof genFun && genFun.constructor;
13439
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
13440
- }, exports.mark = function (genFun) {
13441
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
13442
- }, exports.awrap = function (arg) {
13443
- return {
13444
- __await: arg
13445
- };
13446
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
13447
- return this;
13448
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
13449
- void 0 === PromiseImpl && (PromiseImpl = Promise);
13450
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
13451
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
13452
- return result.done ? result.value : iter.next();
13453
- });
13454
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
13455
- return this;
13456
- }), define(Gp, "toString", function () {
13457
- return "[object Generator]";
13458
- }), exports.keys = function (val) {
13459
- var object = Object(val),
13460
- keys = [];
13461
- for (var key in object) keys.push(key);
13462
- return keys.reverse(), function next() {
13463
- for (; keys.length;) {
13464
- var key = keys.pop();
13465
- if (key in object) return next.value = key, next.done = !1, next;
13466
- }
13467
- return next.done = !0, next;
13468
- };
13469
- }, exports.values = values, Context.prototype = {
13470
- constructor: Context,
13471
- reset: function reset(skipTempReset) {
13472
- 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);
13473
- },
13474
- stop: function stop() {
13475
- this.done = !0;
13476
- var rootRecord = this.tryEntries[0].completion;
13477
- if ("throw" === rootRecord.type) throw rootRecord.arg;
13478
- return this.rval;
13479
- },
13480
- dispatchException: function dispatchException(exception) {
13481
- if (this.done) throw exception;
13482
- var context = this;
13483
- function handle(loc, caught) {
13484
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
13485
- }
13486
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13487
- var entry = this.tryEntries[i],
13488
- record = entry.completion;
13489
- if ("root" === entry.tryLoc) return handle("end");
13490
- if (entry.tryLoc <= this.prev) {
13491
- var hasCatch = hasOwn.call(entry, "catchLoc"),
13492
- hasFinally = hasOwn.call(entry, "finallyLoc");
13493
- if (hasCatch && hasFinally) {
13494
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
13495
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
13496
- } else if (hasCatch) {
13497
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
13498
- } else {
13499
- if (!hasFinally) throw new Error("try statement without catch or finally");
13500
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
13501
- }
13502
- }
13503
- }
13504
- },
13505
- abrupt: function abrupt(type, arg) {
13506
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13507
- var entry = this.tryEntries[i];
13508
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
13509
- var finallyEntry = entry;
13510
- break;
13511
- }
13512
- }
13513
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
13514
- var record = finallyEntry ? finallyEntry.completion : {};
13515
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
13516
- },
13517
- complete: function complete(record, afterLoc) {
13518
- if ("throw" === record.type) throw record.arg;
13519
- 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;
13520
- },
13521
- finish: function finish(finallyLoc) {
13522
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13523
- var entry = this.tryEntries[i];
13524
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
13525
- }
13526
- },
13527
- catch: function _catch(tryLoc) {
13528
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13529
- var entry = this.tryEntries[i];
13530
- if (entry.tryLoc === tryLoc) {
13531
- var record = entry.completion;
13532
- if ("throw" === record.type) {
13533
- var thrown = record.arg;
13534
- resetTryEntry(entry);
13535
- }
13536
- return thrown;
13537
- }
13538
- }
13539
- throw new Error("illegal catch attempt");
13540
- },
13541
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
13542
- return this.delegate = {
13543
- iterator: values(iterable),
13544
- resultName: resultName,
13545
- nextLoc: nextLoc
13546
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13547
- }
13548
- }, exports;
13549
- }
13550
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
13551
- try {
13552
- var info = gen[key](arg);
13553
- var value = info.value;
13554
- } catch (error) {
13555
- reject(error);
13556
- return;
13557
- }
13558
- if (info.done) {
13559
- resolve(value);
13560
- } else {
13561
- Promise.resolve(value).then(_next, _throw);
13562
- }
13563
- }
13564
- function _asyncToGenerator$3(fn) {
13565
- return function () {
13566
- var self = this,
13567
- args = arguments;
13568
- return new Promise(function (resolve, reject) {
13569
- var gen = fn.apply(self, args);
13570
- function _next(value) {
13571
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
13572
- }
13573
- function _throw(err) {
13574
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
13575
- }
13576
- _next(undefined);
13577
- });
13578
- };
13579
- }
13580
- function _inheritsLoose$3(subClass, superClass) {
13581
- subClass.prototype = Object.create(superClass.prototype);
13582
- subClass.prototype.constructor = subClass;
13583
- _setPrototypeOf$3(subClass, superClass);
13584
- }
13585
- function _setPrototypeOf$3(o, p) {
13586
- _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
13587
- o.__proto__ = p;
13588
- return o;
13589
- };
13590
- return _setPrototypeOf$3(o, p);
13591
- }
13592
- var HTML_PREFIX = 'g-html-';
13593
- var CANVAS_CAMERA_ID = 'g-canvas-camera';
13594
- var HTMLRenderingPlugin = /*#__PURE__*/function () {
13595
- function HTMLRenderingPlugin() {
13596
- this.context = void 0;
13597
- /**
13598
- * wrapper for camera
13599
- */
13600
- this.$camera = void 0;
13601
- }
13602
- var _proto = HTMLRenderingPlugin.prototype;
13603
- _proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
13604
- return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
13605
- };
13606
- _proto.apply = function apply(context) {
13607
- var _this = this;
13608
- var camera = context.camera,
13609
- renderingContext = context.renderingContext,
13610
- renderingService = context.renderingService;
13611
- this.context = context;
13612
- var canvas = renderingContext.root.ownerDocument.defaultView;
13613
- var setTransform = function setTransform(object, $el) {
13614
- $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
13615
- };
13616
- var handleMounted = function handleMounted(e) {
13617
- var object = e.target;
13618
- if (object.nodeName === gLite.Shape.HTML) {
13619
- if (!_this.$camera) {
13620
- _this.$camera = _this.createCamera(camera);
13621
- }
13622
- // create DOM element
13623
- var $el = _this.getOrCreateEl(object);
13624
- _this.$camera.appendChild($el);
13625
- // apply documentElement's style
13626
- var attributes = object.ownerDocument.documentElement.attributes;
13627
- Object.keys(attributes).forEach(function (name) {
13628
- $el.style[name] = attributes[name];
13629
- });
13630
- Object.keys(object.attributes).forEach(function (name) {
13631
- _this.updateAttribute(name, object);
13632
- });
13633
- setTransform(object, $el);
13634
- gLite.runtime.nativeHTMLMap.set($el, object);
13635
- }
13636
- };
13637
- var handleUnmounted = function handleUnmounted(e) {
13638
- var object = e.target;
13639
- if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
13640
- var $el = _this.getOrCreateEl(object);
13641
- if ($el) {
13642
- $el.remove();
13643
- gLite.runtime.nativeHTMLMap.delete($el);
13644
- }
13645
- // const existedId = this.getId(object);
13646
- // const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
13647
- // if ($existedElement) {
13648
- // this.$camera.removeChild($existedElement);
13649
- // }
13650
- }
13651
- };
13652
-
13653
- var handleAttributeChanged = function handleAttributeChanged(e) {
13654
- var object = e.target;
13655
- if (object.nodeName === gLite.Shape.HTML) {
13656
- var attrName = e.attrName;
13657
- _this.updateAttribute(attrName, object);
13658
- }
13659
- };
13660
- var handleBoundsChanged = function handleBoundsChanged(e) {
13661
- var object = e.target;
13662
- if (object.nodeName === gLite.Shape.HTML) {
13663
- var $el = _this.getOrCreateEl(object);
13664
- setTransform(object, $el);
13665
- }
13666
- };
13667
- var handleCanvasResize = function handleCanvasResize() {
13668
- if (_this.$camera) {
13669
- var _this$context$config = _this.context.config,
13670
- width = _this$context$config.width,
13671
- height = _this$context$config.height;
13672
- _this.$camera.style.width = (width || 0) + "px";
13673
- _this.$camera.style.height = (height || 0) + "px";
13674
- }
13675
- };
13676
- renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
13677
- return _regeneratorRuntime$3().wrap(function _callee$(_context) {
13678
- while (1) switch (_context.prev = _context.next) {
13679
- case 0:
13680
- canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13681
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13682
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13683
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13684
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13685
- case 5:
13686
- case "end":
13687
- return _context.stop();
13688
- }
13689
- }, _callee);
13690
- })));
13691
- renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
13692
- if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
13693
- _this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
13694
- }
13695
- });
13696
- renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
13697
- // remove camera
13698
- if (_this.$camera) {
13699
- _this.$camera.remove();
13700
- }
13701
- canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13702
- canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13703
- canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13704
- canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13705
- canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13706
- });
13707
- };
13708
- _proto.getId = function getId(object) {
13709
- return object.id || HTML_PREFIX + object.entity;
13710
- };
13711
- _proto.createCamera = function createCamera(camera) {
13712
- var _this$context$config2 = this.context.config,
13713
- doc = _this$context$config2.document,
13714
- width = _this$context$config2.width,
13715
- height = _this$context$config2.height;
13716
- var $canvas = this.context.contextService.getDomElement();
13717
- var $container = $canvas.parentNode;
13718
- if ($container) {
13719
- var cameraId = CANVAS_CAMERA_ID;
13720
- var $existedCamera = $container.querySelector('#' + cameraId);
13721
- if (!$existedCamera) {
13722
- var $camera = (doc || document).createElement('div');
13723
- $existedCamera = $camera;
13724
- $camera.id = cameraId;
13725
- // use absolute position
13726
- $camera.style.position = 'absolute';
13727
- // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
13728
- $camera.style.left = ($canvas.offsetLeft || 0) + "px";
13729
- $camera.style.top = ($canvas.offsetTop || 0) + "px";
13730
- $camera.style.transformOrigin = 'left top';
13731
- $camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
13732
- // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
13733
- $camera.style.overflow = 'hidden';
13734
- $camera.style.pointerEvents = 'none';
13735
- $camera.style.width = (width || 0) + "px";
13736
- $camera.style.height = (height || 0) + "px";
13737
- $container.appendChild($camera);
13738
- }
13739
- return $existedCamera;
13740
- }
13741
- return null;
13742
- };
13743
- _proto.getOrCreateEl = function getOrCreateEl(object) {
13744
- var doc = this.context.config.document;
13745
- var existedId = this.getId(object);
13746
- var $existedElement = this.$camera.querySelector('#' + existedId);
13747
- if (!$existedElement) {
13748
- $existedElement = (doc || document).createElement('div');
13749
- object.parsedStyle.$el = $existedElement;
13750
- $existedElement.id = existedId;
13751
- if (object.name) {
13752
- $existedElement.setAttribute('name', object.name);
13753
- }
13754
- if (object.className) {
13755
- $existedElement.className = object.className;
13756
- }
13757
- // use absolute position
13758
- $existedElement.style.position = 'absolute';
13759
- // @see https://github.com/antvis/G/issues/1150
13760
- $existedElement.style.left = "0px";
13761
- $existedElement.style.top = "0px";
13762
- $existedElement.style['will-change'] = 'transform';
13763
- $existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
13764
- }
13765
- return $existedElement;
13766
- };
13767
- _proto.updateAttribute = function updateAttribute(name, object) {
13768
- var $el = this.getOrCreateEl(object);
13769
- switch (name) {
13770
- case 'innerHTML':
13771
- var innerHTML = object.parsedStyle.innerHTML;
13772
- if (isString(innerHTML)) {
13773
- $el.innerHTML = innerHTML;
13774
- } else {
13775
- $el.innerHTML = '';
13776
- $el.appendChild(innerHTML);
13777
- }
13778
- break;
13779
- case 'transformOrigin':
13780
- var transformOrigin = object.parsedStyle.transformOrigin;
13781
- $el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
13782
- break;
13783
- case 'width':
13784
- if (gLite.runtime.enableCSSParsing) {
13785
- var width = object.computedStyleMap().get('width');
13786
- $el.style.width = width.toString();
13787
- } else {
13788
- var _width = object.parsedStyle.width;
13789
- $el.style.width = isNumber(_width) ? _width + "px" : _width.toString();
13790
- }
13791
- break;
13792
- case 'height':
13793
- if (gLite.runtime.enableCSSParsing) {
13794
- var height = object.computedStyleMap().get('height');
13795
- $el.style.height = height.toString();
13796
- } else {
13797
- var _height = object.parsedStyle.height;
13798
- $el.style.height = isNumber(_height) ? _height + "px" : _height.toString();
13799
- }
13800
- break;
13801
- case 'zIndex':
13802
- var zIndex = object.parsedStyle.zIndex;
13803
- $el.style['z-index'] = "" + zIndex;
13804
- break;
13805
- case 'visibility':
13806
- var visibility = object.parsedStyle.visibility;
13807
- $el.style.visibility = visibility;
13808
- break;
13809
- case 'pointerEvents':
13810
- var pointerEvents = object.parsedStyle.pointerEvents;
13811
- $el.style.pointerEvents = pointerEvents;
13812
- break;
13813
- case 'opacity':
13814
- var opacity = object.parsedStyle.opacity;
13815
- $el.style.opacity = "" + opacity;
13816
- break;
13817
- case 'fill':
13818
- var fill = object.parsedStyle.fill;
13819
- var color = '';
13820
- if (gLite.isCSSRGB(fill)) {
13821
- if (fill.isNone) {
13822
- color = 'transparent';
13823
- } else {
13824
- color = object.getAttribute('fill');
13825
- }
13826
- } else if (Array.isArray(fill)) {
13827
- color = object.getAttribute('fill');
13828
- } else if (gLite.isPattern(fill)) ;
13829
- $el.style.background = color;
13830
- break;
13831
- case 'stroke':
13832
- var stroke = object.parsedStyle.stroke;
13833
- var borderColor = '';
13834
- if (gLite.isCSSRGB(stroke)) {
13835
- if (stroke.isNone) {
13836
- borderColor = 'transparent';
13837
- } else {
13838
- borderColor = object.getAttribute('stroke');
13839
- }
13840
- } else if (Array.isArray(stroke)) {
13841
- borderColor = object.getAttribute('stroke');
13842
- } else if (gLite.isPattern(stroke)) ;
13843
- $el.style['border-color'] = borderColor;
13844
- $el.style['border-style'] = 'solid';
13845
- break;
13846
- case 'lineWidth':
13847
- var lineWidth = object.parsedStyle.lineWidth;
13848
- $el.style['border-width'] = (lineWidth || 0) + "px";
13849
- break;
13850
- case 'lineDash':
13851
- $el.style['border-style'] = 'dashed';
13852
- break;
13853
- case 'filter':
13854
- var filter = object.style.filter;
13855
- $el.style.filter = filter;
13856
- break;
13857
- }
13858
- };
13859
- return HTMLRenderingPlugin;
13860
- }();
13861
- HTMLRenderingPlugin.tag = 'HTMLRendering';
13862
- var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
13863
- _inheritsLoose$3(Plugin, _AbstractRendererPlug);
13864
- function Plugin() {
13865
- var _this;
13866
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13867
- args[_key] = arguments[_key];
13868
- }
13869
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13870
- _this.name = 'html-renderer';
13871
- return _this;
13872
- }
13873
- var _proto = Plugin.prototype;
13874
- _proto.init = function init() {
13875
- this.addRenderingPlugin(new HTMLRenderingPlugin());
13876
- };
13877
- _proto.destroy = function destroy() {
13878
- this.removeAllRenderingPlugins();
13879
- };
13880
- return Plugin;
13881
- }(gLite.AbstractRendererPlugin);
13882
-
13883
- var index_esm$2 = /*#__PURE__*/Object.freeze({
13884
- __proto__: null,
13885
- Plugin: Plugin$2
13886
- });
13887
-
13888
- function _regeneratorRuntime$4() {
13889
- _regeneratorRuntime$4 = function _regeneratorRuntime() {
13890
- return exports;
13891
- };
13892
- var exports = {},
13893
- Op = Object.prototype,
13894
- hasOwn = Op.hasOwnProperty,
13895
- defineProperty = Object.defineProperty || function (obj, key, desc) {
13896
- obj[key] = desc.value;
13897
- },
13898
- $Symbol = "function" == typeof Symbol ? Symbol : {},
13899
- iteratorSymbol = $Symbol.iterator || "@@iterator",
13900
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
13901
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
13902
- function define(obj, key, value) {
13903
- return Object.defineProperty(obj, key, {
13904
- value: value,
13905
- enumerable: !0,
13906
- configurable: !0,
13907
- writable: !0
13908
- }), obj[key];
13909
- }
13910
- try {
13911
- define({}, "");
13912
- } catch (err) {
13913
- define = function define(obj, key, value) {
13914
- return obj[key] = value;
13915
- };
13916
- }
13917
- function wrap(innerFn, outerFn, self, tryLocsList) {
13918
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
13919
- generator = Object.create(protoGenerator.prototype),
13920
- context = new Context(tryLocsList || []);
13921
- return defineProperty(generator, "_invoke", {
13922
- value: makeInvokeMethod(innerFn, self, context)
13923
- }), generator;
13924
- }
13925
- function tryCatch(fn, obj, arg) {
13926
- try {
13927
- return {
13928
- type: "normal",
13929
- arg: fn.call(obj, arg)
13930
- };
13931
- } catch (err) {
13932
- return {
13933
- type: "throw",
13934
- arg: err
13935
- };
13936
- }
13937
- }
13938
- exports.wrap = wrap;
13939
- var ContinueSentinel = {};
13940
- function Generator() {}
13941
- function GeneratorFunction() {}
13942
- function GeneratorFunctionPrototype() {}
13943
- var IteratorPrototype = {};
13944
- define(IteratorPrototype, iteratorSymbol, function () {
13945
- return this;
13946
- });
13947
- var getProto = Object.getPrototypeOf,
13948
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
13949
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
13950
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
13951
- function defineIteratorMethods(prototype) {
13952
- ["next", "throw", "return"].forEach(function (method) {
13953
- define(prototype, method, function (arg) {
13954
- return this._invoke(method, arg);
13955
- });
13956
- });
13957
- }
13958
- function AsyncIterator(generator, PromiseImpl) {
13959
- function invoke(method, arg, resolve, reject) {
13960
- var record = tryCatch(generator[method], generator, arg);
13961
- if ("throw" !== record.type) {
13962
- var result = record.arg,
13963
- value = result.value;
13964
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
13965
- invoke("next", value, resolve, reject);
13966
- }, function (err) {
13967
- invoke("throw", err, resolve, reject);
13968
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
13969
- result.value = unwrapped, resolve(result);
13970
- }, function (error) {
13971
- return invoke("throw", error, resolve, reject);
13972
- });
13973
- }
13974
- reject(record.arg);
13975
- }
13976
- var previousPromise;
13977
- defineProperty(this, "_invoke", {
13978
- value: function value(method, arg) {
13979
- function callInvokeWithMethodAndArg() {
13980
- return new PromiseImpl(function (resolve, reject) {
13981
- invoke(method, arg, resolve, reject);
13982
- });
13983
- }
13984
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
13985
- }
13986
- });
12930
+ return _setPrototypeOf$3(o, p);
12931
+ }
12932
+ var HTML_PREFIX = 'g-html-';
12933
+ var CANVAS_CAMERA_ID = 'g-canvas-camera';
12934
+ var HTMLRenderingPlugin = /*#__PURE__*/function () {
12935
+ function HTMLRenderingPlugin() {
12936
+ this.context = void 0;
12937
+ /**
12938
+ * wrapper for camera
12939
+ */
12940
+ this.$camera = void 0;
13987
12941
  }
13988
- function makeInvokeMethod(innerFn, self, context) {
13989
- var state = "suspendedStart";
13990
- return function (method, arg) {
13991
- if ("executing" === state) throw new Error("Generator is already running");
13992
- if ("completed" === state) {
13993
- if ("throw" === method) throw arg;
13994
- return doneResult();
13995
- }
13996
- for (context.method = method, context.arg = arg;;) {
13997
- var delegate = context.delegate;
13998
- if (delegate) {
13999
- var delegateResult = maybeInvokeDelegate(delegate, context);
14000
- if (delegateResult) {
14001
- if (delegateResult === ContinueSentinel) continue;
14002
- return delegateResult;
14003
- }
14004
- }
14005
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
14006
- if ("suspendedStart" === state) throw state = "completed", context.arg;
14007
- context.dispatchException(context.arg);
14008
- } else "return" === context.method && context.abrupt("return", context.arg);
14009
- state = "executing";
14010
- var record = tryCatch(innerFn, self, context);
14011
- if ("normal" === record.type) {
14012
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
14013
- return {
14014
- value: record.arg,
14015
- done: context.done
14016
- };
12942
+ var _proto = HTMLRenderingPlugin.prototype;
12943
+ _proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
12944
+ return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
12945
+ };
12946
+ _proto.apply = function apply(context) {
12947
+ var _this = this;
12948
+ var camera = context.camera,
12949
+ renderingContext = context.renderingContext,
12950
+ renderingService = context.renderingService;
12951
+ this.context = context;
12952
+ var canvas = renderingContext.root.ownerDocument.defaultView;
12953
+ var setTransform = function setTransform(object, $el) {
12954
+ $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
12955
+ };
12956
+ var handleMounted = function handleMounted(e) {
12957
+ var object = e.target;
12958
+ if (object.nodeName === gLite.Shape.HTML) {
12959
+ if (!_this.$camera) {
12960
+ _this.$camera = _this.createCamera(camera);
14017
12961
  }
14018
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
12962
+ // create DOM element
12963
+ var $el = _this.getOrCreateEl(object);
12964
+ _this.$camera.appendChild($el);
12965
+ // apply documentElement's style
12966
+ var attributes = object.ownerDocument.documentElement.attributes;
12967
+ Object.keys(attributes).forEach(function (name) {
12968
+ $el.style[name] = attributes[name];
12969
+ });
12970
+ Object.keys(object.attributes).forEach(function (name) {
12971
+ _this.updateAttribute(name, object);
12972
+ });
12973
+ setTransform(object, $el);
12974
+ gLite.runtime.nativeHTMLMap.set($el, object);
14019
12975
  }
14020
12976
  };
14021
- }
14022
- function maybeInvokeDelegate(delegate, context) {
14023
- var methodName = context.method,
14024
- method = delegate.iterator[methodName];
14025
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
14026
- var record = tryCatch(method, delegate.iterator, context.arg);
14027
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
14028
- var info = record.arg;
14029
- 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);
14030
- }
14031
- function pushTryEntry(locs) {
14032
- var entry = {
14033
- tryLoc: locs[0]
12977
+ var handleUnmounted = function handleUnmounted(e) {
12978
+ var object = e.target;
12979
+ if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
12980
+ var $el = _this.getOrCreateEl(object);
12981
+ if ($el) {
12982
+ $el.remove();
12983
+ gLite.runtime.nativeHTMLMap.delete($el);
12984
+ }
12985
+ // const existedId = this.getId(object);
12986
+ // const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
12987
+ // if ($existedElement) {
12988
+ // this.$camera.removeChild($existedElement);
12989
+ // }
12990
+ }
14034
12991
  };
14035
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
14036
- }
14037
- function resetTryEntry(entry) {
14038
- var record = entry.completion || {};
14039
- record.type = "normal", delete record.arg, entry.completion = record;
14040
- }
14041
- function Context(tryLocsList) {
14042
- this.tryEntries = [{
14043
- tryLoc: "root"
14044
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
14045
- }
14046
- function values(iterable) {
14047
- if (iterable) {
14048
- var iteratorMethod = iterable[iteratorSymbol];
14049
- if (iteratorMethod) return iteratorMethod.call(iterable);
14050
- if ("function" == typeof iterable.next) return iterable;
14051
- if (!isNaN(iterable.length)) {
14052
- var i = -1,
14053
- next = function next() {
14054
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14055
- return next.value = undefined, next.done = !0, next;
14056
- };
14057
- return next.next = next;
12992
+
12993
+ var handleAttributeChanged = function handleAttributeChanged(e) {
12994
+ var object = e.target;
12995
+ if (object.nodeName === gLite.Shape.HTML) {
12996
+ var attrName = e.attrName;
12997
+ _this.updateAttribute(attrName, object);
14058
12998
  }
14059
- }
14060
- return {
14061
- next: doneResult
14062
12999
  };
14063
- }
14064
- function doneResult() {
14065
- return {
14066
- value: undefined,
14067
- done: !0
13000
+ var handleBoundsChanged = function handleBoundsChanged(e) {
13001
+ var object = e.target;
13002
+ if (object.nodeName === gLite.Shape.HTML) {
13003
+ var $el = _this.getOrCreateEl(object);
13004
+ setTransform(object, $el);
13005
+ }
14068
13006
  };
14069
- }
14070
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
14071
- value: GeneratorFunctionPrototype,
14072
- configurable: !0
14073
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
14074
- value: GeneratorFunction,
14075
- configurable: !0
14076
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
14077
- var ctor = "function" == typeof genFun && genFun.constructor;
14078
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
14079
- }, exports.mark = function (genFun) {
14080
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
14081
- }, exports.awrap = function (arg) {
14082
- return {
14083
- __await: arg
13007
+ var handleCanvasResize = function handleCanvasResize() {
13008
+ if (_this.$camera) {
13009
+ var _this$context$config = _this.context.config,
13010
+ width = _this$context$config.width,
13011
+ height = _this$context$config.height;
13012
+ _this.$camera.style.width = (width || 0) + "px";
13013
+ _this.$camera.style.height = (height || 0) + "px";
13014
+ }
14084
13015
  };
14085
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
14086
- return this;
14087
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
14088
- void 0 === PromiseImpl && (PromiseImpl = Promise);
14089
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
14090
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
14091
- return result.done ? result.value : iter.next();
13016
+ renderingService.hooks.init.tap(HTMLRenderingPlugin.tag, function () {
13017
+ canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13018
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13019
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13020
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13021
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14092
13022
  });
14093
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
14094
- return this;
14095
- }), define(Gp, "toString", function () {
14096
- return "[object Generator]";
14097
- }), exports.keys = function (val) {
14098
- var object = Object(val),
14099
- keys = [];
14100
- for (var key in object) keys.push(key);
14101
- return keys.reverse(), function next() {
14102
- for (; keys.length;) {
14103
- var key = keys.pop();
14104
- if (key in object) return next.value = key, next.done = !1, next;
13023
+ renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
13024
+ if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
13025
+ _this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
14105
13026
  }
14106
- return next.done = !0, next;
14107
- };
14108
- }, exports.values = values, Context.prototype = {
14109
- constructor: Context,
14110
- reset: function reset(skipTempReset) {
14111
- 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);
14112
- },
14113
- stop: function stop() {
14114
- this.done = !0;
14115
- var rootRecord = this.tryEntries[0].completion;
14116
- if ("throw" === rootRecord.type) throw rootRecord.arg;
14117
- return this.rval;
14118
- },
14119
- dispatchException: function dispatchException(exception) {
14120
- if (this.done) throw exception;
14121
- var context = this;
14122
- function handle(loc, caught) {
14123
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
13027
+ });
13028
+ renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
13029
+ // remove camera
13030
+ if (_this.$camera) {
13031
+ _this.$camera.remove();
14124
13032
  }
14125
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14126
- var entry = this.tryEntries[i],
14127
- record = entry.completion;
14128
- if ("root" === entry.tryLoc) return handle("end");
14129
- if (entry.tryLoc <= this.prev) {
14130
- var hasCatch = hasOwn.call(entry, "catchLoc"),
14131
- hasFinally = hasOwn.call(entry, "finallyLoc");
14132
- if (hasCatch && hasFinally) {
14133
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
14134
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
14135
- } else if (hasCatch) {
14136
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
14137
- } else {
14138
- if (!hasFinally) throw new Error("try statement without catch or finally");
14139
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
14140
- }
14141
- }
13033
+ canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13034
+ canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13035
+ canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13036
+ canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13037
+ canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13038
+ });
13039
+ };
13040
+ _proto.getId = function getId(object) {
13041
+ return object.id || HTML_PREFIX + object.entity;
13042
+ };
13043
+ _proto.createCamera = function createCamera(camera) {
13044
+ var _this$context$config2 = this.context.config,
13045
+ doc = _this$context$config2.document,
13046
+ width = _this$context$config2.width,
13047
+ height = _this$context$config2.height;
13048
+ var $canvas = this.context.contextService.getDomElement();
13049
+ var $container = $canvas.parentNode;
13050
+ if ($container) {
13051
+ var cameraId = CANVAS_CAMERA_ID;
13052
+ var $existedCamera = $container.querySelector('#' + cameraId);
13053
+ if (!$existedCamera) {
13054
+ var $camera = (doc || document).createElement('div');
13055
+ $existedCamera = $camera;
13056
+ $camera.id = cameraId;
13057
+ // use absolute position
13058
+ $camera.style.position = 'absolute';
13059
+ // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
13060
+ $camera.style.left = ($canvas.offsetLeft || 0) + "px";
13061
+ $camera.style.top = ($canvas.offsetTop || 0) + "px";
13062
+ $camera.style.transformOrigin = 'left top';
13063
+ $camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
13064
+ // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
13065
+ $camera.style.overflow = 'hidden';
13066
+ $camera.style.pointerEvents = 'none';
13067
+ $camera.style.width = (width || 0) + "px";
13068
+ $camera.style.height = (height || 0) + "px";
13069
+ $container.appendChild($camera);
14142
13070
  }
14143
- },
14144
- abrupt: function abrupt(type, arg) {
14145
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14146
- var entry = this.tryEntries[i];
14147
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
14148
- var finallyEntry = entry;
14149
- break;
14150
- }
13071
+ return $existedCamera;
13072
+ }
13073
+ return null;
13074
+ };
13075
+ _proto.getOrCreateEl = function getOrCreateEl(object) {
13076
+ var doc = this.context.config.document;
13077
+ var existedId = this.getId(object);
13078
+ var $existedElement = this.$camera.querySelector('#' + existedId);
13079
+ if (!$existedElement) {
13080
+ $existedElement = (doc || document).createElement('div');
13081
+ object.parsedStyle.$el = $existedElement;
13082
+ $existedElement.id = existedId;
13083
+ if (object.name) {
13084
+ $existedElement.setAttribute('name', object.name);
14151
13085
  }
14152
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
14153
- var record = finallyEntry ? finallyEntry.completion : {};
14154
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
14155
- },
14156
- complete: function complete(record, afterLoc) {
14157
- if ("throw" === record.type) throw record.arg;
14158
- 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;
14159
- },
14160
- finish: function finish(finallyLoc) {
14161
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14162
- var entry = this.tryEntries[i];
14163
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
13086
+ if (object.className) {
13087
+ $existedElement.className = object.className;
14164
13088
  }
14165
- },
14166
- catch: function _catch(tryLoc) {
14167
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14168
- var entry = this.tryEntries[i];
14169
- if (entry.tryLoc === tryLoc) {
14170
- var record = entry.completion;
14171
- if ("throw" === record.type) {
14172
- var thrown = record.arg;
14173
- resetTryEntry(entry);
14174
- }
14175
- return thrown;
13089
+ // use absolute position
13090
+ $existedElement.style.position = 'absolute';
13091
+ // @see https://github.com/antvis/G/issues/1150
13092
+ $existedElement.style.left = "0px";
13093
+ $existedElement.style.top = "0px";
13094
+ $existedElement.style['will-change'] = 'transform';
13095
+ $existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
13096
+ }
13097
+ return $existedElement;
13098
+ };
13099
+ _proto.updateAttribute = function updateAttribute(name, object) {
13100
+ var $el = this.getOrCreateEl(object);
13101
+ switch (name) {
13102
+ case 'innerHTML':
13103
+ var innerHTML = object.parsedStyle.innerHTML;
13104
+ if (isString(innerHTML)) {
13105
+ $el.innerHTML = innerHTML;
13106
+ } else {
13107
+ $el.innerHTML = '';
13108
+ $el.appendChild(innerHTML);
14176
13109
  }
14177
- }
14178
- throw new Error("illegal catch attempt");
14179
- },
14180
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
14181
- return this.delegate = {
14182
- iterator: values(iterable),
14183
- resultName: resultName,
14184
- nextLoc: nextLoc
14185
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13110
+ break;
13111
+ case 'transformOrigin':
13112
+ var transformOrigin = object.parsedStyle.transformOrigin;
13113
+ $el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
13114
+ break;
13115
+ case 'width':
13116
+ if (gLite.runtime.enableCSSParsing) {
13117
+ var width = object.computedStyleMap().get('width');
13118
+ $el.style.width = width.toString();
13119
+ } else {
13120
+ var _width = object.parsedStyle.width;
13121
+ $el.style.width = isNumber(_width) ? _width + "px" : _width.toString();
13122
+ }
13123
+ break;
13124
+ case 'height':
13125
+ if (gLite.runtime.enableCSSParsing) {
13126
+ var height = object.computedStyleMap().get('height');
13127
+ $el.style.height = height.toString();
13128
+ } else {
13129
+ var _height = object.parsedStyle.height;
13130
+ $el.style.height = isNumber(_height) ? _height + "px" : _height.toString();
13131
+ }
13132
+ break;
13133
+ case 'zIndex':
13134
+ var zIndex = object.parsedStyle.zIndex;
13135
+ $el.style['z-index'] = "" + zIndex;
13136
+ break;
13137
+ case 'visibility':
13138
+ var visibility = object.parsedStyle.visibility;
13139
+ $el.style.visibility = visibility;
13140
+ break;
13141
+ case 'pointerEvents':
13142
+ var pointerEvents = object.parsedStyle.pointerEvents;
13143
+ $el.style.pointerEvents = pointerEvents;
13144
+ break;
13145
+ case 'opacity':
13146
+ var opacity = object.parsedStyle.opacity;
13147
+ $el.style.opacity = "" + opacity;
13148
+ break;
13149
+ case 'fill':
13150
+ var fill = object.parsedStyle.fill;
13151
+ var color = '';
13152
+ if (gLite.isCSSRGB(fill)) {
13153
+ if (fill.isNone) {
13154
+ color = 'transparent';
13155
+ } else {
13156
+ color = object.getAttribute('fill');
13157
+ }
13158
+ } else if (Array.isArray(fill)) {
13159
+ color = object.getAttribute('fill');
13160
+ } else if (gLite.isPattern(fill)) ;
13161
+ $el.style.background = color;
13162
+ break;
13163
+ case 'stroke':
13164
+ var stroke = object.parsedStyle.stroke;
13165
+ var borderColor = '';
13166
+ if (gLite.isCSSRGB(stroke)) {
13167
+ if (stroke.isNone) {
13168
+ borderColor = 'transparent';
13169
+ } else {
13170
+ borderColor = object.getAttribute('stroke');
13171
+ }
13172
+ } else if (Array.isArray(stroke)) {
13173
+ borderColor = object.getAttribute('stroke');
13174
+ } else if (gLite.isPattern(stroke)) ;
13175
+ $el.style['border-color'] = borderColor;
13176
+ $el.style['border-style'] = 'solid';
13177
+ break;
13178
+ case 'lineWidth':
13179
+ var lineWidth = object.parsedStyle.lineWidth;
13180
+ $el.style['border-width'] = (lineWidth || 0) + "px";
13181
+ break;
13182
+ case 'lineDash':
13183
+ $el.style['border-style'] = 'dashed';
13184
+ break;
13185
+ case 'filter':
13186
+ var filter = object.style.filter;
13187
+ $el.style.filter = filter;
13188
+ break;
14186
13189
  }
14187
- }, exports;
14188
- }
14189
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
14190
- try {
14191
- var info = gen[key](arg);
14192
- var value = info.value;
14193
- } catch (error) {
14194
- reject(error);
14195
- return;
14196
- }
14197
- if (info.done) {
14198
- resolve(value);
14199
- } else {
14200
- Promise.resolve(value).then(_next, _throw);
13190
+ };
13191
+ return HTMLRenderingPlugin;
13192
+ }();
13193
+ HTMLRenderingPlugin.tag = 'HTMLRendering';
13194
+ var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
13195
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
13196
+ function Plugin() {
13197
+ var _this;
13198
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13199
+ args[_key] = arguments[_key];
13200
+ }
13201
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13202
+ _this.name = 'html-renderer';
13203
+ return _this;
14201
13204
  }
14202
- }
14203
- function _asyncToGenerator$4(fn) {
14204
- return function () {
14205
- var self = this,
14206
- args = arguments;
14207
- return new Promise(function (resolve, reject) {
14208
- var gen = fn.apply(self, args);
14209
- function _next(value) {
14210
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
14211
- }
14212
- function _throw(err) {
14213
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
14214
- }
14215
- _next(undefined);
14216
- });
13205
+ var _proto = Plugin.prototype;
13206
+ _proto.init = function init() {
13207
+ this.addRenderingPlugin(new HTMLRenderingPlugin());
14217
13208
  };
14218
- }
13209
+ _proto.destroy = function destroy() {
13210
+ this.removeAllRenderingPlugins();
13211
+ };
13212
+ return Plugin;
13213
+ }(gLite.AbstractRendererPlugin);
13214
+
13215
+ var index_esm$2 = /*#__PURE__*/Object.freeze({
13216
+ __proto__: null,
13217
+ Plugin: Plugin$2
13218
+ });
13219
+
14219
13220
  function _inheritsLoose$4(subClass, superClass) {
14220
13221
  subClass.prototype = Object.create(superClass.prototype);
14221
13222
  subClass.prototype.constructor = subClass;
@@ -14539,18 +13540,10 @@
14539
13540
  }
14540
13541
  }
14541
13542
  };
14542
- renderingService.hooks.init.tapPromise(LoadImagePlugin.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
14543
- return _regeneratorRuntime$4().wrap(function _callee$(_context) {
14544
- while (1) switch (_context.prev = _context.next) {
14545
- case 0:
14546
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14547
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14548
- case 2:
14549
- case "end":
14550
- return _context.stop();
14551
- }
14552
- }, _callee);
14553
- })));
13543
+ renderingService.hooks.init.tap(LoadImagePlugin.tag, function () {
13544
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13545
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13546
+ });
14554
13547
  renderingService.hooks.destroy.tap(LoadImagePlugin.tag, function () {
14555
13548
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14556
13549
  canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
@@ -14582,8 +13575,8 @@
14582
13575
  return Plugin;
14583
13576
  }(gLite.AbstractRendererPlugin);
14584
13577
 
14585
- function _regeneratorRuntime$5() {
14586
- _regeneratorRuntime$5 = function _regeneratorRuntime() {
13578
+ function _regeneratorRuntime$2() {
13579
+ _regeneratorRuntime$2 = function _regeneratorRuntime() {
14587
13580
  return exports;
14588
13581
  };
14589
13582
  var exports = {},
@@ -14883,7 +13876,7 @@
14883
13876
  }
14884
13877
  }, exports;
14885
13878
  }
14886
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
13879
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
14887
13880
  try {
14888
13881
  var info = gen[key](arg);
14889
13882
  var value = info.value;
@@ -14897,17 +13890,17 @@
14897
13890
  Promise.resolve(value).then(_next, _throw);
14898
13891
  }
14899
13892
  }
14900
- function _asyncToGenerator$5(fn) {
13893
+ function _asyncToGenerator$2(fn) {
14901
13894
  return function () {
14902
13895
  var self = this,
14903
13896
  args = arguments;
14904
13897
  return new Promise(function (resolve, reject) {
14905
13898
  var gen = fn.apply(self, args);
14906
13899
  function _next(value) {
14907
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
13900
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
14908
13901
  }
14909
13902
  function _throw(err) {
14910
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
13903
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
14911
13904
  }
14912
13905
  _next(undefined);
14913
13906
  });
@@ -15058,9 +14051,9 @@
15058
14051
  return _load.apply(this, arguments);
15059
14052
  }
15060
14053
  function _load() {
15061
- _load = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee(module, imports) {
14054
+ _load = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(module, imports) {
15062
14055
  var bytes, instance;
15063
- return _regeneratorRuntime$5().wrap(function _callee$(_context) {
14056
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
15064
14057
  while (1) switch (_context.prev = _context.next) {
15065
14058
  case 0:
15066
14059
  if (!(typeof Response === 'function' && module instanceof Response)) {
@@ -15124,9 +14117,9 @@
15124
14117
  return _init.apply(this, arguments);
15125
14118
  }
15126
14119
  function _init() {
15127
- _init = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee2(input) {
14120
+ _init = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee2(input) {
15128
14121
  var imports, _yield$load, instance, module;
15129
- return _regeneratorRuntime$5().wrap(function _callee2$(_context2) {
14122
+ return _regeneratorRuntime$2().wrap(function _callee2$(_context2) {
15130
14123
  while (1) switch (_context2.prev = _context2.next) {
15131
14124
  case 0:
15132
14125
  imports = {};
@@ -17035,9 +16028,9 @@
17035
16028
  }
17036
16029
  var _proto = WebGPUDeviceContribution.prototype;
17037
16030
  _proto.createSwapChain = /*#__PURE__*/function () {
17038
- var _createSwapChain = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee($canvas) {
16031
+ var _createSwapChain = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee($canvas) {
17039
16032
  var adapter, optionalFeatures, requiredFeatures, device, context;
17040
- return _regeneratorRuntime$5().wrap(function _callee$(_context) {
16033
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
17041
16034
  while (1) switch (_context.prev = _context.next) {
17042
16035
  case 0:
17043
16036
  if (!(gLite.runtime.globalThis.navigator.gpu === undefined)) {
@@ -17157,51 +16150,40 @@
17157
16150
  this.deviceRendererPlugin = context.deviceRendererPlugin;
17158
16151
  }
17159
16152
  var _proto = WebGPUContextService.prototype;
17160
- _proto.init = /*#__PURE__*/function () {
17161
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17162
- var _this$canvasConfig, container, canvas, $canvas;
17163
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17164
- while (1) switch (_context.prev = _context.next) {
17165
- case 0:
17166
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
17167
- if (canvas) {
17168
- this.$canvas = canvas;
17169
- if (container && canvas.parentElement !== container) {
17170
- container.appendChild(canvas);
17171
- }
17172
- this.$container = canvas.parentElement;
17173
- this.canvasConfig.container = this.$container;
17174
- } else if (container) {
17175
- // create container
17176
- this.$container = isString(container) ? document.getElementById(container) : container;
17177
- if (this.$container) {
17178
- // create canvas
17179
- $canvas = document.createElement('canvas');
17180
- this.$container.appendChild($canvas);
17181
- if (!this.$container.style.position) {
17182
- this.$container.style.position = 'relative';
17183
- }
17184
- this.$canvas = $canvas;
17185
- }
17186
- }
17187
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
17188
- case 3:
17189
- case "end":
17190
- return _context.stop();
16153
+ _proto.init = function init() {
16154
+ var _this$canvasConfig = this.canvasConfig,
16155
+ container = _this$canvasConfig.container,
16156
+ canvas = _this$canvasConfig.canvas;
16157
+ if (canvas) {
16158
+ this.$canvas = canvas;
16159
+ if (container && canvas.parentElement !== container) {
16160
+ container.appendChild(canvas);
16161
+ }
16162
+ this.$container = canvas.parentElement;
16163
+ this.canvasConfig.container = this.$container;
16164
+ } else if (container) {
16165
+ // create container
16166
+ this.$container = isString(container) ? document.getElementById(container) : container;
16167
+ if (this.$container) {
16168
+ // create canvas
16169
+ var $canvas = document.createElement('canvas');
16170
+ this.$container.appendChild($canvas);
16171
+ if (!this.$container.style.position) {
16172
+ this.$container.style.position = 'relative';
17191
16173
  }
17192
- }, _callee, this);
17193
- }));
17194
- function init() {
17195
- return _init.apply(this, arguments);
16174
+ this.$canvas = $canvas;
16175
+ }
17196
16176
  }
17197
- return init;
17198
- }();
16177
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
16178
+ };
17199
16179
  _proto.getDomElement = function getDomElement() {
17200
16180
  return this.$canvas;
17201
16181
  };
17202
16182
  _proto.getContext = function getContext() {
17203
- // @ts-ignore
17204
- return this.deviceRendererPlugin.getDevice().canvasContext;
16183
+ return (
16184
+ // @ts-ignore
16185
+ this.deviceRendererPlugin.getDevice().canvasContext
16186
+ );
17205
16187
  };
17206
16188
  _proto.getBoundingClientRect = function getBoundingClientRect() {
17207
16189
  if (this.$canvas.getBoundingClientRect) {
@@ -17239,16 +16221,16 @@
17239
16221
  }
17240
16222
  };
17241
16223
  _proto.toDataURL = /*#__PURE__*/function () {
17242
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
17243
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17244
- while (1) switch (_context2.prev = _context2.next) {
16224
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
16225
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
16226
+ while (1) switch (_context.prev = _context.next) {
17245
16227
  case 0:
17246
- return _context2.abrupt("return", '');
16228
+ return _context.abrupt("return", '');
17247
16229
  case 1:
17248
16230
  case "end":
17249
- return _context2.stop();
16231
+ return _context.stop();
17250
16232
  }
17251
- }, _callee2);
16233
+ }, _callee);
17252
16234
  }));
17253
16235
  function toDataURL(_x) {
17254
16236
  return _toDataURL.apply(this, arguments);