vite-plugin-taro-runtime 0.7.12-beta.0 → 0.7.12-beta.1

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 (67) hide show
  1. package/dist/api/dist/tools.d.ts +1 -1
  2. package/dist/api/dist/tools.js +1 -1
  3. package/dist/api/dist/tools.js.map +1 -1
  4. package/dist/components/dist/components/taro-image-core.js +13 -12
  5. package/dist/components/dist/components/taro-scroll-view-core.js +8 -3
  6. package/dist/components/dist/components/taro-web-view-core.js +48 -1
  7. package/dist/components/types/Button.d.ts +7 -0
  8. package/dist/components/types/Image.d.ts +6 -0
  9. package/dist/components/types/Input.d.ts +1 -1
  10. package/dist/components/types/ScrollView.d.ts +5 -0
  11. package/dist/components/types/Textarea.d.ts +1 -1
  12. package/dist/components/types/common.d.ts +24 -1
  13. package/dist/plugin-framework-react/runtime.js +25 -3
  14. package/dist/plugin-framework-react/runtime.js.map +1 -1
  15. package/dist/plugin-platform-h5/definition.json +3 -5
  16. package/dist/plugin-platform-weapp/runtime-utils.js +1 -0
  17. package/dist/plugin-platform-weapp/runtime-utils.js.map +1 -1
  18. package/dist/plugin-platform-weapp/runtime.js +1 -0
  19. package/dist/plugin-platform-weapp/runtime.js.map +1 -1
  20. package/dist/plugin-platform-weapp/types/components.d.ts +1 -0
  21. package/dist/react/index.d.ts +1 -0
  22. package/dist/react/react.esm.js +9 -112
  23. package/dist/react/renderer-host.d.ts +7 -0
  24. package/dist/runtime/bom/document.js +1 -1
  25. package/dist/runtime/dom/element.js +1 -1
  26. package/dist/runtime/dom/element.js.map +1 -1
  27. package/dist/runtime/dom/nearest-ctx.d.ts +9 -0
  28. package/dist/runtime/dom/nearest-ctx.js +49 -0
  29. package/dist/runtime/dom/nearest-ctx.js.map +1 -0
  30. package/dist/runtime/dom/node.d.ts +3 -1
  31. package/dist/runtime/dom/node.js +10 -0
  32. package/dist/runtime/dom/node.js.map +1 -1
  33. package/dist/runtime/dom/root.d.ts +2 -0
  34. package/dist/runtime/dom/root.js +4 -0
  35. package/dist/runtime/dom/root.js.map +1 -1
  36. package/dist/runtime/dom/style.js +2 -2
  37. package/dist/runtime/dom/style.js.map +1 -1
  38. package/dist/runtime/dsl/common.d.ts +1 -1
  39. package/dist/runtime/dsl/common.js +18 -9
  40. package/dist/runtime/dsl/common.js.map +1 -1
  41. package/dist/runtime/index.d.ts +1 -0
  42. package/dist/runtime/index.js +1 -0
  43. package/dist/runtime/index.js.map +1 -1
  44. package/dist/runtime/runtime.esm.d.ts +9 -2
  45. package/dist/runtime/runtime.esm.js +81 -13
  46. package/dist/runtime/runtime.esm.js.map +1 -1
  47. package/dist/taro/package.json +9 -9
  48. package/dist/taro/types/api/device/clipboard.d.ts +5 -0
  49. package/dist/taro/types/api/network/request.d.ts +7 -3
  50. package/dist/taro/types/api/network/upload.d.ts +21 -1
  51. package/dist/taro/types/api/payment/index.d.ts +58 -0
  52. package/dist/taro/types/compile/compiler.d.ts +13 -0
  53. package/dist/taro/types/compile/hooks.d.ts +1 -0
  54. package/dist/taro/types/taro.config.d.ts +64 -0
  55. package/dist/taro-h5/dist/api/base/weapp/app-event.js +15 -5
  56. package/dist/taro-h5/dist/api/base/weapp/app-event.js.map +1 -1
  57. package/dist/taro-h5/dist/api/device/clipboard.js +10 -6
  58. package/dist/taro-h5/dist/api/device/clipboard.js.map +1 -1
  59. package/dist/taro-h5/dist/api/media/map.d.ts +14 -1
  60. package/dist/taro-h5/dist/api/media/map.js +72 -2
  61. package/dist/taro-h5/dist/api/media/map.js.map +1 -1
  62. package/dist/taro-h5/dist/api/taro.d.ts +1 -1
  63. package/dist/taro-h5/dist/api/taro.js +3 -3
  64. package/dist/taro-h5/dist/api/taro.js.map +1 -1
  65. package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js +3 -0
  66. package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js.map +1 -1
  67. package/package.json +16 -16
