glass-easel 0.2.0 → 0.3.0
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/.eslintignore +4 -0
- package/dist/glass_easel.all.js +2 -2
- package/dist/glass_easel.all.js.map +1 -1
- package/dist/glass_easel.d.ts +2546 -0
- package/dist/glass_easel.domlike.global.js +2 -2
- package/dist/glass_easel.domlike.global.js.map +1 -1
- package/guide/zh_CN/appendix/backend_protocol.md +164 -74
- package/jest.unit.config.js +7 -4
- package/package.json +7 -5
- package/rollup.config.ts +101 -0
- package/src/backend/backend_protocol.ts +26 -345
- package/src/backend/composed_backend_protocol.ts +10 -264
- package/src/backend/current_window_backend_context.ts +478 -0
- package/src/backend/domlike_backend_protocol.ts +9 -498
- package/src/backend/empty_backend.ts +265 -0
- package/src/backend/empty_composed_backend.ts +245 -0
- package/src/backend/index.ts +18 -0
- package/src/backend/suggested_backend_protocol.ts +62 -11
- package/src/behavior.ts +131 -442
- package/src/class_list.ts +328 -222
- package/src/component.ts +349 -184
- package/src/component_params.ts +54 -25
- package/src/component_space.ts +36 -15
- package/src/data_path.ts +22 -34
- package/src/data_proxy.ts +334 -27
- package/src/devtool.ts +89 -0
- package/src/element.ts +667 -285
- package/src/element_iterator.ts +9 -4
- package/src/event.ts +39 -20
- package/src/external_shadow_tree.ts +2 -2
- package/src/func_arr.ts +55 -101
- package/src/global_options.ts +18 -42
- package/src/index.ts +72 -73
- package/src/mutation_observer.ts +10 -7
- package/src/native_node.ts +79 -35
- package/src/node.ts +23 -30
- package/src/relation.ts +101 -12
- package/src/render.ts +5 -3
- package/src/selector.ts +9 -7
- package/src/shadow_root.ts +96 -240
- package/src/template_engine.ts +10 -7
- package/src/text_node.ts +43 -19
- package/src/tmpl/index.ts +38 -30
- package/src/tmpl/native_rendering.ts +14 -21
- package/src/tmpl/proc_gen_wrapper.ts +189 -151
- package/src/tmpl/proc_gen_wrapper_dom.ts +10 -8
- package/src/tmpl/range_list_diff.ts +30 -9
- package/src/trait_behaviors.ts +1 -1
- package/src/type_symbol.ts +36 -0
- package/src/virtual_node.ts +26 -13
- package/src/warning.ts +119 -0
- package/tests/base/composed_backend.ts +143 -142
- package/tests/base/env.ts +76 -3
- package/tests/base/match.ts +24 -22
- package/tests/base/shadow_backend.ts +917 -0
- package/tests/core/backend.test.ts +53 -1
- package/tests/core/behavior.test.ts +1 -1
- package/tests/core/data_update.test.ts +135 -0
- package/tests/core/misc.test.ts +91 -21
- package/tests/core/placeholder.test.ts +66 -25
- package/tests/core/slot.test.ts +161 -23
- package/tests/legacy/component.test.js +152 -78
- package/tests/legacy/data_path.test.js +19 -19
- package/tests/legacy/data_proxy.test.js +14 -7
- package/tests/legacy/external.test.js +8 -8
- package/tests/legacy/mutation_observer.test.js +7 -5
- package/tests/legacy/slot.test.js +2 -3
- package/tests/legacy/virtual.test.js +258 -25
- package/tests/tmpl/binding_map.test.ts +201 -195
- package/tests/tmpl/event.test.ts +138 -23
- package/tests/tmpl/expression.test.ts +15 -15
- package/tests/tmpl/lvalue.test.ts +101 -0
- package/tests/tmpl/structure.test.ts +486 -43
- package/tests/types/chaining.test.ts +27 -30
- package/tests/types/createElement.test.ts +5 -4
- package/tests/types/definition.test.ts +11 -14
- package/tsconfig.json +1 -3
- package/dist/glass_easel.all.d.ts +0 -1
- package/dist/glass_easel.domlike.global.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/types/src/backend/backend_protocol.d.ts +0 -141
- package/dist/types/src/backend/backend_protocol.d.ts.map +0 -1
- package/dist/types/src/backend/composed_backend_protocol.d.ts +0 -102
- package/dist/types/src/backend/composed_backend_protocol.d.ts.map +0 -1
- package/dist/types/src/backend/domlike_backend_protocol.d.ts +0 -100
- package/dist/types/src/backend/domlike_backend_protocol.d.ts.map +0 -1
- package/dist/types/src/backend/mode.d.ts +0 -65
- package/dist/types/src/backend/mode.d.ts.map +0 -1
- package/dist/types/src/backend/suggested_backend_protocol.d.ts +0 -30
- package/dist/types/src/backend/suggested_backend_protocol.d.ts.map +0 -1
- package/dist/types/src/behavior.d.ts +0 -434
- package/dist/types/src/behavior.d.ts.map +0 -1
- package/dist/types/src/class_list.d.ts +0 -83
- package/dist/types/src/class_list.d.ts.map +0 -1
- package/dist/types/src/component.d.ts +0 -325
- package/dist/types/src/component.d.ts.map +0 -1
- package/dist/types/src/component_params.d.ts +0 -236
- package/dist/types/src/component_params.d.ts.map +0 -1
- package/dist/types/src/component_space.d.ts +0 -211
- package/dist/types/src/component_space.d.ts.map +0 -1
- package/dist/types/src/data_path.d.ts +0 -5
- package/dist/types/src/data_path.d.ts.map +0 -1
- package/dist/types/src/data_proxy.d.ts +0 -107
- package/dist/types/src/data_proxy.d.ts.map +0 -1
- package/dist/types/src/data_utils.d.ts +0 -3
- package/dist/types/src/data_utils.d.ts.map +0 -1
- package/dist/types/src/element.d.ts +0 -365
- package/dist/types/src/element.d.ts.map +0 -1
- package/dist/types/src/element_iterator.d.ts +0 -43
- package/dist/types/src/element_iterator.d.ts.map +0 -1
- package/dist/types/src/event.d.ts +0 -105
- package/dist/types/src/event.d.ts.map +0 -1
- package/dist/types/src/external_shadow_tree.d.ts +0 -20
- package/dist/types/src/external_shadow_tree.d.ts.map +0 -1
- package/dist/types/src/func_arr.d.ts +0 -39
- package/dist/types/src/func_arr.d.ts.map +0 -1
- package/dist/types/src/global_options.d.ts +0 -120
- package/dist/types/src/global_options.d.ts.map +0 -1
- package/dist/types/src/index.d.ts +0 -43
- package/dist/types/src/index.d.ts.map +0 -1
- package/dist/types/src/mutation_observer.d.ts +0 -79
- package/dist/types/src/mutation_observer.d.ts.map +0 -1
- package/dist/types/src/native_node.d.ts +0 -11
- package/dist/types/src/native_node.d.ts.map +0 -1
- package/dist/types/src/node.d.ts +0 -48
- package/dist/types/src/node.d.ts.map +0 -1
- package/dist/types/src/relation.d.ts +0 -46
- package/dist/types/src/relation.d.ts.map +0 -1
- package/dist/types/src/render.d.ts +0 -3
- package/dist/types/src/render.d.ts.map +0 -1
- package/dist/types/src/selector.d.ts +0 -32
- package/dist/types/src/selector.d.ts.map +0 -1
- package/dist/types/src/shadow_root.d.ts +0 -174
- package/dist/types/src/shadow_root.d.ts.map +0 -1
- package/dist/types/src/template_engine.d.ts +0 -56
- package/dist/types/src/template_engine.d.ts.map +0 -1
- package/dist/types/src/text_node.d.ts +0 -44
- package/dist/types/src/text_node.d.ts.map +0 -1
- package/dist/types/src/tmpl/index.d.ts +0 -19
- package/dist/types/src/tmpl/index.d.ts.map +0 -1
- package/dist/types/src/tmpl/native_rendering.d.ts +0 -45
- package/dist/types/src/tmpl/native_rendering.d.ts.map +0 -1
- package/dist/types/src/tmpl/proc_gen_wrapper.d.ts +0 -89
- package/dist/types/src/tmpl/proc_gen_wrapper.d.ts.map +0 -1
- package/dist/types/src/tmpl/proc_gen_wrapper_dom.d.ts +0 -50
- package/dist/types/src/tmpl/proc_gen_wrapper_dom.d.ts.map +0 -1
- package/dist/types/src/tmpl/range_list_diff.d.ts +0 -19
- package/dist/types/src/tmpl/range_list_diff.d.ts.map +0 -1
- package/dist/types/src/trait_behaviors.d.ts +0 -38
- package/dist/types/src/trait_behaviors.d.ts.map +0 -1
- package/dist/types/src/virtual_node.d.ts +0 -10
- package/dist/types/src/virtual_node.d.ts.map +0 -1
- package/dist/types/tests/backend/domlike.test.d.ts +0 -2
- package/dist/types/tests/backend/domlike.test.d.ts.map +0 -1
- package/dist/types/tests/base/composed_backend.d.ts +0 -123
- package/dist/types/tests/base/composed_backend.d.ts.map +0 -1
- package/dist/types/tests/base/env.d.ts +0 -30
- package/dist/types/tests/base/env.d.ts.map +0 -1
- package/dist/types/tests/base/match.d.ts +0 -9
- package/dist/types/tests/base/match.d.ts.map +0 -1
- package/dist/types/tests/core/backend.test.d.ts +0 -2
- package/dist/types/tests/core/backend.test.d.ts.map +0 -1
- package/dist/types/tests/core/behavior.test.d.ts +0 -2
- package/dist/types/tests/core/behavior.test.d.ts.map +0 -1
- package/dist/types/tests/core/component_space.test.d.ts +0 -2
- package/dist/types/tests/core/component_space.test.d.ts.map +0 -1
- package/dist/types/tests/core/data_update.test.d.ts +0 -2
- package/dist/types/tests/core/data_update.test.d.ts.map +0 -1
- package/dist/types/tests/core/misc.test.d.ts +0 -2
- package/dist/types/tests/core/misc.test.d.ts.map +0 -1
- package/dist/types/tests/core/placeholder.test.d.ts +0 -2
- package/dist/types/tests/core/placeholder.test.d.ts.map +0 -1
- package/dist/types/tests/core/slot.test.d.ts +0 -2
- package/dist/types/tests/core/slot.test.d.ts.map +0 -1
- package/dist/types/tests/core/trait_behaviors.test.d.ts +0 -2
- package/dist/types/tests/core/trait_behaviors.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/binding_map.test.d.ts +0 -2
- package/dist/types/tests/tmpl/binding_map.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/event.test.d.ts +0 -2
- package/dist/types/tests/tmpl/event.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/expression.test.d.ts +0 -2
- package/dist/types/tests/tmpl/expression.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/lvalue.test.d.ts +0 -2
- package/dist/types/tests/tmpl/lvalue.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/native_rendering.test.d.ts +0 -2
- package/dist/types/tests/tmpl/native_rendering.test.d.ts.map +0 -1
- package/dist/types/tests/tmpl/structure.test.d.ts +0 -2
- package/dist/types/tests/tmpl/structure.test.d.ts.map +0 -1
- package/dist/types/tests/types/chaining.test.d.ts +0 -2
- package/dist/types/tests/types/chaining.test.d.ts.map +0 -1
- package/dist/types/tests/types/createElement.test.d.ts +0 -2
- package/dist/types/tests/types/createElement.test.d.ts.map +0 -1
- package/dist/types/tests/types/definition.test.d.ts +0 -2
- package/dist/types/tests/types/definition.test.d.ts.map +0 -1
- package/webpack.config.js +0 -275
- /package/src/backend/{mode.ts → shared.ts} +0 -0
|
@@ -0,0 +1,2546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The style scope identifier
|
|
3
|
+
*
|
|
4
|
+
* It is actually a non-negative integer.
|
|
5
|
+
*
|
|
6
|
+
* Specifically, `0` represents *global* scope, which means it is a global style in stylesheets.
|
|
7
|
+
* However, in elements, `0` means it does not match any stylesheets other than the global styles.
|
|
8
|
+
*/
|
|
9
|
+
type StyleScopeId = number;
|
|
10
|
+
/**
|
|
11
|
+
* Style scope manager
|
|
12
|
+
*/
|
|
13
|
+
declare class StyleScopeManager {
|
|
14
|
+
static globalScope(): StyleScopeId;
|
|
15
|
+
register(name: string): StyleScopeId;
|
|
16
|
+
queryName(id: StyleScopeId): string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Class manager for non-virtual `Element`
|
|
20
|
+
*/
|
|
21
|
+
declare class ClassList {
|
|
22
|
+
constructor(element: Element$4, externalNames: string[] | undefined, owner: ClassList | null, styleScope: number, extraStyleScope: number | undefined, styleScopeManager: StyleScopeManager | undefined);
|
|
23
|
+
toggle(name: string, force?: boolean, segmentIndex?: StyleSegmentIndex): boolean;
|
|
24
|
+
contains(name: string, segmentIndex?: StyleSegmentIndex): boolean;
|
|
25
|
+
/** Set class string */
|
|
26
|
+
setClassNames(names: string | string[], segmentIndex?: StyleSegmentIndex): boolean;
|
|
27
|
+
/** Returns space separated class string */
|
|
28
|
+
getClassNames(segmentIndex?: StyleSegmentIndex): string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type DataPath = Array<string | number>;
|
|
32
|
+
type MultiPaths = DataPath[];
|
|
33
|
+
declare const parseSinglePath: (str: string) => DataPath;
|
|
34
|
+
declare const parseMultiPaths: (str: string | readonly string[]) => MultiPaths;
|
|
35
|
+
|
|
36
|
+
type data_path_DataPath = DataPath;
|
|
37
|
+
type data_path_MultiPaths = MultiPaths;
|
|
38
|
+
declare const data_path_parseMultiPaths: typeof parseMultiPaths;
|
|
39
|
+
declare const data_path_parseSinglePath: typeof parseSinglePath;
|
|
40
|
+
declare namespace data_path {
|
|
41
|
+
export { type data_path_DataPath as DataPath, type data_path_MultiPaths as MultiPaths, data_path_parseMultiPaths as parseMultiPaths, data_path_parseSinglePath as parseSinglePath };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Interface that can be implement dynamically
|
|
46
|
+
*
|
|
47
|
+
* A `TraitBehavior` is like a TypeScript interface, but can be implemented dynamically.
|
|
48
|
+
* It requires the implementors to implement `TIn` .
|
|
49
|
+
* Also, it can provide do a transform from `TIn` to `TOut` as common logic of the trait.
|
|
50
|
+
*/
|
|
51
|
+
declare class TraitBehavior<TIn extends {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}, TOut extends {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
} = TIn> {
|
|
56
|
+
ownerSpace: ComponentSpace;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A group of components for cross-component using */
|
|
60
|
+
declare class ComponentSpace {
|
|
61
|
+
styleScopeManager: StyleScopeManager;
|
|
62
|
+
/**
|
|
63
|
+
* Create a new component space
|
|
64
|
+
*
|
|
65
|
+
* The `defaultComponent` is the default component path.
|
|
66
|
+
* It should be defined soon after creation.
|
|
67
|
+
* A `baseSpace` can be provided as a "base" component space -
|
|
68
|
+
* every component alias (and behavior alias) in the space will be imported when creation.
|
|
69
|
+
* However, if any new component is added to the base space after the creation,
|
|
70
|
+
* it will not be added to the created space.
|
|
71
|
+
*/
|
|
72
|
+
constructor(defaultComponent?: string, baseSpace?: ComponentSpace, styleScopeManager?: StyleScopeManager, allowUnusedNativeNode?: boolean);
|
|
73
|
+
/**
|
|
74
|
+
* Update the default component options for this space
|
|
75
|
+
*
|
|
76
|
+
* The new options will be merged with existing options.
|
|
77
|
+
*/
|
|
78
|
+
updateComponentOptions(componentOptions: ComponentOptions): void;
|
|
79
|
+
getComponentOptions(): NormalizedComponentOptions;
|
|
80
|
+
/**
|
|
81
|
+
* Set (or update) a global using component item
|
|
82
|
+
*
|
|
83
|
+
* This will allow all the components in this component space using this component automatically,
|
|
84
|
+
* without declaring it with `using` or `usingComponents` again.
|
|
85
|
+
* The target can also be a tag name of a native node.
|
|
86
|
+
*/
|
|
87
|
+
setGlobalUsingComponent(key: string, target: GeneralComponentDefinition | string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Import another component space
|
|
90
|
+
*
|
|
91
|
+
* The components in the imported space can be used by components in this space.
|
|
92
|
+
* The `protoDomain` should be URL-like, i.e. `space://another-space` .
|
|
93
|
+
* When using, the components in the imported space should be specified with `protoDomain` .
|
|
94
|
+
* For example, if `protoDomain` is `space://another-space` and one imported component has alias `my-comp` ,
|
|
95
|
+
* then it should be specified with `space://another-space/my-comp` .
|
|
96
|
+
* If `privateUse` set to false, only component alias in the imported space can be used;
|
|
97
|
+
* the original name of components is imported otherwise.
|
|
98
|
+
*/
|
|
99
|
+
importSpace(protoDomain: string, space: ComponentSpace, privateUse: boolean): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get a component by the `path`
|
|
102
|
+
*
|
|
103
|
+
* The component `is` is actually treated as the "path" of the component.
|
|
104
|
+
* In other words, the component `is` field can be a string like `path/to/the/component` .
|
|
105
|
+
* Other components can be used by the component with "relative path" specified.
|
|
106
|
+
* In this method, if the `path` is given as a relative path (not started with `/` ),
|
|
107
|
+
* it will be converted according to the `basePath` .
|
|
108
|
+
* If the `path` is given as a URL-like format,
|
|
109
|
+
* the component will be searched in imported component spaces ( `importSpace()` for details).
|
|
110
|
+
*/
|
|
111
|
+
getComponentByUrl(path: string, basePath: string): GeneralComponentDefinition;
|
|
112
|
+
/**
|
|
113
|
+
* Get a component by the `path`
|
|
114
|
+
*
|
|
115
|
+
* Similar to `getComponentByUrl()` ,
|
|
116
|
+
* but returns `null` instead of the default component if no component was found.
|
|
117
|
+
*/
|
|
118
|
+
getComponentByUrlWithoutDefault(path: string, relPath: string): GeneralComponentDefinition | null;
|
|
119
|
+
private getComponent;
|
|
120
|
+
getDefaultComponent(): GeneralComponentDefinition | null;
|
|
121
|
+
isDefaultComponent(def: GeneralComponentDefinition): boolean;
|
|
122
|
+
getGlobalUsingComponent(key: string): GeneralComponentDefinition | NativeNodeDefinition | null;
|
|
123
|
+
/**
|
|
124
|
+
* Get a behavior by the `path`
|
|
125
|
+
*
|
|
126
|
+
* Similar to `getComponentByUrlWithoutDefault()` but for behaviors.
|
|
127
|
+
*/
|
|
128
|
+
getBehaviorByUrl(path: string, relPath: string): GeneralBehavior | null;
|
|
129
|
+
/** Register a component in this space */
|
|
130
|
+
defineComponent<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>): ComponentDefinition<TData, TProperty, TMethod>;
|
|
131
|
+
/** Register a behavior in this space */
|
|
132
|
+
defineBehavior<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>): Behavior<TData, TProperty, TMethod, never>;
|
|
133
|
+
/** Register a component or a behavior with chaining API */
|
|
134
|
+
define(is?: string): BehaviorBuilder;
|
|
135
|
+
/**
|
|
136
|
+
* Register a component or a behavior with chaining API (with method caller type specified)
|
|
137
|
+
*
|
|
138
|
+
* This API is generally designed for adapters which require special method callers.
|
|
139
|
+
*/
|
|
140
|
+
defineWithMethodCaller(is?: string): BehaviorBuilder<Empty, Empty, Empty, Empty, never, never>;
|
|
141
|
+
/**
|
|
142
|
+
* Start a series of components and behaviors registration
|
|
143
|
+
*
|
|
144
|
+
* In most cases, `groupRegister` is prefered.
|
|
145
|
+
*/
|
|
146
|
+
startGroupRegister(): void;
|
|
147
|
+
/**
|
|
148
|
+
* End a series of components and behaviors registration
|
|
149
|
+
*
|
|
150
|
+
* In most cases, `groupRegister` is prefered.
|
|
151
|
+
*/
|
|
152
|
+
endGroupRegister(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Group a series of components and behaviors registration
|
|
155
|
+
*
|
|
156
|
+
* If any placeholder should be replaced,
|
|
157
|
+
* the replacement will happen after the whole series of registration.
|
|
158
|
+
*/
|
|
159
|
+
groupRegister<R>(cb: () => R): R | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Assign a public alias to a component
|
|
162
|
+
*
|
|
163
|
+
* The alias can be used in other component spaces which imported this component space.
|
|
164
|
+
* One component may have multiple aliases.
|
|
165
|
+
*/
|
|
166
|
+
exportComponent(alias: string, is: string): void;
|
|
167
|
+
/** Get a component by its exported alias */
|
|
168
|
+
getExportedComponent(alias: string): GeneralComponentDefinition | undefined;
|
|
169
|
+
/** Get a behavior by its exported alias */
|
|
170
|
+
getExportedBehavior(alias: string): GeneralBehavior | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Assign a public alias to a behavior
|
|
173
|
+
*
|
|
174
|
+
* The alias can be used in other component spaces which imported this component space.
|
|
175
|
+
* One behavior may have multiple aliases.
|
|
176
|
+
*/
|
|
177
|
+
exportBehavior(alias: string, is: string): void;
|
|
178
|
+
/**
|
|
179
|
+
* Set a listener which will be called when a placeholded component is used.
|
|
180
|
+
*
|
|
181
|
+
* This can be used as a hint for a component that should be registered later.
|
|
182
|
+
* If `isPub` is false, the `alias` is the path of the component, a.k.a. `is` .
|
|
183
|
+
* Otherwise, it is the exported `alias` instead.
|
|
184
|
+
*/
|
|
185
|
+
setComponentWaitingListener(listener: ((isPub: boolean, alias: string, owner: GeneralComponent) => void) | null): void;
|
|
186
|
+
/**
|
|
187
|
+
* Create a component by URL
|
|
188
|
+
*
|
|
189
|
+
* This `url` can contain params (started with "?" character).
|
|
190
|
+
* The params will try to be set to component properties (if matches the property name).
|
|
191
|
+
*/
|
|
192
|
+
createComponentByUrl(tagName: string, url: string, genericTargets: {
|
|
193
|
+
[name: string]: string;
|
|
194
|
+
} | null, backendContext: GeneralBackendContext | null): GeneralComponent;
|
|
195
|
+
/**
|
|
196
|
+
* Define a trait behavior
|
|
197
|
+
*
|
|
198
|
+
* A trait behavior
|
|
199
|
+
* Optionally, the trait behavior can add a conversion function.
|
|
200
|
+
* This function can convert the implementation to another interface.
|
|
201
|
+
*/
|
|
202
|
+
defineTraitBehavior<TIn extends {
|
|
203
|
+
[key: string]: any;
|
|
204
|
+
}>(): TraitBehavior<TIn, TIn>;
|
|
205
|
+
defineTraitBehavior<TIn extends {
|
|
206
|
+
[key: string]: any;
|
|
207
|
+
}, TOut extends {
|
|
208
|
+
[key: string]: any;
|
|
209
|
+
}>(trans: (impl: TIn) => TOut): TraitBehavior<TIn, TOut>;
|
|
210
|
+
}
|
|
211
|
+
declare const getDefaultComponentSpace: () => ComponentSpace;
|
|
212
|
+
|
|
213
|
+
type DevtoolInterface = {
|
|
214
|
+
now: () => number;
|
|
215
|
+
addTimelineEvent: (time: number, type: string, data?: Record<string, unknown>) => void;
|
|
216
|
+
addTimelineComponentEvent: (time: number, type: string, component: GeneralComponent, data?: Record<string, unknown>) => void;
|
|
217
|
+
addTimelinePerformanceMeasureStart: (time: number, type: string, component: GeneralComponent | string | null, data?: Record<string, unknown>) => void;
|
|
218
|
+
addTimelinePerformanceMeasureEnd: (time: number) => void;
|
|
219
|
+
addTimelineBackendWaterfall: (type: string, times: [
|
|
220
|
+
number,
|
|
221
|
+
number,
|
|
222
|
+
number
|
|
223
|
+
], data?: Record<string, unknown>) => void;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
declare class VirtualNode extends Element$4 {
|
|
227
|
+
[VIRTUAL_NODE_SYMBOL]: true;
|
|
228
|
+
is: string;
|
|
229
|
+
constructor();
|
|
230
|
+
static isVirtualNode: (e: any) => e is VirtualNode;
|
|
231
|
+
static create(virtualName: string, owner: ShadowRoot): VirtualNode;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
type Node$1 = TextNode | Element$4;
|
|
235
|
+
interface NodeCast {
|
|
236
|
+
/**
|
|
237
|
+
* Cast a node to a text node
|
|
238
|
+
*
|
|
239
|
+
* Returns `null` if the element is not a text node.
|
|
240
|
+
*/
|
|
241
|
+
asTextNode(): TextNode | null;
|
|
242
|
+
/**
|
|
243
|
+
* Cast a node to an element (native node, virtual node, or component node)
|
|
244
|
+
*
|
|
245
|
+
* Returns `null` if the element is not a text node.
|
|
246
|
+
*/
|
|
247
|
+
asElement(): Element$4 | null;
|
|
248
|
+
/**
|
|
249
|
+
* Cast an element to a native node
|
|
250
|
+
*
|
|
251
|
+
* Returns `null` if the element is not a native node.
|
|
252
|
+
*/
|
|
253
|
+
asNativeNode(): NativeNode | null;
|
|
254
|
+
/**
|
|
255
|
+
* Cast an element to a virtual node
|
|
256
|
+
*
|
|
257
|
+
* Returns `null` if the element is not a virtual node.
|
|
258
|
+
*/
|
|
259
|
+
asVirtualNode(): VirtualNode | null;
|
|
260
|
+
/**
|
|
261
|
+
* Cast an element to the instance of the specified component
|
|
262
|
+
*
|
|
263
|
+
* Returns `null` if the element is not the instance of the specified component.
|
|
264
|
+
*/
|
|
265
|
+
asInstanceOf<UData extends DataList, UProperty extends PropertyList, UMethod extends MethodList>(componentDefinition: ComponentDefinition<UData, UProperty, UMethod>): ComponentInstance<UData, UProperty, UMethod> | null;
|
|
266
|
+
}
|
|
267
|
+
declare const dumpSingleElementToString: (elem: any) => string;
|
|
268
|
+
declare const dumpElementToString: (elem: any, composed: boolean, tabDepth?: number) => string;
|
|
269
|
+
declare const dumpElement: (elem: any, composed: boolean) => void;
|
|
270
|
+
|
|
271
|
+
declare class TextNode implements NodeCast {
|
|
272
|
+
ownerShadowRoot: ShadowRoot;
|
|
273
|
+
parentNode: Element$4 | null;
|
|
274
|
+
parentIndex: number;
|
|
275
|
+
containingSlot: Element$4 | null | undefined;
|
|
276
|
+
slotNodes: Node[] | undefined;
|
|
277
|
+
slotIndex: number | undefined;
|
|
278
|
+
constructor(text: string, owner: ShadowRoot);
|
|
279
|
+
static isTextNode: (e: any) => e is TextNode;
|
|
280
|
+
static create(text: string, ownerShadowRoot: ShadowRoot): TextNode;
|
|
281
|
+
asTextNode(): TextNode;
|
|
282
|
+
asElement(): null;
|
|
283
|
+
asNativeNode(): null;
|
|
284
|
+
asVirtualNode(): null;
|
|
285
|
+
asInstanceOf(): null;
|
|
286
|
+
/** Destroy the backend element */
|
|
287
|
+
destroyBackendElement(): void;
|
|
288
|
+
/** Destroy the backend element on next detach */
|
|
289
|
+
destroyBackendElementOnDetach(): void;
|
|
290
|
+
/** Get the backend element */
|
|
291
|
+
getBackendElement(): GeneralBackendElement | null;
|
|
292
|
+
/** Get composed parent (including virtual nodes) */
|
|
293
|
+
getComposedParent(): Element$4 | null;
|
|
294
|
+
get $$(): GeneralBackendElement | null;
|
|
295
|
+
get textContent(): string;
|
|
296
|
+
set textContent(text: string);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
declare const ELEMENT_SYMBOL: unique symbol;
|
|
300
|
+
declare const NATIVE_NODE_SYMBOL: unique symbol;
|
|
301
|
+
declare const VIRTUAL_NODE_SYMBOL: unique symbol;
|
|
302
|
+
declare const COMPONENT_SYMBOL: unique symbol;
|
|
303
|
+
|
|
304
|
+
declare class NativeNode extends Element$4 {
|
|
305
|
+
[NATIVE_NODE_SYMBOL]: true;
|
|
306
|
+
is: string;
|
|
307
|
+
stylingName: string;
|
|
308
|
+
constructor();
|
|
309
|
+
static isNativeNode: (e: any) => e is NativeNode;
|
|
310
|
+
static create(tagName: string, owner: ShadowRoot, stylingName?: string, placeholderHandlerRemover?: () => void): NativeNode;
|
|
311
|
+
setModelBindingListener(propName: string, listener: ModelBindingListener): void;
|
|
312
|
+
getModelBindingListeners(): {
|
|
313
|
+
[name: string]: ModelBindingListener;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
declare const enum SlotMode {
|
|
318
|
+
Direct = 0,
|
|
319
|
+
Single = 1,
|
|
320
|
+
Multiple = 2,
|
|
321
|
+
Dynamic = 3
|
|
322
|
+
}
|
|
323
|
+
declare class ShadowRoot extends VirtualNode {
|
|
324
|
+
constructor();
|
|
325
|
+
static isShadowRoot: (e: any) => e is ShadowRoot;
|
|
326
|
+
static createShadowRoot(host: GeneralComponent): ShadowRoot;
|
|
327
|
+
getHostNode(): GeneralComponent;
|
|
328
|
+
createTextNode(text?: string): TextNode;
|
|
329
|
+
createNativeNode(tagName: string): NativeNode;
|
|
330
|
+
createVirtualNode(virtualName?: string): VirtualNode;
|
|
331
|
+
createNativeNodeWithInit(tagName: string, stylingName: string, placeholderHandlerRemover: (() => void) | undefined, initPropValues?: (comp: NativeNode) => void): NativeNode;
|
|
332
|
+
/**
|
|
333
|
+
* Create a component if possible
|
|
334
|
+
*
|
|
335
|
+
* Placeholding status should be checked with `checkComponentPlaceholder` .
|
|
336
|
+
* This function may create a native node if the using target is native node.
|
|
337
|
+
*/
|
|
338
|
+
createComponent(tagName: string, usingKey?: string, genericTargets?: {
|
|
339
|
+
[key: string]: string;
|
|
340
|
+
}, placeholderCallback?: (c: GeneralComponentDefinition) => void, initPropValues?: (comp: GeneralComponent | NativeNode) => void): GeneralComponent | NativeNode;
|
|
341
|
+
createComponentByDef(tagName: string, componentDef: GeneralComponentDefinition): GeneralComponent;
|
|
342
|
+
/**
|
|
343
|
+
* Create a component if the given tag name is a component in the space, or a native node if not
|
|
344
|
+
*
|
|
345
|
+
* The component `using` map is not used.
|
|
346
|
+
* Consider using `checkComponentPlaceholder` to check if the tag name is in the `using` map.
|
|
347
|
+
* The global using registered with `ComponentSpace.prototype.getGlobalUsingComponent` is still used.
|
|
348
|
+
*/
|
|
349
|
+
createComponentOrNativeNode(tagName: string, genericTargets?: {
|
|
350
|
+
[key: string]: string;
|
|
351
|
+
}, initPropValues?: (comp: GeneralComponent | NativeNode) => void): GeneralComponent | NativeNode;
|
|
352
|
+
/**
|
|
353
|
+
* Find whether this component is placeholding or not
|
|
354
|
+
*
|
|
355
|
+
* This method will only find in the component `using` list and `generics` list.
|
|
356
|
+
* If not found, returns `undefined` .
|
|
357
|
+
* If the placeholder will be used, returns `true` ; `false` otherwise.
|
|
358
|
+
*/
|
|
359
|
+
checkComponentPlaceholder(usingKey: string): boolean | undefined;
|
|
360
|
+
getElementById(id: string): Element$4 | undefined;
|
|
361
|
+
/** Get the slot element with the specified name */
|
|
362
|
+
getSlotElementFromName(name: string): Element$4 | Element$4[] | null;
|
|
363
|
+
/**
|
|
364
|
+
* Get the slot element for the slot content
|
|
365
|
+
*
|
|
366
|
+
* The provided node must be a valid child node of the host of this shadow root.
|
|
367
|
+
* Otherwise the behavior is undefined.
|
|
368
|
+
*/
|
|
369
|
+
getContainingSlot(elem: Node$1 | null): Element$4 | null;
|
|
370
|
+
/**
|
|
371
|
+
* Get the elements that should be composed in specified slot
|
|
372
|
+
*
|
|
373
|
+
* This method always returns a new array (or null if the specified slot is invalid).
|
|
374
|
+
* It is convenient but less performant.
|
|
375
|
+
* For better performance, consider using `forEachNodeInSpecifiedSlot` .
|
|
376
|
+
*/
|
|
377
|
+
getSlotContentArray(slot: Element$4): Node$1[] | null;
|
|
378
|
+
/**
|
|
379
|
+
* Iterate slots
|
|
380
|
+
*/
|
|
381
|
+
forEachSlot(f: (slot: Element$4) => boolean | void): void;
|
|
382
|
+
/**
|
|
383
|
+
* Iterate through elements ahd their corresponding slots (including slots-inherited nodes)
|
|
384
|
+
* @param f A function to execute for each element. Return false to break the iteration.
|
|
385
|
+
* @returns A boolean indicating whether the iteration is complete.
|
|
386
|
+
*/
|
|
387
|
+
forEachNodeInSlot(f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Iterate through elements of a specified slot (including slots-inherited nodes)
|
|
390
|
+
* @param f A function to execute for each element. Return false to break the iteration.
|
|
391
|
+
* @returns A boolean indicating whether the iteration is complete.
|
|
392
|
+
*/
|
|
393
|
+
forEachNodeInSpecifiedSlot(slot: Element$4 | null, f: (node: Node$1) => boolean | void): boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Iterate through elements ahd their corresponding slots (NOT including slots-inherited nodes)
|
|
396
|
+
* @param f A function to execute for each element. Return false to break the iteration.
|
|
397
|
+
* @returns A boolean indicating whether the iteration is complete.
|
|
398
|
+
*/
|
|
399
|
+
forEachSlotContentInSlot(f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean;
|
|
400
|
+
/**
|
|
401
|
+
* Iterate through elements of a specified slot (NOT including slots-inherited nodes)
|
|
402
|
+
* @param f A function to execute for each element. Return false to break the iteration.
|
|
403
|
+
* @returns A boolean indicating whether the iteration is complete.
|
|
404
|
+
*/
|
|
405
|
+
forEachSlotContentInSpecifiedSlot(slot: Element$4 | null, f: (node: Node$1) => boolean | void): boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Check whether a node is connected to this shadow root
|
|
408
|
+
*/
|
|
409
|
+
isConnected(node: Node$1): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Set the dynamic slot handlers
|
|
412
|
+
*
|
|
413
|
+
* If the handlers have not been set yet,
|
|
414
|
+
* the `insertSlotHandler` will be called for each slot that has been added to the shadow tree,
|
|
415
|
+
* otherwise call `updateSlotHandler` for each slots.
|
|
416
|
+
*/
|
|
417
|
+
setDynamicSlotHandler(requiredSlotValueNames: string[], insertSlotHandler: (slots: {
|
|
418
|
+
slot: Element$4;
|
|
419
|
+
name: string;
|
|
420
|
+
slotValues: {
|
|
421
|
+
[name: string]: unknown;
|
|
422
|
+
};
|
|
423
|
+
}[]) => void, removeSlotHandler: (slots: Element$4[]) => void, updateSlotHandler: (slot: Element$4, slotValues: {
|
|
424
|
+
[name: string]: unknown;
|
|
425
|
+
}, updatePathTree: {
|
|
426
|
+
[name: string]: true;
|
|
427
|
+
}) => void): void;
|
|
428
|
+
/**
|
|
429
|
+
* Use the same dynamic slot handlers with the `source`
|
|
430
|
+
*/
|
|
431
|
+
useDynamicSlotHandlerFrom(source: ShadowRoot): void;
|
|
432
|
+
/**
|
|
433
|
+
* Update a slot value
|
|
434
|
+
*
|
|
435
|
+
* The updated value should be applied with `applySlotValueUpdates` call.
|
|
436
|
+
*/
|
|
437
|
+
replaceSlotValue(slot: Element$4, name: string, value: unknown): void;
|
|
438
|
+
/**
|
|
439
|
+
* Apply slot value updates
|
|
440
|
+
*/
|
|
441
|
+
applySlotValueUpdates(slot: Element$4): void;
|
|
442
|
+
applySlotUpdates(): void;
|
|
443
|
+
/**
|
|
444
|
+
* Get slot mode
|
|
445
|
+
*/
|
|
446
|
+
getSlotMode(): SlotMode;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
type GeneralFuncType = (this: any, ...args: any[]) => any;
|
|
450
|
+
declare class FuncArr<F extends GeneralFuncType> {
|
|
451
|
+
empty: boolean;
|
|
452
|
+
private _$type;
|
|
453
|
+
private _$arr;
|
|
454
|
+
constructor(type: string);
|
|
455
|
+
add(func: F): void;
|
|
456
|
+
remove(func: F): F | null;
|
|
457
|
+
call(caller: ThisParameterType<F>, args: Parameters<F>, relatedComponent?: AnyComponent): boolean;
|
|
458
|
+
}
|
|
459
|
+
declare function safeCallback<F extends GeneralFuncType>(this: void, type: string, method: F, caller: ThisParameterType<F>, args: Parameters<F>, relatedComponent?: AnyComponent): ReturnType<F> | undefined;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Options for an event
|
|
463
|
+
*/
|
|
464
|
+
type EventOptions = {
|
|
465
|
+
originalEvent?: unknown;
|
|
466
|
+
bubbles?: boolean;
|
|
467
|
+
composed?: boolean;
|
|
468
|
+
capturePhase?: boolean;
|
|
469
|
+
extraFields?: {
|
|
470
|
+
[key: string]: unknown;
|
|
471
|
+
};
|
|
472
|
+
handleListenerReturn?: (ret: unknown) => boolean | void;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Options for an event listener
|
|
476
|
+
*/
|
|
477
|
+
type EventListenerOptions = {
|
|
478
|
+
/** Always stop bubbling after this listener */
|
|
479
|
+
final?: boolean;
|
|
480
|
+
/** Mark mutated after this listener (ignored if `final` is true) */
|
|
481
|
+
mutated?: boolean;
|
|
482
|
+
/** Listen in the capture phase */
|
|
483
|
+
capture?: boolean;
|
|
484
|
+
/** The same as `capture` for compatibility */
|
|
485
|
+
useCapture?: boolean;
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* Event bubbling control
|
|
489
|
+
*/
|
|
490
|
+
declare const enum EventBubbleStatus {
|
|
491
|
+
Normal = 0,
|
|
492
|
+
NoDefault = 1
|
|
493
|
+
}
|
|
494
|
+
type EventListener<TDetail> = (ev: ShadowedEvent<TDetail>) => boolean | void;
|
|
495
|
+
declare const enum MutLevel {
|
|
496
|
+
None = 0,
|
|
497
|
+
Mut = 1,
|
|
498
|
+
Final = 2
|
|
499
|
+
}
|
|
500
|
+
type ShadowedEvent<TDetail> = Required<Event<TDetail>> & {
|
|
501
|
+
target: Element$4;
|
|
502
|
+
mark: {
|
|
503
|
+
[name: string]: unknown;
|
|
504
|
+
} | null;
|
|
505
|
+
currentTarget: Element$4;
|
|
506
|
+
};
|
|
507
|
+
declare class Event<TDetail> {
|
|
508
|
+
type: string;
|
|
509
|
+
timeStamp: number;
|
|
510
|
+
detail: TDetail;
|
|
511
|
+
bubbles: boolean;
|
|
512
|
+
composed: boolean;
|
|
513
|
+
constructor(name: string, detail: TDetail, options?: EventOptions);
|
|
514
|
+
getEventBubbleStatus(): EventBubbleStatus;
|
|
515
|
+
wrapShadowedEvent(targetCaller: Element$4, mark: {
|
|
516
|
+
[name: string]: unknown;
|
|
517
|
+
} | null, currentTargetCaller: Element$4): ShadowedEvent<TDetail>;
|
|
518
|
+
getEventName(): string;
|
|
519
|
+
getOriginalEvent(): unknown;
|
|
520
|
+
preventDefault(): void;
|
|
521
|
+
defaultPrevented(): boolean;
|
|
522
|
+
stopPropagation(): void;
|
|
523
|
+
propagationStopped(): boolean;
|
|
524
|
+
markMutated(): void;
|
|
525
|
+
mutatedMarked(): boolean;
|
|
526
|
+
listenerReturnHandler(): ((ret: unknown) => boolean | void) | undefined;
|
|
527
|
+
callListener(currentTarget: Element$4, mark: Record<string, unknown> | null, target: Element$4, isCapture: boolean): void;
|
|
528
|
+
dispatch(target: Element$4, externalTarget?: GeneralBackendElement): void;
|
|
529
|
+
static dispatchEvent<TDetail>(target: Element$4, event: Event<TDetail>): void;
|
|
530
|
+
static dispatchExternalEvent<TDetail>(component: GeneralComponent, target: GeneralBackendElement, event: Event<TDetail>): void;
|
|
531
|
+
static triggerEvent<TDetail>(this: void, target: Element$4, name: string, detail: TDetail, options?: EventOptions): void;
|
|
532
|
+
static triggerExternalEvent<TDetail>(this: void, component: GeneralComponent, target: GeneralBackendElement, name: string, detail: TDetail, options?: EventOptions): void;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* An external shadow root
|
|
537
|
+
*
|
|
538
|
+
* It can be used to build an external component.
|
|
539
|
+
* External component is a customizable subtree that can be composed with normal components.
|
|
540
|
+
* It allows third-party frameworks to render a subtree and then compose it together.
|
|
541
|
+
* However, the subtree must be created in the same backend context.
|
|
542
|
+
*/
|
|
543
|
+
interface ExternalShadowRoot {
|
|
544
|
+
root: GeneralBackendElement;
|
|
545
|
+
slot: GeneralBackendElement;
|
|
546
|
+
getIdMap(): {
|
|
547
|
+
[id: string]: GeneralBackendElement;
|
|
548
|
+
};
|
|
549
|
+
handleEvent<T>(target: GeneralBackendElement, event: Event<T>): void;
|
|
550
|
+
setListener<T>(elem: GeneralBackendElement, ev: string, listener: (event: ShadowedEvent<T>) => unknown): void;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* A template engine that handles the template part of a component
|
|
555
|
+
*/
|
|
556
|
+
interface TemplateEngine {
|
|
557
|
+
/**
|
|
558
|
+
* Preprocess a behavior and generate a preprocessed template
|
|
559
|
+
*
|
|
560
|
+
* This function is called during component prepare.
|
|
561
|
+
* The `_$template` field of the behavior is designed to be handled by the template engine,
|
|
562
|
+
* and should be preprocessed in this function.
|
|
563
|
+
*/
|
|
564
|
+
create(behavior: GeneralBehavior, componentOptions: NormalizedComponentOptions): Template;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* A preprocessed template
|
|
568
|
+
*/
|
|
569
|
+
interface Template {
|
|
570
|
+
/**
|
|
571
|
+
* Create a template instance for a component instance
|
|
572
|
+
*/
|
|
573
|
+
createInstance(elem: GeneralComponent, createShadowRoot: (component: GeneralComponent) => ShadowRoot): TemplateInstance;
|
|
574
|
+
/**
|
|
575
|
+
* Update the content of the template (optional)
|
|
576
|
+
*
|
|
577
|
+
* Implement this function if template update is needed (usually used during development).
|
|
578
|
+
* The behavior is always the object which used when creation.
|
|
579
|
+
*/
|
|
580
|
+
updateTemplate?(behavior: GeneralBehavior): void;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* A template instance that works with a component instance
|
|
584
|
+
*/
|
|
585
|
+
interface TemplateInstance {
|
|
586
|
+
/**
|
|
587
|
+
* The shadow root of the component
|
|
588
|
+
*
|
|
589
|
+
* This field should not be changed.
|
|
590
|
+
*/
|
|
591
|
+
shadowRoot: ShadowRoot | ExternalShadowRoot;
|
|
592
|
+
/**
|
|
593
|
+
* Apply the updated template content (optional)
|
|
594
|
+
*
|
|
595
|
+
* Implement this function if template update is needed (usually used during development).
|
|
596
|
+
* The template is always the object which used when creation.
|
|
597
|
+
*/
|
|
598
|
+
updateTemplate?(template: Template, data: DataValue): void;
|
|
599
|
+
initValues(data: DataValue): void;
|
|
600
|
+
updateValues(data: DataValue, changes: DataChange[]): void;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
type template_engine_Template = Template;
|
|
604
|
+
type template_engine_TemplateEngine = TemplateEngine;
|
|
605
|
+
type template_engine_TemplateInstance = TemplateInstance;
|
|
606
|
+
declare namespace template_engine {
|
|
607
|
+
export type { template_engine_Template as Template, template_engine_TemplateEngine as TemplateEngine, template_engine_TemplateInstance as TemplateInstance };
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* The deep copy strategy
|
|
612
|
+
*
|
|
613
|
+
* Higher level indicates more accuracy but probably less performance.
|
|
614
|
+
*/
|
|
615
|
+
declare enum DeepCopyKind {
|
|
616
|
+
/**
|
|
617
|
+
* Avoid deep copy
|
|
618
|
+
*
|
|
619
|
+
* This avoids any copy, and recursive objects can be handled without any failing.
|
|
620
|
+
* However, changing non-copied data will sometimes break the logic.
|
|
621
|
+
*/
|
|
622
|
+
None = "none",
|
|
623
|
+
/**
|
|
624
|
+
* Do a simple deep copy
|
|
625
|
+
*
|
|
626
|
+
* This simply clones each enumerable fields in an object to a new object.
|
|
627
|
+
* It causes stack overflow in recursive objects.
|
|
628
|
+
* Everything in prototypes is ignored.
|
|
629
|
+
*/
|
|
630
|
+
Simple = "simple",
|
|
631
|
+
/**
|
|
632
|
+
* Do a deep copy with recursion detection
|
|
633
|
+
*
|
|
634
|
+
* This clones each enumerable fields in an object to a new object.
|
|
635
|
+
* It can handle recursive objects by recursive detection.
|
|
636
|
+
* Everything in prototypes is ignored.
|
|
637
|
+
*/
|
|
638
|
+
SimpleWithRecursion = "simple-recursion"
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Options for a component
|
|
642
|
+
*/
|
|
643
|
+
type ComponentOptions = {
|
|
644
|
+
/** Is external component or not */
|
|
645
|
+
externalComponent?: boolean;
|
|
646
|
+
/** The host node tag name (only valid in external components) */
|
|
647
|
+
hostNodeTagName?: string;
|
|
648
|
+
/** The template engine */
|
|
649
|
+
templateEngine?: TemplateEngine;
|
|
650
|
+
/** The style scope */
|
|
651
|
+
styleScope?: StyleScopeId;
|
|
652
|
+
/** An extra style scope assigned to the component */
|
|
653
|
+
extraStyleScope?: StyleScopeId | null;
|
|
654
|
+
/** Enable multiple slots or not */
|
|
655
|
+
multipleSlots?: boolean;
|
|
656
|
+
/** Enable dynamic slots or not */
|
|
657
|
+
dynamicSlots?: boolean;
|
|
658
|
+
/** Enable direct slots or not */
|
|
659
|
+
directSlots?: boolean;
|
|
660
|
+
/** Write property values of components to backend with `setAttribute` */
|
|
661
|
+
reflectToAttributes?: boolean;
|
|
662
|
+
/** Allow properties and methods to be able to visit directly in component instance */
|
|
663
|
+
writeFieldsToNode?: boolean;
|
|
664
|
+
/** Write node ID to backend node */
|
|
665
|
+
writeIdToDOM?: boolean;
|
|
666
|
+
/** Use the methods in method caller as the event handlers or not */
|
|
667
|
+
useMethodCallerListeners?: boolean;
|
|
668
|
+
/** Generate a prefix for ID written to backend node */
|
|
669
|
+
idPrefixGenerator?: ((this: GeneralComponent) => string) | null;
|
|
670
|
+
/** Filter some fields out when applying to templates */
|
|
671
|
+
pureDataPattern?: RegExp | null;
|
|
672
|
+
/** Decide how to deep copy component data when updates */
|
|
673
|
+
dataDeepCopy?: DeepCopyKind;
|
|
674
|
+
/** Decide how to deep copy when a property changes */
|
|
675
|
+
propertyPassingDeepCopy?: DeepCopyKind;
|
|
676
|
+
/** Enable listener change events or not */
|
|
677
|
+
listenerChangeLifetimes?: boolean;
|
|
678
|
+
/** Component host node is virtual or not */
|
|
679
|
+
virtualHost?: boolean;
|
|
680
|
+
/** Init component with property values or not */
|
|
681
|
+
propertyEarlyInit?: boolean;
|
|
682
|
+
};
|
|
683
|
+
type NormalizedComponentOptions = {
|
|
684
|
+
externalComponent: boolean;
|
|
685
|
+
hostNodeTagName: string;
|
|
686
|
+
templateEngine: TemplateEngine | null;
|
|
687
|
+
styleScope: StyleScopeId | null;
|
|
688
|
+
extraStyleScope: StyleScopeId | null;
|
|
689
|
+
multipleSlots: boolean;
|
|
690
|
+
dynamicSlots: boolean;
|
|
691
|
+
directSlots: boolean;
|
|
692
|
+
reflectToAttributes: boolean;
|
|
693
|
+
writeFieldsToNode: boolean;
|
|
694
|
+
writeIdToDOM: boolean;
|
|
695
|
+
useMethodCallerListeners: boolean;
|
|
696
|
+
idPrefixGenerator: ((this: GeneralComponent) => string) | null;
|
|
697
|
+
pureDataPattern: RegExp | null;
|
|
698
|
+
dataDeepCopy: DeepCopyKind;
|
|
699
|
+
propertyPassingDeepCopy: DeepCopyKind;
|
|
700
|
+
listenerChangeLifetimes: boolean;
|
|
701
|
+
virtualHost: boolean;
|
|
702
|
+
propertyEarlyInit: boolean;
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* Options for global environment
|
|
706
|
+
*/
|
|
707
|
+
type EnvironmentOptions = {
|
|
708
|
+
/** The default component space */
|
|
709
|
+
defaultComponentSpace: ComponentSpace | null;
|
|
710
|
+
/** Throw errors when errors caught in event callbacks (useful in testing scripts) */
|
|
711
|
+
throwGlobalError: boolean;
|
|
712
|
+
/** Write some extra attributes to DOM backend (for testing) */
|
|
713
|
+
writeExtraInfoToAttr: boolean;
|
|
714
|
+
/** The default backend context */
|
|
715
|
+
backendContext: GeneralBackendContext | null;
|
|
716
|
+
/** The devtool interface */
|
|
717
|
+
devtool: DevtoolInterface | null;
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* The default options
|
|
721
|
+
*/
|
|
722
|
+
declare const globalOptions: NormalizedComponentOptions & EnvironmentOptions;
|
|
723
|
+
|
|
724
|
+
declare const enum NormalizedPropertyType {
|
|
725
|
+
Invalid = "invalid",
|
|
726
|
+
Any = "any",
|
|
727
|
+
String = "string",
|
|
728
|
+
Number = "number",
|
|
729
|
+
Boolean = "boolean",
|
|
730
|
+
Object = "object",
|
|
731
|
+
Array = "array",
|
|
732
|
+
Function = "function"
|
|
733
|
+
}
|
|
734
|
+
type PropertyDefinition = {
|
|
735
|
+
type: NormalizedPropertyType;
|
|
736
|
+
optionalTypes: NormalizedPropertyType[] | null;
|
|
737
|
+
value: unknown;
|
|
738
|
+
default: (() => unknown) | undefined;
|
|
739
|
+
observer: ((newValue: unknown, oldValue: unknown) => void) | null;
|
|
740
|
+
comparer: ((newValue: unknown, oldValue: unknown) => boolean) | null;
|
|
741
|
+
reflectIdPrefix: boolean;
|
|
742
|
+
};
|
|
743
|
+
declare const enum DeepCopyStrategy {
|
|
744
|
+
None = 0,
|
|
745
|
+
Simple = 1,
|
|
746
|
+
SimpleWithRecursion = 2
|
|
747
|
+
}
|
|
748
|
+
type DataValue = unknown;
|
|
749
|
+
type DataObserver = (...values: unknown[]) => void;
|
|
750
|
+
type DataChange = DataReplace | DataSplice;
|
|
751
|
+
type DataReplace = [DataPath, DataValue, RequireComparer, undefined];
|
|
752
|
+
type RequireComparer = true | undefined;
|
|
753
|
+
type DataSplice = [DataPath, DataValue[], number, number];
|
|
754
|
+
type PropertyChange = {
|
|
755
|
+
propName: string;
|
|
756
|
+
prop: PropertyDefinition;
|
|
757
|
+
oldValue: unknown;
|
|
758
|
+
newValue: unknown;
|
|
759
|
+
skipModelListener: boolean;
|
|
760
|
+
};
|
|
761
|
+
type DataUpdateCallback = (data: {
|
|
762
|
+
[name: string]: DataValue;
|
|
763
|
+
}, combinedChanges: DataChange[]) => void;
|
|
764
|
+
type ModelBindingListener = (value: DataValue) => void;
|
|
765
|
+
type ObserverNode = {
|
|
766
|
+
listener?: number[];
|
|
767
|
+
wildcard?: number[];
|
|
768
|
+
sub: {
|
|
769
|
+
[name: string]: ObserverNode;
|
|
770
|
+
};
|
|
771
|
+
};
|
|
772
|
+
declare class DataGroupObserverTree {
|
|
773
|
+
propFields: {
|
|
774
|
+
[name: string]: PropertyDefinition;
|
|
775
|
+
};
|
|
776
|
+
observerTree: ObserverNode;
|
|
777
|
+
observers: DataObserverWithPath[];
|
|
778
|
+
constructor(propFields: {
|
|
779
|
+
[name: string]: PropertyDefinition;
|
|
780
|
+
});
|
|
781
|
+
cloneSub(): DataGroupObserverTree;
|
|
782
|
+
addObserver(func: DataObserver, dataPath: MultiPaths): void;
|
|
783
|
+
}
|
|
784
|
+
type DataObserverWithPath = {
|
|
785
|
+
path: MultiPaths;
|
|
786
|
+
f: DataObserver;
|
|
787
|
+
};
|
|
788
|
+
/** A data wrapper for data operations such as `setData` */
|
|
789
|
+
declare class DataGroup<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> {
|
|
790
|
+
data: DataWithPropertyValues<TData, TProperty>;
|
|
791
|
+
innerData: {
|
|
792
|
+
[key: string]: DataValue;
|
|
793
|
+
} | null;
|
|
794
|
+
private _$comp;
|
|
795
|
+
private _$pureDataPattern;
|
|
796
|
+
private _$dataDeepCopy;
|
|
797
|
+
private _$propertyPassingDeepCopy;
|
|
798
|
+
private _$reflectToAttributes;
|
|
799
|
+
private _$propFields;
|
|
800
|
+
private _$observerTree;
|
|
801
|
+
private _$observers;
|
|
802
|
+
private _$observerStatus;
|
|
803
|
+
private _$modelBindingListener;
|
|
804
|
+
private _$updateListener?;
|
|
805
|
+
private _$pendingChanges;
|
|
806
|
+
private _$doingUpdates;
|
|
807
|
+
private _$generateInnerData;
|
|
808
|
+
constructor(associatedComponent: ComponentInstance<TData, TProperty, TMethod> | null, data: DataWithPropertyValues<TData, TProperty>, pureDataPattern: RegExp | null, dataDeepCopy: DeepCopyStrategy, propertyPassingDeepCopy: DeepCopyStrategy, reflectToAttributes: boolean, observerTree: DataGroupObserverTree);
|
|
809
|
+
/** Create a simple data group */
|
|
810
|
+
static create(data: {
|
|
811
|
+
[key: string]: DataValue;
|
|
812
|
+
}): DataGroup<any, PropertyList, MethodList>;
|
|
813
|
+
/** Set a callback for every grouped update */
|
|
814
|
+
setUpdateListener(updateListener: DataUpdateCallback): void;
|
|
815
|
+
/** Replace the underlying data */
|
|
816
|
+
replaceWholeData(data: DataWithPropertyValues<TData, TProperty>): void;
|
|
817
|
+
/** Add a new common data change to queue */
|
|
818
|
+
replaceDataOnPath(path: DataPath, newData: DataValue): void;
|
|
819
|
+
/** Add a new array splice operation to queue */
|
|
820
|
+
spliceArrayDataOnPath(path: DataPath, index: number | undefined, del: number | undefined, inserts: DataValue[]): void;
|
|
821
|
+
/**
|
|
822
|
+
* Add a new property change to queue
|
|
823
|
+
*
|
|
824
|
+
* (Generally designed for template engines.)
|
|
825
|
+
* If the `propName` is a property,
|
|
826
|
+
* the `newData` will be deep-copied according to the `propertyPassingDeepCopy` configuration.
|
|
827
|
+
* Otherwise, it returns false.
|
|
828
|
+
*/
|
|
829
|
+
replaceProperty(propName: string, newData: DataValue): boolean;
|
|
830
|
+
/** Discard changes in queue and generate a new queue with specified changes */
|
|
831
|
+
setChanges(changes: DataChange[]): void;
|
|
832
|
+
/** Get the data change queue */
|
|
833
|
+
getChanges(): DataChange[];
|
|
834
|
+
/**
|
|
835
|
+
* Set a callback when a specified property changes
|
|
836
|
+
*
|
|
837
|
+
* (Generally designed for template engines.)
|
|
838
|
+
*/
|
|
839
|
+
setModelBindingListener(propName: string, listener: ModelBindingListener): void;
|
|
840
|
+
/** Apply all changes in queue */
|
|
841
|
+
applyDataUpdates(skipModelListener?: boolean): void;
|
|
842
|
+
}
|
|
843
|
+
type GeneralDataGroup = DataGroup<DataList, PropertyList, MethodList>;
|
|
844
|
+
|
|
845
|
+
type Empty = Record<never, never>;
|
|
846
|
+
type IsEmpty<T> = Equal<T, Empty>;
|
|
847
|
+
type NewField<TObject, TField extends string, TValueType> = Extract<keyof TObject, TField> extends never ? TValueType : never;
|
|
848
|
+
type NewFieldList<TObject, TNewObject> = Extract<keyof TObject, keyof TNewObject> extends never ? TNewObject : never;
|
|
849
|
+
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
850
|
+
/**
|
|
851
|
+
* UnionToIntersection<'foo' | 42 | true> = 'foo' & 42 & true
|
|
852
|
+
* UnionToIntersection<(() => 'foo') | ((i: 42) => true)> = (() => 'foo') & ((i: 42) => true)
|
|
853
|
+
*/
|
|
854
|
+
type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends (args: infer Arg) => void ? Arg : never;
|
|
855
|
+
/**
|
|
856
|
+
* Merge<{ foo: string }, { bar: number }> = { foo: string, bar: number }
|
|
857
|
+
*/
|
|
858
|
+
type Merge<U> = U extends infer T ? {
|
|
859
|
+
[K in keyof T]: T[K];
|
|
860
|
+
} : never;
|
|
861
|
+
/**
|
|
862
|
+
* IsAny<any> = true
|
|
863
|
+
* IsAny<{}> = false
|
|
864
|
+
*/
|
|
865
|
+
type IsAny<T> = (<S>(S: S) => S extends T ? 1 : 2) extends <R>(R: R) => R extends any ? 1 : 2 ? true : false;
|
|
866
|
+
/**
|
|
867
|
+
* IsNever<never> = true
|
|
868
|
+
* IsNever<unknown> = false
|
|
869
|
+
* IsNever<any> = false
|
|
870
|
+
*/
|
|
871
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
872
|
+
type SetDataStringPath<K extends string | number, Prefix extends string> = [Prefix] extends [never] ? `${K}` : K extends number ? `${Prefix}[${K}]` : `${Prefix}.${K}`;
|
|
873
|
+
type Tuple<T, Res extends 1[] = []> = 0 extends 1 ? never : Res['length'] extends T ? Res : Tuple<T, [...Res, 1]>;
|
|
874
|
+
type Subtract<M extends number, S extends number> = Tuple<M> extends [...Tuple<S>, ...infer Rest] ? Rest['length'] : never;
|
|
875
|
+
/**
|
|
876
|
+
* SetDataSetter<{ name: string; foo: { bar: number } }> = {
|
|
877
|
+
* name: string,
|
|
878
|
+
* foo: { bar: number },
|
|
879
|
+
* 'foo.bar': number,
|
|
880
|
+
* }
|
|
881
|
+
* setDataSetter<{ list: number[], foo: { bar: number }[]}> = {
|
|
882
|
+
* list: number[],
|
|
883
|
+
* `list[${number}]`: number,
|
|
884
|
+
* foo: { bar: number }[],
|
|
885
|
+
* `foo[${number}]`: { bar: number }[],
|
|
886
|
+
* `foo[${number}].bar`: number,
|
|
887
|
+
* }
|
|
888
|
+
*/
|
|
889
|
+
type SetDataSetter<T, Prefix extends string = never, Count extends number = 4> = Count extends 0 ? Record<SetDataStringPath<any, Prefix>, T> : IsAny<T> extends true ? Record<SetDataStringPath<any, Prefix>, T> : UnionToIntersection<T extends any[] ? {
|
|
890
|
+
[P in keyof T & number]: SetDataSetter<T[P], SetDataStringPath<P, Prefix>, Subtract<Count, 1>> & Record<SetDataStringPath<P, Prefix>, T[P]>;
|
|
891
|
+
}[keyof T & number] : T extends Record<string | number, any> ? {
|
|
892
|
+
[P in keyof T & (string | number)]: SetDataSetter<T[P], SetDataStringPath<P, Prefix>, Subtract<Count, 1>> & Record<SetDataStringPath<P, Prefix>, T[P]>;
|
|
893
|
+
}[keyof T & (string | number)] : never>;
|
|
894
|
+
/**
|
|
895
|
+
* DeepReadonly<{ foo: { bar: number } }> = {
|
|
896
|
+
* readonly foo: {
|
|
897
|
+
* readonly bar: number
|
|
898
|
+
* }
|
|
899
|
+
* }
|
|
900
|
+
*/
|
|
901
|
+
type DeepReadonly<T, Count extends number = 4> = Count extends 0 ? T : T extends Record<any, any> ? T extends (...args: any[]) => any ? T : {
|
|
902
|
+
readonly [P in keyof T]: DeepReadonly<T[P], Subtract<Count, 1>>;
|
|
903
|
+
} : T;
|
|
904
|
+
type PublicFields<T> = {
|
|
905
|
+
[K in keyof T as K extends `_$${any}` ? never : K]: T[K];
|
|
906
|
+
};
|
|
907
|
+
/**
|
|
908
|
+
* ObjectDataPathStrings<{ name: string; age: number }> = 'name' | 'age'
|
|
909
|
+
* ObjectDataPathStrings<{
|
|
910
|
+
* refCount: number;
|
|
911
|
+
* person: { name: string; age: number };
|
|
912
|
+
* }> = 'refCount' | 'person' | 'person.name' | 'person.age'
|
|
913
|
+
* ObjectDataPathStrings<{ books: [{ name: string; price: number }] }> =
|
|
914
|
+
* 'books' | `books[${number}]` | `books[${number}].name` | `books[${number}].price`
|
|
915
|
+
*/
|
|
916
|
+
type ObjectDataPathStrings<T, Prefix extends string = never, Count extends number = 4> = Count extends 0 ? SetDataStringPath<any, Prefix> : IsAny<T> extends true ? SetDataStringPath<any, Prefix> : T extends any[] ? {
|
|
917
|
+
[P in keyof T & number]: SetDataStringPath<P, Prefix> | ObjectDataPathStrings<T[P], SetDataStringPath<P, Prefix>, Subtract<Count, 1>>;
|
|
918
|
+
}[keyof T & number] : T extends Record<string | number, any> ? {
|
|
919
|
+
[P in keyof T & (string | number)]: SetDataStringPath<P, Prefix> | ObjectDataPathStrings<T[P], SetDataStringPath<P, Prefix>, Subtract<Count, 1>>;
|
|
920
|
+
}[keyof T & (string | number)] : Prefix;
|
|
921
|
+
type ObserverDataPathStrings<T, S extends string = ObjectDataPathStrings<T>> = '**' | S | `${S}.**`;
|
|
922
|
+
/**
|
|
923
|
+
* GetFromDataPathString<{ name: string; age: number }, 'name'> = string
|
|
924
|
+
* GetFromDataPathString<{ person: { name: string; age: number } }, 'person.name'> = string
|
|
925
|
+
* GetFromDataPathString<{ books: [{ name: string; price: number }] }, 'books[0].name'> = string
|
|
926
|
+
*/
|
|
927
|
+
type GetFromDataPathString<T, P extends string> = P extends keyof T ? T[P] : P extends '' ? T : P extends `[${infer K extends keyof T & number}].${infer R}` ? GetFromDataPathString<T[K], R> : P extends `[${infer K extends keyof T & number}]${infer R}` ? GetFromDataPathString<T[K], R> : P extends `${infer K extends keyof T & string}[${infer R}` ? GetFromDataPathString<T[K], `[${R}`> : P extends `${infer K extends keyof T & string}.${infer R}` ? GetFromDataPathString<T[K], R> : never;
|
|
928
|
+
type GetFromObserverPathString<T, P extends string> = P extends '**' ? GetFromDataPathString<T, ''> : P extends `${infer K}.**` ? GetFromDataPathString<T, K> : GetFromDataPathString<T, P>;
|
|
929
|
+
/**
|
|
930
|
+
* GetFromDataPath<{ foo: { bar: number } }, ['foo', 'bar']> = number
|
|
931
|
+
* GetFromDataPath<{ list: { bar: number }[] }, ['list', 0, 'bar']> = number
|
|
932
|
+
* GetFromDataPath<{ list: number }, ['nonExists']> = never
|
|
933
|
+
*/
|
|
934
|
+
type GetFromDataPath<T, K extends readonly (string | number)[]> = K extends [
|
|
935
|
+
infer F,
|
|
936
|
+
...infer R extends (string | number)[]
|
|
937
|
+
] ? F extends keyof T ? GetFromDataPath<T[F], R> : never : T;
|
|
938
|
+
declare const TaggedSymbol: unique symbol;
|
|
939
|
+
type Tagged = typeof TaggedSymbol;
|
|
940
|
+
type IfNeverOrAny<T, Replacement> = [T] extends [never] ? Replacement : 1 extends T & 0 ? Replacement : T;
|
|
941
|
+
type GetTags<B> = B extends {
|
|
942
|
+
readonly [Tag in Tagged]: infer Tags extends symbol[];
|
|
943
|
+
} ? Tags : [];
|
|
944
|
+
type GetTagsWithout<B, T extends symbol, Tags = GetTags<B>> = Tags extends [infer F, ...infer R] ? Equal<T, F> extends true ? GetTagsWithout<B, T, R> : [F, ...GetTagsWithout<B, T, R>] : [];
|
|
945
|
+
type UnTagAll<B> = Tagged extends keyof IfNeverOrAny<B, unknown> ? B extends infer Origin & {
|
|
946
|
+
readonly [Tag in Tagged]: GetTags<B>;
|
|
947
|
+
} ? Origin : B : B;
|
|
948
|
+
type Tag<B, T extends symbol> = [IfNeverOrAny<B, unknown>] extends [null | undefined] ? B : UnTagAll<B> & {
|
|
949
|
+
readonly [Tag in Tagged]: [...GetTags<B>, T];
|
|
950
|
+
};
|
|
951
|
+
type UnTag<B, T extends symbol, Tags = GetTagsWithout<B, T>> = Tagged extends keyof IfNeverOrAny<B, unknown> ? Tags extends [] ? UnTagAll<B> : UnTagAll<B> & {
|
|
952
|
+
readonly [Tag in Tagged]: Tags;
|
|
953
|
+
} : B;
|
|
954
|
+
type HasTag<B, T extends symbol> = T extends GetTags<B>[number] ? true : false;
|
|
955
|
+
type DataList = Record<string, unknown>;
|
|
956
|
+
type PropertyList = Record<string, PropertyListItem<PropertyType, any>>;
|
|
957
|
+
type PropertyType = null | StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | NormalizedPropertyType;
|
|
958
|
+
/**
|
|
959
|
+
* PropertyTypeToValueType<null> = any
|
|
960
|
+
* PropertyTypeToValueType<typeof String> = string
|
|
961
|
+
* PropertyTypeToValueType<typeof Number> = number
|
|
962
|
+
*/
|
|
963
|
+
type PropertyTypeToValueType<T extends PropertyType> = T extends null | NormalizedPropertyType.Any ? any : T extends StringConstructor | NormalizedPropertyType.String ? string : T extends NumberConstructor | NormalizedPropertyType.Number ? number : T extends BooleanConstructor | NormalizedPropertyType.Boolean ? boolean : T extends ArrayConstructor | NormalizedPropertyType.Array ? any[] : T extends ObjectConstructor | NormalizedPropertyType.Object ? Record<string, any> | null : T extends FunctionConstructor | NormalizedPropertyType.Function ? (...args: any[]) => any : never;
|
|
964
|
+
type Satisfy<T, V> = V extends T ? V : T;
|
|
965
|
+
/**
|
|
966
|
+
* PropertyTypeToSimpleValueType<typeof String, 'foo'> = 'foo'
|
|
967
|
+
* PropertyTypeToSimpleValueType<typeof String, 123> = string
|
|
968
|
+
*/
|
|
969
|
+
type PropertyTypeToSimpleValueType<T extends PropertyType, V> = T extends StringConstructor | NormalizedPropertyType.String ? Satisfy<string, V> : T extends NumberConstructor | NormalizedPropertyType.Number ? Satisfy<number, V> : T extends BooleanConstructor | NormalizedPropertyType.Boolean ? Satisfy<boolean, V> : T extends ArrayConstructor | NormalizedPropertyType.Array ? Satisfy<any[], V> : T extends ObjectConstructor | NormalizedPropertyType.Object ? Satisfy<Record<string, any> | null, V> : T extends FunctionConstructor | NormalizedPropertyType.Function ? Satisfy<(...args: any[]) => any, V> : never;
|
|
970
|
+
/**
|
|
971
|
+
* PropertyValueType<null> = any
|
|
972
|
+
* PropertyValueType<typeof String> = string
|
|
973
|
+
* PropertyValueType<typeof String | typeof Number> = string | number
|
|
974
|
+
* PropertyValueType<{ type: typeof String }> = string
|
|
975
|
+
* PropertyValueType<{ type: typeof String, optionalTypes: [typeof Number] }> = string | number
|
|
976
|
+
* PropertyValueType<{ type: typeof String, value: 'foo' }> = 'foo'
|
|
977
|
+
* PropertyValueType<{ type: typeof String, value: 123 }> = never
|
|
978
|
+
* PropertyValueType<{ type: typeof String, optionalTypes: [typeof Number], value: 123 }> =
|
|
979
|
+
* string | 123
|
|
980
|
+
*/
|
|
981
|
+
type PropertyValueType<P extends PropertyListItem<PropertyType, any>> = P extends PropertyListItem<infer T, infer V> ? unknown extends V ? PropertyTypeToValueType<T> : ((a: T) => void) extends (a: PropertyType) => void ? V : V extends PropertyTypeToValueType<T> ? PropertyTypeToSimpleValueType<T, V> : never : never;
|
|
982
|
+
type PropertyOption<T extends PropertyType, V> = {
|
|
983
|
+
type?: T;
|
|
984
|
+
optionalTypes?: T[];
|
|
985
|
+
value?: V;
|
|
986
|
+
default?: () => V;
|
|
987
|
+
observer?: ((newValue: V, oldValue: V) => void) | string;
|
|
988
|
+
comparer?: (newValue: V, oldValue: V) => boolean;
|
|
989
|
+
reflectIdPrefix?: boolean;
|
|
990
|
+
};
|
|
991
|
+
type PropertyListItem<T extends PropertyType, V> = T | PropertyOption<T, V>;
|
|
992
|
+
type PropertyValues<P extends PropertyList> = {
|
|
993
|
+
[key in keyof P]: PropertyValueType<P[key]>;
|
|
994
|
+
};
|
|
995
|
+
type DataWithPropertyValues<TData extends DataList, TProperty extends PropertyList> = TData & PropertyValues<TProperty>;
|
|
996
|
+
type ComponentMethod = (...args: any[]) => any;
|
|
997
|
+
type MethodList = Record<string, ComponentMethod>;
|
|
998
|
+
declare const METHOD_TAG: unique symbol;
|
|
999
|
+
type TaggedMethod<Fn extends ComponentMethod> = Tag<Fn, typeof METHOD_TAG>;
|
|
1000
|
+
type UnTaggedMethod<M extends TaggedMethod<any>> = UnTag<M, typeof METHOD_TAG>;
|
|
1001
|
+
type RelationParams = {
|
|
1002
|
+
target?: string | ComponentDefinition<any, any, any> | GeneralBehavior | TraitBehavior<any>;
|
|
1003
|
+
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
1004
|
+
linked?: (target: GeneralComponent) => void;
|
|
1005
|
+
linkChanged?: (target: GeneralComponent) => void;
|
|
1006
|
+
unlinked?: (target: GeneralComponent) => void;
|
|
1007
|
+
linkFailed?: (target: GeneralComponent) => void;
|
|
1008
|
+
};
|
|
1009
|
+
type RelationParamsWithKey = {
|
|
1010
|
+
[name: string]: RelationParams;
|
|
1011
|
+
};
|
|
1012
|
+
type TraitRelationParams<TOut extends {
|
|
1013
|
+
[key: string]: any;
|
|
1014
|
+
}> = {
|
|
1015
|
+
target: TraitBehavior<any, TOut>;
|
|
1016
|
+
type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node';
|
|
1017
|
+
linked?: (target: GeneralComponent) => void;
|
|
1018
|
+
linkChanged?: (target: GeneralComponent) => void;
|
|
1019
|
+
unlinked?: (target: GeneralComponent) => void;
|
|
1020
|
+
linkFailed?: (target: GeneralComponent) => void;
|
|
1021
|
+
};
|
|
1022
|
+
type ChainingFilterFunc<TAddedFields extends {
|
|
1023
|
+
[key: string]: any;
|
|
1024
|
+
}, TRemovedFields extends string = never> = (chain: GeneralBehaviorBuilder) => Omit<GeneralBehaviorBuilder, TRemovedFields> & TAddedFields;
|
|
1025
|
+
type ChainingFilterType = {
|
|
1026
|
+
add: {
|
|
1027
|
+
[key: string]: any;
|
|
1028
|
+
};
|
|
1029
|
+
remove: string;
|
|
1030
|
+
};
|
|
1031
|
+
type ComponentInstance<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> = Component<TData, TProperty, TMethod> & {
|
|
1032
|
+
data: Merge<DataWithPropertyValues<TData, TProperty>>;
|
|
1033
|
+
properties: Merge<DataWithPropertyValues<TData, TProperty>>;
|
|
1034
|
+
} & TMethod;
|
|
1035
|
+
type ComponentParams<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> = {
|
|
1036
|
+
is?: string;
|
|
1037
|
+
behaviors?: (string | GeneralBehavior)[];
|
|
1038
|
+
using?: {
|
|
1039
|
+
[name: string]: string | ComponentDefinition<any, any, any>;
|
|
1040
|
+
};
|
|
1041
|
+
generics?: {
|
|
1042
|
+
[name: string]: {
|
|
1043
|
+
default: string | ComponentDefinition<any, any, any>;
|
|
1044
|
+
} | true;
|
|
1045
|
+
};
|
|
1046
|
+
placeholders?: {
|
|
1047
|
+
[name: string]: string;
|
|
1048
|
+
};
|
|
1049
|
+
template?: {
|
|
1050
|
+
[key: string]: any;
|
|
1051
|
+
} | null;
|
|
1052
|
+
externalClasses?: string[];
|
|
1053
|
+
data?: TData | (() => TData);
|
|
1054
|
+
properties?: TProperty;
|
|
1055
|
+
methods?: TMethod;
|
|
1056
|
+
listeners?: {
|
|
1057
|
+
[name: string]: ComponentMethod | string;
|
|
1058
|
+
};
|
|
1059
|
+
relations?: RelationParamsWithKey;
|
|
1060
|
+
lifetimes?: {
|
|
1061
|
+
[name: string]: ComponentMethod;
|
|
1062
|
+
};
|
|
1063
|
+
created?: () => any;
|
|
1064
|
+
attached?: ComponentMethod;
|
|
1065
|
+
moved?: ComponentMethod;
|
|
1066
|
+
detached?: ComponentMethod;
|
|
1067
|
+
ready?: ComponentMethod;
|
|
1068
|
+
pageLifetimes?: {
|
|
1069
|
+
[name: string]: ComponentMethod;
|
|
1070
|
+
};
|
|
1071
|
+
observers?: {
|
|
1072
|
+
fields?: string;
|
|
1073
|
+
observer: ComponentMethod | string;
|
|
1074
|
+
}[] | {
|
|
1075
|
+
[fields: string]: ComponentMethod | string;
|
|
1076
|
+
};
|
|
1077
|
+
options?: ComponentOptions;
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
type component_params_ChainingFilterFunc<TAddedFields extends {
|
|
1081
|
+
[key: string]: any;
|
|
1082
|
+
}, TRemovedFields extends string = never> = ChainingFilterFunc<TAddedFields, TRemovedFields>;
|
|
1083
|
+
type component_params_ChainingFilterType = ChainingFilterType;
|
|
1084
|
+
type component_params_ComponentInstance<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> = ComponentInstance<TData, TProperty, TMethod>;
|
|
1085
|
+
type component_params_ComponentMethod = ComponentMethod;
|
|
1086
|
+
type component_params_ComponentParams<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> = ComponentParams<TData, TProperty, TMethod>;
|
|
1087
|
+
type component_params_DataList = DataList;
|
|
1088
|
+
type component_params_DataWithPropertyValues<TData extends DataList, TProperty extends PropertyList> = DataWithPropertyValues<TData, TProperty>;
|
|
1089
|
+
type component_params_DeepReadonly<T, Count extends number = 4> = DeepReadonly<T, Count>;
|
|
1090
|
+
type component_params_Empty = Empty;
|
|
1091
|
+
type component_params_Equal<X, Y> = Equal<X, Y>;
|
|
1092
|
+
type component_params_GetFromDataPath<T, K extends readonly (string | number)[]> = GetFromDataPath<T, K>;
|
|
1093
|
+
type component_params_GetFromDataPathString<T, P extends string> = GetFromDataPathString<T, P>;
|
|
1094
|
+
type component_params_GetFromObserverPathString<T, P extends string> = GetFromObserverPathString<T, P>;
|
|
1095
|
+
type component_params_HasTag<B, T extends symbol> = HasTag<B, T>;
|
|
1096
|
+
type component_params_IsAny<T> = IsAny<T>;
|
|
1097
|
+
type component_params_IsEmpty<T> = IsEmpty<T>;
|
|
1098
|
+
type component_params_IsNever<T> = IsNever<T>;
|
|
1099
|
+
declare const component_params_METHOD_TAG: typeof METHOD_TAG;
|
|
1100
|
+
type component_params_Merge<U> = Merge<U>;
|
|
1101
|
+
type component_params_MethodList = MethodList;
|
|
1102
|
+
type component_params_NewField<TObject, TField extends string, TValueType> = NewField<TObject, TField, TValueType>;
|
|
1103
|
+
type component_params_NewFieldList<TObject, TNewObject> = NewFieldList<TObject, TNewObject>;
|
|
1104
|
+
type component_params_ObjectDataPathStrings<T, Prefix extends string = never, Count extends number = 4> = ObjectDataPathStrings<T, Prefix, Count>;
|
|
1105
|
+
type component_params_ObserverDataPathStrings<T, S extends string = ObjectDataPathStrings<T>> = ObserverDataPathStrings<T, S>;
|
|
1106
|
+
type component_params_PropertyList = PropertyList;
|
|
1107
|
+
type component_params_PropertyListItem<T extends PropertyType, V> = PropertyListItem<T, V>;
|
|
1108
|
+
type component_params_PropertyOption<T extends PropertyType, V> = PropertyOption<T, V>;
|
|
1109
|
+
type component_params_PropertyType = PropertyType;
|
|
1110
|
+
type component_params_PropertyTypeToValueType<T extends PropertyType> = PropertyTypeToValueType<T>;
|
|
1111
|
+
type component_params_PropertyValues<P extends PropertyList> = PropertyValues<P>;
|
|
1112
|
+
type component_params_PublicFields<T> = PublicFields<T>;
|
|
1113
|
+
type component_params_RelationParams = RelationParams;
|
|
1114
|
+
type component_params_RelationParamsWithKey = RelationParamsWithKey;
|
|
1115
|
+
type component_params_SetDataSetter<T, Prefix extends string = never, Count extends number = 4> = SetDataSetter<T, Prefix, Count>;
|
|
1116
|
+
type component_params_Tag<B, T extends symbol> = Tag<B, T>;
|
|
1117
|
+
type component_params_TaggedMethod<Fn extends ComponentMethod> = TaggedMethod<Fn>;
|
|
1118
|
+
type component_params_TraitRelationParams<TOut extends {
|
|
1119
|
+
[key: string]: any;
|
|
1120
|
+
}> = TraitRelationParams<TOut>;
|
|
1121
|
+
type component_params_UnTag<B, T extends symbol, Tags = GetTagsWithout<B, T>> = UnTag<B, T, Tags>;
|
|
1122
|
+
type component_params_UnTaggedMethod<M extends TaggedMethod<any>> = UnTaggedMethod<M>;
|
|
1123
|
+
type component_params_UnionToIntersection<T> = UnionToIntersection<T>;
|
|
1124
|
+
declare namespace component_params {
|
|
1125
|
+
export { type component_params_ChainingFilterFunc as ChainingFilterFunc, type component_params_ChainingFilterType as ChainingFilterType, type component_params_ComponentInstance as ComponentInstance, type component_params_ComponentMethod as ComponentMethod, type component_params_ComponentParams as ComponentParams, type component_params_DataList as DataList, type component_params_DataWithPropertyValues as DataWithPropertyValues, type component_params_DeepReadonly as DeepReadonly, type component_params_Empty as Empty, type component_params_Equal as Equal, type component_params_GetFromDataPath as GetFromDataPath, type component_params_GetFromDataPathString as GetFromDataPathString, type component_params_GetFromObserverPathString as GetFromObserverPathString, type component_params_HasTag as HasTag, type component_params_IsAny as IsAny, type component_params_IsEmpty as IsEmpty, type component_params_IsNever as IsNever, component_params_METHOD_TAG as METHOD_TAG, type component_params_Merge as Merge, type component_params_MethodList as MethodList, type component_params_NewField as NewField, type component_params_NewFieldList as NewFieldList, type component_params_ObjectDataPathStrings as ObjectDataPathStrings, type component_params_ObserverDataPathStrings as ObserverDataPathStrings, type component_params_PropertyList as PropertyList, type component_params_PropertyListItem as PropertyListItem, type component_params_PropertyOption as PropertyOption, type component_params_PropertyType as PropertyType, type component_params_PropertyTypeToValueType as PropertyTypeToValueType, type component_params_PropertyValues as PropertyValues, type component_params_PublicFields as PublicFields, type component_params_RelationParams as RelationParams, type component_params_RelationParamsWithKey as RelationParamsWithKey, type component_params_SetDataSetter as SetDataSetter, type component_params_Tag as Tag, type component_params_TaggedMethod as TaggedMethod, type component_params_TraitRelationParams as TraitRelationParams, type component_params_UnTag as UnTag, type component_params_UnTaggedMethod as UnTaggedMethod, type component_params_UnionToIntersection as UnionToIntersection };
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
declare const enum RelationType {
|
|
1129
|
+
Ancestor = 0,
|
|
1130
|
+
Descendant = 1,
|
|
1131
|
+
ParentNonVirtualNode = 2,
|
|
1132
|
+
ChildNonVirtualNode = 3,
|
|
1133
|
+
ParentComponent = 4,
|
|
1134
|
+
ChildComponent = 5
|
|
1135
|
+
}
|
|
1136
|
+
interface RelationHandler<TTarget, TOut> {
|
|
1137
|
+
list(): TTarget[];
|
|
1138
|
+
listAsTrait: TOut extends never ? undefined : () => TOut[];
|
|
1139
|
+
}
|
|
1140
|
+
type RelationListener = (target: unknown) => void;
|
|
1141
|
+
type RelationFailedListener = () => void;
|
|
1142
|
+
|
|
1143
|
+
type NativeNodeDefinition = string;
|
|
1144
|
+
type ResolveBehaviorBuilder<B, TChainingFilter extends ChainingFilterType> = IsNever<TChainingFilter> extends false ? TChainingFilter extends ChainingFilterType ? Omit<B, TChainingFilter['remove']> & TChainingFilter['add'] : B : B;
|
|
1145
|
+
interface BuilderContext<TPrevData extends DataList, TProperty extends PropertyList, TMethodCaller> extends ThisType<TMethodCaller> {
|
|
1146
|
+
self: TMethodCaller;
|
|
1147
|
+
data: Merge<DataWithPropertyValues<TPrevData, TProperty>>;
|
|
1148
|
+
setData: (newData: Partial<SetDataSetter<TPrevData>>) => void;
|
|
1149
|
+
implement: <TIn extends {
|
|
1150
|
+
[x: string]: any;
|
|
1151
|
+
}>(traitBehavior: TraitBehavior<TIn, any>, impl: TIn) => void;
|
|
1152
|
+
relation<TOut extends {
|
|
1153
|
+
[key: string]: any;
|
|
1154
|
+
}>(def: TraitRelationParams<TOut>): RelationHandler<any, TOut>;
|
|
1155
|
+
relation(def: RelationParams): RelationHandler<any, never>;
|
|
1156
|
+
observer<P extends ObserverDataPathStrings<DataWithPropertyValues<TPrevData, TProperty>>, V = Merge<GetFromObserverPathString<DataWithPropertyValues<TPrevData, TProperty>, P>>>(paths: P, func: (newValue: V) => void): void;
|
|
1157
|
+
observer<P extends ObserverDataPathStrings<DataWithPropertyValues<TPrevData, TProperty>>[], V = {
|
|
1158
|
+
[K in keyof P]: Merge<GetFromObserverPathString<DataWithPropertyValues<TPrevData, TProperty>, P[K]>>;
|
|
1159
|
+
}>(paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void;
|
|
1160
|
+
lifetime: <L extends keyof Lifetimes>(name: L, func: Lifetimes[L]) => void;
|
|
1161
|
+
pageLifetime: (name: string, func: (...args: any[]) => void) => void;
|
|
1162
|
+
method: <Fn extends ComponentMethod>(func: Fn) => TaggedMethod<Fn>;
|
|
1163
|
+
listener: <T>(func: EventListener<T>) => TaggedMethod<EventListener<T>>;
|
|
1164
|
+
}
|
|
1165
|
+
type GeneralBehaviorBuilder = BehaviorBuilder<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, never, never>;
|
|
1166
|
+
declare class BehaviorBuilder<TPrevData extends DataList = Empty, TData extends DataList = Empty, TProperty extends PropertyList = Empty, TMethod extends MethodList = Empty, TChainingFilter extends ChainingFilterType = never, TPendingChainingFilter extends ChainingFilterType = never> {
|
|
1167
|
+
/**
|
|
1168
|
+
* Set a front-most init function
|
|
1169
|
+
*
|
|
1170
|
+
* It should return the method caller (the `this` value for various callbacks)
|
|
1171
|
+
* that will be used in future.
|
|
1172
|
+
*/
|
|
1173
|
+
methodCallerInit(func: (this: ComponentInstance<TData, TProperty, TMethod>) => any): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Add a behavior
|
|
1176
|
+
*
|
|
1177
|
+
* If the behavior contains a chaining filter, the chaining filter is called.
|
|
1178
|
+
*/
|
|
1179
|
+
behavior<UData extends DataList, UProperty extends PropertyList, UMethod extends MethodList, UChainingFilter extends ChainingFilterType>(behavior: Behavior<UData, UProperty, UMethod, UChainingFilter>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData & UData, TProperty & UProperty, TMethod & UMethod, UChainingFilter, TPendingChainingFilter>, UChainingFilter>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Set the chaining filter
|
|
1182
|
+
*
|
|
1183
|
+
* The chaining filter is the definition filter for chaining API.
|
|
1184
|
+
* It SHOULD return another chainable object for further chaining.
|
|
1185
|
+
*/
|
|
1186
|
+
chainingFilter<TAddedFields extends {
|
|
1187
|
+
[key: string]: any;
|
|
1188
|
+
}, TRemovedFields extends string = never>(func: ChainingFilterFunc<TAddedFields, TRemovedFields>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod, TChainingFilter, {
|
|
1189
|
+
add: TAddedFields;
|
|
1190
|
+
remove: TRemovedFields;
|
|
1191
|
+
}>, TChainingFilter>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Set component options
|
|
1194
|
+
*
|
|
1195
|
+
* The options will be merged with previous settings.
|
|
1196
|
+
*/
|
|
1197
|
+
options(options: ComponentOptions): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Implement a trait behavior
|
|
1200
|
+
*/
|
|
1201
|
+
implement<TIn extends {
|
|
1202
|
+
[key: string]: any;
|
|
1203
|
+
}>(traitBehavior: TraitBehavior<TIn, any>, impl: TIn): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1204
|
+
/**
|
|
1205
|
+
* Set the compiled template object
|
|
1206
|
+
*/
|
|
1207
|
+
template(template: {
|
|
1208
|
+
[key: string]: unknown;
|
|
1209
|
+
}): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Add other components to the component using list
|
|
1212
|
+
*/
|
|
1213
|
+
usingComponents<T extends Record<string, string | ComponentDefinition<any, any, any>>>(list: T): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Add some placeholders
|
|
1216
|
+
*
|
|
1217
|
+
* The alias SHOULD be in the using list, otherwise it will be ignored.
|
|
1218
|
+
*/
|
|
1219
|
+
placeholders(list: Record<string, string>): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Add other generics
|
|
1222
|
+
*
|
|
1223
|
+
* The alias SHOULD NOT be in the using list, otherwise it will be ignored.
|
|
1224
|
+
*/
|
|
1225
|
+
generics(list: Record<string, {
|
|
1226
|
+
default?: string | GeneralComponentDefinition;
|
|
1227
|
+
} | true>): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Add external classes
|
|
1230
|
+
*/
|
|
1231
|
+
externalClasses(list: string[]): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Add some template data fields
|
|
1234
|
+
*
|
|
1235
|
+
* It does not support raw data, but a `gen` function which returns the new data fields.
|
|
1236
|
+
* The `gen` function executes once during component creation.
|
|
1237
|
+
*/
|
|
1238
|
+
data<T extends DataList>(gen: () => NewFieldList<DataWithPropertyValues<TData, TProperty>, T>): ResolveBehaviorBuilder<BehaviorBuilder<T, TData & T, TProperty, TMethod, TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Set the static template data fields
|
|
1241
|
+
*
|
|
1242
|
+
* The data will be cloned once during component creation.
|
|
1243
|
+
* If called multiple times, the static data will be overwritten but not merged!
|
|
1244
|
+
* Usually, the `data()` method is preferred.
|
|
1245
|
+
*/
|
|
1246
|
+
staticData<T extends DataList>(data: NewFieldList<DataWithPropertyValues<TData, TProperty>, T>): ResolveBehaviorBuilder<BehaviorBuilder<T, TData & T, TProperty, TMethod, TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1247
|
+
/**
|
|
1248
|
+
* Add a single property
|
|
1249
|
+
*
|
|
1250
|
+
* The property name should be different from other properties.
|
|
1251
|
+
*/
|
|
1252
|
+
property<N extends string, T extends PropertyType, V extends PropertyTypeToValueType<T>>(name: N, def: N extends keyof (TData & TProperty) ? never : PropertyListItem<T, V>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty & Record<N, unknown extends V ? T : PropertyOption<T, V>>, TMethod, TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Add a single public method
|
|
1255
|
+
*
|
|
1256
|
+
* The public method can be used as an event handler, and can be visited in component instance.
|
|
1257
|
+
*/
|
|
1258
|
+
methods<T extends MethodList>(funcs: T & ThisType<ComponentInstance<TData, TProperty, TMethod & T>>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod & T, TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Add a data observer
|
|
1261
|
+
*/
|
|
1262
|
+
observer<P extends ObserverDataPathStrings<DataWithPropertyValues<TPrevData, TProperty>>, V = Merge<GetFromObserverPathString<DataWithPropertyValues<TPrevData, TProperty>, P>>>(paths: P, func: (this: ComponentInstance<TData, TProperty, TMethod>, newValue: V) => void, once?: boolean): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1263
|
+
observer<P extends ObserverDataPathStrings<DataWithPropertyValues<TPrevData, TProperty>>[], V = {
|
|
1264
|
+
[K in keyof P]: Merge<GetFromObserverPathString<DataWithPropertyValues<TPrevData, TProperty>, P[K]>>;
|
|
1265
|
+
}>(paths: readonly [...P], func: (this: ComponentInstance<TData, TProperty, TMethod>, ...newValues: V extends any[] ? V : never) => void, once?: boolean): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Add a lifetime callback
|
|
1268
|
+
*/
|
|
1269
|
+
lifetime<L extends keyof Lifetimes>(name: L, func: (this: ComponentInstance<TData, TProperty, TMethod>, ...args: Parameters<Lifetimes[L]>) => ReturnType<Lifetimes[L]>, once?: boolean): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Add a page-lifetime callback
|
|
1272
|
+
*/
|
|
1273
|
+
pageLifetime(name: string, func: (this: ComponentInstance<TData, TProperty, TMethod>, ...args: any[]) => any, once?: boolean): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Add a relation
|
|
1276
|
+
*/
|
|
1277
|
+
relation(name: string, rel: RelationParams & ThisType<ComponentInstance<TData, TProperty, TMethod>>): ResolveBehaviorBuilder<this, TChainingFilter>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Execute a function while component instance creation
|
|
1280
|
+
*
|
|
1281
|
+
* A `BuilderContext` is provided to tweak the component creation progress.
|
|
1282
|
+
* The return value is used as the "export" value of the behavior,
|
|
1283
|
+
* which can be imported by other behaviors.
|
|
1284
|
+
*/
|
|
1285
|
+
init<TExport extends Record<string, TaggedMethod<(...args: any[]) => any>> | void>(func: (this: ComponentInstance<TData, TProperty, TMethod>, builderContext: BuilderContext<TPrevData, TProperty, ComponentInstance<TData, TProperty, TMethod>>) => TExport): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData, TProperty, TMethod & (TExport extends void ? Empty : {
|
|
1286
|
+
[K in keyof TExport]: UnTaggedMethod<TExport[K]>;
|
|
1287
|
+
}), TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1288
|
+
/**
|
|
1289
|
+
* Apply a classic-style definition
|
|
1290
|
+
*/
|
|
1291
|
+
definition<TNewData extends DataList = Empty, TNewProperty extends PropertyList = Empty, TNewMethod extends MethodList = Empty>(def: ComponentParams<TNewData, TNewProperty, TNewMethod> & ThisType<ComponentInstance<TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod>>): ResolveBehaviorBuilder<BehaviorBuilder<TPrevData, TData & TNewData, TProperty & TNewProperty, TMethod & TNewMethod, TChainingFilter, TPendingChainingFilter>, TChainingFilter>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Finish build, generate a behavior, and register it in the component space
|
|
1294
|
+
*/
|
|
1295
|
+
registerBehavior(): Behavior<TData, TProperty, TMethod, TPendingChainingFilter>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Finish build, generate a component definition, and register it in the component space
|
|
1298
|
+
*/
|
|
1299
|
+
registerComponent(): ComponentDefinition<TData, TProperty, TMethod>;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Common mixin-like behavior
|
|
1303
|
+
*
|
|
1304
|
+
* Each component definition contains a single *root* behavior.
|
|
1305
|
+
* A behavior can mixin other behaviors.
|
|
1306
|
+
*/
|
|
1307
|
+
declare class Behavior<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TChainingFilter extends ChainingFilterType> {
|
|
1308
|
+
is: string;
|
|
1309
|
+
ownerSpace: ComponentSpace;
|
|
1310
|
+
/**
|
|
1311
|
+
* Create a behavior with classic-style definition
|
|
1312
|
+
*/
|
|
1313
|
+
static create<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>, ownerSpace?: ComponentSpace): Behavior<Empty & TData, Empty & TProperty, Empty & TMethod, never>;
|
|
1314
|
+
general(): GeneralBehavior;
|
|
1315
|
+
/**
|
|
1316
|
+
* List all component dependencies (recursively)
|
|
1317
|
+
*
|
|
1318
|
+
* This method will prepare the underlying behavior.
|
|
1319
|
+
*/
|
|
1320
|
+
getComponentDependencies(genericTargets?: {
|
|
1321
|
+
[name: string]: GeneralComponentDefinition | NativeNodeDefinition;
|
|
1322
|
+
}): Set<GeneralComponentDefinition>;
|
|
1323
|
+
/** Same as `prepare` method in the prototype (for backward compatibility) */
|
|
1324
|
+
static prepare<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList, TChainingFilter extends ChainingFilterType = never>(behavior: Behavior<TData, TProperty, TMethod, TChainingFilter>): void;
|
|
1325
|
+
/**
|
|
1326
|
+
* Execute the prepare phase (an optimization phase) of this behavior
|
|
1327
|
+
*
|
|
1328
|
+
* Every behavior needs this phase for better future performance.
|
|
1329
|
+
* However, this phase requires a little time for execution,
|
|
1330
|
+
* and requires its all dependent behaviors created.
|
|
1331
|
+
* If a dependent behavior is not prepared, then its prepare phase is also executed.
|
|
1332
|
+
*/
|
|
1333
|
+
prepare(): void;
|
|
1334
|
+
/**
|
|
1335
|
+
* Get the template content
|
|
1336
|
+
*
|
|
1337
|
+
* This method is usually used by the template engine.
|
|
1338
|
+
*/
|
|
1339
|
+
getTemplate(): {
|
|
1340
|
+
[key: string]: unknown;
|
|
1341
|
+
} | undefined;
|
|
1342
|
+
_$updateTemplate(template: {
|
|
1343
|
+
[key: string]: unknown;
|
|
1344
|
+
}): void;
|
|
1345
|
+
/** Check whether the `other` behavior is a dependent behavior of this behavior */
|
|
1346
|
+
hasBehavior(other: string | GeneralBehavior): boolean;
|
|
1347
|
+
/**
|
|
1348
|
+
* Get the methods
|
|
1349
|
+
*
|
|
1350
|
+
* Only valid after `prepare` .
|
|
1351
|
+
*/
|
|
1352
|
+
getMethods(): TMethod;
|
|
1353
|
+
}
|
|
1354
|
+
type GeneralBehavior = Behavior<Record<string, any>, Record<string, any>, Record<string, any>, any>;
|
|
1355
|
+
|
|
1356
|
+
type Lifetimes = {
|
|
1357
|
+
created: () => void;
|
|
1358
|
+
attached: () => void;
|
|
1359
|
+
moved: () => void;
|
|
1360
|
+
detached: () => void;
|
|
1361
|
+
ready: () => void;
|
|
1362
|
+
listenerChange: (isAdd: boolean, name: string, func: EventListener<unknown>, options: EventListenerOptions | undefined) => void;
|
|
1363
|
+
workletChange: (name: string, value: unknown) => void;
|
|
1364
|
+
};
|
|
1365
|
+
declare class ComponentDefinition<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> {
|
|
1366
|
+
is: string;
|
|
1367
|
+
behavior: Behavior<TData, TProperty, TMethod, any>;
|
|
1368
|
+
general(): GeneralComponentDefinition;
|
|
1369
|
+
/** Get the normalized component options */
|
|
1370
|
+
getComponentOptions(): NormalizedComponentOptions;
|
|
1371
|
+
/**
|
|
1372
|
+
* List all component dependencies (recursively)
|
|
1373
|
+
*
|
|
1374
|
+
* This method will prepare the underlying behavior.
|
|
1375
|
+
* The caller component is not included in the result.
|
|
1376
|
+
*/
|
|
1377
|
+
getComponentDependencies(): Set<GeneralComponentDefinition>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Update the template field
|
|
1380
|
+
*
|
|
1381
|
+
* This method throws error if the template engine does not support template update.
|
|
1382
|
+
*/
|
|
1383
|
+
updateTemplate(template: {
|
|
1384
|
+
[key: string]: unknown;
|
|
1385
|
+
}): void;
|
|
1386
|
+
isPrepared(): boolean;
|
|
1387
|
+
prepare(): void;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* A node that has a shadow tree attached to it
|
|
1391
|
+
*/
|
|
1392
|
+
declare class Component<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList> extends Element$4 {
|
|
1393
|
+
[COMPONENT_SYMBOL]: true;
|
|
1394
|
+
shadowRoot: ShadowRoot | ExternalShadowRoot;
|
|
1395
|
+
tagName: string;
|
|
1396
|
+
constructor();
|
|
1397
|
+
general(): GeneralComponent;
|
|
1398
|
+
static isComponent: (e: any) => e is GeneralComponent;
|
|
1399
|
+
/**
|
|
1400
|
+
* Cast a general component node to the instance of the specified component
|
|
1401
|
+
*
|
|
1402
|
+
* Returns `null` if the component node is not the instance of the specified component.
|
|
1403
|
+
*/
|
|
1404
|
+
asInstanceOf<UData extends DataList, UProperty extends PropertyList, UMethod extends MethodList>(componentDefinition: ComponentDefinition<UData, UProperty, UMethod>): ComponentInstance<UData, UProperty, UMethod> | null;
|
|
1405
|
+
static register<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>, space?: ComponentSpace): ComponentDefinition<TData, TProperty, TMethod>;
|
|
1406
|
+
static createWithGenericsAndContext<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(tagName: string | ComponentDefinition<TData, TProperty, TMethod>, componentDefinition: ComponentDefinition<TData, TProperty, TMethod> | null, genericTargets: {
|
|
1407
|
+
[name: string]: GeneralComponentDefinition;
|
|
1408
|
+
} | null, backendContext: GeneralBackendContext | null, initPropValues?: (comp: ComponentInstance<TData, TProperty, TMethod>) => void): ComponentInstance<TData, TProperty, TMethod>;
|
|
1409
|
+
static createWithGenerics<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(tagName: string | ComponentDefinition<TData, TProperty, TMethod>, componentDefinition: ComponentDefinition<TData, TProperty, TMethod> | null, genericImpls: {
|
|
1410
|
+
[name: string]: GeneralComponentDefinition;
|
|
1411
|
+
} | null, initPropValues?: (comp: ComponentInstance<TData, TProperty, TMethod>) => void): ComponentInstance<TData, TProperty, TMethod>;
|
|
1412
|
+
static createWithContext<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(tagName: string | ComponentDefinition<TData, TProperty, TMethod>, componentDefinition: ComponentDefinition<TData, TProperty, TMethod> | null, backendContext: GeneralBackendContext | null, initPropValues?: (comp: ComponentInstance<TData, TProperty, TMethod>) => void): ComponentInstance<TData, TProperty, TMethod>;
|
|
1413
|
+
static create<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(tagName: string | ComponentDefinition<TData, TProperty, TMethod>, componentDefinition: ComponentDefinition<TData, TProperty, TMethod> | null, initPropValues?: (comp: ComponentInstance<TData, TProperty, TMethod>) => void): ComponentInstance<TData, TProperty, TMethod>;
|
|
1414
|
+
get is(): string;
|
|
1415
|
+
get properties(): Merge<DataWithPropertyValues<TData, TProperty>>;
|
|
1416
|
+
get data(): Merge<DataWithPropertyValues<TData, TProperty>>;
|
|
1417
|
+
set data(newData: Partial<DataWithPropertyValues<TData, TProperty>>);
|
|
1418
|
+
get $(): {
|
|
1419
|
+
[id: string]: Element$4;
|
|
1420
|
+
} | {
|
|
1421
|
+
[id: string]: GeneralBackendElement;
|
|
1422
|
+
};
|
|
1423
|
+
/**
|
|
1424
|
+
* Returns the shadow root element
|
|
1425
|
+
*
|
|
1426
|
+
* Returns `null` for external components.
|
|
1427
|
+
*/
|
|
1428
|
+
getShadowRoot(): ShadowRoot | null;
|
|
1429
|
+
/**
|
|
1430
|
+
* Apply the template updates to this component instance
|
|
1431
|
+
*
|
|
1432
|
+
* This method throws error if the template engine does not support template update.
|
|
1433
|
+
*/
|
|
1434
|
+
applyTemplateUpdates(): void;
|
|
1435
|
+
/**
|
|
1436
|
+
* Returns the owner component space of this component
|
|
1437
|
+
*/
|
|
1438
|
+
getOwnerSpace(): ComponentSpace;
|
|
1439
|
+
/** Get whether the component is external or not */
|
|
1440
|
+
isExternal(): boolean;
|
|
1441
|
+
static listProperties<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: ComponentInstance<TData, TProperty, TMethod>): string[];
|
|
1442
|
+
static hasProperty<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: Component<TData, TProperty, TMethod>, propName: string): boolean;
|
|
1443
|
+
/** List methods by the component definition (backward compatibility) */
|
|
1444
|
+
static getMethodsFromDef<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(compDef: ComponentDefinition<TData, TProperty, TMethod>): {
|
|
1445
|
+
[name: string]: GeneralFuncType;
|
|
1446
|
+
};
|
|
1447
|
+
/**
|
|
1448
|
+
* Get a method
|
|
1449
|
+
*
|
|
1450
|
+
* If `useMethodCallerListeners` option is set for this component,
|
|
1451
|
+
* this method will use the corresponding fields in the `methodCaller` .
|
|
1452
|
+
*/
|
|
1453
|
+
static getMethod<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: Component<TData, TProperty, TMethod>, methodName: string): GeneralFuncType | undefined;
|
|
1454
|
+
/**
|
|
1455
|
+
* Call a method
|
|
1456
|
+
*
|
|
1457
|
+
* If `useMethodCallerListeners` option is set for this component,
|
|
1458
|
+
* this method will use the corresponding fields in the `methodCaller` .
|
|
1459
|
+
* Returns `undefined` if there is no such method.
|
|
1460
|
+
*/
|
|
1461
|
+
callMethod<T extends string>(methodName: T, ...args: Parameters<MethodList[T]>): ReturnType<MethodList[T]>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Get the corresponding component definition
|
|
1464
|
+
*/
|
|
1465
|
+
getComponentDefinition(): ComponentDefinition<TData, TProperty, TMethod>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Get the options of the component
|
|
1468
|
+
*/
|
|
1469
|
+
getComponentOptions(): NormalizedComponentOptions;
|
|
1470
|
+
/**
|
|
1471
|
+
* Check whether the `other` behavior is a dependent behavior or a implemented trait behavior
|
|
1472
|
+
*/
|
|
1473
|
+
hasBehavior(other: string | GeneralBehavior | TraitBehavior<any, any>): boolean;
|
|
1474
|
+
/** Get the root behavior of the component */
|
|
1475
|
+
getRootBehavior(): Behavior<TData, TProperty, TMethod, any>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Get the trait behavior implementation of the component
|
|
1478
|
+
*
|
|
1479
|
+
* Returns `undefined` if the specified trait behavior is not implemented.
|
|
1480
|
+
*/
|
|
1481
|
+
traitBehavior<TOut extends {
|
|
1482
|
+
[x: string]: any;
|
|
1483
|
+
}>(traitBehavior: TraitBehavior<any, TOut>): TOut | undefined;
|
|
1484
|
+
/**
|
|
1485
|
+
* Set the caller (a.k.a. `this` ) of event callbacks and life-time callbacks
|
|
1486
|
+
*
|
|
1487
|
+
* By default, the caller is the component instance itself.
|
|
1488
|
+
* Use this method to override this behavior.
|
|
1489
|
+
*/
|
|
1490
|
+
setMethodCaller(caller: ComponentInstance<TData, TProperty, TMethod>): void;
|
|
1491
|
+
/**
|
|
1492
|
+
* Get the current caller set by `setMethodCaller`
|
|
1493
|
+
*/
|
|
1494
|
+
getMethodCaller(): ComponentInstance<TData, TProperty, TMethod>;
|
|
1495
|
+
/**
|
|
1496
|
+
* Triggers a life-time callback on an element
|
|
1497
|
+
*
|
|
1498
|
+
* Normally external life-times should only be triggered by template engine.
|
|
1499
|
+
* Most cases should take a common method instead.
|
|
1500
|
+
*/
|
|
1501
|
+
triggerLifetime(name: string, args: Parameters<GeneralFuncType>): void;
|
|
1502
|
+
/**
|
|
1503
|
+
* Triggers a page-life-time callback on an element
|
|
1504
|
+
*/
|
|
1505
|
+
triggerPageLifetime(name: string, args: Parameters<GeneralFuncType>): void;
|
|
1506
|
+
/**
|
|
1507
|
+
* Get the target elements of a relation
|
|
1508
|
+
*/
|
|
1509
|
+
getRelationNodes(relationKey: string): GeneralComponent[];
|
|
1510
|
+
/** Check the existence of an external class */
|
|
1511
|
+
hasExternalClass(name: string): boolean;
|
|
1512
|
+
/** Update an external class value */
|
|
1513
|
+
setExternalClass(name: string, target: string | string[]): void;
|
|
1514
|
+
/** Get all external classes */
|
|
1515
|
+
getExternalClasses(): string[] | undefined;
|
|
1516
|
+
/** Schedule an update for an external class value */
|
|
1517
|
+
scheduleExternalClassChange(name: string, target: string | string[]): void;
|
|
1518
|
+
/** Update multiple external class values */
|
|
1519
|
+
applyExternalClassChanges(): void;
|
|
1520
|
+
/** Triggers a worklet change lifetime */
|
|
1521
|
+
triggerWorkletChangeLifetime(name: string, value: unknown): void;
|
|
1522
|
+
/** Check a field is excluded by pureDataPattern or not */
|
|
1523
|
+
isInnerDataExcluded(fieldName: string): boolean;
|
|
1524
|
+
static getInnerData<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: Component<TData, TProperty, TMethod>): {
|
|
1525
|
+
[key: string]: DataValue;
|
|
1526
|
+
} | null;
|
|
1527
|
+
static getDataProxy<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: Component<TData, TProperty, TMethod>): DataGroup<TData, TProperty, TMethod>;
|
|
1528
|
+
static replaceWholeData<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(comp: Component<TData, TProperty, TMethod>, newData: DataWithPropertyValues<TData, TProperty>): void;
|
|
1529
|
+
/**
|
|
1530
|
+
* Schedule a data update on a single specified path
|
|
1531
|
+
*
|
|
1532
|
+
* The data update will not be applied until next `setData` or `applyDataUpdates` call.
|
|
1533
|
+
* All data observers will not be triggered immediately before applied.
|
|
1534
|
+
* Reads of the data will get the unchanged value before applied.
|
|
1535
|
+
*/
|
|
1536
|
+
replaceDataOnPath<T extends DataPath>(path: readonly [...T], data: GetFromDataPath<DataWithPropertyValues<TData, TProperty>, T>): void;
|
|
1537
|
+
/**
|
|
1538
|
+
* Schedule an array update
|
|
1539
|
+
*
|
|
1540
|
+
* The behavior is like `Array.prototype.slice` .
|
|
1541
|
+
* Break the array before the `index`-th item, delete `del` items, and insert some items here.
|
|
1542
|
+
* If `index` is undefined, negative, or larger than the length of the array,
|
|
1543
|
+
* no items will be deleted and new items will be appended to the end of the array.
|
|
1544
|
+
* The data update will not be applied until next `setData` or `applyDataUpdates` call.
|
|
1545
|
+
* All data observers will not be triggered immediately before applied.
|
|
1546
|
+
* Reads of the data will get the unchanged value before applied.
|
|
1547
|
+
*/
|
|
1548
|
+
spliceArrayDataOnPath<T extends DataPath>(path: readonly [...T], index: GetFromDataPath<DataWithPropertyValues<TData, TProperty>, T> extends any[] ? number | undefined : never, del: GetFromDataPath<DataWithPropertyValues<TData, TProperty>, T> extends any[] ? number | undefined : never, inserts: GetFromDataPath<DataWithPropertyValues<TData, TProperty>, T> extends (infer I)[] ? I[] : never): void;
|
|
1549
|
+
/**
|
|
1550
|
+
* Check whether there are pending changes or not
|
|
1551
|
+
*/
|
|
1552
|
+
hasPendingChanges(): boolean;
|
|
1553
|
+
/**
|
|
1554
|
+
* Apply all scheduled updates immediately
|
|
1555
|
+
*
|
|
1556
|
+
* Inside observers, it is generally not .
|
|
1557
|
+
*/
|
|
1558
|
+
applyDataUpdates(): void;
|
|
1559
|
+
/**
|
|
1560
|
+
* Pending all data updates in the callback, and apply updates after callback returns
|
|
1561
|
+
*
|
|
1562
|
+
* This function helps grouping several `replaceDataOnPath` or `spliceArrayDataOnPath` calls,
|
|
1563
|
+
* and then apply them at the end of the callback.
|
|
1564
|
+
* `setData` and `applyDataUpdates` calls inside the callback still apply updates immediately.
|
|
1565
|
+
*/
|
|
1566
|
+
groupUpdates<T>(callback: () => T): T;
|
|
1567
|
+
/**
|
|
1568
|
+
* Schedule a classic data updates
|
|
1569
|
+
*
|
|
1570
|
+
* The data update will not be applied until next `setData` or `applyDataUpdates` call.
|
|
1571
|
+
* When called inside observers, the data update will be applied when observer ends.
|
|
1572
|
+
* All data observers will not be triggered immediately before applied.
|
|
1573
|
+
* Reads of the data will get the unchanged value before applied.
|
|
1574
|
+
*/
|
|
1575
|
+
updateData(newData?: Partial<SetDataSetter<DataWithPropertyValues<TData, TProperty>>>): void;
|
|
1576
|
+
/**
|
|
1577
|
+
* Do a classic data updates
|
|
1578
|
+
*
|
|
1579
|
+
* This method apply updates immediately, so there is no async callback.
|
|
1580
|
+
* When called inside observers, the data update will not be applied to templates.
|
|
1581
|
+
* Inside observers, it is recommended to use `updateData` instead.
|
|
1582
|
+
*/
|
|
1583
|
+
setData(newData?: Partial<SetDataSetter<DataWithPropertyValues<TData, TProperty>>>): void;
|
|
1584
|
+
}
|
|
1585
|
+
type GeneralComponentDefinition = ComponentDefinition<Record<string, any>, Record<string, any>, Record<string, any>>;
|
|
1586
|
+
type GeneralComponent = Component<Record<string, any>, Record<string, any>, Record<string, any>>;
|
|
1587
|
+
type AnyComponent = Component<any, any, any>;
|
|
1588
|
+
|
|
1589
|
+
declare const enum SegmentRelation {
|
|
1590
|
+
Child = 0,
|
|
1591
|
+
Descendant = 1,
|
|
1592
|
+
CrossShadowDescendant = 2
|
|
1593
|
+
}
|
|
1594
|
+
type Segment = {
|
|
1595
|
+
id: string;
|
|
1596
|
+
classes: string[];
|
|
1597
|
+
relation: SegmentRelation;
|
|
1598
|
+
};
|
|
1599
|
+
type Union = Segment[];
|
|
1600
|
+
/** A parsed selector that can be used in selector queries */
|
|
1601
|
+
declare class ParsedSelector {
|
|
1602
|
+
unions: Union[];
|
|
1603
|
+
private static _$parseSegment;
|
|
1604
|
+
constructor(str: string);
|
|
1605
|
+
/** Whether the selector is empty */
|
|
1606
|
+
isEmpty(): boolean;
|
|
1607
|
+
private static _$testSelectorSegment;
|
|
1608
|
+
/**
|
|
1609
|
+
* Test whether the specified node matches the selector
|
|
1610
|
+
*
|
|
1611
|
+
* If `root` is specified, than the selector is match inside this subtree;
|
|
1612
|
+
* otherwise it match in the whole tree.
|
|
1613
|
+
*/
|
|
1614
|
+
testSelector(root: Element$4 | null, node: Element$4): boolean;
|
|
1615
|
+
/** Queries an element or elements that matches this selector */
|
|
1616
|
+
query(root: Element$4, findOne: boolean): Element$4[] | Element$4 | null;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* The "style" attribute and class list segments
|
|
1621
|
+
*
|
|
1622
|
+
* This allows different modules set the "style" attribute or the class list of an element
|
|
1623
|
+
* without overriding each other.
|
|
1624
|
+
* The final value is the concat of all segments.
|
|
1625
|
+
* When calling `setNodeStyle` or `setNodeClass` on an element,
|
|
1626
|
+
* a segment can be specified.
|
|
1627
|
+
*/
|
|
1628
|
+
declare const enum StyleSegmentIndex {
|
|
1629
|
+
/** The main style segment, generally managed by the template engine (or manually set) */
|
|
1630
|
+
MAIN = 0,
|
|
1631
|
+
/** The template style segment, preserved for template engine */
|
|
1632
|
+
TEMPLATE_EXTRA = 1,
|
|
1633
|
+
/** The animation style segment, preserved for temporary transition */
|
|
1634
|
+
ANIMATION_EXTRA = 2,
|
|
1635
|
+
/** The temporary style segment, preserved for high priority styles */
|
|
1636
|
+
TEMP_EXTRA = 3
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* A general element
|
|
1640
|
+
*
|
|
1641
|
+
* An element can be a `NativeNode` , a `Component` , or a `VirtualNode` .
|
|
1642
|
+
*/
|
|
1643
|
+
declare class Element$4 implements NodeCast {
|
|
1644
|
+
[ELEMENT_SYMBOL]: true;
|
|
1645
|
+
dataset: {
|
|
1646
|
+
[name: string]: unknown;
|
|
1647
|
+
};
|
|
1648
|
+
/** The `ClassList` of the element (will never change and must not be modified!) */
|
|
1649
|
+
classList: ClassList | null;
|
|
1650
|
+
/** The parent element (must not be modified directly!) */
|
|
1651
|
+
parentNode: Element$4 | null;
|
|
1652
|
+
/** The child nodes (must not be modified directly!) */
|
|
1653
|
+
childNodes: Node$1[];
|
|
1654
|
+
/** The index in parentNode.childNodes (-1 if no parentNode) (must not be modified directly!) */
|
|
1655
|
+
parentIndex: number;
|
|
1656
|
+
/** The parent slot element in composed tree (must not be modified directly!) */
|
|
1657
|
+
containingSlot: Element$4 | null | undefined;
|
|
1658
|
+
/** The slot content nodes composed tree (must not be modified directly!) */
|
|
1659
|
+
slotNodes: Node$1[] | undefined;
|
|
1660
|
+
/** The index in containingSlot.slotNodes (must not be modified directly!) */
|
|
1661
|
+
slotIndex: number | undefined;
|
|
1662
|
+
/** The shadow-root which owns the element (will never change and must not be modified!) */
|
|
1663
|
+
ownerShadowRoot: ShadowRoot | null;
|
|
1664
|
+
constructor();
|
|
1665
|
+
get $$(): GeneralBackendElement | null;
|
|
1666
|
+
get id(): string;
|
|
1667
|
+
set id(x: unknown);
|
|
1668
|
+
get slot(): string;
|
|
1669
|
+
set slot(x: string);
|
|
1670
|
+
get attributes(): {
|
|
1671
|
+
name: string;
|
|
1672
|
+
value: unknown;
|
|
1673
|
+
}[];
|
|
1674
|
+
get class(): string;
|
|
1675
|
+
set class(classNames: string);
|
|
1676
|
+
get style(): string;
|
|
1677
|
+
set style(styleText: string);
|
|
1678
|
+
asTextNode(): null;
|
|
1679
|
+
asElement(): Element$4;
|
|
1680
|
+
asNativeNode(): NativeNode | null;
|
|
1681
|
+
asVirtualNode(): VirtualNode | null;
|
|
1682
|
+
static isElement: (e: any) => e is Element$4;
|
|
1683
|
+
asInstanceOf<UData extends DataList, UProperty extends PropertyList, UMethod extends MethodList>(componentDefinition: ComponentDefinition<UData, UProperty, UMethod>): ComponentInstance<UData, UProperty, UMethod> | null;
|
|
1684
|
+
/** Get the backend context */
|
|
1685
|
+
getBackendContext(): GeneralBackendContext | null;
|
|
1686
|
+
/** Get the backend mode */
|
|
1687
|
+
getBackendMode(): BackendMode;
|
|
1688
|
+
/** Get the backend element */
|
|
1689
|
+
getBackendElement(): GeneralBackendElement | null;
|
|
1690
|
+
/** Destroy the backend element */
|
|
1691
|
+
destroyBackendElement(): void;
|
|
1692
|
+
/** Destroy the backend element on next detach */
|
|
1693
|
+
destroyBackendElementOnDetach(): void;
|
|
1694
|
+
/** Cancel destroying backend element on detach */
|
|
1695
|
+
cancelDestroyBackendElementOnDetach(): void;
|
|
1696
|
+
/** Get whether the node is virtual or not */
|
|
1697
|
+
isVirtual(): boolean;
|
|
1698
|
+
/** Set the node class */
|
|
1699
|
+
setNodeClass(classNames: string | string[], index?: StyleSegmentIndex): void;
|
|
1700
|
+
/** Toggle the node class */
|
|
1701
|
+
toggleNodeClass(classNames: string, force?: boolean, index?: StyleSegmentIndex): void;
|
|
1702
|
+
/** Set the node style */
|
|
1703
|
+
setNodeStyle(styleSegment: string, index?: StyleSegmentIndex): void;
|
|
1704
|
+
private static checkAndCallAttached;
|
|
1705
|
+
private static checkAndCallDetached;
|
|
1706
|
+
private static checkAndCallMoved;
|
|
1707
|
+
private static checkChildObservers;
|
|
1708
|
+
/**
|
|
1709
|
+
* Get whether a node has any subtree `MutationObserver` attached to it
|
|
1710
|
+
*
|
|
1711
|
+
* If there is, then tree update may have more performance impact.
|
|
1712
|
+
*/
|
|
1713
|
+
static hasSubtreeMutationObservers(node: Element$4): boolean;
|
|
1714
|
+
static insertChildReassign(shadowParent: Element$4, child: Node$1, oldSlot: Element$4 | null, newSlot: Element$4 | null, ideaPosIndex: number): void;
|
|
1715
|
+
private static findNearestNonVirtual;
|
|
1716
|
+
private static countNonVirtual;
|
|
1717
|
+
/**
|
|
1718
|
+
* Iterate elements with their slots (slots-inherited nodes included)
|
|
1719
|
+
*/
|
|
1720
|
+
static forEachNodeInSlot(node: Node$1, f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean;
|
|
1721
|
+
/**
|
|
1722
|
+
* Iterate elements in specified slot (slots-inherited nodes included)
|
|
1723
|
+
*/
|
|
1724
|
+
static forEachNodeInSpecificSlot(node: Node$1, slot: Element$4 | undefined | null, f: (node: Node$1) => boolean | void): boolean;
|
|
1725
|
+
/**
|
|
1726
|
+
* Iterate elements with their slots (slots-inherited nodes NOT included)
|
|
1727
|
+
*/
|
|
1728
|
+
static forEachSlotContentInSlot(node: Node$1, f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean;
|
|
1729
|
+
/**
|
|
1730
|
+
* Iterate elements in specified slot (slots-inherited nodes NOT included)
|
|
1731
|
+
*/
|
|
1732
|
+
static forEachSlotContentInSpecificSlot(node: Node$1, slot: Element$4 | undefined | null, f: (node: Node$1) => boolean | void): boolean;
|
|
1733
|
+
private static insertChildComposed;
|
|
1734
|
+
private static insertChildSingleOperation;
|
|
1735
|
+
private static insertChildBatchRemoval;
|
|
1736
|
+
private static insertChildBatchInsertion;
|
|
1737
|
+
private static insertChildPlaceholderReplace;
|
|
1738
|
+
appendChild(child: Node$1): void;
|
|
1739
|
+
insertChildAt(child: Node$1, index: number): void;
|
|
1740
|
+
insertBefore(child: Node$1, before?: Node$1): void;
|
|
1741
|
+
removeChildAt(index: number): void;
|
|
1742
|
+
removeChild(child: Node$1): void;
|
|
1743
|
+
replaceChildAt(child: Node$1, index: number): void;
|
|
1744
|
+
replaceChild(child: Node$1, relChild: Node$1): void;
|
|
1745
|
+
insertChildren(children: Node$1[], index: number): void;
|
|
1746
|
+
removeChildren(index: number, count: number): void;
|
|
1747
|
+
selfReplaceWith(replaceWith: Element$4): void;
|
|
1748
|
+
/** Trigger an event on the element */
|
|
1749
|
+
triggerEvent(name: string, detail?: unknown, options?: EventOptions): void;
|
|
1750
|
+
/** Trigger an event with specified event object on the element */
|
|
1751
|
+
dispatchEvent(ev: Event<unknown>): void;
|
|
1752
|
+
/** Add an event listener on the element */
|
|
1753
|
+
addListener(name: string, func: EventListener<unknown>, options?: EventListenerOptions): void;
|
|
1754
|
+
/** Remove an event listener on the element */
|
|
1755
|
+
removeListener(name: string, func: EventListener<unknown>, options?: EventListenerOptions): void;
|
|
1756
|
+
/** Get an attribute value ( `null` if not set or removed) */
|
|
1757
|
+
getAttribute(name: string): unknown;
|
|
1758
|
+
/** Update an attribute value */
|
|
1759
|
+
updateAttribute(name: string, value: unknown): void;
|
|
1760
|
+
/** Set an attribute value */
|
|
1761
|
+
setAttribute(name: string, value: unknown): void;
|
|
1762
|
+
/** Remove an attribute */
|
|
1763
|
+
removeAttribute(name: string): void;
|
|
1764
|
+
/** Set a dataset on the element */
|
|
1765
|
+
setDataset(name: string, value: unknown): void;
|
|
1766
|
+
/** Set a mark on the element */
|
|
1767
|
+
setMark(name: string, value: unknown): void;
|
|
1768
|
+
/**
|
|
1769
|
+
* Collect the marks on the element
|
|
1770
|
+
*
|
|
1771
|
+
* The marks includes the marks on ancestors (in shadow tree) of the element.
|
|
1772
|
+
* If multiple marks on different elements shares the same name,
|
|
1773
|
+
* the mark value on the child-most element is accepted.
|
|
1774
|
+
*/
|
|
1775
|
+
collectMarks(): {
|
|
1776
|
+
[name: string]: unknown;
|
|
1777
|
+
};
|
|
1778
|
+
/**
|
|
1779
|
+
* Attach the element into the backend, swapping out a placeholder element in the backend.
|
|
1780
|
+
*
|
|
1781
|
+
* The `element` must not be a child node of another element,
|
|
1782
|
+
* must not be attached before,
|
|
1783
|
+
* and must not have a `ownerShadowRoot` .
|
|
1784
|
+
* The `element` `targetParent` and `targetNode` must be in the same backend context.
|
|
1785
|
+
* The `element` replaces the `targetNode` in the `targetParent` .
|
|
1786
|
+
*/
|
|
1787
|
+
static replaceDocumentElement(element: Element$4, targetParent: GeneralBackendElement, targetNode: GeneralBackendElement): void;
|
|
1788
|
+
/**
|
|
1789
|
+
* Make the element looks like attached.
|
|
1790
|
+
*
|
|
1791
|
+
* If the element will never be attached to backend or it has no backend element at all,
|
|
1792
|
+
* this can be used to trigger `attached` life-time.
|
|
1793
|
+
*/
|
|
1794
|
+
static pretendAttached(element: Element$4): void;
|
|
1795
|
+
/**
|
|
1796
|
+
* Make the element looks like detached.
|
|
1797
|
+
*
|
|
1798
|
+
* This can be used to trigger `detached` life-time without remove the element in the backend.
|
|
1799
|
+
*/
|
|
1800
|
+
static pretendDetached(element: Element$4): void;
|
|
1801
|
+
/** Check the element is attached or not */
|
|
1802
|
+
static isAttached(element: Element$4): boolean;
|
|
1803
|
+
/**
|
|
1804
|
+
* Set the slot name of the element
|
|
1805
|
+
*
|
|
1806
|
+
* Once this method is called for an `element` ,
|
|
1807
|
+
* it will be treated as a slot which can contain child nodes in composed tree.
|
|
1808
|
+
* This method should not be used in components,
|
|
1809
|
+
* otherwise the slot content will always be dangled.
|
|
1810
|
+
*/
|
|
1811
|
+
static setSlotName(element: Element$4, name?: string): void;
|
|
1812
|
+
/**
|
|
1813
|
+
* Get the slot name of the element
|
|
1814
|
+
*/
|
|
1815
|
+
static getSlotName(element: Element$4): string | undefined;
|
|
1816
|
+
/**
|
|
1817
|
+
* Set the virtual node to slot-inherit mode
|
|
1818
|
+
*
|
|
1819
|
+
* In slot-inherit mode of an element,
|
|
1820
|
+
* the child nodes of the element will be treated as siblings and can have different target slot.
|
|
1821
|
+
*/
|
|
1822
|
+
static setInheritSlots(element: Element$4): void;
|
|
1823
|
+
/** Get whether the slot-inherit mode is set or not */
|
|
1824
|
+
static getInheritSlots(element: Element$4): boolean;
|
|
1825
|
+
/** Get whether the slot-inherit mode is set or not */
|
|
1826
|
+
isInheritSlots(): boolean;
|
|
1827
|
+
/**
|
|
1828
|
+
* Set the binding slot of specific node
|
|
1829
|
+
*
|
|
1830
|
+
* Necessary if node belongs to a dynamic slot, which cannot be identified by slot name.
|
|
1831
|
+
*/
|
|
1832
|
+
static setSlotElement(node: Node$1, slot: Element$4 | null): void;
|
|
1833
|
+
static _$updateContainingSlot(node: Node$1, containingSlot: Element$4 | null | undefined): void;
|
|
1834
|
+
static _$spliceSlotNodes(slot: Element$4, before: number, deleteCount: number, insertion: Node$1[] | undefined): void;
|
|
1835
|
+
/** Get composed parent (including virtual nodes) */
|
|
1836
|
+
getComposedParent(): Element$4 | null;
|
|
1837
|
+
/**
|
|
1838
|
+
* Get the composed children
|
|
1839
|
+
*
|
|
1840
|
+
* This method always returns a new array.
|
|
1841
|
+
* It is convenient but less performant.
|
|
1842
|
+
* For better performance, consider using `forEachComposedChild` .
|
|
1843
|
+
*/
|
|
1844
|
+
getComposedChildren(): Node$1[];
|
|
1845
|
+
/**
|
|
1846
|
+
* Iterate composed child nodes (including virtual nodes)
|
|
1847
|
+
*
|
|
1848
|
+
* if `f` returns `false` then the iteration is interrupted.
|
|
1849
|
+
* Returns `true` if that happens.
|
|
1850
|
+
*/
|
|
1851
|
+
forEachComposedChild(f: (node: Node$1) => boolean | void): boolean;
|
|
1852
|
+
/**
|
|
1853
|
+
* Iterate non-virtual composed child nodes
|
|
1854
|
+
*
|
|
1855
|
+
* if `f` returns `false` then the iteration is interrupted.
|
|
1856
|
+
* Returns `true` if that happens.
|
|
1857
|
+
*/
|
|
1858
|
+
forEachNonVirtualComposedChild(f: (node: Node$1) => boolean | void): boolean;
|
|
1859
|
+
/** Parse a selector string so that it can be used multiple queries */
|
|
1860
|
+
static parseSelector(str: string): ParsedSelector;
|
|
1861
|
+
/** Select the first descendant which matches the selector */
|
|
1862
|
+
querySelector(selectorStr: string | ParsedSelector): Element$4 | null;
|
|
1863
|
+
/** Select all descendants which matches the selector */
|
|
1864
|
+
querySelectorAll(selectorStr: string | ParsedSelector): Element$4[];
|
|
1865
|
+
/** Test whether the target matches the selector */
|
|
1866
|
+
static matchSelector(selectorStr: string | ParsedSelector, target: Element$4): boolean;
|
|
1867
|
+
/** Test whether the target in this subtree matches the selector */
|
|
1868
|
+
matchSelector(selectorStr: string | ParsedSelector, target: Element$4): boolean;
|
|
1869
|
+
/**
|
|
1870
|
+
* Get the bounding client rect
|
|
1871
|
+
*
|
|
1872
|
+
* Return zero values when the backend element is invalid or it does not have layout information.
|
|
1873
|
+
*/
|
|
1874
|
+
getBoundingClientRect(cb: (res: BoundingClientRect) => void): void;
|
|
1875
|
+
/**
|
|
1876
|
+
* Get the bounding client rect
|
|
1877
|
+
*
|
|
1878
|
+
* Return zero values when the backend element is invalid or it does not have layout information.
|
|
1879
|
+
*/
|
|
1880
|
+
getScrollOffset(cb: (res: ScrollOffset) => void): void;
|
|
1881
|
+
/**
|
|
1882
|
+
* Create an intersection observer
|
|
1883
|
+
*
|
|
1884
|
+
* The `relativeElement` is the element to calculate intersection with ( `null` for the viewport).
|
|
1885
|
+
* The `relativeElementMargin` is the margins of the `relativeElement` .
|
|
1886
|
+
* The `thresholds` is a list of intersection ratios to trigger the `listener` .
|
|
1887
|
+
* The listener always triggers once immediately after this call.
|
|
1888
|
+
*/
|
|
1889
|
+
createIntersectionObserver(relativeElement: Element$4 | null, relativeElementMargin: string, thresholds: number[], listener: (res: IntersectionStatus) => void): Observer | null;
|
|
1890
|
+
/**
|
|
1891
|
+
* Get an interactive context
|
|
1892
|
+
*/
|
|
1893
|
+
getContext(cb: (res: unknown) => void): void;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
declare const BM: {
|
|
1897
|
+
DYNAMIC: boolean;
|
|
1898
|
+
SHADOW: boolean;
|
|
1899
|
+
COMPOSED: boolean;
|
|
1900
|
+
DOMLIKE: boolean;
|
|
1901
|
+
};
|
|
1902
|
+
declare const enum BackendMode {
|
|
1903
|
+
Shadow = 1,
|
|
1904
|
+
Composed = 2,
|
|
1905
|
+
Domlike = 3
|
|
1906
|
+
}
|
|
1907
|
+
type BoundingClientRect = {
|
|
1908
|
+
left: number;
|
|
1909
|
+
top: number;
|
|
1910
|
+
width: number;
|
|
1911
|
+
height: number;
|
|
1912
|
+
};
|
|
1913
|
+
type ScrollOffset = {
|
|
1914
|
+
scrollLeft: number;
|
|
1915
|
+
scrollTop: number;
|
|
1916
|
+
scrollWidth: number;
|
|
1917
|
+
scrollHeight: number;
|
|
1918
|
+
};
|
|
1919
|
+
type CSSProperty = {
|
|
1920
|
+
name: string;
|
|
1921
|
+
value: string;
|
|
1922
|
+
disabled: boolean;
|
|
1923
|
+
invalid: boolean;
|
|
1924
|
+
};
|
|
1925
|
+
type CSSRule = {
|
|
1926
|
+
sheetIndex: number;
|
|
1927
|
+
ruleIndex: number;
|
|
1928
|
+
mediaQueries: string[];
|
|
1929
|
+
selector: string;
|
|
1930
|
+
properties: CSSProperty[];
|
|
1931
|
+
weightHighBits: number;
|
|
1932
|
+
weightLowBits: number;
|
|
1933
|
+
};
|
|
1934
|
+
type GetMatchedRulesResponses = {
|
|
1935
|
+
inline: CSSProperty[];
|
|
1936
|
+
rules: CSSRule[];
|
|
1937
|
+
};
|
|
1938
|
+
type GetAllComputedStylesResponses = {
|
|
1939
|
+
properties: CSSProperty[];
|
|
1940
|
+
};
|
|
1941
|
+
interface Observer {
|
|
1942
|
+
disconnect(): void;
|
|
1943
|
+
}
|
|
1944
|
+
type IntersectionStatus = {
|
|
1945
|
+
intersectionRatio: number;
|
|
1946
|
+
boundingClientRect: BoundingClientRect;
|
|
1947
|
+
intersectionRect: BoundingClientRect;
|
|
1948
|
+
relativeRect: BoundingClientRect;
|
|
1949
|
+
time: number;
|
|
1950
|
+
};
|
|
1951
|
+
type MediaQueryStatus = {
|
|
1952
|
+
minWidth?: number;
|
|
1953
|
+
maxWidth?: number;
|
|
1954
|
+
width?: number;
|
|
1955
|
+
minHeight?: number;
|
|
1956
|
+
maxHeight?: number;
|
|
1957
|
+
height?: number;
|
|
1958
|
+
orientation?: string;
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
interface GetWrapper<T> {
|
|
1962
|
+
get(): T;
|
|
1963
|
+
}
|
|
1964
|
+
type Element$3<E> = {
|
|
1965
|
+
getAllComputedStyles(cb: (res: GetAllComputedStylesResponses) => void): void;
|
|
1966
|
+
getBoundingClientRect(cb: (res: BoundingClientRect) => void): void;
|
|
1967
|
+
createIntersectionObserver(relativeElement: E | null, relativeElementMargin: string, thresholds: number[], listener: (res: IntersectionStatus) => void): Observer;
|
|
1968
|
+
getMatchedRules(cb: (res: GetMatchedRulesResponses) => void): void;
|
|
1969
|
+
getScrollOffset(cb: (res: ScrollOffset) => void): void;
|
|
1970
|
+
setScrollPosition(scrollLeft: number, scrollTop: number, duration: number): void;
|
|
1971
|
+
getContext(cb: (res: unknown) => void): void;
|
|
1972
|
+
};
|
|
1973
|
+
type ElementForDomLike = {
|
|
1974
|
+
getBoundingClientRect(): BoundingClientRect;
|
|
1975
|
+
readonly scrollLeft: number;
|
|
1976
|
+
readonly scrollTop: number;
|
|
1977
|
+
readonly scrollWidth: number;
|
|
1978
|
+
readonly scrollHeight: number;
|
|
1979
|
+
};
|
|
1980
|
+
interface Context$3<Ctx> {
|
|
1981
|
+
createContext(options: unknown, cb: (ContextWrapper: GetWrapper<Partial<Context$3<Ctx> & Ctx>>) => void): void;
|
|
1982
|
+
setFocusedNode(target: Node$1): void;
|
|
1983
|
+
getFocusedNode(cb: (node: Node$1 | undefined) => void): void;
|
|
1984
|
+
onWindowResize(cb: (res: {
|
|
1985
|
+
width: number;
|
|
1986
|
+
height: number;
|
|
1987
|
+
devicePixelRatio: number;
|
|
1988
|
+
}) => void): void;
|
|
1989
|
+
onThemeChange(cb: (res: {
|
|
1990
|
+
theme: string;
|
|
1991
|
+
}) => void): void;
|
|
1992
|
+
elementFromPoint(left: number, top: number, cb: (node: Node$1) => void): void;
|
|
1993
|
+
createMediaQueryObserver(status: MediaQueryStatus, listener: (res: {
|
|
1994
|
+
matches: boolean;
|
|
1995
|
+
}) => void): Observer;
|
|
1996
|
+
addStyleSheetRule(mediaQueryStr: string, selector: string, callback: (ruleIndex: number | null) => void): void;
|
|
1997
|
+
getStyleSheetIndexForNewRules(callback: (sheetIndex: number) => void): void;
|
|
1998
|
+
resetStyleSheetRule(sheetIndex: number, ruleIndex: number, callback: (ruleIndex: number | null) => void): void;
|
|
1999
|
+
modifyStyleSheetRuleSelector(sheetIndex: number, ruleIndex: number, selector: string, callback: (ruleIndex: number | null) => void): void;
|
|
2000
|
+
addStyleSheetProperty(sheetIndex: number, ruleIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void;
|
|
2001
|
+
replaceStyleSheetAllProperties(sheetIndex: number, ruleIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void;
|
|
2002
|
+
setStyleSheetPropertyDisabled(sheetIndex: number, ruleIndex: number, propertyIndex: number, disabled: boolean, callback: (propertyIndex: number | null) => void): void;
|
|
2003
|
+
removeStyleSheetProperty(sheetIndex: number, ruleIndex: number, propertyIndex: number, callback: (propertyIndex: number | null) => void): void;
|
|
2004
|
+
replaceStyleSheetProperty(sheetIndex: number, ruleIndex: number, propertyIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void;
|
|
2005
|
+
performanceTraceStart(): number;
|
|
2006
|
+
performanceTraceEnd(id: number, cb: (stats: {
|
|
2007
|
+
startTimestamp: number;
|
|
2008
|
+
endTimestamp: number;
|
|
2009
|
+
}) => void): void;
|
|
2010
|
+
}
|
|
2011
|
+
type UnshiftTarget<Fn, T> = Fn extends (...args: infer Args) => infer Ret ? (target: T, ...args: Args) => Ret : never;
|
|
2012
|
+
type UnshiftTargets<T, E> = {
|
|
2013
|
+
[K in keyof T]: UnshiftTarget<T[K], E>;
|
|
2014
|
+
};
|
|
2015
|
+
type ContextForDomLike<Ctx> = Context$3<Ctx> & UnshiftTargets<Pick<Element$3<Ctx>, 'getAllComputedStyles' | 'createIntersectionObserver' | 'getMatchedRules' | 'setScrollPosition' | 'getContext'>, Ctx>;
|
|
2016
|
+
|
|
2017
|
+
interface Context$2 extends Partial<Context$3<Context$2>> {
|
|
2018
|
+
mode: BackendMode.Shadow;
|
|
2019
|
+
destroy(): void;
|
|
2020
|
+
getWindowWidth(): number;
|
|
2021
|
+
getWindowHeight(): number;
|
|
2022
|
+
getDevicePixelRatio(): number;
|
|
2023
|
+
getTheme(): string;
|
|
2024
|
+
registerStyleSheetContent(path: string, content: unknown): void;
|
|
2025
|
+
appendStyleSheetPath(path: string, styleScope?: number): number;
|
|
2026
|
+
disableStyleSheet(index: number): void;
|
|
2027
|
+
render(cb: (err: Error | null) => void): void;
|
|
2028
|
+
getRootNode(): ShadowRootContext;
|
|
2029
|
+
createFragment(): Element$2;
|
|
2030
|
+
onEvent(createEvent: (type: string, detail: unknown, options: EventOptions) => Event<unknown>, listener: (event: Event<unknown>, currentTarget: Element$4, mark: Record<string, unknown> | null, target: Element$4, isCapture: boolean) => EventBubbleStatus | void): void;
|
|
2031
|
+
}
|
|
2032
|
+
interface Element$2 extends Partial<Element$3<Element$2>> {
|
|
2033
|
+
release(): void;
|
|
2034
|
+
associateValue(v: Element$4): void;
|
|
2035
|
+
getShadowRoot(): ShadowRootContext | undefined;
|
|
2036
|
+
appendChild(child: Element$2): void;
|
|
2037
|
+
removeChild(child: Element$2, index?: number): void;
|
|
2038
|
+
insertBefore(child: Element$2, before: Element$2, index?: number): void;
|
|
2039
|
+
replaceChild(child: Element$2, oldChild: Element$2, index?: number): void;
|
|
2040
|
+
spliceBefore(before: Element$2, deleteCount: number, list: Element$2): void;
|
|
2041
|
+
spliceAppend(list: Element$2): void;
|
|
2042
|
+
spliceRemove(before: Element$2, deleteCount: number): void;
|
|
2043
|
+
setId(id: string): void;
|
|
2044
|
+
setSlotName(slot: string): void;
|
|
2045
|
+
setContainingSlot(slot: Element$2 | undefined | null): void;
|
|
2046
|
+
reassignContainingSlot(oldSlot: Element$2 | null, newSlot: Element$2 | null): void;
|
|
2047
|
+
spliceBeforeSlotNodes(before: number, deleteCount: number, list: Element$2): void;
|
|
2048
|
+
spliceAppendSlotNodes(list: Element$2): void;
|
|
2049
|
+
spliceRemoveSlotNodes(before: number, deleteCount: number): void;
|
|
2050
|
+
setInheritSlots(): void;
|
|
2051
|
+
setStyle(styleText: string): void;
|
|
2052
|
+
addClass(className: string): void;
|
|
2053
|
+
removeClass(className: string): void;
|
|
2054
|
+
clearClasses(): void;
|
|
2055
|
+
setClassAlias(className: string, targets: string[]): void;
|
|
2056
|
+
setAttribute(name: string, value: unknown): void;
|
|
2057
|
+
removeAttribute(name: string): void;
|
|
2058
|
+
setDataset(name: string, value: unknown): void;
|
|
2059
|
+
setText(content: string): void;
|
|
2060
|
+
setModelBindingStat(attributeName: string, listener: ((newValue: unknown) => void) | null): void;
|
|
2061
|
+
setListenerStats(type: string, capture: boolean, mutLevel: MutLevel): void;
|
|
2062
|
+
}
|
|
2063
|
+
interface ShadowRootContext extends Element$2 {
|
|
2064
|
+
createElement(logicalName: string, stylingName: string): Element$2;
|
|
2065
|
+
createTextNode(content: string): Element$2;
|
|
2066
|
+
createComponent(tagName: string, external: boolean, virtualHost: boolean, styleScope: number, extraStyleScope: number | null, externalClasses: string[] | undefined): Element$2;
|
|
2067
|
+
createVirtualNode(virtualName: string): Element$2;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
declare const backend_BM: typeof BM;
|
|
2071
|
+
type backend_BackendMode = BackendMode;
|
|
2072
|
+
declare const backend_BackendMode: typeof BackendMode;
|
|
2073
|
+
type backend_BoundingClientRect = BoundingClientRect;
|
|
2074
|
+
type backend_CSSProperty = CSSProperty;
|
|
2075
|
+
type backend_CSSRule = CSSRule;
|
|
2076
|
+
type backend_GetAllComputedStylesResponses = GetAllComputedStylesResponses;
|
|
2077
|
+
type backend_GetMatchedRulesResponses = GetMatchedRulesResponses;
|
|
2078
|
+
type backend_IntersectionStatus = IntersectionStatus;
|
|
2079
|
+
type backend_MediaQueryStatus = MediaQueryStatus;
|
|
2080
|
+
type backend_Observer = Observer;
|
|
2081
|
+
type backend_ScrollOffset = ScrollOffset;
|
|
2082
|
+
type backend_ShadowRootContext = ShadowRootContext;
|
|
2083
|
+
declare namespace backend {
|
|
2084
|
+
export { backend_BM as BM, backend_BackendMode as BackendMode, type backend_BoundingClientRect as BoundingClientRect, type backend_CSSProperty as CSSProperty, type backend_CSSRule as CSSRule, type Context$2 as Context, type Element$2 as Element, type backend_GetAllComputedStylesResponses as GetAllComputedStylesResponses, type backend_GetMatchedRulesResponses as GetMatchedRulesResponses, type backend_IntersectionStatus as IntersectionStatus, type backend_MediaQueryStatus as MediaQueryStatus, type backend_Observer as Observer, type backend_ScrollOffset as ScrollOffset, type backend_ShadowRootContext as ShadowRootContext };
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
interface Context$1 extends Partial<Context$3<Context$1>> {
|
|
2088
|
+
mode: BackendMode.Composed;
|
|
2089
|
+
destroy(): void;
|
|
2090
|
+
getWindowWidth(): number;
|
|
2091
|
+
getWindowHeight(): number;
|
|
2092
|
+
getDevicePixelRatio(): number;
|
|
2093
|
+
getTheme(): string;
|
|
2094
|
+
registerStyleSheetContent(path: string, content: unknown): void;
|
|
2095
|
+
appendStyleSheetPath(path: string, styleScope?: number): number;
|
|
2096
|
+
disableStyleSheet(index: number): void;
|
|
2097
|
+
render(cb: (err: Error | null) => void): void;
|
|
2098
|
+
getRootNode(): Element$1;
|
|
2099
|
+
createElement(logicalName: string, stylingName: string): Element$1;
|
|
2100
|
+
createTextNode(content: string): Element$1;
|
|
2101
|
+
createFragment(): Element$1;
|
|
2102
|
+
onEvent(listener: (target: Element$4, type: string, detail: unknown, options: EventOptions) => EventBubbleStatus | void): void;
|
|
2103
|
+
}
|
|
2104
|
+
interface Element$1 extends Partial<Element$3<Element$1>> {
|
|
2105
|
+
release(): void;
|
|
2106
|
+
associateValue(v: Element$4): void;
|
|
2107
|
+
appendChild(child: Element$1): void;
|
|
2108
|
+
removeChild(child: Element$1, index?: number): void;
|
|
2109
|
+
insertBefore(child: Element$1, before: Element$1, index?: number): void;
|
|
2110
|
+
replaceChild(child: Element$1, oldChild: Element$1, index?: number): void;
|
|
2111
|
+
spliceBefore(before: Element$1, deleteCount: number, list: Element$1): void;
|
|
2112
|
+
spliceAppend(list: Element$1): void;
|
|
2113
|
+
spliceRemove(before: Element$1, deleteCount: number): void;
|
|
2114
|
+
setId(id: string): void;
|
|
2115
|
+
setStyleScope(styleScope: number, extraStyleScope?: number, hostStyleScope?: number): void;
|
|
2116
|
+
setStyle(styleText: string): void;
|
|
2117
|
+
addClass(elementClass: string, styleScope?: number): void;
|
|
2118
|
+
removeClass(elementClass: string, styleScope?: number): void;
|
|
2119
|
+
clearClasses(): void;
|
|
2120
|
+
setAttribute(name: string, value: unknown): void;
|
|
2121
|
+
removeAttribute(name: string): void;
|
|
2122
|
+
setText(content: string): void;
|
|
2123
|
+
setModelBindingStat(attributeName: string, listener: ((newValue: unknown) => void) | null): void;
|
|
2124
|
+
setListenerStats(type: string, capture: boolean, mutLevel: MutLevel): void;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
declare namespace composedBackend {
|
|
2128
|
+
export type { Context$1 as Context, Element$1 as Element };
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
interface Context extends Partial<ContextForDomLike<Element>> {
|
|
2132
|
+
mode: BackendMode.Domlike;
|
|
2133
|
+
destroy(): void;
|
|
2134
|
+
getWindowWidth(): number;
|
|
2135
|
+
getWindowHeight(): number;
|
|
2136
|
+
getDevicePixelRatio(): number;
|
|
2137
|
+
getTheme(): string;
|
|
2138
|
+
registerStyleSheetContent(path: string, content: unknown): void;
|
|
2139
|
+
appendStyleSheetPath(path: string, styleScope?: number): number;
|
|
2140
|
+
disableStyleSheet(index: number): void;
|
|
2141
|
+
render(cb: (err: Error | null) => void): void;
|
|
2142
|
+
getRootNode(): Element;
|
|
2143
|
+
document: {
|
|
2144
|
+
createElement(tagName: string): Element;
|
|
2145
|
+
createTextNode(content: string): Element;
|
|
2146
|
+
createDocumentFragment(): Element;
|
|
2147
|
+
};
|
|
2148
|
+
associateValue(element: Element, value: Element$4): void;
|
|
2149
|
+
onEvent(listener: (target: Element$4, type: string, detail: unknown, options: EventOptions) => EventBubbleStatus | void): void;
|
|
2150
|
+
setListenerStats(element: Element, type: string, capture: boolean, mutLevel: MutLevel): void;
|
|
2151
|
+
setModelBindingStat(element: Element, attributeName: string, listener: ((newValue: unknown) => void) | null): void;
|
|
2152
|
+
}
|
|
2153
|
+
interface Element extends Partial<ElementForDomLike> {
|
|
2154
|
+
_$wxArgs?: {
|
|
2155
|
+
modelListeners: {
|
|
2156
|
+
[name: string]: ((newValue: unknown) => void) | null;
|
|
2157
|
+
};
|
|
2158
|
+
};
|
|
2159
|
+
__wxElement?: Element$4;
|
|
2160
|
+
appendChild(child: Element): void;
|
|
2161
|
+
removeChild(child: Element, index?: number): void;
|
|
2162
|
+
insertBefore(child: Element, before?: Element, index?: number): void;
|
|
2163
|
+
replaceChild(child: Element, oldChild?: Element, index?: number): void;
|
|
2164
|
+
tagName: string;
|
|
2165
|
+
id: string;
|
|
2166
|
+
classList: {
|
|
2167
|
+
add(elementClass: string): void;
|
|
2168
|
+
remove(elementClass: string): void;
|
|
2169
|
+
};
|
|
2170
|
+
setAttribute(name: string, value: unknown): void;
|
|
2171
|
+
removeAttribute(name: string): void;
|
|
2172
|
+
textContent: string;
|
|
2173
|
+
nextSibling: Element | undefined;
|
|
2174
|
+
childNodes: Element[];
|
|
2175
|
+
parentNode: Element | null;
|
|
2176
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
2177
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
type domlikeBackend_Context = Context;
|
|
2181
|
+
type domlikeBackend_Element = Element;
|
|
2182
|
+
declare namespace domlikeBackend {
|
|
2183
|
+
export type { domlikeBackend_Context as Context, domlikeBackend_Element as Element };
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
type GeneralBackendContext = Context$2 | Context$1 | Context;
|
|
2187
|
+
type GeneralBackendElement = Element$2 | Element$1 | Element;
|
|
2188
|
+
|
|
2189
|
+
declare class CurrentWindowBackendContext implements Context {
|
|
2190
|
+
mode: BackendMode.Domlike;
|
|
2191
|
+
document: {
|
|
2192
|
+
createElement(tagName: string): Element;
|
|
2193
|
+
createTextNode(content: string): Element;
|
|
2194
|
+
createDocumentFragment(): Element;
|
|
2195
|
+
};
|
|
2196
|
+
destroy(): void;
|
|
2197
|
+
getWindowWidth(): number;
|
|
2198
|
+
getWindowHeight(): number;
|
|
2199
|
+
getDevicePixelRatio(): number;
|
|
2200
|
+
getTheme(): string;
|
|
2201
|
+
registerStyleSheetContent(path: string, content: unknown): void;
|
|
2202
|
+
appendStyleSheetPath(path: string, styleScope?: number): number;
|
|
2203
|
+
disableStyleSheet(index: number): void;
|
|
2204
|
+
render(cb: (err: Error | null) => void): void;
|
|
2205
|
+
getRootNode(): Element;
|
|
2206
|
+
associateValue(element: Element, value: Element$4): void;
|
|
2207
|
+
onEvent(listener: (target: Element$4, type: string, detail: any, options: EventOptions) => EventBubbleStatus | void): void;
|
|
2208
|
+
setListenerStats(element: Element, type: string, capture: boolean, mutLevel: MutLevel): void;
|
|
2209
|
+
setModelBindingStat(element: Element, attributeName: string, listener: ((newValue: unknown) => void) | null): void;
|
|
2210
|
+
createIntersectionObserver(targetElement: Element, relativeElement: Element | null, relativeElementMargin: string, thresholds: number[], listener: (res: IntersectionStatus) => void): Observer;
|
|
2211
|
+
createMediaQueryObserver(status: MediaQueryStatus, listener: (res: {
|
|
2212
|
+
matches: boolean;
|
|
2213
|
+
}) => void): Observer;
|
|
2214
|
+
getContext(element: Element, cb: (res: unknown) => void): void;
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
declare const enum EmptyBackendElementType {
|
|
2218
|
+
Fragment = 0,
|
|
2219
|
+
Element = 1,
|
|
2220
|
+
TextNode = 2,
|
|
2221
|
+
Component = 3,
|
|
2222
|
+
VirtualNode = 4
|
|
2223
|
+
}
|
|
2224
|
+
/** An empty backend implementation */
|
|
2225
|
+
declare class EmptyBackendContext implements Context$2 {
|
|
2226
|
+
mode: BackendMode.Shadow;
|
|
2227
|
+
destroy(): void;
|
|
2228
|
+
getWindowWidth(): number;
|
|
2229
|
+
getWindowHeight(): number;
|
|
2230
|
+
getDevicePixelRatio(): number;
|
|
2231
|
+
getTheme(): string;
|
|
2232
|
+
registerStyleSheetContent(_path: string, _content: unknown): void;
|
|
2233
|
+
appendStyleSheetPath(_path: string, _styleScope?: number): number;
|
|
2234
|
+
disableStyleSheet(_index: number): void;
|
|
2235
|
+
render(cb: (err: Error | null) => void): void;
|
|
2236
|
+
getRootNode(): EmptyBackendShadowRootContext;
|
|
2237
|
+
createFragment(): EmptyBackendElement;
|
|
2238
|
+
onEvent(_createEvent: (type: string, detail: unknown, options: EventOptions) => Event<unknown>, _listener: (event: Event<unknown>, currentTarget: Element$4, mark: Record<string, unknown> | null, target: Element$4, isCapture: boolean) => EventBubbleStatus): void;
|
|
2239
|
+
}
|
|
2240
|
+
/** An element for empty backend implementation */
|
|
2241
|
+
declare class EmptyBackendElement implements Element$2 {
|
|
2242
|
+
private _$shadowRoot;
|
|
2243
|
+
constructor(type: EmptyBackendElementType);
|
|
2244
|
+
release(): void;
|
|
2245
|
+
associateValue(_v: Element$4): void;
|
|
2246
|
+
getShadowRoot(): EmptyBackendShadowRootContext | undefined;
|
|
2247
|
+
appendChild(_child: EmptyBackendElement): void;
|
|
2248
|
+
removeChild(_child: EmptyBackendElement, _index: number): void;
|
|
2249
|
+
insertBefore(_child: EmptyBackendElement, _before: EmptyBackendElement, _index: number): void;
|
|
2250
|
+
replaceChild(_child: EmptyBackendElement, _oldChild: EmptyBackendElement, _index?: number): void;
|
|
2251
|
+
spliceBefore(_before: EmptyBackendElement, _deleteCount: number, _list: EmptyBackendElement): void;
|
|
2252
|
+
spliceAppend(_list: EmptyBackendElement): void;
|
|
2253
|
+
spliceRemove(_before: EmptyBackendElement, _deleteCount: number): void;
|
|
2254
|
+
setId(_id: string): void;
|
|
2255
|
+
setSlotName(_name: string): void;
|
|
2256
|
+
setContainingSlot(_slot: EmptyBackendElement | undefined | null): void;
|
|
2257
|
+
reassignContainingSlot(_oldSlot: Element$2 | null, _newSlot: Element$2 | null): void;
|
|
2258
|
+
spliceBeforeSlotNodes(_before: number, _deleteCount: number, _list: Element$2): void;
|
|
2259
|
+
spliceRemoveSlotNodes(_before: number, _deleteCount: number): void;
|
|
2260
|
+
spliceAppendSlotNodes(_list: Element$2): void;
|
|
2261
|
+
setInheritSlots(): void;
|
|
2262
|
+
setStyle(_styleText: string): void;
|
|
2263
|
+
addClass(_className: string): void;
|
|
2264
|
+
removeClass(_className: string): void;
|
|
2265
|
+
clearClasses(): void;
|
|
2266
|
+
setClassAlias(_className: string, _target: string[]): void;
|
|
2267
|
+
setAttribute(_name: string, _value: unknown): void;
|
|
2268
|
+
removeAttribute(_name: string): void;
|
|
2269
|
+
setDataset(_name: string, _value: unknown): void;
|
|
2270
|
+
setText(_content: string): void;
|
|
2271
|
+
setListenerStats(_type: string, _capture: boolean, _mutLevel: MutLevel): void;
|
|
2272
|
+
setModelBindingStat(_attributeName: string, _listener: ((newValue: unknown) => void) | null): void;
|
|
2273
|
+
}
|
|
2274
|
+
/** A shadow root for empty backend implementation */
|
|
2275
|
+
declare class EmptyBackendShadowRootContext extends EmptyBackendElement implements ShadowRootContext {
|
|
2276
|
+
constructor();
|
|
2277
|
+
createElement(_tagName: string, _stylingName: string): EmptyBackendElement;
|
|
2278
|
+
createTextNode(_content: string): EmptyBackendElement;
|
|
2279
|
+
createComponent(_tagName: string, _external: boolean, _virtualHost: boolean, _styleScope: number, _extraStyleScope: number | null, _externalClasses: string[] | undefined): EmptyBackendElement;
|
|
2280
|
+
createVirtualNode(_virtualName: string): EmptyBackendElement;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/** An empty backend implementation */
|
|
2284
|
+
declare class EmptyComposedBackendContext implements Context$1 {
|
|
2285
|
+
mode: BackendMode.Composed;
|
|
2286
|
+
private _$styleSheetIdInc;
|
|
2287
|
+
private _$renderCallbacks;
|
|
2288
|
+
private _$rootNode;
|
|
2289
|
+
destroy(): void;
|
|
2290
|
+
getWindowWidth(): number;
|
|
2291
|
+
getWindowHeight(): number;
|
|
2292
|
+
getDevicePixelRatio(): number;
|
|
2293
|
+
getTheme(): string;
|
|
2294
|
+
registerStyleSheetContent(_path: string, _content: unknown): void;
|
|
2295
|
+
appendStyleSheetPath(_path: string, _styleScope?: number): number;
|
|
2296
|
+
disableStyleSheet(_index: number): void;
|
|
2297
|
+
render(cb: (err: Error | null) => void): void;
|
|
2298
|
+
getRootNode(): EmptyComposedBackendElement;
|
|
2299
|
+
createElement(_tagName: string, _stylingName: string): EmptyComposedBackendElement;
|
|
2300
|
+
createTextNode(_tagName: string): EmptyComposedBackendElement;
|
|
2301
|
+
createFragment(): EmptyComposedBackendElement;
|
|
2302
|
+
onEvent(_listener: (target: Element$4, type: string, detail: unknown, options: EventOptions) => EventBubbleStatus): void;
|
|
2303
|
+
createMediaQueryObserver(_status: MediaQueryStatus, _listener: (res: {
|
|
2304
|
+
matches: boolean;
|
|
2305
|
+
}) => void): Observer;
|
|
2306
|
+
}
|
|
2307
|
+
/** An element for empty backend implementation */
|
|
2308
|
+
declare class EmptyComposedBackendElement implements Element$1 {
|
|
2309
|
+
release(): void;
|
|
2310
|
+
associateValue(_v: unknown): void;
|
|
2311
|
+
appendChild(_child: EmptyComposedBackendElement): void;
|
|
2312
|
+
removeChild(_child: EmptyComposedBackendElement, _index?: number): void;
|
|
2313
|
+
insertBefore(_child: EmptyComposedBackendElement, _before: EmptyComposedBackendElement, _index?: number): void;
|
|
2314
|
+
replaceChild(_child: EmptyComposedBackendElement, _oldChild: EmptyComposedBackendElement, _index?: number): void;
|
|
2315
|
+
spliceBefore(_before: EmptyComposedBackendElement, _deleteCount: number, _list: EmptyComposedBackendElement): void;
|
|
2316
|
+
spliceAppend(_list: EmptyComposedBackendElement): void;
|
|
2317
|
+
spliceRemove(_before: EmptyComposedBackendElement, _deleteCount: number): void;
|
|
2318
|
+
setId(_id: string): void;
|
|
2319
|
+
setStyleScope(_styleScope: number, _extraStyleScope?: number, _hostStyleScope?: number): void;
|
|
2320
|
+
setStyle(_styleText: string): void;
|
|
2321
|
+
addClass(_elementClass: string, _styleScope?: number): void;
|
|
2322
|
+
removeClass(_elementClass: string, _styleScope?: number): void;
|
|
2323
|
+
clearClasses(): void;
|
|
2324
|
+
setAttribute(_name: string, _value: unknown): void;
|
|
2325
|
+
removeAttribute(_name: string): void;
|
|
2326
|
+
setText(_content: string): void;
|
|
2327
|
+
getBoundingClientRect(cb: (res: BoundingClientRect) => void): void;
|
|
2328
|
+
getScrollOffset(cb: (res: ScrollOffset) => void): void;
|
|
2329
|
+
setListenerStats(_type: string, _capture: boolean, _mutLevel: MutLevel): void;
|
|
2330
|
+
setModelBindingStat(_attributeName: string, _listener: ((newValue: unknown) => void) | null): void;
|
|
2331
|
+
createIntersectionObserver(_relativeElement: EmptyComposedBackendElement | null, _relativeElementMargin: string, _thresholds: number[], _listener: (res: IntersectionStatus) => void): Observer;
|
|
2332
|
+
getContext(cb: (res: unknown) => void): void;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
declare const simpleDeepCopy: <T>(src: T) => T;
|
|
2336
|
+
declare const deepCopy: <T>(src: T, withRecursion: boolean) => T;
|
|
2337
|
+
|
|
2338
|
+
declare const data_utils_deepCopy: typeof deepCopy;
|
|
2339
|
+
declare const data_utils_simpleDeepCopy: typeof simpleDeepCopy;
|
|
2340
|
+
declare namespace data_utils {
|
|
2341
|
+
export { data_utils_deepCopy as deepCopy, data_utils_simpleDeepCopy as simpleDeepCopy };
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
/** The iterator direction and order */
|
|
2345
|
+
declare const enum ElementIteratorType {
|
|
2346
|
+
/** Iterate all ancestors in shadow tree */
|
|
2347
|
+
ShadowAncestors = "shadow-ancestors",
|
|
2348
|
+
/** Iterate all ancestors in composed tree */
|
|
2349
|
+
ComposedAncestors = "composed-ancestors",
|
|
2350
|
+
/** Iterate all descendants in shadow tree, returning parents before their children */
|
|
2351
|
+
ShadowDescendantsRootFirst = "shadow-descendants-root-first",
|
|
2352
|
+
/** Iterate all descendants in shadow tree, returning parents after their children */
|
|
2353
|
+
ShadowDescendantsRootLast = "shadow-descendants-root-last",
|
|
2354
|
+
/** Iterate all descendants in composed tree, returning parents before their children */
|
|
2355
|
+
ComposedDescendantsRootFirst = "composed-descendants-root-first",
|
|
2356
|
+
/** Iterate all descendants in composed tree, returning parents after their children */
|
|
2357
|
+
ComposedDescendantsRootLast = "composed-descendants-root-last"
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* An iterator for node tree traversal
|
|
2361
|
+
*
|
|
2362
|
+
* This iterator is convenient but seems a little slower.
|
|
2363
|
+
*/
|
|
2364
|
+
declare class ElementIterator {
|
|
2365
|
+
/**
|
|
2366
|
+
* Create an iterator with type specified
|
|
2367
|
+
*
|
|
2368
|
+
* The `nodeTypeLimit` is used to limit which kind of nodes will be returned.
|
|
2369
|
+
* It limits the returned result by an `instanceof` call.
|
|
2370
|
+
* The default value is `Element` ,
|
|
2371
|
+
* which means only elements will be returned (text nodes will not).
|
|
2372
|
+
* Consider specifying `Node` if text nodes need to be returned as well as elements.
|
|
2373
|
+
* Specify `Component` will only return components.
|
|
2374
|
+
*/
|
|
2375
|
+
constructor(node: Node$1, type: ElementIteratorType, nodeTypeLimit?: unknown);
|
|
2376
|
+
/** Same as constructor (for backward compatibility) */
|
|
2377
|
+
static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit?: unknown): ElementIterator;
|
|
2378
|
+
forEach(f: (node: Node$1) => boolean): void;
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* What the observer will listen
|
|
2383
|
+
*/
|
|
2384
|
+
type MutationObserverOptions = {
|
|
2385
|
+
/** Attribute changes, including property, id, slot, and class changes */
|
|
2386
|
+
properties: boolean;
|
|
2387
|
+
/** Child nodes changes */
|
|
2388
|
+
childList: boolean;
|
|
2389
|
+
/** Text content changes */
|
|
2390
|
+
characterData: boolean;
|
|
2391
|
+
/** Enable property, childList, and characterData changes in subtree */
|
|
2392
|
+
subtree: boolean;
|
|
2393
|
+
/** Attached status changes */
|
|
2394
|
+
attachStatus: boolean;
|
|
2395
|
+
};
|
|
2396
|
+
type MutationObserverAttrEvent = {
|
|
2397
|
+
type: 'properties';
|
|
2398
|
+
target: Element$4;
|
|
2399
|
+
propertyName?: string;
|
|
2400
|
+
attributeName?: string;
|
|
2401
|
+
};
|
|
2402
|
+
type MutationObserverTextEvent = {
|
|
2403
|
+
type: 'characterData';
|
|
2404
|
+
target: TextNode;
|
|
2405
|
+
};
|
|
2406
|
+
type MutationObserverChildEvent = {
|
|
2407
|
+
type: 'childList';
|
|
2408
|
+
target: Node$1;
|
|
2409
|
+
addedNodes?: Node$1[];
|
|
2410
|
+
removedNodes?: Node$1[];
|
|
2411
|
+
};
|
|
2412
|
+
type MutationObserverAttachEvent = {
|
|
2413
|
+
type: 'attachStatus';
|
|
2414
|
+
target: Element$4;
|
|
2415
|
+
status: 'attached' | 'detached';
|
|
2416
|
+
};
|
|
2417
|
+
type MutationObserverEvent = MutationObserverAttrEvent | MutationObserverTextEvent | MutationObserverChildEvent | MutationObserverAttachEvent;
|
|
2418
|
+
/**
|
|
2419
|
+
* An observer that can observe shadow tree changes
|
|
2420
|
+
*
|
|
2421
|
+
* Like DOM MutationObserver,
|
|
2422
|
+
* this observer can observe attributes, text content, and child nodes changes.
|
|
2423
|
+
* It can optionally observe changes in a subtree.
|
|
2424
|
+
* Further more, it can listen attached/detached events on an element.
|
|
2425
|
+
*/
|
|
2426
|
+
declare class MutationObserver {
|
|
2427
|
+
private _$listener;
|
|
2428
|
+
private _$normalizedListener;
|
|
2429
|
+
private _$subtreeListenersCount;
|
|
2430
|
+
private _$boundFuncArrs;
|
|
2431
|
+
private _$boundTarget;
|
|
2432
|
+
constructor(listener: (ev: MutationObserverEvent) => void);
|
|
2433
|
+
static create(listener: (ev: MutationObserverEvent) => void): MutationObserver;
|
|
2434
|
+
/** Start observation */
|
|
2435
|
+
observe(targetElement: Element$4, options?: Partial<MutationObserverOptions>): void;
|
|
2436
|
+
/** End observation */
|
|
2437
|
+
disconnect(): void;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
declare const triggerRender: (element: Element$4, callback?: ((err: Error | null) => void) | undefined) => void;
|
|
2441
|
+
|
|
2442
|
+
type UpdatePathTreeNode = true | {
|
|
2443
|
+
[key: string]: UpdatePathTreeNode;
|
|
2444
|
+
} | UpdatePathTreeNode[];
|
|
2445
|
+
type UpdatePathTreeRoot = UpdatePathTreeNode | undefined;
|
|
2446
|
+
type ChangePropListener = (this: unknown, newValue: unknown, oldValue: unknown, host: unknown, elem: unknown) => void;
|
|
2447
|
+
type ProcGen = (wrapper: ProcGenWrapper, isCreation: boolean, data: DataValue, dataUpdatePathTree: UpdatePathTreeRoot) => {
|
|
2448
|
+
C: DefineChildren;
|
|
2449
|
+
B?: {
|
|
2450
|
+
[field: string]: BindingMapGen[];
|
|
2451
|
+
};
|
|
2452
|
+
};
|
|
2453
|
+
type BindingMapGen = (data: DataValue, elementUpdated: (elem: Element$4) => void, updateText: (node: TextNode, content: string) => void) => void;
|
|
2454
|
+
type DefineChildren = (isCreation: boolean, defineTextNode: DefineTextNode, defineElement: DefineElement, defineIfGroup: DefineIfGroup, defineForLoop: DefineForLoop, defineSlot: DefineSlot, definePureVirtualNode: DefinePureVirtualNode, dynamicSlotValues: {
|
|
2455
|
+
[name: string]: unknown;
|
|
2456
|
+
} | undefined, slotValueUpdatePathTrees: UpdatePathTreeNode | undefined) => void;
|
|
2457
|
+
type DefineTextNode = (text: string | undefined, textInit?: (elem: TextNode) => boolean) => void;
|
|
2458
|
+
type DefineElement = (tag: string, genericImpls: {
|
|
2459
|
+
[key: string]: string;
|
|
2460
|
+
}, propertyInit: (elem: Element$4, isCreation: boolean) => void, children: DefineChildren, slot?: string, dynamicSlotValueNames?: string[]) => void;
|
|
2461
|
+
type DefineIfGroup = (branchKey: number | string, branchFunc: DefineChildren) => void;
|
|
2462
|
+
type DefineForLoop = (list: DataValue[], key: string | null, oriListUpdatePathTree: UpdatePathTreeRoot, lvaluePath: DataPath | null, itemCallback: (isCreation: boolean, item: DataValue, index: number | string, itemUpdatePathTree: UpdatePathTreeRoot, indexUpdatePathTree: UpdatePathTreeRoot, itemLvaluePath: DataPath | null, defineTextNode: DefineTextNode, defineElement: DefineElement, defineIfGroup: DefineIfGroup, defineForLoop: DefineForLoop, defineSlot: DefineSlot, definePureVirtualNode: DefinePureVirtualNode) => void) => void;
|
|
2463
|
+
type DefineSlot = (name: string | undefined, slotValueInit?: (elem: Element$4) => void, slot?: string) => void;
|
|
2464
|
+
type DefinePureVirtualNode = (children: DefineChildren, slot: string | undefined) => void;
|
|
2465
|
+
declare class ProcGenWrapper {
|
|
2466
|
+
shadowRoot: ShadowRoot;
|
|
2467
|
+
procGen: ProcGen;
|
|
2468
|
+
fallbackListenerOnNativeNode: boolean;
|
|
2469
|
+
bindingMapDisabled: boolean;
|
|
2470
|
+
eventObjectFilter: (x: ShadowedEvent<unknown>) => ShadowedEvent<unknown>;
|
|
2471
|
+
changePropFilter: <T>(x: T) => T;
|
|
2472
|
+
eventListenerFilter: <T>(x: T) => T;
|
|
2473
|
+
constructor(shadowRoot: ShadowRoot, procGen: ProcGen, fallbackListenerOnNativeNode: boolean, eventObjectFilter?: (x: ShadowedEvent<unknown>) => ShadowedEvent<unknown>);
|
|
2474
|
+
create(data: DataValue): {
|
|
2475
|
+
[field: string]: BindingMapGen[];
|
|
2476
|
+
} | undefined;
|
|
2477
|
+
update(data: DataValue, dataUpdatePathTree: UpdatePathTreeRoot): void;
|
|
2478
|
+
bindingMapUpdate(field: string, data: DataValue, bindingMapGenList: {
|
|
2479
|
+
[field: string]: BindingMapGen[];
|
|
2480
|
+
}): boolean;
|
|
2481
|
+
handleChildrenCreation(children: DefineChildren, slotElement: Element$4 | undefined, dynamicSlotName: string | undefined): Node$1[];
|
|
2482
|
+
handleChildrenCreationAndInsert(children: DefineChildren, parentNode: Element$4, slotElement: Element$4 | undefined, dynamicSlotName: string | undefined): void;
|
|
2483
|
+
handleChildrenUpdate(children: DefineChildren, parentNode: Element$4, slotElement: Element$4 | undefined, dynamicSlotName: string | undefined): void;
|
|
2484
|
+
dynamicSlotUpdate(elem: GeneralComponent, dynamicSlotValueNames: string[] | undefined, children: DefineChildren): ShadowRoot | null;
|
|
2485
|
+
createDynamicPlaceholder(slotElement: Element$4): Element$4;
|
|
2486
|
+
createCommonElement(tagName: string, genericImpls: {
|
|
2487
|
+
[key: string]: string;
|
|
2488
|
+
}, propertyInit: (elem: Element$4, isCreation: boolean) => void, children: DefineChildren, dynamicSlotValueNames: string[] | undefined): Element$4;
|
|
2489
|
+
s(elem: Element$4, v: string): void;
|
|
2490
|
+
l(elem: Element$4, name: string, value: unknown): void;
|
|
2491
|
+
i(elem: Element$4, v: string): void;
|
|
2492
|
+
c(elem: Element$4, v: string | string[]): void;
|
|
2493
|
+
y(elem: Element$4, v: string): void;
|
|
2494
|
+
d(elem: Element$4, name: string, v: unknown): void;
|
|
2495
|
+
m(elem: Element$4, name: string, v: unknown): void;
|
|
2496
|
+
v(elem: Element$4, evName: string, v: string | ((ev: ShadowedEvent<unknown>) => void) | undefined, final: boolean, mutated: boolean, capture: boolean, isDynamic: boolean, _generalLvaluePath?: DataPath | null): void;
|
|
2497
|
+
r: (elem: Element$4, name: string, v: unknown, modelLvaluePath?: DataPath | null, generalLvaluePath?: DataPath | null) => void;
|
|
2498
|
+
wl(elem: Element$4, name: string, value: unknown): void;
|
|
2499
|
+
p(elem: Element$4, name: string, v: ChangePropListener, _generalLvaluePath?: DataPath | null): void;
|
|
2500
|
+
setFnFilter(changePropFilter: <T>(v: T) => T, eventListenerFilter: <T>(v: T) => T): void;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
declare const DEFAULT_PROC_GEN_GROUP: (name: string) => ProcGen;
|
|
2504
|
+
type ProcGenGroup = (name: string) => ProcGen;
|
|
2505
|
+
type ProcGenGroupList = {
|
|
2506
|
+
[path: string]: ProcGenGroup;
|
|
2507
|
+
};
|
|
2508
|
+
type ComponentTemplate = {
|
|
2509
|
+
groupList?: ProcGenGroupList;
|
|
2510
|
+
content: (name: string) => ProcGen;
|
|
2511
|
+
updateMode?: string;
|
|
2512
|
+
fallbackListenerOnNativeNode?: boolean;
|
|
2513
|
+
eventObjectFilter?: (x: ShadowedEvent<unknown>) => ShadowedEvent<unknown>;
|
|
2514
|
+
procGenWrapperType?: typeof ProcGenWrapper;
|
|
2515
|
+
};
|
|
2516
|
+
declare class GlassEaselTemplateEngine implements TemplateEngine {
|
|
2517
|
+
create(behavior: GeneralBehavior, componentOptions: NormalizedComponentOptions): Template;
|
|
2518
|
+
}
|
|
2519
|
+
declare const getDefaultTemplateEngine: () => TemplateEngine;
|
|
2520
|
+
|
|
2521
|
+
type index_ComponentTemplate = ComponentTemplate;
|
|
2522
|
+
declare const index_DEFAULT_PROC_GEN_GROUP: typeof DEFAULT_PROC_GEN_GROUP;
|
|
2523
|
+
type index_GlassEaselTemplateEngine = GlassEaselTemplateEngine;
|
|
2524
|
+
declare const index_GlassEaselTemplateEngine: typeof GlassEaselTemplateEngine;
|
|
2525
|
+
type index_ProcGenGroup = ProcGenGroup;
|
|
2526
|
+
type index_ProcGenGroupList = ProcGenGroupList;
|
|
2527
|
+
declare const index_getDefaultTemplateEngine: typeof getDefaultTemplateEngine;
|
|
2528
|
+
declare namespace index {
|
|
2529
|
+
export { type index_ComponentTemplate as ComponentTemplate, index_DEFAULT_PROC_GEN_GROUP as DEFAULT_PROC_GEN_GROUP, index_GlassEaselTemplateEngine as GlassEaselTemplateEngine, type index_ProcGenGroup as ProcGenGroup, type index_ProcGenGroupList as ProcGenGroupList, index_getDefaultTemplateEngine as getDefaultTemplateEngine };
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
type ErrorListener = (error: unknown, method?: string, relatedComponent?: GeneralComponent | string, element?: Node$1) => boolean | void;
|
|
2533
|
+
type WarningListener = (message: string, relatedComponent: GeneralComponent | string, element?: Node$1) => boolean | void;
|
|
2534
|
+
declare function addGlobalErrorListener(func: ErrorListener): void;
|
|
2535
|
+
declare function removeGlobalErrorListener(func: ErrorListener): void;
|
|
2536
|
+
declare function addGlobalWarningListener(func: WarningListener): void;
|
|
2537
|
+
declare function removeGlobalWarningListener(func: WarningListener): void;
|
|
2538
|
+
|
|
2539
|
+
declare const registerBehavior: <TData extends DataList = Empty, TProperty extends PropertyList = Empty, TMethod extends MethodList = Empty>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>) => Behavior<TData, TProperty, TMethod, never>;
|
|
2540
|
+
declare const registerElement: <TData extends DataList = Empty, TProperty extends PropertyList = Empty, TMethod extends MethodList = Empty>(def: ComponentParams<TData, TProperty, TMethod> & ThisType<ComponentInstance<TData, TProperty, TMethod>>) => ComponentDefinition<TData, TProperty, TMethod>;
|
|
2541
|
+
declare function createElement(tagName: string, compDef?: GeneralComponentDefinition): GeneralComponent;
|
|
2542
|
+
declare function createElement<TData extends DataList, TProperty extends PropertyList, TMethod extends MethodList>(tagName: string, compDef: ComponentDefinition<TData, TProperty, TMethod>): ComponentInstance<TData, TProperty, TMethod>;
|
|
2543
|
+
declare const triggerEvent: typeof Event.triggerEvent;
|
|
2544
|
+
declare const triggerExternalEvent: typeof Event.triggerExternalEvent;
|
|
2545
|
+
|
|
2546
|
+
export { BackendMode, Behavior, BehaviorBuilder, type BuilderContext, ClassList, Component, ComponentDefinition, type ComponentOptions, ComponentSpace, CurrentWindowBackendContext, type DataChange, DataGroup, type DataObserver, type DataUpdateCallback, type DataValue, DeepCopyKind, Element$4 as Element, ElementIterator, ElementIteratorType, EmptyBackendContext, EmptyComposedBackendContext, type EnvironmentOptions, Event, EventBubbleStatus, type EventListener, type EventListenerOptions, MutLevel as EventMutLevel, type EventOptions, type ExternalShadowRoot, FuncArr, type GeneralBackendContext, type GeneralBackendElement, type GeneralBehavior, type GeneralBehaviorBuilder, type GeneralComponent, type GeneralComponentDefinition, type GeneralDataGroup, type GeneralFuncType, MutationObserver, NativeNode, type Node$1 as Node, type NodeCast, type NormalizedComponentOptions, NormalizedPropertyType, MutationObserver as Observer, ParsedSelector, type PropertyChange, type RelationFailedListener, type RelationListener, RelationType, ShadowRoot, type ShadowedEvent, type StyleScopeId, StyleScopeManager, StyleSegmentIndex, TextNode, TraitBehavior, VirtualNode, addGlobalErrorListener, addGlobalWarningListener, backend, composedBackend, createElement, data_path as dataPath, data_utils as dataUtils, domlikeBackend, dumpElement, dumpElementToString, dumpSingleElementToString, getDefaultComponentSpace, globalOptions, registerBehavior, registerElement, removeGlobalErrorListener, removeGlobalWarningListener, safeCallback, index as template, template_engine as templateEngine, triggerEvent, triggerExternalEvent, triggerRender, component_params as typeUtils };
|