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

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
@@ -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) {
@@ -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");
@@ -29007,6 +29013,40 @@
29007
29013
  this.cache = {};
29008
29014
  }
29009
29015
  };
29016
+ function setMiniAppEventTarget$1(event, key, value) {
29017
+ if (event && value) try {
29018
+ event[key] = value;
29019
+ } catch (_a) {
29020
+ Object.defineProperty(event, key, {
29021
+ configurable: !0,
29022
+ value: value
29023
+ });
29024
+ }
29025
+ }
29026
+ function isValidCoordinate$1(value) {
29027
+ return "number" == typeof value && Number.isFinite(value);
29028
+ }
29029
+ function pickCoordinate$1(...values) {
29030
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate$1(values[i])) return values[i];
29031
+ }
29032
+ function setLynxEventValue(event, key, value) {
29033
+ try {
29034
+ event[key] = value;
29035
+ } catch (_a) {
29036
+ Object.defineProperty(event, key, {
29037
+ configurable: !0,
29038
+ value: value
29039
+ });
29040
+ }
29041
+ }
29042
+ function normalizeLynxTouchEventPoint(event) {
29043
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
29044
+ 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];
29045
+ if (!touch) return;
29046
+ const x = pickCoordinate$1(event.x, event.offsetX, event.clientX, event.pageX, touch.x, touch.offsetX, touch.clientX, touch.pageX),
29047
+ y = pickCoordinate$1(event.y, event.offsetY, event.clientY, event.pageY, touch.y, touch.offsetY, touch.clientY, touch.pageY);
29048
+ 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);
29049
+ }
29010
29050
  class LynxWindowHandlerContribution extends BaseWindowHandlerContribution {
29011
29051
  get container() {
29012
29052
  return null;
@@ -29050,7 +29090,12 @@
29050
29090
  createWindowByCanvas(params) {
29051
29091
  let canvas;
29052
29092
  if ("string" == typeof params.canvas) {
29053
- if (canvas = this.global.getElementById(params.canvas), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29093
+ if (canvas = this.global.getElementById(params.canvas), canvas || (canvas = this.global.createCanvas({
29094
+ id: params.canvas,
29095
+ width: params.width,
29096
+ height: params.height,
29097
+ dpr: params.dpr
29098
+ })), !canvas) throw new Error("canvasId 参数不正确,请确认canvas存在并插入dom");
29054
29099
  } else canvas = params.canvas;
29055
29100
  let width = params.width,
29056
29101
  height = params.height;
@@ -29090,12 +29135,15 @@
29090
29135
  this.eventManager.removeEventListener(type, listener);
29091
29136
  }
29092
29137
  dispatchEvent(event) {
29138
+ var _a;
29093
29139
  const {
29094
29140
  type: type
29095
29141
  } = 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 => {
29142
+ if (!this.eventManager.cache[type]) return !1;
29143
+ const nativeCanvas = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.nativeCanvas;
29144
+ 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
29145
  f(event);
29098
- }), !0);
29146
+ }), !0;
29099
29147
  }
