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.
Files changed (60) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/LICENSE +1 -1
  3. package/README.md +216 -70
  4. package/examples/Text.js +5 -0
  5. package/examples/index.html +64 -0
  6. package/examples/index.js +31 -0
  7. package/index.d.ts +394 -356
  8. package/index.js +64 -1413
  9. package/package.json +1 -1
  10. package/src/builtIn/Active.js +67 -0
  11. package/src/builtIn/viewTransition.js +42 -0
  12. package/src/component/index.js +194 -0
  13. package/src/component/utils.js +358 -0
  14. package/src/control-flow/attribute.js +83 -0
  15. package/src/control-flow/await.js +78 -0
  16. package/src/control-flow/for.js +220 -0
  17. package/src/control-flow/if.js +127 -0
  18. package/src/control-flow/key.js +87 -0
  19. package/src/control-flow/ref.js +34 -0
  20. package/src/control-flow/state.js +26 -0
  21. package/src/control-flow/template.js +25 -0
  22. package/src/control-flow/text.js +58 -0
  23. package/src/control-flow/timers.js +26 -0
  24. package/src/control-flow/utils.js +42 -0
  25. package/src/dev/index.js +67 -0
  26. package/src/dev/plugin.js +24 -0
  27. package/src/dev/tools.js +89 -0
  28. package/src/event/index.js +212 -0
  29. package/src/global.js +93 -0
  30. package/src/graph/graph.js +156 -0
  31. package/src/graph/index.js +150 -0
  32. package/src/graph/setup.js +28 -0
  33. package/src/hooks/index.js +217 -0
  34. package/src/hooks/registerComponent.js +101 -0
  35. package/src/hooks/state.js +295 -0
  36. package/src/hooks/utils.js +35 -0
  37. package/src/pawaElement.js +159 -0
  38. package/src/reactive.js +251 -0
  39. package/{server.js → src/server/index.js} +6 -4
  40. package/src/store.js +3 -0
  41. package/src/utils.js +56 -0
  42. package/cdn/index.html +0 -25
  43. package/cdn/index.js +0 -23
  44. package/merger/for.js +0 -203
  45. package/merger/if.js +0 -135
  46. package/merger/key.js +0 -117
  47. package/merger/switch.js +0 -134
  48. package/normal/For.js +0 -30
  49. package/normal/If.js +0 -29
  50. package/normal/Key.js +0 -27
  51. package/normal/Switch.js +0 -29
  52. package/normal/component.js +0 -419
  53. package/normal/template.js +0 -33
  54. package/pawaComponent.js +0 -72
  55. package/pawaElement.js +0 -504
  56. package/power.js +0 -667
  57. package/reactive.js +0 -190
  58. package/resumer.js +0 -19
  59. package/server.d.ts +0 -13
  60. 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
