@pithyjs/core 0.1.0-beta.2 → 0.1.0-beta.21
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/README.md +46 -8
- package/dist/a11y/focus-trap.d.ts +11 -3
- package/dist/a11y/focus-trap.d.ts.map +1 -1
- package/dist/a11y/focus-trap.js +55 -10
- package/dist/a11y/focus-trap.js.map +1 -1
- package/dist/a11y/index.d.ts +4 -4
- package/dist/a11y/index.js +4 -4
- package/dist/a11y/index.js.map +1 -1
- package/dist/a11y/keyboard-utils.js.map +1 -1
- package/dist/a11y/roving-tabindex.js.map +1 -1
- package/dist/a11y/skip-link.js.map +1 -1
- package/dist/compile/bindSwitchCases.d.ts +8 -3
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +137 -183
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindAfterComponents.d.ts +4 -0
- package/dist/compile/binds/bindAfterComponents.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterComponents.js +26 -0
- package/dist/compile/binds/bindAfterComponents.js.map +1 -0
- package/dist/compile/binds/bindAfterProjection.d.ts +7 -0
- package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterProjection.js +15 -0
- package/dist/compile/binds/bindAfterProjection.js.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts +8 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.js +227 -21
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +58 -21
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +186 -74
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindConditionals.d.ts +2 -2
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
- package/dist/compile/binds/bindConditionals.js +22 -5
- package/dist/compile/binds/bindConditionals.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +21 -19
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +61 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +272 -16
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
- package/dist/compile/binds/bindEventHandlers.js +15 -5
- package/dist/compile/binds/bindEventHandlers.js.map +1 -1
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindRefDirectives.js +2 -1
- package/dist/compile/binds/bindRefDirectives.js.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
- package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindStyleDirectives.js +48 -0
- package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +4 -2
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +87 -35
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/binds/declaredDirective.d.ts +12 -0
- package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
- package/dist/compile/binds/declaredDirective.js +42 -0
- package/dist/compile/binds/declaredDirective.js.map +1 -0
- package/dist/compile/binds/directiveRegistry.js.map +1 -1
- package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
- package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
- package/dist/compile/binds/forwardedAttrs.js +10 -2
- package/dist/compile/binds/forwardedAttrs.js.map +1 -1
- package/dist/compile/binds/propNames.d.ts +14 -0
- package/dist/compile/binds/propNames.d.ts.map +1 -0
- package/dist/compile/binds/propNames.js +116 -0
- package/dist/compile/binds/propNames.js.map +1 -0
- package/dist/compile/binds/staleRowProps.d.ts +9 -0
- package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
- package/dist/compile/binds/staleRowProps.js +86 -0
- package/dist/compile/binds/staleRowProps.js.map +1 -0
- package/dist/compile/compileExpression.js.map +1 -1
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +16 -7
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts +3 -4
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +36 -54
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/componentResult.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +15 -3
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +90 -9
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/disposeOrder.d.ts +35 -0
- package/dist/compile/disposeOrder.d.ts.map +1 -0
- package/dist/compile/disposeOrder.js +81 -0
- package/dist/compile/disposeOrder.js.map +1 -0
- package/dist/compile/evalDiagnostics.d.ts +7 -0
- package/dist/compile/evalDiagnostics.d.ts.map +1 -0
- package/dist/compile/evalDiagnostics.js +8 -0
- package/dist/compile/evalDiagnostics.js.map +1 -0
- package/dist/compile/forLoops/bindForLoops.d.ts +3 -3
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
- package/dist/compile/forLoops/bindForLoops.js +18 -13
- package/dist/compile/forLoops/bindForLoops.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +44 -26
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/forLoops/index.d.ts +5 -5
- package/dist/compile/forLoops/index.js +5 -5
- package/dist/compile/forLoops/index.js.map +1 -1
- package/dist/compile/forLoops/loopHelpers.js.map +1 -1
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
- package/dist/compile/forLoops/loopSignals.js +15 -1
- package/dist/compile/forLoops/loopSignals.js.map +1 -1
- package/dist/compile/forLoops/loopTraversal.js +2 -2
- package/dist/compile/forLoops/loopTraversal.js.map +1 -1
- package/dist/compile/handleConditionalChain.d.ts +2 -2
- package/dist/compile/handleConditionalChain.d.ts.map +1 -1
- package/dist/compile/handleConditionalChain.js +23 -89
- package/dist/compile/handleConditionalChain.js.map +1 -1
- package/dist/compile/index.d.ts +17 -17
- package/dist/compile/index.js +14 -14
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/injectScopedStyle.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +28 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js +12 -0
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/parseHtml.js +12 -6
- package/dist/compile/parseHtml.js.map +1 -1
- package/dist/compile/pithyTreeToDom.d.ts.map +1 -1
- package/dist/compile/pithyTreeToDom.js +17 -12
- package/dist/compile/pithyTreeToDom.js.map +1 -1
- package/dist/compile/renderBranch.d.ts +13 -0
- package/dist/compile/renderBranch.d.ts.map +1 -0
- package/dist/compile/renderBranch.js +72 -0
- package/dist/compile/renderBranch.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +12 -2
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +33 -4
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +65 -37
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +344 -39
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/compile/ssrMode.js +1 -1
- package/dist/compile/ssrMode.js.map +1 -1
- package/dist/compile/textValue.js.map +1 -1
- package/dist/compile/trimBlankEdges.d.ts +2 -0
- package/dist/compile/trimBlankEdges.d.ts.map +1 -0
- package/dist/compile/trimBlankEdges.js +15 -0
- package/dist/compile/trimBlankEdges.js.map +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/ref-signal.interface.js.map +1 -1
- package/dist/interfaces/ref.interface.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts +9 -5
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +130 -43
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts +2 -2
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +143 -87
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
- package/dist/runtime/bindings/applyDefer.js +16 -15
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +10 -1
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +117 -46
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +140 -124
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts +8 -1
- package/dist/runtime/bindings/helpers.d.ts.map +1 -1
- package/dist/runtime/bindings/helpers.js +36 -2
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +6 -6
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +5 -5
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/runtime/bindings/types.d.ts +2 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +1 -1
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/createContextProxy.js.map +1 -1
- package/dist/runtime/deferHelpers.d.ts +1 -1
- package/dist/runtime/deferHelpers.js.map +1 -1
- package/dist/runtime/html.js +7 -7
- package/dist/runtime/html.js.map +1 -1
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lazy.js +1 -1
- package/dist/runtime/lazy.js.map +1 -1
- package/dist/runtime/module-cache.js.map +1 -1
- package/dist/runtime/onDestroy.d.ts +7 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -1
- package/dist/runtime/onDestroy.js +16 -1
- package/dist/runtime/onDestroy.js.map +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
- package/dist/runtime/resource/createAction.d.ts +1 -1
- package/dist/runtime/resource/createAction.js +1 -1
- package/dist/runtime/resource/createAction.js.map +1 -1
- package/dist/runtime/resource/createResource.d.ts +1 -1
- package/dist/runtime/resource/createResource.d.ts.map +1 -1
- package/dist/runtime/resource/createResource.js +3 -4
- package/dist/runtime/resource/createResource.js.map +1 -1
- package/dist/runtime/resource/engine.d.ts +1 -1
- package/dist/runtime/resource/engine.js.map +1 -1
- package/dist/runtime/resource/index.d.ts +3 -3
- package/dist/runtime/resource/index.js +2 -2
- package/dist/runtime/resource/index.js.map +1 -1
- package/dist/runtime/resource/types.js.map +1 -1
- package/dist/types/globals.d.ts +10 -2
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.d.ts +2 -2
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/ref-signal.utility.d.ts +1 -1
- package/dist/utilities/ref-signal.utility.js.map +1 -1
- package/dist/utilities/ref.untility.d.ts +1 -1
- package/dist/utilities/ref.untility.js.map +1 -1
- package/package.json +11 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directiveRegistry.js","sourceRoot":"","sources":["../../../src/compile/binds/directiveRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAqBF;;GAEG;AACH,MAAM,gBAAgB,GAAsB,EAAE,CAAC;AAE/C;;;;;GAKG;AACH,iKAAiK;AACjK,MAAM,UAAU,uBAAuB,CAAC,MAAuB;IAC7D,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,mKAAmK;AACnK,MAAM,UAAU,yBAAyB,CAAC,MAAuB;IAC/D,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,gPAAgP;AAChP,MAAM,UAAU,6BAA6B,CAC3C,IAAgC,EAChC,OAAgC,EAChC,SAA4B;IAE5B,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"directiveRegistry.js","sourceRoot":"","sources":["../../../src/compile/binds/directiveRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAqBF;;GAEG;AACH,MAAM,gBAAgB,GAAsB,EAAE,CAAC;AAE/C;;;;;GAKG;AACH,iKAAiK;AACjK,MAAM,UAAU,uBAAuB,CAAC,MAAuB;IAC7D,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,mKAAmK;AACnK,MAAM,UAAU,yBAAyB,CAAC,MAAuB;IAC/D,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,gPAAgP;AAChP,MAAM,UAAU,6BAA6B,CAC3C,IAAgC,EAChC,OAAgC,EAChC,SAA4B;IAE5B,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACnC,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.directive-registry\",\n \"title\": \"Custom Directive Registry\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Custom Directive Registry\n *\n * Allows external packages (like @pithyjs/router) to register custom directive\n * binders that will be called during template compilation. This breaks the\n * circular dependency between core and router.\n *\n * @module compile/binds/directiveRegistry\n */\n\n/**\n * Type for a custom directive binder function\n */\nexport type DirectiveBinder = (\n root: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: Array<() => void>\n) => void;\n\n/**\n * Registry of custom directive binders\n */\nconst directiveBinders: DirectiveBinder[] = [];\n\n/**\n * Register a custom directive binder\n * Called by external packages to register their directive binding logic\n *\n * @param binder - The directive binder function to register\n */\n/** @codexApi {\"parent\":\"pithy.core.directive-registry\",\"name\":\"registerDirectiveBinder\",\"stability\":\"stable\",\"signature\":\"(binder: DirectiveBinder) => void\"} */\nexport function registerDirectiveBinder(binder: DirectiveBinder): void {\n if (!directiveBinders.includes(binder)) {\n directiveBinders.push(binder);\n }\n}\n\n/**\n * Unregister a custom directive binder\n *\n * @param binder - The directive binder function to unregister\n */\n/** @codexApi {\"parent\":\"pithy.core.directive-registry\",\"name\":\"unregisterDirectiveBinder\",\"stability\":\"stable\",\"signature\":\"(binder: DirectiveBinder) => void\"} */\nexport function unregisterDirectiveBinder(binder: DirectiveBinder): void {\n const index = directiveBinders.indexOf(binder);\n if (index !== -1) {\n directiveBinders.splice(index, 1);\n }\n}\n\n/**\n * Execute all registered directive binders\n * Called by compileTemplate during the binding phase\n *\n * @param root - The root element or fragment to bind directives in\n * @param context - The template context\n * @param disposers - Array to collect cleanup functions\n */\n/** @codexApi {\"parent\":\"pithy.core.directive-registry\",\"name\":\"executeCustomDirectiveBinders\",\"stability\":\"stable\",\"signature\":\"(root: Element | DocumentFragment, context: Record<string, unknown>, disposers: Array<() => void>) => void\"} */\nexport function executeCustomDirectiveBinders(\n root: Element | DocumentFragment,\n context: Record<string, unknown>,\n disposers: Array<() => void>\n): void {\n for (const binder of directiveBinders) {\n binder(root, context, disposers);\n }\n}\n"]}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
8
|
/** Collect the `data-*` attributes to carry from a component tag to its rendered root. */
|
|
9
|
-
export declare function collectForwardedAttrs(el: Element):
|
|
9
|
+
export declare function collectForwardedAttrs(el: Element): ForwardedAttr[];
|
|
10
|
+
/** Name, value, and whether the tag's template wrote that value. */
|
|
11
|
+
export type ForwardedAttr = [name: string, value: string, declared: boolean];
|
|
10
12
|
/**
|
|
11
13
|
* Write collected attributes onto the rendered root.
|
|
12
14
|
*
|
|
@@ -18,5 +20,5 @@ export declare function collectForwardedAttrs(el: Element): Array<[string, strin
|
|
|
18
20
|
*
|
|
19
21
|
* Shared by both binders so the two paths cannot drift.
|
|
20
22
|
*/
|
|
21
|
-
export declare function applyForwardedAttrs(target: Element, forwarded:
|
|
23
|
+
export declare function applyForwardedAttrs(target: Element, forwarded: ForwardedAttr[], tag: string): void;
|
|
22
24
|
//# sourceMappingURL=forwardedAttrs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwardedAttrs.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/forwardedAttrs.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"forwardedAttrs.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/forwardedAttrs.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AA+BF,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,OAAO,GAAG,aAAa,EAAE,CAQlE;AAED,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAE7E;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,aAAa,EAAE,EAC1B,GAAG,EAAE,MAAM,GACV,IAAI,CAgBN"}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
8
|
import { DIRECTIVE_ATTR_PREFIXES, isDirectiveAttr } from '@pithyjs/compiler';
|
|
9
|
+
import { nodeExpando } from '../nodeExpando.js';
|
|
10
|
+
import { isDeclaredDirective } from './declaredDirective.js';
|
|
9
11
|
const FORWARDED_DIRECTIVE_ATTRS = new Set(['data-classes']);
|
|
10
12
|
// Runtime-owned attributes: forwarding them would give the rendered root the
|
|
11
13
|
// component tag's node identity, its parent's style scope, or its loop/defer state.
|
|
@@ -37,7 +39,7 @@ export function collectForwardedAttrs(el) {
|
|
|
37
39
|
const forwarded = [];
|
|
38
40
|
for (const attr of Array.from(el.attributes)) {
|
|
39
41
|
if (isForwardableAttr(attr.name)) {
|
|
40
|
-
forwarded.push([attr.name, attr.value]);
|
|
42
|
+
forwarded.push([attr.name, attr.value, isDeclaredDirective(attr)]);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
return forwarded;
|
|
@@ -54,13 +56,19 @@ export function collectForwardedAttrs(el) {
|
|
|
54
56
|
* Shared by both binders so the two paths cannot drift.
|
|
55
57
|
*/
|
|
56
58
|
export function applyForwardedAttrs(target, forwarded, tag) {
|
|
57
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
for (const [name, value, declared] of forwarded) {
|
|
58
61
|
if (import.meta.env?.DEV &&
|
|
59
62
|
target.hasAttribute(name) &&
|
|
60
63
|
target.getAttribute(name) !== value) {
|
|
61
64
|
console.warn(`[PithyJS] <${tag}> forwarded ${name}="${value}" over the component's own "${target.getAttribute(name)}".`);
|
|
62
65
|
}
|
|
63
66
|
target.setAttribute(name, value);
|
|
67
|
+
const records = ((_a = nodeExpando(target)).__forwardedDirectives ?? (_a.__forwardedDirectives = new Map()));
|
|
68
|
+
if (declared)
|
|
69
|
+
records.set(name, value);
|
|
70
|
+
else
|
|
71
|
+
records.delete(name);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
//# sourceMappingURL=forwardedAttrs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwardedAttrs.js","sourceRoot":"","sources":["../../../src/compile/binds/forwardedAttrs.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,uBAAuB,EA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IAC5B,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { DIRECTIVE_ATTR_PREFIXES, isDirectiveAttr } from '@pithyjs/compiler';\nimport { nodeExpando } from '../nodeExpando';\nimport { isDeclaredDirective } from './declaredDirective';\n\nconst FORWARDED_DIRECTIVE_ATTRS = new Set(['data-classes']);\n\n// Runtime-owned attributes: forwarding them would give the rendered root the\n// component tag's node identity, its parent's style scope, or its loop/defer state.\nconst RUNTIME_ATTRS = new Set(['data-pid', 'data-for']);\nconst RUNTIME_ATTR_PREFIXES = ['data-scope-', 'data-defer-', 'data-loop-'];\n\n/**\n * Whether a `data-*` attribute on a component tag belongs on the rendered root.\n *\n * Shared by both compilation paths — the JIT binder (`bindComponentTags`) and\n * the AOT binder (`applyComponent`) — so a plain `data-testid` cannot survive\n * `pnpm dev` and vanish in a production build.\n */\nfunction isForwardableAttr(name: string): boolean {\n if (!name.startsWith('data-') || name.length === 'data-'.length) return false;\n if (DIRECTIVE_ATTR_PREFIXES.some(prefix => name.startsWith(prefix))) {\n return true;\n }\n if (FORWARDED_DIRECTIVE_ATTRS.has(name)) return true;\n if (isDirectiveAttr(name)) return false;\n if (RUNTIME_ATTRS.has(name)) return false;\n return !RUNTIME_ATTR_PREFIXES.some(prefix => name.startsWith(prefix));\n}\n\n/** Collect the `data-*` attributes to carry from a component tag to its rendered root. */\nexport function collectForwardedAttrs(el: Element): ForwardedAttr[] {\n const forwarded: ForwardedAttr[] = [];\n for (const attr of Array.from(el.attributes)) {\n if (isForwardableAttr(attr.name)) {\n forwarded.push([attr.name, attr.value, isDeclaredDirective(attr)]);\n }\n }\n return forwarded;\n}\n\n/** Name, value, and whether the tag's template wrote that value. */\nexport type ForwardedAttr = [name: string, value: string, declared: boolean];\n\n/**\n * Write collected attributes onto the rendered root.\n *\n * A forwarded `data-*` REPLACES the component's own value, where a forwarded\n * `class` merges into it — the asymmetry is invisible at the call site, and\n * ui-kit drives styling from `data-variant`/`data-color`/`data-size`, so an\n * author who copies one out of devtools silently overrides the prop that set\n * it. The DEV warning surfaces that collision without picking a winner.\n *\n * Shared by both binders so the two paths cannot drift.\n */\nexport function applyForwardedAttrs(\n target: Element,\n forwarded: ForwardedAttr[],\n tag: string\n): void {\n for (const [name, value, declared] of forwarded) {\n if (\n import.meta.env?.DEV &&\n target.hasAttribute(name) &&\n target.getAttribute(name) !== value\n ) {\n console.warn(\n `[PithyJS] <${tag}> forwarded ${name}=\"${value}\" over the component's own \"${target.getAttribute(name)}\".`\n );\n }\n target.setAttribute(name, value);\n const records = (nodeExpando(target).__forwardedDirectives ??= new Map());\n if (declared) records.set(name, value);\n else records.delete(name);\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.runtime.components",
|
|
4
|
+
"title": "Component Tag Binding System",
|
|
5
|
+
"category": "runtime"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
export interface PropNames {
|
|
9
|
+
names: string[];
|
|
10
|
+
fromParam: boolean;
|
|
11
|
+
exhaustive: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function parsePropNames(src: string): PropNames;
|
|
14
|
+
//# sourceMappingURL=propNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propNames.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAgDrD"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** @codex
|
|
2
|
+
{
|
|
3
|
+
"id": "pithy.runtime.components",
|
|
4
|
+
"title": "Component Tag Binding System",
|
|
5
|
+
"category": "runtime"
|
|
6
|
+
}
|
|
7
|
+
*/
|
|
8
|
+
const NONE = { names: [], fromParam: false, exhaustive: false };
|
|
9
|
+
export function parsePropNames(src) {
|
|
10
|
+
const arrow = /^\s*(?:async\s+)?([A-Za-z_$][\w$]*)\s*=>/.exec(src);
|
|
11
|
+
let head;
|
|
12
|
+
if (arrow) {
|
|
13
|
+
head = arrow[1];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const open = src.indexOf('(');
|
|
17
|
+
if (open < 0 ||
|
|
18
|
+
!/^\s*(?:async\b\s*)?(?:function\b[^(]*|[A-Za-z_$][\w$]*\s*)?$/.test(src.slice(0, open))) {
|
|
19
|
+
return NONE;
|
|
20
|
+
}
|
|
21
|
+
head = src.slice(open + 1).trimStart();
|
|
22
|
+
}
|
|
23
|
+
if (head.startsWith('{')) {
|
|
24
|
+
const body = balanced(head, 0);
|
|
25
|
+
if (body === null)
|
|
26
|
+
return NONE;
|
|
27
|
+
const entries = topLevelEntries(body);
|
|
28
|
+
return {
|
|
29
|
+
names: keyNames(entries),
|
|
30
|
+
fromParam: true,
|
|
31
|
+
exhaustive: !entries.some(e => e.startsWith('...')),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const param = /^([A-Za-z_$][\w$]*)/.exec(head)?.[1]?.replace(/\$/g, '\\$');
|
|
35
|
+
if (!param)
|
|
36
|
+
return NONE;
|
|
37
|
+
const names = new Set();
|
|
38
|
+
const destructure = /\b(?:const|let|var)\s*\{/g;
|
|
39
|
+
let m;
|
|
40
|
+
while ((m = destructure.exec(src))) {
|
|
41
|
+
const start = m.index + m[0].length - 1;
|
|
42
|
+
const body = balanced(src, start);
|
|
43
|
+
if (body === null)
|
|
44
|
+
break;
|
|
45
|
+
const rest = src.slice(start + body.length + 2);
|
|
46
|
+
if (new RegExp(`^\\s*=\\s*${param}\\b(?!\\s*\\.)`).test(rest)) {
|
|
47
|
+
for (const name of keyNames(topLevelEntries(body)))
|
|
48
|
+
names.add(name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const access of src.matchAll(new RegExp(`\\b${param}\\.([A-Za-z_$][\\w$]*)`, 'g'))) {
|
|
52
|
+
names.add(access[1]);
|
|
53
|
+
}
|
|
54
|
+
return { names: [...names], fromParam: false, exhaustive: false };
|
|
55
|
+
}
|
|
56
|
+
function balanced(src, start) {
|
|
57
|
+
let depth = 0;
|
|
58
|
+
let quote = '';
|
|
59
|
+
for (let i = start; i < src.length; i++) {
|
|
60
|
+
const c = src[i];
|
|
61
|
+
if (quote) {
|
|
62
|
+
if (c === '\\')
|
|
63
|
+
i++;
|
|
64
|
+
else if (c === quote)
|
|
65
|
+
quote = '';
|
|
66
|
+
}
|
|
67
|
+
else if (c === '"' || c === "'" || c === '`') {
|
|
68
|
+
quote = c;
|
|
69
|
+
}
|
|
70
|
+
else if (c === '{' || c === '[' || c === '(') {
|
|
71
|
+
depth++;
|
|
72
|
+
}
|
|
73
|
+
else if (c === '}' || c === ']' || c === ')') {
|
|
74
|
+
if (--depth === 0)
|
|
75
|
+
return src.slice(start + 1, i);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function topLevelEntries(body) {
|
|
81
|
+
const entries = [];
|
|
82
|
+
let depth = 0;
|
|
83
|
+
let quote = '';
|
|
84
|
+
let from = 0;
|
|
85
|
+
for (let i = 0; i < body.length; i++) {
|
|
86
|
+
const c = body[i];
|
|
87
|
+
if (quote) {
|
|
88
|
+
if (c === '\\')
|
|
89
|
+
i++;
|
|
90
|
+
else if (c === quote)
|
|
91
|
+
quote = '';
|
|
92
|
+
}
|
|
93
|
+
else if (c === '"' || c === "'" || c === '`') {
|
|
94
|
+
quote = c;
|
|
95
|
+
}
|
|
96
|
+
else if (c === '{' || c === '[' || c === '(') {
|
|
97
|
+
depth++;
|
|
98
|
+
}
|
|
99
|
+
else if (c === '}' || c === ']' || c === ')') {
|
|
100
|
+
depth--;
|
|
101
|
+
}
|
|
102
|
+
else if (c === ',' && depth === 0) {
|
|
103
|
+
entries.push(body.slice(from, i));
|
|
104
|
+
from = i + 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
entries.push(body.slice(from));
|
|
108
|
+
return entries.map(s => s.trim()).filter(Boolean);
|
|
109
|
+
}
|
|
110
|
+
function keyNames(entries) {
|
|
111
|
+
return entries
|
|
112
|
+
.filter(s => !s.startsWith('...'))
|
|
113
|
+
.map(s => s.split(/[:=]/)[0].trim())
|
|
114
|
+
.filter(s => /^[A-Za-z_$][\w$]*$/.test(s));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=propNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propNames.js","sourceRoot":"","sources":["../../../src/compile/binds/propNames.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAQF,MAAM,IAAI,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAE3E,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,0CAA0C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,IAAY,CAAC;IACjB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,IACE,IAAI,GAAG,CAAC;YACR,CAAC,8DAA8D,CAAC,IAAI,CAClE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CACnB,EACD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC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,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAClC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,QAAQ,CAAC,OAAiB;IACjC,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nexport interface PropNames {\n names: string[];\n fromParam: boolean;\n exhaustive: boolean;\n}\n\nconst NONE: PropNames = { names: [], fromParam: false, exhaustive: false };\n\nexport function parsePropNames(src: string): PropNames {\n const arrow = /^\\s*(?:async\\s+)?([A-Za-z_$][\\w$]*)\\s*=>/.exec(src);\n let head: string;\n if (arrow) {\n head = arrow[1];\n } else {\n const open = src.indexOf('(');\n if (\n open < 0 ||\n !/^\\s*(?:async\\b\\s*)?(?:function\\b[^(]*|[A-Za-z_$][\\w$]*\\s*)?$/.test(\n src.slice(0, open)\n )\n ) {\n return NONE;\n }\n head = src.slice(open + 1).trimStart();\n }\n if (head.startsWith('{')) {\n const body = balanced(head, 0);\n if (body === null) return NONE;\n const entries = topLevelEntries(body);\n return {\n names: keyNames(entries),\n fromParam: true,\n exhaustive: !entries.some(e => e.startsWith('...')),\n };\n }\n\n const param = /^([A-Za-z_$][\\w$]*)/.exec(head)?.[1]?.replace(/\\$/g, '\\\\$');\n if (!param) return NONE;\n const names = new Set<string>();\n const destructure = /\\b(?:const|let|var)\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = destructure.exec(src))) {\n const start = m.index + m[0].length - 1;\n const body = balanced(src, start);\n if (body === null) break;\n const rest = src.slice(start + body.length + 2);\n if (new RegExp(`^\\\\s*=\\\\s*${param}\\\\b(?!\\\\s*\\\\.)`).test(rest)) {\n for (const name of keyNames(topLevelEntries(body))) names.add(name);\n }\n }\n for (const access of src.matchAll(\n new RegExp(`\\\\b${param}\\\\.([A-Za-z_$][\\\\w$]*)`, 'g')\n )) {\n names.add(access[1]);\n }\n return { names: [...names], fromParam: false, exhaustive: false };\n}\n\nfunction balanced(src: string, start: number): string | null {\n let depth = 0;\n let quote = '';\n for (let i = start; i < src.length; i++) {\n const c = src[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n if (--depth === 0) return src.slice(start + 1, i);\n }\n }\n return null;\n}\n\nfunction topLevelEntries(body: string): string[] {\n const entries: string[] = [];\n let depth = 0;\n let quote = '';\n let from = 0;\n for (let i = 0; i < body.length; i++) {\n const c = body[i];\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\"' || c === \"'\" || c === '`') {\n quote = c;\n } else if (c === '{' || c === '[' || c === '(') {\n depth++;\n } else if (c === '}' || c === ']' || c === ')') {\n depth--;\n } else if (c === ',' && depth === 0) {\n entries.push(body.slice(from, i));\n from = i + 1;\n }\n }\n entries.push(body.slice(from));\n return entries.map(s => s.trim()).filter(Boolean);\n}\n\nfunction keyNames(entries: string[]): string[] {\n return entries\n .filter(s => !s.startsWith('...'))\n .map(s => s.split(/[:=]/)[0].trim())\n .filter(s => /^[A-Za-z_$][\\w$]*$/.test(s));\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RowLocals = Map<string, () => unknown>;
|
|
2
|
+
export declare function rowLocalsOf(ctx: Record<string, unknown>): RowLocals | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Warns when a component prop in a kept `@for` row would now read differently.
|
|
5
|
+
* Objects are skipped: a list can rebuild them on every write while the
|
|
6
|
+
* component reads live values through them, as Studio's `PropEditor` does.
|
|
7
|
+
*/
|
|
8
|
+
export declare function watchStaleRowProp(ctx: Record<string, unknown>, site: object, tag: string, prop: string, expr: string, value: unknown, read: () => unknown, disposers: (() => void)[]): void;
|
|
9
|
+
//# sourceMappingURL=staleRowProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleRowProps.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/staleRowProps.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC;AAKnD,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,SAAS,GAAG,SAAS,CAIvB;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,OAAO,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAmDN"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { effect, untrack } from '@pithyjs/signals';
|
|
2
|
+
import { isSSRMode } from '../ssrMode.js';
|
|
3
|
+
const warned = new WeakMap();
|
|
4
|
+
// `in` first: a context can be a proxy that warns on reading a missing key.
|
|
5
|
+
export function rowLocalsOf(ctx) {
|
|
6
|
+
return '__pithyRowLocals' in ctx
|
|
7
|
+
? ctx.__pithyRowLocals
|
|
8
|
+
: undefined;
|
|
9
|
+
}
|
|
10
|
+
function callsLocal(expr, name) {
|
|
11
|
+
const escaped = name.replace(/\$/g, '\\$');
|
|
12
|
+
return new RegExp(`(?<![\\w$.])${escaped}\\s*(\\?\\.\\s*)?\\(`).test(expr);
|
|
13
|
+
}
|
|
14
|
+
// Must not throw: a throw here reaches the loop's catch, which clears the list.
|
|
15
|
+
function describe(value) {
|
|
16
|
+
if (typeof value === 'string')
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
if (typeof value === 'object' && value !== null)
|
|
19
|
+
return 'an object';
|
|
20
|
+
if (typeof value === 'function')
|
|
21
|
+
return 'a function';
|
|
22
|
+
return String(value);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Warns when a component prop in a kept `@for` row would now read differently.
|
|
26
|
+
* Objects are skipped: a list can rebuild them on every write while the
|
|
27
|
+
* component reads live values through them, as Studio's `PropEditor` does.
|
|
28
|
+
*/
|
|
29
|
+
export function watchStaleRowProp(ctx, site, tag, prop, expr, value, read, disposers) {
|
|
30
|
+
const locals = rowLocalsOf(ctx);
|
|
31
|
+
if (!locals || isSSRMode())
|
|
32
|
+
return;
|
|
33
|
+
if (typeof value === 'function')
|
|
34
|
+
return;
|
|
35
|
+
if (typeof value === 'object' && value !== null)
|
|
36
|
+
return;
|
|
37
|
+
const used = [...locals].filter(([name]) => callsLocal(expr, name));
|
|
38
|
+
if (used.length === 0)
|
|
39
|
+
return;
|
|
40
|
+
let subscribed = false;
|
|
41
|
+
let queued = false;
|
|
42
|
+
let disposed = false;
|
|
43
|
+
const compare = () => {
|
|
44
|
+
queued = false;
|
|
45
|
+
if (disposed)
|
|
46
|
+
return;
|
|
47
|
+
let next;
|
|
48
|
+
try {
|
|
49
|
+
next = untrack(read);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (Object.is(next, value))
|
|
55
|
+
return;
|
|
56
|
+
let props = warned.get(site);
|
|
57
|
+
if (!props)
|
|
58
|
+
warned.set(site, (props = new Set()));
|
|
59
|
+
if (props.has(prop))
|
|
60
|
+
return;
|
|
61
|
+
props.add(prop);
|
|
62
|
+
console.warn(`[PithyJS] <${tag} ${prop}="${expr}"> in an @for row still shows ` +
|
|
63
|
+
`${describe(value)}, not ${describe(next)}: a component ` +
|
|
64
|
+
`reads this value once, and a list write kept the row. Pass an ` +
|
|
65
|
+
`accessor (${prop}="() => ${expr}") if the component accepts one, ` +
|
|
66
|
+
`or use a track value that changes with the item.`);
|
|
67
|
+
};
|
|
68
|
+
const stop = effect(() => {
|
|
69
|
+
for (const [, accessor] of used)
|
|
70
|
+
accessor();
|
|
71
|
+
if (!subscribed) {
|
|
72
|
+
subscribed = true;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (queued)
|
|
76
|
+
return;
|
|
77
|
+
queued = true;
|
|
78
|
+
// Not inline: this effect can run between two loops' syncs in one flush.
|
|
79
|
+
queueMicrotask(compare);
|
|
80
|
+
});
|
|
81
|
+
disposers.push(() => {
|
|
82
|
+
disposed = true;
|
|
83
|
+
stop();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=staleRowProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleRowProps.js","sourceRoot":"","sources":["../../../src/compile/binds/staleRowProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,MAAM,MAAM,GAAG,IAAI,O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AChB,UAAU,GAAG,IAAI,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,yEAAyE;QACzE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { effect, untrack } from '@pithyjs/signals';\nimport { isSSRMode } from '../ssrMode';\n\nexport type RowLocals = Map<string, () => unknown>;\n\nconst warned = new WeakMap<object, Set<string>>();\n\n// `in` first: a context can be a proxy that warns on reading a missing key.\nexport function rowLocalsOf(\n ctx: Record<string, unknown>\n): RowLocals | undefined {\n return '__pithyRowLocals' in ctx\n ? (ctx.__pithyRowLocals as RowLocals)\n : undefined;\n}\n\nfunction callsLocal(expr: string, name: string): boolean {\n const escaped = name.replace(/\\$/g, '\\\\$');\n return new RegExp(`(?<![\\\\w$.])${escaped}\\\\s*(\\\\?\\\\.\\\\s*)?\\\\(`).test(expr);\n}\n\n// Must not throw: a throw here reaches the loop's catch, which clears the list.\nfunction describe(value: unknown): string {\n if (typeof value === 'string') return JSON.stringify(value);\n if (typeof value === 'object' && value !== null) return 'an object';\n if (typeof value === 'function') return 'a function';\n return String(value);\n}\n\n/**\n * Warns when a component prop in a kept `@for` row would now read differently.\n * Objects are skipped: a list can rebuild them on every write while the\n * component reads live values through them, as Studio's `PropEditor` does.\n */\nexport function watchStaleRowProp(\n ctx: Record<string, unknown>,\n site: object,\n tag: string,\n prop: string,\n expr: string,\n value: unknown,\n read: () => unknown,\n disposers: (() => void)[]\n): void {\n const locals = rowLocalsOf(ctx);\n if (!locals || isSSRMode()) return;\n if (typeof value === 'function') return;\n if (typeof value === 'object' && value !== null) return;\n\n const used = [...locals].filter(([name]) => callsLocal(expr, name));\n if (used.length === 0) return;\n\n let subscribed = false;\n let queued = false;\n let disposed = false;\n\n const compare = () => {\n queued = false;\n if (disposed) return;\n let next: unknown;\n try {\n next = untrack(read);\n } catch {\n return;\n }\n if (Object.is(next, value)) return;\n let props = warned.get(site);\n if (!props) warned.set(site, (props = new Set()));\n if (props.has(prop)) return;\n props.add(prop);\n console.warn(\n `[PithyJS] <${tag} ${prop}=\"${expr}\"> in an @for row still shows ` +\n `${describe(value)}, not ${describe(next)}: a component ` +\n `reads this value once, and a list write kept the row. Pass an ` +\n `accessor (${prop}=\"() => ${expr}\") if the component accepts one, ` +\n `or use a track value that changes with the item.`\n );\n };\n\n const stop = effect(() => {\n for (const [, accessor] of used) accessor();\n if (!subscribed) {\n subscribed = true;\n return;\n }\n if (queued) return;\n queued = true;\n // Not inline: this effect can run between two loops' syncs in one flush.\n queueMicrotask(compare);\n });\n disposers.push(() => {\n disposed = true;\n stop();\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileExpression.js","sourceRoot":"","sources":["../../src/compile/compileExpression.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,wMAAwM;AACxM,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,GAA4B,EAC5B,QAAY;IAEZ,2BAA2B;IAC3B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,OAAO,GAAG,EAAE,CAAC,QAAa,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC;QACH,yGAAyG;QACzG,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,uBAAuB,IAAI,KAAK,CAEzD,CAAC;QACP,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,6CAA6C,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,GAAG,EAAE,CAAC,QAAa,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"compileExpression.js","sourceRoot":"","sources":["../../src/compile/compileExpression.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,wMAAwM;AACxM,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,GAA4B,EAC5B,QAAY;IAEZ,2BAA2B;IAC3B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,OAAO,GAAG,EAAE,CAAC,QAAa,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC;QACH,yGAAyG;QACzG,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,uBAAuB,IAAI,KAAK,CAEzD,CAAC;QACP,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,6CAA6C,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,GAAG,EAAE,CAAC,QAAa,CAAC;IAC7B,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.compiler.expression\",\n \"title\": \"Expression Compiler\",\n \"category\": \"compiler\"\n}\n*/\n\n/** @codexApi {\"parent\":\"pithy.compiler.expression\",\"name\":\"compileExpression\",\"stability\":\"stable\",\"signature\":\"<T = unknown>(expr: string, ctx: Record<string, unknown>, fallback?: T) => () => T\"} */\nexport function compileExpression<T = unknown>(\n expr: string,\n ctx: Record<string, unknown>,\n fallback?: T\n): () => T {\n // Handle empty expressions\n if (!expr || expr.trim() === '') {\n return () => fallback as T;\n }\n\n try {\n // eslint-disable-next-line no-new-func -- JIT template expression evaluation is a core framework feature\n const fn = new Function('ctx', `with(ctx) { return (${expr}) }`) as (\n ctx: Record<string, unknown>\n ) => T;\n return () => fn(ctx);\n } catch (err) {\n if (import.meta.env?.DEV) {\n console.warn(`[PithyJS] ❌ Failed to compile expression \"${expr}\":`, err);\n }\n return () => fallback as T;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileNodes.d.ts","sourceRoot":"","sources":["../../src/compile/compileNodes.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"compileNodes.d.ts","sourceRoot":"","sources":["../../src/compile/compileNodes.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAUnD;;;;;;;;;;;;;;;;;GAiBG;AACH,0NAA0N;AAC1N,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA+E/C"}
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
"category": "runtime"
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
|
-
import { pithyTreeToDom } from './pithyTreeToDom';
|
|
9
|
-
import { bindStructuralDirectives, bindTemplateDirectives, } from './compileTemplate';
|
|
10
|
-
import { drainDestroyCallbacks } from '../runtime/onDestroy';
|
|
8
|
+
import { pithyTreeToDom } from './pithyTreeToDom.js';
|
|
9
|
+
import { bindStructuralDirectives, bindTemplateDirectives, } from './compileTemplate.js';
|
|
10
|
+
import { drainDestroyCallbacks } from '../runtime/onDestroy.js';
|
|
11
|
+
import { orderByDocument } from './disposeOrder.js';
|
|
12
|
+
import { withinRender } from './ssrCrashes.js';
|
|
11
13
|
/**
|
|
12
14
|
* Compiles an array of PithyNode AST nodes into live DOM with full binding pipeline.
|
|
13
15
|
*
|
|
@@ -36,10 +38,14 @@ export function compileNodes(nodes, context) {
|
|
|
36
38
|
try {
|
|
37
39
|
// 1. AST → unbound DOM
|
|
38
40
|
fragment = pithyTreeToDom(nodes, context);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const built = fragment;
|
|
42
|
+
withinRender(() => {
|
|
43
|
+
// 2. Structural directives (@switch, @if/@else, @for)
|
|
44
|
+
bindStructuralDirectives(nodes, built, context, disposers);
|
|
45
|
+
// 3. Non-structural bindings (refs, error boundaries, components, text, events, etc.)
|
|
46
|
+
bindTemplateDirectives(built, context, disposers);
|
|
47
|
+
});
|
|
48
|
+
orderByDocument(disposers);
|
|
43
49
|
}
|
|
44
50
|
catch (err) {
|
|
45
51
|
// Clean up any disposers already registered during partial compilation
|
|
@@ -76,6 +82,7 @@ export function compileNodes(nodes, context) {
|
|
|
76
82
|
/* ignore */
|
|
77
83
|
}
|
|
78
84
|
}
|
|
85
|
+
disposers.length = 0;
|
|
79
86
|
},
|
|
80
87
|
};
|
|
81
88
|
}
|
|
@@ -90,6 +97,7 @@ export function compileNodes(nodes, context) {
|
|
|
90
97
|
/* ignore */
|
|
91
98
|
}
|
|
92
99
|
}
|
|
100
|
+
disposers.length = 0;
|
|
93
101
|
for (let i = destroyCallbacks.length - 1; i >= 0; i--) {
|
|
94
102
|
try {
|
|
95
103
|
destroyCallbacks[i]();
|
|
@@ -98,6 +106,7 @@ export function compileNodes(nodes, context) {
|
|
|
98
106
|
/* ignore */
|
|
99
107
|
}
|
|
100
108
|
}
|
|
109
|
+
destroyCallbacks.length = 0;
|
|
101
110
|
},
|
|
102
111
|
};
|
|
103
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileNodes.js","sourceRoot":"","sources":["../../src/compile/compileNodes.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"compileNodes.js","sourceRoot":"","sources":["../../src/compile/compileNodes.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,0NAA0N;AAC1N,MAAM,UAAU,YAAY,CAC1B,KAAkB,EAClB,OAAgC;IAEhC,yEAAyE;IACzE,+DAA+D;IAC/D,MAAM,gBAAgB,GAAG,qBAAqB,EAAE,CAAC;IACjD,MAAM,SAAS,GAAmB,EAAE,CAAC;IAErC,IAAI,QAA0B,CAAC;IAC/B,IAAI,CAAC;QACH,uBAAuB;QACvB,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC;QAEvB,YAAY,CAAC,GAAG,EAAE;YAChB,sDAAsD;YACtD,wBAAwB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;YAE3D,sFAAsF;YACtF,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QACH,eAAe,CAAC,SAAS,CAA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BACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;YACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.compile-nodes\",\n \"title\": \"AST Node Compiler\",\n \"category\": \"runtime\"\n}\n*/\n\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport {\n bindStructuralDirectives,\n bindTemplateDirectives,\n} from './compileTemplate';\nimport { drainDestroyCallbacks } from '../runtime/onDestroy';\nimport { orderByDocument } from './disposeOrder';\nimport { withinRender } from './ssrCrashes';\n\n/**\n * Compiles an array of PithyNode AST nodes into live DOM with full binding pipeline.\n *\n * This is the AST counterpart to `compileTemplate`:\n * - `compileTemplate`: HTML string → parse → AST → DOM → structural → non-structural\n * - `compileNodes`: AST → DOM → structural → non-structural\n *\n * Use when you already have AST nodes (e.g. from `__childAstNodes` in component context)\n * and need the full compilation pipeline including structural directives (@if, @switch, @for).\n *\n * @example\n * ```ts\n * import { compileNodes } from \"@pithyjs/core\";\n * const { el, destroy } = compileNodes(astNodes, context);\n * document.body.appendChild(el);\n * // later: destroy();\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"compileNodes\",\"stability\":\"stable\",\"signature\":\"(nodes: PithyNode[], context: Record<string, unknown>) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function compileNodes(\n nodes: PithyNode[],\n context: Record<string, unknown>\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks — prevents leaks when compileNodes is used\n // as a standalone entry point (renderChildren, ErrorBoundary).\n const destroyCallbacks = drainDestroyCallbacks();\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // 1. AST → unbound DOM\n fragment = pithyTreeToDom(nodes, context);\n const built = fragment;\n\n withinRender(() => {\n // 2. Structural directives (@switch, @if/@else, @for)\n bindStructuralDirectives(nodes, built, context, disposers);\n\n // 3. Non-structural bindings (refs, error boundaries, components, text, events, etc.)\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers already registered during partial compilation\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n // Run drained callbacks LIFO before rethrowing so partially-initialized\n // resources are still cleaned up.\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n // Fast path when no onDestroy was called\n if (destroyCallbacks.length === 0) {\n return {\n el: fragment,\n destroy() {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n disposers.length = 0;\n },\n };\n }\n\n return {\n el: fragment,\n destroy() {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n disposers.length = 0;\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
* Runs all structural directive bindings on a fragment.
|
|
10
10
|
*
|
|
11
11
|
* Ordering:
|
|
12
|
-
* 1) Switch cases first — they
|
|
13
|
-
* 2) Conditionals (@if/@else) —
|
|
14
|
-
* 3)
|
|
15
|
-
* 4) For loops — skips nodes already processed by conditionals
|
|
12
|
+
* 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM
|
|
13
|
+
* 2) Conditionals (@if/@else) — each branch binds its own nested switches
|
|
14
|
+
* 3) For loops — skips nodes already processed by switches and conditionals
|
|
16
15
|
*/
|
|
17
16
|
export declare function bindStructuralDirectives(nodes: import('@pithyjs/compiler').PithyNode[], fragment: DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]): void;
|
|
18
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileTemplate.d.ts","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"compileTemplate.d.ts","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAkBF;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,EAC9C,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAUN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+RAA+R;AAC/R,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAChC;IAAE,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAiD7D;AAED;;;;;;;;;;;;;;;GAeG;AACH,qNAAqN;AACrN,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAsBN"}
|
|
@@ -5,36 +5,29 @@
|
|
|
5
5
|
"category": "runtime"
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
|
-
import { parseHtml } from './parseHtml';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { bindDeferDirectives } from './binds/bindDeferDirectives';
|
|
20
|
-
import { bindForLoops } from './forLoops/bindForLoops';
|
|
21
|
-
import { bindSwitchCases } from './bindSwitchCases';
|
|
22
|
-
import { extractSlotDefs, mountProjection, } from './contentProjection';
|
|
23
|
-
import { executeCustomDirectiveBinders } from './binds/directiveRegistry';
|
|
8
|
+
import { parseHtml } from './parseHtml.js';
|
|
9
|
+
import { withinRender } from './ssrCrashes.js';
|
|
10
|
+
import { injectScopedStyle } from './injectScopedStyle.js';
|
|
11
|
+
import { bindConditionals } from './binds/bindConditionals.js';
|
|
12
|
+
import { bindRefDirectives } from './binds/bindRefDirectives.js';
|
|
13
|
+
import { bindErrorBoundary } from './binds/bindErrorBoundary.js';
|
|
14
|
+
import { bindForLoops } from './forLoops/bindForLoops.js';
|
|
15
|
+
import { bindSwitchCases } from './bindSwitchCases.js';
|
|
16
|
+
import { extractSlotDefs, mountProjection, } from './contentProjection.js';
|
|
17
|
+
import { bindAfterProjection } from './binds/bindAfterProjection.js';
|
|
18
|
+
import { orderByDocument } from './disposeOrder.js';
|
|
24
19
|
/**
|
|
25
20
|
* Runs all structural directive bindings on a fragment.
|
|
26
21
|
*
|
|
27
22
|
* Ordering:
|
|
28
|
-
* 1) Switch cases first — they
|
|
29
|
-
* 2) Conditionals (@if/@else) —
|
|
30
|
-
* 3)
|
|
31
|
-
* 4) For loops — skips nodes already processed by conditionals
|
|
23
|
+
* 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM
|
|
24
|
+
* 2) Conditionals (@if/@else) — each branch binds its own nested switches
|
|
25
|
+
* 3) For loops — skips nodes already processed by switches and conditionals
|
|
32
26
|
*/
|
|
33
27
|
export function bindStructuralDirectives(nodes, fragment, context, disposers) {
|
|
34
|
-
bindSwitchCases(nodes, fragment, context, new Set(), disposers);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
bindForLoops(nodes, fragment, context, disposers, conditionalProcessedIds);
|
|
28
|
+
const processed = bindSwitchCases(nodes, fragment, context, new Set(), disposers);
|
|
29
|
+
bindConditionals(nodes, fragment, context, processed, disposers);
|
|
30
|
+
bindForLoops(nodes, fragment, context, disposers, processed);
|
|
38
31
|
}
|
|
39
32
|
/**
|
|
40
33
|
* Compiles a raw HTML template into live DOM nodes with signal bindings,
|
|
@@ -68,14 +61,18 @@ export function compileTemplate(html, context, css, scopeId, importedIdentifiers
|
|
|
68
61
|
// Parse into fragment + AST
|
|
69
62
|
const parsed = parseHtml(html, id, context, importedIdentifiers);
|
|
70
63
|
fragment = parsed.fragment;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
const built = fragment;
|
|
65
|
+
withinRender(() => {
|
|
66
|
+
// Structural transforms first (they change the DOM shape and add anchors)
|
|
67
|
+
bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);
|
|
68
|
+
// Scoped CSS after structure is stable
|
|
69
|
+
if (css) {
|
|
70
|
+
injectScopedStyle(css, id);
|
|
71
|
+
}
|
|
72
|
+
// Remaining directives/bindings in carefully chosen order
|
|
73
|
+
bindTemplateDirectives(built, context, disposers);
|
|
74
|
+
});
|
|
75
|
+
orderByDocument(disposers);
|
|
79
76
|
}
|
|
80
77
|
catch (err) {
|
|
81
78
|
// Clean up any disposers registered during partial compilation
|
|
@@ -100,6 +97,7 @@ export function compileTemplate(html, context, css, scopeId, importedIdentifiers
|
|
|
100
97
|
/* ignore */
|
|
101
98
|
}
|
|
102
99
|
}
|
|
100
|
+
disposers.length = 0;
|
|
103
101
|
},
|
|
104
102
|
};
|
|
105
103
|
}
|
|
@@ -128,30 +126,14 @@ export function bindTemplateDirectives(fragment, context, disposers) {
|
|
|
128
126
|
// 3) content projection — mount projected content into slot anchors BEFORE components.
|
|
129
127
|
// Projected content may contain component tags (e.g., nested <Show> inside <Show>).
|
|
130
128
|
// If components ran first, those nested component tags would never be processed.
|
|
131
|
-
//
|
|
129
|
+
// Without a SlotMap (a component called directly) slots still get their fallback.
|
|
132
130
|
// Use 'in' operator to check via Proxy's has() trap without triggering the get() warning
|
|
133
131
|
const slotMap = ('__slotMap' in context ? context.__slotMap : undefined);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
mountProjection(slotDefs, slotMap, disposers);
|
|
138
|
-
}
|
|
132
|
+
const slotDefs = extractSlotDefs(fragment);
|
|
133
|
+
if (slotDefs.length > 0) {
|
|
134
|
+
mountProjection(slotDefs, slotMap ?? new Map(), disposers);
|
|
139
135
|
}
|
|
140
|
-
// 4) components
|
|
141
|
-
|
|
142
|
-
// 5) two-way model bindings for native controls at this level
|
|
143
|
-
bindDefaultTwoWay(fragment, context, disposers);
|
|
144
|
-
// 6) text interpolations — our binder already skips nested loops & component roots
|
|
145
|
-
bindTextInterpolations(fragment, context, disposers);
|
|
146
|
-
// 7) events (idempotent; supports modifiers; nearest ctx; $event/$el)
|
|
147
|
-
bindEventHandlers(fragment, context, disposers);
|
|
148
|
-
// 8) classes
|
|
149
|
-
bindClassDirectives(fragment, context, disposers);
|
|
150
|
-
// 9) bound attributes
|
|
151
|
-
bindBoundAttributes(fragment, context, disposers);
|
|
152
|
-
// 10) custom directives — allows external packages (router, etc.) to register binders
|
|
153
|
-
executeCustomDirectiveBinders(fragment, context, disposers);
|
|
154
|
-
// 11) defer directives — lazy loading with @defer, @load, @placeholder
|
|
155
|
-
bindDeferDirectives(fragment, context, disposers);
|
|
136
|
+
// 4-11) components, two-way, text, events, classes, attributes, custom, defer
|
|
137
|
+
bindAfterProjection(fragment, context, disposers);
|
|
156
138
|
}
|
|
157
139
|
//# sourceMappingURL=compileTemplate.js.map
|