vite-plugin-taro-runtime 0.7.12-beta.0 → 0.7.12
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/api/dist/tools.d.ts +1 -1
- package/dist/api/dist/tools.js +1 -1
- package/dist/api/dist/tools.js.map +1 -1
- package/dist/components/dist/components/taro-image-core.js +13 -12
- package/dist/components/dist/components/taro-scroll-view-core.js +8 -3
- package/dist/components/dist/components/taro-web-view-core.js +48 -1
- package/dist/components/types/Button.d.ts +7 -0
- package/dist/components/types/Image.d.ts +6 -0
- package/dist/components/types/Input.d.ts +1 -1
- package/dist/components/types/ScrollView.d.ts +5 -0
- package/dist/components/types/Textarea.d.ts +1 -1
- package/dist/components/types/common.d.ts +24 -1
- package/dist/plugin-framework-react/runtime.js +29 -67
- package/dist/plugin-framework-react/runtime.js.map +1 -1
- package/dist/plugin-platform-h5/definition.json +3 -5
- package/dist/plugin-platform-weapp/runtime-utils.js +1 -0
- package/dist/plugin-platform-weapp/runtime-utils.js.map +1 -1
- package/dist/plugin-platform-weapp/runtime.js +1 -0
- package/dist/plugin-platform-weapp/runtime.js.map +1 -1
- package/dist/plugin-platform-weapp/types/components.d.ts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/react.esm.js +12 -113
- package/dist/react/renderer-host.d.ts +8 -0
- package/dist/runtime/bom/document.js +1 -1
- package/dist/runtime/dom/element.d.ts +4 -0
- package/dist/runtime/dom/element.js +9 -1
- package/dist/runtime/dom/element.js.map +1 -1
- package/dist/runtime/dom/nearest-ctx.d.ts +9 -0
- package/dist/runtime/dom/nearest-ctx.js +49 -0
- package/dist/runtime/dom/nearest-ctx.js.map +1 -0
- package/dist/runtime/dom/node.d.ts +15 -2
- package/dist/runtime/dom/node.js +71 -59
- package/dist/runtime/dom/node.js.map +1 -1
- package/dist/runtime/dom/root.d.ts +2 -0
- package/dist/runtime/dom/root.js +12 -14
- package/dist/runtime/dom/root.js.map +1 -1
- package/dist/runtime/dom/style.d.ts +2 -0
- package/dist/runtime/dom/style.js +15 -14
- package/dist/runtime/dom/style.js.map +1 -1
- package/dist/runtime/dom/text.d.ts +5 -0
- package/dist/runtime/dom/text.js +8 -4
- package/dist/runtime/dsl/common.d.ts +1 -1
- package/dist/runtime/dsl/common.js +18 -9
- package/dist/runtime/dsl/common.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/runtime.esm.d.ts +9 -2
- package/dist/runtime/runtime.esm.js +81 -13
- package/dist/runtime/runtime.esm.js.map +1 -1
- package/dist/taro/package.json +9 -9
- package/dist/taro/types/api/device/clipboard.d.ts +5 -0
- package/dist/taro/types/api/network/request.d.ts +7 -3
- package/dist/taro/types/api/network/upload.d.ts +21 -1
- package/dist/taro/types/api/payment/index.d.ts +58 -0
- package/dist/taro/types/compile/compiler.d.ts +13 -0
- package/dist/taro/types/compile/hooks.d.ts +1 -0
- package/dist/taro/types/taro.config.d.ts +64 -0
- package/dist/taro-h5/dist/api/base/weapp/app-event.js +15 -5
- package/dist/taro-h5/dist/api/base/weapp/app-event.js.map +1 -1
- package/dist/taro-h5/dist/api/device/clipboard.js +10 -6
- package/dist/taro-h5/dist/api/device/clipboard.js.map +1 -1
- package/dist/taro-h5/dist/api/media/map.d.ts +14 -1
- package/dist/taro-h5/dist/api/media/map.js +72 -2
- package/dist/taro-h5/dist/api/media/map.js.map +1 -1
- package/dist/taro-h5/dist/api/taro.d.ts +1 -1
- package/dist/taro-h5/dist/api/taro.js +3 -3
- package/dist/taro-h5/dist/api/taro.js.map +1 -1
- package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js +3 -0
- package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js.map +1 -1
- package/package.json +22 -16
- package/types/tt-document.d.ts +38 -0
package/dist/api/dist/tools.d.ts
CHANGED
|
@@ -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;
|
package/dist/api/dist/tools.js
CHANGED
|
@@ -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,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;AAC3C,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;AAC3C,KAAC;AACH;AAEgB,SAAA,cAAc,CAAE,IAAI,EAAE,SAAkB,EAAA;AACtD,IAAA,OAAO,UAAU,IAAI,EAAA;AACnB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE;AAChC,QAAA,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY;AACxC,QAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,kBAAkB;AAC5D,QAAA,MAAM,WAAW,GAAgB,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,WAAW;AAC5E,cAAE,MAAM,CAAC,WAAW,CAAC,KAAK;cACxB,MAAM,CAAC,WAAW,IAAI,kBAAkB,EAAE,IAAI,CAAC;AACnD,QAAA,IAAI,EAAE,WAAW,IAAI,WAAW,CAAC,EAAE;AACjC,YAAA,MAAM,IAAI,KAAK,CAAC,sBAAsB,WAAW,CAAA,KAAA,CAAO,CAAC;;AAE3D,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,iBAAiB;AACzD,QAAA,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,oBAAoB;AAClE,QAAA,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI;QACzB,IAAI,SAAS,GAAG,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC;QAC5C,QAAQ,UAAU;AAChB,YAAA,KAAK,KAAK;AACR,gBAAA,SAAS,IAAI,YAAY,GAAG,CAAC;gBAC7B;AACF,YAAA,KAAK,IAAI;gBACP,SAAS,IAAI,CAAC;gBACd;;AAEJ,QAAA,IAAI,GAAG,GAAG,UAAU,GAAG,SAAS;QAChC,IAAI,aAAa,IAAI,CAAC,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,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%;
|
|
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.
|
|
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
|
-
|
|
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,
|
|
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
|
-
"
|
|
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
|
-
|
|
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') : '
|
|
135
|
-
inline: this.scrollX ? (this.mpScrollIntoViewAlignment || '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", {
|
|
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
|
*/
|
|
@@ -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
|
|
@@ -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
|
|
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` 的代称 */
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { EMPTY_OBJ, isArray, isFunction, hooks, ensure, isUndefined } from '@tarojs/shared';
|
|
2
|
-
import { Current, getPageInstance, injectPageInstance, incrementId, document, perf, PAGE_INIT, CONTAINER, window, CONTEXT_ACTIONS, safeExecute, ON_HIDE, eventCenter, getOnHideEventKey, ON_SHOW, requestAnimationFrame, getOnShowEventKey, ON_READY, getOnReadyEventKey, removePageInstance, getPath, eventHandler, addLeadingSlash
|
|
2
|
+
import { Current, getPageInstance, injectPageInstance, incrementId, document, perf, PAGE_INIT, CONTAINER, window, CONTEXT_ACTIONS, safeExecute, ON_HIDE, eventCenter, getOnHideEventKey, ON_SHOW, requestAnimationFrame, getOnShowEventKey, ON_READY, getOnReadyEventKey, removePageInstance, getPath, eventHandler, addLeadingSlash } from '@tarojs/runtime';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* WX App-wrap flow:
|
|
6
|
-
*
|
|
7
|
-
* React still owns one root in which every Page remains an ordinary child of the singleton App. Native WX rendering,
|
|
8
|
-
* however, is driven by independent Page.setData surfaces, so App hosts above those Page roots have no scheduler of their
|
|
9
|
-
* own. The Mini Program branch below gives the App host an app.* scheduler, fans its deltas into every mounted Page, places
|
|
10
|
-
* one opaque outlet at App {children}, and seeds each new Page with the current App snapshot in its first native batch.
|
|
11
|
-
* hydrate() is needed only for that initial snapshot; the patched runtime stops traversal at the outlet so Page roots stay
|
|
12
|
-
* in the React/Taro ownership tree without being copied into app data.
|
|
13
|
-
*/
|
|
14
4
|
const reactMeta = {
|
|
15
5
|
PageContext: EMPTY_OBJ,
|
|
16
6
|
R: EMPTY_OBJ,
|
|
@@ -266,29 +256,6 @@ function connectReactPage(R, id) {
|
|
|
266
256
|
};
|
|
267
257
|
};
|
|
268
258
|
}
|
|
269
|
-
/**
|
|
270
|
-
* One App reconciliation produces one granular app.* batch, while WX stores an App mirror inside every mounted native
|
|
271
|
-
* Page. Resolve the native stack only when that batch flushes instead of maintaining a second Page registry or active-Page
|
|
272
|
-
* tracker. WeChat orders getCurrentPages() from the oldest hidden Page to the current visible Page, so forEach dispatches
|
|
273
|
-
* all hidden surfaces first. Only the final current Page receives Taro's callback: every setData call has then been issued,
|
|
274
|
-
* and Taro's scheduler completes its batch exactly once rather than coordinating one callback per Page.
|
|
275
|
-
*/
|
|
276
|
-
function broadcastAppUpdate(data, callback) {
|
|
277
|
-
const pages = getCurrentPages();
|
|
278
|
-
const currentPage = pages[pages.length - 1];
|
|
279
|
-
if (!currentPage) {
|
|
280
|
-
callback();
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
pages.forEach(page => {
|
|
284
|
-
if (page === currentPage) {
|
|
285
|
-
page.setData(data, callback);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
page.setData(data);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
259
|
/**
|
|
293
260
|
* 桥接小程序 App 构造器和 React 渲染流程
|
|
294
261
|
* @param App 用户编写的入口组件
|
|
@@ -335,21 +302,9 @@ function createReactApp(App, react, dom, config) {
|
|
|
335
302
|
container.id = appId;
|
|
336
303
|
appContainer === null || appContainer === void 0 ? void 0 : appContainer.appendChild(container);
|
|
337
304
|
}
|
|
338
|
-
/*
|
|
339
|
-
* renderReactRoot runs only for the Mini Program branch. The patched WX document makes this App container a
|
|
340
|
-
* TaroRootElement, so it serves simultaneously as React's existing host container and Taro's App scheduler; its
|
|
341
|
-
* structural _path is app and its _root is itself. Assign only the native sink that fans Taro's normal granular
|
|
342
|
-
* batches across Page surfaces. No detached scheduler node, second React root, or host-property override participates.
|
|
343
|
-
*/
|
|
344
|
-
container.ctx = { setData: broadcastAppUpdate };
|
|
345
305
|
// VPT requires React 19: both the Mini renderer and react-dom/client provide concurrent roots.
|
|
346
306
|
const root = ReactDOM$1.createRoot(container);
|
|
347
307
|
root.render(h$1(AppWrapper));
|
|
348
|
-
/*
|
|
349
|
-
* Return the exact host passed to ReactDOM. AppWrapper.mount closes over this immutable value when a Page is added,
|
|
350
|
-
* guaranteeing that its initial snapshot comes from the same singleton App tree without a host registry or lookup.
|
|
351
|
-
*/
|
|
352
|
-
return container;
|
|
353
308
|
}
|
|
354
309
|
class AppWrapper extends react.Component {
|
|
355
310
|
constructor(props) {
|
|
@@ -371,19 +326,6 @@ function createReactApp(App, react, dom, config) {
|
|
|
371
326
|
}
|
|
372
327
|
this.forceUpdate((...args) => {
|
|
373
328
|
perf.stop(PAGE_INIT);
|
|
374
|
-
if (process.env.TARO_PLATFORM !== 'web') {
|
|
375
|
-
/*
|
|
376
|
-
* React has now committed the Page root, but createPageConfig has not yet attached the native Page ctx or
|
|
377
|
-
* called performUpdate(true). Queue a lazy app.cn snapshot beside the Page root's already-pending page.*
|
|
378
|
-
* payloads. Taro therefore resolves both in one initial setData: no blank App frame, second bridge write,
|
|
379
|
-
* Page-ready phase, or custom pending queue. Patched hydrate() stops at the outlet before Page roots.
|
|
380
|
-
*/
|
|
381
|
-
const pageRoot = document.getElementById(id);
|
|
382
|
-
pageRoot.enqueueUpdate({
|
|
383
|
-
path: 'app.cn',
|
|
384
|
-
value: () => hydrate(container).cn
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
329
|
return cb(...args);
|
|
388
330
|
});
|
|
389
331
|
}
|
|
@@ -417,11 +359,9 @@ function createReactApp(App, react, dom, config) {
|
|
|
417
359
|
return h$1(App, props, children);
|
|
418
360
|
}
|
|
419
361
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
*/
|
|
424
|
-
const container = process.env.TARO_PLATFORM !== 'web' ? renderReactRoot() : null;
|
|
362
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
363
|
+
renderReactRoot();
|
|
364
|
+
}
|
|
425
365
|
const [ONLAUNCH, ONSHOW, ONHIDE] = hooks.call('getMiniLifecycleImpl').app;
|
|
426
366
|
const appObj = Object.create({
|
|
427
367
|
render(cb) {
|
|
@@ -899,7 +839,9 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
|
|
|
899
839
|
});
|
|
900
840
|
},
|
|
901
841
|
ready() {
|
|
842
|
+
updateCurrentRouter(this.compId);
|
|
902
843
|
safeExecute(this.compId, 'onReady');
|
|
844
|
+
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
845
|
},
|
|
904
846
|
detached() {
|
|
905
847
|
resetCurrent();
|
|
@@ -908,7 +850,9 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
|
|
|
908
850
|
},
|
|
909
851
|
pageLifetimes: {
|
|
910
852
|
show(options) {
|
|
853
|
+
updateCurrentRouter(this.compId);
|
|
911
854
|
safeExecute(this.compId, 'onShow', options);
|
|
855
|
+
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
856
|
},
|
|
913
857
|
hide() {
|
|
914
858
|
safeExecute(this.compId, 'onHide');
|
|
@@ -970,6 +914,24 @@ function createNativeComponentConfig(Component, react, reactDOM, componentConfig
|
|
|
970
914
|
}
|
|
971
915
|
return componentObj;
|
|
972
916
|
}
|
|
917
|
+
function updateCurrentRouter(compId) {
|
|
918
|
+
if (!getCurrentPages || typeof getCurrentPages !== 'function')
|
|
919
|
+
return;
|
|
920
|
+
const pages = getCurrentPages();
|
|
921
|
+
const currentPage = pages[pages.length - 1];
|
|
922
|
+
if (!currentPage)
|
|
923
|
+
return;
|
|
924
|
+
const route = currentPage.route || currentPage.__route__;
|
|
925
|
+
Current.page = currentPage;
|
|
926
|
+
Current.router = {
|
|
927
|
+
params: currentPage.options || {},
|
|
928
|
+
path: addLeadingSlash(route),
|
|
929
|
+
$taroPath: compId,
|
|
930
|
+
onReady: getOnReadyEventKey(route),
|
|
931
|
+
onShow: getOnShowEventKey(route),
|
|
932
|
+
onHide: getOnHideEventKey(route),
|
|
933
|
+
};
|
|
934
|
+
}
|
|
973
935
|
function setCurrent(compId) {
|
|
974
936
|
if (!getCurrentPages || typeof getCurrentPages !== 'function')
|
|
975
937
|
return;
|
|
@@ -983,9 +945,9 @@ function setCurrent(compId) {
|
|
|
983
945
|
params: currentPage.options || {},
|
|
984
946
|
path: addLeadingSlash(route),
|
|
985
947
|
$taroPath: compId,
|
|
986
|
-
onReady:
|
|
987
|
-
|
|
988
|
-
|
|
948
|
+
onReady: getOnReadyEventKey(route),
|
|
949
|
+
onShow: getOnShowEventKey(route),
|
|
950
|
+
onHide: getOnHideEventKey(route),
|
|
989
951
|
};
|
|
990
952
|
Current.router = router;
|
|
991
953
|
if (!currentPage.options) {
|