@tarojs/shared 3.5.0-beta.4 → 3.5.0-beta.7

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.
@@ -1,113 +1,112 @@
1
- /**
2
- * 这里我们需要关心的小程序种类有两类:
3
- * 1. 模板递归:
4
- * - 支持:tmpl0 套 tmpl0
5
- * - 不支持:这就使得我们必须生成多级的模板,tmpl0 套 tmpl1,tmpl1 套 tmpl2……
6
- * 直到超过阈值 N (N = config.miniapp.baseLevel) tmplN 会套组件 comp,组件 comp 重新再套 tmpl0。
7
- * 2. 小程序脚本语言(wxs, sjs, etc...):
8
- * - 支持:可以在模板使用函数缩减模板大小或提高性能(存疑),例如判断一个值是不是假值(falsy value)。
9
- * 将来或许会把数据序列化^1 的操作也放到小程序脚本语言里。
10
- * - 不支持:使用纯 *xml 语法
11
- *
12
- * ^1: packages/taro-runtime/src/hydrate.ts
13
- */
14
- import { internalComponents } from './components';
15
- import { Shortcuts } from './shortcuts';
16
- import { capitalize, toCamelCase } from './utils';
17
- interface Component {
18
- nodeName: string;
19
- nodeAlias: string;
20
- attributes: Attributes;
21
- }
22
- interface Components {
23
- [key: string]: Record<string, string>;
24
- }
25
- interface ComponentConfig {
26
- includes: Set<string>;
27
- exclude: Set<string>;
28
- thirdPartyComponents: Map<string, Set<string>>;
29
- includeAll: boolean;
30
- }
31
- export interface IAdapter {
32
- if: string;
33
- else: string;
34
- elseif: string;
35
- for: string;
36
- forItem: string;
37
- forIndex: string;
38
- key: string;
39
- xs?: string;
40
- type: string;
41
- }
42
- export declare type Attributes = Record<string, string>;
43
- export declare const styles: {
44
- style: string;
45
- class: string;
46
- };
47
- export declare const events: {
48
- bindtap: string;
49
- };
50
- export declare class BaseTemplate {
51
- protected exportExpr: string;
52
- protected isSupportRecursive: boolean;
53
- protected supportXS: boolean;
54
- protected miniComponents: Components;
55
- protected thirdPartyPatcher: Record<string, Record<string, string>>;
56
- protected componentsAlias: any;
57
- protected modifyCompProps?: (compName: string, target: Record<string, string>) => Record<string, string>;
58
- protected modifyLoopBody?: (child: string, nodeName: string) => string;
59
- protected modifyLoopContainer?: (children: string, nodeName: string) => string;
60
- protected modifyTemplateResult?: (res: string, nodeName: string, level: number, children: string) => string;
61
- protected modifyThirdPartyLoopBody?: (child: string, nodeName: string) => string;
62
- Adapter: IAdapter;
63
- /** 组件列表 */
64
- internalComponents: Record<string, Record<string, string>>;
65
- /** 可以 focus 聚焦的组件 */
66
- focusComponents: Set<string>;
67
- /** 不需要渲染子节点的元素 */
68
- voidElements: Set<string>;
69
- /** 可以递归调用自身的组件 */
70
- nestElements: Map<string, number>;
71
- private buildAttribute;
72
- protected replacePropName(name: string, value: string, _componentName?: string, _componentAlias?: any): string;
73
- protected createMiniComponents(components: Components): Components;
74
- protected buildBaseTemplate(): string;
75
- protected buildThirdPartyAttr(attrs: Set<string>, patcher?: Record<string, string>): string;
76
- protected buildComponentTemplate(comp: Component, level: number): string;
77
- private getChildren;
78
- protected buildFocusComponentTemplte(comp: Component, level: number): string;
79
- protected buildStandardComponentTemplate(comp: Component, level: number): string;
80
- protected buildPlainTextTemplate(level: number): string;
81
- protected buildThirdPartyTemplate(level: number, componentConfig: ComponentConfig): string;
82
- protected buildContainerTemplate(level: number, restart?: boolean): string;
83
- protected dataKeymap(keymap: string): string;
84
- protected getEvents(): any;
85
- protected getAttrValue(value: string, _key: string, _nodeName: string): string;
86
- protected buildXsTemplate(): string;
87
- buildPageTemplate: (baseTempPath: string) => string;
88
- buildBaseComponentTemplate: (ext: string) => string;
89
- buildCustomComponentTemplate: (ext: string) => string;
90
- buildXScript: () => string;
91
- mergeComponents(ctx: any, patch: Record<string, Record<string, string>>): void;
92
- mergeThirdPartyComponents(patch: Record<string, Record<string, string>>): void;
93
- protected buildXSTmplName(): string;
94
- protected buildXSTepFocus(nn: string): string;
95
- protected buildXSTmpExtra(): string;
96
- }
97
- export declare class RecursiveTemplate extends BaseTemplate {
98
- isSupportRecursive: boolean;
99
- buildTemplate: (componentConfig: ComponentConfig) => string;
100
- }
101
- export declare class UnRecursiveTemplate extends BaseTemplate {
102
- isSupportRecursive: boolean;
103
- private _baseLevel;
104
- private componentConfig;
105
- set baseLevel(lv: number);
106
- get baseLevel(): number;
107
- buildTemplate: (componentConfig: ComponentConfig) => string;
108
- protected buildFloor(level: number, components: string[], restart?: boolean): string;
109
- protected buildOptimizeFloor(level: number, components: string[], restart?: boolean): string;
110
- protected buildXSTmplName(): string;
111
- protected buildXSTmpExtra(): string;
112
- }
113
- export { capitalize, internalComponents, Shortcuts, toCamelCase };
1
+ declare const internalComponents: Record<string, Record<string, string>>;
2
+ // 字符串简写
3
+ declare const enum Shortcuts {
4
+ Container = "container",
5
+ Childnodes = "cn",
6
+ Text = "v",
7
+ NodeType = "nt",
8
+ NodeName = "nn",
9
+ // Attrtibutes
10
+ Style = "st",
11
+ Class = "cl",
12
+ Src = "src"
13
+ }
14
+ declare function toCamelCase(s: string): string;
15
+ declare function capitalize(s: string): string;
16
+ interface Component {
17
+ nodeName: string;
18
+ nodeAlias: string;
19
+ attributes: Attributes;
20
+ }
21
+ interface Components {
22
+ [key: string]: Record<string, string>;
23
+ }
24
+ interface ComponentConfig {
25
+ includes: Set<string>;
26
+ exclude: Set<string>;
27
+ thirdPartyComponents: Map<string, Set<string>>;
28
+ includeAll: boolean;
29
+ }
30
+ interface IAdapter {
31
+ if: string;
32
+ else: string;
33
+ elseif: string;
34
+ for: string;
35
+ forItem: string;
36
+ forIndex: string;
37
+ key: string;
38
+ xs?: string;
39
+ type: string;
40
+ }
41
+ type Attributes = Record<string, string>;
42
+ declare const styles: {
43
+ style: string;
44
+ class: string;
45
+ };
46
+ declare const events: {
47
+ bindtap: string;
48
+ };
49
+ declare class BaseTemplate {
50
+ protected exportExpr: string;
51
+ protected isSupportRecursive: boolean;
52
+ protected supportXS: boolean;
53
+ protected miniComponents: Components;
54
+ protected thirdPartyPatcher: Record<string, Record<string, string>>;
55
+ protected componentsAlias: any;
56
+ protected modifyCompProps?: (compName: string, target: Record<string, string>) => Record<string, string>;
57
+ protected modifyLoopBody?: (child: string, nodeName: string) => string;
58
+ protected modifyLoopContainer?: (children: string, nodeName: string) => string;
59
+ protected modifyTemplateResult?: (res: string, nodeName: string, level: number, children: string) => string;
60
+ protected modifyThirdPartyLoopBody?: (child: string, nodeName: string) => string;
61
+ Adapter: IAdapter;
62
+ /** 组件列表 */
63
+ internalComponents: Record<string, Record<string, string>>;
64
+ /** 可以 focus 聚焦的组件 */
65
+ focusComponents: Set<string>;
66
+ /** 不需要渲染子节点的元素 */
67
+ voidElements: Set<string>;
68
+ /** 可以递归调用自身的组件 */
69
+ nestElements: Map<string, number>;
70
+ private buildAttribute;
71
+ protected replacePropName(name: string, value: string, _componentName?: string, _componentAlias?: any): string;
72
+ protected createMiniComponents(components: Components): Components;
73
+ protected buildBaseTemplate(): string;
74
+ protected buildThirdPartyAttr(attrs: Set<string>, patcher?: Record<string, string>): string;
75
+ protected buildComponentTemplate(comp: Component, level: number): string;
76
+ private getChildren;
77
+ protected buildFocusComponentTemplte(comp: Component, level: number): string;
78
+ protected buildStandardComponentTemplate(comp: Component, level: number): string;
79
+ protected buildPlainTextTemplate(level: number): string;
80
+ protected buildThirdPartyTemplate(level: number, componentConfig: ComponentConfig): string;
81
+ protected buildContainerTemplate(level: number, restart?: boolean): string;
82
+ protected dataKeymap(keymap: string): string;
83
+ protected getEvents(): any;
84
+ protected getAttrValue(value: string, _key: string, _nodeName: string): string;
85
+ protected buildXsTemplate(): string;
86
+ buildPageTemplate: (baseTempPath: string) => string;
87
+ buildBaseComponentTemplate: (ext: string) => string;
88
+ buildCustomComponentTemplate: (ext: string) => string;
89
+ buildXScript: () => string;
90
+ mergeComponents(ctx: any, patch: Record<string, Record<string, string>>): void;
91
+ mergeThirdPartyComponents(patch: Record<string, Record<string, string>>): void;
92
+ protected buildXSTmplName(): string;
93
+ protected buildXSTepFocus(nn: string): string;
94
+ protected buildXSTmpExtra(): string;
95
+ }
96
+ declare class RecursiveTemplate extends BaseTemplate {
97
+ isSupportRecursive: boolean;
98
+ buildTemplate: (componentConfig: ComponentConfig) => string;
99
+ }
100
+ declare class UnRecursiveTemplate extends BaseTemplate {
101
+ isSupportRecursive: boolean;
102
+ private _baseLevel;
103
+ private componentConfig;
104
+ set baseLevel(lv: number);
105
+ get baseLevel(): number;
106
+ buildTemplate: (componentConfig: ComponentConfig) => string;
107
+ protected buildFloor(level: number, components: string[], restart?: boolean): string;
108
+ protected buildOptimizeFloor(level: number, components: string[], restart?: boolean): string;
109
+ protected buildXSTmplName(): string;
110
+ protected buildXSTmpExtra(): string;
111
+ }
112
+ export { IAdapter, Attributes, styles, events, BaseTemplate, RecursiveTemplate, UnRecursiveTemplate, capitalize, internalComponents, Shortcuts, toCamelCase };