29100
29148
  getStyle() {
29101
29149
  return {};
@@ -29127,30 +29175,131 @@
29127
29175
  (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
29176
  }
29129
29177
 
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;
29178
+ 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.",
29179
+ LYNX_CANVAS_SIZE_ERROR = "Lynx canvas size is unavailable. Pass stage width/height when creating a Lynx stage canvas.";
29180
+ function isValidCoordinate(value) {
29181
+ return "number" == typeof value && Number.isFinite(value);
29182
+ }
29183
+ function pickCoordinate(...values) {
29184
+ for (let i = 0; i < values.length; i++) if (isValidCoordinate(values[i])) return values[i];
29185
+ }
29186
+ function getPrimaryTouch(event) {
29187
+ var _a, _b, _c;
29188
+ 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];
29189
+ }
29190
+ function getLynxEventPoint(event) {
29191
+ const touch = getPrimaryTouch(event),
29192
+ 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),
29193
+ 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);
29194
+ return null == x || null == y ? null : {
29195
+ x: x,
29196
+ y: y
29197
+ };
29198
+ }
29199
+ function getGlobalLynxRuntime() {
29200
+ try {
29201
+ return "undefined" != typeof lynx ? lynx : void 0;
29202
+ } catch (err) {
29203
+ return;
29204
+ }
29205
+ }
29206
+ function getGlobalSystemPixelRatio() {
29207
+ try {
29208
+ return "undefined" != typeof SystemInfo ? SystemInfo.pixelRatio : void 0;
29209
+ } catch (err) {
29210
+ return;
29211
+ }
29212
+ }
29213
+ function getLynxRuntime(params) {
29214
+ var _a, _b;
29215
+ 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();
29216
+ }
29217
+ function getLynxPixelRatio(params, runtime) {
29218
+ var _a, _b, _c, _d, _e;
29219
+ 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;
29220
+ }
29221
+ function attachLynxCanvasToView(canvas, id) {
29222
+ var _a;
29223
+ return null === (_a = null == canvas ? void 0 : canvas.attachToCanvasView) || void 0 === _a || _a.call(canvas, id), canvas;
29224
+ }
29225
+ function createBoundLynxCanvas(id, runtime) {
29226
+ var _a, _b, _c;
29227
+ if ("function" == typeof (null === (_a = null == runtime ? void 0 : runtime.krypton) || void 0 === _a ? void 0 : _a.createCanvas)) {
29228
+ const canvas = runtime.krypton.createCanvas(id);
29229
+ if (canvas) return canvas;
29230
+ }
29231
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createCanvasNG)) {
29232
+ const canvas = runtime.createCanvasNG(id);
29233
+ if (canvas) return attachLynxCanvasToView(canvas, id);
29234
+ }
29235
+ if ("function" == typeof (null === (_b = null == runtime ? void 0 : runtime.krypton) || void 0 === _b ? void 0 : _b.createCanvasNG)) {
29236
+ const canvas = runtime.krypton.createCanvasNG();
29237
+ if (canvas) return attachLynxCanvasToView(canvas, id);
29238
+ }
29239
+ if ("function" == typeof (null === (_c = null == runtime ? void 0 : runtime.krypton) || void 0 === _c ? void 0 : _c.CanvasElement)) return new runtime.krypton.CanvasElement(id);
29240
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createCanvas)) {
29241
+ const canvas = runtime.createCanvas(id);
29242
+ if (canvas) return canvas;
29243
+ }
29244
+ return null;
29245
+ }
29246
+ function getCanvasSize(domref, width, height) {
29247
+ const resolvedWidth = null != width ? width : null == domref ? void 0 : domref.width,
29248
+ resolvedHeight = null != height ? height : null == domref ? void 0 : domref.height;
29249
+ if (!isValidCoordinate(resolvedWidth) || !isValidCoordinate(resolvedHeight)) throw new Error(LYNX_CANVAS_SIZE_ERROR);
29250
+ return {
29251
+ width: resolvedWidth,
29252
+ height: resolvedHeight
29253
+ };
29254
+ }
29255
+ function wrapLynxNativeCanvas(nativeCanvas, id, width, height, dpr) {
29256
+ nativeCanvas.width = width * dpr, nativeCanvas.height = height * dpr;
29257
+ const ctx = nativeCanvas.getContext("2d");
29258
+ return new CanvasWrapEnableWH(nativeCanvas, ctx, dpr, width, height, id);
29259
+ }
29260
+ function createLynxNativeCanvas(id, width, height, dpr, offscreen, params, runtime) {
29261
+ if (params.canvasFactory) return params.canvasFactory({
29262
+ id: id,
29263
+ width: width,
29264
+ height: height,
29265
+ dpr: dpr,
29266
+ offscreen: offscreen
29267
+ });
29268
+ if (offscreen) {
29269
+ if ("function" == typeof (null == runtime ? void 0 : runtime.createOffscreenCanvas)) return runtime.createOffscreenCanvas();
29270
+ } else {
29271
+ const canvas = createBoundLynxCanvas(id, runtime);
29272
+ if (canvas) return canvas;
29273
+ }
29274
+ throw new Error(LYNX_CANVAS_BRIDGE_ERROR);
29275
+ }
29276
+ function makeUpCanvas$3(params = {}, canvasMap, freeCanvasList) {
29277
+ const runtime = getLynxRuntime(params),
29278
+ {
29279
+ domref: domref,
29280
+ canvasIdLists = [],
29281
+ freeCanvasIdx = 0
29282
+ } = params,
29283
+ offscreen = !!params.offscreen,
29284
+ dpr = getLynxPixelRatio(params, runtime);
29136
29285
  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);