@@ -1,4 +1,4 @@
1
1
  export declare function Behavior(options: any): any;
2
2
  export declare function getPreload(current: any): (key: any, val: unknown) => void;
3
3
  export declare function getInitPxTransform(taro: any): (config: any) => void;
4
- export declare function getPxTransform(taro: any): (size: any) => any;
4
+ export declare function getPxTransform(taro: any, designWid?: number): (size: any) => any;
@@ -32,7 +32,7 @@ function getInitPxTransform(taro) {
32
32
  taro.config.unitPrecision = unitPrecision;
33
33
  };
34
34
  }
35
- function getPxTransform(taro) {
35
+ function getPxTransform(taro, designWid) {
36
36
  return function (size) {
37
37
  const config = taro.config || {};
38
38
  const baseFontSize = config.baseFontSize;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sources":["../src/tools.ts"],"sourcesContent":["import { isFunction, isObject } from '@tarojs/shared'\n\nexport function Behavior (options) {\n return options\n}\n\nexport function getPreload (current) {\n return function (key: any, val: unknown) {\n current.preloadData = isObject(key)\n ? key\n : {\n [key]: val\n }\n }\n}\n\nconst defaultDesignWidth = 750\nconst defaultDesignRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n}\nconst defaultBaseFontSize = 20\nconst defaultUnitPrecision = 5\nconst defaultTargetUnit = 'rpx'\n\nexport function getInitPxTransform (taro) {\n return function (config) {\n const {\n designWidth = defaultDesignWidth,\n deviceRatio = defaultDesignRatio,\n baseFontSize = defaultBaseFontSize,\n targetUnit = defaultTargetUnit,\n unitPrecision = defaultUnitPrecision,\n } = config\n taro.config = taro.config || {}\n taro.config.designWidth = designWidth\n taro.config.deviceRatio = deviceRatio\n taro.config.baseFontSize = baseFontSize\n taro.config.targetUnit = targetUnit\n taro.config.unitPrecision = unitPrecision\n }\n}\n\nexport function getPxTransform (taro) {\n return function (size) {\n const config = taro.config || {}\n const baseFontSize = config.baseFontSize\n const deviceRatio = config.deviceRatio || defaultDesignRatio\n const designWidth = ((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth || defaultDesignWidth)(size)\n if (!(designWidth in deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const targetUnit = config.targetUnit || defaultTargetUnit\n const unitPrecision = config.unitPrecision || defaultUnitPrecision\n const formatSize = ~~size\n let rootValue = 1 / deviceRatio[designWidth]\n switch (targetUnit) {\n case 'rem':\n rootValue *= baseFontSize * 2\n break\n case 'px':\n rootValue *= 2\n break\n }\n let val = formatSize / rootValue\n if (unitPrecision >= 0 && unitPrecision <= 100) {\n val = Number(val.toFixed(unitPrecision))\n }\n return val + targetUnit\n }\n}\n"],"names":[],"mappings":";;AAEM,SAAU,QAAQ,CAAE,OAAO,EAAA;AAC/B,IAAA,OAAO,OAAO;AAChB;AAEM,SAAU,UAAU,CAAE,OAAO,EAAA;IACjC,OAAO,UAAU,GAAQ,EAAE,GAAY,EAAA;AACrC,QAAA,OAAO,CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG;AAChC,cAAE;AACF,cAAE;gBACA,CAAC,GAAG,GAAG;aACR;AACL,KAAC;AACH;AAEA,MAAM,kBAAkB,GAAG,GAAG;AAC9B,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,IAAI,GAAG,CAAC;AACb,IAAA,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,IAAI,GAAG;CACb;AACD,MAAM,mBAAmB,GAAG,EAAE;AAC9B,MAAM,oBAAoB,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,KAAK;AAEzB,SAAU,kBAAkB,CAAE,IAAI,EAAA;AACtC,IAAA,OAAO,UAAU,MAAM,EAAA;QACrB,MAAM,EACJ,WAAW,GAAG,kBAAkB,EAChC,WAAW,GAAG,kBAAkB,EAChC,YAAY,GAAG,mBAAmB,EAClC,UAAU,GAAG,iBAAiB,EAC9B,aAAa,GAAG,oBAAoB,GACrC,GAAG,MAAM;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE;AAC/B,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW;AACrC,QAAA,IAAI,CAAC,MAAM,CA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AC,IAAI,aAAa,IAAI,GAAG,EAAE;YAC9C,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;QAE1C,OAAO,GAAG,GAAG,UAAU;AACzB,KAAC;AACH;;;;"}
1
+ {"version":3,"file":"tools.js","sources":["../src/tools.ts"],"sourcesContent":["import { isFunction, isObject } from '@tarojs/shared'\n\nexport function Behavior (options) {\n return options\n}\n\nexport function getPreload (current) {\n return function (key: any, val: unknown) {\n current.preloadData = isObject(key)\n ? key\n : {\n [key]: val\n }\n }\n}\n\nconst defaultDesignWidth = 750\nconst defaultDesignRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n}\nconst defaultBaseFontSize = 20\nconst defaultUnitPrecision = 5\nconst defaultTargetUnit = 'rpx'\n\nexport function getInitPxTransform (taro) {\n return function (config) {\n const {\n designWidth = defaultDesignWidth,\n deviceRatio = defaultDesignRatio,\n baseFontSize = defaultBaseFontSize,\n targetUnit = defaultTargetUnit,\n unitPrecision = defaultUnitPrecision,\n } = config\n taro.config = taro.config || {}\n taro.config.designWidth = designWidth\n taro.config.deviceRatio = deviceRatio\n taro.config.baseFontSize = baseFontSize\n taro.config.targetUnit = targetUnit\n taro.config.unitPrecision = unitPrecision\n }\n}\n\nexport function getPxTransform (taro, designWid?: number) {\n return function (size) {\n const config = taro.config || {}\n const baseFontSize = config.baseFontSize\n const deviceRatio = config.deviceRatio || defaultDesignRatio\n const designWidth = designWid || ((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth || defaultDesignWidth)(size)\n if (!(designWidth in deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const targetUnit = config.targetUnit || defaultTargetUnit\n const unitPrecision = config.unitPrecision || defaultUnitPrecision\n const formatSize = ~~size\n let rootValue = 1 / deviceRatio[designWidth]\n switch (targetUnit) {\n case 'rem':\n rootValue *= baseFontSize * 2\n break\n case 'px':\n rootValue *= 2\n break\n }\n let val = formatSize / rootValue\n if (unitPrecision >= 0 && unitPrecision <= 100) {\n val = Number(val.toFixed(unitPrecision))\n }\n return val + targetUnit\n }\n}\n"],"names":[],"mappings":";;AAEM,SAAU,QAAQ,CAAE,OAAO,EAAA;AAC/B,IAAA,OAAO,OAAO;AAChB;AAEM,SAAU,UAAU,CAAE,OAAO,EAAA;IACjC,OAAO,UAAU,GAAQ,EAAE,GAAY,EAAA;AACrC,QAAA,OAAO,CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG;AAChC,cAAE;AACF,cAAE;gBACA,CAAC,GAAG,GAAG;aACR;AACL,KAAC;AACH;AAEA,MAAM,kBAAkB,GAAG,GAAG;AAC9B,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,IAAI,GAAG,CAAC;AACb,IAAA,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,IAAI,GAAG;CACb;AACD,MAAM,mBAAmB,GAAG,EAAE;AAC9B,MAAM,oBAAoB,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,KAAK;AAEzB,SAAU,kBAAkB,CAAE,IAAI,EAAA;AACtC,IAAA,OAAO,UAAU,MAAM,EAAA;QACrB,MAAM,EACJ,WAAW,GAAG,kBAAkB,EAChC,WAAW,GAAG,kBAAkB,EAChC,YAAY,GAAG,mBAAmB,EAClC,UAAU,GAAG,iBAAiB,EAC9B,aAAa,GAAG,oBAAoB,GACrC,GAAG,MAAM;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE;AAC/B,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW;AACrC,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW;AACrC,QAAA,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY;AACvC,QAAA,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,UAAU;AACnC,QAAA,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,aAAa;A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,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { c as classnames } from './index2.js';
3
3
 
4
- const indexCss = "img[src=\"\"]{opacity:0}taro-image-core{width:320px;height:240px;font-size:0;display:inline-block;position:relative;overflow:hidden}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%;position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{position:absolute;left:50%;transform:translate(-50%)}.taro-img__mode-bottom{position:absolute;bottom:0;left:50%;transform:translate(-50%)}.taro-img__mode-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-left{position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-right{position:absolute;top:50%;right:0;transform:translateY(-50%)}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;bottom:0;right:0}";
4
+ const indexCss = "img[src=\"\"]{opacity:0}:where(taro-image-core){width:320px;height:240px;font-size:0;display:inline-block;position:relative;overflow:hidden}:where(taro-image-core.taro-img__disable-default-size){width:auto;height:auto}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-aspectfill{object-fit:cover;width:100%;height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{position:absolute;left:50%;transform:translate(-50%)}.taro-img__mode-bottom{position:absolute;bottom:0;left:50%;transform:translate(-50%)}.taro-img__mode-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-left{position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-right{position:absolute;top:50%;right:0;transform:translateY(-50%)}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;bottom:0;right:0}";
5
5
 
6
6
  const Image = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -13,16 +13,16 @@ const Image = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
13
13
  this.mode = 'scaleToFill';
14
14
  this.lazyLoad = false;
15
15
  this.nativeProps = {};
16
- this.aspectFillMode = 'width';
16
+ this.disableDefaultSize = false;
17
17
  this.didLoad = false;
18
18
  }
19
19
  componentDidLoad() {
20
- if (!this.lazyLoad)
20
+ if (!this.lazyLoad || !this.imgRef)
21
21
  return;
22
22
  const lazyImg = new IntersectionObserver(entries => {
23
23
  // 异步 api 关系
24
24
  if (entries[entries.length - 1].isIntersecting) {
25
- lazyImg.unobserve(this.imgRef);
25
+ this.imgRef && lazyImg.unobserve(this.imgRef);
26
26
  this.didLoad = true;
27
27
  }
28
28
  }, {
@@ -31,26 +31,27 @@ const Image = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
31
31
  lazyImg.observe(this.imgRef);
32
32
  }
33
33
  imageOnLoad() {
34
- const { width, height, naturalWidth, naturalHeight } = this.imgRef;
34
+ // 防止组件已卸载或 img 已被移除时 ref 为 null(如列表滚动、src 清空、lazyLoad 时序等)
35
+ if (!this.imgRef)
36
+ return;
37
+ const { width, height } = this.imgRef;
35
38
  this.onLoad.emit({
36
39
  width,
37
40
  height
38
41
  });
39
- this.aspectFillMode = naturalWidth > naturalHeight ? 'width' : 'height';
40
42
  }
41
43
  imageOnError(e) {
42
44
  this.onError.emit(e);
43
45
  }
44
46
  render() {
45
- const { src, lazyLoad = false, aspectFillMode = 'width', imageOnLoad, imageOnError, nativeProps, didLoad } = this;
47
+ const { src, lazyLoad = false, imageOnLoad, imageOnError, nativeProps, didLoad } = this;
46
48
  // mode="" 按默认值处理
47
49
  const mode = this.mode || 'scaleToFill';
48
50
  const cls = classnames({
49
- 'taro-img__widthfix': mode === 'widthFix'
50
- });
51
- const imgCls = classnames(`taro-img__mode-${mode.toLowerCase().replace(/\s/g, '')}`, {
52
- [`taro-img__mode-aspectfill--${aspectFillMode}`]: mode === 'aspectFill'
51
+ 'taro-img__widthfix': mode === 'widthFix',
52
+ 'taro-img__disable-default-size': this.disableDefaultSize,
53
53
  });
54
+ const imgCls = `taro-img__mode-${mode.toLowerCase().replace(/\s/g, '')}`;
54
55
  return (h(Host, { class: cls }, src ? (h("img", Object.assign({ ref: (img) => (this.imgRef = img), class: imgCls, src: lazyLoad && !didLoad ? undefined : src, onLoad: imageOnLoad.bind(this), onError: imageOnError.bind(this) }, nativeProps))) : ''));
55
56
  }
56
57
  static get style() { return indexCss; }
@@ -59,7 +60,7 @@ const Image = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
59
60
  "mode": [1],
60
61
  "lazyLoad": [4, "lazy-load"],
61
62
  "nativeProps": [16],
62
- "aspectFillMode": [32],
63
+ "disableDefaultSize": [4, "disable-default-size"],
63
64
  "didLoad": [32]
64
65
  }]);
65
66
  function defineCustomElement$1() {
@@ -65,6 +65,7 @@ const ScrollView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
65
65
  this.animated = false;
66
66
  this.enhanced = false;
67
67
  this.showScrollbar = true;
68
+ this.stopTouchMovePropagation = true;
68
69
  }
69
70
  watchScrollLeft(newVal) {
70
71
  const left = Number(newVal);
@@ -103,7 +104,9 @@ const ScrollView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
103
104
  handleTouchMove(e) {
104
105
  if (e instanceof CustomEvent)
105
106
  return;
106
- e.stopPropagation();
107
+ if (this.stopTouchMovePropagation) {
108
+ e.stopPropagation();
109
+ }
107
110
  }
108
111
  async mpScrollToMethod(object) {
109
112
  let { top, left, duration, animated = false } = object;
@@ -129,10 +132,11 @@ const ScrollView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
129
132
  async mpScrollIntoViewMethod(selector) {
130
133
  var _a;
131
134
  if (typeof selector === 'string' && selector) {
135
+ // 未开启的滚动轴使用 nearest 避免原生 scrollIntoView 沿该轴滚动整页
132
136
  (_a = document.querySelector(`#${selector}`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
133
137
  behavior: this.animated ? 'smooth' : 'auto',
134
- block: this.scrollY ? (this.mpScrollIntoViewAlignment || 'center') : 'center',
135
- inline: this.scrollX ? (this.mpScrollIntoViewAlignment || 'start') : 'start'
138
+ block: this.scrollY ? (this.mpScrollIntoViewAlignment || 'center') : 'nearest',
139
+ inline: this.scrollX ? (this.mpScrollIntoViewAlignment || 'start') : 'nearest'
136
140
  });
137
141
  }
138
142
  }
@@ -176,6 +180,7 @@ const ScrollView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
176
180
  "animated": [4, "scroll-with-animation"],
177
181
  "enhanced": [4],
178
182
  "showScrollbar": [4, "show-scrollbar"],
183
+ "stopTouchMovePropagation": [4, "stop-touch-move-propagation"],
179
184
  "mpScrollToMethod": [64],
180
185
  "mpScrollIntoViewMethod": [64]
181
186
  }, [[1, "scroll", "handleScroll"], [1, "touchmove", "handleTouchMove"]]]);
@@ -2,17 +2,64 @@ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/i
2
2
 
3
3
  const indexCss = "iframe{border:none}.taro-webview{z-index:999;width:100%;height:100%;position:fixed;top:0;bottom:0}";
4
4
 
5
+ const hasWindow = typeof window !== 'undefined' && typeof window.addEventListener === 'function';
6
+ const webViewInstances = new Set();
7
+ let messageListenerAttached = false;
8
+ function handleWindowMessage(event) {
9
+ webViewInstances.forEach(instance => {
10
+ instance.handleMessage(event);
11
+ });
12
+ }
13
+ function attachGlobalMessageListener() {
14
+ if (!hasWindow || messageListenerAttached)
15
+ return;
16
+ window.addEventListener('message', handleWindowMessage);
17
+ messageListenerAttached = true;
18
+ }
19
+ function detachGlobalMessageListenerIfNeeded() {
20
+ if (!hasWindow || !messageListenerAttached)
21
+ return;
22
+ if (webViewInstances.size > 0)
23
+ return;
24
+ window.removeEventListener('message', handleWindowMessage);
25
+ messageListenerAttached = false;
26
+ }
5
27
  const WebView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
28
  constructor() {
7
29
  super();
8
30
  this.__registerHost();
9
31
  this.onLoad = createEvent(this, "load", 7);
10
32
  this.onError = createEvent(this, "error", 7);
33
+ this.onMessage = createEvent(this, "message", 7);
11
34
  this.src = undefined;
12
35
  }
36
+ componentDidLoad() {
37
+ webViewInstances.add(this);
38
+ attachGlobalMessageListener();
39
+ }
40
+ disconnectedCallback() {
41
+ webViewInstances.delete(this);
42
+ detachGlobalMessageListenerIfNeeded();
43
+ }
44
+ handleMessage(event) {
45
+ var _a;
46
+ const iframeWindow = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow;
47
+ if (!iframeWindow || event.source !== iframeWindow)
48
+ return;
49
+ const { src, onMessage } = this;
50
+ if (!onMessage)
51
+ return;
52
+ onMessage.emit({
53
+ data: event.data,
54
+ origin: event.origin,
55
+ src
56
+ });
57
+ }
13
58
  render() {
14
59
  const { src, onLoad, onError } = this;
15
- return (h("iframe", { class: 'taro-webview', onLoad: (e) => {
60
+ return (h("iframe", { ref: el => {
61
+ this.iframe = el;
62
+ }, class: 'taro-webview', onLoad: (e) => {
16
63
  e.stopPropagation();
17
64
  onLoad.emit({ src });
18
65
  }, onError: (e) => {
@@ -138,6 +138,13 @@ interface ButtonProps extends StandardProps {
138
138
  * @default false
139
139
  */
140
140
  showMessageCard?: boolean
141
+ /** 当手机号快速验证或手机号实时验证额度用尽时,是否对用户展示平台默认提示
142
+ *
143
+ * 生效时机:`open-type="getPhoneNumber"` 或 `open-type="getRealtimePhoneNumber"`
144
+ * @supported weapp
145
+ * @default true
146
+ */
147
+ phoneNumberNoQuotaToast?: boolean
141
148
  /** 生活号 id,必须是当前小程序同主体且已关联的生活号,open-type="lifestyle" 时有效。
142
149
  * @supported alipay, qq
143
150
  */
@@ -41,6 +41,12 @@ interface ImageProps extends StandardProps {
41
41
  * @supported h5, harmony_hybrid
42
42
  */
43
43
  nativeProps?: Record<string, unknown>
44
+ /**
45
+ * H5 / WebComponents 为 true 时关闭默认占位,`taro-image-core` 外层宽高均为 `auto`(默认 false 仍为 320×240)。
46
+ * @default false
47
+ * @supported h5, harmony_hybrid
48
+ */
49
+ disableDefaultSize?: boolean
44
50
  /** 默认图片地址,若设置默认图片地址,会先显示默认图片,等 src 对应的图片加载成功后,再渲染对应的图片。
45
51
  * @supported alipay
46
52
  */
@@ -99,7 +99,7 @@ interface InputProps extends StandardProps, FormItemProps {
99
99
  adjustPosition?: boolean
100
100
  /** focus 时,点击页面的时候不收起键盘
101
101
  * @default false
102
- * @supported weapp, tt
102
+ * @supported weapp, swan, tt
103
103
  */
104
104
  holdKeyboard?: boolean
105
105
  /**
@@ -13,6 +13,11 @@ interface ScrollViewProps extends StandardProps {
13
13
  * @rn 二选一
14
14
  */
15
15
  scrollY?: boolean
16
+ /** 是否阻止 touchmove 事件冒泡
17
+ * @supported h5
18
+ * @default true
19
+ */
20
+ stopTouchMovePropagation?: boolean
16
21
  /** 距顶部/左边多远时(单位px),触发 scrolltoupper 事件
17
22
  * @default 50
18
23
  * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid, ascf
@@ -85,7 +85,7 @@ interface TextareaProps extends StandardProps, FormItemProps {
85
85
  adjustPosition?: boolean
86
86
  /** focus 时,点击页面的时候不收起键盘
87
87
  * @default false
88
- * @supported weapp, tt
88
+ * @supported weapp, swan, tt
89
89
  */
90
90
  holdKeyboard?: boolean
91
91
  /** 是否去掉 iOS 下的默认内边距
@@ -1,7 +1,30 @@
1
1
  import { CSSProperties, LegacyRef, ReactNode } from 'react'
2
2
  import { COMPILE_MODE_SUB_RENDER_FN } from '@tarojs/shared'
3
3
 
4
- export interface StandardProps<T = any, TouchEvent extends BaseTouchEvent<any> = ITouchEvent> extends EventProps<TouchEvent> {
4
+ export interface A11yProps {
5
+ /** 定义元素的角色 */
6
+ ariaRole?: string
7
+ /** 为元素提供一个可访问名称 */
8
+ ariaLabel?: string
9
+ /** 当前 view 及其子 view 是否屏幕无障碍隐藏 */
10
+ ariaHidden?: boolean
11
+ /** 标识当前是否被选中 */
12
+ ariaChecked?: boolean
13
+ /** 指示元素是否处于选中状态 */
14
+ ariaSelected?: boolean
15
+ /** 为元素的 role 提供额外说明 */
16
+ ariaRoledescription?: string
17
+ /** 设置数值控件的最大值 */
18
+ ariaValuemax?: string
19
+ /** 设置数值控件的最小值 */
20
+ ariaValuemin?: string
21
+ /** 设置数值控件的当前值 */
22
+ ariaValuenow?: string
23
+ /** 设置将覆盖 ariaValuemax、ariaValuemin 和 ariaValuenow 的值 */
24
+ ariaValuetext?: string
25
+ }
26
+
27
+ export interface StandardProps<T = any, TouchEvent extends BaseTouchEvent<any> = ITouchEvent> extends EventProps<TouchEvent>, A11yProps {
5
28
  /** 组件的唯一标示, 保持整个页面唯一 */
6
29
  id?: string
7
30
  /** 同 `class`,在 React/Preact 里一般使用 `className` 作为 `class` 的代称 */
@@ -899,7 +899,9 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
899
899
  });
900
900
  },
901
901
  ready() {
902
+ updateCurrentRouter(this.compId);
902
903
  safeExecute(this.compId, 'onReady');
904
+ requestAnimationFrame(() => { var _a, _b; return eventCenter.trigger((_b = (_a = Current.router) === null || _a === void 0 ? void 0 : _a.onReady) !== null && _b !== void 0 ? _b : ''); });
903
905
  },
904
906
  detached() {
905
907
  resetCurrent();
@@ -908,7 +910,9 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
908
910
  },
909
911
  pageLifetimes: {
910
912
  show(options) {
913
+ updateCurrentRouter(this.compId);
911
914
  safeExecute(this.compId, 'onShow', options);
915
+ requestAnimationFrame(() => { var _a, _b; return eventCenter.trigger((_b = (_a = Current.router) === null || _a === void 0 ? void 0 : _a.onShow) !== null && _b !== void 0 ? _b : ''); });
912
916
  },
913
917
  hide() {
914
918
  safeExecute(this.compId, 'onHide');
@@ -970,6 +974,24 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
970
974
  }
971
975
  return componentObj;
972
976
  }
977
+ function updateCurrentRouter(compId) {
978
+ if (!getCurrentPages || typeof getCurrentPages !== 'function')
979
+ return;
980
+ const pages = getCurrentPages();
981
+ const currentPage = pages[pages.length - 1];
982
+ if (!currentPage)
983
+ return;
984
+ const route = currentPage.route || currentPage.__route__;
985
+ Current.page = currentPage;
986
+ Current.router = {
987
+ params: currentPage.options || {},
988
+ path: addLeadingSlash(route),
989
+ $taroPath: compId,
990
+ onReady: getOnReadyEventKey(route),
991
+ onShow: getOnShowEventKey(route),
992
+ onHide: getOnHideEventKey(route),
993
+ };
994
+ }
973
995
  function setCurrent(compId) {
974
996
  if (!getCurrentPages || typeof getCurrentPages !== 'function')
975
997
  return;
@@ -983,9 +1005,9 @@ function setCurrent(compId) {
983
1005
  params: currentPage.options || {},
984
1006
  path: addLeadingSlash(route),
985
1007
  $taroPath: compId,
986
- onReady: '',
987
- onHide: '',
988
- onShow: ''
1008
+ onReady: getOnReadyEventKey(route),
1009
+ onShow: getOnShowEventKey(route),
1010
+ onHide: getOnHideEventKey(route),
989
1011
  };
990
1012
  Current.router = router;
991
1013
  if (!currentPage.options) {