@tarojs/shared 4.0.7-alpha.0 → 4.0.7-alpha.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.
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/runtime-hooks.d.ts +1 -1
- package/dist/runtime-hooks.js.map +1 -1
- package/dist/shared.esm.js +4 -4
- package/dist/shared.esm.js.map +1 -1
- package/dist/shortcuts.d.ts +5 -5
- package/dist/shortcuts.js +4 -4
- package/dist/shortcuts.js.map +1 -1
- package/dist/template.d.ts +1 -1
- package/dist/template.js +30 -30
- package/dist/template.js.map +1 -1
- package/package.json +1 -1
package/dist/template.js
CHANGED
|
@@ -343,15 +343,15 @@ function isBooleanStringLiteral(o) {
|
|
|
343
343
|
exports.Shortcuts = void 0;
|
|
344
344
|
(function (Shortcuts) {
|
|
345
345
|
Shortcuts["Container"] = "container";
|
|
346
|
-
Shortcuts["Childnodes"] = "
|
|
346
|
+
Shortcuts["Childnodes"] = "cn";
|
|
347
347
|
Shortcuts["Text"] = "v";
|
|
348
348
|
Shortcuts["NodeType"] = "nt";
|
|
349
|
-
Shortcuts["NodeName"] = "
|
|
349
|
+
Shortcuts["NodeName"] = "nn";
|
|
350
350
|
// Attrtibutes
|
|
351
|
+
Shortcuts["Sid"] = "sid";
|
|
351
352
|
Shortcuts["Style"] = "st";
|
|
352
|
-
Shortcuts["Class"] = "
|
|
353
|
+
Shortcuts["Class"] = "cl";
|
|
353
354
|
Shortcuts["Src"] = "src";
|
|
354
|
-
Shortcuts["Sid"] = "s";
|
|
355
355
|
})(exports.Shortcuts || (exports.Shortcuts = {}));
|
|
356
356
|
|
|
357
357
|
var PLATFORM_TYPE;
|
|
@@ -744,7 +744,7 @@ function indent(str, size) {
|
|
|
744
744
|
*/
|
|
745
745
|
const styles = {
|
|
746
746
|
style: `i.${"st" /* Shortcuts.Style */}`,
|
|
747
|
-
class: `i.${"
|
|
747
|
+
class: `i.${"cl" /* Shortcuts.Class */}`
|
|
748
748
|
};
|
|
749
749
|
const events = {
|
|
750
750
|
bindtap: 'eh'
|
|
@@ -784,24 +784,24 @@ class BaseTemplate {
|
|
|
784
784
|
};
|
|
785
785
|
this.buildBaseComponentTemplate = (ext) => {
|
|
786
786
|
const data = !this.isSupportRecursive && this.isUseXS
|
|
787
|
-
? this.dataKeymap(`i:i,c:1,l:xs.f('',i.${"
|
|
787
|
+
? this.dataKeymap(`i:i,c:1,l:xs.f('',i.${"nn" /* Shortcuts.NodeName */})`)
|
|
788
788
|
: this.isSupportRecursive
|
|
789
789
|
? this.dataKeymap('i:i')
|
|
790
790
|
: this.dataKeymap('i:i,c:1');
|
|
791
791
|
// 此处需要重新引入 xs 函数,否则会出现 ws.f() 在 comp.wxml 和 custom-wrapper.wxml 中永远返回 undefined 的问题 #14599
|
|
792
792
|
return `<import src="./base${ext}" />
|
|
793
|
-
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + i.${"
|
|
793
|
+
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + i.${"nn" /* Shortcuts.NodeName */}}}" data="{{${data}}}" />`;
|
|
794
794
|
};
|
|
795
795
|
this.buildCustomComponentTemplate = (ext) => {
|
|
796
796
|
const Adapter = this.Adapter;
|
|
797
797
|
const data = !this.isSupportRecursive && this.isUseXS
|
|
798
|
-
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"
|
|
798
|
+
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"nn" /* Shortcuts.NodeName */})`)}`
|
|
799
799
|
: this.isSupportRecursive
|
|
800
800
|
? this.dataKeymap('i:item')
|
|
801
801
|
: this.dataKeymap('i:item,c:1');
|
|
802
802
|
// 此处需要重新引入 xs 函数,否则会出现 ws.f() 在 comp.wxml 和 custom-wrapper.wxml 中永远返回 undefined 的问题 #14599
|
|
803
803
|
return `<import src="./base${ext}" />
|
|
804
|
-
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"
|
|
804
|
+
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"nn" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${Adapter.for}="{{i.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"sid" /* Shortcuts.Sid */}" />
|
|
805
805
|
`;
|
|
806
806
|
};
|
|
807
807
|
this.buildXScript = () => {
|
|
@@ -810,7 +810,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
810
810
|
b: function (a, b) {
|
|
811
811
|
return a === undefined ? b : a
|
|
812
812
|
},
|
|
813
|
-
c: ${this.buildXSTepFocus("
|
|
813
|
+
c: ${this.buildXSTepFocus("nn" /* Shortcuts.NodeName */)},
|
|
814
814
|
e: function (n) {
|
|
815
815
|
return 'tmpl_' + n + '_${"container" /* Shortcuts.Container */}'
|
|
816
816
|
},
|
|
@@ -938,17 +938,17 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
938
938
|
buildBaseTemplate() {
|
|
939
939
|
const Adapter = this.Adapter;
|
|
940
940
|
const data = !this.isSupportRecursive && this.isUseXS
|
|
941
|
-
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"
|
|
941
|
+
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"nn" /* Shortcuts.NodeName */})`)}`
|
|
942
942
|
: this.isSupportRecursive
|
|
943
943
|
? this.dataKeymap('i:item')
|
|
944
944
|
: this.dataKeymap('i:item,c:1');
|
|
945
945
|
const xs = this.isUseXS
|
|
946
946
|
? (this.isSupportRecursive
|
|
947
|
-
? `xs.a(0, item.${"
|
|
948
|
-
: `xs.a(0, item.${"
|
|
949
|
-
: `'tmpl_0_' + item.${"
|
|
947
|
+
? `xs.a(0, item.${"nn" /* Shortcuts.NodeName */})`
|
|
948
|
+
: `xs.a(0, item.${"nn" /* Shortcuts.NodeName */}, '')`)
|
|
949
|
+
: `'tmpl_0_' + item.${"nn" /* Shortcuts.NodeName */}`;
|
|
950
950
|
return `${this.buildXsImportTemplate()}<template name="taro_tmpl">
|
|
951
|
-
<template is="{{${xs}}}" data="{{${data}}}" ${Adapter.for}="{{root.${"
|
|
951
|
+
<template is="{{${xs}}}" data="{{${data}}}" ${Adapter.for}="{{root.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"sid" /* Shortcuts.Sid */}" />
|
|
952
952
|
</template>
|
|
953
953
|
`;
|
|
954
954
|
}
|
|
@@ -975,7 +975,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
975
975
|
return str + ` bind${value}="eh"`;
|
|
976
976
|
}
|
|
977
977
|
else if (attr === 'class') {
|
|
978
|
-
return str + ` class="{{i.${"
|
|
978
|
+
return str + ` class="{{i.${"cl" /* Shortcuts.Class */}}}"`;
|
|
979
979
|
}
|
|
980
980
|
else if (attr === 'style') {
|
|
981
981
|
return str + ` style="{{i.${"st" /* Shortcuts.Style */}}}"`;
|
|
@@ -999,7 +999,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
999
999
|
const { isSupportRecursive, isUseXS, Adapter } = this;
|
|
1000
1000
|
const isLastRecursiveComp = !isSupportRecursive && level + 1 === this.baseLevel;
|
|
1001
1001
|
const isUnRecursiveXs = !this.isSupportRecursive && isUseXS;
|
|
1002
|
-
const forAttribute = `${Adapter.for}="{{i.${"
|
|
1002
|
+
const forAttribute = `${Adapter.for}="{{i.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"sid" /* Shortcuts.Sid */}"`;
|
|
1003
1003
|
if (isLastRecursiveComp) {
|
|
1004
1004
|
const data = isUnRecursiveXs
|
|
1005
1005
|
? `${this.dataKeymap('i:item,c:c,l:l')}`
|
|
@@ -1014,18 +1014,18 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1014
1014
|
const data = isUnRecursiveXs
|
|
1015
1015
|
// TODO: 此处直接 c+1,不是最优解,变量 c 的作用是监测组件嵌套的层级是否大于 baselevel
|
|
1016
1016
|
// 但目前的监测方法用于所有组件嵌套的总和,应该分开组件计算,单个组件嵌套层级大于 baselevel 时,再进入 comp 组件中进行新的嵌套
|
|
1017
|
-
? `${this.dataKeymap(`i:item,c:c+1,l:xs.f(l,item.${"
|
|
1017
|
+
? `${this.dataKeymap(`i:item,c:c+1,l:xs.f(l,item.${"nn" /* Shortcuts.NodeName */})`)}`
|
|
1018
1018
|
: this.isSupportRecursive
|
|
1019
1019
|
? `${this.dataKeymap('i:item')}`
|
|
1020
1020
|
: `${this.dataKeymap('i:item,c:c+1')}`;
|
|
1021
1021
|
const xs = !this.isSupportRecursive
|
|
1022
|
-
? `xs.a(c, item.${"
|
|
1023
|
-
: `xs.a(0, item.${"
|
|
1022
|
+
? `xs.a(c, item.${"nn" /* Shortcuts.NodeName */}, l)`
|
|
1023
|
+
: `xs.a(0, item.${"nn" /* Shortcuts.NodeName */})`;
|
|
1024
1024
|
return isUseXS
|
|
1025
1025
|
? `<template is="{{${xs}}}" data="{{${data}}}" ${forAttribute} />`
|
|
1026
1026
|
: isSupportRecursive
|
|
1027
|
-
? `<template is="{{'tmpl_0_' + item.${"
|
|
1028
|
-
: `<template is="{{'tmpl_' + c + '_' + item.${"
|
|
1027
|
+
? `<template is="{{'tmpl_0_' + item.${"nn" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${forAttribute} />`
|
|
1028
|
+
: `<template is="{{'tmpl_' + c + '_' + item.${"nn" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${forAttribute} />`;
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
1031
|
getChildren(comp, level) {
|
|
@@ -1060,11 +1060,11 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1060
1060
|
</template>
|
|
1061
1061
|
|
|
1062
1062
|
<template name="tmpl_${level}_${nodeAlias}_focus">
|
|
1063
|
-
<${nodeName} ${this.buildAttribute(comp.attributes, nodeName)} id="{{i.uid||i
|
|
1063
|
+
<${nodeName} ${this.buildAttribute(comp.attributes, nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
|
|
1064
1064
|
</template>
|
|
1065
1065
|
|
|
1066
1066
|
<template name="tmpl_${level}_${nodeAlias}_blur">
|
|
1067
|
-
<${nodeName} ${this.buildAttribute(attrs, nodeName)} id="{{i.uid||i
|
|
1067
|
+
<${nodeName} ${this.buildAttribute(attrs, nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
|
|
1068
1068
|
</template>
|
|
1069
1069
|
`;
|
|
1070
1070
|
if (isFunction(this.modifyTemplateResult)) {
|
|
@@ -1100,7 +1100,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1100
1100
|
}
|
|
1101
1101
|
let res = `
|
|
1102
1102
|
<template name="tmpl_${level}_${nodeAlias}">
|
|
1103
|
-
<${nodeName} ${this.buildAttribute(comp.attributes, comp.nodeName)} id="{{i.uid||i
|
|
1103
|
+
<${nodeName} ${this.buildAttribute(comp.attributes, comp.nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
|
|
1104
1104
|
</template>
|
|
1105
1105
|
`;
|
|
1106
1106
|
if (isFunction(this.modifyTemplateResult)) {
|
|
@@ -1123,7 +1123,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1123
1123
|
if (compName === 'custom-wrapper') {
|
|
1124
1124
|
template += `
|
|
1125
1125
|
<template name="tmpl_${level}_${compName}">
|
|
1126
|
-
<${compName} i="{{i}}" l="{{l}}" id="{{i.uid||i
|
|
1126
|
+
<${compName} i="{{i}}" l="{{l}}" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">
|
|
1127
1127
|
</${compName}>
|
|
1128
1128
|
</template>
|
|
1129
1129
|
`;
|
|
@@ -1142,7 +1142,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1142
1142
|
`;
|
|
1143
1143
|
template += `
|
|
1144
1144
|
<template name="tmpl_${level}_${compName}">
|
|
1145
|
-
<${compName} ${this.buildThirdPartyAttr(attrs, this.thirdPartyPatcher[compName] || {})} id="{{i.uid||i
|
|
1145
|
+
<${compName} ${this.buildThirdPartyAttr(attrs, this.thirdPartyPatcher[compName] || {})} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${compName}>
|
|
1146
1146
|
</template>
|
|
1147
1147
|
`;
|
|
1148
1148
|
}
|
|
@@ -1151,7 +1151,7 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1151
1151
|
}
|
|
1152
1152
|
// 最后一层的 comp 需要引用 container 进行重新的模版循环,其他情况不需要 container
|
|
1153
1153
|
buildContainerTemplate(level) {
|
|
1154
|
-
const tmpl = `<block ${this.Adapter.if}="{{i
|
|
1154
|
+
const tmpl = `<block ${this.Adapter.if}="{{i.nn === '${this.componentsAlias['#text']._num}'}}">
|
|
1155
1155
|
<template is="tmpl_0_${this.componentsAlias['#text']._num}" data="{{${this.dataKeymap('i:i')}}}" />
|
|
1156
1156
|
</block>
|
|
1157
1157
|
<block ${this.Adapter.else}>
|
|
@@ -1189,10 +1189,10 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcu
|
|
|
1189
1189
|
return 'tmpl_' + l + '_' + n
|
|
1190
1190
|
}`;
|
|
1191
1191
|
}
|
|
1192
|
-
buildXSTepFocus(
|
|
1192
|
+
buildXSTepFocus(nn) {
|
|
1193
1193
|
return `function(i, prefix) {
|
|
1194
1194
|
var s = i.focus !== undefined ? 'focus' : 'blur'
|
|
1195
|
-
return prefix + i.${
|
|
1195
|
+
return prefix + i.${nn} + '_' + s
|
|
1196
1196
|
}`;
|
|
1197
1197
|
}
|
|
1198
1198
|
buildXSTmpExtra() {
|