@tarojs/shared 4.2.2-alpha.2 → 4.2.2-alpha.3
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/event-emitter.js +13 -2
- package/dist/event-emitter.js.map +1 -1
- package/dist/index.cjs.js +17 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/native-apis.js +4 -0
- package/dist/native-apis.js.map +1 -1
- package/dist/shared.esm.js +17 -2
- package/dist/shared.esm.js.map +1 -1
- package/dist/template.d.ts +3 -1
- package/dist/template.js +19 -3
- package/dist/template.js.map +1 -1
- package/package.json +1 -1
package/dist/template.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ interface ComponentConfig {
|
|
|
27
27
|
exclude: Set<string>;
|
|
28
28
|
thirdPartyComponents: Map<string, Set<string>>;
|
|
29
29
|
includeAll: boolean;
|
|
30
|
+
/** 当为 true 时,跳过最后一层 container template 中对 <comp> 的引用,超出 baseLevel 的节点将被静默截断 */
|
|
31
|
+
skipRecursiveComponent?: boolean;
|
|
30
32
|
}
|
|
31
33
|
export interface IAdapter {
|
|
32
34
|
if: string;
|
|
@@ -54,6 +56,7 @@ export declare class BaseTemplate {
|
|
|
54
56
|
protected exportExpr: string;
|
|
55
57
|
protected isSupportRecursive: boolean;
|
|
56
58
|
protected miniComponents: Components;
|
|
59
|
+
protected componentConfig: ComponentConfig | undefined;
|
|
57
60
|
protected thirdPartyPatcher: Record<string, Record<string, string>>;
|
|
58
61
|
protected modifyCompProps?: (compName: string, target: Record<string, string>) => Record<string, string>;
|
|
59
62
|
protected modifyLoopBody?: (child: string, nodeName: string) => string;
|
|
@@ -117,7 +120,6 @@ export declare class RecursiveTemplate extends BaseTemplate {
|
|
|
117
120
|
export declare class UnRecursiveTemplate extends BaseTemplate {
|
|
118
121
|
isSupportRecursive: boolean;
|
|
119
122
|
protected _baseLevel: number;
|
|
120
|
-
private componentConfig;
|
|
121
123
|
buildTemplate: (componentConfig: ComponentConfig) => string;
|
|
122
124
|
protected buildFloor(level: number, components: string[], restart?: boolean): string;
|
|
123
125
|
protected buildOptimizeFloor(level: number, components: string[], restart?: boolean): string;
|
package/dist/template.js
CHANGED
|
@@ -422,9 +422,20 @@ class Events {
|
|
|
422
422
|
return this;
|
|
423
423
|
}
|
|
424
424
|
once(events, callback, context) {
|
|
425
|
+
let fired = false;
|
|
425
426
|
const wrapper = (...args) => {
|
|
426
|
-
|
|
427
|
-
|
|
427
|
+
// Note: 监听器内再次 trigger 同一事件时,wrapper 会在 off 之前被重入,
|
|
428
|
+
// 因此用 fired 标记保证回调只执行一次;回调报错时也需要解绑。
|
|
429
|
+
if (fired) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
fired = true;
|
|
433
|
+
try {
|
|
434
|
+
callback.apply(this, args);
|
|
435
|
+
}
|
|
436
|
+
finally {
|
|
437
|
+
this.off(events, wrapper, context);
|
|
438
|
+
}
|
|
428
439
|
};
|
|
429
440
|
this.on(events, wrapper, context);
|
|
430
441
|
return this;
|
|
@@ -1196,11 +1207,16 @@ ${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"nn" /* Shortc
|
|
|
1196
1207
|
}
|
|
1197
1208
|
// 最后一层的 comp 需要引用 container 进行重新的模版循环,其他情况不需要 container
|
|
1198
1209
|
buildContainerTemplate(level) {
|
|
1210
|
+
var _a;
|
|
1211
|
+
const skipRecursive = (_a = this.componentConfig) === null || _a === void 0 ? void 0 : _a.skipRecursiveComponent;
|
|
1212
|
+
const compTag = skipRecursive
|
|
1213
|
+
? '<!-- nodes beyond baseLevel are truncated -->'
|
|
1214
|
+
: (!this.isSupportRecursive && this.isUseXS ? '<comp i="{{i}}" l="{{l}}" />' : '<comp i="{{i}}" />');
|
|
1199
1215
|
const tmpl = `<block ${this.Adapter.if}="{{i.nn === '${this.componentsAlias['#text']._num}'}}">
|
|
1200
1216
|
<template is="tmpl_0_${this.componentsAlias['#text']._num}" data="{{${this.dataKeymap('i:i')}}}" />
|
|
1201
1217
|
</block>
|
|
1202
1218
|
<block ${this.Adapter.else}>
|
|
1203
|
-
${
|
|
1219
|
+
${compTag}
|
|
1204
1220
|
</block>`;
|
|
1205
1221
|
return `
|
|
1206
1222
|
<template name="tmpl_${level}_${"container" /* Shortcuts.Container */}">
|