- export interface PawaElement extends HTMLElement {
3
- _running: boolean;
4
- _context: any;
5
- _staticContext: Array<string>;
6
- _resetEffects: Set<Function>;
7
- _avoidPawaRender: boolean;
8
- _el: HTMLElement;
9
- _out: boolean;
10
- _terminateEffects: Set<Function>;
11
- _deleteEffects: () => void;
12
- _slots: DocumentFragment;
13
- _stateContext: StateContextType;
14
- _mainAttribute: Record<string, any>;
15
- _preRenderAvoid: string[];
16
- _lazy: boolean;
17
- _await: boolean;
18
- _hasForOrIf: () => boolean;
19
- _elementContent: string | null;
20
- _textContent: Record<string, string>;
21
- _attributes: ({ name: string; value: string } | Attr)[];
22
- _template: string;
23
- _exitAnimation: (() => Promise<void>) | null;
24
- _component: any;
25
- _unMountFunctions: Function[];
26
- _MountFunctions: Function[];
27
- _elementType: string;
28
- _getNode: () => Element | null;
29
- _componentOrTemplate: boolean;
30
- _props: Record<string, any>;
31
- _isView: any;
32
- _isElementComponent: boolean;
33
- _pawaAttribute: Record<string, string>;
34
- _setUnMount: (func: Function) => void;
35
- _componentName: string;
36
- _attrElement: (attrName: string) => HTMLElement;
37
- _attr: Record<string, string>;
38
- _checkStatic: () => void;
39
- _callMount: () => void;
40
- _callUnMOunt: () => Promise<void>;
41
- _remove: (callback?: Function) => Promise<any>;
42
- _componentChildren: string;
43
- _pawaElementComponent: any;
44
- _componentTerminate: Function | null;
45
- _cacheSetUp: boolean;
46
- _effectsCache: HTMLElement | null;
47
- _effectsCarrier: any;
48
- _pawaElementComponentName: string;
49
- _reCallEffect: () => void;
50
- _ElementEffects: Map<any, any>;
51
- _deCompositionElement: boolean;
52
- _restProps: Record<string, any>;
53
- _kill: Function | null;
54
- _isKill: boolean;
55
- _scriptFetching: boolean;
56
- _scriptDone: boolean;
57
- _underControl: any;
58
- _reactiveProps: Record<string, any>;
59
- getChildrenTree(): Element[];
60
- reCallEffect(): void;
61
- setPawaAttr(): void;
62
- findPawaAttribute(): void;
63
- setUnMounts(func: Function): void;
64
- isPawaElementComponent(): void;
65
- getNode(): Element | null;
66
- terminateEffects(): void;
67
- getNewElementByRemovingAttr(attrName: string): HTMLElement;
68
- setAttri(): void;
69
- hasForOrIf(): boolean;
70
- cache(): void;
71
- effectsCache(): HTMLElement | null;
72
- reCheckStaticContext(): void;
73
- remove(callback?: Function): Promise<any>;
74
- unMount(): Promise<void>;
75
- mount(): void;
76
- elementType(): void;
77
- setProps(): void;
78
- safeEval(context: any, expr: string, error?: string, element?: boolean): any;
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
- tool: boolean;
83
- errors: any[];
84
- totalEffect: number;
85
- errorState: any;
86
- components: Set<any>;
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
- performance: {
89
- renderTime: number[];
90
- effectTime: number[];
91
- componentTime: number[];
92
- start: number;
93
- end: number;
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
- declare global {
148
- var __pawaDev: PawaDev;
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
- export interface PawaComment extends Comment {
153
- _index: number | null;
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
- export interface AttriPlugin {
189
- startsWith?: string;
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
- export interface PluginObject {
197
- attribute?: {
198
- register: AttriPlugin[];
199
- };
200
- component?: {
201
- beforeCall?: (stateContext: any, app: any) => void;
202
- afterCall?: (stateContext: any, el: HTMLElement) => void;
203
- };
204
- renderSystem?: {
205
- beforePawa?: (el: HTMLElement, context: any) => void;
206
- afterPawa?: (el: PawaElement) => void;
207
- beforeChildRender?: (el: PawaElement) => void;
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
- value: T;
215
- readonly id: string;
216
- async?: boolean;
217
- failed?: boolean;
218
- retry?: () => void;
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
- * Removes a plugin by name.
247
- * @param {...string} pluginName - Names of plugins to remove.
275
+ * Plugin callback signature used by the dev-plugin system.
248
276
  */
249
- export function removePlugin(...pluginName: string[]): void;
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
- * Registers plugins to extend PawaJS capabilities.
253
- * @param {...(() => PluginObject)} func - Functions returning plugin definitions.
282
+ * Attribute plugin declaration.
254
283
  */
255
- export function PluginSystem(...func: (() => PluginObject)[]): void;
256
-
257
- export function keepContext(context: any): void;
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
- * Internal registry for tracking elements awaiting lazy component loading.
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 lazyComponentElement: Map<string, { element: PawaElement; func: Function }[]>;
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
- export const HmrComponentMap: Map<string, any>;
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
- export function getCurrentContext(): any;
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
- export function setPawaAttributes(...attr: string[]): void;
313
+ /**
314
+ * Returns the active development flag.
315
+ */
316
+ export const getDevelopment: () => boolean;
277
317
 
278
- export function getDependentAttribute(): Set<string>;
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
- export function getPawaAttributes(): Set<string>;
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
- export function getPrimaryDirectives(): Set<string>;
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
- * Registers components for use in templates.
286
- * @param {...(string | Function)} args - Component functions or (name, function - done by pawajs-vite-plugin automaticly) pairs.
339
+ * Detects whether a value is a Pawa proxy.
340
+ * @param value Value to inspect.
287
341
  */
288
- export function RegisterComponent(...args: (string | Function)[]): void;
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
- * Runs a side effect or lifecycle hook.
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 function runEffect(callback: (comment:PawaComment) => void | (() => void), deps?: any[] | object | number | null): void;
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
- export interface PropValidation {
310
- strict?: boolean;
311
- err?: string;
312
- default?: any;
313
- type?: Function | Function[];
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
- export function useValidateComponent(component: Function, object: Record<string, PropValidation>): void;
366
+ /**
367
+ * Creates a ref object.
368
+ */
369
+ export const useRef: <T = any>() => { value: T | null };
317
370
 
318
- export interface ContextHandle<T = any> {
319
- id: string;
320
- setValue: (val?: T) => void;
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 function setContext<T = any>(): ContextHandle<T>;
382
+ export const setContext: <T = any>() => ContextHandle<T>;
329
383
 
330
384
  /**
331
- * Consumes a context value.
332
- * @template T
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 function useContext<T = any>(context: ContextHandle<T>): T;
388
+ export const useContext: <T = any>(context: ContextHandle<T>) => T | undefined;
337
389
 
338
390
  /**
339
- * Gets the context from the parent Element
340
- * @template T
341
- * @returns {T}
391
+ * Validates a component's prop contract.
392
+ * @param component Component constructor.
393
+ * @param object Prop validation map.
342
394
  */
343
- export function useInnerContext<T=any>(): T;
395
+ export const useValidateComponent: (component: Function, object: Record<string, any>) => void;
344
396
 
345
397
  /**
346
- * Tells pawa-ssr to serialize the children prop.
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 function accessChild(): void;
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
- * Tells pawa-ssr to serialized data.
353
- * Then pawajs continuity model de-serializes it and adds to the rendering context or getServerData hook
354
- * @returns {{setServerData:(data:object)=>void,getServerData:()=>any}}
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 function useServer<T = Record<string, any>>(): {
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
- * Stores the component instance into the returned $async hook.
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 function useAsync(): { $async: <T>(callback: () => T) => T ,onSuspense:(html:string)=>void};
418
+ export const useInnerContext: <T = any>() => T | undefined;
368
419
 
369
420
  /**
370
- * Returns TRUE when pawajs is in continous rendering mode from ssr
421
+ * Forwards props into the current component scope.
422
+ * @param props Props object to forward.
371
423
  */
372
- export function isResume(): boolean;
424
+ export const forwardProps: (props?: Record<string, any>) => void;
373
425
 
374
426
  /**
375
- * Forwards props to the child component.
376
- * @param {Record<string, any>} [props] - Props to forward.
427
+ * Mounts the visual devtools panel.
428
+ * @param options Optional devtools options.
377
429
  */
378
- export function forwardProps(props?: Record<string, any>): void;
430
+ export const mountPawaDevtools: (options?: { open?: boolean }) => () => void;
379
431
 
380
432
  /**
381
- * Exposes variables to the template scope.
382
- * @param {Record<string, any>} [obj] - Variables to expose.
433
+ * Removes the devtools panel from the page.
383
434
  */
384
- export function useInsert(obj?: Record<string, any>): void;
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
- * Creates a reactive state.
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 function $state<T>(initialValue: StateInput<T>, section?: string | null | Function[] | Object[] | string[]): State<T>;
440
+ export const RootGraph: any;
396
441
 
397
- export function restoreContext(state_context: any): void;
442
+ /**
443
+ * Updates the current component graph.
444
+ */
445
+ export const setComponentGraph: (graph: any) => void;
398
446
 
399
447
  /**
400
- * Creates a reference object.
401
- * @template T
402
- * @returns {{ value: T | null }} Ref object.
448
+ * Reads the current component graph.
403
449
  */
404
- export function useRef<T = any>(): { value: T | null };
450
+ export const getComponentGraph: () => any;
405
451
 
406
452
  /**
407
- * Renders a component or element.
408
- * @param {HTMLElement} el - Target element.
409
- * @param {object} [contexts] - Context.
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 function render(el: HTMLElement, contexts?: object, notRender?: any, isName?: boolean): void;
457
+ export const useStorage: (createCall: () => any, name: string) => any;
414
458
 
415
459
  /**
416
- * Initializes and starts the Pawa application.
417
- * @param {HTMLElement} app - Root element.
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 function pawaStartApp(app: HTMLElement, context?: Record<string, any>): void;
463
+ export const schedule: (callback: () => void) => void;
421
464
 
422
465
  /**
423
- * Tagged template literal for HTML strings. Enables syntax highlighting in compatible editors.
424
- * @param {TemplateStringsArray} strings
425
- * @param {...any} values
466
+ * Creates a render graph node.
467
+ * @param graph Optional parent graph.
426
468
  */
427
- export function html(strings: TemplateStringsArray, ...values: any[]): string;
469
+ export const Graph: (graph?: any) => PawaGraph;
428
470
 
429
- declare const Pawa: {
430
- useInsert: typeof useInsert;
431
- useContext: typeof useContext;
432
- useValidateComponent: typeof useValidateComponent;
433
- setPawaAttributes: typeof setPawaAttributes;
434
- setContext: typeof setContext;
435
- $state: typeof $state;
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
- export default Pawa;
480
+ declare global {
481
+ var __pawaDev: PawaDev;
482
+ var __PAWA_DEBUG__: boolean;
483
+ }