@visactor/vrender 1.1.0-alpha.22 → 1.1.0-alpha.23

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.js CHANGED
@@ -169,7 +169,7 @@
169
169
  }
170
170
  }
171
171
 
172
- var __awaiter$a = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
172
+ var __awaiter$8 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
173
173
  return new (P || (P = Promise))(function (resolve, reject) {
174
174
  function fulfilled(value) {
175
175
  try {
@@ -338,7 +338,7 @@
338
338
  return this._env || this.setEnv("browser"), this.envContribution.loadBlob(url);
339
339
  }
340
340
  loadFont(name, source, descriptors) {
341
- return __awaiter$a(this, void 0, void 0, function* () {
341
+ return __awaiter$8(this, void 0, void 0, function* () {
342
342
  return this._env || this.setEnv("browser"), this.envContribution.loadFont(name, source, descriptors);
343
343
  });
344
344
  }
@@ -2668,7 +2668,7 @@
2668
2668
  };
2669
2669
  const lowerCamelCaseToMiddle = str => str.replace(/([A-Z])/g, "-$1").toLowerCase();
2670
2670
 
2671
- var __awaiter$9 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
2671
+ var __awaiter$7 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
2672
2672
  return new (P || (P = Promise))(function (resolve, reject) {
2673
2673
  function fulfilled(value) {
2674
2674
  try {
@@ -2736,7 +2736,7 @@
2736
2736
  }
2737
2737
  }
2738
2738
  forEachChildrenAsync(cb, reverse = !1) {
2739
- return __awaiter$9(this, void 0, void 0, function* () {
2739
+ return __awaiter$7(this, void 0, void 0, function* () {
2740
2740
  if (reverse) {
2741
2741
  let child = this._lastChild,
2742
2742
  i = 0;
@@ -6292,7 +6292,7 @@
6292
6292
  return str.startsWith("<");
6293
6293
  }
6294
6294
 
6295
- var __awaiter$8 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
6295
+ var __awaiter$6 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
6296
6296
  return new (P || (P = Promise))(function (resolve, reject) {
6297
6297
  function fulfilled(value) {
6298
6298
  try {
@@ -6321,7 +6321,7 @@
6321
6321
  group.incrementalAppendChild(graphic);
6322
6322
  }
6323
6323
  function waitForAllSubLayers(stage) {
6324
- return __awaiter$8(this, void 0, void 0, function* () {
6324
+ return __awaiter$6(this, void 0, void 0, function* () {
6325
6325
  const promiseList = [],
6326
6326
  layers = stage.getChildren();
6327
6327
  yield new Promise(resolve => {
@@ -14304,7 +14304,7 @@
14304
14304
  }
14305
14305
  }
14306
14306
 
14307
- var __awaiter$7 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
14307
+ var __awaiter$5 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
14308
14308
  return new (P || (P = Promise))(function (resolve, reject) {
14309
14309
  function fulfilled(value) {
14310
14310
  try {
@@ -14374,7 +14374,7 @@
14374
14374
  } else graphic.forEachChildren(cb, reverse);
14375
14375
  }
14376
14376
  function foreachAsync(graphic, defaultZIndex, cb, reverse = !1) {
14377
- return __awaiter$7(this, void 0, void 0, function* () {
14377
+ return __awaiter$5(this, void 0, void 0, function* () {
14378
14378
  yield graphic.forEachChildrenAsync(cb, reverse);
14379
14379
  });
14380
14380
  }
@@ -15261,7 +15261,7 @@
15261
15261
  return isBrowserEnv() ? "browser" : "node";
15262
15262
  }
15263
15263
 
15264
- var __awaiter$6 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
15264
+ var __awaiter$4 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
15265
15265
  return new (P || (P = Promise))(function (resolve, reject) {
15266
15266
  function fulfilled(value) {
15267
15267
  try {
@@ -15458,7 +15458,7 @@
15458
15458
  }
15459
15459
  runJob(job) {
15460
15460
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
15461
- return __awaiter$6(this, void 0, void 0, function* () {
15461
+ return __awaiter$4(this, void 0, void 0, function* () {
15462
15462
  if ("cancelled" === job.status) return;
15463
15463
  if (yield this.waitForNextFrame(), "cancelled" === job.status) return;
15464
15464
  job.status = "running", null === (_a = this.perfMonitor) || void 0 === _a || _a.recordEvent("deferred-job-start", {
@@ -17943,7 +17943,7 @@
17943
17943
  }
17944
17944
 
17945
17945
  var STATUS,
17946
- __awaiter$5 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
17946
+ __awaiter$3 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
17947
17947
  return new (P || (P = Promise))(function (resolve, reject) {
17948
17948
  function fulfilled(value) {
17949
17949
  try {
@@ -17978,7 +17978,7 @@
17978
17978
  }, this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender), this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
17979
17979
  }
17980
17980
  draw(renderService, drawContext) {
17981
- return __awaiter$5(this, void 0, void 0, function* () {
17981
+ return __awaiter$3(this, void 0, void 0, function* () {
17982
17982
  if (this.checkingForDrawPromise) return;
17983
17983
  this.lastRenderService = renderService, this.lastDrawContext = drawContext, this.checkingForDrawPromise = this.checkForDraw(drawContext);
17984
17984
  const skipDraw = yield this.checkingForDrawPromise;
@@ -17999,15 +17999,15 @@
17999
17999
  });
18000
18000
  }
18001
18001
  _increaseRender(group, drawContext) {
18002
- return __awaiter$5(this, void 0, void 0, function* () {
18002
+ return __awaiter$3(this, void 0, void 0, function* () {
18003
18003
  this.rendering = !0, yield this._renderIncrementalGroup(group, drawContext);
18004
18004
  });
18005
18005
  }
18006
18006
  _renderIncrementalGroup(group, drawContext) {
18007
- return __awaiter$5(this, void 0, void 0, function* () {
18007
+ return __awaiter$3(this, void 0, void 0, function* () {
18008
18008
  this.count = group.count, yield new Promise(resolve => {
18009
18009
  this.renderItem(group, drawContext, {
18010
- drawingCb: () => __awaiter$5(this, void 0, void 0, function* () {
18010
+ drawingCb: () => __awaiter$3(this, void 0, void 0, function* () {
18011
18011
  if (2 !== group.count) yield foreachAsync(group, DefaultAttribute.zIndex, (item, i) => {
18012
18012
  if (this.status === STATUS.STOP) return !0;
18013
18013
  if (item.isContainer) return !1;
@@ -18028,7 +18028,7 @@
18028
18028
  });
18029
18029
  }
18030
18030
  waitToNextFrame() {
18031
- return __awaiter$5(this, void 0, void 0, function* () {
18031
+ return __awaiter$3(this, void 0, void 0, function* () {
18032
18032
  return new Promise(resolve => {
18033
18033
  this.global.getRequestAnimationFrame()(() => {
18034
18034
  resolve(!1);
@@ -18037,13 +18037,13 @@
18037
18037
  });
18038
18038
  }
18039
18039
  checkForDraw(drawContext) {
18040
- return __awaiter$5(this, void 0, void 0, function* () {
18040
+ return __awaiter$3(this, void 0, void 0, function* () {
18041
18041
  let skip = this.rendering;
18042
18042
  return drawContext.restartIncremental && (skip = !1, yield this.forceStop(), this.resetToInit()), skip;
18043
18043
  });
18044
18044
  }
18045
18045
  forceStop() {
18046
- return __awaiter$5(this, void 0, void 0, function* () {
18046
+ return __awaiter$3(this, void 0, void 0, function* () {
18047
18047
  this.rendering && (this.status = STATUS.STOP, yield new Promise(resolve => {
18048
18048
  this.hooks.completeDraw.tap("stopCb", () => {
18049
18049
  this.status = STATUS.NORMAL, this.hooks.completeDraw.taps = this.hooks.completeDraw.taps.filter(item => "stopCb" !== item.name), resolve(!1);
@@ -18055,11 +18055,11 @@
18055
18055
  this.currFrameStartAt = 0, this.currentIdx = 0;
18056
18056
  }
18057
18057
  renderGroup(group, drawContext) {
18058
- return __awaiter$5(this, void 0, void 0, function* () {
18058
+ return __awaiter$3(this, void 0, void 0, function* () {
18059
18059
  if (!drawContext.break && !1 !== group.attribute.visibleAll) return group.incremental && drawContext.startAtId === group._uid ? (yield this._increaseRender(group, drawContext), void (drawContext.break = !0)) : void (yield new Promise(resolve => {
18060
18060
  this.renderItem(group, drawContext, {
18061
- drawingCb: () => __awaiter$5(this, void 0, void 0, function* () {
18062
- yield foreachAsync(group, DefaultAttribute.zIndex, item => __awaiter$5(this, void 0, void 0, function* () {
18061
+ drawingCb: () => __awaiter$3(this, void 0, void 0, function* () {
18062
+ yield foreachAsync(group, DefaultAttribute.zIndex, item => __awaiter$3(this, void 0, void 0, function* () {
18063
18063
  drawContext.break || item.isContainer && (yield this.renderGroup(item, drawContext));
18064
18064
  })), resolve(!1);
18065
18065
  })
@@ -19937,7 +19937,7 @@
19937
19937
  }
19938
19938
  }
19939
19939
 
19940
- var __awaiter$4 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
19940
+ var __awaiter$2 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
19941
19941
  return new (P || (P = Promise))(function (resolve, reject) {
19942
19942
  function fulfilled(value) {
19943
19943
  try {
@@ -20031,7 +20031,7 @@
20031
20031
  };
20032
20032
  }
20033
20033
  loadFont(font, source, descriptors) {
20034
- return __awaiter$4(this, void 0, void 0, function* () {
20034
+ return __awaiter$2(this, void 0, void 0, function* () {
20035
20035
  return {
20036
20036
  loadState: "fail"
20037
20037
  };
@@ -27097,7 +27097,9 @@
27097
27097
  init() {
27098
27098
  this._context = new HarmonyContext2d(this, this._dpr);
27099
27099
  }
27100
- resize(width, height) {}
27100
+ resize(width, height) {
27101
+ this.controled && (this._pixelWidth = width * this._dpr, this._pixelHeight = height * this._dpr, this._displayWidth = width, this._displayHeight = height, this._nativeCanvas.width = this._pixelWidth, this._nativeCanvas.height = this._pixelHeight, this._context.dpr = this._dpr);
27102
+ }
27101
27103
  release(...params) {}
27102
27104
  }
27103
27105
  HarmonyCanvas.env = "harmony";
@@ -28028,7 +28030,7 @@
28028
28030
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, BrowserWindowHandlerContribution)) || container.bind(BrowserWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, BrowserWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(BrowserWindowHandlerContribution).whenTargetNamed(BrowserWindowHandlerContribution.env);
28029
28031
  }
28030
28032
 
28031
- var __awaiter$3 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
28033
+ var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
28032
28034
  return new (P || (P = Promise))(function (resolve, reject) {
28033
28035
  function fulfilled(value) {
28034
28036
  try {
@@ -28247,7 +28249,7 @@
28247
28249
  };
28248
28250
  }
28249
28251
  loadFont(font, source, descriptors) {
28250
- return __awaiter$3(this, void 0, void 0, function* () {
28252
+ return __awaiter$1(this, void 0, void 0, function* () {
28251
28253
  return new FontFace(font, isString$1(source) ? `url(${source})` : source, descriptors).load().then(function (loadedFont) {
28252
28254
  return document.fonts.add(loadedFont), {
28253
28255
  loadState: "success"
@@ -28346,7 +28348,12 @@
28346
28348
  createWindowByCanvas(params) {
28347
28349
  let canvas;
28348
28350
  if ("string" == typeof params.canvas) {
28349
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
28351
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
28352
+ id: params.canvas,
28353
+ width: params.width,
28354
+ height: params.height,
28355
+ dpr: params.dpr
28356
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
28350
28357
  } else canvas = params.canvas;
28351
28358
  let width = params.width,
28352
28359
  height = params.height;
@@ -28673,17 +28680,55 @@
28673
28680
  }
28674
28681
  }
28675
28682
 
28676
- function makeUpCanvas$4(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, pixelRatio) {
28677
- const dpr = null != pixelRatio ? pixelRatio : tt.getSystemInfoSync().pixelRatio;
28678
- canvasIdLists.forEach((id, i) => {
28679
- const ctx = tt.createCanvasContext(id),
28680
- canvas = new CanvasWrapDisableWH(ctx.canvas || {}, ctx, dpr, domref.width, domref.height, id);
28681
- ctx.canvas = canvas, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas);
28682
- });
28683
+ function getMiniAppCanvasOptions(params, pixelRatio, offscreen = null == params.id) {
28684
+ var _a, _b, _c;
28685
+ return {
28686
+ id: null == params.id ? void 0 : String(params.id),
28687
+ width: null !== (_a = params.width) && void 0 !== _a ? _a : 0,
28688
+ height: null !== (_b = params.height) && void 0 !== _b ? _b : 0,
28689
+ dpr: null !== (_c = params.dpr) && void 0 !== _c ? _c : pixelRatio,
28690
+ offscreen: offscreen
28691
+ };
28692
+ }
28693
+ function wrapMiniAppNativeCanvas(nativeCanvas, options) {
28694
+ var _a;
28695
+ const ctx = null === (_a = null == nativeCanvas ? void 0 : nativeCanvas.getContext) || void 0 === _a ? void 0 : _a.call(nativeCanvas, "2d");
28696
+ if (!ctx) throw new Error('MiniApp canvas bridge returned a canvas without getContext("2d").');
28697
+ return new CanvasWrapEnableWH(nativeCanvas, ctx, options.dpr, options.width, options.height, options.id);
28698
+ }
28699
+ function wrapMiniAppContextCanvas(ctx, options) {
28700
+ if (!ctx) throw new Error("MiniApp canvas bridge returned an empty 2d context.");
28701
+ const canvas = new CanvasWrapDisableWH(ctx.canvas || {}, ctx, options.dpr, options.width, options.height, options.id);
28702
+ return ctx.canvas = canvas, canvas;
28703
+ }
28704
+ function createCanvasWithFactory(params, pixelRatio, canvasMap, factory) {
28705
+ const options = getMiniAppCanvasOptions(params, pixelRatio),
28706
+ id = options.id;
28707
+ if (null != id) {
28708
+ const existing = canvasMap.get(id);
28709
+ if (existing) return existing;
28710
+ }
28711
+ if (!factory) return null;
28712
+ const canvas = wrapMiniAppNativeCanvas(factory(options), options);
28713
+ return null != id && canvasMap.set(id, canvas), canvas;
28714
+ }
28715
+
28716
+ const FEISHU_CANVAS_BRIDGE_ERROR = "Feishu canvas bridge is unavailable. VRender feishu env requires envParams.canvasFactory, a Stage canvas object, or a feishu/tt runtime that exposes createCanvasContext(id).";
28717
+ function getFeishuRuntime(params) {
28718
+ var _a, _b, _c, _d, _e;
28719
+ try {
28720
+ return null !== (_c = null !== (_b = null !== (_a = null == params ? void 0 : params.feishu) && void 0 !== _a ? _a : null == params ? void 0 : params.tt) && void 0 !== _b ? _b : null == params ? void 0 : params.runtime) && void 0 !== _c ? _c : "undefined" != typeof tt ? tt : void 0;
28721
+ } catch (_f) {
28722
+ return null !== (_e = null !== (_d = null == params ? void 0 : params.feishu) && void 0 !== _d ? _d : null == params ? void 0 : params.tt) && void 0 !== _e ? _e : null == params ? void 0 : params.runtime;
28723
+ }
28724
+ }
28725
+ function getFeishuPixelRatio(params, runtime = getFeishuRuntime(params)) {
28726
+ var _a, _b, _c, _d;
28727
+ return null !== (_d = null !== (_a = null == params ? void 0 : params.pixelRatio) && void 0 !== _a ? _a : null === (_c = null === (_b = null == runtime ? void 0 : runtime.getSystemInfoSync) || void 0 === _b ? void 0 : _b.call(runtime)) || void 0 === _c ? void 0 : _c.pixelRatio) && void 0 !== _d ? _d : 1;
28683
28728
  }
28684
28729
  class FeishuEnvContribution extends BaseEnvContribution {
28685
28730
  constructor() {
28686
- super(), this.type = "feishu", this.supportEvent = !0, this.canvasMap = new Map(), this.freeCanvasList = [], this.canvasIdx = 0, this.supportsTouchEvents = !0;
28731
+ super(), this.type = "feishu", this.supportEvent = !0, this.canvasMap = new Map(), this.feishuEnvParams = {}, this.supportsTouchEvents = !0;
28687
28732
  try {
28688
28733
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
28689
28734
  } catch (err) {
@@ -28692,13 +28737,13 @@
28692
28737
  this.applyStyles = !0;
28693
28738
  }
28694
28739
  getDynamicCanvasCount() {
28695
- return this.freeCanvasList.length;
28740
+ return 0;
28696
28741
  }
28697
28742
  getStaticCanvasCount() {
28698
28743
  return 9999;
28699
28744
  }
28700
- configure(service, params) {
28701
- service.env === this.type && (service.setActiveEnvContribution(this), makeUpCanvas$4(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, params.pixelRatio));
28745
+ configure(service, params = {}) {
28746
+ service.env === this.type && (service.setActiveEnvContribution(this), this.feishuEnvParams = params);
28702
28747
  }
28703
28748
  loadImage(url) {
28704
28749
  return Promise.resolve({
@@ -28710,13 +28755,21 @@
28710
28755
  return Promise.reject();
28711
28756
  }
28712
28757
  createCanvas(params) {
28713
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
28714
- return this.canvasIdx++, result;
28758
+ var _a;
28759
+ const envParams = this.feishuEnvParams,
28760
+ runtime = getFeishuRuntime(envParams),
28761
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : getFeishuPixelRatio(envParams, runtime),
28762
+ factoryCanvas = createCanvasWithFactory(params, dpr, this.canvasMap, envParams.canvasFactory);
28763
+ if (factoryCanvas) return factoryCanvas;
28764
+ const options = getMiniAppCanvasOptions(params, dpr, !1);
28765
+ if (null == options.id || "function" != typeof (null == runtime ? void 0 : runtime.createCanvasContext)) throw new Error(FEISHU_CANVAS_BRIDGE_ERROR);
28766
+ const canvas = wrapMiniAppContextCanvas(runtime.createCanvasContext(options.id), options);
28767
+ return this.canvasMap.set(options.id, canvas), canvas;
28715
28768
  }
28716
28769
  createOffscreenCanvas(params) {}
28717
28770
  releaseCanvas(canvas) {}
28718
28771
  getDevicePixelRatio() {
28719
- return tt.getSystemInfoSync().pixelRatio;
28772
+ return getFeishuPixelRatio(this.feishuEnvParams);
28720
28773
  }
28721
28774
  getRequestAnimationFrame() {
28722
28775
  return function (callback) {
@@ -28784,6 +28837,40 @@
28784
28837
  this.cache = {};
28785
28838
  }
28786
28839
  };
28840
+ function setMiniAppEventTarget$2(event, key, value) {
28841
+ if (event && value) try {
28842
+ event[key] = value;
28843
+ } catch (_a) {
28844
+ Object.defineProperty(event, key, {
28845
+ configurable: !0,
28846
+ value: value
28847
+ });
28848
+ }
28849
+ }
28850
+ function isValidCoordinate$3(value) {
28851
+ return "number" == typeof value && Number.isFinite(value);
28852
+ }
28853
+ function pickCoordinate$3(...values) {
28854
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate$3(values[i])) return values[i];
28855
+ }
28856
+ function setHarmonyEventValue(event, key, value) {
28857
+ try {
28858
+ event[key] = value;
28859
+ } catch (_a) {
28860
+ Object.defineProperty(event, key, {
28861
+ configurable: !0,
28862
+ value: value
28863
+ });
28864
+ }
28865
+ }
28866
+ function normalizeHarmonyTouchEventPoint(event) {
28867
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
28868
+ const touch = null !== (_b = null === (_a = null == event ? void 0 : event.changedTouches) || void 0 === _a ? void 0 : _a[0]) && void 0 !== _b ? _b : null === (_c = null == event ? void 0 : event.touches) || void 0 === _c ? void 0 : _c[0];
28869
+ if (!touch) return;
28870
+ const x = pickCoordinate$3(event.x, event.offsetX, event.clientX, event.pageX, touch.x, touch.offsetX, touch.clientX, touch.pageX),
28871
+ y = pickCoordinate$3(event.y, event.offsetY, event.clientY, event.pageY, touch.y, touch.offsetY, touch.clientY, touch.pageY);
28872
+ null != x && null != y && (!event.touches && event.changedTouches && setHarmonyEventValue(event, "touches", "touchend" === event.type || "touchcancel" === event.type ? [] : event.changedTouches), setHarmonyEventValue(event, "x", x), setHarmonyEventValue(event, "y", y), setHarmonyEventValue(event, "offsetX", null !== (_d = event.offsetX) && void 0 !== _d ? _d : x), setHarmonyEventValue(event, "offsetY", null !== (_e = event.offsetY) && void 0 !== _e ? _e : y), setHarmonyEventValue(event, "clientX", null !== (_f = event.clientX) && void 0 !== _f ? _f : x), setHarmonyEventValue(event, "clientY", null !== (_g = event.clientY) && void 0 !== _g ? _g : y), setHarmonyEventValue(event, "pageX", null !== (_h = event.pageX) && void 0 !== _h ? _h : x), setHarmonyEventValue(event, "pageY", null !== (_j = event.pageY) && void 0 !== _j ? _j : y), touch.x = null !== (_k = touch.x) && void 0 !== _k ? _k : x, touch.y = null !== (_l = touch.y) && void 0 !== _l ? _l : y, touch.offsetX = null !== (_m = touch.offsetX) && void 0 !== _m ? _m : x, touch.offsetY = null !== (_o = touch.offsetY) && void 0 !== _o ? _o : y, touch.clientX = null !== (_p = touch.clientX) && void 0 !== _p ? _p : x, touch.clientY = null !== (_q = touch.clientY) && void 0 !== _q ? _q : y, touch.pageX = null !== (_r = touch.pageX) && void 0 !== _r ? _r : x, touch.pageY = null !== (_s = touch.pageY) && void 0 !== _s ? _s : y);
28873
+ }
28787
28874
  class HarmonyWindowHandlerContribution extends BaseWindowHandlerContribution {
28788
28875
  get container() {
28789
28876
  return null;
@@ -28812,7 +28899,8 @@
28812
28899
  createWindowByConfig(params) {
28813
28900
  const nativeCanvas = this.global.createCanvas({
28814
28901
  width: params.width,
28815
- height: params.height
28902
+ height: params.height,
28903
+ dpr: params.dpr
28816
28904
  }),
28817
28905
  options = {
28818
28906
  width: params.width,
@@ -28827,7 +28915,12 @@
28827
28915
  createWindowByCanvas(params) {
28828
28916
  let canvas;
28829
28917
  if ("string" == typeof params.canvas) {
28830
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
28918
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
28919
+ id: params.canvas,
28920
+ width: params.width,
28921
+ height: params.height,
28922
+ dpr: params.dpr
28923
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
28831
28924
  } else canvas = params.canvas;
28832
28925
  let width = params.width,
28833
28926
  height = params.height;
@@ -28835,15 +28928,19 @@
28835
28928
  const data = canvas.getBoundingClientRect();
28836
28929
  width = data.width, height = data.height;
28837
28930
  }
28838
- this.canvas = new HarmonyCanvas({
28931
+ let dpr = params.dpr;
28932
+ null == dpr && (dpr = canvas.width / width), this.canvas = new HarmonyCanvas({
28839
28933
  width: width,
28840
28934
  height: height,
28841
- dpr: 1,
28935
+ dpr: dpr,
28842
28936
  nativeCanvas: canvas,
28843
28937
  canvasControled: params.canvasControled
28844
28938
  });
28845
28939
  }
28846
- releaseWindow() {}
28940
+ releaseWindow() {
28941
+ var _a, _b;
28942
+ this.eventManager.cleanEvent(), null === (_b = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a);
28943
+ }
28847
28944
  resizeWindow(width, height) {
28848
28945
  this.canvas.resize(width, height);
28849
28946
  }
@@ -28866,12 +28963,15 @@
28866
28963
  this.eventManager.removeEventListener(type, listener);
28867
28964
  }
28868
28965
  dispatchEvent(event) {
28966
+ var _a;
28869
28967
  const {
28870
28968
  type: type
28871
28969
  } = event;
28872
- return !!this.eventManager.cache[type] && (event.changedTouches && event.changedTouches[0] && (event.offsetX = event.changedTouches[0].x, event.changedTouches[0].offsetX = event.changedTouches[0].x, event.changedTouches[0].clientX = event.changedTouches[0].x, event.offsetY = event.changedTouches[0].y, event.changedTouches[0].offsetY = event.changedTouches[0].y, event.changedTouches[0].clientY = event.changedTouches[0].y), event.preventDefault = () => {}, event.stopPropagation = () => {}, this.eventManager.cache[type].listener && this.eventManager.cache[type].listener.forEach(f => {
28970
+ if (!this.eventManager.cache[type]) return !1;
28971
+ const nativeCanvas = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.nativeCanvas;
28972
+ return setMiniAppEventTarget$2(event, "target", nativeCanvas), setMiniAppEventTarget$2(event, "currentTarget", nativeCanvas), normalizeHarmonyTouchEventPoint(event), event.preventDefault = () => {}, event.stopPropagation = () => {}, this.eventManager.cache[type].listener && this.eventManager.cache[type].listener.forEach(f => {
28873
28973
  f(event);
28874
- }), !0);
28974
+ }), !0;
28875
28975
  }
28876
28976
  getStyle() {
28877
28977
  return {};
@@ -28903,24 +29003,89 @@
28903
29003
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, HarmonyWindowHandlerContribution)) || container.bind(HarmonyWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, HarmonyWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(HarmonyWindowHandlerContribution).whenTargetNamed(HarmonyWindowHandlerContribution.env);
28904
29004
  }
28905
29005
 
28906
- function createCanvas(width, height, id) {
28907
- const _c = new OffscreenCanvas(width, height),
28908
- context = _c.getContext("2d");
28909
- return new CanvasWrapDisableWH({
29006
+ const HARMONY_CANVAS_BRIDGE_ERROR = "Harmony canvas bridge is unavailable. VRender Harmony env requires envParams.canvasFactory or a Harmony runtime that exposes a global createCanvas/createOffscreenCanvas capability.",
29007
+ HARMONY_CANVAS_SIZE_ERROR = "Harmony canvas size is unavailable. Pass stage width/height when creating a Harmony stage canvas.";
29008
+ function isValidCoordinate$2(value) {
29009
+ return "number" == typeof value && Number.isFinite(value);
29010
+ }
29011
+ function pickCoordinate$2(...values) {
29012
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate$2(values[i])) return values[i];
29013
+ }
29014
+ function getPrimaryTouch$1(event) {
29015
+ var _a, _b, _c;
29016
+ return null !== (_b = null === (_a = null == event ? void 0 : event.changedTouches) || void 0 === _a ? void 0 : _a[0]) && void 0 !== _b ? _b : null === (_c = null == event ? void 0 : event.touches) || void 0 === _c ? void 0 : _c[0];
29017
+ }
29018
+ function getHarmonyEventPoint(event) {
29019
+ const touch = getPrimaryTouch$1(event),
29020
+ x = pickCoordinate$2(null == event ? void 0 : event.x, null == event ? void 0 : event.offsetX, null == event ? void 0 : event.clientX, null == event ? void 0 : event.pageX, null == touch ? void 0 : touch.x, null == touch ? void 0 : touch.offsetX, null == touch ? void 0 : touch.clientX, null == touch ? void 0 : touch.pageX),
29021
+ y = pickCoordinate$2(null == event ? void 0 : event.y, null == event ? void 0 : event.offsetY, null == event ? void 0 : event.clientY, null == event ? void 0 : event.pageY, null == touch ? void 0 : touch.y, null == touch ? void 0 : touch.offsetY, null == touch ? void 0 : touch.clientY, null == touch ? void 0 : touch.pageY);
29022
+ return null == x || null == y ? null : {
29023
+ x: x,
29024
+ y: y
29025
+ };
29026
+ }
29027
+ function getHarmonyRuntime(params) {
29028
+ var _a;
29029
+ return null !== (_a = null == params ? void 0 : params.harmony) && void 0 !== _a ? _a : null == params ? void 0 : params.runtime;
29030
+ }
29031
+ function getHarmonyPixelRatio(params) {
29032
+ var _a;
29033
+ return null !== (_a = null == params ? void 0 : params.pixelRatio) && void 0 !== _a ? _a : 1;
29034
+ }
29035
+ function getCanvasSize$1(width, height) {
29036
+ if (!isValidCoordinate$2(width) || !isValidCoordinate$2(height)) throw new Error(HARMONY_CANVAS_SIZE_ERROR);
29037
+ return {
29038
+ width: width,
29039
+ height: height
29040
+ };
29041
+ }
29042
+ function getGlobalOffscreenCanvasCtor() {
29043
+ try {
29044
+ return "undefined" != typeof OffscreenCanvas ? OffscreenCanvas : void 0;
29045
+ } catch (err) {
29046
+ return;
29047
+ }
29048
+ }
29049
+ function createFallbackOffscreenCanvas(width, height) {
29050
+ const OffscreenCanvasCtor = getGlobalOffscreenCanvasCtor();
29051
+ return "function" != typeof OffscreenCanvasCtor ? null : new OffscreenCanvasCtor(width, height);
29052
+ }
29053
+ function wrapHarmonyNativeCanvas(nativeCanvas, id, width, height, dpr) {
29054
+ var _a, _b, _c;
29055
+ nativeCanvas.width = width * dpr, nativeCanvas.height = height * dpr;
29056
+ const context = null !== (_b = null === (_a = nativeCanvas.getContext) || void 0 === _a ? void 0 : _a.call(nativeCanvas, "2d")) && void 0 !== _b ? _b : null === (_c = nativeCanvas.getContext) || void 0 === _c ? void 0 : _c.call(nativeCanvas);
29057
+ if (!context) throw new Error(HARMONY_CANVAS_BRIDGE_ERROR);
29058
+ return "function" != typeof nativeCanvas.getBoundingClientRect && (nativeCanvas.getBoundingClientRect = () => ({
29059
+ width: width,
29060
+ height: height
29061
+ })), new CanvasWrapEnableWH(nativeCanvas, context, dpr, width, height, id);
29062
+ }
29063
+ function createHarmonyNativeCanvas(id, width, height, dpr, offscreen, params, runtime) {
29064
+ const options = {
29065
+ id: id,
28910
29066
  width: width,
28911
29067
  height: height,
28912
- context: context,
28913
- _c: _c,
28914
- getBoundingClientRect: () => ({
28915
- width: width,
28916
- height: height
28917
- }),
28918
- getContext: () => context
28919
- }, context, 1, width, height, id);
29068
+ dpr: dpr,
29069
+ offscreen: offscreen
29070
+ };
29071
+ if (params.canvasFactory) return params.canvasFactory(options);
29072
+ if (offscreen && "function" == typeof (null == runtime ? void 0 : runtime.createOffscreenCanvas)) {
29073
+ const canvas = runtime.createOffscreenCanvas(options);
29074
+ if (canvas) return canvas;
29075
+ }
29076
+ if (!offscreen && "function" == typeof (null == runtime ? void 0 : runtime.createCanvas)) {
29077
+ const canvas = runtime.createCanvas(options);
29078
+ if (canvas) return canvas;
29079
+ }
29080
+ if (offscreen) {
29081
+ const canvas = createFallbackOffscreenCanvas(width * dpr, height * dpr);
29082
+ if (canvas) return canvas;
29083
+ }
29084
+ throw new Error(HARMONY_CANVAS_BRIDGE_ERROR);
28920
29085
  }
28921
29086
  class HarmonyEnvContribution extends BaseEnvContribution {
28922
29087
  constructor() {
28923
- super(), this.type = "harmony", this.supportEvent = !0, this.supportsTouchEvents = !0;
29088
+ super(), this.type = "harmony", this.supportEvent = !0, this.canvasMap = new Map(), this.freeCanvasList = [], this.canvasIdx = 0, this.supportsTouchEvents = !0;
28924
29089
  try {
28925
29090
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
28926
29091
  } catch (err) {
@@ -28928,8 +29093,8 @@
28928
29093
  }
28929
29094
  this.applyStyles = !0, this.rafSTO = new RafBasedSTO(0);
28930
29095
  }
28931
- configure(service, params) {
28932
- service.env === this.type && service.setActiveEnvContribution(this);
29096
+ configure(service, params = {}) {
29097
+ service.env === this.type && (service.setActiveEnvContribution(this), this.harmonyEnvParams = params, this.harmonyRuntime = getHarmonyRuntime(params));
28933
29098
  }
28934
29099
  getDynamicCanvasCount() {
28935
29100
  return 9999;
@@ -28937,17 +29102,56 @@
28937
29102
  getStaticCanvasCount() {
28938
29103
  return 9999;
28939
29104
  }
28940
- loadImage(url) {}
29105
+ loadImage(url) {
29106
+ var _a;
29107
+ if ("function" != typeof (null === (_a = this.harmonyRuntime) || void 0 === _a ? void 0 : _a.createImage)) return Promise.resolve({
29108
+ data: null,
29109
+ loadState: "fail"
29110
+ });
29111
+ const img = this.harmonyRuntime.createImage(url);
29112
+ return new Promise(resolve => {
29113
+ img.onload = () => {
29114
+ resolve({
29115
+ data: img,
29116
+ loadState: "success"
29117
+ });
29118
+ }, img.onerror = () => {
29119
+ resolve({
29120
+ data: null,
29121
+ loadState: "fail"
29122
+ });
29123
+ };
29124
+ });
29125
+ }
28941
29126
  loadSvg(url) {
28942
- return Promise.reject();
29127
+ return Promise.resolve({
29128
+ data: null,
29129
+ loadState: "fail"
29130
+ });
28943
29131
  }
28944
29132
  createCanvas(params) {
28945
- return createCanvas(params.width, params.height, params.id);
29133
+ var _a, _b;
29134
+ const envParams = null !== (_a = this.harmonyEnvParams) && void 0 !== _a ? _a : {},
29135
+ runtime = getHarmonyRuntime(envParams),
29136
+ dpr = null !== (_b = params.dpr) && void 0 !== _b ? _b : getHarmonyPixelRatio(envParams),
29137
+ size = getCanvasSize$1(params.width, params.height);
29138
+ if (null != params.id) {
29139
+ const id = String(params.id),
29140
+ existing = this.canvasMap.get(id);
29141
+ if (existing) return existing;
29142
+ const canvas = wrapHarmonyNativeCanvas(createHarmonyNativeCanvas(id, size.width, size.height, dpr, !1, envParams, runtime), id, size.width, size.height, dpr);
29143
+ return this.canvasMap.set(id, canvas), canvas;
29144
+ }
29145
+ const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29146
+ if (this.canvasIdx++, result) return result;
29147
+ const id = Math.random().toString(),
29148
+ canvas = wrapHarmonyNativeCanvas(createHarmonyNativeCanvas(id, size.width, size.height, dpr, !0, envParams, runtime), id, size.width, size.height, dpr);
29149
+ return this.canvasMap.set(id, canvas), this.freeCanvasList.push(canvas), canvas;
28946
29150
  }
28947
29151
  createOffscreenCanvas(params) {}
28948
29152
  releaseCanvas(canvas) {}
28949
29153
  getDevicePixelRatio() {
28950
- return 1;
29154
+ return getHarmonyPixelRatio(this.harmonyEnvParams);
28951
29155
  }
28952
29156
  getRequestAnimationFrame() {
28953
29157
  return callback => this.rafSTO.call(callback);
@@ -28959,7 +29163,7 @@
28959
29163
  }
28960
29164
  mapToCanvasPoint(event) {
28961
29165
  var _a;
28962
- return null === (_a = null == event ? void 0 : event.type) || void 0 === _a || _a.startsWith("mouse"), event;
29166
+ return null !== (_a = getHarmonyEventPoint(event)) && void 0 !== _a ? _a : event;
28963
29167
  }
28964
29168
  addEventListener(type, listener, options) {
28965
29169
  return null;
@@ -28971,7 +29175,8 @@
28971
29175
  return null;
28972
29176
  }
28973
29177
  getElementById(str) {
28974
- return null;
29178
+ var _a;
29179
+ return null !== (_a = this.canvasMap.get(str)) && void 0 !== _a ? _a : null;
28975
29180
  }
28976
29181
  getRootElement() {
28977
29182
  return null;
@@ -29243,13 +29448,11 @@
29243
29448
  }
29244
29449
  return null;
29245
29450
  }
29246
- function getCanvasSize(domref, width, height) {
29247
- const resolvedWidth = null != width ? width : null == domref ? void 0 : domref.width,
29248
- resolvedHeight = null != height ? height : null == domref ? void 0 : domref.height;
29249
- if (!isValidCoordinate(resolvedWidth) || !isValidCoordinate(resolvedHeight)) throw new Error(LYNX_CANVAS_SIZE_ERROR);
29451
+ function getCanvasSize(width, height) {
29452
+ if (!isValidCoordinate(width) || !isValidCoordinate(height)) throw new Error(LYNX_CANVAS_SIZE_ERROR);
29250
29453
  return {
29251
- width: resolvedWidth,
29252
- height: resolvedHeight
29454
+ width: width,
29455
+ height: height
29253
29456
  };
29254
29457
  }
29255
29458
  function wrapLynxNativeCanvas(nativeCanvas, id, width, height, dpr) {
@@ -29273,29 +29476,6 @@
29273
29476
  }
29274
29477
  throw new Error(LYNX_CANVAS_BRIDGE_ERROR);
29275
29478
  }
29276
- function makeUpCanvas$3(params = {}, canvasMap, freeCanvasList) {
29277
- const runtime = getLynxRuntime(params),
29278
- {
29279
- domref: domref,
29280
- canvasIdLists = [],
29281
- freeCanvasIdx = 0
29282
- } = params,
29283
- offscreen = !!params.offscreen,
29284
- dpr = getLynxPixelRatio(params, runtime);
29285
- if (canvasIdLists.forEach((id, i) => {
29286
- const size = getCanvasSize(domref),
29287
- canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, offscreen, params, runtime), id, size.width, size.height, dpr);
29288
- canvasMap.set(id, canvas), i > freeCanvasIdx && freeCanvasList.push(canvas);
29289
- }), !freeCanvasList.length && domref && "function" == typeof (null == runtime ? void 0 : runtime.createOffscreenCanvas)) {
29290
- const size = getCanvasSize(domref),
29291
- _canvas = runtime.createOffscreenCanvas();
29292
- _canvas.width = size.width * dpr, _canvas.height = size.height * dpr;
29293
- const ctx = _canvas.getContext("2d"),
29294
- id = Math.random().toString(),
29295
- canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, size.width, size.height, id);
29296
- canvasMap.set(id, canvas), freeCanvasList.push(canvas);
29297
- }
29298
- }
29299
29479
  function createImageElement(src, isSvg = !1, runtime = getGlobalLynxRuntime()) {
29300
29480
  if (isSvg) return Promise.reject();
29301
29481
  if ("function" != typeof (null == runtime ? void 0 : runtime.createImage)) return Promise.reject(new Error("Lynx image bridge is unavailable."));
@@ -29319,7 +29499,7 @@
29319
29499
  this.applyStyles = !0;
29320
29500
  }
29321
29501
  configure(service, params = {}) {
29322
- service.env === this.type && (service.setActiveEnvContribution(this), this.lynxEnvParams = params, this.lynxRuntime = getLynxRuntime(params), makeUpCanvas$3(params, this.canvasMap, this.freeCanvasList));
29502
+ service.env === this.type && (service.setActiveEnvContribution(this), this.lynxEnvParams = params, this.lynxRuntime = getLynxRuntime(params));
29323
29503
  }
29324
29504
  getDynamicCanvasCount() {
29325
29505
  return this.freeCanvasList.length;
@@ -29351,7 +29531,7 @@
29351
29531
  const envParams = null !== (_a = this.lynxEnvParams) && void 0 !== _a ? _a : {},
29352
29532
  runtime = getLynxRuntime(envParams),
29353
29533
  dpr = null !== (_b = params.dpr) && void 0 !== _b ? _b : getLynxPixelRatio(envParams, runtime),
29354
- size = getCanvasSize(envParams.domref, params.width, params.height),
29534
+ size = getCanvasSize(params.width, params.height),
29355
29535
  canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !1, envParams, runtime), id, size.width, size.height, dpr);
29356
29536
  return this.canvasMap.set(id, canvas), canvas;
29357
29537
  }
@@ -29360,7 +29540,7 @@
29360
29540
  const envParams = null !== (_c = this.lynxEnvParams) && void 0 !== _c ? _c : {},
29361
29541
  runtime = getLynxRuntime(envParams),
29362
29542
  dpr = null !== (_d = params.dpr) && void 0 !== _d ? _d : getLynxPixelRatio(envParams, runtime),
29363
- size = getCanvasSize(envParams.domref, params.width, params.height),
29543
+ size = getCanvasSize(params.width, params.height),
29364
29544
  id = Math.random().toString(),
29365
29545
  canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !0, envParams, runtime), id, size.width, size.height, dpr);
29366
29546
  return this.canvasMap.set(id, canvas), this.freeCanvasList.push(canvas), canvas;
@@ -29671,7 +29851,12 @@
29671
29851
  createWindowByCanvas(params) {
29672
29852
  let canvas;
29673
29853
  if ("string" == typeof params.canvas) {
29674
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29854
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
29855
+ id: params.canvas,
29856
+ width: params.width,
29857
+ height: params.height,
29858
+ dpr: params.dpr
29859
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29675
29860
  } else canvas = params.canvas;
29676
29861
  let width = params.width,
29677
29862
  height = params.height;
@@ -29756,16 +29941,10 @@
29756
29941
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, TaroWindowHandlerContribution)) || container.bind(TaroWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, TaroWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(TaroWindowHandlerContribution).whenTargetNamed(TaroWindowHandlerContribution.env);
29757
29942
  }
29758
29943
 
29759
- function makeUpCanvas$2(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, taro, dpr) {
29760
- canvasIdLists.forEach((id, i) => {
29761
- const ctx = taro.createCanvasContext(id),
29762
- canvas = new CanvasWrapDisableWH(ctx.canvas || {}, ctx, dpr, domref.width, domref.height, id);
29763
- return ctx.canvas = canvas, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), canvas;
29764
- });
29765
- }
29944
+ const TARO_CANVAS_BRIDGE_ERROR = "Taro canvas bridge is unavailable. VRender taro env requires envParams.canvasFactory, a Stage canvas object, or envParams.taro.createCanvasContext(id).";
29766
29945
  class TaroEnvContribution extends BaseEnvContribution {
29767
29946
  constructor() {
29768
- super(), this.type = "taro", this.supportEvent = !0, this.canvasMap = new Map(), this.freeCanvasList = [], this.canvasIdx = 0, this.supportsTouchEvents = !0;
29947
+ super(), this.type = "taro", this.supportEvent = !0, this.canvasMap = new Map(), this.pixelRatio = 1, this.taroEnvParams = {}, this.supportsTouchEvents = !0;
29769
29948
  try {
29770
29949
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
29771
29950
  } catch (err) {
@@ -29774,7 +29953,7 @@
29774
29953
  this.applyStyles = !0;
29775
29954
  }
29776
29955
  getDynamicCanvasCount() {
29777
- return this.freeCanvasList.length;
29956
+ return 0;
29778
29957
  }
29779
29958
  getStaticCanvasCount() {
29780
29959
  return 9999;
@@ -29783,8 +29962,9 @@
29783
29962
  var _a;
29784
29963
  return null === (_a = null == event ? void 0 : event.type) || void 0 === _a || _a.startsWith("mouse"), event;
29785
29964
  }
29786
- configure(service, params) {
29787
- service.env === this.type && (service.setActiveEnvContribution(this), makeUpCanvas$2(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, params.taro, params.pixelRatio), this.taro = params.taro, this.pixelRatio = params.pixelRatio);
29965
+ configure(service, params = {}) {
29966
+ var _a;
29967
+ service.env === this.type && (service.setActiveEnvContribution(this), this.taroEnvParams = params, this.taro = params.taro, this.pixelRatio = null !== (_a = params.pixelRatio) && void 0 !== _a ? _a : 1);
29788
29968
  }
29789
29969
  loadImage(url) {
29790
29970
  return Promise.resolve({
@@ -29793,7 +29973,7 @@
29793
29973
  });
29794
29974
  }
29795
29975
  loadSvg(svgStr) {
29796
- const _window = window || globalThis;
29976
+ const _window = "undefined" != typeof window ? window : globalThis;
29797
29977
  if (_window.DOMParser) {
29798
29978
  const svg = new _window.DOMParser().parseFromString(svgStr, "image/svg+xml").children[0],
29799
29979
  data = new XMLSerializer().serializeToString(svg),
@@ -29816,8 +29996,15 @@
29816
29996
  return Promise.reject();
29817
29997
  }
29818
29998
  createCanvas(params) {
29819
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29820
- return this.canvasIdx++, result;
29999
+ var _a, _b;
30000
+ const envParams = this.taroEnvParams,
30001
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : this.getDevicePixelRatio(),
30002
+ factoryCanvas = createCanvasWithFactory(params, dpr, this.canvasMap, envParams.canvasFactory);
30003
+ if (factoryCanvas) return factoryCanvas;
30004
+ const options = getMiniAppCanvasOptions(params, dpr, !1);
30005
+ if (null == options.id || "function" != typeof (null === (_b = envParams.taro) || void 0 === _b ? void 0 : _b.createCanvasContext)) throw new Error(TARO_CANVAS_BRIDGE_ERROR);
30006
+ const canvas = wrapMiniAppContextCanvas(envParams.taro.createCanvasContext(options.id), options);
30007
+ return this.canvasMap.set(options.id, canvas), canvas;
29821
30008
  }
29822
30009
  createOffscreenCanvas(params) {}
29823
30010
  releaseCanvas(canvas) {}
@@ -29925,7 +30112,12 @@
29925
30112
  createWindowByCanvas(params) {
29926
30113
  let canvas;
29927
30114
  if ("string" == typeof params.canvas) {
29928
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
30115
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
30116
+ id: params.canvas,
30117
+ width: params.width,
30118
+ height: params.height,
30119
+ dpr: params.dpr
30120
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29929
30121
  } else canvas = params.canvas;
29930
30122
  let width = params.width,
29931
30123
  height = params.height;
@@ -30000,51 +30192,22 @@
30000
30192
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, TTWindowHandlerContribution)) || container.bind(TTWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, TTWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(TTWindowHandlerContribution).whenTargetNamed(TTWindowHandlerContribution.env);
30001
30193
  }
30002
30194
 
30003
- var __awaiter$2 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
30004
- return new (P || (P = Promise))(function (resolve, reject) {
30005
- function fulfilled(value) {
30006
- try {
30007
- step(generator.next(value));
30008
- } catch (e) {
30009
- reject(e);
30010
- }
30011
- }
30012
- function rejected(value) {
30013
- try {
30014
- step(generator.throw(value));
30015
- } catch (e) {
30016
- reject(e);
30017
- }
30018
- }
30019
- function step(result) {
30020
- var value;
30021
- result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P(function (resolve) {
30022
- resolve(value);
30023
- })).then(fulfilled, rejected);
30024
- }
30025
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30026
- });
30027
- };
30028
- function makeUpCanvas$1(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, component) {
30029
- return __awaiter$2(this, void 0, void 0, function* () {
30030
- const dpr = tt.getSystemInfoSync().pixelRatio;
30031
- for (let i = 0; i < canvasIdLists.length; i++) {
30032
- const id = canvasIdLists[i];
30033
- yield new Promise(resolve => {
30034
- let data = tt.createSelectorQuery();
30035
- component && (data = data.in(component)), data.select(`#${id}`).node().exec(res => {
30036
- const canvas = res[0].node,
30037
- width = canvas.width,
30038
- height = canvas.height;
30039
- canvas.width = width * dpr, canvas.height = height * dpr, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), resolve(null);
30040
- });
30041
- });
30042
- }
30043
- });
30195
+ const TT_CANVAS_BRIDGE_ERROR = "TT canvas bridge is unavailable. VRender tt env requires envParams.canvasFactory, a Stage canvas object, or a tt runtime that exposes createCanvasContext(id).";
30196
+ function getTTRuntime(params) {
30197
+ var _a, _b, _c;
30198
+ try {
30199
+ return null !== (_b = null !== (_a = null == params ? void 0 : params.tt) && void 0 !== _a ? _a : null == params ? void 0 : params.runtime) && void 0 !== _b ? _b : "undefined" != typeof tt ? tt : void 0;
30200
+ } catch (_d) {
30201
+ return null !== (_c = null == params ? void 0 : params.tt) && void 0 !== _c ? _c : null == params ? void 0 : params.runtime;
30202
+ }
30203
+ }
30204
+ function getTTPixelRatio(params, runtime = getTTRuntime(params)) {
30205
+ var _a, _b, _c, _d;
30206
+ return null !== (_d = null !== (_a = null == params ? void 0 : params.pixelRatio) && void 0 !== _a ? _a : null === (_c = null === (_b = null == runtime ? void 0 : runtime.getSystemInfoSync) || void 0 === _b ? void 0 : _b.call(runtime)) || void 0 === _c ? void 0 : _c.pixelRatio) && void 0 !== _d ? _d : 1;
30044
30207
  }
30045
30208
  class TTEnvContribution extends BaseEnvContribution {
30046
30209
  constructor() {
30047
- super(), this.type = "tt", this.supportEvent = !0, this.canvasMap = new Map(), this.freeCanvasList = [], this.canvasIdx = 0, this.supportsTouchEvents = !0;
30210
+ super(), this.type = "tt", this.supportEvent = !0, this.canvasMap = new Map(), this.ttEnvParams = {}, this.supportsTouchEvents = !0;
30048
30211
  try {
30049
30212
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
30050
30213
  } catch (err) {
@@ -30052,8 +30215,8 @@
30052
30215
  }
30053
30216
  this.applyStyles = !0;
30054
30217
  }
30055
- configure(service, params) {
30056
- if (service.env === this.type) return service.setActiveEnvContribution(this), makeUpCanvas$1(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, params.component).then(() => {});
30218
+ configure(service, params = {}) {
30219
+ service.env === this.type && (service.setActiveEnvContribution(this), this.ttEnvParams = params);
30057
30220
  }
30058
30221
  loadImage(url) {
30059
30222
  return Promise.resolve({
@@ -30065,13 +30228,21 @@
30065
30228
  return Promise.reject();
30066
30229
  }
30067
30230
  createCanvas(params) {
30068
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
30069
- return this.canvasIdx++, result;
30231
+ var _a;
30232
+ const envParams = this.ttEnvParams,
30233
+ runtime = getTTRuntime(envParams),
30234
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : getTTPixelRatio(envParams, runtime),
30235
+ factoryCanvas = createCanvasWithFactory(params, dpr, this.canvasMap, envParams.canvasFactory);
30236
+ if (factoryCanvas) return factoryCanvas;
30237
+ const options = getMiniAppCanvasOptions(params, dpr, !1);
30238
+ if (null == options.id || "function" != typeof (null == runtime ? void 0 : runtime.createCanvasContext)) throw new Error(TT_CANVAS_BRIDGE_ERROR);
30239
+ const canvas = wrapMiniAppContextCanvas(runtime.createCanvasContext(options.id), options);
30240
+ return this.canvasMap.set(options.id, canvas), canvas;
30070
30241
  }
30071
30242
  createOffscreenCanvas(params) {}
30072
30243
  releaseCanvas(canvas) {}
30073
30244
  getDevicePixelRatio() {
30074
- return tt.getSystemInfoSync().pixelRatio;
30245
+ return getTTPixelRatio(this.ttEnvParams);
30075
30246
  }
30076
30247
  getRequestAnimationFrame() {
30077
30248
  return function (callback) {
@@ -30192,7 +30363,12 @@
30192
30363
  createWindowByCanvas(params) {
30193
30364
  let canvas;
30194
30365
  if ("string" == typeof params.canvas) {
30195
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
30366
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
30367
+ id: params.canvas,
30368
+ width: params.width,
30369
+ height: params.height,
30370
+ dpr: params.dpr
30371
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
30196
30372
  } else canvas = params.canvas;
30197
30373
  let width = params.width,
30198
30374
  height = params.height;
@@ -30270,55 +30446,22 @@
30270
30446
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, WxWindowHandlerContribution)) || container.bind(WxWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, WxWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(WxWindowHandlerContribution).whenTargetNamed(WxWindowHandlerContribution.env);
30271
30447
  }
30272
30448
 
30273
- var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
30274
- return new (P || (P = Promise))(function (resolve, reject) {
30275
- function fulfilled(value) {
30276
- try {
30277
- step(generator.next(value));
30278
- } catch (e) {
30279
- reject(e);
30280
- }
30281
- }
30282
- function rejected(value) {
30283
- try {
30284
- step(generator.throw(value));
30285
- } catch (e) {
30286
- reject(e);
30287
- }
30288
- }
30289
- function step(result) {
30290
- var value;
30291
- result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P(function (resolve) {
30292
- resolve(value);
30293
- })).then(fulfilled, rejected);
30294
- }
30295
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30296
- });
30297
- };
30298
- function makeUpCanvas(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, component, forceUpdate) {
30299
- return __awaiter$1(this, void 0, void 0, function* () {
30300
- const dpr = wx.getSystemInfoSync().pixelRatio;
30301
- for (let i = 0; i < canvasIdLists.length; i++) {
30302
- const id = canvasIdLists[i];
30303
- !forceUpdate && canvasMap.has(id) || (yield new Promise(resolve => {
30304
- let data = wx.createSelectorQuery();
30305
- component && (data = data.in(component)), data.select(`#${id}`).fields({
30306
- node: !0,
30307
- size: !0
30308
- }).exec(res => {
30309
- if (!res[0]) return;
30310
- const canvas = res[0].node,
30311
- width = res[0].width,
30312
- height = res[0].height;
30313
- canvas.width = width * dpr, canvas.height = height * dpr, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), resolve(null);
30314
- });
30315
- }));
30316
- }
30317
- });
30449
+ const WX_CANVAS_BRIDGE_ERROR = "Wx canvas bridge is unavailable. VRender wx env requires envParams.canvasFactory, a Stage canvas object, or a wx runtime that exposes createCanvasContext(id).";
30450
+ function getWxRuntime(params) {
30451
+ var _a, _b, _c;
30452
+ try {
30453
+ return null !== (_b = null !== (_a = null == params ? void 0 : params.wx) && void 0 !== _a ? _a : null == params ? void 0 : params.runtime) && void 0 !== _b ? _b : "undefined" != typeof wx ? wx : void 0;
30454
+ } catch (_d) {
30455
+ return null !== (_c = null == params ? void 0 : params.wx) && void 0 !== _c ? _c : null == params ? void 0 : params.runtime;
30456
+ }
30457
+ }
30458
+ function getWxPixelRatio(params, runtime = getWxRuntime(params)) {
30459
+ var _a, _b, _c, _d;
30460
+ return null !== (_d = null !== (_a = null == params ? void 0 : params.pixelRatio) && void 0 !== _a ? _a : null === (_c = null === (_b = null == runtime ? void 0 : runtime.getSystemInfoSync) || void 0 === _b ? void 0 : _b.call(runtime)) || void 0 === _c ? void 0 : _c.pixelRatio) && void 0 !== _d ? _d : 1;
30318
30461
  }
30319
30462
  class WxEnvContribution extends BaseEnvContribution {
30320
30463
  constructor() {
30321
- super(), this.type = "wx", this.supportEvent = !0, this.canvasMap = new Map(), this.freeCanvasList = [], this.canvasIdx = 0, this.supportsTouchEvents = !0;
30464
+ super(), this.type = "wx", this.supportEvent = !0, this.canvasMap = new Map(), this.wxEnvParams = {}, this.supportsTouchEvents = !0;
30322
30465
  try {
30323
30466
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
30324
30467
  } catch (err) {
@@ -30326,8 +30469,8 @@
30326
30469
  }
30327
30470
  this.applyStyles = !0;
30328
30471
  }
30329
- configure(service, params) {
30330
- if (service.env === this.type) return service.setActiveEnvContribution(this), makeUpCanvas(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, params.component, params.forceUpdate).then(() => {});
30472
+ configure(service, params = {}) {
30473
+ service.env === this.type && (service.setActiveEnvContribution(this), this.wxEnvParams = params);
30331
30474
  }
30332
30475
  loadImage(url) {
30333
30476
  return Promise.resolve({
@@ -30342,13 +30485,21 @@
30342
30485
  });
30343
30486
  }
30344
30487
  createCanvas(params) {
30345
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
30346
- return this.canvasIdx++, result;
30488
+ var _a;
30489
+ const envParams = this.wxEnvParams,
30490
+ runtime = getWxRuntime(envParams),
30491
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : getWxPixelRatio(envParams, runtime),
30492
+ factoryCanvas = createCanvasWithFactory(params, dpr, this.canvasMap, envParams.canvasFactory);
30493
+ if (factoryCanvas) return factoryCanvas;
30494
+ const options = getMiniAppCanvasOptions(params, dpr, !1);
30495
+ if (null == options.id || "function" != typeof (null == runtime ? void 0 : runtime.createCanvasContext)) throw new Error(WX_CANVAS_BRIDGE_ERROR);
30496
+ const canvas = wrapMiniAppContextCanvas(runtime.createCanvasContext(options.id), options);
30497
+ return this.canvasMap.set(options.id, canvas), canvas;
30347
30498
  }
30348
30499
  createOffscreenCanvas(params) {}
30349
30500
  releaseCanvas(canvas) {}
30350
30501
  getDevicePixelRatio() {
30351
- return wx.getSystemInfoSync().pixelRatio;
30502
+ return getWxPixelRatio(this.wxEnvParams);
30352
30503
  }
30353
30504
  getRequestAnimationFrame() {
30354
30505
  return function (callback) {
@@ -45369,14 +45520,6 @@
45369
45520
  }
45370
45521
  return t;
45371
45522
  };
45372
- function cloneAttributeSnapshot(value) {
45373
- if (!isObject$1(value) || isArray$1(value)) return value;
45374
- const snapshot = {};
45375
- return Object.keys(value).forEach(key => {
45376
- const nextValue = value[key];
45377
- snapshot[key] = isObject$1(nextValue) && !isArray$1(nextValue) ? cloneAttributeSnapshot(nextValue) : nextValue;
45378
- }), snapshot;
45379
- }
45380
45523
  loadLabelComponent();
45381
45524
  class LabelBase extends AnimateComponent {
45382
45525
  setBitmap(bitmap) {
@@ -45420,7 +45563,7 @@
45420
45563
  }
45421
45564
  labeling(textBounds, graphicBounds, position, offset) {}
45422
45565
  _getLabelLinePoints(text, baseMark) {
45423
- return connectLineBetweenBounds(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
45566
+ return connectLineBetweenBounds(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark));
45424
45567
  }
45425
45568
  _createLabelLine(text, baseMark) {
45426
45569
  const points = this._getLabelLinePoints(text, baseMark);
@@ -45488,11 +45631,8 @@
45488
45631
  }
45489
45632
  render() {
45490
45633
  if (this._exitReleaseState) return;
45491
- if (this._prepare(), isNil$1(this._idToGraphic) || this._isCollectionBase && isNil$1(this._idToPoint)) return;
45492
- const markAttributeList = [];
45493
- !1 !== this._enableAnimation && this._baseMarks.forEach(mark => {
45494
- markAttributeList.push(cloneAttributeSnapshot(mark.attribute)), mark.initAttributes(this.getGraphicFinalLayoutAttributes(mark));
45495
- });
45634
+ if (this._finalLayoutBoundsCache = void 0, this._prepare(), isNil$1(this._idToGraphic) || this._isCollectionBase && isNil$1(this._idToPoint)) return;
45635
+ this._finalLayoutBoundsCache = new Map();
45496
45636
  const {
45497
45637
  overlap: overlap,
45498
45638
  smartInvert: smartInvert,
@@ -45517,9 +45657,7 @@
45517
45657
  }
45518
45658
  isFunction$1(customOverlapFunc) ? labels = customOverlapFunc(overlapLabels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this).concat(filteredLabels) : !1 !== overlap && (labels = this._overlapping(overlapLabels).concat(filteredLabels)), isFunction$1(this.attribute.onAfterOverlapping) && this.attribute.onAfterOverlapping(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null, this), labels && labels.length && labels.forEach(label => {
45519
45659
  this._bindEvent(label), this._setStatesOfText(label);
45520
- }), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels), !1 !== this._enableAnimation && this._baseMarks.forEach((mark, index) => {
45521
- mark.initAttributes(markAttributeList[index]);
45522
- });
45660
+ }), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels), this._finalLayoutBoundsCache = void 0;
45523
45661
  }
45524
45662
  _bindEvent(target) {
45525
45663
  if (this.attribute.disableTriggerEvent) return;
@@ -45586,6 +45724,24 @@
45586
45724
  var _a;
45587
45725
  return !!(null === (_a = null == graphic ? void 0 : graphic.context) || void 0 === _a ? void 0 : _a.finalAttrs);
45588
45726
  }
45727
+ shouldUseGraphicFinalLayoutAttributes(graphic) {
45728
+ var _a;
45729
+ return !!graphic && (!!(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic));
45730
+ }
45731
+ getGraphicFinalLayoutBounds(graphic) {
45732
+ var _a, _b;
45733
+ if (!graphic) return;
45734
+ const useFinalAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic),
45735
+ graphicAttrs = useFinalAttrs ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
45736
+ if (!1 === (null == graphicAttrs ? void 0 : graphicAttrs.visible)) return;
45737
+ if (!useFinalAttrs) return graphic.AABBBounds;
45738
+ const cachedBounds = null === (_a = this._finalLayoutBoundsCache) || void 0 === _a ? void 0 : _a.get(graphic);
45739
+ if (cachedBounds) return cachedBounds;
45740
+ const clonedGraphic = graphic.clone();
45741
+ clonedGraphic.initAttributes(Object.assign(Object.assign({}, clonedGraphic.attribute), graphicAttrs));
45742
+ const bounds = clonedGraphic.AABBBounds;
45743
+ return null === (_b = this._finalLayoutBoundsCache) || void 0 === _b || _b.set(graphic, bounds), bounds;
45744
+ }
45589
45745
  _initText(data = []) {
45590
45746
  const {
45591
45747
  textStyle = {}
@@ -45733,7 +45889,8 @@
45733
45889
  result = [],
45734
45890
  checkBounds = strategy.some(s => "bound" === s.type);
45735
45891
  avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach(mark => {
45736
- mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, !0));
45892
+ const markBounds = this.getGraphicFinalLayoutBounds(mark);
45893
+ markBounds && bitmap.setRange(boundToRange(bmpTool, markBounds, !0));
45737
45894
  })), avoidMarks.length > 0 && avoidMarks.forEach(avoid => {
45738
45895
  isString$1(avoid) ? getNoneGroupMarksByName(this.getRootNode(), avoid).forEach(avoidMark => {
45739
45896
  avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, !0));
@@ -45749,7 +45906,7 @@
45749
45906
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
45750
45907
  continue;
45751
45908
  }
45752
- if (checkBounds && baseMark && baseMark.AABBBounds && this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
45909
+ if (checkBounds && baseMark && this._canPlaceInside(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark))) {
45753
45910
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
45754
45911
  continue;
45755
45912
  }
@@ -45774,6 +45931,7 @@
45774
45931
  return result;
45775
45932
  }
45776
45933
  isMarkInsideRect(baseMark, bmpTool) {
45934
+ if (!baseMark) return !1;
45777
45935
  const {
45778
45936
  left: left,
45779
45937
  right: right,
@@ -45786,11 +45944,9 @@
45786
45944
  y1: -top,
45787
45945
  y2: bmpTool.height + bottom
45788
45946
  },
45789
- bounds = baseMark.AABBBounds;
45790
- if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
45791
- const {
45792
- attribute: attribute
45793
- } = baseMark;
45947
+ bounds = this.getGraphicFinalLayoutBounds(baseMark);
45948
+ if (bounds && 0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(bounds, rect, !0);
45949
+ const attribute = this.shouldUseGraphicFinalLayoutAttributes(baseMark) ? this.getGraphicFinalLayoutAttributes(baseMark) : baseMark.attribute;
45794
45950
  if ("rect" === baseMark.type) {
45795
45951
  const {
45796
45952
  x: x,
@@ -45815,19 +45971,13 @@
45815
45971
  if (baseMarkGroupName) return this.getRootNode().find(node => node.name === baseMarkGroupName, !0);
45816
45972
  }
45817
45973
  getGraphicBounds(graphic, point = {}, position) {
45818
- var _a;
45819
45974
  if (graphic) {
45820
- if (!1 !== graphic.attribute.visible) {
45821
- if ((null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic)) {
45822
- const clonedGraphic = graphic.clone();
45823
- return Object.assign(clonedGraphic.attribute, this.getGraphicFinalLayoutAttributes(graphic)), clonedGraphic.AABBBounds;
45824
- }
45825
- return graphic.AABBBounds;
45826
- }
45975
+ const graphicAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic) ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
45976
+ if (!1 !== graphicAttrs.visible) return this.getGraphicFinalLayoutBounds(graphic);
45827
45977
  const {
45828
45978
  x: x,
45829
45979
  y: y
45830
- } = graphic.attribute;
45980
+ } = graphicAttrs;
45831
45981
  return {
45832
45982
  x1: x,
45833
45983
  x2: x,
@@ -46015,8 +46165,9 @@
46015
46165
  }
46016
46166
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode),
46017
46167
  similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor,
46018
- isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds),
46019
- isIntersect = !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);
46168
+ baseMarkBounds = this.getGraphicFinalLayoutBounds(baseMark),
46169
+ isInside = this._canPlaceInside(label.AABBBounds, baseMarkBounds),
46170
+ isIntersect = !isInside && label.AABBBounds && baseMarkBounds && baseMarkBounds.intersects(label.AABBBounds);
46020
46171
  if (isInside || outsideEnable || isIntersect && "inside" === interactInvertType) {
46021
46172
  const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
46022
46173
  if (fill && label.setAttributes({
@@ -56113,7 +56264,7 @@
56113
56264
  return resolveLegacyApp().createStage(params);
56114
56265
  }
56115
56266
 
56116
- const version = "1.1.0-alpha.22";
56267
+ const version = "1.1.0-alpha.23";
56117
56268
 
56118
56269
  exports.AComponentAnimate = AComponentAnimate;
56119
56270
  exports.ACustomAnimate = ACustomAnimate;