29286
+ const size = getCanvasSize(domref),
29287
+ canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, offscreen, params, runtime), id, size.width, size.height, dpr);
29141
29288
  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;
29289
+ }), !freeCanvasList.length && domref && "function" == typeof (null == runtime ? void 0 : runtime.createOffscreenCanvas)) {
29290
+ const size = getCanvasSize(domref),
29291
+ _canvas = runtime.createOffscreenCanvas();
29292
+ _canvas.width = size.width * dpr, _canvas.height = size.height * dpr;
29145
29293
  const ctx = _canvas.getContext("2d"),
29146
29294
  id = Math.random().toString(),
29147
- canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, domref.width, domref.height, id);
29295
+ canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, size.width, size.height, id);
29148
29296
  canvasMap.set(id, canvas), freeCanvasList.push(canvas);
29149
29297
  }
29150
29298
  }
29151
- function createImageElement(src, isSvg = !1) {
29299
+ function createImageElement(src, isSvg = !1, runtime = getGlobalLynxRuntime()) {
29152
29300
  if (isSvg) return Promise.reject();
29153
- const img = lynx.createImage(src);
29301
+ if ("function" != typeof (null == runtime ? void 0 : runtime.createImage)) return Promise.reject(new Error("Lynx image bridge is unavailable."));
29302
+ const img = runtime.createImage(src);
29154
29303
  return new Promise((resolve, reject) => {
29155
29304
  img.onload = () => {
29156
29305
  resolve(img);
@@ -29169,8 +29318,8 @@
29169
29318
  }
29170
29319
  this.applyStyles = !0;
29171
29320
  }
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));
29321
+ configure(service, params = {}) {
29322
+ service.env === this.type && (service.setActiveEnvContribution(this), this.lynxEnvParams = params, this.lynxRuntime = getLynxRuntime(params), makeUpCanvas$3(params, this.canvasMap, this.freeCanvasList));
29174
29323
  }
29175
29324
  getDynamicCanvasCount() {
29176
29325
  return this.freeCanvasList.length;
@@ -29179,7 +29328,7 @@
29179
29328
  return 9999;
29180
29329
  }
29181
29330
  loadImage(url) {
29182
- return createImageElement(url, !1).then(img => ({
29331
+ return createImageElement(url, !1, this.lynxRuntime).then(img => ({
29183
29332
  data: img,
29184
29333
  loadState: "success"
29185
29334
  })).catch(() => ({
@@ -29188,16 +29337,38 @@
29188
29337
  }));
29189
29338
  }
29190
29339
  loadSvg(url) {
29191
- return Promise.reject();
29340
+ return Promise.resolve({
29341
+ data: null,
29342
+ loadState: "fail"
29343
+ });
29192
29344
  }
29193
29345
  createCanvas(params) {
29346
+ var _a, _b, _c, _d;
29347
+ if (null != params.id) {
29348
+ const id = String(params.id),
29349
+ existing = this.canvasMap.get(id);
29350
+ if (existing) return existing;
29351
+ const envParams = null !== (_a = this.lynxEnvParams) && void 0 !== _a ? _a : {},
29352
+ runtime = getLynxRuntime(envParams),
29353
+ dpr = null !== (_b = params.dpr) && void 0 !== _b ? _b : getLynxPixelRatio(envParams, runtime),
29354
+ size = getCanvasSize(envParams.domref, params.width, params.height),
29355
+ canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !1, envParams, runtime), id, size.width, size.height, dpr);
29356
+ return this.canvasMap.set(id, canvas), canvas;
29357
+ }
29194
29358
  const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
29195
- return this.canvasIdx++, result;
29359
+ if (this.canvasIdx++, result) return result;
29360
+ const envParams = null !== (_c = this.lynxEnvParams) && void 0 !== _c ? _c : {},
29361
+ runtime = getLynxRuntime(envParams),
29362
+ dpr = null !== (_d = params.dpr) && void 0 !== _d ? _d : getLynxPixelRatio(envParams, runtime),
29363
+ size = getCanvasSize(envParams.domref, params.width, params.height),
29364
+ id = Math.random().toString(),
29365
+ canvas = wrapLynxNativeCanvas(createLynxNativeCanvas(id, size.width, size.height, dpr, !0, envParams, runtime), id, size.width, size.height, dpr);
29366
+ return this.canvasMap.set(id, canvas), this.freeCanvasList.push(canvas), canvas;
29196
29367
  }
29197
29368
  createOffscreenCanvas(params) {}
29198
29369
  releaseCanvas(canvas) {}
29199
29370
  getDevicePixelRatio() {
29200
- return SystemInfo.pixelRatio;
29371
+ return getLynxPixelRatio(void 0, this.lynxRuntime);
29201
29372
  }
29202
29373
  getRequestAnimationFrame() {
29203
29374
  return function (callback) {
@@ -29211,7 +29382,7 @@
29211
29382
  }
29212
29383
  mapToCanvasPoint(event) {
29213
29384
  var _a;
29214
- return null === (_a = null == event ? void 0 : event.type) || void 0 === _a || _a.startsWith("mouse"), event;
29385
+ return null !== (_a = getLynxEventPoint(event)) && void 0 !== _a ? _a : event;
29215
29386
  }
29216
29387
  addEventListener(type, listener, options) {
29217
29388
  return null;
@@ -29968,6 +30139,16 @@
29968
30139
  this.cache = {};
29969
30140
  }
29970
30141
  }
30142
+ function setMiniAppEventTarget(event, key, value) {
30143
+ if (event && value) try {
30144
+ event[key] = value;
30145
+ } catch (_a) {
30146
+ Object.defineProperty(event, key, {
30147
+ configurable: !0,
30148
+ value: value
30149
+ });
30150
+ }
30151
+ }
29971
30152
  class WxWindowHandlerContribution extends BaseWindowHandlerContribution {
29972
30153
  get container() {
29973
30154
  return null;
@@ -30049,13 +30230,15 @@
30049
30230
  this.eventManager.removeEventListener(type, listener);
30050
30231
  }
30051
30232
  dispatchEvent(event) {
30052
- var _a, _b, _c, _d;
30233
+ var _a, _b, _c, _d, _e;
30053
30234
  const {
30054
30235
  type: type
30055
30236
  } = 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 => {
30237
+ if (!this.eventManager.cache[type]) return !1;
30238
+ const nativeCanvas = null === (_a = this.canvas) || void 0 === _a ? void 0 : _a.nativeCanvas;
30239
+ 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
30240
  f(event);
30058
- }), !0);
30241
+ }), !0;
30059
30242
  }
