@visactor/vrender-kits 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.
Files changed (26) hide show
  1. package/cjs/env/contributions/lynx-contribution.d.ts +39 -10
  2. package/cjs/env/contributions/lynx-contribution.js +136 -25
  3. package/cjs/env/contributions/lynx-contribution.js.map +1 -1
  4. package/cjs/env/contributions/wx-contribution.d.ts +1 -2
  5. package/cjs/env/contributions/wx-contribution.js +4 -1
  6. package/cjs/env/contributions/wx-contribution.js.map +1 -1
  7. package/cjs/window/contributions/lynx-contribution.d.ts +1 -2
  8. package/cjs/window/contributions/lynx-contribution.js +63 -9
  9. package/cjs/window/contributions/lynx-contribution.js.map +1 -1
  10. package/cjs/window/contributions/wx-contribution.d.ts +1 -2
  11. package/cjs/window/contributions/wx-contribution.js +23 -9
  12. package/cjs/window/contributions/wx-contribution.js.map +1 -1
  13. package/dist/index.es.js +283 -48
  14. package/es/env/contributions/lynx-contribution.d.ts +39 -10
  15. package/es/env/contributions/lynx-contribution.js +137 -24
  16. package/es/env/contributions/lynx-contribution.js.map +1 -1
  17. package/es/env/contributions/wx-contribution.d.ts +1 -2
  18. package/es/env/contributions/wx-contribution.js +4 -1
  19. package/es/env/contributions/wx-contribution.js.map +1 -1
  20. package/es/window/contributions/lynx-contribution.d.ts +1 -2
  21. package/es/window/contributions/lynx-contribution.js +62 -10
  22. package/es/window/contributions/lynx-contribution.js.map +1 -1
  23. package/es/window/contributions/wx-contribution.d.ts +1 -2
  24. package/es/window/contributions/wx-contribution.js +22 -10
  25. package/es/window/contributions/wx-contribution.js.map +1 -1
  26. package/package.json +2 -2
package/dist/index.es.js CHANGED
@@ -6435,6 +6435,73 @@ let MiniAppEventManager$3 = class MiniAppEventManager {
6435
6435
  this.cache = {};
6436
6436
  }
6437
6437
  };
