@pithyjs/core 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +513 -0
- package/dist/a11y/focus-trap.d.ts +109 -0
- package/dist/a11y/focus-trap.d.ts.map +1 -0
- package/dist/a11y/focus-trap.js +246 -0
- package/dist/a11y/focus-trap.js.map +1 -0
- package/dist/a11y/index.d.ts +12 -0
- package/dist/a11y/index.d.ts.map +1 -0
- package/dist/a11y/index.js +16 -0
- package/dist/a11y/index.js.map +1 -0
- package/dist/a11y/keyboard-utils.d.ts +165 -0
- package/dist/a11y/keyboard-utils.d.ts.map +1 -0
- package/dist/a11y/keyboard-utils.js +321 -0
- package/dist/a11y/keyboard-utils.js.map +1 -0
- package/dist/a11y/roving-tabindex.d.ts +118 -0
- package/dist/a11y/roving-tabindex.d.ts.map +1 -0
- package/dist/a11y/roving-tabindex.js +249 -0
- package/dist/a11y/roving-tabindex.js.map +1 -0
- package/dist/a11y/skip-link.d.ts +55 -0
- package/dist/a11y/skip-link.d.ts.map +1 -0
- package/dist/a11y/skip-link.js +164 -0
- package/dist/a11y/skip-link.js.map +1 -0
- package/dist/compile/bindSwitchCases.d.ts +16 -0
- package/dist/compile/bindSwitchCases.d.ts.map +1 -0
- package/dist/compile/bindSwitchCases.js +323 -0
- package/dist/compile/bindSwitchCases.js.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts +14 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.js +57 -0
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -0
- package/dist/compile/binds/bindClassDirectives.d.ts +20 -0
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindClassDirectives.js +94 -0
- package/dist/compile/binds/bindClassDirectives.js.map +1 -0
- package/dist/compile/binds/bindComponentsTags.d.ts +17 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -0
- package/dist/compile/binds/bindComponentsTags.js +355 -0
- package/dist/compile/binds/bindComponentsTags.js.map +1 -0
- package/dist/compile/binds/bindConditionals.d.ts +16 -0
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -0
- package/dist/compile/binds/bindConditionals.js +102 -0
- package/dist/compile/binds/bindConditionals.js.map +1 -0
- package/dist/compile/binds/bindDefaultTwoWay.d.ts +35 -0
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -0
- package/dist/compile/binds/bindDefaultTwoWay.js +128 -0
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -0
- package/dist/compile/binds/bindDeferDirectives.d.ts +21 -0
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindDeferDirectives.js +465 -0
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts +71 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -0
- package/dist/compile/binds/bindErrorBoundary.js +389 -0
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -0
- package/dist/compile/binds/bindEventHandlers.d.ts +17 -0
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -0
- package/dist/compile/binds/bindEventHandlers.js +174 -0
- package/dist/compile/binds/bindEventHandlers.js.map +1 -0
- package/dist/compile/binds/bindRefDirectives.d.ts +14 -0
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindRefDirectives.js +35 -0
- package/dist/compile/binds/bindRefDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +16 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.js +408 -0
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -0
- package/dist/compile/binds/directiveRegistry.d.ts +46 -0
- package/dist/compile/binds/directiveRegistry.d.ts.map +1 -0
- package/dist/compile/binds/directiveRegistry.js +50 -0
- package/dist/compile/binds/directiveRegistry.js.map +1 -0
- package/dist/compile/compileExpression.d.ts +10 -0
- package/dist/compile/compileExpression.d.ts.map +1 -0
- package/dist/compile/compileExpression.js +26 -0
- package/dist/compile/compileExpression.js.map +1 -0
- package/dist/compile/compileNodes.d.ts +32 -0
- package/dist/compile/compileNodes.d.ts.map +1 -0
- package/dist/compile/compileNodes.js +104 -0
- package/dist/compile/compileNodes.js.map +1 -0
- package/dist/compile/compileTemplate.d.ts +64 -0
- package/dist/compile/compileTemplate.d.ts.map +1 -0
- package/dist/compile/compileTemplate.js +157 -0
- package/dist/compile/compileTemplate.js.map +1 -0
- package/dist/compile/contentProjection.d.ts +29 -0
- package/dist/compile/contentProjection.d.ts.map +1 -0
- package/dist/compile/contentProjection.js +210 -0
- package/dist/compile/contentProjection.js.map +1 -0
- package/dist/compile/forLoops/bindForLoops.d.ts +21 -0
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -0
- package/dist/compile/forLoops/bindForLoops.js +151 -0
- package/dist/compile/forLoops/bindForLoops.js.map +1 -0
- package/dist/compile/forLoops/createLoopManager.d.ts +51 -0
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -0
- package/dist/compile/forLoops/createLoopManager.js +429 -0
- package/dist/compile/forLoops/createLoopManager.js.map +1 -0
- package/dist/compile/forLoops/index.d.ts +6 -0
- package/dist/compile/forLoops/index.d.ts.map +1 -0
- package/dist/compile/forLoops/index.js +8 -0
- package/dist/compile/forLoops/index.js.map +1 -0
- package/dist/compile/forLoops/loopHelpers.d.ts +33 -0
- package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -0
- package/dist/compile/forLoops/loopHelpers.js +69 -0
- package/dist/compile/forLoops/loopHelpers.js.map +1 -0
- package/dist/compile/forLoops/loopSignals.d.ts +36 -0
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -0
- package/dist/compile/forLoops/loopSignals.js +64 -0
- package/dist/compile/forLoops/loopSignals.js.map +1 -0
- package/dist/compile/forLoops/loopTraversal.d.ts +18 -0
- package/dist/compile/forLoops/loopTraversal.d.ts.map +1 -0
- package/dist/compile/forLoops/loopTraversal.js +38 -0
- package/dist/compile/forLoops/loopTraversal.js.map +1 -0
- package/dist/compile/handleConditionalChain.d.ts +15 -0
- package/dist/compile/handleConditionalChain.d.ts.map +1 -0
- package/dist/compile/handleConditionalChain.js +181 -0
- package/dist/compile/handleConditionalChain.js.map +1 -0
- package/dist/compile/index.d.ts +15 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +19 -0
- package/dist/compile/index.js.map +1 -0
- package/dist/compile/injectScopedStyle.d.ts +16 -0
- package/dist/compile/injectScopedStyle.d.ts.map +1 -0
- package/dist/compile/injectScopedStyle.js +50 -0
- package/dist/compile/injectScopedStyle.js.map +1 -0
- package/dist/compile/nodeExpando.d.ts +12 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -0
- package/dist/compile/nodeExpando.js +4 -0
- package/dist/compile/nodeExpando.js.map +1 -0
- package/dist/compile/parseHtml.d.ts +70 -0
- package/dist/compile/parseHtml.d.ts.map +1 -0
- package/dist/compile/parseHtml.js +164 -0
- package/dist/compile/parseHtml.js.map +1 -0
- package/dist/compile/pithyTreeToDom.d.ts +16 -0
- package/dist/compile/pithyTreeToDom.d.ts.map +1 -0
- package/dist/compile/pithyTreeToDom.js +118 -0
- package/dist/compile/pithyTreeToDom.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +50 -0
- package/dist/compile/renderChildren.d.ts.map +1 -0
- package/dist/compile/renderChildren.js +76 -0
- package/dist/compile/renderChildren.js.map +1 -0
- package/dist/compile/ssrMode.d.ts +17 -0
- package/dist/compile/ssrMode.d.ts.map +1 -0
- package/dist/compile/ssrMode.js +20 -0
- package/dist/compile/ssrMode.js.map +1 -0
- package/dist/compile/textValue.d.ts +28 -0
- package/dist/compile/textValue.d.ts.map +1 -0
- package/dist/compile/textValue.js +30 -0
- package/dist/compile/textValue.js.map +1 -0
- package/dist/config/index.d.ts +37 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +16 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/ref-signal.interface.d.ts +6 -0
- package/dist/interfaces/ref-signal.interface.d.ts.map +1 -0
- package/dist/interfaces/ref-signal.interface.js +2 -0
- package/dist/interfaces/ref-signal.interface.js.map +1 -0
- package/dist/interfaces/ref.interface.d.ts +5 -0
- package/dist/interfaces/ref.interface.d.ts.map +1 -0
- package/dist/interfaces/ref.interface.js +2 -0
- package/dist/interfaces/ref.interface.js.map +1 -0
- package/dist/runtime/applyBindings.d.ts +36 -0
- package/dist/runtime/applyBindings.d.ts.map +1 -0
- package/dist/runtime/applyBindings.js +165 -0
- package/dist/runtime/applyBindings.js.map +1 -0
- package/dist/runtime/bindings/applyComponent.d.ts +3 -0
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -0
- package/dist/runtime/bindings/applyComponent.js +190 -0
- package/dist/runtime/bindings/applyComponent.js.map +1 -0
- package/dist/runtime/bindings/applyDefer.d.ts +11 -0
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -0
- package/dist/runtime/bindings/applyDefer.js +422 -0
- package/dist/runtime/bindings/applyDefer.js.map +1 -0
- package/dist/runtime/bindings/applySimple.d.ts +11 -0
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -0
- package/dist/runtime/bindings/applySimple.js +346 -0
- package/dist/runtime/bindings/applySimple.js.map +1 -0
- package/dist/runtime/bindings/applyStructural.d.ts +5 -0
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -0
- package/dist/runtime/bindings/applyStructural.js +312 -0
- package/dist/runtime/bindings/applyStructural.js.map +1 -0
- package/dist/runtime/bindings/helpers.d.ts +56 -0
- package/dist/runtime/bindings/helpers.d.ts.map +1 -0
- package/dist/runtime/bindings/helpers.js +121 -0
- package/dist/runtime/bindings/helpers.js.map +1 -0
- package/dist/runtime/bindings/index.d.ts +7 -0
- package/dist/runtime/bindings/index.d.ts.map +1 -0
- package/dist/runtime/bindings/index.js +6 -0
- package/dist/runtime/bindings/index.js.map +1 -0
- package/dist/runtime/bindings/types.d.ts +105 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -0
- package/dist/runtime/bindings/types.js +5 -0
- package/dist/runtime/bindings/types.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts +59 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -0
- package/dist/runtime/bootstrap.js +82 -0
- package/dist/runtime/bootstrap.js.map +1 -0
- package/dist/runtime/createContextProxy.d.ts +10 -0
- package/dist/runtime/createContextProxy.d.ts.map +1 -0
- package/dist/runtime/createContextProxy.js +45 -0
- package/dist/runtime/createContextProxy.js.map +1 -0
- package/dist/runtime/deferHelpers.d.ts +49 -0
- package/dist/runtime/deferHelpers.d.ts.map +1 -0
- package/dist/runtime/deferHelpers.js +65 -0
- package/dist/runtime/deferHelpers.js.map +1 -0
- package/dist/runtime/html.d.ts +23 -0
- package/dist/runtime/html.d.ts.map +1 -0
- package/dist/runtime/html.js +97 -0
- package/dist/runtime/html.js.map +1 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +21 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/lazy.d.ts +144 -0
- package/dist/runtime/lazy.d.ts.map +1 -0
- package/dist/runtime/lazy.js +295 -0
- package/dist/runtime/lazy.js.map +1 -0
- package/dist/runtime/module-cache.d.ts +78 -0
- package/dist/runtime/module-cache.d.ts.map +1 -0
- package/dist/runtime/module-cache.js +109 -0
- package/dist/runtime/module-cache.js.map +1 -0
- package/dist/runtime/onDestroy.d.ts +29 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -0
- package/dist/runtime/onDestroy.js +66 -0
- package/dist/runtime/onDestroy.js.map +1 -0
- package/dist/runtime/parseIdentifiersFromTemplate.d.ts +17 -0
- package/dist/runtime/parseIdentifiersFromTemplate.d.ts.map +1 -0
- package/dist/runtime/parseIdentifiersFromTemplate.js +68 -0
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -0
- package/dist/types/globals.d.ts +18 -0
- package/dist/types/globals.d.ts.map +1 -0
- package/dist/types/globals.js +4 -0
- package/dist/types/globals.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utilities/index.d.ts +3 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +3 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/ref-signal.utility.d.ts +32 -0
- package/dist/utilities/ref-signal.utility.d.ts.map +1 -0
- package/dist/utilities/ref-signal.utility.js +46 -0
- package/dist/utilities/ref-signal.utility.js.map +1 -0
- package/dist/utilities/ref.untility.d.ts +37 -0
- package/dist/utilities/ref.untility.d.ts.map +1 -0
- package/dist/utilities/ref.untility.js +47 -0
- package/dist/utilities/ref.untility.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.runtime.two-way-binding",
|
|
4
|
+
"title": "Two-Way Data Binding System",
|
|
5
|
+
"category": "runtime"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { effect, isSignal } from '@pithyjs/signals';
|
|
9
|
+
// Type guard to check if an element is an HTMLElement
|
|
10
|
+
function isHTMLElement(element) {
|
|
11
|
+
return element instanceof HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
// Type guard to check if a signal is writable
|
|
14
|
+
function isWritableSignal(signal) {
|
|
15
|
+
return (isSignal(signal) && typeof signal.set === 'function');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Establishes two-way data binding between HTML elements with `data-bind` attributes and writable signals.
|
|
19
|
+
*
|
|
20
|
+
* This function scans the provided fragment for elements with `data-bind` attributes and creates
|
|
21
|
+
* bidirectional synchronization between the DOM elements and their corresponding signals in the context.
|
|
22
|
+
*
|
|
23
|
+
* **How it works:**
|
|
24
|
+
* 1. Finds all elements with `data-bind` attributes within the fragment
|
|
25
|
+
* 2. For each element, retrieves the corresponding signal from the context using the attribute value
|
|
26
|
+
* 3. Sets up reactive updates: when the signal changes, the DOM element is updated
|
|
27
|
+
* 4. Sets up event listeners: when the user interacts with the element, the signal is updated
|
|
28
|
+
* 5. Automatically infers the appropriate property and event based on the element type
|
|
29
|
+
*
|
|
30
|
+
* **Supported elements:**
|
|
31
|
+
* - `<input>` elements: binds to `value` property (or `checked` for checkboxes/radio buttons)
|
|
32
|
+
* - `<textarea>` elements: binds to `value` property
|
|
33
|
+
* - `<select>` elements: binds to `value` property
|
|
34
|
+
* - Other elements: falls back to `value` property
|
|
35
|
+
*
|
|
36
|
+
* @param fragment - The DOM fragment or element to search for bindable elements
|
|
37
|
+
* @param context - Object containing the signals referenced by `data-bind` attributes
|
|
38
|
+
* @param disposers - Array to collect cleanup functions for proper resource disposal
|
|
39
|
+
*
|
|
40
|
+
* @throws Will log warnings for elements that are not HTMLElements or signals that are not writable
|
|
41
|
+
*/
|
|
42
|
+
/** @codexApi {"parent":"pithy.runtime.two-way-binding","name":"bindDefaultTwoWay","stability":"stable","signature":"(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void"} */
|
|
43
|
+
export function bindDefaultTwoWay(fragment, context, disposers) {
|
|
44
|
+
fragment.querySelectorAll('[data-bind]').forEach(element => {
|
|
45
|
+
// Type guard to ensure we have an HTMLElement
|
|
46
|
+
if (!isHTMLElement(element)) {
|
|
47
|
+
console.warn(`[PithyJS] Element with data-bind is not an HTMLElement:`, element);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const el = element; // Now TypeScript knows this is HTMLElement
|
|
51
|
+
Array.from(el.attributes).forEach(attr => {
|
|
52
|
+
if (!attr.name.startsWith('data-bind'))
|
|
53
|
+
return;
|
|
54
|
+
const signal = context[attr.value];
|
|
55
|
+
if (!isWritableSignal(signal)) {
|
|
56
|
+
console.warn(`[PithyJS] @bind="${attr.value}" must refer to a writable signal`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const prop = inferBindableProperty(el);
|
|
60
|
+
const target = el;
|
|
61
|
+
// Reactive update: signal → DOM
|
|
62
|
+
const effectDisposer = effect(() => {
|
|
63
|
+
const value = signal();
|
|
64
|
+
const currentValue = target[prop];
|
|
65
|
+
if (currentValue !== value) {
|
|
66
|
+
target[prop] = value;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// Event listener: DOM → signal
|
|
70
|
+
const event = inferBindableEvent(el, prop);
|
|
71
|
+
const eventHandler = () => {
|
|
72
|
+
const newVal = extractBindableValue(el, prop);
|
|
73
|
+
signal.set(newVal);
|
|
74
|
+
};
|
|
75
|
+
el.addEventListener(event, eventHandler);
|
|
76
|
+
// Add proper cleanup
|
|
77
|
+
disposers.push(() => {
|
|
78
|
+
el.removeEventListener(event, eventHandler);
|
|
79
|
+
if (typeof effectDisposer === 'function') {
|
|
80
|
+
effectDisposer();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function inferBindableProperty(el) {
|
|
87
|
+
const tag = el.tagName.toLowerCase();
|
|
88
|
+
if (tag === 'input') {
|
|
89
|
+
const inputEl = el;
|
|
90
|
+
const type = inputEl.type;
|
|
91
|
+
if (type === 'checkbox' || type === 'radio')
|
|
92
|
+
return 'checked';
|
|
93
|
+
return 'value';
|
|
94
|
+
}
|
|
95
|
+
if (tag === 'textarea')
|
|
96
|
+
return 'value';
|
|
97
|
+
if (tag === 'select')
|
|
98
|
+
return 'value';
|
|
99
|
+
return 'value'; // fallback
|
|
100
|
+
}
|
|
101
|
+
function inferBindableEvent(el, prop) {
|
|
102
|
+
if (prop === 'checked')
|
|
103
|
+
return 'change';
|
|
104
|
+
return 'input';
|
|
105
|
+
}
|
|
106
|
+
function extractBindableValue(el, prop) {
|
|
107
|
+
if (prop === 'checked') {
|
|
108
|
+
return el.checked;
|
|
109
|
+
}
|
|
110
|
+
const tag = el.tagName.toLowerCase();
|
|
111
|
+
if (tag === 'input') {
|
|
112
|
+
const inputEl = el;
|
|
113
|
+
const type = inputEl.type;
|
|
114
|
+
if (type === 'number') {
|
|
115
|
+
const numValue = Number(inputEl.value);
|
|
116
|
+
return isNaN(numValue) ? inputEl.value : numValue;
|
|
117
|
+
}
|
|
118
|
+
return inputEl.value;
|
|
119
|
+
}
|
|
120
|
+
if (tag === 'textarea') {
|
|
121
|
+
return el.value;
|
|
122
|
+
}
|
|
123
|
+
if (tag === 'select') {
|
|
124
|
+
return el.value;
|
|
125
|
+
}
|
|
126
|
+
return el[prop];
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=bindDefaultTwoWay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindDefaultTwoWay.js","sourceRoot":"","sources":["../../../src/compile/binds/bindDefaultTwoWay.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQpD,sDAAsD;AACtD,SAAS,aAAa,CAAC,OAAgB;IACrC,OAAO,OAAO,YAAY,WAAW,CAAC;AACxC,CAAC;AAED,8CAA8C;AAC9C,SAAS,gBAAgB,CAAC,MAAe;IACvC,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAQ,MAAyB,CAAC,GAAG,KAAK,UAAU,CACzE,CAAC;AACJ,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,q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AAE,CAAC;QACvB,OAAQ,EAAuB,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,EAAsB,CAAC;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;QACpD,CAAC;QACD,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;QACvB,OAAQ,EAA0B,CAAC,KAAK,CAAC;IAC3C,CAAC;IAED,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;QACrB,OAAQ,EAAwB,CAAC,KAAK,CAAC;IACzC,CAAC;IAED,OAAQ,EAA4C,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.core.bind-defer-directives",
|
|
4
|
+
"title": "Defer Directive Binder for Lazy Loading",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Bind @defer directives to enable lazy loading of components.
|
|
10
|
+
*
|
|
11
|
+
* Supports two trigger modes:
|
|
12
|
+
* - `visible`: Load when element scrolls into viewport (IntersectionObserver)
|
|
13
|
+
* - `when`: Load when a boolean expression becomes truthy
|
|
14
|
+
*
|
|
15
|
+
* @param fragment - The root document fragment
|
|
16
|
+
* @param context - Template context with signals and lazy handles
|
|
17
|
+
* @param disposers - Array to collect cleanup functions
|
|
18
|
+
*/
|
|
19
|
+
/** @codexApi {"parent":"pithy.core.bind-defer-directives","name":"bindDeferDirectives","stability":"stable","signature":"(fragment: DocumentFragment, context: Record<string, unknown>, disposers: Array<() => void>) => void"} */
|
|
20
|
+
export declare function bindDeferDirectives(fragment: DocumentFragment, context: Record<string, unknown>, disposers: Array<() => void>): void;
|
|
21
|
+
//# sourceMappingURL=bindDeferDirectives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindDeferDirectives.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindDeferDirectives.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAmCF;;;;;;;;;;GAUG;AACH,mOAAmO;AACnO,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAC3B,IAAI,CAugBN"}
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.core.bind-defer-directives",
|
|
4
|
+
"title": "Defer Directive Binder for Lazy Loading",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Lazy Loading Directive Binder
|
|
10
|
+
*
|
|
11
|
+
* Handles @defer directives to lazily load components based on
|
|
12
|
+
* visibility (IntersectionObserver) or boolean conditions.
|
|
13
|
+
*
|
|
14
|
+
* @module compile/binds/bindDeferDirectives
|
|
15
|
+
*/
|
|
16
|
+
import { effect } from '@pithyjs/signals';
|
|
17
|
+
import { DEFAULT_LAZY_TIMEOUT, } from '@pithyjs/compiler';
|
|
18
|
+
import { compileExpression } from '../compileExpression';
|
|
19
|
+
import { DEFAULT_VISIBILITY_MARGIN, isLazyHandle, observeVisibilityOnce, } from '../../runtime';
|
|
20
|
+
import { boundaryForElement, setBoundaryError } from './bindErrorBoundary';
|
|
21
|
+
import { loadWithTimeout, scheduleByPriority, } from '../../runtime/deferHelpers';
|
|
22
|
+
/** Unique ID counter for defer anchors */
|
|
23
|
+
let deferIdCounter = 0;
|
|
24
|
+
/**
|
|
25
|
+
* Bind @defer directives to enable lazy loading of components.
|
|
26
|
+
*
|
|
27
|
+
* Supports two trigger modes:
|
|
28
|
+
* - `visible`: Load when element scrolls into viewport (IntersectionObserver)
|
|
29
|
+
* - `when`: Load when a boolean expression becomes truthy
|
|
30
|
+
*
|
|
31
|
+
* @param fragment - The root document fragment
|
|
32
|
+
* @param context - Template context with signals and lazy handles
|
|
33
|
+
* @param disposers - Array to collect cleanup functions
|
|
34
|
+
*/
|
|
35
|
+
/** @codexApi {"parent":"pithy.core.bind-defer-directives","name":"bindDeferDirectives","stability":"stable","signature":"(fragment: DocumentFragment, context: Record<string, unknown>, disposers: Array<() => void>) => void"} */
|
|
36
|
+
export function bindDeferDirectives(fragment, context, disposers) {
|
|
37
|
+
// Find all elements with @defer directive
|
|
38
|
+
const deferElements = fragment.querySelectorAll('[data-defer]');
|
|
39
|
+
for (const el of deferElements) {
|
|
40
|
+
const element = el;
|
|
41
|
+
// Skip elements already processed (e.g., inside component subtrees that
|
|
42
|
+
// ran their own bindDeferDirectives before being inserted into the outer DOM)
|
|
43
|
+
if (element.hasAttribute('data-defer-state'))
|
|
44
|
+
continue;
|
|
45
|
+
// Read directive values from data attributes
|
|
46
|
+
const trigger = element.dataset.defer;
|
|
47
|
+
const loadExpr = element.dataset.load;
|
|
48
|
+
const placeholderExpr = element.dataset.placeholder;
|
|
49
|
+
const whenExpr = element.dataset.when;
|
|
50
|
+
const priority = element.dataset.deferPriority;
|
|
51
|
+
const timeoutStr = element.dataset.deferTimeout;
|
|
52
|
+
const timeout = timeoutStr ? parseInt(timeoutStr, 10) : undefined;
|
|
53
|
+
// Validate required attributes
|
|
54
|
+
if (!trigger) {
|
|
55
|
+
if (import.meta.env?.DEV) {
|
|
56
|
+
console.warn('[pithy] @defer element missing trigger type', element);
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (!loadExpr) {
|
|
61
|
+
if (import.meta.env?.DEV) {
|
|
62
|
+
console.warn('[pithy] @defer element missing @load directive', element);
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Get the lazy handle from context
|
|
67
|
+
const lazyHandleGetter = compileExpression(loadExpr, context, undefined);
|
|
68
|
+
const lazyHandle = lazyHandleGetter();
|
|
69
|
+
if (!isLazyHandle(lazyHandle)) {
|
|
70
|
+
if (import.meta.env?.DEV) {
|
|
71
|
+
console.warn(`[pithy] @load="${loadExpr}" did not resolve to a LazyHandle`, element);
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Use existing data-defer-id or generate a unique one
|
|
76
|
+
const existingId = element.getAttribute('data-defer-id');
|
|
77
|
+
const deferId = existingId || `defer-${++deferIdCounter}`;
|
|
78
|
+
// Set data attributes for SSR markers (preserve existing ID if present)
|
|
79
|
+
if (!existingId) {
|
|
80
|
+
element.setAttribute('data-defer-id', deferId);
|
|
81
|
+
}
|
|
82
|
+
element.setAttribute('data-defer-state', 'pending');
|
|
83
|
+
// Create anchor comment
|
|
84
|
+
const anchor = document.createComment(`defer:${deferId}`);
|
|
85
|
+
// Setup placeholder - check both data-placeholder attribute and slot="placeholder" children
|
|
86
|
+
let placeholderEl = null;
|
|
87
|
+
// First, try to extract slot="placeholder" from element children
|
|
88
|
+
const slotPlaceholder = element.querySelector('[slot="placeholder"]');
|
|
89
|
+
if (slotPlaceholder) {
|
|
90
|
+
// Remove from original parent and use as placeholder
|
|
91
|
+
placeholderEl = slotPlaceholder;
|
|
92
|
+
placeholderEl.removeAttribute('slot');
|
|
93
|
+
// Add data attribute for test accessibility
|
|
94
|
+
placeholderEl.setAttribute('data-defer-placeholder', deferId);
|
|
95
|
+
}
|
|
96
|
+
else if (placeholderExpr) {
|
|
97
|
+
// Fallback to data-placeholder attribute
|
|
98
|
+
// Check if it's a string literal
|
|
99
|
+
if ((placeholderExpr.startsWith("'") && placeholderExpr.endsWith("'")) ||
|
|
100
|
+
(placeholderExpr.startsWith('"') && placeholderExpr.endsWith('"'))) {
|
|
101
|
+
// String placeholder
|
|
102
|
+
const text = placeholderExpr.slice(1, -1);
|
|
103
|
+
placeholderEl = document.createTextNode(text);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Component placeholder - get from context
|
|
107
|
+
const placeholderGetter = compileExpression(placeholderExpr, context, null);
|
|
108
|
+
const placeholder = placeholderGetter();
|
|
109
|
+
if (typeof placeholder === 'function') {
|
|
110
|
+
// It's a component function
|
|
111
|
+
try {
|
|
112
|
+
const result = placeholder();
|
|
113
|
+
if (result && typeof result === 'object' && 'el' in result) {
|
|
114
|
+
placeholderEl = result.el;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (import.meta.env?.DEV) {
|
|
119
|
+
console.warn(`[pithy] Error rendering placeholder component:`, err);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Also extract slot="error" for error handling
|
|
126
|
+
const slotError = element.querySelector('[slot="error"]');
|
|
127
|
+
let errorEl = null;
|
|
128
|
+
if (slotError) {
|
|
129
|
+
errorEl = slotError;
|
|
130
|
+
errorEl.removeAttribute('slot');
|
|
131
|
+
// Add data attribute for test accessibility
|
|
132
|
+
errorEl.setAttribute('data-defer-error', deferId);
|
|
133
|
+
// Keep error slot hidden until needed
|
|
134
|
+
errorEl.style.display = 'none';
|
|
135
|
+
}
|
|
136
|
+
// Insert anchor and placeholder
|
|
137
|
+
const parent = element.parentNode;
|
|
138
|
+
if (!parent)
|
|
139
|
+
continue;
|
|
140
|
+
parent.insertBefore(anchor, element);
|
|
141
|
+
if (placeholderEl) {
|
|
142
|
+
// For @defer="when", placeholder starts hidden (only shows during loading)
|
|
143
|
+
// For @defer="visible", placeholder shows immediately (triggers on visibility)
|
|
144
|
+
if (trigger === 'when' && placeholderEl instanceof HTMLElement) {
|
|
145
|
+
placeholderEl.style.display = 'none';
|
|
146
|
+
}
|
|
147
|
+
parent.insertBefore(placeholderEl, element);
|
|
148
|
+
}
|
|
149
|
+
// Insert error element (hidden) after placeholder
|
|
150
|
+
if (errorEl) {
|
|
151
|
+
parent.insertBefore(errorEl, element);
|
|
152
|
+
}
|
|
153
|
+
// Hide the original element (it becomes the container after load)
|
|
154
|
+
element.style.display = 'none';
|
|
155
|
+
// Track mounted component for cleanup
|
|
156
|
+
let mountedDestroy = null;
|
|
157
|
+
let isMounted = false;
|
|
158
|
+
let isMounting = false; // true while an async mount is in-flight
|
|
159
|
+
// Mount generation counter — incremented on every unmount/cleanup to
|
|
160
|
+
// invalidate in-flight async mounts that started before the unmount.
|
|
161
|
+
let mountGeneration = 0;
|
|
162
|
+
// Track inserted nodes directly (no wrapper div)
|
|
163
|
+
let insertedNodes = [];
|
|
164
|
+
/**
|
|
165
|
+
* Remove mounted component nodes from DOM
|
|
166
|
+
*/
|
|
167
|
+
function unmountComponent() {
|
|
168
|
+
// Invalidate any in-flight async mount
|
|
169
|
+
mountGeneration++;
|
|
170
|
+
isMounting = false;
|
|
171
|
+
// Call destroy function if present
|
|
172
|
+
if (mountedDestroy) {
|
|
173
|
+
mountedDestroy();
|
|
174
|
+
mountedDestroy = null;
|
|
175
|
+
}
|
|
176
|
+
// Remove all inserted nodes
|
|
177
|
+
for (const node of insertedNodes) {
|
|
178
|
+
if (node.parentNode) {
|
|
179
|
+
node.parentNode.removeChild(node);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
insertedNodes = [];
|
|
183
|
+
isMounted = false;
|
|
184
|
+
// Hide placeholder if it was shown during a cancelled in-flight mount
|
|
185
|
+
if (placeholderEl && placeholderEl instanceof HTMLElement) {
|
|
186
|
+
placeholderEl.style.display = 'none';
|
|
187
|
+
}
|
|
188
|
+
// Reset state to pending (ready for re-mount on next trigger)
|
|
189
|
+
element.setAttribute('data-defer-state', 'pending');
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Mount the lazy component with timeout support
|
|
193
|
+
*/
|
|
194
|
+
async function mountComponent() {
|
|
195
|
+
// If already mounted or a mount is in-flight, skip
|
|
196
|
+
if (isMounted || isMounting)
|
|
197
|
+
return;
|
|
198
|
+
isMounting = true;
|
|
199
|
+
// Capture generation so we can detect if an unmount happened while awaiting
|
|
200
|
+
const thisGeneration = mountGeneration;
|
|
201
|
+
element.setAttribute('data-defer-state', 'loading');
|
|
202
|
+
// Show placeholder during loading (for @defer="when" it starts hidden)
|
|
203
|
+
if (placeholderEl && placeholderEl instanceof HTMLElement) {
|
|
204
|
+
placeholderEl.style.display = '';
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
// Load the module with timeout (chunk is cached after first load)
|
|
208
|
+
const effectiveTimeout = timeout ?? DEFAULT_LAZY_TIMEOUT;
|
|
209
|
+
const module = await loadWithTimeout(lazyHandle, effectiveTimeout);
|
|
210
|
+
// Check if an unmount/cleanup happened during async load (generation changed)
|
|
211
|
+
if (thisGeneration !== mountGeneration) {
|
|
212
|
+
isMounting = false;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
// Use fresh parentNode — the element may have been moved into the real DOM
|
|
216
|
+
// by bindComponentTags.replaceWith() during the async gap
|
|
217
|
+
const freshParent = element.parentNode;
|
|
218
|
+
if (!freshParent) {
|
|
219
|
+
isMounting = false;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
element.setAttribute('data-defer-state', 'loaded');
|
|
223
|
+
// Remove placeholder
|
|
224
|
+
if (placeholderEl && placeholderEl.parentNode) {
|
|
225
|
+
placeholderEl.parentNode.removeChild(placeholderEl);
|
|
226
|
+
placeholderEl = null;
|
|
227
|
+
}
|
|
228
|
+
// Remove error element (no longer needed on success)
|
|
229
|
+
if (errorEl && errorEl.parentNode) {
|
|
230
|
+
errorEl.parentNode.removeChild(errorEl);
|
|
231
|
+
errorEl = null;
|
|
232
|
+
}
|
|
233
|
+
// Get the component from the module
|
|
234
|
+
const Component = module.default || module;
|
|
235
|
+
if (typeof Component === 'function') {
|
|
236
|
+
// Render the component
|
|
237
|
+
const result = Component();
|
|
238
|
+
if (result && typeof result === 'object' && 'el' in result) {
|
|
239
|
+
const { el, destroy } = result;
|
|
240
|
+
// Insert component content directly (no wrapper div)
|
|
241
|
+
if (el instanceof DocumentFragment) {
|
|
242
|
+
// Track all children before moving them
|
|
243
|
+
const nodes = Array.from(el.childNodes);
|
|
244
|
+
insertedNodes = nodes;
|
|
245
|
+
// Insert fragment directly - this moves all children to the DOM
|
|
246
|
+
freshParent.insertBefore(el, element);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
insertedNodes = [el];
|
|
250
|
+
freshParent.insertBefore(el, element);
|
|
251
|
+
}
|
|
252
|
+
isMounted = true;
|
|
253
|
+
isMounting = false;
|
|
254
|
+
// Track destroy function
|
|
255
|
+
if (destroy) {
|
|
256
|
+
mountedDestroy = destroy;
|
|
257
|
+
}
|
|
258
|
+
// Dispatch loaded event
|
|
259
|
+
element.dispatchEvent(new CustomEvent('loaded', {
|
|
260
|
+
detail: {
|
|
261
|
+
ttiMs: Date.now(), // Could track actual load time
|
|
262
|
+
chunkId: lazyHandle.key,
|
|
263
|
+
},
|
|
264
|
+
bubbles: true,
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
isMounting = false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
isMounting = false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
isMounting = false;
|
|
277
|
+
// Check if an unmount/cleanup happened during async load
|
|
278
|
+
if (thisGeneration !== mountGeneration)
|
|
279
|
+
return;
|
|
280
|
+
element.setAttribute('data-defer-state', 'error');
|
|
281
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
282
|
+
// Remove placeholder and show error slot if available
|
|
283
|
+
if (placeholderEl && placeholderEl.parentNode) {
|
|
284
|
+
placeholderEl.parentNode.removeChild(placeholderEl);
|
|
285
|
+
placeholderEl = null;
|
|
286
|
+
}
|
|
287
|
+
// Propagate error to nearest error boundary (if one exists)
|
|
288
|
+
const boundary = boundaryForElement(element);
|
|
289
|
+
if (boundary) {
|
|
290
|
+
setBoundaryError(boundary, error);
|
|
291
|
+
}
|
|
292
|
+
else if (errorEl) {
|
|
293
|
+
// No error boundary - fall back to local error slot
|
|
294
|
+
errorEl.style.display = '';
|
|
295
|
+
}
|
|
296
|
+
// Dispatch error event (for programmatic handling)
|
|
297
|
+
element.dispatchEvent(new CustomEvent('error', {
|
|
298
|
+
detail: {
|
|
299
|
+
error,
|
|
300
|
+
retry: () => {
|
|
301
|
+
// Hide error, re-show placeholder if we had one
|
|
302
|
+
if (errorEl) {
|
|
303
|
+
errorEl.style.display = 'none';
|
|
304
|
+
}
|
|
305
|
+
lazyHandle.retry().then(mountComponent);
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
bubbles: true,
|
|
309
|
+
}));
|
|
310
|
+
if (import.meta.env?.DEV) {
|
|
311
|
+
console.error(`[pithy] Failed to load lazy component:`, err);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// Track idle callback for cancellation
|
|
316
|
+
let idleCallbackId;
|
|
317
|
+
/**
|
|
318
|
+
* Cleanup function
|
|
319
|
+
*/
|
|
320
|
+
function cleanup() {
|
|
321
|
+
// Cancel any scheduled-but-not-started mount
|
|
322
|
+
cancelPendingMount();
|
|
323
|
+
// Invalidate any in-flight async mount (unmountComponent also does this,
|
|
324
|
+
// but we bump it here too in case unmountComponent is skipped)
|
|
325
|
+
mountGeneration++;
|
|
326
|
+
// Cancel pending idle callback (cancelPendingMount handles the scheduled
|
|
327
|
+
// case, but cover the already-in-flight case too)
|
|
328
|
+
if (idleCallbackId !== undefined &&
|
|
329
|
+
typeof cancelIdleCallback !== 'undefined') {
|
|
330
|
+
cancelIdleCallback(idleCallbackId);
|
|
331
|
+
idleCallbackId = undefined;
|
|
332
|
+
}
|
|
333
|
+
// Unmount component (calls destroy and removes nodes)
|
|
334
|
+
unmountComponent();
|
|
335
|
+
// Cancel any in-flight load
|
|
336
|
+
lazyHandle.cancel();
|
|
337
|
+
}
|
|
338
|
+
// Track whether a mount has been scheduled but not yet started.
|
|
339
|
+
// This is needed so that unmount/cancel can invalidate pending
|
|
340
|
+
// scheduled mounts (e.g., rapid toggle: true → false → true).
|
|
341
|
+
let mountScheduled = false;
|
|
342
|
+
/**
|
|
343
|
+
* Trigger mount with priority scheduling
|
|
344
|
+
*/
|
|
345
|
+
function triggerMount() {
|
|
346
|
+
mountScheduled = true;
|
|
347
|
+
// Capture current generation so the microtask can detect cancellation.
|
|
348
|
+
// cancelPendingMount bumps mountGeneration, so if it fires between
|
|
349
|
+
// scheduling and execution, the microtask will see the mismatch.
|
|
350
|
+
const expectedGen = mountGeneration;
|
|
351
|
+
const result = scheduleByPriority(() => {
|
|
352
|
+
mountScheduled = false;
|
|
353
|
+
if (expectedGen !== mountGeneration)
|
|
354
|
+
return; // cancelled
|
|
355
|
+
mountComponent();
|
|
356
|
+
}, priority);
|
|
357
|
+
// Track idle callback ID for cleanup
|
|
358
|
+
if (typeof result === 'number') {
|
|
359
|
+
idleCallbackId = result;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Cancel any pending scheduled mount that hasn't started yet.
|
|
364
|
+
* Bumps mountGeneration to also invalidate any in-flight async mounts.
|
|
365
|
+
*/
|
|
366
|
+
function cancelPendingMount() {
|
|
367
|
+
if (mountScheduled) {
|
|
368
|
+
mountScheduled = false;
|
|
369
|
+
mountGeneration++;
|
|
370
|
+
// Cancel pending idle callback if one is tracked
|
|
371
|
+
if (idleCallbackId !== undefined &&
|
|
372
|
+
typeof cancelIdleCallback !== 'undefined') {
|
|
373
|
+
cancelIdleCallback(idleCallbackId);
|
|
374
|
+
idleCallbackId = undefined;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
// Subscribe to lazy handle state for external retry support
|
|
379
|
+
// This allows calling lazyHandle.retry() from error slot buttons
|
|
380
|
+
const stopStateEffect = effect(() => {
|
|
381
|
+
const handleState = lazyHandle.state();
|
|
382
|
+
const elementState = element.getAttribute('data-defer-state');
|
|
383
|
+
// If handle loaded externally (via retry) and we're in error state, try to mount
|
|
384
|
+
if (handleState === 'loaded' &&
|
|
385
|
+
!isMounted &&
|
|
386
|
+
!isMounting &&
|
|
387
|
+
elementState === 'error') {
|
|
388
|
+
// Hide error slot
|
|
389
|
+
if (errorEl) {
|
|
390
|
+
errorEl.style.display = 'none';
|
|
391
|
+
}
|
|
392
|
+
// Mount the component - it will handle state transitions
|
|
393
|
+
mountComponent();
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
disposers.push(stopStateEffect);
|
|
397
|
+
// Setup trigger based on mode
|
|
398
|
+
if (trigger === 'visible') {
|
|
399
|
+
// Visibility trigger using IntersectionObserver
|
|
400
|
+
// IMPORTANT: Observe the placeholder (which is visible), not the hidden element
|
|
401
|
+
// If no placeholder exists, create a sentinel element to observe
|
|
402
|
+
let observeTarget;
|
|
403
|
+
let sentinelEl = null;
|
|
404
|
+
if (placeholderEl && placeholderEl instanceof HTMLElement) {
|
|
405
|
+
observeTarget = placeholderEl;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
// Create a minimal sentinel element to observe
|
|
409
|
+
sentinelEl = document.createElement('span');
|
|
410
|
+
sentinelEl.style.display = 'inline-block';
|
|
411
|
+
sentinelEl.style.width = '1px';
|
|
412
|
+
sentinelEl.style.height = '1px';
|
|
413
|
+
parent.insertBefore(sentinelEl, element);
|
|
414
|
+
observeTarget = sentinelEl;
|
|
415
|
+
}
|
|
416
|
+
const stopObserving = observeVisibilityOnce(observeTarget, triggerMount, {
|
|
417
|
+
rootMargin: DEFAULT_VISIBILITY_MARGIN,
|
|
418
|
+
});
|
|
419
|
+
disposers.push(() => {
|
|
420
|
+
stopObserving();
|
|
421
|
+
// Remove sentinel if we created one
|
|
422
|
+
if (sentinelEl && sentinelEl.parentNode) {
|
|
423
|
+
sentinelEl.parentNode.removeChild(sentinelEl);
|
|
424
|
+
}
|
|
425
|
+
cleanup();
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
else if (trigger === 'when' && whenExpr) {
|
|
429
|
+
// Boolean trigger using effect
|
|
430
|
+
const conditionGetter = compileExpression(whenExpr, context, false);
|
|
431
|
+
const stopEffect = effect(() => {
|
|
432
|
+
const shouldShow = conditionGetter();
|
|
433
|
+
if (shouldShow) {
|
|
434
|
+
// Mount component (chunk is cached after first load, so remounting is fast)
|
|
435
|
+
if (!isMounted && !isMounting && !mountScheduled) {
|
|
436
|
+
triggerMount();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
// Cancel any scheduled-but-not-started mount first (handles rapid toggle)
|
|
441
|
+
cancelPendingMount();
|
|
442
|
+
// Destroy component when condition becomes false
|
|
443
|
+
// This is consistent with React, Vue, Angular - no automatic show/hide
|
|
444
|
+
if (isMounted || isMounting) {
|
|
445
|
+
unmountComponent();
|
|
446
|
+
}
|
|
447
|
+
// Hide error slot when condition becomes false (after a failed load)
|
|
448
|
+
if (errorEl) {
|
|
449
|
+
errorEl.style.display = 'none';
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
disposers.push(() => {
|
|
454
|
+
stopEffect();
|
|
455
|
+
cleanup();
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
if (import.meta.env?.DEV) {
|
|
460
|
+
console.warn(`[pithy] @defer="when" requires @when attribute`, element);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
//# sourceMappingURL=bindDeferDirectives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindDeferDirectives.js","sourceRoot":"","sources":["../../../src/compile/binds/bindDeferDirectives.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,oBAAoB,GAGrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,qBAAqB,GAEtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,0CAA0C;AAC1C,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,mOAAmO;AACnO,MAAM,UAAU,mBAAmB,CACjC,QAA0B,EAC1B,OAAgC,EAChC,SAA4B;IAE5B,0CAA0C;IAC1C,MAAM,aAAa,GAAG,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAEhE,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,EAAiB,CAAC;QAElC,wEAAwE;QACxE,8EAA8E;QAC9E,IAAI,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC;YAAE,SAAS;QAEvD,6CAA6C;QAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAiC,CAAC;QAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QACtC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QACpD,MAAM,QAA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