30060
30243
  getStyle() {
30061
30244
  return {};
@@ -30153,7 +30336,10 @@
30153
30336
  });
30154
30337
  }
30155
30338
  loadSvg(url) {
30156
- return Promise.reject();
30339
+ return Promise.resolve({
30340
+ data: null,
30341
+ loadState: "fail"
30342
+ });
30157
30343
  }
30158
30344
  createCanvas(params) {
30159
30345
  const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
@@ -53166,15 +53352,16 @@
53166
53352
  loadBrushComponent();
53167
53353
  class Brush extends AbstractComponent {
53168
53354
  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 => {
53355
+ 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
53356
  if (!1 === this.attribute.interactive) return;
53171
53357
  if (!1 === this._beforeBrushEvent(e)) return;
53172
53358
  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];
53359
+ updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,
53360
+ endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger,
53361
+ brushMoved = !0
53362
+ } = this.attribute,
53363
+ stage = this.stage;
53364
+ 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
53365
  }, this._onBrushing = e => {
53179
53366
  !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
53367
  }, this._onBrushingWithDelay = 0 === this.attribute.delayTime ? this._onBrushing : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime), this._onBrushEnd = e => {
@@ -53185,11 +53372,14 @@
53185
53372
  }
53186
53373
  _bindBrushEvents() {
53187
53374
  if (this.releaseBrushEvents(), this.attribute.disableTriggerEvent) return;
53375
+ const stage = this.stage;
53376
+ if (!stage) return;
53377
+ this._brushEventStage = stage;
53188
53378
  const {
53189
53379
  trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,
53190
53380
  resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger
53191
53381
  } = this.attribute;
53192
- array(trigger).forEach(t => this.stage.addEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushClear));
53382
+ array(trigger).forEach(t => stage.addEventListener(t, this._onBrushStart)), array(resetTrigger).forEach(t => stage.addEventListener(t, this._onBrushClear));
53193
53383
  }
