nuclo 0.2.35 → 0.2.37
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/dist/Element-DLSdmoqX.mjs +2 -0
- package/dist/Element-DLSdmoqX.mjs.map +1 -0
- package/dist/Element-DfxBbUgD.cjs +2 -0
- package/dist/Element-DfxBbUgD.cjs.map +1 -0
- package/dist/nuclo.cjs +1 -1
- package/dist/nuclo.cjs.map +1 -1
- package/dist/nuclo.mjs +1 -1
- package/dist/nuclo.mjs.map +1 -1
- package/dist/polyfill/nuclo.polyfill.cjs +1 -1
- package/dist/polyfill/nuclo.polyfill.cjs.map +1 -1
- package/dist/polyfill/nuclo.polyfill.mjs +1 -1
- package/dist/polyfill/nuclo.polyfill.mjs.map +1 -1
- package/dist/ssr/nuclo.ssr.cjs +1 -1
- package/dist/ssr/nuclo.ssr.cjs.map +1 -1
- package/dist/ssr/nuclo.ssr.mjs +1 -1
- package/dist/ssr/nuclo.ssr.mjs.map +1 -1
- package/package.json +4 -20
- package/types/core/base.d.ts +1 -4
- package/types/features/list.d.ts +0 -1
- package/types/index.d.ts +0 -53
- package/types/polyfill.d.ts +9 -44
- package/types/ssr.d.ts +0 -6
- package/dist/Element-BUdteOsZ.cjs +0 -2
- package/dist/Element-BUdteOsZ.cjs.map +0 -1
- package/dist/Element-Djosl17E.mjs +0 -2
- package/dist/Element-Djosl17E.mjs.map +0 -1
- package/dist/bootstrap.d.ts +0 -5
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/element/attributes.d.ts +0 -6
- package/dist/element/attributes.d.ts.map +0 -1
- package/dist/element/class-name.d.ts +0 -6
- package/dist/element/class-name.d.ts.map +0 -1
- package/dist/element/event-attributes.d.ts +0 -5
- package/dist/element/event-attributes.d.ts.map +0 -1
- package/dist/element/events.d.ts +0 -46
- package/dist/element/events.d.ts.map +0 -1
- package/dist/element/factory-meta.d.ts +0 -27
- package/dist/element/factory-meta.d.ts.map +0 -1
- package/dist/element/factory.d.ts +0 -32
- package/dist/element/factory.d.ts.map +0 -1
- package/dist/element/inline-style.d.ts +0 -9
- package/dist/element/inline-style.d.ts.map +0 -1
- package/dist/element/lifecycle.d.ts +0 -106
- package/dist/element/lifecycle.d.ts.map +0 -1
- package/dist/element/modifiers.d.ts +0 -11
- package/dist/element/modifiers.d.ts.map +0 -1
- package/dist/element/tags.d.ts +0 -5
- package/dist/element/tags.d.ts.map +0 -1
- package/dist/hydration.d.ts +0 -73
- package/dist/hydration.d.ts.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +0 -1
- package/dist/list/index.d.ts +0 -7
- package/dist/list/index.d.ts.map +0 -1
- package/dist/list/runtime.d.ts +0 -6
- package/dist/list/runtime.d.ts.map +0 -1
- package/dist/list/template.d.ts +0 -113
- package/dist/list/template.d.ts.map +0 -1
- package/dist/list/types.d.ts +0 -57
- package/dist/list/types.d.ts.map +0 -1
- package/dist/nuclo.umd.js +0 -2
- package/dist/nuclo.umd.js.map +0 -1
- package/dist/polyfill/Document.d.ts +0 -19
- package/dist/polyfill/Document.d.ts.map +0 -1
- package/dist/polyfill/Element.d.ts +0 -48
- package/dist/polyfill/Element.d.ts.map +0 -1
- package/dist/polyfill/Event.d.ts +0 -43
- package/dist/polyfill/Event.d.ts.map +0 -1
- package/dist/polyfill/Node.d.ts +0 -13
- package/dist/polyfill/Node.d.ts.map +0 -1
- package/dist/polyfill/Text.d.ts +0 -11
- package/dist/polyfill/Text.d.ts.map +0 -1
- package/dist/polyfill/index.d.ts +0 -24
- package/dist/polyfill/index.d.ts.map +0 -1
- package/dist/render.d.ts +0 -33
- package/dist/render.d.ts.map +0 -1
- package/dist/shared/conditions.d.ts +0 -4
- package/dist/shared/conditions.d.ts.map +0 -1
- package/dist/shared/dom.d.ts +0 -80
- package/dist/shared/dom.d.ts.map +0 -1
- package/dist/shared/environment.d.ts +0 -5
- package/dist/shared/environment.d.ts.map +0 -1
- package/dist/shared/errors.d.ts +0 -2
- package/dist/shared/errors.d.ts.map +0 -1
- package/dist/shared/renderables.d.ts +0 -4
- package/dist/shared/renderables.d.ts.map +0 -1
- package/dist/shared/strings.d.ts +0 -19
- package/dist/shared/strings.d.ts.map +0 -1
- package/dist/shared/type-guards.d.ts +0 -16
- package/dist/shared/type-guards.d.ts.map +0 -1
- package/dist/ssr/index.d.ts +0 -19
- package/dist/ssr/index.d.ts.map +0 -1
- package/dist/ssr/render-to-string.d.ts +0 -41
- package/dist/ssr/render-to-string.d.ts.map +0 -1
- package/dist/style/css.d.ts +0 -26
- package/dist/style/css.d.ts.map +0 -1
- package/dist/style/engine.d.ts +0 -94
- package/dist/style/engine.d.ts.map +0 -1
- package/dist/style/index.d.ts +0 -3
- package/dist/style/index.d.ts.map +0 -1
- package/dist/update/conditional.d.ts +0 -3
- package/dist/update/conditional.d.ts.map +0 -1
- package/dist/update/reactive-attributes.d.ts +0 -45
- package/dist/update/reactive-attributes.d.ts.map +0 -1
- package/dist/update/reactive-text.d.ts +0 -38
- package/dist/update/reactive-text.d.ts.map +0 -1
- package/dist/update/registry.d.ts +0 -116
- package/dist/update/registry.d.ts.map +0 -1
- package/dist/update/scope.d.ts +0 -7
- package/dist/update/scope.d.ts.map +0 -1
- package/dist/update/update.d.ts +0 -4
- package/dist/update/update.d.ts.map +0 -1
- package/dist/when/builder.d.ts +0 -16
- package/dist/when/builder.d.ts.map +0 -1
- package/dist/when/index.d.ts +0 -44
- package/dist/when/index.d.ts.map +0 -1
- package/dist/when/runtime.d.ts +0 -59
- package/dist/when/runtime.d.ts.map +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { UpdateScope } from "./scope";
|
|
2
|
-
import type { AttributeResolver } from "./registry";
|
|
3
|
-
/**
|
|
4
|
-
* Registers a reactive attribute resolver for an element.
|
|
5
|
-
*
|
|
6
|
-
* The resolver will be called whenever reactive updates run (e.g. via `update()`),
|
|
7
|
-
* or when an `"update"` event is dispatched on the element (or a descendant),
|
|
8
|
-
* allowing attributes to reactively update based on application state.
|
|
9
|
-
*
|
|
10
|
-
* @param element - The DOM element to make reactive
|
|
11
|
-
* @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')
|
|
12
|
-
* @param resolver - Function that returns the new attribute value
|
|
13
|
-
* @param applyValue - Callback that applies the resolved value to the element
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const isActive = signal(false);
|
|
18
|
-
* const button = document.createElement('button');
|
|
19
|
-
* registerAttributeResolver(
|
|
20
|
-
* button,
|
|
21
|
-
* 'class',
|
|
22
|
-
* () => isActive.value ? 'active' : 'inactive',
|
|
23
|
-
* (value) => button.className = String(value)
|
|
24
|
-
* );
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function registerAttributeResolver<TTagName extends ElementTagName>(element: ExpandedElement<TTagName>, key: string, resolver: AttributeResolver, applyValue: (value: unknown) => void): void;
|
|
28
|
-
/**
|
|
29
|
-
* Updates all registered reactive elements by re-evaluating their attribute resolvers.
|
|
30
|
-
*
|
|
31
|
-
* Iterates through all reactive elements and triggers their registered attribute resolvers
|
|
32
|
-
* to update. Automatically cleans up disconnected elements and their event listeners.
|
|
33
|
-
*
|
|
34
|
-
* This function should be called after state changes to synchronize element attributes
|
|
35
|
-
* with application state.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* // After updating application state
|
|
40
|
-
* isActive.value = true;
|
|
41
|
-
* notifyReactiveElements(); // All reactive attributes update
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function notifyReactiveElements(scope?: UpdateScope): void;
|
|
45
|
-
//# sourceMappingURL=reactive-attributes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactive-attributes.d.ts","sourceRoot":"","sources":["../../src/update/reactive-attributes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAgD,MAAM,YAAY,CAAC;AA+ElG;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,SAAS,cAAc,EACvE,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACnC,IAAI,CA4BN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAwBhE"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { UpdateScope } from "./scope";
|
|
2
|
-
import type { TextResolver } from "./registry";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a reactive text node that automatically updates when its resolver function changes.
|
|
5
|
-
*
|
|
6
|
-
* The text node will be registered for reactive updates and its content will be synchronized
|
|
7
|
-
* whenever notifyReactiveTextNodes() is called.
|
|
8
|
-
*
|
|
9
|
-
* @param resolver - Function that returns the text content (string, number, boolean, etc.)
|
|
10
|
-
* @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately
|
|
11
|
-
* @returns A Text node that will reactively update its content
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const count = signal(0);
|
|
16
|
-
* const textNode = createReactiveTextNode(() => `Count: ${count.value}`);
|
|
17
|
-
* // Later, when count changes and notifyReactiveTextNodes() is called,
|
|
18
|
-
* // the text content automatically updates
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown, sanitize?: boolean): Text | DocumentFragment;
|
|
22
|
-
/**
|
|
23
|
-
* Updates all registered reactive text nodes.
|
|
24
|
-
*
|
|
25
|
-
* Iterates through all reactive text nodes, re-evaluates their resolver functions,
|
|
26
|
-
* and updates their content if it has changed. Automatically cleans up disconnected nodes.
|
|
27
|
-
*
|
|
28
|
-
* This function should be called after state changes to synchronize the DOM with application state.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* // After updating application state
|
|
33
|
-
* count.value++;
|
|
34
|
-
* notifyReactiveTextNodes(); // All reactive text nodes update
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function notifyReactiveTextNodes(scope?: UpdateScope): void;
|
|
38
|
-
//# sourceMappingURL=reactive-text.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactive-text.d.ts","sourceRoot":"","sources":["../../src/update/reactive-text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAgClI;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CA0CjE"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types and registries for reactive nodes.
|
|
3
|
-
* Single source of truth — imported by reactiveText.ts and reactiveAttributes.ts.
|
|
4
|
-
*
|
|
5
|
-
* Registry structure: the iteration sets only hold WeakRefs; the actual info
|
|
6
|
-
* records live in WeakMaps keyed by the node. Info records may strongly
|
|
7
|
-
* reference the node (e.g. attribute applyValue closures capture the
|
|
8
|
-
* element), so storing them in a strongly-held map would pin the node in
|
|
9
|
-
* memory forever. With WeakMap storage the whole record is collectible as
|
|
10
|
-
* soon as the node is unreachable.
|
|
11
|
-
*
|
|
12
|
-
* Dead WeakRefs left in the iteration sets are pruned by the notify passes as
|
|
13
|
-
* they iterate (deref() === undefined, or node disconnected). Registration is
|
|
14
|
-
* the hottest path in list-heavy renders (one text node + often one element
|
|
15
|
-
* per row), so no per-node FinalizationRegistry is used here: its register()
|
|
16
|
-
* cost per row outweighs keeping the sets tidy between updates, and a stale
|
|
17
|
-
* husk is just an empty WeakRef until the next update() sweeps it.
|
|
18
|
-
*/
|
|
19
|
-
export type TextResolver = () => Primitive;
|
|
20
|
-
export interface ReactiveTextNodeInfo {
|
|
21
|
-
resolver: TextResolver;
|
|
22
|
-
lastValue: string;
|
|
23
|
-
/**
|
|
24
|
-
* DSL semantics: nullish and non-primitive resolver results render as ""
|
|
25
|
-
* (instead of String(value)). Set by the tag-builder text path so it can
|
|
26
|
-
* register the user's resolver directly rather than allocating a
|
|
27
|
-
* sanitizing wrapper closure per text node.
|
|
28
|
-
*/
|
|
29
|
-
sanitize?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export type AttributeResolver = () => unknown;
|
|
32
|
-
export interface AttributeResolverRecord {
|
|
33
|
-
key: string;
|
|
34
|
-
resolver: AttributeResolver;
|
|
35
|
-
applyValue: (value: unknown) => void;
|
|
36
|
-
lastValue: unknown;
|
|
37
|
-
}
|
|
38
|
-
export interface ReactiveElementInfo {
|
|
39
|
-
/**
|
|
40
|
-
* Flat keyed array rather than a Map: elements almost always carry one or
|
|
41
|
-
* two reactive attributes, so linear key lookup on registration beats a Map
|
|
42
|
-
* allocation per element, and the per-update flush iterates with a plain
|
|
43
|
-
* index loop (no iterator/destructuring allocations).
|
|
44
|
-
*/
|
|
45
|
-
attributeResolvers: AttributeResolverRecord[];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Iteration set of weak references to reactive text nodes.
|
|
49
|
-
*/
|
|
50
|
-
export declare const reactiveTextNodes: Set<WeakRef<Text>>;
|
|
51
|
-
/**
|
|
52
|
-
* WeakMap for O(1) lookups of reactive text node info by node reference.
|
|
53
|
-
*/
|
|
54
|
-
export declare const reactiveTextNodesByNode: WeakMap<Text, {
|
|
55
|
-
ref: WeakRef<Text>;
|
|
56
|
-
info: ReactiveTextNodeInfo;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* Iteration set of weak references to reactive elements.
|
|
60
|
-
*/
|
|
61
|
-
export declare const reactiveElements: Set<WeakRef<Element>>;
|
|
62
|
-
/**
|
|
63
|
-
* WeakMap for O(1) lookups of reactive element info by element reference.
|
|
64
|
-
*/
|
|
65
|
-
export declare const reactiveElementsByNode: WeakMap<Element, {
|
|
66
|
-
ref: WeakRef<Element>;
|
|
67
|
-
info: ReactiveElementInfo;
|
|
68
|
-
}>;
|
|
69
|
-
/**
|
|
70
|
-
* Registers a reactive text node in both lookup structures.
|
|
71
|
-
*/
|
|
72
|
-
export declare function registerReactiveTextNode(node: Text, info: ReactiveTextNodeInfo): void;
|
|
73
|
-
/**
|
|
74
|
-
* Registers a reactive element in both lookup structures.
|
|
75
|
-
*/
|
|
76
|
-
export declare function registerReactiveElement(element: Element, info: ReactiveElementInfo): void;
|
|
77
|
-
/**
|
|
78
|
-
* Removes a reactive text node's WeakRef entry from the iteration set.
|
|
79
|
-
*/
|
|
80
|
-
export declare function removeReactiveTextNodeRef(ref: WeakRef<Text>): void;
|
|
81
|
-
/**
|
|
82
|
-
* Removes a reactive element's WeakRef entry from the iteration set.
|
|
83
|
-
*/
|
|
84
|
-
export declare function removeReactiveElementRef(ref: WeakRef<Element>): void;
|
|
85
|
-
/**
|
|
86
|
-
* Manually removes reactive text node info for a specific text node.
|
|
87
|
-
* This should be called when a text node is removed from the DOM to prevent memory leaks.
|
|
88
|
-
*/
|
|
89
|
-
export declare function cleanupReactiveTextNode(node: Text): void;
|
|
90
|
-
/**
|
|
91
|
-
* Manually removes reactive element info for a specific element.
|
|
92
|
-
* This should be called when an element is removed from the DOM to prevent memory leaks.
|
|
93
|
-
*/
|
|
94
|
-
export declare function cleanupReactiveElement(element: Element): void;
|
|
95
|
-
export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {
|
|
96
|
-
condition: () => boolean;
|
|
97
|
-
tagName: TTagName;
|
|
98
|
-
modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;
|
|
99
|
-
isSvg: boolean;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Attach conditional info to a node and register it.
|
|
103
|
-
*/
|
|
104
|
-
export declare function storeConditionalInfo<TTagName extends ElementTagName>(node: Node, info: ConditionalInfo<TTagName>): void;
|
|
105
|
-
/**
|
|
106
|
-
* Explicit unregister helper (optional use on teardown if needed).
|
|
107
|
-
* O(1) via reverse lookup WeakMap.
|
|
108
|
-
*/
|
|
109
|
-
export declare function unregisterConditionalNode(node: Node): void;
|
|
110
|
-
/**
|
|
111
|
-
* Returns an array of currently tracked conditional nodes that are still alive.
|
|
112
|
-
* Automatically cleans up garbage-collected nodes.
|
|
113
|
-
*/
|
|
114
|
-
export declare function getActiveConditionalNodes(): Node[];
|
|
115
|
-
export declare function getConditionalInfo(node: Node): ConditionalInfo<ElementTagName> | null;
|
|
116
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/update/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC;AAE9C,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,EAAE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,CAAC,CAAC,CAAC;IAC1D,KAAK,EAAE,OAAO,CAAC;CACf;AAyBD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,cAAc,EACnE,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,GAC7B,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,EAAE,CAalD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAErF"}
|
package/dist/update/scope.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export interface UpdateScope {
|
|
2
|
-
roots: ReadonlyArray<Element>;
|
|
3
|
-
contains(node: Node): boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare function getScopeRoots(ids: readonly string[]): Element[];
|
|
6
|
-
export declare function scope<TTagName extends ElementTagName = ElementTagName>(...ids: string[]): NodeModFn<TTagName>;
|
|
7
|
-
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/update/scope.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;CAC/B;AAoCD,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,EAAE,CAoC/D;AAED,wBAAgB,KAAK,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EACpE,GAAG,GAAG,EAAE,MAAM,EAAE,GACf,SAAS,CAAC,QAAQ,CAAC,CAQrB"}
|
package/dist/update/update.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/update/update.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAY3C,wBAAgB,MAAM,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAiClD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAqBnE"}
|
package/dist/when/builder.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { WhenCondition, WhenContent, WhenGroup } from "./runtime";
|
|
2
|
-
declare class WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {
|
|
3
|
-
private groups;
|
|
4
|
-
private elseContent;
|
|
5
|
-
constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]);
|
|
6
|
-
cloneWith(additionalGroup?: WhenGroup<TTagName>, newElseContent?: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName>;
|
|
7
|
-
when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName>;
|
|
8
|
-
else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName>;
|
|
9
|
-
render(host: ExpandedElement<TTagName>, index: number): Node | null;
|
|
10
|
-
private freshRender;
|
|
11
|
-
private hydrateRender;
|
|
12
|
-
private createRuntimeFromMarkers;
|
|
13
|
-
}
|
|
14
|
-
export declare function createWhenBuilderFunction<TTagName extends ElementTagName>(builder: WhenBuilderImpl<TTagName>): WhenBuilder<TTagName>;
|
|
15
|
-
export { WhenBuilderImpl };
|
|
16
|
-
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/when/builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAe,MAAM,WAAW,CAAC;AAyBpF,cAAM,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IACpE,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,WAAW,CAA+B;IAElD,YAAY,gBAAgB,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,EAE/E;IAED,SAAS,CACP,eAAe,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EACrC,cAAc,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GACvC,eAAe,CAAC,QAAQ,CAAC,CAM3B;IAED,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAG7F;IAED,IAAI,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAGnE;IAED,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAUlE;IAED,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAgFrB,OAAO,CAAC,wBAAwB;CAwBjC;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,SAAS,cAAc,EACvE,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,WAAW,CAAC,QAAQ,CAAC,CAavB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/when/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { WhenCondition, WhenContent } from "./runtime";
|
|
2
|
-
export { updateWhenRuntimes } from "./runtime";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a conditional rendering block (when/else logic).
|
|
5
|
-
*
|
|
6
|
-
* Renders different content based on boolean conditions, similar to if/else statements.
|
|
7
|
-
* Conditions can be static booleans or reactive functions that are re-evaluated on updates.
|
|
8
|
-
*
|
|
9
|
-
* @param condition - Boolean value or function returning a boolean
|
|
10
|
-
* @param content - Content to render when condition is true
|
|
11
|
-
* @returns A builder that allows chaining additional .when() or .else() branches
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const isLoggedIn = signal(false);
|
|
16
|
-
*
|
|
17
|
-
* div(
|
|
18
|
-
* when(() => isLoggedIn.value,
|
|
19
|
-
* span('Welcome back!')
|
|
20
|
-
* )
|
|
21
|
-
* .else(
|
|
22
|
-
* button('Login', on('click', () => login()))
|
|
23
|
-
* )
|
|
24
|
-
* )
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* // Multiple conditions
|
|
30
|
-
* div(
|
|
31
|
-
* when(() => status.value === 'loading',
|
|
32
|
-
* spinner()
|
|
33
|
-
* )
|
|
34
|
-
* .when(() => status.value === 'error',
|
|
35
|
-
* errorMessage()
|
|
36
|
-
* )
|
|
37
|
-
* .else(
|
|
38
|
-
* contentView()
|
|
39
|
-
* )
|
|
40
|
-
* )
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function when<TTagName extends ElementTagName = ElementTagName>(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName>;
|
|
44
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/when/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/when/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,IAAI,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EACnE,SAAS,EAAE,aAAa,EACxB,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,GAClC,WAAW,CAAC,QAAQ,CAAC,CAGvB"}
|
package/dist/when/runtime.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { UpdateScope } from "../update/scope";
|
|
2
|
-
export type WhenCondition = boolean | (() => boolean);
|
|
3
|
-
export type WhenContent<TTagName extends ElementTagName = ElementTagName> = NodeModLike<TTagName>;
|
|
4
|
-
export interface WhenGroup<TTagName extends ElementTagName = ElementTagName> {
|
|
5
|
-
condition: WhenCondition;
|
|
6
|
-
content: WhenContent<TTagName>[];
|
|
7
|
-
}
|
|
8
|
-
export interface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {
|
|
9
|
-
startMarker: Comment;
|
|
10
|
-
endMarker: Comment;
|
|
11
|
-
host: ExpandedElement<TTagName>;
|
|
12
|
-
index: number;
|
|
13
|
-
groups: WhenGroup<TTagName>[];
|
|
14
|
-
elseContent: WhenContent<TTagName>[];
|
|
15
|
-
/**
|
|
16
|
-
* Tracks which branch is currently rendered:
|
|
17
|
-
* - null: nothing rendered yet (initial state)
|
|
18
|
-
* - -1: else branch is active
|
|
19
|
-
* - >= 0: groups[activeIndex] is active
|
|
20
|
-
*/
|
|
21
|
-
activeIndex: number | null;
|
|
22
|
-
update(): void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Evaluates which condition branch should be active.
|
|
26
|
-
* Returns the index of the first truthy condition, -1 for else branch, or null for no match.
|
|
27
|
-
*/
|
|
28
|
-
export declare function evaluateActiveCondition<TTagName extends ElementTagName>(groups: ReadonlyArray<WhenGroup<TTagName>>, elseContent: ReadonlyArray<WhenContent<TTagName>>): number | null;
|
|
29
|
-
/**
|
|
30
|
-
* Main render function for when/else conditionals.
|
|
31
|
-
* Evaluates conditions, clears old content, and renders the active branch.
|
|
32
|
-
*/
|
|
33
|
-
export declare function renderWhenContent<TTagName extends ElementTagName>(runtime: WhenRuntime<TTagName>): void;
|
|
34
|
-
/**
|
|
35
|
-
* Registers a when runtime for tracking and updates.
|
|
36
|
-
* Uses WeakRef to prevent memory leaks when elements are removed.
|
|
37
|
-
* The runtime object itself is mutable and will be updated in place.
|
|
38
|
-
*/
|
|
39
|
-
export declare function registerWhenRuntime<TTagName extends ElementTagName>(runtime: WhenRuntime<TTagName>): void;
|
|
40
|
-
/**
|
|
41
|
-
* Updates all active when/else conditional runtimes.
|
|
42
|
-
*
|
|
43
|
-
* Re-evaluates all conditional branches and re-renders if the active branch has changed.
|
|
44
|
-
* Automatically cleans up runtimes that are garbage collected or disconnected from DOM.
|
|
45
|
-
*
|
|
46
|
-
* This function should be called after state changes that affect conditional expressions.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* isLoggedIn.value = true;
|
|
51
|
-
* updateWhenRuntimes(); // All when() conditionals re-evaluate
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare function updateWhenRuntimes(scope?: UpdateScope): void;
|
|
55
|
-
/**
|
|
56
|
-
* Renders a list of content items and collects the resulting nodes.
|
|
57
|
-
*/
|
|
58
|
-
export declare function renderContentItems<TTagName extends ElementTagName>(items: ReadonlyArray<WhenContent<TTagName>>, host: ExpandedElement<TTagName>, index: number, endMarker: Comment): Node[];
|
|
59
|
-
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/when/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AACtD,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,IACtE,WAAW,CAAC,QAAQ,CAAC,CAAC;AAExB,MAAM,W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