@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,64 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.directive.loop-signals",
|
|
4
|
+
"title": "Loop Reactive Signals",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { batch, signal } from '@pithyjs/signals';
|
|
9
|
+
/** @codexApi {"parent":"pithy.directive.loop-signals","name":"createLoopSignals","stability":"stable","signature":"<T>(item: T, idx: number, total: number) => LoopSignals"} */
|
|
10
|
+
/**
|
|
11
|
+
* Creates all the reactive signals needed for a loop item
|
|
12
|
+
*/
|
|
13
|
+
export function createLoopSignals(item, idx, total) {
|
|
14
|
+
const itemSig = signal(item);
|
|
15
|
+
const countSig = signal(total);
|
|
16
|
+
const idxSig = signal(idx);
|
|
17
|
+
const firstSig = signal(idx === 0);
|
|
18
|
+
const lastSig = signal(idx === total - 1);
|
|
19
|
+
const evenSig = signal(idx % 2 === 0);
|
|
20
|
+
const oddSig = signal(idx % 2 === 1);
|
|
21
|
+
return {
|
|
22
|
+
itemSig,
|
|
23
|
+
countSig,
|
|
24
|
+
idxSig,
|
|
25
|
+
firstSig,
|
|
26
|
+
lastSig,
|
|
27
|
+
evenSig,
|
|
28
|
+
oddSig,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** @codexApi {"parent":"pithy.directive.loop-signals","name":"updateLoopSignals","stability":"stable","signature":"(signals: LoopSignals, idx: number, total: number) => void"} */
|
|
32
|
+
/**
|
|
33
|
+
* Updates all positional signals for a loop item (idx, first, last, even, odd, count)
|
|
34
|
+
* Uses batch() for optimal performance
|
|
35
|
+
*/
|
|
36
|
+
export function updateLoopSignals(signals, idx, total) {
|
|
37
|
+
batch(() => {
|
|
38
|
+
signals.countSig.set(total);
|
|
39
|
+
signals.idxSig.set(idx);
|
|
40
|
+
signals.firstSig.set(idx === 0);
|
|
41
|
+
signals.lastSig.set(idx === total - 1);
|
|
42
|
+
signals.evenSig.set(idx % 2 === 0);
|
|
43
|
+
signals.oddSig.set(idx % 2 === 1);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** @codexApi {"parent":"pithy.directive.loop-signals","name":"createLoopContext","stability":"stable","signature":"(parentCtx: Record<string, unknown>, signals: LoopSignals, itemVar: string, indexVar?: string, countVar?: string, firstVar?: string, lastVar?: string, evenVar?: string, oddVar?: string) => Record<string, unknown>"} */
|
|
47
|
+
/**
|
|
48
|
+
* Creates the context object for a loop item with all necessary signals.
|
|
49
|
+
* Helper signal names (count, first, last, even, odd) can be aliased to
|
|
50
|
+
* avoid shadowing in nested loops.
|
|
51
|
+
*/
|
|
52
|
+
export function createLoopContext(parentCtx, signals, itemVar, indexVar, countVar = 'count', firstVar = 'first', lastVar = 'last', evenVar = 'even', oddVar = 'odd') {
|
|
53
|
+
return {
|
|
54
|
+
...parentCtx,
|
|
55
|
+
[itemVar]: signals.itemSig,
|
|
56
|
+
...(indexVar ? { [indexVar]: signals.idxSig } : {}),
|
|
57
|
+
[countVar]: signals.countSig,
|
|
58
|
+
[firstVar]: signals.firstSig,
|
|
59
|
+
[lastVar]: signals.lastSig,
|
|
60
|
+
[evenVar]: signals.evenSig,
|
|
61
|
+
[oddVar]: signals.oddSig,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=loopSignals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopSignals.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopSignals.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,kBAAkB,CAAC;AAYzD,gLAAgL;AAChL;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAO,EACP,GAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAErC,OAAO;QACL,OAAO;QACP,QAAQ;QACR,MAAM;Q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,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.directive.loop-traversal",
|
|
4
|
+
"title": "Loop Node Traversal",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import type { PithyNode } from '@pithyjs/compiler';
|
|
9
|
+
/**
|
|
10
|
+
* Node traversal utilities for loop operations
|
|
11
|
+
*/
|
|
12
|
+
/** @codexApi {"parent":"pithy.directive.loop-traversal","name":"findAllNestedLoopNodes","stability":"stable","signature":"(node: PithyNode) => PithyNode[]"} */
|
|
13
|
+
/**
|
|
14
|
+
* Recursively finds all nested loop nodes within a given node
|
|
15
|
+
* Used to process nested loops before binding to preserve data-pid references
|
|
16
|
+
*/
|
|
17
|
+
export declare function findAllNestedLoopNodes(node: PithyNode): PithyNode[];
|
|
18
|
+
//# sourceMappingURL=loopTraversal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopTraversal.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/loopTraversal.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AAEH,gKAAgK;AAChK;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,CAyBnE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.directive.loop-traversal",
|
|
4
|
+
"title": "Loop Node Traversal",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Node traversal utilities for loop operations
|
|
10
|
+
*/
|
|
11
|
+
/** @codexApi {"parent":"pithy.directive.loop-traversal","name":"findAllNestedLoopNodes","stability":"stable","signature":"(node: PithyNode) => PithyNode[]"} */
|
|
12
|
+
/**
|
|
13
|
+
* Recursively finds all nested loop nodes within a given node
|
|
14
|
+
* Used to process nested loops before binding to preserve data-pid references
|
|
15
|
+
*/
|
|
16
|
+
export function findAllNestedLoopNodes(node) {
|
|
17
|
+
const loopNodes = [];
|
|
18
|
+
function traverse(currentNode) {
|
|
19
|
+
// If this node has a @for directive, it's a loop node
|
|
20
|
+
if (currentNode.directives?.for) {
|
|
21
|
+
loopNodes.push(currentNode);
|
|
22
|
+
}
|
|
23
|
+
// Recursively traverse children
|
|
24
|
+
if (currentNode.children) {
|
|
25
|
+
for (const child of currentNode.children) {
|
|
26
|
+
traverse(child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Start traversal from the node's children (not the node itself, as it's already being processed)
|
|
31
|
+
if (node.children) {
|
|
32
|
+
for (const child of node.children) {
|
|
33
|
+
traverse(child);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return loopNodes;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=loopTraversal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopTraversal.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopTraversal.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;GAEG;AAEH,gKAAgK;AAChK;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAe;IACpD,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,SAAS,QAAQ,CAAC,WAAsB;QACtC,sDAAsD;QACtD,IAAI,WAAW,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;QAED,gCAAgC;QAChC,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;YACzB,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;gBACzC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,kGAAkG;IAClG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.directive.conditional-chain",
|
|
4
|
+
"title": "Conditional Chain Handler",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import type { PithyNode } from '@pithyjs/compiler';
|
|
9
|
+
/**
|
|
10
|
+
* Handles rendering and reactivity for an @if/@else-if/@else chain.
|
|
11
|
+
* Returns a Set of all node IDs that were processed (to avoid double-binding).
|
|
12
|
+
*/
|
|
13
|
+
/** @codexApi {"parent":"pithy.directive.conditional-chain","name":"handleConditionalChain","stability":"stable","signature":"(domChain: HTMLElement[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>"} */
|
|
14
|
+
export declare function handleConditionalChain(domChain: HTMLElement[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]): Set<string>;
|
|
15
|
+
//# sourceMappingURL=handleConditionalChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleConditionalChain.d.ts","sourceRoot":"","sources":["../../src/compile/handleConditionalChain.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAMF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD;;;GAGG;AACH,4RAA4R;AAC5R,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,QAAQ,EAAE,SAAS,EAAE,EACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,EACzC,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,GAC7B,GAAG,CAAC,MAAM,CAAC,CAiNb"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.directive.conditional-chain",
|
|
4
|
+
"title": "Conditional Chain Handler",
|
|
5
|
+
"category": "directive"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { effect } from '@pithyjs/signals';
|
|
9
|
+
import { bindConditionals } from './binds/bindConditionals';
|
|
10
|
+
import { flashUpdate } from './binds/bindTextInterpolations';
|
|
11
|
+
import { compileExpression } from './compileExpression';
|
|
12
|
+
import { bindTemplateDirectives } from './compileTemplate';
|
|
13
|
+
import { bindForLoops } from './forLoops/bindForLoops';
|
|
14
|
+
import { bindSwitchCases } from './bindSwitchCases';
|
|
15
|
+
import { pithyTreeToDom } from './pithyTreeToDom';
|
|
16
|
+
import { isSSRMode } from './ssrMode';
|
|
17
|
+
/**
|
|
18
|
+
* Handles rendering and reactivity for an @if/@else-if/@else chain.
|
|
19
|
+
* Returns a Set of all node IDs that were processed (to avoid double-binding).
|
|
20
|
+
*/
|
|
21
|
+
/** @codexApi {"parent":"pithy.directive.conditional-chain","name":"handleConditionalChain","stability":"stable","signature":"(domChain: HTMLElement[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>"} */
|
|
22
|
+
export function handleConditionalChain(domChain, astChain, ctx, processedNodeIds = new Set(), disposers = []) {
|
|
23
|
+
// Generate a unique ID for this chain for debugging
|
|
24
|
+
const chainId = Math.random().toString(36).substring(2, 8);
|
|
25
|
+
// Create a placeholder comment to mark where our conditional content should go
|
|
26
|
+
const placeholder = document.createComment(`conditional-chain-${chainId}`);
|
|
27
|
+
// Insert the placeholder before the first element in the chain
|
|
28
|
+
const firstElement = domChain[0];
|
|
29
|
+
const parent = firstElement.parentNode;
|
|
30
|
+
if (!parent) {
|
|
31
|
+
console.error(`[Chain-${chainId}] No parent found for first element`);
|
|
32
|
+
return processedNodeIds;
|
|
33
|
+
}
|
|
34
|
+
parent.insertBefore(placeholder, firstElement);
|
|
35
|
+
// Remove all original elements from the DOM immediately
|
|
36
|
+
for (const el of domChain) {
|
|
37
|
+
el.remove();
|
|
38
|
+
}
|
|
39
|
+
// Note: We don't clone the original DOM elements because cloning loses
|
|
40
|
+
// the structural transformations (e.g., @for loops need Comment anchors).
|
|
41
|
+
// Instead, we rebuild from the AST when needed using pithyTreeToDom.
|
|
42
|
+
// Note: We mark nodes as processed AFTER binding each matched branch,
|
|
43
|
+
// not upfront, so that they can be properly bound first.
|
|
44
|
+
// Keep track of the currently displayed element and its disposers
|
|
45
|
+
let currentElement = null;
|
|
46
|
+
let currentDisposers = [];
|
|
47
|
+
// Create a function to clear the current element and dispose effects
|
|
48
|
+
function clearCurrentElement() {
|
|
49
|
+
// Dispose all effects from the previous render
|
|
50
|
+
for (const dispose of currentDisposers) {
|
|
51
|
+
try {
|
|
52
|
+
dispose();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Ignore disposal errors
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
currentDisposers = [];
|
|
59
|
+
if (currentElement && currentElement.parentNode) {
|
|
60
|
+
currentElement.remove();
|
|
61
|
+
currentElement = null;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// Shared logic for evaluating conditions and rendering the matched branch
|
|
67
|
+
function evaluateAndRender() {
|
|
68
|
+
// Find the first matching condition
|
|
69
|
+
let matchIndex = -1;
|
|
70
|
+
for (let i = 0; i < astChain.length; i++) {
|
|
71
|
+
const node = astChain[i];
|
|
72
|
+
if (node.directives?.if !== undefined) {
|
|
73
|
+
// This is an @if node
|
|
74
|
+
const fn = compileExpression(node.directives.if, ctx, false);
|
|
75
|
+
const result = fn();
|
|
76
|
+
if (result) {
|
|
77
|
+
matchIndex = i;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (node.directives?.elseIf !== undefined) {
|
|
82
|
+
// This is an @else-if node
|
|
83
|
+
const fn = compileExpression(node.directives.elseIf, ctx, false);
|
|
84
|
+
if (fn()) {
|
|
85
|
+
matchIndex = i;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (node.directives?.else !== undefined) {
|
|
90
|
+
// This is an @else node, which always matches if we reach it
|
|
91
|
+
matchIndex = i;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return matchIndex;
|
|
96
|
+
}
|
|
97
|
+
function renderMatchedBranch(matchIndex) {
|
|
98
|
+
// If we found a match, insert the corresponding element
|
|
99
|
+
if (matchIndex < 0 || !placeholder.parentNode)
|
|
100
|
+
return;
|
|
101
|
+
// Get the matched AST node for this conditional branch
|
|
102
|
+
const matchedAst = astChain[matchIndex];
|
|
103
|
+
// Rebuild the DOM from the AST instead of cloning
|
|
104
|
+
// This ensures structural transformations (e.g., @for -> Comment) are applied
|
|
105
|
+
const freshFragment = pithyTreeToDom([matchedAst], ctx);
|
|
106
|
+
// Extract the first (and should be only) element from the fragment
|
|
107
|
+
const rebuiltElement = freshFragment.firstChild;
|
|
108
|
+
if (!rebuiltElement)
|
|
109
|
+
return;
|
|
110
|
+
// Update our current element reference (set before binding so cleanup can find it)
|
|
111
|
+
currentElement = rebuiltElement;
|
|
112
|
+
// Bind structural directives FIRST (in the same order as compileTemplate)
|
|
113
|
+
// This creates the necessary contexts (e.g., loop item variables) before
|
|
114
|
+
// bindTemplateDirectives tries to use them in text interpolations
|
|
115
|
+
// Store disposers in the outer scope so they can be cleaned up on re-render
|
|
116
|
+
currentDisposers = [];
|
|
117
|
+
// Use a fresh set for this effect run to prevent double-binding within this render
|
|
118
|
+
// But also update the outer processedNodeIds for the caller
|
|
119
|
+
const effectLocalProcessedIds = new Set();
|
|
120
|
+
// 1) Switch/case statements FIRST
|
|
121
|
+
// IMPORTANT: bindSwitchCases must run BEFORE bindConditionals!
|
|
122
|
+
// Switch cases clone their content from DOM - if bindConditionals runs first,
|
|
123
|
+
// it removes @if/@else elements and replaces them with placeholders, so the
|
|
124
|
+
// cloned switch case content would be missing the conditional elements.
|
|
125
|
+
bindSwitchCases(matchedAst.children || [], rebuiltElement, ctx, new Set(), currentDisposers);
|
|
126
|
+
// 2) Nested conditionals
|
|
127
|
+
// Pass currentDisposers so nested conditional effects are cleaned up on re-render
|
|
128
|
+
bindConditionals(matchedAst.children || [], rebuiltElement, ctx, effectLocalProcessedIds, currentDisposers);
|
|
129
|
+
// 3) For loops - creates loop contexts with item/index variables
|
|
130
|
+
// Pass local processed IDs to prevent double-binding within this render
|
|
131
|
+
bindForLoops(matchedAst.children || [], rebuiltElement, ctx, currentDisposers, effectLocalProcessedIds);
|
|
132
|
+
// 4) Now bind non-structural directives (text, events, classes, etc.)
|
|
133
|
+
// Use a temporary fragment for binding (bindTemplateDirectives expects a fragment)
|
|
134
|
+
const tempFragment = document.createDocumentFragment();
|
|
135
|
+
tempFragment.appendChild(rebuiltElement);
|
|
136
|
+
bindTemplateDirectives(tempFragment, ctx, currentDisposers);
|
|
137
|
+
// Insert the element into the DOM after binding
|
|
138
|
+
placeholder.parentNode.insertBefore(rebuiltElement, placeholder.nextSibling);
|
|
139
|
+
// Defer flashUpdate via queueMicrotask to prevent blocking
|
|
140
|
+
if (!isSSRMode()) {
|
|
141
|
+
queueMicrotask(() => flashUpdate(rebuiltElement));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (isSSRMode()) {
|
|
145
|
+
// SSR mode: evaluate once synchronously, no reactive effects
|
|
146
|
+
const matchIndex = evaluateAndRender();
|
|
147
|
+
renderMatchedBranch(matchIndex);
|
|
148
|
+
// Ensure nested directive disposers created during SSR are added
|
|
149
|
+
// to the parent disposers array for proper cleanup on destroy()
|
|
150
|
+
disposers.push(...currentDisposers);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Client mode: reactive effect for dynamic updates
|
|
154
|
+
// Track the previous match index to avoid unnecessary DOM operations
|
|
155
|
+
let previousMatchIndex = -1;
|
|
156
|
+
// Set up the reactive effect and capture the stop function for disposal
|
|
157
|
+
const stopEffect = effect(() => {
|
|
158
|
+
const matchIndex = evaluateAndRender();
|
|
159
|
+
// Skip re-insertion if match hasn't changed
|
|
160
|
+
if (matchIndex === previousMatchIndex) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// Update the previous match index
|
|
164
|
+
previousMatchIndex = matchIndex;
|
|
165
|
+
// Now clear the current element (only if we're about to rebuild)
|
|
166
|
+
clearCurrentElement();
|
|
167
|
+
renderMatchedBranch(matchIndex);
|
|
168
|
+
// Don't return cleanup here - we handle cleanup explicitly:
|
|
169
|
+
// 1. When match changes: clearCurrentElement() is called above
|
|
170
|
+
// 2. When effect stops: clearCurrentElement is in disposers array
|
|
171
|
+
// Returning cleanup would cause it to run on EVERY re-run, even when match is same
|
|
172
|
+
});
|
|
173
|
+
// Add cleanup and effect stop to disposers for proper cleanup
|
|
174
|
+
// Note: We add clearCurrentElement explicitly because the effect may have
|
|
175
|
+
// returned undefined on its last run (when match didn't change)
|
|
176
|
+
disposers.push(clearCurrentElement);
|
|
177
|
+
disposers.push(stopEffect);
|
|
178
|
+
}
|
|
179
|
+
return processedNodeIds;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=handleConditionalChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleConditionalChain.js","sourceRoot":"","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,EAAE;YAC7B,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;YAEvC,4CAA4C;YAC5C,IAAI,UAAU,KAAK,kBAAkB,EAAE,CAAC;gBACtC,OAAO;YACT,CAAC;YAED,kCAAkC;YAClC,kBAAkB,GAAG,UAAU,CAAC;YAEhC,iEAAiE;YACjE,mBAAmB,EAAE,CAAC;YACtB,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAEhC,4DAA4D;YAC5D,+DAA+D;YAC/D,kEAAkE;YAClE,mFAAmF;QACrF,CAAC,CAAC,CAAC;QAEH,8DAA8D;QAC9D,0EAA0E;QAC1E,gEAAgE;QAChE,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACpC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { compileTemplate } from './compileTemplate';
|
|
2
|
+
export { compileNodes } from './compileNodes';
|
|
3
|
+
export { renderChildren, captureChildren } from './renderChildren';
|
|
4
|
+
export { injectScopedStyle } from './injectScopedStyle';
|
|
5
|
+
export { bindTextInterpolations } from './binds/bindTextInterpolations';
|
|
6
|
+
export { bindEventHandlers } from './binds/bindEventHandlers';
|
|
7
|
+
export { bindClassDirectives } from './binds/bindClassDirectives';
|
|
8
|
+
export { bindComponentTags } from './binds/bindComponentsTags';
|
|
9
|
+
export { bindForLoops, createLoopManager, type LoopManager } from './forLoops';
|
|
10
|
+
export { bindTemplateDirectives } from './compileTemplate';
|
|
11
|
+
export type { SlotMap } from './contentProjection';
|
|
12
|
+
export { registerDirectiveBinder, unregisterDirectiveBinder, executeCustomDirectiveBinders, type DirectiveBinder, } from './binds/directiveRegistry';
|
|
13
|
+
export { boundaryForElement, setBoundaryError, clearBoundaryError, } from './binds/bindErrorBoundary';
|
|
14
|
+
export type { BoundaryInfo } from './binds/bindErrorBoundary';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,KAAK,eAAe,GACrB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { compileTemplate } from './compileTemplate';
|
|
2
|
+
export { compileNodes } from './compileNodes';
|
|
3
|
+
export { renderChildren, captureChildren } from './renderChildren';
|
|
4
|
+
// parseHtml is NOT re-exported from this barrel to prevent parse5 from
|
|
5
|
+
// being pulled into production bundles. Use the dedicated subpath export:
|
|
6
|
+
// import { loadJITCompiler } from '@pithyjs/core/compile/parseHtml'
|
|
7
|
+
export { injectScopedStyle } from './injectScopedStyle';
|
|
8
|
+
// Only export these if useful for advanced users / SSR:
|
|
9
|
+
export { bindTextInterpolations } from './binds/bindTextInterpolations';
|
|
10
|
+
export { bindEventHandlers } from './binds/bindEventHandlers';
|
|
11
|
+
export { bindClassDirectives } from './binds/bindClassDirectives';
|
|
12
|
+
export { bindComponentTags } from './binds/bindComponentsTags';
|
|
13
|
+
export { bindForLoops, createLoopManager } from './forLoops';
|
|
14
|
+
export { bindTemplateDirectives } from './compileTemplate';
|
|
15
|
+
// Custom directive registry - allows external packages (router, etc.) to register binders
|
|
16
|
+
export { registerDirectiveBinder, unregisterDirectiveBinder, executeCustomDirectiveBinders, } from './binds/directiveRegistry';
|
|
17
|
+
// Error boundary functions for router integration:
|
|
18
|
+
export { boundaryForElement, setBoundaryError, clearBoundaryError, } from './binds/bindErrorBoundary';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnE,uEAAuE;AACvE,0EAA0E;AAC1E,sEAAsE;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,wDAAwD;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAK3D,0FAA0F;AAC1F,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC;AAEnC,mDAAmD;AACnD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.compiler.scoped-styles",
|
|
4
|
+
"title": "Scoped CSS Style Injector",
|
|
5
|
+
"category": "compiler"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Rewrites CSS selectors to scope them with a unique attribute (e.g., `[data-scope-xxxx]`) and injects them into the DOM.
|
|
10
|
+
*
|
|
11
|
+
* @param css - Raw CSS string from the component
|
|
12
|
+
* @param scopeId - Unique scope ID used to prefix selectors (e.g., `pithy-abc123`)
|
|
13
|
+
*/
|
|
14
|
+
/** @codexApi {"parent":"pithy.compiler.scoped-styles","name":"injectScopedStyle","stability":"stable","signature":"(css: string, scopeId: string) => void"} */
|
|
15
|
+
export declare function injectScopedStyle(css: string, scopeId: string): void;
|
|
16
|
+
//# sourceMappingURL=injectScopedStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectScopedStyle.d.ts","sourceRoot":"","sources":["../../src/compile/injectScopedStyle.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAOF;;;;;GAKG;AACH,+JAA+J;AAC/J,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CASpE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.compiler.scoped-styles",
|
|
4
|
+
"title": "Scoped CSS Style Injector",
|
|
5
|
+
"category": "compiler"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A Set to track injected styles and avoid duplicate <style> tags.
|
|
10
|
+
*/
|
|
11
|
+
const injectedStyles = new Set();
|
|
12
|
+
/**
|
|
13
|
+
* Rewrites CSS selectors to scope them with a unique attribute (e.g., `[data-scope-xxxx]`) and injects them into the DOM.
|
|
14
|
+
*
|
|
15
|
+
* @param css - Raw CSS string from the component
|
|
16
|
+
* @param scopeId - Unique scope ID used to prefix selectors (e.g., `pithy-abc123`)
|
|
17
|
+
*/
|
|
18
|
+
/** @codexApi {"parent":"pithy.compiler.scoped-styles","name":"injectScopedStyle","stability":"stable","signature":"(css: string, scopeId: string) => void"} */
|
|
19
|
+
export function injectScopedStyle(css, scopeId) {
|
|
20
|
+
const scopedCss = scopeCss(css, scopeId);
|
|
21
|
+
if (injectedStyles.has(scopedCss))
|
|
22
|
+
return; // Avoid reinjecting same style
|
|
23
|
+
injectedStyles.add(scopedCss);
|
|
24
|
+
const style = document.createElement('style');
|
|
25
|
+
style.textContent = scopedCss;
|
|
26
|
+
document.head.appendChild(style);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Prefixes all top-level CSS selectors with a scoped attribute selector.
|
|
30
|
+
* This ensures styles apply only to elements within the component.
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
* Input: "p { color: red; }", scopeId = "abc123"
|
|
34
|
+
* Output: "p[data-scope="abc123"] { color: red; }"
|
|
35
|
+
*
|
|
36
|
+
* @param css - Raw CSS string
|
|
37
|
+
* @param scopeId - Unique ID used as a data-scope attribute value
|
|
38
|
+
* @returns Scoped CSS string
|
|
39
|
+
*/
|
|
40
|
+
/** @codexApi {"parent":"pithy.compiler.scoped-styles","name":"scopeCss","stability":"stable","signature":"(css: string, scopeId: string) => string"} */
|
|
41
|
+
function scopeCss(css, scopeId) {
|
|
42
|
+
return css.replace(/(^|\})\s*([^{}]+)\s*\{/g, (_, sep, selector) => {
|
|
43
|
+
const scoped = selector
|
|
44
|
+
.split(',')
|
|
45
|
+
.map((s) => `${s.trim()}[data-scope="${scopeId}"]`)
|
|
46
|
+
.join(', ');
|
|
47
|
+
return `${sep} ${scoped} {`;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=injectScopedStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectScopedStyle.js","sourceRoot":"","sources":["../../src/compile/injectScopedStyle.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;AAEzC;;;;;GAKG;AACH,+JAA+J;AAC/J,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,OAAe;IAC5D,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAEzC,IAAI,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,OAAO,CAAC,+BAA+B;IAC1E,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAE9B,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,wJAAwJ;AACxJ,SAAS,QAAQ,CAAC,GAAW,EAAE,OAAe;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;QACjE,MAAM,MAAM,GAAG,QAAQ;aACpB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,gBAAgB,OAAO,IAAI,CAAC;aAC1D,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,GAAG,GAAG,IAAI,MAAM,IAAI,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PithyNode } from '@pithyjs/compiler';
|
|
2
|
+
export interface NodeExpando {
|
|
3
|
+
__pithyCtx?: Record<string, unknown>;
|
|
4
|
+
__pithyNode?: PithyNode;
|
|
5
|
+
__nodeId?: string;
|
|
6
|
+
__slotName?: string;
|
|
7
|
+
__fallbackFactory?: () => DocumentFragment;
|
|
8
|
+
__nested?: boolean;
|
|
9
|
+
__pithySkipText?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function nodeExpando<T extends Node>(node: T): T & NodeExpando;
|
|
12
|
+
//# sourceMappingURL=nodeExpando.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExpando.d.ts","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,gBAAgB,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,WAAW,CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExpando.js","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,WAAW,CAAiB,IAAO;IACjD,OAAO,IAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.compiler.html-parser",
|
|
4
|
+
"title": "HTML Template Parser",
|
|
5
|
+
"category": "compiler"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
import { type PithyNode } from '@pithyjs/compiler';
|
|
9
|
+
/** Structural type matching parse5's parseFragment — avoids leaking parse5 into .d.ts */
|
|
10
|
+
type ParseFragmentFn = (html: string, options?: {
|
|
11
|
+
sourceCodeLocationInfo?: boolean;
|
|
12
|
+
}) => unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Dynamically import parse5 and cache the parseFragment function.
|
|
15
|
+
* Must be called before using html() for runtime template compilation.
|
|
16
|
+
*
|
|
17
|
+
* If all templates are AOT-compiled, this function never needs to be called
|
|
18
|
+
* and parse5 will be completely absent from the production bundle.
|
|
19
|
+
*
|
|
20
|
+
* @returns Promise that resolves when parse5 is ready
|
|
21
|
+
*/
|
|
22
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"loadJITCompiler","stability":"stable","signature":"() => Promise<void>"} */
|
|
23
|
+
export declare function loadJITCompiler(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the JIT compiler (parse5) has been loaded.
|
|
26
|
+
* Used internally by parseHtml to provide a clear error message.
|
|
27
|
+
* @returns `true` if parse5 parseFragment is cached
|
|
28
|
+
*/
|
|
29
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"isJITLoaded","stability":"internal","signature":"() => boolean"} */
|
|
30
|
+
export declare function isJITLoaded(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Reset JIT compiler state. For testing only.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"resetJITState","stability":"internal","signature":"() => void"} */
|
|
36
|
+
export declare function resetJITState(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Pre-load parse5 synchronously for environments where it's already available
|
|
39
|
+
* (e.g., Node.js test environments, SSR). This is a convenience for the
|
|
40
|
+
* transition period — production code should use loadJITCompiler().
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"setParseFragment","stability":"internal","signature":"(fn: ParseFragmentFn) => void"} */
|
|
44
|
+
export declare function setParseFragment(fn: ParseFragmentFn): void;
|
|
45
|
+
/**
|
|
46
|
+
* Return the cached parseFragment function (or null if not loaded).
|
|
47
|
+
* Used by parseIdentifiersFromTemplate to reuse the same parse5 instance
|
|
48
|
+
* loaded via loadJITCompiler(), avoiding a separate dynamic import.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"getParseFragmentFn","stability":"internal","signature":"() => ParseFragmentFn | null"} */
|
|
52
|
+
export declare function getParseFragmentFn(): ParseFragmentFn | null;
|
|
53
|
+
/**
|
|
54
|
+
* Parse an HTML template string into a DOM fragment with PithyNode metadata.
|
|
55
|
+
* Requires parse5 to be loaded first via `loadJITCompiler()` or `setParseFragment()`.
|
|
56
|
+
* Throws if the runtime compiler has not been loaded.
|
|
57
|
+
*
|
|
58
|
+
* @param html - Raw HTML template string
|
|
59
|
+
* @param scopeId - Unique scope identifier for style scoping
|
|
60
|
+
* @param context - Reactive context for expression evaluation
|
|
61
|
+
* @param importedIdentifiers - Set of imported component names for self-closing tag handling
|
|
62
|
+
* @returns Object with `fragment` (live DOM) and `pithyNodes` (AST metadata)
|
|
63
|
+
*/
|
|
64
|
+
/** @codexApi {"parent":"pithy.compiler.html-parser","name":"parseHtml","stability":"stable","signature":"(html: string, scopeId: string, context: Record<string, unknown>, importedIdentifiers?: Set<string>) => { fragment: DocumentFragment; pithyNodes: PithyNode[] }"} */
|
|
65
|
+
export declare function parseHtml(html: string, scopeId: string, context: Record<string, unknown>, importedIdentifiers?: Set<string>): {
|
|
66
|
+
fragment: DocumentFragment;
|
|
67
|
+
pithyNodes: PithyNode[];
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=parseHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseHtml.d.ts","sourceRoot":"","sources":["../../src/compile/parseHtml.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAS3B,yFAAyF;AACzF,KAAK,eAAe,GAAG,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3C,OAAO,CAAC;AAKb;;;;;;;;GAQG;AACH,wIAAwI;AACxI,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAsB/C;AAED;;;;GAIG;AACH,gIAAgI;AAChI,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAgBD;;;GAGG;AACH,+HAA+H;AAC/H,wBAAgB,aAAa,IAAI,IAAI,CAGpC;AAED;;;;;GAKG;AACH,qJAAqJ;AACrJ,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,CAE1D;AAED;;;;;GAKG;AACH,sJAAsJ;AACtJ,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAE3D;AAID;;;;;;;;;;GAUG;AACH,8QAA8Q;AAC9Q,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,mBAAmB,GAAE,GAAG,CAAC,MAAM,CAAa,GAC3C;IACD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAqDA"}
|