53194
53384
  _initDraw(e) {
53195
53385
  if (!1 === this.attribute.interactive) return;
@@ -53290,19 +53480,30 @@
53290
53480
  const group = this.createOrUpdateChild("brush-container", {}, "group");
53291
53481
  this._container = group;
53292
53482
  }
53483
+ setStage(stage, layer) {
53484
+ this._brushEventStage && this._brushEventStage !== stage && this.releaseBrushEvents(), super.setStage(stage, layer);
53485
+ }
53486
+ release(all) {
53487
+ this.releaseBrushEvents(), super.release(all);
53488
+ }
53293
53489
  releaseBrushEvents() {
53490
+ var _a;
53491
+ const stage = null !== (_a = this._brushEventStage) && void 0 !== _a ? _a : this.stage;
53492
+ if (!stage) return;
53294
53493
  const {
53295
53494
  trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger,
53296
53495
  resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger
53297
53496
  } = 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();
53497
+ 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
53498
  }
53300
- _releaseBrushUpdateEvents() {
53499
+ _releaseBrushUpdateEvents(stage) {
53500
+ var _a;
53501
+ if (void 0 === stage && (stage = null !== (_a = this._brushEventStage) && void 0 !== _a ? _a : this.stage), !stage) return;
53301
53502
  const {
53302
53503
  updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger,
53303
53504
  endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger
53304
53505
  } = this.attribute;
53305
- array(updateTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushEnd));
53506
+ array(updateTrigger).forEach(t => stage.removeEventListener(t, this._onBrushingWithDelay)), array(endTrigger).forEach(t => stage.removeEventListener(t, this._onBrushEnd));
53306
53507
  }
