pawajs 2.4.0-beta.2 → 2.4.0-beta.4
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/CHANGELOG.md +2 -1
- package/LICENSE +1 -1
- package/README.md +216 -70
- package/examples/Text.js +5 -0
- package/examples/index.html +64 -0
- package/examples/index.js +31 -0
- package/index.d.ts +394 -356
- package/index.js +64 -1413
- package/package.json +1 -1
- package/src/builtIn/Active.js +67 -0
- package/src/builtIn/viewTransition.js +42 -0
- package/src/component/index.js +194 -0
- package/src/component/utils.js +358 -0
- package/src/control-flow/attribute.js +83 -0
- package/src/control-flow/await.js +78 -0
- package/src/control-flow/for.js +220 -0
- package/src/control-flow/if.js +127 -0
- package/src/control-flow/key.js +87 -0
- package/src/control-flow/ref.js +34 -0
- package/src/control-flow/state.js +26 -0
- package/src/control-flow/template.js +25 -0
- package/src/control-flow/text.js +58 -0
- package/src/control-flow/timers.js +26 -0
- package/src/control-flow/utils.js +42 -0
- package/src/dev/index.js +67 -0
- package/src/dev/plugin.js +24 -0
- package/src/dev/tools.js +89 -0
- package/src/event/index.js +212 -0
- package/src/global.js +93 -0
- package/src/graph/graph.js +156 -0
- package/src/graph/index.js +150 -0
- package/src/graph/setup.js +28 -0
- package/src/hooks/index.js +217 -0
- package/src/hooks/registerComponent.js +101 -0
- package/src/hooks/state.js +295 -0
- package/src/hooks/utils.js +35 -0
- package/src/pawaElement.js +159 -0
- package/src/reactive.js +251 -0
- package/{server.js → src/server/index.js} +6 -4
- package/src/store.js +3 -0
- package/src/utils.js +56 -0
- package/cdn/index.html +0 -25
- package/cdn/index.js +0 -23
- package/merger/for.js +0 -203
- package/merger/if.js +0 -135
- package/merger/key.js +0 -117
- package/merger/switch.js +0 -134
- package/normal/For.js +0 -30
- package/normal/If.js +0 -29
- package/normal/Key.js +0 -27
- package/normal/Switch.js +0 -29
- package/normal/component.js +0 -419
- package/normal/template.js +0 -33
- package/pawaComponent.js +0 -72
- package/pawaElement.js +0 -504
- package/power.js +0 -667
- package/reactive.js +0 -190
- package/resumer.js +0 -19
- package/server.d.ts +0 -13
- package/utils.js +0 -309
package/index.d.ts
CHANGED
|
@@ -1,445 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime graph instance used by the render pipeline.
|
|
3
|
+
* Owns lifecycle, effects, and DOM refs for a component or control-flow region.
|
|
4
|
+
* Not a virtual DOM node — structural ownership only.
|
|
5
|
+
*/
|
|
6
|
+
export interface PawaGraph {
|
|
7
|
+
/** DOM node, comment anchor, or nested graph root this instance controls. */
|
|
8
|
+
ref: any;
|
|
1
9
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
10
|
+
/** Semantic kind of this node (e.g. component, condition, for-each, template). */
|
|
11
|
+
nodeType: string;
|
|
12
|
+
|
|
13
|
+
/** Whether this region is tied to async work (e.g. await). */
|
|
14
|
+
async: boolean;
|
|
15
|
+
|
|
16
|
+
/** Resolved or reactive props for a component instance. */
|
|
17
|
+
props: Record<string, any>;
|
|
18
|
+
|
|
19
|
+
/** Child component instances or slot-related nodes. */
|
|
20
|
+
componentChildren: any[];
|
|
21
|
+
|
|
22
|
+
/** Values inserted into template scope at setup (useInsert / initial bindings). */
|
|
23
|
+
initialInsert: Record<string, any>;
|
|
24
|
+
|
|
25
|
+
/** Stable identity for list/key regions. */
|
|
26
|
+
key: string;
|
|
27
|
+
|
|
28
|
+
/** Current branch or control-flow cursor (e.g. active condition id). */
|
|
29
|
+
current: string;
|
|
30
|
+
|
|
31
|
+
/** High-level graph category (e.g. pawa-dom). */
|
|
32
|
+
type: string;
|
|
33
|
+
|
|
34
|
+
/** Attributes/props not mapped into the main props object. */
|
|
35
|
+
restProps: Record<string, any>;
|
|
36
|
+
|
|
37
|
+
/** Parent graph, or null at the root. */
|
|
38
|
+
parent: PawaGraph | null;
|
|
39
|
+
|
|
40
|
+
/** Child ownership graphs (nested components and control flow). */
|
|
41
|
+
children: PawaGraph[];
|
|
42
|
+
|
|
43
|
+
/** Control-flow anchor (often a comment) or related control metadata. */
|
|
44
|
+
control: Record<string, any>;
|
|
45
|
+
|
|
46
|
+
/** True until the first successful mount/continue pass completes. */
|
|
47
|
+
firstTime: boolean;
|
|
48
|
+
|
|
49
|
+
/** Whether enter transitions/hooks should run on the next paint. */
|
|
50
|
+
entrance: boolean;
|
|
51
|
+
|
|
52
|
+
/** Mount callbacks scheduled after the instance is attached. */
|
|
53
|
+
mount: Function[];
|
|
54
|
+
|
|
55
|
+
/** Enter transition/lifecycle hooks (e.g. Transition onEnter). */
|
|
56
|
+
onEnter: Function[];
|
|
57
|
+
|
|
58
|
+
/** Cross-boundary bag (e.g. values carried across component graphs). */
|
|
59
|
+
transport: Record<string, any>;
|
|
60
|
+
|
|
61
|
+
/** Previous graph or boundary context when replacing an instance. */
|
|
62
|
+
former: any;
|
|
63
|
+
|
|
64
|
+
/** Exit transition/lifecycle hooks; may be async. */
|
|
65
|
+
onExit: Function[];
|
|
66
|
+
|
|
67
|
+
/** Cleanup callbacks run on teardown (subscriptions, timers, etc.). */
|
|
68
|
+
unMount: Function[];
|
|
69
|
+
|
|
70
|
+
/** Effect disposer functions registered under this graph. */
|
|
71
|
+
effect: Function[];
|
|
72
|
+
|
|
73
|
+
/** Server/client prop-recall handlers when props change after continue. */
|
|
74
|
+
reProps: any[];
|
|
75
|
+
|
|
76
|
+
/** Template/evaluation context for this instance. */
|
|
77
|
+
context: Record<string, any>;
|
|
78
|
+
|
|
79
|
+
/** Debug or component display name. */
|
|
80
|
+
name: string;
|
|
81
|
+
|
|
82
|
+
/** Effects that do not write (read-only tracking helpers). */
|
|
83
|
+
readOnlyffect: any[];
|
|
84
|
+
|
|
85
|
+
/** List/array-driven effects (e.g. for-each drivers). */
|
|
86
|
+
arrayEffect: any[];
|
|
87
|
+
|
|
88
|
+
/** Callbacks run before mount. */
|
|
89
|
+
beforeMount: Function[];
|
|
90
|
+
|
|
91
|
+
/** When true, teardown should dispose this node and descendants. */
|
|
92
|
+
kill: boolean;
|
|
93
|
+
|
|
94
|
+
/** Inactive (paused) effect or child bookkeeping for Active-style regions. */
|
|
95
|
+
unActive: any[];
|
|
96
|
+
|
|
97
|
+
/** Whether this region is active and should apply updates. */
|
|
98
|
+
active: boolean;
|
|
99
|
+
|
|
100
|
+
/** Index among parent.children. */
|
|
101
|
+
index: number;
|
|
102
|
+
|
|
103
|
+
/** Runs all registered effect disposers. */
|
|
104
|
+
terminate: () => void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Moves this node's DOM (and nested structure) relative to a comment anchor.
|
|
108
|
+
* Used for list reorder and branch placement.
|
|
109
|
+
*/
|
|
110
|
+
move: (comment?: any) => void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Resolves the underlying DOM element(s) from ref chains.
|
|
114
|
+
* @param all When true, collect multiple roots (e.g. template graphs).
|
|
115
|
+
* @param and Reserved/extension flag for multi-root resolution.
|
|
116
|
+
*/
|
|
117
|
+
getElement: (all?: boolean, and?: boolean) => any;
|
|
118
|
+
|
|
119
|
+
/** Removes this node from parent.children. */
|
|
120
|
+
fromParent: () => void;
|
|
121
|
+
|
|
122
|
+
/** Marks this node and all descendants with kill for teardown. */
|
|
123
|
+
killDown: () => void;
|
|
124
|
+
|
|
125
|
+
/** Refreshes ref after DOM swap or continue adopt. */
|
|
126
|
+
updateRef: () => void;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Tears down lifecycle, effects, and DOM for this subtree.
|
|
130
|
+
* @param node When true, prefer node-level removal semantics.
|
|
131
|
+
*/
|
|
132
|
+
remove: (node?: boolean) => Promise<any>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Renders or continues into an element.
|
|
136
|
+
* @param refresh When false, bind the host only (continue / no deep child walk).
|
|
137
|
+
*/
|
|
138
|
+
render?: (el: HTMLElement, refresh?: boolean) => void;
|
|
139
|
+
|
|
140
|
+
/** Replaces the evaluation context used by nested render. */
|
|
141
|
+
setContext?: (contexts: Record<string, any>) => void;
|
|
142
|
+
|
|
143
|
+
/** Extension bag for SSR flags, plugins, and internal metadata. */
|
|
144
|
+
[key: string]: any;
|
|
79
145
|
}
|
|
80
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Runtime dev metadata produced by the Pawa debugging tools.
|
|
149
|
+
* Tracks errors, effect/render counts, and coarse performance samples.
|
|
150
|
+
*/
|
|
81
151
|
export interface PawaDev {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
152
|
+
/** Whether the debug tool layer is active. */
|
|
153
|
+
tool: boolean;
|
|
154
|
+
|
|
155
|
+
/** Collected runtime errors and warnings. */
|
|
156
|
+
errors: any[];
|
|
157
|
+
|
|
158
|
+
/** Number of effects registered or run while debugging. */
|
|
159
|
+
totalEffect: number;
|
|
160
|
+
|
|
161
|
+
/** Number of render passes observed. */
|
|
162
|
+
renderCount: number;
|
|
163
|
+
|
|
164
|
+
/** Timing samples for renders, effects, and components. */
|
|
165
|
+
performance: {
|
|
166
|
+
/** Render durations (ms samples). */
|
|
167
|
+
renderTime: number[];
|
|
168
|
+
/** Effect durations (ms samples). */
|
|
169
|
+
effectTime: number[];
|
|
170
|
+
/** Component setup durations (ms samples). */
|
|
171
|
+
componentTime: number[];
|
|
172
|
+
/** Session or batch start timestamp. */
|
|
173
|
+
start: number;
|
|
174
|
+
/** Session or batch end timestamp. */
|
|
175
|
+
end: number;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** Live component set or aggregated component count. */
|
|
179
|
+
components: Set<any> | number;
|
|
180
|
+
|
|
181
|
+
/** Subscribers notified on debug events. */
|
|
182
|
+
listeners: Set<Function>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Subscribes to debug bus events.
|
|
186
|
+
* @returns Unsubscribe function.
|
|
187
|
+
*/
|
|
188
|
+
subscribe(cb: (event: { type: string; data: any }) => void): () => void;
|
|
189
|
+
|
|
190
|
+
/** Emits a debug event to all subscribers. */
|
|
191
|
+
emit(type: string, data: any): void;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Records a structured error or warning for the dev overlay and logs.
|
|
195
|
+
*/
|
|
196
|
+
setError(options?: {
|
|
197
|
+
el?: HTMLElement;
|
|
198
|
+
msg?: string;
|
|
199
|
+
directives?: string;
|
|
200
|
+
stack?: string;
|
|
201
|
+
template?: string;
|
|
202
|
+
warn?: boolean;
|
|
203
|
+
effect?: any;
|
|
204
|
+
ref?: any;
|
|
205
|
+
exp?: string;
|
|
206
|
+
}): any;
|
|
207
|
+
|
|
208
|
+
/** Clears the collected error list. */
|
|
209
|
+
clearErrors(): void;
|
|
210
|
+
|
|
211
|
+
/** Returns a serializable snapshot of debug counters and errors. */
|
|
212
|
+
getSnapshot(): {
|
|
87
213
|
renderCount: number;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
_originalStyles: Map<any, any>;
|
|
96
|
-
listeners: Set<Function>;
|
|
97
|
-
highlightElement(el: HTMLElement): void;
|
|
98
|
-
unhighlightElement(el: HTMLElement): void;
|
|
99
|
-
subscribe(cb: (event: { type: string; data: any }) => void): () => void;
|
|
100
|
-
emit(type: string, data: any): void;
|
|
101
|
-
setError(options?: {
|
|
102
|
-
el?: HTMLElement;
|
|
103
|
-
msg?: string;
|
|
104
|
-
directives?: string;
|
|
105
|
-
stack?: string;
|
|
106
|
-
template?: string;
|
|
107
|
-
warn?: boolean;
|
|
108
|
-
}): void;
|
|
109
|
-
clearErrors(): void;
|
|
110
|
-
getSnapshot(): {
|
|
111
|
-
renderCount: number;
|
|
112
|
-
totalEffect: number;
|
|
113
|
-
performance: any;
|
|
114
|
-
errors: any[];
|
|
115
|
-
componentCount: number;
|
|
116
|
-
};
|
|
117
|
-
logRender(c: any, t: any): void;
|
|
118
|
-
logEffect(e: any, t: any): void;
|
|
119
|
-
logComponent(n: any, t: any): void;
|
|
120
|
-
}
|
|
121
|
-
type StateContextType={
|
|
122
|
-
_name:string,
|
|
123
|
-
_props:object,
|
|
124
|
-
_formerStateContext:stateContextType,
|
|
125
|
-
_elementContext:object,
|
|
126
|
-
_template:string,
|
|
127
|
-
_reactiveProps:object,
|
|
128
|
-
_restProps:object,
|
|
129
|
-
_hasRun:boolean,
|
|
130
|
-
_transportContext:object,
|
|
131
|
-
_static:any[],
|
|
132
|
-
_serializedData:object,
|
|
133
|
-
_formerContext:stateContextType,
|
|
134
|
-
_resume:boolean,
|
|
135
|
-
_suspense:string,
|
|
136
|
-
_hmr:boolean,
|
|
137
|
-
_hook:{
|
|
138
|
-
beforeMount:Function[],
|
|
139
|
-
reactiveEffect:Function[],
|
|
140
|
-
effect:Function[],
|
|
141
|
-
isMount:Function[],
|
|
142
|
-
isUnMount:Function[]
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
export const statecontext:StateContextType
|
|
214
|
+
totalEffect: number;
|
|
215
|
+
performance: any;
|
|
216
|
+
errors: any[];
|
|
217
|
+
componentCount: number;
|
|
218
|
+
[key: string]: any;
|
|
219
|
+
};
|
|
146
220
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var __pawaStream: (element: HTMLElement, context: any, statecontext?: any) => void;
|
|
150
|
-
}
|
|
221
|
+
/** Logs a render timing sample. */
|
|
222
|
+
logRender(c: any, t: any): void;
|
|
151
223
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_el: Comment;
|
|
155
|
-
_setCoveringElement: (el: any) => void;
|
|
156
|
-
_data: Record<string, any>;
|
|
157
|
-
_terminateEffects: Set<Function>;
|
|
158
|
-
_run: any;
|
|
159
|
-
_coveringElement: any;
|
|
160
|
-
_setData: (obj: any) => void;
|
|
161
|
-
_removeSiblings: (endComment: any) => void;
|
|
162
|
-
_controlComponent: boolean;
|
|
163
|
-
_componentTerminate: Function | null;
|
|
164
|
-
_componentElement: any;
|
|
165
|
-
_setComponentOut: any;
|
|
166
|
-
_deleteEffects: () => void;
|
|
167
|
-
_remove: () => void;
|
|
168
|
-
_terminateByComponent: (endComment: any) => void;
|
|
169
|
-
_forKey: string | null;
|
|
170
|
-
_forIndex: any;
|
|
171
|
-
_setKey: (arg: any) => void;
|
|
172
|
-
_endComment: Comment | null;
|
|
173
|
-
_keyRemover: (callback?: Function, firstElement?: boolean) => Promise<void>;
|
|
174
|
-
_resetForKeyElement: () => DocumentFragment;
|
|
175
|
-
_deletKey: () => void;
|
|
176
|
-
forKeyResetElement(): DocumentFragment;
|
|
177
|
-
keyRemoveElement(callback?: Function, firstElement?: boolean): Promise<void>;
|
|
178
|
-
deleteKey(): void;
|
|
179
|
-
setForKey(arg: any): void;
|
|
180
|
-
terminateEffects(): void;
|
|
181
|
-
setCoveringElement(el: any): void;
|
|
182
|
-
setData(obj: any): void;
|
|
183
|
-
terminate(endComment: any): void;
|
|
184
|
-
remove(): void;
|
|
185
|
-
removeSiblings(endComment: any): void;
|
|
186
|
-
}
|
|
224
|
+
/** Logs an effect timing sample. */
|
|
225
|
+
logEffect(e: any, t: any): void;
|
|
187
226
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
fullName?: string;
|
|
191
|
-
mode?: null | 'client' | 'server';
|
|
192
|
-
dependency?: string[];
|
|
193
|
-
plugin: (el: HTMLElement | PawaElement, attr: { name: string; value: string }, stateContext?: any, notRender?: any, stopResume?: any) => void;
|
|
227
|
+
/** Logs a component setup timing sample. */
|
|
228
|
+
logComponent(n: any, t: any): void;
|
|
194
229
|
}
|
|
195
230
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
231
|
+
/**
|
|
232
|
+
* HTMLElement augmented with Pawa runtime fields after render/continue.
|
|
233
|
+
*/
|
|
234
|
+
export interface PawaElement extends HTMLElement {
|
|
235
|
+
/** Active template/evaluation context for this element. */
|
|
236
|
+
context: object;
|
|
237
|
+
|
|
238
|
+
/** Owning structure graph for this host, when bound. */
|
|
239
|
+
graph: PawaGraph;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Runs a keyframe-style animation helper when provided by the runtime.
|
|
243
|
+
* @param frames Class or style frame list.
|
|
244
|
+
*/
|
|
245
|
+
animation: (frames: string[]) => Promise<void>;
|
|
246
|
+
|
|
247
|
+
/** Runtime-added fields (bindings, markers, etc.). */
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Context handle used by the component context API.
|
|
252
|
+
*/
|
|
253
|
+
export interface ContextHandle<T = any> {
|
|
254
|
+
id: string;
|
|
255
|
+
setValue: (val?: T) => void;
|
|
209
256
|
}
|
|
210
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Input accepted by the state factory.
|
|
260
|
+
*/
|
|
211
261
|
export type StateInput<T> = T | (() => T) | (() => Promise<T>);
|
|
212
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Reactive state container.
|
|
265
|
+
*/
|
|
213
266
|
export interface State<T> {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
267
|
+
value: T;
|
|
268
|
+
readonly id: string;
|
|
269
|
+
async?: boolean;
|
|
270
|
+
failed?: boolean;
|
|
271
|
+
retry?: () => void;
|
|
219
272
|
}
|
|
220
273
|
|
|
221
|
-
export function setErrorCALLER(callback: (message: any) => void): void;
|
|
222
|
-
|
|
223
|
-
export function pluginsMap(): {
|
|
224
|
-
compoAfterCall: Set<Function>;
|
|
225
|
-
compoBeforeCall: Set<Function>;
|
|
226
|
-
renderAfterPawa: Set<Function>;
|
|
227
|
-
renderBeforePawa: Set<Function>;
|
|
228
|
-
renderBeforeChild: Set<Function>;
|
|
229
|
-
startsWithSet: Set<string>;
|
|
230
|
-
fullNamePlugin: Set<string>;
|
|
231
|
-
externalPlugin: Record<string, Function>;
|
|
232
|
-
externalPluginMap: Map<string, string[]>;
|
|
233
|
-
primaryDirective: Set<string>;
|
|
234
|
-
pawaAttributes: Set<string>;
|
|
235
|
-
allowAsProp: Set<string>;
|
|
236
|
-
};
|
|
237
|
-
export function PawaCustomEvent(eventType:string,handler:(el:PawaElement,modifiers:Set<string>,options:{
|
|
238
|
-
capture: Boolean,
|
|
239
|
-
once: Boolean,
|
|
240
|
-
passive: Boolean
|
|
241
|
-
},execute:(e:EventListener)=>void)=>void):void;
|
|
242
|
-
export const escapePawaAttribute: Set<string>;
|
|
243
|
-
export const dependentPawaAttribute: Set<string>;
|
|
244
|
-
|
|
245
274
|
/**
|
|
246
|
-
*
|
|
247
|
-
* @param {...string} pluginName - Names of plugins to remove.
|
|
275
|
+
* Plugin callback signature used by the dev-plugin system.
|
|
248
276
|
*/
|
|
249
|
-
export
|
|
277
|
+
export interface PluginCallback {
|
|
278
|
+
(el: HTMLElement | PawaElement, attr: { name: string; value: string }, graph?: any, context?: any): void | (() => void);
|
|
279
|
+
}
|
|
250
280
|
|
|
251
281
|
/**
|
|
252
|
-
*
|
|
253
|
-
* @param {...(() => PluginObject)} func - Functions returning plugin definitions.
|
|
282
|
+
* Attribute plugin declaration.
|
|
254
283
|
*/
|
|
255
|
-
export
|
|
256
|
-
|
|
257
|
-
|
|
284
|
+
export interface AttriPlugin {
|
|
285
|
+
startsWith?: string;
|
|
286
|
+
fullName?: string;
|
|
287
|
+
mode?: null | 'client' | 'server';
|
|
288
|
+
dependency?: string[];
|
|
289
|
+
plugin: PluginCallback;
|
|
290
|
+
}
|
|
258
291
|
|
|
259
|
-
export const components: Map<string, Function>;
|
|
260
292
|
|
|
261
|
-
export const lazyComponents: Map<string, any>;
|
|
262
293
|
|
|
263
294
|
/**
|
|
264
|
-
*
|
|
295
|
+
* Starts the Pawa application and mounts the root graph into the given element.
|
|
296
|
+
* @param el The root application container.
|
|
297
|
+
* @param context Optional render context.
|
|
265
298
|
*/
|
|
266
|
-
export const
|
|
267
|
-
|
|
268
|
-
export function addLazyComponentElement(element: PawaElement, func: Function): void;
|
|
269
|
-
|
|
270
|
-
export function createIntersectionObserver(element: HTMLElement, observeBy?: HTMLElement): IntersectionObserver;
|
|
299
|
+
export const pawaStartApp: (el: HTMLElement, context?: Record<string, any>) => void;
|
|
271
300
|
|
|
272
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Enables or disables the developer tooling.
|
|
303
|
+
* @param enabled Toggle the runtime debugger.
|
|
304
|
+
*/
|
|
305
|
+
export const pawaDebug: (enabled?: boolean) => PawaDev;
|
|
273
306
|
|
|
274
|
-
|
|
307
|
+
/**
|
|
308
|
+
* Sets the development mode flag and creates the debug instance.
|
|
309
|
+
* @param enabled Whether debug mode should be active.
|
|
310
|
+
*/
|
|
311
|
+
export const setDevelopment: (enabled?: boolean) => PawaDev;
|
|
275
312
|
|
|
276
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Returns the active development flag.
|
|
315
|
+
*/
|
|
316
|
+
export const getDevelopment: () => boolean;
|
|
277
317
|
|
|
278
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Enables or disables the Pawa debug runtime.
|
|
320
|
+
* @param enabled Debug flag.
|
|
321
|
+
*/
|
|
322
|
+
export const setDev: (enabled?: boolean) => PawaDev;
|
|
279
323
|
|
|
280
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Registers a custom directive plugin.
|
|
326
|
+
* @param name Plugin name.
|
|
327
|
+
* @param callback Plugin callback.
|
|
328
|
+
*/
|
|
329
|
+
export const Plugin: (name: string, callback: PluginCallback) => void;
|
|
281
330
|
|
|
282
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Creates a reactive state container.
|
|
333
|
+
* @param initialValue Initial state value or a factory function.
|
|
334
|
+
* @param section Optional storage key or dependency list.
|
|
335
|
+
*/
|
|
336
|
+
export const $state: <T>(initialValue: StateInput<T>, section?: string | null | Function[] | Object[] | string[]) => State<T>;
|
|
283
337
|
|
|
284
338
|
/**
|
|
285
|
-
*
|
|
286
|
-
* @param
|
|
339
|
+
* Detects whether a value is a Pawa proxy.
|
|
340
|
+
* @param value Value to inspect.
|
|
287
341
|
*/
|
|
288
|
-
export
|
|
342
|
+
export const isProxy: (value: any) => boolean;
|
|
289
343
|
|
|
290
|
-
export namespace RegisterComponent {
|
|
291
|
-
/**
|
|
292
|
-
* Registers components lazily. The component's bundle is only fetched during runime encounter.
|
|
293
|
-
* (name,import) or ([names,...],import)
|
|
294
|
-
*/
|
|
295
|
-
export function lazy(...arg:Array<string|Function|Array<string>>): Promise<void>;
|
|
296
|
-
}
|
|
297
344
|
/**
|
|
298
|
-
*
|
|
299
|
-
* @param {(comment:PawaComment) => void | (() => void)} callback - Effect function,comment for component hacking and optionally returning cleanup .
|
|
300
|
-
* @param {any[] | object | number | null} [deps] - Dependencies or hook type (null=mount).
|
|
301
|
-
* # number - beforemount
|
|
302
|
-
* # null - onMount
|
|
303
|
-
* # array[...deps] - dependency reactive
|
|
304
|
-
* # object<{component:true}|any element from ref> - read alone effect tied to either the component or element
|
|
345
|
+
* Conditional visibility helper component.
|
|
305
346
|
*/
|
|
306
|
-
export
|
|
347
|
+
export const Active: (props: { show: () => boolean; [key: string]: any }) => string;
|
|
307
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Transition helper for enter/exit animation hooks.
|
|
351
|
+
*/
|
|
352
|
+
export const Transition: (props: {
|
|
353
|
+
name?: () => string;
|
|
354
|
+
duration?: () => number;
|
|
355
|
+
enter?: () => any;
|
|
356
|
+
exit?: () => any;
|
|
357
|
+
[key: string]: any;
|
|
358
|
+
}) => string;
|
|
308
359
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
360
|
+
/**
|
|
361
|
+
* Exposes variables into the current component template scope.
|
|
362
|
+
* @param obj Variables to expose.
|
|
363
|
+
*/
|
|
364
|
+
export const useInsert: (obj?: Record<string, any>) => void;
|
|
315
365
|
|
|
316
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Creates a ref object.
|
|
368
|
+
*/
|
|
369
|
+
export const useRef: <T = any>() => { value: T | null };
|
|
317
370
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Tagged template helper for HTML strings.
|
|
373
|
+
*/
|
|
374
|
+
export const html: {
|
|
375
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
376
|
+
(template: string): string;
|
|
377
|
+
};
|
|
322
378
|
|
|
323
379
|
/**
|
|
324
380
|
* Creates a context provider handle.
|
|
325
|
-
* @template T
|
|
326
|
-
* @returns {ContextHandle<T>} Handle to set context values.
|
|
327
381
|
*/
|
|
328
|
-
export
|
|
382
|
+
export const setContext: <T = any>() => ContextHandle<T>;
|
|
329
383
|
|
|
330
384
|
/**
|
|
331
|
-
*
|
|
332
|
-
* @
|
|
333
|
-
* @param {ContextHandle<T>} context - The context handle.
|
|
334
|
-
* @returns {T} The context value.
|
|
385
|
+
* Reads a context value from the currently active component graph.
|
|
386
|
+
* @param context Context handle returned by setContext().
|
|
335
387
|
*/
|
|
336
|
-
export
|
|
388
|
+
export const useContext: <T = any>(context: ContextHandle<T>) => T | undefined;
|
|
337
389
|
|
|
338
390
|
/**
|
|
339
|
-
*
|
|
340
|
-
* @
|
|
341
|
-
* @
|
|
391
|
+
* Validates a component's prop contract.
|
|
392
|
+
* @param component Component constructor.
|
|
393
|
+
* @param object Prop validation map.
|
|
342
394
|
*/
|
|
343
|
-
export
|
|
395
|
+
export const useValidateComponent: (component: Function, object: Record<string, any>) => void;
|
|
344
396
|
|
|
345
397
|
/**
|
|
346
|
-
*
|
|
347
|
-
* Then pawajs adds it into the component unpon re-execution
|
|
348
|
-
* @returns {void}
|
|
398
|
+
* Registers one or more component constructors into the global registry.
|
|
349
399
|
*/
|
|
350
|
-
export
|
|
400
|
+
export const RegisterComponent: {
|
|
401
|
+
(...args: Array<string | Function>): void;
|
|
402
|
+
/**
|
|
403
|
+
* Registers lazy components keyed by name.
|
|
404
|
+
*/
|
|
405
|
+
lazy: (...args: Array<string | string[] | Function>) => Promise<void>;
|
|
406
|
+
};
|
|
407
|
+
|
|
351
408
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* @
|
|
409
|
+
* Runs a lifecycle or reactive side effect.
|
|
410
|
+
* @param callback Effect callback.
|
|
411
|
+
* @param deps Dependency set or lifecycle mode.
|
|
355
412
|
*/
|
|
356
|
-
export
|
|
357
|
-
setServerData: (data: T) => void;
|
|
358
|
-
getServerData: () => T;
|
|
359
|
-
};
|
|
413
|
+
export const runEffect: (callback: (comment?: any) => void | (() => void), deps?: any[] | object | number | null) => void;
|
|
360
414
|
|
|
361
415
|
/**
|
|
362
|
-
*
|
|
363
|
-
* Used in async component.
|
|
364
|
-
* Must be called before any await call
|
|
365
|
-
* + uses onSuspense for loading state before any await
|
|
416
|
+
* Reads the parent component context.
|
|
366
417
|
*/
|
|
367
|
-
export
|
|
418
|
+
export const useInnerContext: <T = any>() => T | undefined;
|
|
368
419
|
|
|
369
420
|
/**
|
|
370
|
-
*
|
|
421
|
+
* Forwards props into the current component scope.
|
|
422
|
+
* @param props Props object to forward.
|
|
371
423
|
*/
|
|
372
|
-
export
|
|
424
|
+
export const forwardProps: (props?: Record<string, any>) => void;
|
|
373
425
|
|
|
374
426
|
/**
|
|
375
|
-
*
|
|
376
|
-
* @param
|
|
427
|
+
* Mounts the visual devtools panel.
|
|
428
|
+
* @param options Optional devtools options.
|
|
377
429
|
*/
|
|
378
|
-
export
|
|
430
|
+
export const mountPawaDevtools: (options?: { open?: boolean }) => () => void;
|
|
379
431
|
|
|
380
432
|
/**
|
|
381
|
-
*
|
|
382
|
-
* @param {Record<string, any>} [obj] - Variables to expose.
|
|
433
|
+
* Removes the devtools panel from the page.
|
|
383
434
|
*/
|
|
384
|
-
export
|
|
435
|
+
export const unmountPawaDevtools: () => void;
|
|
385
436
|
|
|
386
|
-
export function setStateContext(context: any): any;
|
|
387
|
-
export function globalRerender(el:HTMLElement | string,formercontext:StateContextType,context:any)
|
|
388
437
|
/**
|
|
389
|
-
*
|
|
390
|
-
* @template T
|
|
391
|
-
* @param {StateInput<T>} initialValue - Initial value or generator function.
|
|
392
|
-
* @param {string | null | string[]} [section] - Persistence key or dependency array.
|
|
393
|
-
* @returns {State<T>} Reactive state object.
|
|
438
|
+
* Exposes the current root graph instance.
|
|
394
439
|
*/
|
|
395
|
-
export
|
|
440
|
+
export const RootGraph: any;
|
|
396
441
|
|
|
397
|
-
|
|
442
|
+
/**
|
|
443
|
+
* Updates the current component graph.
|
|
444
|
+
*/
|
|
445
|
+
export const setComponentGraph: (graph: any) => void;
|
|
398
446
|
|
|
399
447
|
/**
|
|
400
|
-
*
|
|
401
|
-
* @template T
|
|
402
|
-
* @returns {{ value: T | null }} Ref object.
|
|
448
|
+
* Reads the current component graph.
|
|
403
449
|
*/
|
|
404
|
-
export
|
|
450
|
+
export const getComponentGraph: () => any;
|
|
405
451
|
|
|
406
452
|
/**
|
|
407
|
-
*
|
|
408
|
-
* @param
|
|
409
|
-
* @param
|
|
410
|
-
* @param {any} [notRender] - Internal.
|
|
411
|
-
* @param {boolean} [isName] - Internal.
|
|
453
|
+
* Creates a persistent store that mirrors a state value in localStorage.
|
|
454
|
+
* @param createCall Factory that returns the initial state value.
|
|
455
|
+
* @param name Storage key.
|
|
412
456
|
*/
|
|
413
|
-
export
|
|
457
|
+
export const useStorage: (createCall: () => any, name: string) => any;
|
|
414
458
|
|
|
415
459
|
/**
|
|
416
|
-
*
|
|
417
|
-
* @param
|
|
418
|
-
* @param {Record<string, any>} [context] - Initial context.
|
|
460
|
+
* Schedules a reactive update batch.
|
|
461
|
+
* @param callback Callback to run through the scheduler.
|
|
419
462
|
*/
|
|
420
|
-
export
|
|
463
|
+
export const schedule: (callback: () => void) => void;
|
|
421
464
|
|
|
422
465
|
/**
|
|
423
|
-
*
|
|
424
|
-
* @param
|
|
425
|
-
* @param {...any} values
|
|
466
|
+
* Creates a render graph node.
|
|
467
|
+
* @param graph Optional parent graph.
|
|
426
468
|
*/
|
|
427
|
-
export
|
|
469
|
+
export const Graph: (graph?: any) => PawaGraph;
|
|
428
470
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
pawaStartApp: typeof pawaStartApp;
|
|
437
|
-
useAsync: typeof useAsync;
|
|
438
|
-
useInnerContext: typeof useInnerContext;
|
|
439
|
-
RegisterComponent: typeof RegisterComponent;
|
|
440
|
-
forwardProps: typeof forwardProps;
|
|
441
|
-
runEffect: typeof runEffect;
|
|
442
|
-
html: typeof html;
|
|
471
|
+
/**
|
|
472
|
+
* Creates or reuses the render graph used by the runtime.
|
|
473
|
+
*/
|
|
474
|
+
export const PawaRender: (graph: any, contexts?: Record<string, any>) => {
|
|
475
|
+
render: (el: HTMLElement, refresh?: boolean) => void;
|
|
476
|
+
renderGraph: PawaGraph;
|
|
477
|
+
setContext: (contexts: Record<string, any>) => void;
|
|
443
478
|
};
|
|
444
479
|
|
|
445
|
-
|
|
480
|
+
declare global {
|
|
481
|
+
var __pawaDev: PawaDev;
|
|
482
|
+
var __PAWA_DEBUG__: boolean;
|
|
483
|
+
}
|