1 | import type { ComponentInstanceState, PreparedArguments } from '../../components.js';
|
2 | import type { Destroyable, Nullable } from '../../core.js';
|
3 | import type { Bounds } from '../../dom/bounds.js';
|
4 | import type { SimpleElement } from '../../dom/simple.js';
|
5 | import type { Reference } from '../../references.js';
|
6 | import type { Owner } from '../../runtime.js';
|
7 | import type { CapturedArguments, VMArguments } from '../../runtime/arguments.js';
|
8 | import type { RenderNode } from '../../runtime/debug-render-tree.js';
|
9 | import type { ElementOperations } from '../../runtime/element.js';
|
10 | import type { Environment } from '../../runtime/environment.js';
|
11 | import type { DynamicScope } from '../../runtime/scope.js';
|
12 | import type { RuntimeResolver } from '../../serialize.js';
|
13 | import type { CompilableProgram } from '../../template.js';
|
14 | import type { ProgramSymbolTable } from '../../tier1/symbol-table.js';
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export interface InternalComponentCapabilities {
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 | dynamicLayout: boolean;
|
37 |
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 | dynamicTag: boolean;
|
44 |
|
45 | wrapped: boolean;
|
46 |
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | prepareArgs: boolean;
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | createArgs: boolean;
|
66 |
|
67 | |
68 |
|
69 |
|
70 | createCaller: boolean;
|
71 |
|
72 | |
73 |
|
74 |
|
75 | attributeHook: boolean;
|
76 |
|
77 | |
78 |
|
79 |
|
80 | elementHook: boolean;
|
81 |
|
82 | |
83 |
|
84 |
|
85 | updateHook: boolean;
|
86 |
|
87 | |
88 |
|
89 |
|
90 | dynamicScope: boolean;
|
91 |
|
92 | |
93 |
|
94 |
|
95 |
|
96 | createInstance: boolean;
|
97 |
|
98 | |
99 |
|
100 |
|
101 |
|
102 | willDestroy: boolean;
|
103 |
|
104 | |
105 |
|
106 |
|
107 |
|
108 | hasSubOwner: boolean;
|
109 | }
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | export type EmptyCapability = 0b0000000000000;
|
116 | export type DynamicLayoutCapability = 0b0000000000001;
|
117 | export type DynamicTagCapability = 0b0000000000010;
|
118 | export type PrepareArgsCapability = 0b0000000000100;
|
119 | export type CreateArgsCapability = 0b0000000001000;
|
120 | export type AttributeHookCapability = 0b0000000010000;
|
121 | export type ElementHookCapability = 0b0000000100000;
|
122 | export type DynamicScopeCapability = 0b0000001000000;
|
123 | export type CreateCallerCapability = 0b0000010000000;
|
124 | export type UpdateHookCapability = 0b0000100000000;
|
125 | export type CreateInstanceCapability = 0b0001000000000;
|
126 | export type WrappedCapability = 0b0010000000000;
|
127 | export type WillDestroyCapability = 0b0100000000000;
|
128 | export type HasSubOwnerCapability = 0b1000000000000;
|
129 |
|
130 | export type InternalComponentCapability =
|
131 | | EmptyCapability
|
132 | | DynamicLayoutCapability
|
133 | | DynamicTagCapability
|
134 | | PrepareArgsCapability
|
135 | | CreateArgsCapability
|
136 | | AttributeHookCapability
|
137 | | ElementHookCapability
|
138 | | DynamicScopeCapability
|
139 | | CreateCallerCapability
|
140 | | UpdateHookCapability
|
141 | | CreateInstanceCapability
|
142 | | WrappedCapability
|
143 | | WillDestroyCapability
|
144 | | HasSubOwnerCapability;
|
145 |
|
146 |
|
147 |
|
148 | export interface InternalComponentManager<
|
149 | TComponentStateBucket = unknown,
|
150 | TComponentDefinition = object,
|
151 | > {
|
152 | getCapabilities(state: TComponentDefinition): InternalComponentCapabilities;
|
153 | getSelf(state: TComponentStateBucket): Reference;
|
154 | getDestroyable(state: TComponentStateBucket): Nullable<Destroyable>;
|
155 | getDebugName(state: TComponentDefinition): string;
|
156 | }
|
157 |
|
158 | export interface CustomRenderNode extends RenderNode {
|
159 | bucket: object;
|
160 | }
|
161 |
|
162 | export interface WithCustomDebugRenderTree<
|
163 | ComponentInstanceState = unknown,
|
164 | ComponentDefinitionState = unknown,
|
165 | > extends InternalComponentManager<ComponentInstanceState, ComponentDefinitionState> {
|
166 |
|
167 |
|
168 | getDebugCustomRenderTree(
|
169 | definition: ComponentDefinitionState,
|
170 | state: ComponentInstanceState,
|
171 | args: CapturedArguments,
|
172 | template?: string
|
173 | ): CustomRenderNode[];
|
174 | }
|
175 |
|
176 | export interface WithPrepareArgs<
|
177 | ComponentInstanceState = unknown,
|
178 | ComponentDefinitionState = unknown,
|
179 | > extends InternalComponentManager<ComponentInstanceState, ComponentDefinitionState> {
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | prepareArgs(state: ComponentDefinitionState, args: VMArguments): Nullable<PreparedArguments>;
|
185 | }
|
186 |
|
187 | export interface WithSubOwner<ComponentInstanceState = unknown, ComponentDefinitionState = unknown>
|
188 | extends InternalComponentManager<ComponentInstanceState, ComponentDefinitionState> {
|
189 | getOwner(state: ComponentInstanceState): Owner;
|
190 | }
|
191 |
|
192 | export interface WithCreateInstance<
|
193 | ComponentInstanceState = unknown,
|
194 | ComponentDefinitionState = unknown,
|
195 | O extends Owner = Owner,
|
196 | > extends InternalComponentManager<ComponentInstanceState, ComponentDefinitionState> {
|
197 |
|
198 |
|
199 |
|
200 | create(
|
201 | owner: O,
|
202 | state: ComponentDefinitionState,
|
203 | args: Nullable<VMArguments>,
|
204 | env: Environment,
|
205 | dynamicScope: Nullable<DynamicScope>,
|
206 | caller: Nullable<Reference>,
|
207 | hasDefaultBlock: boolean
|
208 | ): ComponentInstanceState;
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | didRenderLayout(state: ComponentInstanceState, bounds: Bounds): void;
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | didUpdateLayout(state: ComponentInstanceState, bounds: Bounds): void;
|
221 |
|
222 |
|
223 |
|
224 | didCreate(state: ComponentInstanceState): void;
|
225 |
|
226 |
|
227 |
|
228 | didUpdate(state: ComponentInstanceState): void;
|
229 | }
|
230 |
|
231 | export interface WithUpdateHook<ComponentInstanceState = unknown>
|
232 | extends InternalComponentManager<ComponentInstanceState> {
|
233 |
|
234 |
|
235 | update(state: ComponentInstanceState, dynamicScope: Nullable<DynamicScope>): void;
|
236 | }
|
237 |
|
238 | export interface WithDynamicLayout<
|
239 | I = ComponentInstanceState,
|
240 | R extends RuntimeResolver = RuntimeResolver,
|
241 | > extends InternalComponentManager<I> {
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | getDynamicLayout(component: I, resolver: R): CompilableProgram | null;
|
247 | }
|
248 |
|
249 | export interface WithDynamicTagName<ComponentInstanceState>
|
250 | extends InternalComponentManager<ComponentInstanceState> {
|
251 |
|
252 |
|
253 | getTagName(component: ComponentInstanceState): Nullable<string>;
|
254 | }
|
255 |
|
256 | export interface WithAttributeHook<ComponentInstanceState>
|
257 | extends InternalComponentManager<ComponentInstanceState> {
|
258 | didSplatAttributes(
|
259 | component: ComponentInstanceState,
|
260 | element: ComponentInstanceState,
|
261 | operations: ElementOperations
|
262 | ): void;
|
263 | }
|
264 |
|
265 | export interface WithElementHook<ComponentInstanceState>
|
266 | extends InternalComponentManager<ComponentInstanceState> {
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | didCreateElement(
|
275 | component: ComponentInstanceState,
|
276 | element: SimpleElement,
|
277 | operations: ElementOperations
|
278 | ): void;
|
279 | }
|
280 |
|
281 | export interface Invocation {
|
282 | handle: number;
|
283 | symbolTable: ProgramSymbolTable;
|
284 | }
|