53307
53508
  _computeMaskPoints() {
53308
53509
  const {
@@ -55763,6 +55964,141 @@
55763
55964
  return bootstrapVRenderNodeApp(createNodeApp(entryOptions), envParams);
55764
55965
  }
55765
55966
 
55967
+ const SHARED_APP_REGISTRY_KEY = Symbol.for('visactor.vrender.sharedAppRegistry');
55968
+ const DEFAULT_SHARED_APP_KEY = 'default';
55969
+ function getSharedAppRegistry() {
55970
+ var _a;
55971
+ const target = globalThis;
55972
+ const registry = (_a = target[SHARED_APP_REGISTRY_KEY]) !== null && _a !== void 0 ? _a : new Map();
55973
+ target[SHARED_APP_REGISTRY_KEY] = registry;
55974
+ return registry;
55975
+ }
55976
+ function getSharedAppEnvRegistry(env, create) {
55977
+ const registry = getSharedAppRegistry();
55978
+ const envRegistry = registry.get(env);
55979
+ if (envRegistry || !create) {
55980
+ return envRegistry;
55981
+ }
55982
+ const nextEnvRegistry = new Map();
55983
+ registry.set(env, nextEnvRegistry);
55984
+ return nextEnvRegistry;
55985
+ }
55986
+ function getOrCreateSharedAppEnvRegistry(env) {
55987
+ return getSharedAppEnvRegistry(env, true);
55988
+ }
55989
+ function removeSharedAppRecord(env, key, record) {
55990
+ const registry = getSharedAppRegistry();
55991
+ const envRegistry = registry.get(env);
55992
+ if ((envRegistry === null || envRegistry === void 0 ? void 0 : envRegistry.get(key)) === record) {
55993
+ envRegistry.delete(key);
55994
+ if (!envRegistry.size) {
55995
+ registry.delete(env);
55996
+ }
55997
+ }
55998
+ }
55999
+ function releaseSharedAppRecord(env, key, record) {
56000
+ if (record.released) {
56001
+ return;
56002
+ }
56003
+ record.released = true;
56004
+ record.refCount = 0;
56005
+ removeSharedAppRecord(env, key, record);
56006
+ record.releaseApp();
56007
+ }
56008
+ function createAppForSharedEnv(options) {
56009
+ const { env } = options;
56010
+ const entryOptions = Object.assign({}, options);
56011
+ delete entryOptions.env;
56012
+ delete entryOptions.key;
56013
+ if (env === 'browser') {
56014
+ return createBrowserVRenderApp(entryOptions);
56015
+ }
56016
+ if (env === 'node') {
56017
+ return createNodeVRenderApp(entryOptions);
56018
+ }
56019
+ if (env === 'taro') {
56020
+ return createTaroVRenderApp(entryOptions);
56021
+ }
56022
+ if (env === 'feishu') {
56023
+ return createFeishuVRenderApp(entryOptions);
56024
+ }
56025
+ if (env === 'tt') {
56026
+ return createTTVRenderApp(entryOptions);
56027
+ }
56028
+ if (env === 'wx') {
56029
+ return createWxVRenderApp(entryOptions);
56030
+ }
56031
+ if (env === 'lynx') {
56032
+ return createLynxVRenderApp(entryOptions);
56033
+ }
56034
+ return createHarmonyVRenderApp(entryOptions);
56035
+ }
56036
+ function createSharedAppRecord(env, key, options) {
56037
+ const app = createAppForSharedEnv(options);
56038
+ const originalRelease = app.release.bind(app);
56039
+ const record = {
56040
+ app,
56041
+ refCount: 0,
56042
+ released: false,
56043
+ releaseApp: originalRelease
56044
+ };
56045
+ app.release = () => releaseSharedAppRecord(env, key, record);
56046
+ return record;
56047
+ }
56048
+ function createSharedAppHandle(env, key, record) {
56049
+ let released = false;
56050
+ return {
56051
+ app: record.app,
56052
+ env,
56053
+ key,
56054
+ release() {
56055
+ if (released) {
56056
+ return;
56057
+ }
56058
+ released = true;
56059
+ const envRegistry = getSharedAppEnvRegistry(env, false);
56060
+ if ((envRegistry === null || envRegistry === void 0 ? void 0 : envRegistry.get(key)) !== record || record.released) {
56061
+ return;
56062
+ }
56063
+ record.refCount -= 1;
56064
+ if (record.refCount <= 0) {
56065
+ releaseSharedAppRecord(env, key, record);
56066
+ }
56067
+ }
56068
+ };
56069
+ }
56070
+ function acquireSharedVRenderApp(options) {
56071
+ var _a;
56072
+ const key = (_a = options.key) !== null && _a !== void 0 ? _a : DEFAULT_SHARED_APP_KEY;
56073
+ const envRegistry = getOrCreateSharedAppEnvRegistry(options.env);
56074
+ let record = envRegistry.get(key);
56075
+ if (record === null || record === void 0 ? void 0 : record.app.released) {
56076
+ releaseSharedAppRecord(options.env, key, record);
56077
+ record = undefined;
56078
+ }
56079
+ if (!record) {
56080
+ record = createSharedAppRecord(options.env, key, options);
56081
+ envRegistry.set(key, record);
56082
+ }
56083
+ record.refCount += 1;
56084
+ return createSharedAppHandle(options.env, key, record);
56085
+ }
56086
+ function getSharedVRenderApp(env, key = DEFAULT_SHARED_APP_KEY) {
56087
+ var _a;
56088
+ const record = (_a = getSharedAppEnvRegistry(env, false)) === null || _a === void 0 ? void 0 : _a.get(key);
56089
+ if (!record || record.released || record.app.released) {
56090
+ return null;
56091
+ }
56092
+ return record.app;
56093
+ }
56094
+ function releaseSharedVRenderApp(env, key = DEFAULT_SHARED_APP_KEY) {
56095
+ var _a;
56096
+ const record = (_a = getSharedAppEnvRegistry(env, false)) === null || _a === void 0 ? void 0 : _a.get(key);
56097
+ if (record) {
56098
+ releaseSharedAppRecord(env, key, record);
56099
+ }
56100
+ }
56101
+
55766
56102
  let browserApp;
55767
56103
  let nodeApp;
55768
56104
  function resolveLegacyApp() {
@@ -55777,7 +56113,7 @@
55777
56113
  return resolveLegacyApp().createStage(params);
55778
56114
  }
55779
56115
 
55780
- const version = "1.1.0-alpha.21";
56116
+ const version = "1.1.0-alpha.22";
55781
56117
 
55782
56118
  exports.AComponentAnimate = AComponentAnimate;
55783
56119
  exports.ACustomAnimate = ACustomAnimate;
@@ -56249,6 +56585,7 @@
56249
56585
  exports._calculateLineHeight = _calculateLineHeight;
56250
56586
  exports._interpolateColor = _interpolateColor;
56251
56587
  exports._registerArc = _registerArc;
56588
+ exports.acquireSharedVRenderApp = acquireSharedVRenderApp;
56252
56589
  exports.addArcToBezierPath = addArcToBezierPath$1;
56253
56590
  exports.addAttributeToPrototype = addAttributeToPrototype;
56254
56591
  exports.alignBezierCurves = alignBezierCurves;
@@ -56500,6 +56837,7 @@
56500
56837
  exports.getRuntimeInstallerBindingContext = getRuntimeInstallerBindingContext;
56501
56838
  exports.getRuntimeInstallerGlobal = getRuntimeInstallerGlobal;
56502
56839
  exports.getScaledStroke = getScaledStroke;
56840
+ exports.getSharedVRenderApp = getSharedVRenderApp;
56503
56841
  exports.getSizeHandlerPath = getSizeHandlerPath;
56504
56842
  exports.getTextAlignAttrOfVerticalDir = getTextAlignAttrOfVerticalDir;
56505
56843
  exports.getTextBounds = getTextBounds;
@@ -56685,6 +57023,7 @@
56685
57023
  exports.registerWindowEventTransformer = registerWindowEventTransformer;
56686
57024
  exports.registerWrapText = registerWrapText;
56687
57025
  exports.registerWrapTextGraphic = registerWrapTextGraphic;
57026
+ exports.releaseSharedVRenderApp = releaseSharedVRenderApp;
56688
57027
  exports.removeRepeatPoint = removeRepeatPoint;
56689
57028
  exports.renderCommandList = renderCommandList;
56690
57029
  exports.resolveBackgroundDrawMode = resolveBackgroundDrawMode;