@visactor/vrender 1.1.0-alpha.21 → 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;
@@ -5376,6 +5376,11 @@
5376
5376
  data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
5377
5377
  (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(svgStr, res.data)) : (data.loadState = "fail", mark.imageLoadFail(svgStr));
5378
5378
  }), data.waitingMark && (data.waitingMark = []);
5379
+ }).catch(() => {
5380
+ var _a;
5381
+ data.loadState = "fail", null === (_a = data.waitingMark) || void 0 === _a || _a.map(mark => {
5382
+ mark.imageLoadFail(svgStr);
5383
+ }), data.waitingMark && (data.waitingMark = []);
5379
5384
  })) : (data.loadState = "fail", mark.imageLoadFail(svgStr)));
5380
5385
  }
5381
5386
  static GetFile(url, type) {
@@ -6287,7 +6292,7 @@
6287
6292
  return str.startsWith("<");
6288
6293
  }
6289
6294
 
6290
- var __awaiter$8 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
6295
+ var __awaiter$6 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
6291
6296
  return new (P || (P = Promise))(function (resolve, reject) {
6292
6297
  function fulfilled(value) {
6293
6298
  try {
@@ -6316,7 +6321,7 @@
6316
6321
  group.incrementalAppendChild(graphic);
6317
6322
  }
6318
6323
  function waitForAllSubLayers(stage) {
6319
- return __awaiter$8(this, void 0, void 0, function* () {
6324
+ return __awaiter$6(this, void 0, void 0, function* () {
6320
6325
  const promiseList = [],
6321
6326
  layers = stage.getChildren();
6322
6327
  yield new Promise(resolve => {
@@ -14299,7 +14304,7 @@
14299
14304
  }
14300
14305
  }
14301
14306
 
14302
- var __awaiter$7 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
14307
+ var __awaiter$5 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
14303
14308
  return new (P || (P = Promise))(function (resolve, reject) {
14304
14309
  function fulfilled(value) {
14305
14310
  try {
@@ -14369,7 +14374,7 @@
14369
14374
  } else graphic.forEachChildren(cb, reverse);
14370
14375
  }
14371
14376
  function foreachAsync(graphic, defaultZIndex, cb, reverse = !1) {
14372
- return __awaiter$7(this, void 0, void 0, function* () {
14377
+ return __awaiter$5(this, void 0, void 0, function* () {
14373
14378
  yield graphic.forEachChildrenAsync(cb, reverse);
14374
14379
  });
14375
14380
  }
@@ -15256,7 +15261,7 @@
15256
15261
  return isBrowserEnv() ? "browser" : "node";
15257
15262
  }
15258
15263
 
15259
- var __awaiter$6 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
15264
+ var __awaiter$4 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
15260
15265
  return new (P || (P = Promise))(function (resolve, reject) {
15261
15266
  function fulfilled(value) {
15262
15267
  try {
@@ -15453,7 +15458,7 @@
15453
15458
  }
15454
15459
  runJob(job) {
15455
15460
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
15456
- return __awaiter$6(this, void 0, void 0, function* () {
15461
+ return __awaiter$4(this, void 0, void 0, function* () {
15457
15462
  if ("cancelled" === job.status) return;
15458
15463
  if (yield this.waitForNextFrame(), "cancelled" === job.status) return;
15459
15464
  job.status = "running", null === (_a = this.perfMonitor) || void 0 === _a || _a.recordEvent("deferred-job-start", {
@@ -16890,6 +16895,7 @@
16890
16895
  if (this.layer = layer, this.window = window, params.main) this.main = !0, this.context = window.getContext(), this.canvas = this.context.getCanvas();else {
16891
16896
  let nativeCanvas;
16892
16897
  this.main = !1, params.canvasId && (nativeCanvas = this.global.getElementById(params.canvasId)), nativeCanvas || (nativeCanvas = this.global.createCanvas({
16898
+ id: params.canvasId,
16893
16899
  width: window.width,
16894
16900
  height: window.height
16895
16901
  })), nativeCanvas.style && (nativeCanvas.style["pointer-events"] = "none");
@@ -17937,7 +17943,7 @@
17937
17943
  }
17938
17944
 
17939
17945
  var STATUS,
17940
- __awaiter$5 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
17946
+ __awaiter$3 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
17941
17947
  return new (P || (P = Promise))(function (resolve, reject) {
17942
17948
  function fulfilled(value) {
17943
17949
  try {
@@ -17972,7 +17978,7 @@
17972
17978
  }, this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender), this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
17973
17979
  }
17974
17980
  draw(renderService, drawContext) {
17975
- return __awaiter$5(this, void 0, void 0, function* () {
17981
+ return __awaiter$3(this, void 0, void 0, function* () {
17976
17982
  if (this.checkingForDrawPromise) return;
17977
17983
  this.lastRenderService = renderService, this.lastDrawContext = drawContext, this.checkingForDrawPromise = this.checkForDraw(drawContext);
17978
17984
  const skipDraw = yield this.checkingForDrawPromise;
@@ -17993,15 +17999,15 @@
17993
17999
  });
17994
18000
  }
17995
18001
  _increaseRender(group, drawContext) {
17996
- return __awaiter$5(this, void 0, void 0, function* () {
18002
+ return __awaiter$3(this, void 0, void 0, function* () {
17997
18003
  this.rendering = !0, yield this._renderIncrementalGroup(group, drawContext);
17998
18004
  });
17999
18005
  }
18000
18006
  _renderIncrementalGroup(group, drawContext) {
18001
- return __awaiter$5(this, void 0, void 0, function* () {
18007
+ return __awaiter$3(this, void 0, void 0, function* () {
18002
18008
  this.count = group.count, yield new Promise(resolve => {
18003
18009
  this.renderItem(group, drawContext, {
18004
- drawingCb: () => __awaiter$5(this, void 0, void 0, function* () {
18010
+ drawingCb: () => __awaiter$3(this, void 0, void 0, function* () {
18005
18011
  if (2 !== group.count) yield foreachAsync(group, DefaultAttribute.zIndex, (item, i) => {
18006
18012
  if (this.status === STATUS.STOP) return !0;
18007
18013
  if (item.isContainer) return !1;
@@ -18022,7 +18028,7 @@
18022
18028
  });
18023
18029
  }
18024
18030
  waitToNextFrame() {
18025
- return __awaiter$5(this, void 0, void 0, function* () {
18031
+ return __awaiter$3(this, void 0, void 0, function* () {
18026
18032
  return new Promise(resolve => {
18027
18033
  this.global.getRequestAnimationFrame()(() => {
18028
18034
  resolve(!1);
@@ -18031,13 +18037,13 @@
18031
18037
  });
18032
18038
  }
18033
18039
  checkForDraw(drawContext) {
18034
- return __awaiter$5(this, void 0, void 0, function* () {
18040
+ return __awaiter$3(this, void 0, void 0, function* () {
18035
18041
  let skip = this.rendering;
18036
18042
  return drawContext.restartIncremental && (skip = !1, yield this.forceStop(), this.resetToInit()), skip;
18037
18043
  });
18038
18044
  }
18039
18045
  forceStop() {
18040
- return __awaiter$5(this, void 0, void 0, function* () {
18046
+ return __awaiter$3(this, void 0, void 0, function* () {
18041
18047
  this.rendering && (this.status = STATUS.STOP, yield new Promise(resolve => {
18042
18048
  this.hooks.completeDraw.tap("stopCb", () => {
18043
18049
  this.status = STATUS.NORMAL, this.hooks.completeDraw.taps = this.hooks.completeDraw.taps.filter(item => "stopCb" !== item.name), resolve(!1);
@@ -18049,11 +18055,11 @@
18049
18055
  this.currFrameStartAt = 0, this.currentIdx = 0;
18050
18056
  }
18051
18057
  renderGroup(group, drawContext) {
18052
- return __awaiter$5(this, void 0, void 0, function* () {
18058
+ return __awaiter$3(this, void 0, void 0, function* () {
18053
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 => {
18054
18060
  this.renderItem(group, drawContext, {
18055
- drawingCb: () => __awaiter$5(this, void 0, void 0, function* () {
18056
- 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* () {
18057
18063
  drawContext.break || item.isContainer && (yield this.renderGroup(item, drawContext));
18058
18064
  })), resolve(!1);
18059
18065
  })
@@ -19931,7 +19937,7 @@
19931
19937
  }
19932
19938
  }
19933
19939
 
19934
- var __awaiter$4 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
19940
+ var __awaiter$2 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
19935
19941
  return new (P || (P = Promise))(function (resolve, reject) {
19936
19942
  function fulfilled(value) {
19937
19943
  try {
@@ -20025,7 +20031,7 @@
20025
20031
  };
20026
20032
  }
20027
20033
  loadFont(font, source, descriptors) {
20028
- return __awaiter$4(this, void 0, void 0, function* () {
20034
+ return __awaiter$2(this, void 0, void 0, function* () {
20029
20035
  return {
20030
20036
  loadState: "fail"
20031
20037
  };
@@ -27091,7 +27097,9 @@
27091
27097
  init() {
27092
27098
  this._context = new HarmonyContext2d(this, this._dpr);
27093
27099
  }
27094
- 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
+ }
27095
27103
  release(...params) {}
27096
27104
  }
27097
27105
  HarmonyCanvas.env = "harmony";
@@ -28022,7 +28030,7 @@
28022
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);
28023
28031
  }
28024
28032
 
28025
- var __awaiter$3 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
28033
+ var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
28026
28034
  return new (P || (P = Promise))(function (resolve, reject) {
28027
28035
  function fulfilled(value) {
28028
28036
  try {
@@ -28241,7 +28249,7 @@
28241
28249
  };
28242
28250
  }
28243
28251
  loadFont(font, source, descriptors) {
28244
- return __awaiter$3(this, void 0, void 0, function* () {
28252
+ return __awaiter$1(this, void 0, void 0, function* () {
28245
28253
  return new FontFace(font, isString$1(source) ? `url(${source})` : source, descriptors).load().then(function (loadedFont) {
28246
28254
  return document.fonts.add(loadedFont), {
28247
28255
  loadState: "success"
@@ -28340,7 +28348,12 @@
28340
28348
  createWindowByCanvas(params) {
28341
28349
  let canvas;
28342
28350
  if ("string" == typeof params.canvas) {
28343
- 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");
28344
28357
  } else canvas = params.canvas;
28345
28358
  let width = params.width,
28346
28359
  height = params.height;
@@ -28667,17 +28680,55 @@
28667
28680
  }
28668
28681
  }
28669
28682
 
28670
- function makeUpCanvas$4(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, pixelRatio) {
28671
- const dpr = null != pixelRatio ? pixelRatio : tt.getSystemInfoSync().pixelRatio;
28672
- canvasIdLists.forEach((id, i) => {
28673
- const ctx = tt.createCanvasContext(id),
28674
- canvas = new CanvasWrapDisableWH(ctx.canvas || {}, ctx, dpr, domref.width, domref.height, id);
28675
- ctx.canvas = canvas, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas);
28676
- });
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;
28677
28728
  }
28678
28729
  class FeishuEnvContribution extends BaseEnvContribution {
28679
28730
  constructor() {
28680
- 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;
28681
28732
  try {
28682
28733
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
28683
28734
  } catch (err) {
@@ -28686,13 +28737,13 @@
28686
28737
  this.applyStyles = !0;
28687
28738
  }
28688
28739
  getDynamicCanvasCount() {
28689
- return this.freeCanvasList.length;
28740
+ return 0;
28690
28741
  }
28691
28742
  getStaticCanvasCount() {
28692
28743
  return 9999;
28693
28744
  }
28694
- configure(service, params) {
28695
- 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);
28696
28747
  }
28697
28748
  loadImage(url) {
28698
28749
  return Promise.resolve({
@@ -28704,13 +28755,21 @@
28704
28755
  return Promise.reject();
28705
28756
  }
28706
28757
  createCanvas(params) {
28707
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
28708
- 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;
28709
28768
  }
28710
28769
  createOffscreenCanvas(params) {}
28711
28770
  releaseCanvas(canvas) {}
28712
28771
  getDevicePixelRatio() {
28713
- return tt.getSystemInfoSync().pixelRatio;
28772
+ return getFeishuPixelRatio(this.feishuEnvParams);
28714
28773
  }
28715
28774
  getRequestAnimationFrame() {
28716
28775
  return function (callback) {
@@ -28778,6 +28837,40 @@
28778
28837
  this.cache = {};
28779
28838
  }
28780
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
+ }
28781
28874
  class HarmonyWindowHandlerContribution extends BaseWindowHandlerContribution {
28782
28875
  get container() {
28783
28876
  return null;
@@ -28806,7 +28899,8 @@
28806
28899
  createWindowByConfig(params) {
28807
28900
  const nativeCanvas = this.global.createCanvas({
28808
28901
  width: params.width,
28809
- height: params.height
28902
+ height: params.height,
28903
+ dpr: params.dpr
28810
28904
  }),
28811
28905
  options = {
28812
28906
  width: params.width,
@@ -28821,7 +28915,12 @@
28821
28915
  createWindowByCanvas(params) {
28822
28916
  let canvas;
28823
28917
  if ("string" == typeof params.canvas) {
28824
- 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");
28825
28924
  } else canvas = params.canvas;
28826
28925
  let width = params.width,
28827
28926
  height = params.height;
@@ -28829,15 +28928,19 @@
28829
28928
  const data = canvas.getBoundingClientRect();
28830
28929
  width = data.width, height = data.height;
28831
28930
  }
28832
- this.canvas = new HarmonyCanvas({
28931
+ let dpr = params.dpr;
28932
+ null == dpr && (dpr = canvas.width / width), this.canvas = new HarmonyCanvas({
28833
28933
  width: width,
28834
28934
  height: height,
28835
- dpr: 1,
28935
+ dpr: dpr,
28836
28936
  nativeCanvas: canvas,
28837
28937
  canvasControled: params.canvasControled
28838
28938
  });
28839
28939
  }
28840
- 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
+ }
28841
28944
  resizeWindow(width, height) {
28842
28945
  this.canvas.resize(width, height);
28843
28946
  }
@@ -28860,12 +28963,15 @@
28860
28963
  this.eventManager.removeEventListener(type, listener);
28861
28964
  }
28862
28965
  dispatchEvent(event) {
28966
+ var _a;
28863
28967
  const {
28864
28968
  type: type
28865
28969
  } = event;
28866
- 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 => {
28867
28973
  f(event);
28868
- }), !0);
28974
+ }), !0;
28869
28975
  }
28870
28976
  getStyle() {
28871
28977
  return {};
@@ -28897,24 +29003,89 @@
28897
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);
28898
29004
  }
28899
29005
 
28900
- function createCanvas(width, height, id) {
28901
- const _c = new OffscreenCanvas(width, height),
28902
- context = _c.getContext("2d");
28903
- 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,
28904
29066
  width: width,
28905
29067
  height: height,
28906
- context: context,
28907
- _c: _c,
28908
- getBoundingClientRect: () => ({
28909
- width: width,
28910
- height: height
28911
- }),
28912
- getContext: () => context
28913
- }, 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);
28914
29085
  }
28915
29086
  class HarmonyEnvContribution extends BaseEnvContribution {
28916
29087
  constructor() {
28917
- 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;
28918
29089
  try {
28919
29090
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
28920
29091
  } catch (err) {
@@ -28922,8 +29093,8 @@
28922
29093
  }
28923
29094
  this.applyStyles = !0, this.rafSTO = new RafBasedSTO(0);
28924
29095
  }
28925
- configure(service, params) {
28926
- 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));
28927
29098
  }
28928
29099
  getDynamicCanvasCount() {
28929
29100
  return 9999;
@@ -28931,17 +29102,56 @@
28931
29102
  getStaticCanvasCount() {
28932
29103
  return 9999;
28933
29104
  }
28934
- 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
+ }
28935
29126
  loadSvg(url) {
28936
- return Promise.reject();
29127
+ return Promise.resolve({
29128
+ data: null,
29129
+ loadState: "fail"
29130
+ });
28937
29131
  }
28938
29132
  createCanvas(params) {
28939
- 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;
28940
29150
  }
28941
29151
  createOffscreenCanvas(params) {}
28942
29152
  releaseCanvas(canvas) {}
28943
29153
  getDevicePixelRatio() {
28944
- return 1;
29154
+ return getHarmonyPixelRatio(this.harmonyEnvParams);
28945
29155
  }
28946
29156
  getRequestAnimationFrame() {
28947
29157
  return callback => this.rafSTO.call(callback);
@@ -28953,7 +29163,7 @@
28953
29163
  }
28954
29164
  mapToCanvasPoint(event) {
28955
29165
  var _a;
28956
- 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;
28957
29167
  }
28958
29168
  addEventListener(type, listener, options) {
28959
29169
  return null;
@@ -28965,7 +29175,8 @@
28965
29175
  return null;
28966
29176
  }
28967
29177
  getElementById(str) {
28968
- return null;
29178
+ var _a;
29179
+ return null !== (_a = this.canvasMap.get(str)) && void 0 !== _a ? _a : null;
28969
29180
  }
28970
29181
  getRootElement() {
28971
29182
  return null;
@@ -29007,6 +29218,40 @@
29007
29218
  this.cache = {};
29008
29219
  }
29009
29220
  };
29221
+ function setMiniAppEventTarget$1(event, key, value) {
29222
+ if (event && value) try {
29223
+ event[key] = value;
29224
+ } catch (_a) {
29225
+ Object.defineProperty(event, key, {
29226
+ configurable: !0,
29227
+ value: value
29228
+ });
29229
+ }
29230
+ }
29231
+ function isValidCoordinate$1(value) {
29232
+ return "number" == typeof value && Number.isFinite(value);
29233
+ }
29234
+ function pickCoordinate$1(...values) {
29235
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate$1(values[i])) return values[i];
29236
+ }
29237
+ function setLynxEventValue(event, key, value) {
29238
+ try {
29239
+ event[key] = value;
29240
+ } catch (_a) {
29241
+ Object.defineProperty(event, key, {
29242
+ configurable: !0,
29243
+ value: value
29244
+ });
29245
+ }
29246
+ }
29247
+ function normalizeLynxTouchEventPoint(event) {
29248
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
29249
+ 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];
29250
+ if (!touch) return;
29251
+ const x = pickCoordinate$1(event.x, event.offsetX, event.clientX, event.pageX, touch.x, touch.offsetX, touch.clientX, touch.pageX),
29252
+ y = pickCoordinate$1(event.y, event.offsetY, event.clientY, event.pageY, touch.y, touch.offsetY, touch.clientY, touch.pageY);
29253
+ null != x && null != y && (!event.touches && event.changedTouches && setLynxEventValue(event, "touches", "touchend" === event.type || "touchcancel" === event.type ? [] : event.changedTouches), setLynxEventValue(event, "x", x), setLynxEventValue(event, "y", y), setLynxEventValue(event, "offsetX", null !== (_d = event.offsetX) && void 0 !== _d ? _d : x), setLynxEventValue(event, "offsetY", null !== (_e = event.offsetY) && void 0 !== _e ? _e : y), setLynxEventValue(event, "clientX", null !== (_f = event.clientX) && void 0 !== _f ? _f : x), setLynxEventValue(event, "clientY", null !== (_g = event.clientY) && void 0 !== _g ? _g : y), setLynxEventValue(event, "pageX", null !== (_h = event.pageX) && void 0 !== _h ? _h : x), setLynxEventValue(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);
29254
+ }
29010
29255
  class LynxWindowHandlerContribution extends BaseWindowHandlerContribution {
29011
29256
  get container() {
29012
29257
  return null;
@@ -29050,7 +29295,12 @@
29050
29295
  createWindowByCanvas(params) {
29051
29296
  let canvas;
29052
29297
  if ("string" == typeof params.canvas) {
29053
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29298
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
29299
+ id: params.canvas,
29300
+ width: params.width,
29301
+ height: params.height,
29302
+ dpr: params.dpr
29303
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29054
29304
  } else canvas = params.canvas;
29055
29305
  let width = params.width,
29056
29306
  height = params.height;
@@ -29090,12 +29340,15 @@
29090
29340
  this.eventManager.removeEventListener(type, listener);
29091
29341
  }
29092
29342
  dispatchEvent(event) {
29343
+ var _a;
29093
29344
  const {
29094
29345
  type: type
29095
29346
  } = event;
29096
- 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 => {
29347
+ if (!this.eventManager.cache[type]) return !1;
29348
+ const nativeCanvas = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.nativeCanvas;
29349
+ return setMiniAppEventTarget$1(event, "target", nativeCanvas), setMiniAppEventTarget$1(event, "currentTarget", nativeCanvas), normalizeLynxTouchEventPoint(event), event.preventDefault = () => {}, event.stopPropagation = () => {}, this.eventManager.cache[type].listener && this.eventManager.cache[type].listener.forEach(f => {
29097
29350
  f(event);
29098
- }), !0);
29351
+ }), !0;
29099
29352
  }
29100
29353
  getStyle() {
29101
29354
  return {};
@@ -29127,30 +29380,106 @@
29127
29380
  (null === (_a = container.isBound) || void 0 === _a ? void 0 : _a.call(container, LynxWindowHandlerContribution)) || container.bind(LynxWindowHandlerContribution).toSelf(), (null === (_b = container.getNamed) || void 0 === _b ? void 0 : _b.call(container, WindowHandlerContribution, LynxWindowHandlerContribution.env)) || container.bind(WindowHandlerContribution).toService(LynxWindowHandlerContribution).whenTargetNamed(LynxWindowHandlerContribution.env);
29128
29381
  }
29129
29382
 
29130
- let ng = !1;
29131
- try {
29132
- ng = !!lynx.createCanvasNG;
29133
- } catch (err) {}
29134
- function makeUpCanvas$3(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, offscreen, pixelRatio) {
29135
- const dpr = null != pixelRatio ? pixelRatio : SystemInfo.pixelRatio;
29136
- if (canvasIdLists.forEach((id, i) => {
29137
- let _canvas;
29138
- offscreen ? _canvas = lynx.createOffscreenCanvas() : (_canvas = ng ? lynx.createCanvasNG(id) : lynx.createCanvas(id), ng && _canvas.attachToCanvasView(id)), _canvas.width = domref.width * dpr, _canvas.height = domref.height * dpr;
29139
- const ctx = _canvas.getContext("2d"),
29140
- canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, domref.width, domref.height, id);
29141
- canvasMap.set(id, canvas), i > freeCanvasIdx && freeCanvasList.push(canvas);
29142
- }), !freeCanvasList.length && lynx.createOffscreenCanvas) {
29143
- const _canvas = lynx.createOffscreenCanvas();
29144
- _canvas.width = domref.width * dpr, _canvas.height = domref.height * dpr;
29145
- const ctx = _canvas.getContext("2d"),
29146
- id = Math.random().toString(),
29147
- canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, domref.width, domref.height, id);
29148
- canvasMap.set(id, canvas), freeCanvasList.push(canvas);
29383
+ const LYNX_CANVAS_BRIDGE_ERROR = "Lynx canvas bridge is unavailable. VRender Lynx env requires envParams.canvasFactory or a Lynx runtime that exposes createCanvasNG/createCanvas/createOffscreenCanvas/krypton canvas APIs.",
29384
+ LYNX_CANVAS_SIZE_ERROR = "Lynx canvas size is unavailable. Pass stage width/height when creating a Lynx stage canvas.";
29385
+ function isValidCoordinate(value) {
29386
+ return "number" == typeof value && Number.isFinite(value);
29387
+ }
29388
+ function pickCoordinate(...values) {
29389
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate(values[i])) return values[i];
29390
+ }
29391
+ function getPrimaryTouch(event) {
29392
+ var _a, _b, _c;
29393
+ 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];
29394
+ }
29395
+ function getLynxEventPoint(event) {
29396
+ const touch = getPrimaryTouch(event),
29397
+ x = pickCoordinate(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),
29398
+ y = pickCoordinate(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);
29399
+ return null == x || null == y ? null : {
29400
+ x: x,
29401
+ y: y
29402
+ };
29403
+ }
29404
+ function getGlobalLynxRuntime() {
29405
+ try {
29406
+ return "undefined" != typeof lynx ? lynx : void 0;
29407
+ } catch (err) {
29408
+ return;
29409
+ }
29410
+ }
29411
+ function getGlobalSystemPixelRatio() {
29412
+ try {
29413
+ return "undefined" != typeof SystemInfo ? SystemInfo.pixelRatio : void 0;
29414
+ } catch (err) {
29415
+ return;
29416
+ }
29417
+ }
29418
+ function getLynxRuntime(params) {
29419
+ var _a, _b;
29420
+ return null !== (_b = null !== (_a = null == params ? void 0 : params.lynx) && void 0 !== _a ? _a : null == params ? void 0 : params.runtime) && void 0 !== _b ? _b : getGlobalLynxRuntime();
29421
+ }
29422
+ function getLynxPixelRatio(params, runtime) {
29423
+ var _a, _b, _c, _d, _e;
29424
+ return null !== (_e = 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 : getGlobalSystemPixelRatio()) && void 0 !== _e ? _e : 1;
29425
+ }
29426
+ function attachLynxCanvasToView(canvas, id) {
29427
+ var _a;
29428
+ return null === (_a = null == canvas ? void 0 : canvas.attachToCanvasView) || void 0 === _a || _a.call(canvas, id), canvas;
29429
+ }
29430
+ function createBoundLynxCanvas(id, runtime) {
29431
+ var _a, _b, _c;
29432
+ if ("function" == typeof (null === (_a = null == runtime ? void 0 : runtime.krypton) || void 0 === _a ? void 0 : _a.createCanvas)) {
29433
+ const canvas = runtime.krypton.createCanvas(id);
29434
+ if (canvas) return canvas;
29435
+ }
29436
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createCanvasNG)) {
29437
+ const canvas = runtime.createCanvasNG(id);
29438
+ if (canvas) return attachLynxCanvasToView(canvas, id);
29439
+ }
29440
+ if ("function" == typeof (null === (_b = null == runtime ? void 0 : runtime.krypton) || void 0 === _b ? void 0 : _b.createCanvasNG)) {
29441
+ const canvas = runtime.krypton.createCanvasNG();
29442
+ if (canvas) return attachLynxCanvasToView(canvas, id);
29443
+ }
29444
+ if ("function" == typeof (null === (_c = null == runtime ? void 0 : runtime.krypton) || void 0 === _c ? void 0 : _c.CanvasElement)) return new runtime.krypton.CanvasElement(id);
29445
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createCanvas)) {
29446
+ const canvas = runtime.createCanvas(id);
29447
+ if (canvas) return canvas;
29149
29448
  }
29449
+ return null;
29450
+ }
29451
+ function getCanvasSize(width, height) {
29452
+ if (!isValidCoordinate(width) || !isValidCoordinate(height)) throw new Error(LYNX_CANVAS_SIZE_ERROR);
29453
+ return {
29454
+ width: width,
29455
+ height: height
29456
+ };
29150
29457
  }
29151
- function createImageElement(src, isSvg = !1) {
29458
+ function wrapLynxNativeCanvas(nativeCanvas, id, width, height, dpr) {
29459
+ nativeCanvas.width = width * dpr, nativeCanvas.height = height * dpr;
29460
+ const ctx = nativeCanvas.getContext("2d");
29461
+ return new CanvasWrapEnableWH(nativeCanvas, ctx, dpr, width, height, id);
29462
+ }
29463
+ function createLynxNativeCanvas(id, width, height, dpr, offscreen, params, runtime) {
29464
+ if (params.canvasFactory) return params.canvasFactory({
29465
+ id: id,
29466
+ width: width,
29467
+ height: height,
29468
+ dpr: dpr,
29469
+ offscreen: offscreen
29470
+ });
29471
+ if (offscreen) {
29472
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createOffscreenCanvas)) return runtime.createOffscreenCanvas();
29473
+ } else {
29474
+ const canvas = createBoundLynxCanvas(id, runtime);
29475
+ if (canvas) return canvas;
29476
+ }
29477
+ throw new Error(LYNX_CANVAS_BRIDGE_ERROR);
29478
+ }
29479
+ function createImageElement(src, isSvg = !1, runtime = getGlobalLynxRuntime()) {
29152
29480
  if (isSvg) return Promise.reject();
29153
- const img = lynx.createImage(src);
29481
+ if ("function" != typeof (null == runtime ? void 0 : runtime.createImage)) return Promise.reject(new Error("Lynx image bridge is unavailable."));
29482
+ const img = runtime.createImage(src);
29154
29483
  return new Promise((resolve, reject) => {
29155
29484
  img.onload = () => {
29156
29485
  resolve(img);
@@ -29169,8 +29498,8 @@
29169
29498
  }
29170
29499
  this.applyStyles = !0;
29171
29500
  }
29172
- configure(service, params) {
29173
- service.env === this.type && (service.setActiveEnvContribution(this), makeUpCanvas$3(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, !!params.offscreen, params.pixelRatio));
29501
+ configure(service, params = {}) {
29502
+ service.env === this.type && (service.setActiveEnvContribution(this), this.lynxEnvParams = params, this.lynxRuntime = getLynxRuntime(params));
29174
29503
  }
29175
29504
  getDynamicCanvasCount() {
29176
29505
  return this.freeCanvasList.length;
@@ -29179,7 +29508,7 @@
29179
29508
  return 9999;
29180
29509
  }
29181
29510
  loadImage(url) {
29182
- return createImageElement(url, !1).then(img => ({
29511
+ return createImageElement(url, !1, this.lynxRuntime).then(img => ({
29183
29512
  data: img,
29184
29513
  loadState: "success"
29185
29514
  })).catch(() => ({
@@ -29188,16 +29517,38 @@
29188
29517
  }));
29189
29518
  }
29190
29519
  loadSvg(url) {
29191
- return Promise.reject();
29520
+ return Promise.resolve({
29521
+ data: null,
29522
+ loadState: "fail"
29523
+ });
29192
29524
  }
29193
29525
  createCanvas(params) {
29526
+ var _a, _b, _c, _d;
29527
+ if (null != params.id) {
29528
+ const id = String(params.id),
29529
+ existing = this.canvasMap.get(id);
29530
+ if (existing) return existing;
29531
+ const envParams = null !== (_a = this.lynxEnvParams) && void 0 !== _a ? _a : {},
29532
+ runtime = getLynxRuntime(envParams),
29533
+ dpr = null !== (_b = params.dpr) && void 0 !== _b ? _b : getLynxPixelRatio(envParams, runtime),
29534
+ size = getCanvasSize(params.width, params.height),
29535
+ canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !1, envParams, runtime), id, size.width, size.height, dpr);
29536
+ return this.canvasMap.set(id, canvas), canvas;
29537
+ }
29194
29538
  const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29195
- return this.canvasIdx++, result;
29539
+ if (this.canvasIdx++, result) return result;
29540
+ const envParams = null !== (_c = this.lynxEnvParams) && void 0 !== _c ? _c : {},
29541
+ runtime = getLynxRuntime(envParams),
29542
+ dpr = null !== (_d = params.dpr) && void 0 !== _d ? _d : getLynxPixelRatio(envParams, runtime),
29543
+ size = getCanvasSize(params.width, params.height),
29544
+ id = Math.random().toString(),
29545
+ canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !0, envParams, runtime), id, size.width, size.height, dpr);
29546
+ return this.canvasMap.set(id, canvas), this.freeCanvasList.push(canvas), canvas;
29196
29547
  }
29197
29548
  createOffscreenCanvas(params) {}
29198
29549
  releaseCanvas(canvas) {}
29199
29550
  getDevicePixelRatio() {
29200
- return SystemInfo.pixelRatio;
29551
+ return getLynxPixelRatio(void 0, this.lynxRuntime);
29201
29552
  }
29202
29553
  getRequestAnimationFrame() {
29203
29554
  return function (callback) {
@@ -29211,7 +29562,7 @@
29211
29562
  }
29212
29563
  mapToCanvasPoint(event) {
29213
29564
  var _a;
29214
- return null === (_a = null == event ? void 0 : event.type) || void 0 === _a || _a.startsWith("mouse"), event;
29565
+ return null !== (_a = getLynxEventPoint(event)) && void 0 !== _a ? _a : event;
29215
29566
  }
29216
29567
  addEventListener(type, listener, options) {
29217
29568
  return null;
@@ -29500,7 +29851,12 @@
29500
29851
  createWindowByCanvas(params) {
29501
29852
  let canvas;
29502
29853
  if ("string" == typeof params.canvas) {
29503
- 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");
29504
29860
  } else canvas = params.canvas;
29505
29861
  let width = params.width,
29506
29862
  height = params.height;
@@ -29585,16 +29941,10 @@
29585
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);
29586
29942
  }
29587
29943
 
29588
- function makeUpCanvas$2(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, taro, dpr) {
29589
- canvasIdLists.forEach((id, i) => {
29590
- const ctx = taro.createCanvasContext(id),
29591
- canvas = new CanvasWrapDisableWH(ctx.canvas || {}, ctx, dpr, domref.width, domref.height, id);
29592
- return ctx.canvas = canvas, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), canvas;
29593
- });
29594
- }
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).";
29595
29945
  class TaroEnvContribution extends BaseEnvContribution {
29596
29946
  constructor() {
29597
- 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;
29598
29948
  try {
29599
29949
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
29600
29950
  } catch (err) {
@@ -29603,7 +29953,7 @@
29603
29953
  this.applyStyles = !0;
29604
29954
  }
29605
29955
  getDynamicCanvasCount() {
29606
- return this.freeCanvasList.length;
29956
+ return 0;
29607
29957
  }
29608
29958
  getStaticCanvasCount() {
29609
29959
  return 9999;
@@ -29612,8 +29962,9 @@
29612
29962
  var _a;
29613
29963
  return null === (_a = null == event ? void 0 : event.type) || void 0 === _a || _a.startsWith("mouse"), event;
29614
29964
  }
29615
- configure(service, params) {
29616
- 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);
29617
29968
  }
29618
29969
  loadImage(url) {
29619
29970
  return Promise.resolve({
@@ -29622,7 +29973,7 @@
29622
29973
  });
29623
29974
  }
29624
29975
  loadSvg(svgStr) {
29625
- const _window = window || globalThis;
29976
+ const _window = "undefined" != typeof window ? window : globalThis;
29626
29977
  if (_window.DOMParser) {
29627
29978
  const svg = new _window.DOMParser().parseFromString(svgStr, "image/svg+xml").children[0],
29628
29979
  data = new XMLSerializer().serializeToString(svg),
@@ -29645,8 +29996,15 @@
29645
29996
  return Promise.reject();
29646
29997
  }
29647
29998
  createCanvas(params) {
29648
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29649
- 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;
29650
30008
  }
29651
30009
  createOffscreenCanvas(params) {}
29652
30010
  releaseCanvas(canvas) {}
@@ -29754,7 +30112,12 @@
29754
30112
  createWindowByCanvas(params) {
29755
30113
  let canvas;
29756
30114
  if ("string" == typeof params.canvas) {
29757
- 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");
29758
30121
  } else canvas = params.canvas;
29759
30122
  let width = params.width,
29760
30123
  height = params.height;
@@ -29829,51 +30192,22 @@
29829
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);
29830
30193
  }
29831
30194
 
29832
- var __awaiter$2 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
29833
- return new (P || (P = Promise))(function (resolve, reject) {
29834
- function fulfilled(value) {
29835
- try {
29836
- step(generator.next(value));
29837
- } catch (e) {
29838
- reject(e);
29839
- }
29840
- }
29841
- function rejected(value) {
29842
- try {
29843
- step(generator.throw(value));
29844
- } catch (e) {
29845
- reject(e);
29846
- }
29847
- }
29848
- function step(result) {
29849
- var value;
29850
- result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P(function (resolve) {
29851
- resolve(value);
29852
- })).then(fulfilled, rejected);
29853
- }
29854
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29855
- });
29856
- };
29857
- function makeUpCanvas$1(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, component) {
29858
- return __awaiter$2(this, void 0, void 0, function* () {
29859
- const dpr = tt.getSystemInfoSync().pixelRatio;
29860
- for (let i = 0; i < canvasIdLists.length; i++) {
29861
- const id = canvasIdLists[i];
29862
- yield new Promise(resolve => {
29863
- let data = tt.createSelectorQuery();
29864
- component && (data = data.in(component)), data.select(`#${id}`).node().exec(res => {
29865
- const canvas = res[0].node,
29866
- width = canvas.width,
29867
- height = canvas.height;
29868
- canvas.width = width * dpr, canvas.height = height * dpr, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), resolve(null);
29869
- });
29870
- });
29871
- }
29872
- });
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;
29873
30207
  }
29874
30208
  class TTEnvContribution extends BaseEnvContribution {
29875
30209
  constructor() {
29876
- 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;
29877
30211
  try {
29878
30212
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
29879
30213
  } catch (err) {
@@ -29881,8 +30215,8 @@
29881
30215
  }
29882
30216
  this.applyStyles = !0;
29883
30217
  }
29884
- configure(service, params) {
29885
- 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);
29886
30220
  }
29887
30221
  loadImage(url) {
29888
30222
  return Promise.resolve({
@@ -29894,13 +30228,21 @@
29894
30228
  return Promise.reject();
29895
30229
  }
29896
30230
  createCanvas(params) {
29897
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29898
- 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;
29899
30241
  }
29900
30242
  createOffscreenCanvas(params) {}
29901
30243
  releaseCanvas(canvas) {}
29902
30244
  getDevicePixelRatio() {
29903
- return tt.getSystemInfoSync().pixelRatio;
30245
+ return getTTPixelRatio(this.ttEnvParams);
29904
30246
  }
29905
30247
  getRequestAnimationFrame() {
29906
30248
  return function (callback) {
@@ -29968,6 +30310,16 @@
29968
30310
  this.cache = {};
29969
30311
  }
29970
30312
  }
30313
+ function setMiniAppEventTarget(event, key, value) {
30314
+ if (event && value) try {
30315
+ event[key] = value;
30316
+ } catch (_a) {
30317
+ Object.defineProperty(event, key, {
30318
+ configurable: !0,
30319
+ value: value
30320
+ });
30321
+ }
30322
+ }
29971
30323
  class WxWindowHandlerContribution extends BaseWindowHandlerContribution {
29972
30324
  get container() {
29973
30325
  return null;
@@ -30011,7 +30363,12 @@
30011
30363
  createWindowByCanvas(params) {
30012
30364
  let canvas;
30013
30365
  if ("string" == typeof params.canvas) {
30014
- 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");
30015
30372
  } else canvas = params.canvas;
30016
30373
  let width = params.width,
30017
30374
  height = params.height;
@@ -30049,13 +30406,15 @@
30049
30406
  this.eventManager.removeEventListener(type, listener);
30050
30407
  }
30051
30408
  dispatchEvent(event) {
30052
- var _a, _b, _c, _d;
30409
+ var _a, _b, _c, _d, _e;
30053
30410
  const {
30054
30411
  type: type
30055
30412
  } = event;
30056
- return !!this.eventManager.cache[type] && (event.changedTouches && event.changedTouches[0] && (event.offsetX = event.changedTouches[0].x, event.changedTouches[0].offsetX = null !== (_a = event.changedTouches[0].x) && void 0 !== _a ? _a : event.changedTouches[0].pageX, event.changedTouches[0].clientX = null !== (_b = event.changedTouches[0].x) && void 0 !== _b ? _b : event.changedTouches[0].pageX, event.offsetY = event.changedTouches[0].y, event.changedTouches[0].offsetY = null !== (_c = event.changedTouches[0].y) && void 0 !== _c ? _c : event.changedTouches[0].pageY, event.changedTouches[0].clientY = null !== (_d = event.changedTouches[0].y) && void 0 !== _d ? _d : event.changedTouches[0].pageY), event.preventDefault = () => {}, event.stopPropagation = () => {}, this.eventManager.cache[type].listener && this.eventManager.cache[type].listener.forEach(f => {
30413
+ if (!this.eventManager.cache[type]) return !1;
30414
+ const nativeCanvas = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.nativeCanvas;
30415
+ return setMiniAppEventTarget(event, "target", nativeCanvas), setMiniAppEventTarget(event, "currentTarget", nativeCanvas), event.changedTouches && event.changedTouches[0] && (event.offsetX = event.changedTouches[0].x, event.changedTouches[0].offsetX = null !== (_b = event.changedTouches[0].x) && void 0 !== _b ? _b : event.changedTouches[0].pageX, event.changedTouches[0].clientX = null !== (_c = event.changedTouches[0].x) && void 0 !== _c ? _c : event.changedTouches[0].pageX, event.offsetY = event.changedTouches[0].y, event.changedTouches[0].offsetY = null !== (_d = event.changedTouches[0].y) && void 0 !== _d ? _d : event.changedTouches[0].pageY, event.changedTouches[0].clientY = null !== (_e = event.changedTouches[0].y) && void 0 !== _e ? _e : event.changedTouches[0].pageY), event.preventDefault = () => {}, event.stopPropagation = () => {}, this.eventManager.cache[type].listener && this.eventManager.cache[type].listener.forEach(f => {
30057
30416
  f(event);
30058
- }), !0);
30417
+ }), !0;
30059
30418
  }
30060
30419
  getStyle() {
30061
30420
  return {};
@@ -30087,55 +30446,22 @@
30087
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);
30088
30447
  }
30089
30448
 
30090
- var __awaiter$1 = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
30091
- return new (P || (P = Promise))(function (resolve, reject) {
30092
- function fulfilled(value) {
30093
- try {
30094
- step(generator.next(value));
30095
- } catch (e) {
30096
- reject(e);
30097
- }
30098
- }
30099
- function rejected(value) {
30100
- try {
30101
- step(generator.throw(value));
30102
- } catch (e) {
30103
- reject(e);
30104
- }
30105
- }
30106
- function step(result) {
30107
- var value;
30108
- result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P(function (resolve) {
30109
- resolve(value);
30110
- })).then(fulfilled, rejected);
30111
- }
30112
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30113
- });
30114
- };
30115
- function makeUpCanvas(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, component, forceUpdate) {
30116
- return __awaiter$1(this, void 0, void 0, function* () {
30117
- const dpr = wx.getSystemInfoSync().pixelRatio;
30118
- for (let i = 0; i < canvasIdLists.length; i++) {
30119
- const id = canvasIdLists[i];
30120
- !forceUpdate && canvasMap.has(id) || (yield new Promise(resolve => {
30121
- let data = wx.createSelectorQuery();
30122
- component && (data = data.in(component)), data.select(`#${id}`).fields({
30123
- node: !0,
30124
- size: !0
30125
- }).exec(res => {
30126
- if (!res[0]) return;
30127
- const canvas = res[0].node,
30128
- width = res[0].width,
30129
- height = res[0].height;
30130
- canvas.width = width * dpr, canvas.height = height * dpr, canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas), resolve(null);
30131
- });
30132
- }));
30133
- }
30134
- });
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;
30135
30461
  }
30136
30462
  class WxEnvContribution extends BaseEnvContribution {
30137
30463
  constructor() {
30138
- 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;
30139
30465
  try {
30140
30466
  this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
30141
30467
  } catch (err) {
@@ -30143,8 +30469,8 @@
30143
30469
  }
30144
30470
  this.applyStyles = !0;
30145
30471
  }
30146
- configure(service, params) {
30147
- 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);
30148
30474
  }
30149
30475
  loadImage(url) {
30150
30476
  return Promise.resolve({
@@ -30153,16 +30479,27 @@
30153
30479
  });
30154
30480
  }
30155
30481
  loadSvg(url) {
30156
- return Promise.reject();
30482
+ return Promise.resolve({
30483
+ data: null,
30484
+ loadState: "fail"
30485
+ });
30157
30486
  }
30158
30487
  createCanvas(params) {
30159
- const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
30160
- 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;
30161
30498
  }
30162
30499
  createOffscreenCanvas(params) {}
30163
30500
  releaseCanvas(canvas) {}
30164
30501
  getDevicePixelRatio() {
30165
- return wx.getSystemInfoSync().pixelRatio;
30502
+ return getWxPixelRatio(this.wxEnvParams);
30166
30503
  }
30167
30504
  getRequestAnimationFrame() {
30168
30505
  return function (callback) {
@@ -45183,14 +45520,6 @@
45183
45520
  }
45184
45521
  return t;
45185
45522
  };
45186
- function cloneAttributeSnapshot(value) {
45187
- if (!isObject$1(value) || isArray$1(value)) return value;
45188
- const snapshot = {};
45189
- return Object.keys(value).forEach(key => {
45190
- const nextValue = value[key];
45191
- snapshot[key] = isObject$1(nextValue) && !isArray$1(nextValue) ? cloneAttributeSnapshot(nextValue) : nextValue;
45192
- }), snapshot;
45193
- }
45194
45523
  loadLabelComponent();
45195
45524
  class LabelBase extends AnimateComponent {
45196
45525
  setBitmap(bitmap) {
@@ -45234,7 +45563,7 @@
45234
45563
  }
45235
45564
  labeling(textBounds, graphicBounds, position, offset) {}
45236
45565
  _getLabelLinePoints(text, baseMark) {
45237
- return connectLineBetweenBounds(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
45566
+ return connectLineBetweenBounds(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark));
45238
45567
  }
45239
45568
  _createLabelLine(text, baseMark) {
45240
45569
  const points = this._getLabelLinePoints(text, baseMark);
@@ -45302,11 +45631,8 @@
45302
45631
  }
45303
45632
  render() {
45304
45633
  if (this._exitReleaseState) return;
45305
- if (this._prepare(), isNil$1(this._idToGraphic) || this._isCollectionBase && isNil$1(this._idToPoint)) return;
45306
- const markAttributeList = [];
45307
- !1 !== this._enableAnimation && this._baseMarks.forEach(mark => {
45308
- markAttributeList.push(cloneAttributeSnapshot(mark.attribute)), mark.initAttributes(this.getGraphicFinalLayoutAttributes(mark));
45309
- });
45634
+ if (this._finalLayoutBoundsCache = void 0, this._prepare(), isNil$1(this._idToGraphic) || this._isCollectionBase && isNil$1(this._idToPoint)) return;
45635
+ this._finalLayoutBoundsCache = new Map();
45310
45636
  const {
45311
45637
  overlap: overlap,
45312
45638
  smartInvert: smartInvert,
@@ -45331,9 +45657,7 @@
45331
45657
  }
45332
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 => {
45333
45659
  this._bindEvent(label), this._setStatesOfText(label);
45334
- }), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels), !1 !== this._enableAnimation && this._baseMarks.forEach((mark, index) => {
45335
- mark.initAttributes(markAttributeList[index]);
45336
- });
45660
+ }), !1 !== smartInvert && this._smartInvert(labels), this._renderLabels(labels), this._finalLayoutBoundsCache = void 0;
45337
45661
  }
45338
45662
  _bindEvent(target) {
45339
45663
  if (this.attribute.disableTriggerEvent) return;
@@ -45400,6 +45724,24 @@
45400
45724
  var _a;
45401
45725
  return !!(null === (_a = null == graphic ? void 0 : graphic.context) || void 0 === _a ? void 0 : _a.finalAttrs);
45402
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
+ }
45403
45745
  _initText(data = []) {
45404
45746
  const {
45405
45747
  textStyle = {}
@@ -45547,7 +45889,8 @@
45547
45889
  result = [],
45548
45890
  checkBounds = strategy.some(s => "bound" === s.type);
45549
45891
  avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach(mark => {
45550
- mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, !0));
45892
+ const markBounds = this.getGraphicFinalLayoutBounds(mark);
45893
+ markBounds && bitmap.setRange(boundToRange(bmpTool, markBounds, !0));
45551
45894
  })), avoidMarks.length > 0 && avoidMarks.forEach(avoid => {
45552
45895
  isString$1(avoid) ? getNoneGroupMarksByName(this.getRootNode(), avoid).forEach(avoidMark => {
45553
45896
  avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, !0));
@@ -45563,7 +45906,7 @@
45563
45906
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
45564
45907
  continue;
45565
45908
  }
45566
- if (checkBounds && baseMark && baseMark.AABBBounds && this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
45909
+ if (checkBounds && baseMark && this._canPlaceInside(text.AABBBounds, this.getGraphicFinalLayoutBounds(baseMark))) {
45567
45910
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
45568
45911
  continue;
45569
45912
  }
@@ -45588,6 +45931,7 @@
45588
45931
  return result;
45589
45932
  }
45590
45933
  isMarkInsideRect(baseMark, bmpTool) {
45934
+ if (!baseMark) return !1;
45591
45935
  const {
45592
45936
  left: left,
45593
45937
  right: right,
@@ -45600,11 +45944,9 @@
45600
45944
  y1: -top,
45601
45945
  y2: bmpTool.height + bottom
45602
45946
  },
45603
- bounds = baseMark.AABBBounds;
45604
- if (0 !== bounds.width() && 0 !== bounds.height()) return isRectIntersect(baseMark.AABBBounds, rect, !0);
45605
- const {
45606
- attribute: attribute
45607
- } = 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;
45608
45950
  if ("rect" === baseMark.type) {
45609
45951
  const {
45610
45952
  x: x,
@@ -45629,19 +45971,13 @@
45629
45971
  if (baseMarkGroupName) return this.getRootNode().find(node => node.name === baseMarkGroupName, !0);
45630
45972
  }
45631
45973
  getGraphicBounds(graphic, point = {}, position) {
45632
- var _a;
45633
45974
  if (graphic) {
45634
- if (!1 !== graphic.attribute.visible) {
45635
- if ((null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.animationState) || this.hasGraphicContextFinalLayoutAttributes(graphic)) {
45636
- const clonedGraphic = graphic.clone();
45637
- return Object.assign(clonedGraphic.attribute, this.getGraphicFinalLayoutAttributes(graphic)), clonedGraphic.AABBBounds;
45638
- }
45639
- return graphic.AABBBounds;
45640
- }
45975
+ const graphicAttrs = this.shouldUseGraphicFinalLayoutAttributes(graphic) ? this.getGraphicFinalLayoutAttributes(graphic) : graphic.attribute;
45976
+ if (!1 !== graphicAttrs.visible) return this.getGraphicFinalLayoutBounds(graphic);
45641
45977
  const {
45642
45978
  x: x,
45643
45979
  y: y
45644
- } = graphic.attribute;
45980
+ } = graphicAttrs;
45645
45981
  return {
45646
45982
  x1: x,
45647
45983
  x2: x,
@@ -45829,8 +46165,9 @@
45829
46165
  }
45830
46166
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode),
45831
46167
  similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor,
45832
- isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds),
45833
- 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);
45834
46171
  if (isInside || outsideEnable || isIntersect && "inside" === interactInvertType) {
45835
46172
  const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
45836
46173
  if (fill && label.setAttributes({
@@ -53166,15 +53503,16 @@
53166
53503
  loadBrushComponent();
53167
53504
  class Brush extends AbstractComponent {
53168
53505
  constructor(attributes, options) {
53169
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, Brush.defaultAttributes, attributes)), this.name = "brush", this._activeBrushState = !1, this._activeDrawState = !1, this._cacheDrawPoints = [], this._activeMoveState = !1, this._operatingMaskMoveDx = 0, this._operatingMaskMoveDy = 0, this._operatingMaskMoveRangeX = [-1 / 0, 1 / 0], this._operatingMaskMoveRangeY = [-1 / 0, 1 / 0], this._brushMaskAABBBoundsDict = {}, this._firstUpdate = !0, this._onBrushStart = e => {
53506
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, Brush.defaultAttributes, attributes)), this.name = "brush", this._activeBrushState = !1, this._activeDrawState = !1, this._cacheDrawPoints = [], this._activeMoveState = !1, this._operatingMaskMoveDx = 0, this._operatingMaskMoveDy = 0, this._operatingMaskMoveRangeX = [-1 / 0, 1 / 0], this._operatingMaskMoveRangeY = [-1 / 0, 1 / 0], this._brushEventStage = null, this._brushMaskAABBBoundsDict = {}, this._firstUpdate = !0, this._onBrushStart = e => {
53170
53507
  if (!1 === this.attribute.interactive) return;
53171
53508
  if (!1 === this._beforeBrushEvent(e)) return;
53172
53509
  const {
53173
- updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,
53174
- endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,
53175
- brushMoved = !0
53176
- } = this.attribute;
53177
- array(updateTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushEnd)), e.stopPropagation(), this._firstUpdate = !0, this._activeMoveState = brushMoved && this._isPosInBrushMask(e), this._activeDrawState = !this._activeMoveState, this._startPos = this.eventPosToStagePos(e), this._cacheDrawPoints = [this._startPos];
53510
+ updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,
53511
+ endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,
53512
+ brushMoved = !0
53513
+ } = this.attribute,
53514
+ stage = this.stage;
53515
+ stage && (array(updateTrigger).forEach(t => stage.addEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => stage.addEventListener(t, this._onBrushEnd)), e.stopPropagation(), this._firstUpdate = !0, this._activeMoveState = brushMoved && this._isPosInBrushMask(e), this._activeDrawState = !this._activeMoveState, this._startPos = this.eventPosToStagePos(e), this._cacheDrawPoints = [this._startPos]);
53178
53516
  }, this._onBrushing = e => {
53179
53517
  !1 !== this.attribute.interactive && !1 !== this._beforeBrushEvent(e) && (this._outOfInteractiveRange(e) || (e.stopPropagation(), this._firstUpdate ? (this._activeDrawState && this._initDraw(e), this._activeMoveState && this._initMove(e), this._firstUpdate = !1) : (this._activeDrawState && this._drawing(e), this._activeMoveState && this._moving(e))));
53180
53518
  }, this._onBrushingWithDelay = 0 === this.attribute.delayTime ? this._onBrushing : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime), this._onBrushEnd = e => {
@@ -53185,11 +53523,14 @@
53185
53523
  }
53186
53524
  _bindBrushEvents() {
53187
53525
  if (this.releaseBrushEvents(), this.attribute.disableTriggerEvent) return;
53526
+ const stage = this.stage;
53527
+ if (!stage) return;
53528
+ this._brushEventStage = stage;
53188
53529
  const {
53189
53530
  trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,
53190
53531
  resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger
53191
53532
  } = this.attribute;
53192
- array(trigger).forEach(t => this.stage.addEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushClear));
53533
+ array(trigger).forEach(t => stage.addEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => stage.addEventListener(t, this._onBrushClear));
53193
53534
  }
53194
53535
  _initDraw(e) {
53195
53536
  if (!1 === this.attribute.interactive) return;
@@ -53290,19 +53631,30 @@
53290
53631
  const group = this.createOrUpdateChild("brush-container", {}, "group");
53291
53632
  this._container = group;
53292
53633
  }
53634
+ setStage(stage, layer) {
53635
+ this._brushEventStage && this._brushEventStage !== stage && this.releaseBrushEvents(), super.setStage(stage, layer);
53636
+ }
53637
+ release(all) {
53638
+ this.releaseBrushEvents(), super.release(all);
53639
+ }
53293
53640
  releaseBrushEvents() {
53641
+ var _a;
53642
+ const stage = null !== (_a = this._brushEventStage) && void 0 !== _a ? _a : this.stage;
53643
+ if (!stage) return;
53294
53644
  const {
53295
53645
  trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,
53296
53646
  resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger
53297
53647
  } = this.attribute;
53298
- array(trigger).forEach(t => this.stage.removeEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushClear)), this._releaseBrushUpdateEvents();
53648
+ array(trigger).forEach(t => stage.removeEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => stage.removeEventListener(t, this._onBrushClear)), this._releaseBrushUpdateEvents(stage), this._brushEventStage = null;
53299
53649
  }
53300
- _releaseBrushUpdateEvents() {
53650
+ _releaseBrushUpdateEvents(stage) {
53651
+ var _a;
53652
+ if (void 0 === stage && (stage = null !== (_a = this._brushEventStage) && void 0 !== _a ? _a : this.stage), !stage) return;
53301
53653
  const {
53302
53654
  updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,
53303
53655
  endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger
53304
53656
  } = this.attribute;
53305
- array(updateTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushEnd));
53657
+ array(updateTrigger).forEach(t => stage.removeEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => stage.removeEventListener(t, this._onBrushEnd));
53306
53658
  }
53307
53659
  _computeMaskPoints() {
53308
53660
  const {
@@ -55763,6 +56115,141 @@
55763
56115
  return bootstrapVRenderNodeApp(createNodeApp(entryOptions), envParams);
55764
56116
  }
55765
56117
 
56118
+ const SHARED_APP_REGISTRY_KEY = Symbol.for('visactor.vrender.sharedAppRegistry');
56119
+ const DEFAULT_SHARED_APP_KEY = 'default';
56120
+ function getSharedAppRegistry() {
56121
+ var _a;
56122
+ const target = globalThis;
56123
+ const registry = (_a = target[SHARED_APP_REGISTRY_KEY]) !== null && _a !== void 0 ? _a : new Map();
56124
+ target[SHARED_APP_REGISTRY_KEY] = registry;
56125
+ return registry;
56126
+ }
56127
+ function getSharedAppEnvRegistry(env, create) {
56128
+ const registry = getSharedAppRegistry();
56129
+ const envRegistry = registry.get(env);
56130
+ if (envRegistry || !create) {
56131
+ return envRegistry;
56132
+ }
56133
+ const nextEnvRegistry = new Map();
56134
+ registry.set(env, nextEnvRegistry);
56135
+ return nextEnvRegistry;
56136
+ }
56137
+ function getOrCreateSharedAppEnvRegistry(env) {
56138
+ return getSharedAppEnvRegistry(env, true);
56139
+ }
56140
+ function removeSharedAppRecord(env, key, record) {
56141
+ const registry = getSharedAppRegistry();
56142
+ const envRegistry = registry.get(env);
56143
+ if ((envRegistry === null || envRegistry === void 0 ? void 0 : envRegistry.get(key)) === record) {
56144
+ envRegistry.delete(key);
56145
+ if (!envRegistry.size) {
56146
+ registry.delete(env);
56147
+ }
56148
+ }
56149
+ }
56150
+ function releaseSharedAppRecord(env, key, record) {
56151
+ if (record.released) {
56152
+ return;
56153
+ }
56154
+ record.released = true;
56155
+ record.refCount = 0;
56156
+ removeSharedAppRecord(env, key, record);
56157
+ record.releaseApp();
56158
+ }
56159
+ function createAppForSharedEnv(options) {
56160
+ const { env } = options;
56161
+ const entryOptions = Object.assign({}, options);
56162
+ delete entryOptions.env;
56163
+ delete entryOptions.key;
56164
+ if (env === 'browser') {
56165
+ return createBrowserVRenderApp(entryOptions);
56166
+ }
56167
+ if (env === 'node') {
56168
+ return createNodeVRenderApp(entryOptions);
56169
+ }
56170
+ if (env === 'taro') {
56171
+ return createTaroVRenderApp(entryOptions);
56172
+ }
56173
+ if (env === 'feishu') {
56174
+ return createFeishuVRenderApp(entryOptions);
56175
+ }
56176
+ if (env === 'tt') {
56177
+ return createTTVRenderApp(entryOptions);
56178
+ }
56179
+ if (env === 'wx') {
56180
+ return createWxVRenderApp(entryOptions);
56181
+ }
56182
+ if (env === 'lynx') {
56183
+ return createLynxVRenderApp(entryOptions);
56184
+ }
56185
+ return createHarmonyVRenderApp(entryOptions);
56186
+ }
56187
+ function createSharedAppRecord(env, key, options) {
56188
+ const app = createAppForSharedEnv(options);
56189
+ const originalRelease = app.release.bind(app);
56190
+ const record = {
56191
+ app,
56192
+ refCount: 0,
56193
+ released: false,
56194
+ releaseApp: originalRelease
56195
+ };
56196
+ app.release = () => releaseSharedAppRecord(env, key, record);
56197
+ return record;
56198
+ }
56199
+ function createSharedAppHandle(env, key, record) {
56200
+ let released = false;
56201
+ return {
56202
+ app: record.app,
56203
+ env,
56204
+ key,
56205
+ release() {
56206
+ if (released) {
56207
+ return;
56208
+ }
56209
+ released = true;
56210
+ const envRegistry = getSharedAppEnvRegistry(env, false);
56211
+ if ((envRegistry === null || envRegistry === void 0 ? void 0 : envRegistry.get(key)) !== record || record.released) {
56212
+ return;
56213
+ }
56214
+ record.refCount -= 1;
56215
+ if (record.refCount <= 0) {
56216
+ releaseSharedAppRecord(env, key, record);
56217
+ }
56218
+ }
56219
+ };
56220
+ }
56221
+ function acquireSharedVRenderApp(options) {
56222
+ var _a;
56223
+ const key = (_a = options.key) !== null && _a !== void 0 ? _a : DEFAULT_SHARED_APP_KEY;
56224
+ const envRegistry = getOrCreateSharedAppEnvRegistry(options.env);
56225
+ let record = envRegistry.get(key);
56226
+ if (record === null || record === void 0 ? void 0 : record.app.released) {
56227
+ releaseSharedAppRecord(options.env, key, record);
56228
+ record = undefined;
56229
+ }
56230
+ if (!record) {
56231
+ record = createSharedAppRecord(options.env, key, options);
56232
+ envRegistry.set(key, record);
56233
+ }
56234
+ record.refCount += 1;
56235
+ return createSharedAppHandle(options.env, key, record);
56236
+ }
56237
+ function getSharedVRenderApp(env, key = DEFAULT_SHARED_APP_KEY) {
56238
+ var _a;
56239
+ const record = (_a = getSharedAppEnvRegistry(env, false)) === null || _a === void 0 ? void 0 : _a.get(key);
56240
+ if (!record || record.released || record.app.released) {
56241
+ return null;
56242
+ }
56243
+ return record.app;
56244
+ }
56245
+ function releaseSharedVRenderApp(env, key = DEFAULT_SHARED_APP_KEY) {
56246
+ var _a;
56247
+ const record = (_a = getSharedAppEnvRegistry(env, false)) === null || _a === void 0 ? void 0 : _a.get(key);
56248
+ if (record) {
56249
+ releaseSharedAppRecord(env, key, record);
56250
+ }
56251
+ }
56252
+
55766
56253
  let browserApp;
55767
56254
  let nodeApp;
55768
56255
  function resolveLegacyApp() {
@@ -55777,7 +56264,7 @@
55777
56264
  return resolveLegacyApp().createStage(params);
55778
56265
  }
55779
56266
 
55780
- const version = "1.1.0-alpha.21";
56267
+ const version = "1.1.0-alpha.23";
55781
56268
 
55782
56269
  exports.AComponentAnimate = AComponentAnimate;
55783
56270
  exports.ACustomAnimate = ACustomAnimate;
@@ -56249,6 +56736,7 @@
56249
56736
  exports._calculateLineHeight = _calculateLineHeight;
56250
56737
  exports._interpolateColor = _interpolateColor;
56251
56738
  exports._registerArc = _registerArc;
56739
+ exports.acquireSharedVRenderApp = acquireSharedVRenderApp;
56252
56740
  exports.addArcToBezierPath = addArcToBezierPath$1;
56253
56741
  exports.addAttributeToPrototype = addAttributeToPrototype;
56254
56742
  exports.alignBezierCurves = alignBezierCurves;
@@ -56500,6 +56988,7 @@
56500
56988
  exports.getRuntimeInstallerBindingContext = getRuntimeInstallerBindingContext;
56501
56989
  exports.getRuntimeInstallerGlobal = getRuntimeInstallerGlobal;
56502
56990
  exports.getScaledStroke = getScaledStroke;
56991
+ exports.getSharedVRenderApp = getSharedVRenderApp;
56503
56992
  exports.getSizeHandlerPath = getSizeHandlerPath;
56504
56993
  exports.getTextAlignAttrOfVerticalDir = getTextAlignAttrOfVerticalDir;
56505
56994
  exports.getTextBounds = getTextBounds;
@@ -56685,6 +57174,7 @@
56685
57174
  exports.registerWindowEventTransformer = registerWindowEventTransformer;
56686
57175
  exports.registerWrapText = registerWrapText;
56687
57176
  exports.registerWrapTextGraphic = registerWrapTextGraphic;
57177
+ exports.releaseSharedVRenderApp = releaseSharedVRenderApp;
56688
57178
  exports.removeRepeatPoint = removeRepeatPoint;
56689
57179
  exports.renderCommandList = renderCommandList;
56690
57180
  exports.resolveBackgroundDrawMode = resolveBackgroundDrawMode;