6438
+ function setMiniAppEventTarget$1(event, key, value) {
6439
+ if (!event || !value) {
6440
+ return;
6441
+ }
6442
+ try {
6443
+ event[key] = value;
6444
+ }
6445
+ catch (_a) {
6446
+ Object.defineProperty(event, key, {
6447
+ configurable: true,
6448
+ value
6449
+ });
6450
+ }
6451
+ }
6452
+ function isValidCoordinate$1(value) {
6453
+ return typeof value === 'number' && Number.isFinite(value);
6454
+ }
6455
+ function pickCoordinate$1(...values) {
6456
+ for (let i = 0; i < values.length; i++) {
6457
+ if (isValidCoordinate$1(values[i])) {
6458
+ return values[i];
6459
+ }
6460
+ }
6461
+ return undefined;
6462
+ }
6463
+ function setLynxEventValue(event, key, value) {
6464
+ try {
6465
+ event[key] = value;
6466
+ }
6467
+ catch (_a) {
6468
+ Object.defineProperty(event, key, {
6469
+ configurable: true,
6470
+ value
6471
+ });
6472
+ }
6473
+ }
6474
+ function normalizeLynxTouchEventPoint(event) {
6475
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
6476
+ const touch = (_b = (_a = event === null || event === void 0 ? void 0 : event.changedTouches) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = event === null || event === void 0 ? void 0 : event.touches) === null || _c === void 0 ? void 0 : _c[0];
6477
+ if (!touch) {
6478
+ return;
6479
+ }
6480
+ const x = pickCoordinate$1(event.x, event.offsetX, event.clientX, event.pageX, touch.x, touch.offsetX, touch.clientX, touch.pageX);
6481
+ const y = pickCoordinate$1(event.y, event.offsetY, event.clientY, event.pageY, touch.y, touch.offsetY, touch.clientY, touch.pageY);
6482
+ if (x == null || y == null) {
6483
+ return;
6484
+ }
6485
+ if (!event.touches && event.changedTouches) {
6486
+ setLynxEventValue(event, 'touches', event.type === 'touchend' || event.type === 'touchcancel' ? [] : event.changedTouches);
6487
+ }
6488
+ setLynxEventValue(event, 'x', x);
6489
+ setLynxEventValue(event, 'y', y);
6490
+ setLynxEventValue(event, 'offsetX', (_d = event.offsetX) !== null && _d !== void 0 ? _d : x);
6491
+ setLynxEventValue(event, 'offsetY', (_e = event.offsetY) !== null && _e !== void 0 ? _e : y);
6492
+ setLynxEventValue(event, 'clientX', (_f = event.clientX) !== null && _f !== void 0 ? _f : x);
6493
+ setLynxEventValue(event, 'clientY', (_g = event.clientY) !== null && _g !== void 0 ? _g : y);
6494
+ setLynxEventValue(event, 'pageX', (_h = event.pageX) !== null && _h !== void 0 ? _h : x);
6495
+ setLynxEventValue(event, 'pageY', (_j = event.pageY) !== null && _j !== void 0 ? _j : y);
6496
+ touch.x = (_k = touch.x) !== null && _k !== void 0 ? _k : x;
6497
+ touch.y = (_l = touch.y) !== null && _l !== void 0 ? _l : y;
6498
+ touch.offsetX = (_m = touch.offsetX) !== null && _m !== void 0 ? _m : x;
6499
+ touch.offsetY = (_o = touch.offsetY) !== null && _o !== void 0 ? _o : y;
6500
+ touch.clientX = (_p = touch.clientX) !== null && _p !== void 0 ? _p : x;
6501
+ touch.clientY = (_q = touch.clientY) !== null && _q !== void 0 ? _q : y;
6502
+ touch.pageX = (_r = touch.pageX) !== null && _r !== void 0 ? _r : x;
6503
+ touch.pageY = (_s = touch.pageY) !== null && _s !== void 0 ? _s : y;
6504
+ }
6438
6505
  class LynxWindowHandlerContribution extends BaseWindowHandlerContribution {
6439
6506
  get container() {
6440
6507
  return null;
@@ -6484,6 +6551,14 @@ class LynxWindowHandlerContribution extends BaseWindowHandlerContribution {
6484
6551
  let canvas;
6485
6552
  if (typeof params.canvas === 'string') {
6486
6553
  canvas = this.global.getElementById(params.canvas);
6554
+ if (!canvas) {
6555
+ canvas = this.global.createCanvas({
6556
+ id: params.canvas,
6557
+ width: params.width,
6558
+ height: params.height,
6559
+ dpr: params.dpr
6560
+ });
6561
+ }
6487
6562
  if (!canvas) {
6488
6563
  throw new Error('canvasId 参数不正确,请确认canvas存在并插入dom');
6489
6564
  }
@@ -6535,18 +6610,15 @@ class LynxWindowHandlerContribution extends BaseWindowHandlerContribution {
6535
6610
  this.eventManager.removeEventListener(type, listener);
6536
6611
  }
6537
6612
  dispatchEvent(event) {
6613
+ var _a;
6538
6614
  const { type } = event;
6539
6615
  if (!this.eventManager.cache[type]) {
6540
6616
  return false;
6541
6617
  }
6542
- if (event.changedTouches && event.changedTouches[0]) {
6543
- event.offsetX = event.changedTouches[0].x;
6544
- event.changedTouches[0].offsetX = event.changedTouches[0].x;
6545
- event.changedTouches[0].clientX = event.changedTouches[0].x;
6546
- event.offsetY = event.changedTouches[0].y;
6547
- event.changedTouches[0].offsetY = event.changedTouches[0].y;
6548
- event.changedTouches[0].clientY = event.changedTouches[0].y;
6549
- }
6618
+ const nativeCanvas = (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.nativeCanvas;
6619
+ setMiniAppEventTarget$1(event, 'target', nativeCanvas);
6620
+ setMiniAppEventTarget$1(event, 'currentTarget', nativeCanvas);
6621
+ normalizeLynxTouchEventPoint(event);
6550
6622
  event.preventDefault = () => {
6551
6623
  return;
6552
6624
  };
@@ -6607,48 +6679,161 @@ function bindLynxWindowContribution(container) {
6607
6679
  }
6608
6680
  }
6609
6681
 
6610
- let ng = false;
6611
- try {
6612
- ng = !!lynx.createCanvasNG;
6682
+ const LYNX_CANVAS_BRIDGE_ERROR = 'Lynx canvas bridge is unavailable. VRender Lynx env requires envParams.canvasFactory ' +
6683
+ 'or a Lynx runtime that exposes createCanvasNG/createCanvas/createOffscreenCanvas/krypton canvas APIs.';
6684
+ const LYNX_CANVAS_SIZE_ERROR = 'Lynx canvas size is unavailable. Pass stage width/height when creating a Lynx stage canvas.';
6685
+ function isValidCoordinate(value) {
6686
+ return typeof value === 'number' && Number.isFinite(value);
6613
6687
  }
6614
- catch (err) {
6688
+ function pickCoordinate(...values) {
6689
+ for (let i = 0; i < values.length; i++) {
6690
+ if (isValidCoordinate(values[i])) {
6691
+ return values[i];
6692
+ }
6693
+ }
6694
+ return undefined;
6615
6695
  }
6616
- function makeUpCanvas$3(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList, offscreen, pixelRatio) {
6617
- const dpr = pixelRatio !== null && pixelRatio !== void 0 ? pixelRatio : SystemInfo.pixelRatio;
6618
- canvasIdLists.forEach((id, i) => {
6619
- let _canvas;
6620
- if (offscreen) {
6621
- _canvas = lynx.createOffscreenCanvas();
6696
+ function getPrimaryTouch(event) {
6697
+ var _a, _b, _c;
6698
+ return (_b = (_a = event === null || event === void 0 ? void 0 : event.changedTouches) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = event === null || event === void 0 ? void 0 : event.touches) === null || _c === void 0 ? void 0 : _c[0];
6699
+ }
6700
+ function getLynxEventPoint(event) {
6701
+ const touch = getPrimaryTouch(event);
6702
+ const x = pickCoordinate(event === null || event === void 0 ? void 0 : event.x, event === null || event === void 0 ? void 0 : event.offsetX, event === null || event === void 0 ? void 0 : event.clientX, event === null || event === void 0 ? void 0 : event.pageX, touch === null || touch === void 0 ? void 0 : touch.x, touch === null || touch === void 0 ? void 0 : touch.offsetX, touch === null || touch === void 0 ? void 0 : touch.clientX, touch === null || touch === void 0 ? void 0 : touch.pageX);
6703
+ const y = pickCoordinate(event === null || event === void 0 ? void 0 : event.y, event === null || event === void 0 ? void 0 : event.offsetY, event === null || event === void 0 ? void 0 : event.clientY, event === null || event === void 0 ? void 0 : event.pageY, touch === null || touch === void 0 ? void 0 : touch.y, touch === null || touch === void 0 ? void 0 : touch.offsetY, touch === null || touch === void 0 ? void 0 : touch.clientY, touch === null || touch === void 0 ? void 0 : touch.pageY);
6704
+ return x == null || y == null ? null : { x, y };
6705
+ }
6706
+ function getGlobalLynxRuntime() {
6707
+ try {
6708
+ return typeof lynx !== 'undefined' ? lynx : undefined;
6709
+ }
6710
+ catch (err) {
6711
+ return undefined;
6712
+ }
6713
+ }
6714
+ function getGlobalSystemPixelRatio() {
6715
+ try {
6716
+ return typeof SystemInfo !== 'undefined' ? SystemInfo.pixelRatio : undefined;
6717
+ }
6718
+ catch (err) {
6719
+ return undefined;
6720
+ }
6721
+ }
6722
+ function getLynxRuntime(params) {
6723
+ var _a, _b;
6724
+ return (_b = (_a = params === null || params === void 0 ? void 0 : params.lynx) !== null && _a !== void 0 ? _a : params === null || params === void 0 ? void 0 : params.runtime) !== null && _b !== void 0 ? _b : getGlobalLynxRuntime();
6725
+ }
6726
+ function getLynxPixelRatio(params, runtime) {
6727
+ var _a, _b, _c, _d, _e;
6728
+ return (_e = (_d = (_a = params === null || params === void 0 ? void 0 : params.pixelRatio) !== null && _a !== void 0 ? _a : (_c = (_b = runtime === null || runtime === void 0 ? void 0 : runtime.getSystemInfoSync) === null || _b === void 0 ? void 0 : _b.call(runtime)) === null || _c === void 0 ? void 0 : _c.pixelRatio) !== null && _d !== void 0 ? _d : getGlobalSystemPixelRatio()) !== null && _e !== void 0 ? _e : 1;
6729
+ }
6730
+ function attachLynxCanvasToView(canvas, id) {
6731
+ var _a;
6732
+ (_a = canvas === null || canvas === void 0 ? void 0 : canvas.attachToCanvasView) === null || _a === void 0 ? void 0 : _a.call(canvas, id);
6733
+ return canvas;
6734
+ }
6735
+ function createBoundLynxCanvas(id, runtime) {
6736
+ var _a, _b, _c;
6737
+ if (typeof ((_a = runtime === null || runtime === void 0 ? void 0 : runtime.krypton) === null || _a === void 0 ? void 0 : _a.createCanvas) === 'function') {
6738
+ const canvas = runtime.krypton.createCanvas(id);
6739
+ if (canvas) {
6740
+ return canvas;
6622
6741
  }
6623
- else {
6624
- _canvas = ng ? lynx.createCanvasNG(id) : lynx.createCanvas(id);
6625
- ng && _canvas.attachToCanvasView(id);
6742
+ }
6743
+ if (typeof (runtime === null || runtime === void 0 ? void 0 : runtime.createCanvasNG) === 'function') {
6744
+ const canvas = runtime.createCanvasNG(id);
6745
+ if (canvas) {
6746
+ return attachLynxCanvasToView(canvas, id);
6626
6747
  }
6627
- _canvas.width = domref.width * dpr;
6628
- _canvas.height = domref.height * dpr;
6629
- const ctx = _canvas.getContext('2d');
6630
- const canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, domref.width, domref.height, id);
6748
+ }
6749
+ if (typeof ((_b = runtime === null || runtime === void 0 ? void 0 : runtime.krypton) === null || _b === void 0 ? void 0 : _b.createCanvasNG) === 'function') {
6750
+ const canvas = runtime.krypton.createCanvasNG();
6751
+ if (canvas) {
6752
+ return attachLynxCanvasToView(canvas, id);
6753
+ }
6754
+ }
6755
+ if (typeof ((_c = runtime === null || runtime === void 0 ? void 0 : runtime.krypton) === null || _c === void 0 ? void 0 : _c.CanvasElement) === 'function') {
6756
+ return new runtime.krypton.CanvasElement(id);
6757
+ }
6758
+ if (typeof (runtime === null || runtime === void 0 ? void 0 : runtime.createCanvas) === 'function') {
6759
+ const canvas = runtime.createCanvas(id);
6760
+ if (canvas) {
6761
+ return canvas;
6762
+ }
6763
+ }
6764
+ return null;
6765
+ }
6766
+ function getCanvasSize(domref, width, height) {
6767
+ const resolvedWidth = width !== null && width !== void 0 ? width : domref === null || domref === void 0 ? void 0 : domref.width;
6768
+ const resolvedHeight = height !== null && height !== void 0 ? height : domref === null || domref === void 0 ? void 0 : domref.height;
6769
+ if (!isValidCoordinate(resolvedWidth) || !isValidCoordinate(resolvedHeight)) {
6770
+ throw new Error(LYNX_CANVAS_SIZE_ERROR);
6771
+ }
6772
+ return { width: resolvedWidth, height: resolvedHeight };
6773
+ }
6774
+ function wrapLynxNativeCanvas(nativeCanvas, id, width, height, dpr) {
6775
+ nativeCanvas.width = width * dpr;
6776
+ nativeCanvas.height = height * dpr;
6777
+ const ctx = nativeCanvas.getContext('2d');
6778
+ return new CanvasWrapEnableWH(nativeCanvas, ctx, dpr, width, height, id);
6779
+ }
6780
+ function createLynxNativeCanvas(id, width, height, dpr, offscreen, params, runtime) {
6781
+ if (params.canvasFactory) {
6782
+ return params.canvasFactory({
6783
+ id,
6784
+ width,
6785
+ height,
6786
+ dpr,
6787
+ offscreen
6788
+ });
6789
+ }
6790
+ if (offscreen) {
6791
+ if (typeof (runtime === null || runtime === void 0 ? void 0 : runtime.createOffscreenCanvas) === 'function') {
6792
+ return runtime.createOffscreenCanvas();
6793
+ }
6794
+ }
6795
+ else {
6796
+ const canvas = createBoundLynxCanvas(id, runtime);
6797
+ if (canvas) {
6798
+ return canvas;
6799
+ }
6800
+ }
6801
+ throw new Error(LYNX_CANVAS_BRIDGE_ERROR);
6802
+ }
6803
+ function makeUpCanvas$3(params = {}, canvasMap, freeCanvasList) {
6804
+ const runtime = getLynxRuntime(params);
6805
+ const { domref, canvasIdLists = [], freeCanvasIdx = 0 } = params;
6806
+ const offscreen = !!params.offscreen;
6807
+ const dpr = getLynxPixelRatio(params, runtime);
6808
+ canvasIdLists.forEach((id, i) => {
6809
+ const size = getCanvasSize(domref);
6810
+ const _canvas = createLynxNativeCanvas(id, size.width, size.height, dpr, offscreen, params, runtime);
6811
+ const canvas = wrapLynxNativeCanvas(_canvas, id, size.width, size.height, dpr);
6631
6812
  canvasMap.set(id, canvas);
6632
6813
  if (i > freeCanvasIdx) {
6633
6814
  freeCanvasList.push(canvas);
6634
6815
  }
6635
6816
  });
6636
- if (!freeCanvasList.length && lynx.createOffscreenCanvas) {
6637
- const _canvas = lynx.createOffscreenCanvas();
6638
- _canvas.width = domref.width * dpr;
6639
- _canvas.height = domref.height * dpr;
6817
+ if (!freeCanvasList.length && domref && typeof (runtime === null || runtime === void 0 ? void 0 : runtime.createOffscreenCanvas) === 'function') {
6818
+ const size = getCanvasSize(domref);
6819
+ const _canvas = runtime.createOffscreenCanvas();
6820
+ _canvas.width = size.width * dpr;
6821
+ _canvas.height = size.height * dpr;
6640
6822
  const ctx = _canvas.getContext('2d');
6641
6823
  const id = Math.random().toString();
6642
- const canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, domref.width, domref.height, id);
6824
+ const canvas = new CanvasWrapEnableWH(_canvas, ctx, dpr, size.width, size.height, id);
6643
6825
  canvasMap.set(id, canvas);
6644
6826
  freeCanvasList.push(canvas);
6645
6827
  }
6646
6828
  }
6647
- function createImageElement(src, isSvg = false) {
6829
+ function createImageElement(src, isSvg = false, runtime = getGlobalLynxRuntime()) {
6648
6830
  if (isSvg) {
6649
6831
  return Promise.reject();
6650
6832
  }
6651
- const img = lynx.createImage(src);
6833
+ if (typeof (runtime === null || runtime === void 0 ? void 0 : runtime.createImage) !== 'function') {
6834
+ return Promise.reject(new Error('Lynx image bridge is unavailable.'));
6835
+ }
6836
+ const img = runtime.createImage(src);
6652
6837
  const promise = new Promise((resolve, reject) => {
6653
6838
  img.onload = () => {
6654
6839
  resolve(img);
@@ -6678,10 +6863,12 @@ class LynxEnvContribution extends BaseEnvContribution {
6678
6863
  }
6679
6864
  this.applyStyles = true;
6680
6865
  }
6681
- configure(service, params) {
6866
+ configure(service, params = {}) {
6682
6867
  if (service.env === this.type) {
6683
6868
  service.setActiveEnvContribution(this);
6684
- makeUpCanvas$3(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList, !!params.offscreen, params.pixelRatio);
6869
+ this.lynxEnvParams = params;
6870
+ this.lynxRuntime = getLynxRuntime(params);
6871
+ makeUpCanvas$3(params, this.canvasMap, this.freeCanvasList);
6685
6872
  }
6686
6873
  }
6687
6874
  getDynamicCanvasCount() {
@@ -6691,7 +6878,7 @@ class LynxEnvContribution extends BaseEnvContribution {
6691
6878
  return 9999;
6692
6879
  }
6693
6880
  loadImage(url) {
6694
- const imagePromise = createImageElement(url, false);
6881
+ const imagePromise = createImageElement(url, false, this.lynxRuntime);
6695
6882
  return imagePromise
6696
6883
  .then((img) => {
6697
6884
  return {
@@ -6707,12 +6894,43 @@ class LynxEnvContribution extends BaseEnvContribution {
6707
6894
  });
6708
6895
  }
6709
6896
  loadSvg(url) {
6710
- return Promise.reject();
6897
+ return Promise.resolve({
6898
+ data: null,
6899
+ loadState: 'fail'
6900
+ });
6711
6901
  }
6712
6902
  createCanvas(params) {
6903
+ var _a, _b, _c, _d;
6904
+ if (params.id != null) {
6905
+ const id = String(params.id);
6906
+ const existing = this.canvasMap.get(id);
6907
+ if (existing) {
6908
+ return existing;
6909
+ }
6910
+ const envParams = (_a = this.lynxEnvParams) !== null && _a !== void 0 ? _a : {};
6911
+ const runtime = getLynxRuntime(envParams);
6912
+ const dpr = (_b = params.dpr) !== null && _b !== void 0 ? _b : getLynxPixelRatio(envParams, runtime);
6913
+ const size = getCanvasSize(envParams.domref, params.width, params.height);
6914
+ const nativeCanvas = createLynxNativeCanvas(id, size.width, size.height, dpr, false, envParams, runtime);
6915
+ const canvas = wrapLynxNativeCanvas(nativeCanvas, id, size.width, size.height, dpr);
6916
+ this.canvasMap.set(id, canvas);
6917
+ return canvas;
6918
+ }
6713
6919
  const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
6714
6920
  this.canvasIdx++;
6715
- return result;
6921
+ if (result) {
6922
+ return result;
6923
+ }
6924
+ const envParams = (_c = this.lynxEnvParams) !== null && _c !== void 0 ? _c : {};
6925
+ const runtime = getLynxRuntime(envParams);
6926
+ const dpr = (_d = params.dpr) !== null && _d !== void 0 ? _d : getLynxPixelRatio(envParams, runtime);
6927
+ const size = getCanvasSize(envParams.domref, params.width, params.height);
6928
+ const id = Math.random().toString();
6929
+ const nativeCanvas = createLynxNativeCanvas(id, size.width, size.height, dpr, true, envParams, runtime);
6930
+ const canvas = wrapLynxNativeCanvas(nativeCanvas, id, size.width, size.height, dpr);
6931
+ this.canvasMap.set(id, canvas);
6932
+ this.freeCanvasList.push(canvas);
6933
+ return canvas;
6716
6934
  }
6717
6935
  createOffscreenCanvas(params) {
6718
6936
  return;
@@ -6721,7 +6939,7 @@ class LynxEnvContribution extends BaseEnvContribution {
6721
6939
  return;
6722
6940
  }
6723
6941
  getDevicePixelRatio() {
6724
- return SystemInfo.pixelRatio;
6942
+ return getLynxPixelRatio(undefined, this.lynxRuntime);
6725
6943
  }
6726
6944
  getRequestAnimationFrame() {
6727
6945
  return function (callback) {
@@ -6735,10 +6953,7 @@ class LynxEnvContribution extends BaseEnvContribution {
6735
6953
  }
6736
6954
  mapToCanvasPoint(event) {
6737
6955
  var _a;
6738
- if ((_a = event === null || event === void 0 ? void 0 : event.type) === null || _a === void 0 ? void 0 : _a.startsWith('mouse')) {
6739
- return event;
6740
- }
6741
- return event;
6956
+ return (_a = getLynxEventPoint(event)) !== null && _a !== void 0 ? _a : event;
6742
6957
  }
6743
6958
  addEventListener(type, listener, options) {
6744
6959
  return null;
@@ -7772,6 +7987,20 @@ class MiniAppEventManager {
7772
7987
  this.cache = {};
7773
7988
  }
7774
7989
  }
7990
+ function setMiniAppEventTarget(event, key, value) {
7991
+ if (!event || !value) {
7992
+ return;
7993
+ }
7994
+ try {
7995
+ event[key] = value;
7996
+ }
7997
+ catch (_a) {
7998
+ Object.defineProperty(event, key, {
7999
+ configurable: true,
8000
+ value
8001
+ });
8002
+ }
8003
+ }
7775
8004
  class WxWindowHandlerContribution extends BaseWindowHandlerContribution {
7776
8005
  get container() {
7777
8006
  return null;
@@ -7872,18 +8101,21 @@ class WxWindowHandlerContribution extends BaseWindowHandlerContribution {
7872
8101
  this.eventManager.removeEventListener(type, listener);
7873
8102
  }
7874
8103
  dispatchEvent(event) {
7875
- var _a, _b, _c, _d;
8104
+ var _a, _b, _c, _d, _e;
7876
8105
  const { type } = event;
7877
8106
  if (!this.eventManager.cache[type]) {
7878
8107
  return false;
7879
8108
  }
8109
+ const nativeCanvas = (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.nativeCanvas;
8110
+ setMiniAppEventTarget(event, 'target', nativeCanvas);
8111
+ setMiniAppEventTarget(event, 'currentTarget', nativeCanvas);
7880
8112
  if (event.changedTouches && event.changedTouches[0]) {
7881
8113
  event.offsetX = event.changedTouches[0].x;
7882
- event.changedTouches[0].offsetX = (_a = event.changedTouches[0].x) !== null && _a !== void 0 ? _a : event.changedTouches[0].pageX;
7883
- event.changedTouches[0].clientX = (_b = event.changedTouches[0].x) !== null && _b !== void 0 ? _b : event.changedTouches[0].pageX;
8114
+ event.changedTouches[0].offsetX = (_b = event.changedTouches[0].x) !== null && _b !== void 0 ? _b : event.changedTouches[0].pageX;
8115
+ event.changedTouches[0].clientX = (_c = event.changedTouches[0].x) !== null && _c !== void 0 ? _c : event.changedTouches[0].pageX;
7884
8116
  event.offsetY = event.changedTouches[0].y;
7885
- event.changedTouches[0].offsetY = (_c = event.changedTouches[0].y) !== null && _c !== void 0 ? _c : event.changedTouches[0].pageY;
7886
- event.changedTouches[0].clientY = (_d = event.changedTouches[0].y) !== null && _d !== void 0 ? _d : event.changedTouches[0].pageY;
8117
+ event.changedTouches[0].offsetY = (_d = event.changedTouches[0].y) !== null && _d !== void 0 ? _d : event.changedTouches[0].pageY;
8118
+ event.changedTouches[0].clientY = (_e = event.changedTouches[0].y) !== null && _e !== void 0 ? _e : event.changedTouches[0].pageY;
7887
8119
  }
7888
8120
  event.preventDefault = () => {
7889
8121
  return;
@@ -8013,7 +8245,10 @@ class WxEnvContribution extends BaseEnvContribution {
8013
8245
  });
8014
8246
  }
8015
8247
  loadSvg(url) {
8016
- return Promise.reject();
8248
+ return Promise.resolve({
8249
+ data: null,
8250
+ loadState: 'fail'
8251
+ });
8017
8252
  }
8018
8253
  createCanvas(params) {
8019
8254
  const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
@@ -1,20 +1,48 @@
1
- import { BaseEnvContribution } from '@visactor/vrender-core';
2
- import type { ICanvasLike, EnvType, ICreateCanvasParams, IEnvContribution, IGlobal, ILynxCanvas } from '@visactor/vrender-core';
3
- export declare function createImageElement(src: string, isSvg?: boolean): Promise<HTMLImageElement>;
1
+ import { BaseEnvContribution, type EnvType, type ICanvasLike, type ICreateCanvasParams, type IEnvContribution, type IGlobal, type ILynxCanvas } from '@visactor/vrender-core';
2
+ type LynxKryptonRuntime = Partial<{
3
+ createCanvas: (id: string) => any;
4
+ createCanvasNG: () => any;
5
+ CanvasElement: new (name: string) => any;
6
+ }>;
7
+ type LynxRuntime = Partial<{
8
+ getSystemInfoSync: () => {
9
+ pixelRatio?: number;
10
+ };
11
+ createCanvas: (id: string) => any;
12
+ createCanvasNG: (id?: string) => any;
13
+ createImage: (id: string) => any;
14
+ createOffscreenCanvas: () => any;
15
+ krypton: LynxKryptonRuntime;
16
+ }>;
17
+ type LynxCanvasFactoryOptions = {
18
+ id: string;
19
+ width: number;
20
+ height: number;
21
+ dpr: number;
22
+ offscreen: boolean;
23
+ };
24
+ type LynxCanvasFactory = (options: LynxCanvasFactoryOptions) => any;
25
+ type LynxEnvParams = {
26
+ domref?: any;
27
+ canvasIdLists?: string[];
28
+ freeCanvasIdx?: number;
29
+ offscreen?: boolean;
30
+ pixelRatio?: number;
31
+ lynx?: LynxRuntime;
32
+ runtime?: LynxRuntime;
33
+ canvasFactory?: LynxCanvasFactory;
34
+ };
35
+ export declare function createImageElement(src: string, isSvg?: boolean, runtime?: LynxRuntime | undefined): Promise<HTMLImageElement>;
4
36
  export declare class LynxEnvContribution extends BaseEnvContribution implements IEnvContribution {
5
37
  type: EnvType;
6
38
  supportEvent: boolean;
7
39
  canvasMap: Map<string, ILynxCanvas>;
8
40
  freeCanvasList: ILynxCanvas[];
9
41
  canvasIdx: number;
42
+ private lynxRuntime?;
43
+ private lynxEnvParams?;
10
44
  constructor();
11
- configure(service: IGlobal, params: {
12
- domref: any;
13
- canvasIdLists: string[];
14
- freeCanvasIdx: number;
15
- offscreen?: boolean;
16
- pixelRatio?: number;
17
- }): void;
45
+ configure(service: IGlobal, params?: LynxEnvParams): void;
18
46
  getDynamicCanvasCount(): number;
19
47
  getStaticCanvasCount(): number;
20
48
  loadImage(url: string): Promise<{
@@ -42,3 +70,4 @@ export declare class LynxEnvContribution extends BaseEnvContribution implements
42
70
  getDocument(): Document | null;
43
71
  release(...params: any): void;
44
72
  }
73
+ export {};