@pithyjs/core 0.1.0-beta.24 → 0.1.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +3 -1
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +5 -1
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +39 -0
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +77 -2
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/index.d.ts +1 -0
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +1 -0
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +4 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/renderChildren.d.ts +2 -0
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +6 -2
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +9 -0
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +3 -1
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindComponentsTags.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"bindComponentsTags.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAmEF,qGAAqG;AACrG,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAqGD;;;;;;GAMG;AACH,4NAA4N;AAC5N,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAmbN"}
|
|
@@ -9,7 +9,7 @@ import { compileExpression } from '../compileExpression.js';
|
|
|
9
9
|
import { isTemplateAttr } from './declaredDirective.js';
|
|
10
10
|
import { boundaryForElement, currentBoundary, replaceHidden, runWithBoundary, slotContentHidden, withSlotBoundary, } from './bindErrorBoundary.js';
|
|
11
11
|
import { bindAfterComponents } from './bindAfterComponents.js';
|
|
12
|
-
import { collectSlotMap, inProjectedContent } from '../contentProjection.js';
|
|
12
|
+
import { collectSlotMap, inProjectedContent, warnUndeclaredSlots, } from '../contentProjection.js';
|
|
13
13
|
import { boundSlotMessage, componentChildDirectiveMessage, componentChildDirectives, nativeTags, } from '@pithyjs/compiler';
|
|
14
14
|
import { collectForwardedAttrs, applyForwardedAttrs } from './forwardedAttrs.js';
|
|
15
15
|
import { createRoot, untrack } from '@pithyjs/signals';
|
|
@@ -397,6 +397,8 @@ export function bindComponentTags(root, rootCtx, disposers) {
|
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
399
|
const { el: renderedEl, destroy } = out;
|
|
400
|
+
if (import.meta.env?.DEV)
|
|
401
|
+
warnUndeclaredSlots(slotMap);
|
|
400
402
|
// Capture class and data-* attributes for forwarding to rendered root:
|
|
401
403
|
// directive bindings (data-on-*, data-bind-*, data-class-toggle-*,
|
|
402
404
|
// data-classes, data-style-*) plus any author-written data-* attribute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindComponentsTags.js","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAA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;YAC/C,mBAAmB,CAAC,aAAa,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;YACxD,iBAAiB,CACf,aAAa,EACb,QAAQ,EACR,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAC9C,CAAC;YACF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;YACtE,IAAI,UAAU,CAAC,MAAM;gBACnB,WAAW,CAAC,aAAa,CAAC,CAAC,YAAY,GAAG,UAAU,CAAC;YACvD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;YACxE,IAAI,YAAY,CAAC,MAAM;gBACrB,WAAW,CAAC,aAAa,CAAC,CAAC,cAAc,GAAG,YAAY,CAAC;YAC3D,wEAAwE;YACxE,qEAAqE;YACrE,IAAI,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBACxC,MAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;gBACnD,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC/B,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { compileExpression } from '../compileExpression';\nimport { isTemplateAttr } from './declaredDirective';\nimport {\n boundaryForElement,\n currentBoundary,\n replaceHidden,\n runWithBoundary,\n slotContentHidden,\n withSlotBoundary,\n} from './bindErrorBoundary';\nimport { bindAfterComponents } from './bindAfterComponents';\nimport { collectSlotMap, inProjectedContent } from '../contentProjection';\nimport {\n boundSlotMessage,\n componentChildDirectiveMessage,\n componentChildDirectives,\n nativeTags,\n type PithyNode,\n} from '@pithyjs/compiler';\nimport { collectForwardedAttrs, applyForwardedAttrs } from './forwardedAttrs';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport { watchStaleRowProp } from './staleRowProps';\nimport { markForwardTarget, nodeExpando } from '../nodeExpando';\nimport {\n invalidRenderError,\n invalidRenderMessage,\n propEvalMessage,\n} from '../evalDiagnostics';\nimport { componentDisposer } from '../disposeOrder';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../ssrMode';\nimport {\n clearSSRRenderCrash,\n forgetCrash,\n hasCrashed,\n failedInBranch,\n logFailure,\n reportComponentFailure,\n resolveBeforeFallback,\n} from '../ssrCrashes';\nimport { isRenderableComponentEl } from '../componentResult';\nimport { readPropNames } from './propNames';\nimport { warnBoundProps, warnUnexpectedProps } from './propWarnings';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/**\n * Find the closest element-scoped context we attach in createLoopItem().\n * This is what exposes item(), gIdx(), count(), etc.\n */\n// Warn once per component/tag pair — the same idiom re-renders constantly\n// (e.g. a panel importing Button while using a native <button>), and\n// repeating the warning drowns out real ones.\nconst warnedComponentTags = new Set<string>();\nconst warnedChildDirectives = new WeakSet<PithyNode>();\n\n/** Test-only: forget which tags were warned about, so each render warns as a fresh process would. */\nexport function __resetComponentTagWarnings(): void {\n warnedComponentTags.clear();\n}\n\nfunction nearestCtx(\n el: Element,\n rootCtx: Record<string, unknown>\n): Record<string, unknown> {\n let n: Element | null = el;\n while (n) {\n const local = nodeExpando(n).__pithyCtx;\n if (local) return local;\n n = n.parentElement;\n }\n return rootCtx;\n}\n\n/**\n * Detect whether a node is inside a subtree that represents a NOT-YET-EXPANDED nested loop.\n * Those hosts are tagged in createLoopManager.createLoopItem() via `__pithySkipText`,\n * and real templates may also still carry @for / data-for before expansion.\n * We must *defer* binding for anything under such a host, otherwise expressions like item()\n * will throw ReferenceError (because inner loop ctx isn’t created yet).\n */\nfunction isInsidePendingLoopZone(node: Element): boolean {\n let p: Element | null = node;\n while (p) {\n if (nodeExpando(p).__pithySkipText) return true;\n if (\n p.hasAttribute &&\n (p.hasAttribute('@for') || p.hasAttribute('data-for'))\n ) {\n return true;\n }\n p = p.parentElement;\n }\n return false;\n}\n\n/** Evaluate `expr` in `ctx`. Try engine compiler first, then args-style fallback. */\nfunction evalInCtx(expr: string, ctx: Record<string, unknown>): unknown {\n // 1) Preferred: compileExpression uses `with(ctx) { return (...) }`\n try {\n const f = compileExpression(expr, ctx);\n try {\n return f();\n } catch {\n /* fall through to fallback */\n }\n } catch {\n /* fall through to fallback */\n }\n\n // 2) Fallback: args-style evaluator (robust even if compileExpression throws)\n const keys = Object.keys(ctx);\n const vals = keys.map(k => ctx[k]);\n // eslint-disable-next-line no-new-func -- args-style template expression evaluation is a core framework feature\n const fn = new Function(...keys, `return (${expr});`) as (\n ...args: unknown[]\n ) => unknown;\n return fn(...vals);\n}\n\nfunction extractExpectedPropNames(componentFn: ComponentFn): string[] {\n return readPropNames(componentFn).names;\n}\n\nconst warnedBoundSlots = new Set<string>();\n\nfunction warnBoundAttrs(\n componentFn: ComponentFn,\n el: Element,\n componentName: string\n): void {\n const bound: string[] = [];\n for (const attr of Array.from(el.attributes))\n if (attr.name.startsWith('data-bind-'))\n bound.push(attr.name.slice('data-bind-'.length));\n if (bound.includes('slot') && !warnedBoundSlots.has(componentName)) {\n warnedBoundSlots.add(componentName);\n console.warn(`[PithyJS] ${boundSlotMessage(componentName)}`);\n }\n warnBoundProps(extractExpectedPropNames(componentFn), bound, componentName);\n}\n\n/** DOM a component already rendered: its native tags may share a component's name. */\nfunction inComponentDom(el: Element): boolean {\n for (let n: Element | null = el; n; n = n.parentElement)\n if (nodeExpando(n).__pithyComponentDom) return true;\n return false;\n}\n\n/** Map lowercased DOM attr name to expected prop name (case-insensitive). */\nfunction normalizePropName(\n authoredName: string,\n expectedProps: string[]\n): string {\n if (expectedProps.includes(authoredName)) return authoredName;\n const lower = authoredName.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authoredName;\n}\n\n/**\n * Replace custom component tags (<Counter/>, <NestedComponent/>) with rendered output.\n * - Skips anything under a pending nested loop host (bind after loop expansion)\n * - Evaluates prop expressions in nearest loop ctx\n * - Case-insensitive prop name normalization\n * - No raw-string fallback (prevents things like calling count() on a string)\n */\n/** @codexApi {\"parent\":\"pithy.runtime.components\",\"name\":\"bindComponentTags\",\"stability\":\"stable\",\"signature\":\"(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindComponentTags(\n root: Element | DocumentFragment,\n rootCtx: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // case-insensitive tag lookup from context\n const tagMap = new Map<string, unknown>(\n Object.keys(rootCtx).map(k => [k.toLowerCase(), rootCtx[k]])\n );\n\n const scope =\n root instanceof Element ? (root as Element) : (root as DocumentFragment);\n const elements = Array.from(scope.querySelectorAll('*'));\n\n for (const el of elements) {\n // Skip elements removed from the tree by a parent component's render, or\n // hidden by an `@error-boundary` that has since activated.\n if (!scope.contains(el)) {\n // An element that has left the tree contributes nothing to the output, so\n // a crash recorded for it on an earlier detached pass is stale.\n forgetCrash(el);\n continue;\n }\n\n // Defer components inside not-yet-expanded loops\n if (isInsidePendingLoopZone(el)) continue;\n\n // A build's placeholder carries no AST: its children are DOM, which only\n // the AOT binder reads.\n const aotMount = nodeExpando(el).__pithyAotMount;\n if (aotMount) {\n // Marked as below, so the text pass skips what the component rendered.\n for (const node of aotMount(disposers))\n nodeExpando(node).__pithyComponentDom = true;\n continue;\n }\n\n const tag = el.tagName.toLowerCase();\n\n // Check if the parser marked this element as a component\n // This is the authoritative source - it checks originalTagName starts with uppercase\n // AND the tag name exists in importedIdentifiers\n const pithyNode = nodeExpando(el).__pithyNode;\n if (pithyNode) {\n // Parser processed this element - use its isComponent flag\n if (!pithyNode.isComponent) {\n // DEV: Warn if there's a component that matches case-insensitively\n // This helps developers catch typos like <button> when they meant <Button>\n // Skip warning if we're inside a component's render (the component might\n // legitimately use native elements like <button> in its implementation)\n const isInsideComponentRender =\n !!pithyGlobals().__pithyRenderingComponent;\n if (\n import.meta.env?.DEV &&\n !isInsideComponentRender &&\n !inComponentDom(el)\n ) {\n const matchingComponent = tagMap.get(tag);\n if (matchingComponent && typeof matchingComponent === 'function') {\n // Find the actual component name from context\n const componentName = Object.keys(rootCtx).find(\n k => k.toLowerCase() === tag && rootCtx[k] === matchingComponent\n );\n const warnKey = `${componentName}:${pithyNode.originalTagName}`;\n if (\n componentName &&\n componentName !== pithyNode.originalTagName &&\n !warnedComponentTags.has(warnKey)\n ) {\n warnedComponentTags.add(warnKey);\n console.warn(\n `[PithyJS] ⚠️ Component '${componentName}' is imported but used as '<${pithyNode.originalTagName}>'. ` +\n `Components must use PascalCase. Use '<${componentName}>' instead.`\n );\n }\n }\n }\n continue;\n }\n } else {\n // Fallback for elements not processed by our parser:\n // Skip native HTML elements to prevent <button> matching Button component\n if (nativeTags.has(tag)) continue;\n // Rendered already, e.g. a build's slot content.\n if (inComponentDom(el)) continue;\n }\n\n if (\n import.meta.env?.DEV &&\n pithyNode &&\n !warnedChildDirectives.has(pithyNode)\n ) {\n warnedChildDirectives.add(pithyNode);\n for (const name of componentChildDirectives(pithyNode))\n console.warn(\n `[pithy] ${componentChildDirectiveMessage(pithyNode.originalTagName ?? tag, name)}`\n );\n }\n\n let candidate = tagMap.get(tag);\n\n if (!candidate) continue;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') continue;\n // Content a runtime-compiled receiver projected: bound detached, inside the\n // output of the component being rendered.\n const projectedHost =\n !el.closest('[data-error]') && inProjectedContent(el)\n ? pithyGlobals().__pithyComponentContext?.__slotHost\n : undefined;\n // Hidden like a sibling an activated boundary detached: never rendered.\n if (withSlotBoundary(undefined, projectedHost, () => slotContentHidden(el)))\n continue;\n\n // It failed already, and a build never retries (BUG-161).\n if (hasCrashed(el) || failedInBranch(el)) continue;\n\n const componentFn = candidate as ComponentFn;\n resolveBeforeFallback(el);\n const localCtx = nearestCtx(el, rootCtx); // crucial for item(), gIdx(), etc.\n\n // Extract expected props for validation (DEV) and prop name normalization (always)\n // This ensures case-insensitive matching works even when originalAttrs is unavailable\n const { names, fromParam } = readPropNames(componentFn);\n const expectedProps = fromParam ? names : [];\n\n // Preserve originally-authored attribute names/casing from the parsed template\n // (pithyNode already extracted above for isComponent check)\n const originalAttrs: Record<string, string> | undefined =\n pithyNode?.originalAttrs;\n\n const props: Record<string, unknown> = {};\n\n const staleWatchers: (() => void)[] = [];\n\n // Evaluate attributes as expressions in localCtx\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name;\n const raw = attr.value;\n\n // Skip internal/behavioral attributes\n if (name.startsWith('data-')) continue;\n if (name === 'class' || name === 'style' || name === 'slot') continue;\n if (!isTemplateAttr(attr)) continue;\n\n // Prefer originally-authored name (preserve casing), else DOM name\n const authored = originalAttrs?.[name] ?? name;\n const propName = normalizePropName(authored, expectedProps);\n\n try {\n const value = untrack(() => evalInCtx(raw, localCtx));\n props[propName] = value; // only set when evaluation succeeds\n if (import.meta.env?.DEV) {\n staleWatchers.push(() =>\n watchStaleRowProp(\n localCtx,\n pithyNode ?? el,\n pithyNode?.originalTagName || tag,\n propName,\n raw,\n value,\n () => evalInCtx(raw, localCtx),\n disposers\n )\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV) {\n console.warn(propEvalMessage(propName, raw), err);\n }\n // IMPORTANT: do NOT set a raw string fallback here.\n // Leaving it undefined lets the child use defaults and avoids count()-on-string.\n }\n }\n\n // Validate props for all components in DEV mode.\n // Native elements are already filtered out earlier (line 197 for fallback, line 171 for parser).\n if (import.meta.env?.DEV) {\n const displayTag = pithyNode?.originalTagName || tag;\n warnUnexpectedProps(readPropNames(componentFn), props, displayTag);\n warnBoundAttrs(componentFn, el, displayTag);\n }\n\n // Collect content projection SlotMap from component children\n const pithyChildren: PithyNode[] = pithyNode?.children || [];\n const slotMap = collectSlotMap(pithyChildren, localCtx, el, componentFn);\n\n // Create enhanced context with SlotMap for content projection\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: pithyChildren,\n __childFactory: undefined,\n __slotHost: el,\n };\n\n // Find nearest error boundary for this component\n const boundaryEl = el.closest('[data-error]') as Element | null;\n // Projected content is bound detached, during its receiver's render.\n const boundary =\n boundaryForElement(boundaryEl) ??\n (!boundaryEl && inProjectedContent(el) ? currentBoundary() : null);\n\n // Invoke component under boundary context; expect { el, destroy }\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(\n boundary,\n () => {\n // Store the enhanced context globally for the component's html() calls to access.\n // This per-component context contains __slotMap for content projection.\n //\n // In SSR, there are TWO context sources that html() merges:\n // 1. AsyncLocalStorage context (__getComponentContext) - request-level isolation\n // 2. This global context (__pithyComponentContext) - per-component __slotMap\n //\n // Both are needed: AsyncLocalStorage provides request isolation, while this\n // global provides the __slotMap that changes for each component render.\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n g.__pithyComponentContext = componentContext;\n // Mark that we're rendering a component to suppress casing warnings for\n // native elements used in component implementations (e.g., <button> in Button)\n g.__pithyRenderingComponent = true;\n\n try {\n const result = createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n return result;\n } finally {\n // Restore original context\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n }\n },\n el\n );\n } catch (err) {\n // Route sync render errors to the nearest boundary with escalation\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // A boundary being in scope does not mean it accepted the error: an\n // already-active boundary with no free ancestor drops it (React's\n // first-error-wins). A component inside that boundary's `@fallback` is\n // the everyday case, and the fallback is what the user actually sees.\n const message = `❌ Component <${tag}> crashed during render:`;\n const accepted = reportComponentFailure(el, tag, error, boundary, {\n message,\n onCaptured: () => {\n if (import.meta.env?.DEV)\n console.log(\n `[ErrorBoundary] Captured sync render error in <${tag}>:`,\n error.message\n );\n },\n });\n if (!hasCrashed(el)) {\n if (import.meta.env?.DEV) {\n // Say which of the two actually happened. \"Captured\" on a rejected\n // error reports the opposite of the truth, and this branch exists\n // precisely because the two are not the same.\n console.log(\n accepted\n ? `[ErrorBoundary] Captured sync render error in <${tag}>:`\n : `[ErrorBoundary] No boundary took the error from <${tag}>:`,\n error.message\n );\n }\n if (!accepted) logFailure(el, () => console.error(message, error));\n }\n continue;\n }\n\n // No boundary reachable through the DOM. A branch, slot or component\n // built detached knows the one it will sit under (`deferCrash`).\n // Otherwise degrade in both modes.\n //\n // A static/server render additionally records the crash. Nobody reads a\n // console during `pithy-ssg`, so this used to leave the raw <${tag}> in\n // the emitted HTML while the route still counted as rendered and the CLI\n // exited 0 (BUG-018). Anything still recorded when the render finishes\n // makes the SSR renderer throw, and the per-route catch in `vite-ssg.ts`\n // fails that route.\n const error = err instanceof Error ? err : new Error(String(err));\n const message = `❌ Component <${tag}> crashed during render:`;\n const attributed = reportComponentFailure(el, tag, error, null, {\n message,\n onCaptured: () => {\n if (import.meta.env?.DEV)\n console.log(\n `[ErrorBoundary] Captured sync render error in <${tag}>:`,\n error.message\n );\n },\n });\n if (!attributed) logFailure(el, () => console.error(message, err));\n continue;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n const displayTag = pithyNode?.originalTagName || tag;\n logFailure(el, () => console.warn(invalidRenderMessage(displayTag)));\n // Not a throw, but the same outcome as one: the raw <${tag}> is left in\n // the document and the subtree never renders. Under SSR that is content\n // silently missing from the emitted HTML, so it is recorded exactly like\n // a crash (BUG-018). Recorded rather than merely left in place, because\n // this attempt may also be retracting an earlier attempt's record.\n // Same funnel as a throw: a boundary above this component gets the\n // chance to claim it and render its fallback, and only an unclaimed\n // failure is recorded. Bypassing this meant a component under\n // `@error-boundary` that returned garbage failed the route with the\n // boundary signal still null.\n reportComponentFailure(\n el,\n displayTag,\n invalidRenderError(displayTag),\n boundary\n );\n disposeSetup?.();\n continue;\n }\n\n const { el: renderedEl, destroy } = out;\n\n // Capture class and data-* attributes for forwarding to rendered root:\n // directive bindings (data-on-*, data-bind-*, data-class-toggle-*,\n // data-classes, data-style-*) plus any author-written data-* attribute.\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n\n const isFragment = renderedEl.nodeType === Node.DOCUMENT_FRAGMENT_NODE;\n let forwardTarget: HTMLElement | null = null;\n const hasForwardables = !!(forwardedClass || forwardedAttrs.length > 0);\n if (hasForwardables) {\n if (isFragment) {\n forwardTarget = (renderedEl as DocumentFragment)\n .firstElementChild as HTMLElement | null;\n if (import.meta.env?.DEV && !forwardTarget) {\n const displayTag = pithyNode?.originalTagName || tag;\n console.warn(\n `[PithyJS] <${displayTag}> has class or data-* attributes but returns a fragment with no element children — forwarding skipped.`\n );\n }\n } else if (renderedEl.nodeType === Node.ELEMENT_NODE) {\n forwardTarget = renderedEl as HTMLElement;\n }\n }\n\n const renderedNodes = isFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n const slotOwner = nodeExpando(el).__pithySlotOwner;\n for (const node of renderedNodes) {\n const x = nodeExpando(node);\n x.__pithyComponentDom = true;\n if (slotOwner) x.__pithySlotOwner ??= slotOwner;\n }\n\n let replaced = true;\n let hidden = false;\n try {\n // A boundary that caught a crash in this render may have hidden `el`.\n hidden = replaceHidden(el, renderedNodes);\n if (!hidden) el.replaceWith(...renderedNodes);\n } catch (err) {\n // A failed replacement leaves the raw <${tag}> exactly where a crash\n // would have, so it is the same content loss and is recorded the same way.\n replaced = false;\n const error = err instanceof Error ? err : new Error(String(err));\n reportComponentFailure(el, tag, error, boundary);\n console.error(`❌ Failed to replace <${tag}> with rendered DOM:`, err);\n }\n\n // Retracted only here, and in the boundary catch above — never eagerly at\n // the top of an attempt, where any early `continue` added later would\n // silently drop a real record. This is the point at which the component is\n // known to have produced a usable node AND to have reached the document, so\n // an earlier detached attempt's crash is genuinely no longer the outcome.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n for (const watch of staleWatchers) watch();\n\n // Forward class from component tag onto the rendered root element\n if (forwardedClass && forwardTarget) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) forwardTarget.classList.add(cls);\n }\n }\n\n // Before any binding pass below, which can throw.\n const teardown = componentDisposer(\n destroy,\n disposeSetup,\n renderedNodes[0] ?? (replaced ? null : el)\n );\n if (teardown) disposers.push(teardown);\n\n // Forward captured attributes so subsequent binders can attach the bindings\n if (forwardedAttrs.length > 0 && forwardTarget) {\n applyForwardedAttrs(forwardTarget, forwardedAttrs, tag);\n markForwardTarget(\n forwardTarget,\n localCtx,\n new Set(forwardedAttrs.map(([name]) => name))\n );\n const styleProps = Object.keys(pithyNode?.directives?.styleMap ?? {});\n if (styleProps.length)\n nodeExpando(forwardTarget).__styleProps = styleProps;\n const classToggles = Object.keys(pithyNode?.directives?.classMap ?? {});\n if (classToggles.length)\n nodeExpando(forwardTarget).__classToggles = classToggles;\n // Hidden, it is out of reach of this fragment's later passes. An active\n // nested boundary `hideContent` kept in place is still within reach.\n if (hidden && !forwardTarget.parentNode) {\n const detached = document.createDocumentFragment();\n detached.append(forwardTarget);\n bindAfterComponents(detached, localCtx, disposers);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bindComponentsTags.js","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,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Ac,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,EAAE,CAAC;YAC/C,mBAAmB,CAAC,aAAa,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;YACxD,iBAAiB,CACf,aAAa,EACb,QAAQ,EACR,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAC9C,CAAC;YACF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;YACtE,IAAI,UAAU,CAAC,MAAM;gBACnB,WAAW,CAAC,aAAa,CAAC,CAAC,YAAY,GAAG,UAAU,CAAC;YACvD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;YACxE,IAAI,YAAY,CAAC,MAAM;gBACrB,WAAW,CAAC,aAAa,CAAC,CAAC,cAAc,GAAG,YAAY,CAAC;YAC3D,wEAAwE;YACxE,qEAAqE;YACrE,IAAI,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBACxC,MAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;gBACnD,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC/B,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { compileExpression } from '../compileExpression';\nimport { isTemplateAttr } from './declaredDirective';\nimport {\n boundaryForElement,\n currentBoundary,\n replaceHidden,\n runWithBoundary,\n slotContentHidden,\n withSlotBoundary,\n} from './bindErrorBoundary';\nimport { bindAfterComponents } from './bindAfterComponents';\nimport {\n collectSlotMap,\n inProjectedContent,\n warnUndeclaredSlots,\n} from '../contentProjection';\nimport {\n boundSlotMessage,\n componentChildDirectiveMessage,\n componentChildDirectives,\n nativeTags,\n type PithyNode,\n} from '@pithyjs/compiler';\nimport { collectForwardedAttrs, applyForwardedAttrs } from './forwardedAttrs';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport { watchStaleRowProp } from './staleRowProps';\nimport { markForwardTarget, nodeExpando } from '../nodeExpando';\nimport {\n invalidRenderError,\n invalidRenderMessage,\n propEvalMessage,\n} from '../evalDiagnostics';\nimport { componentDisposer } from '../disposeOrder';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../ssrMode';\nimport {\n clearSSRRenderCrash,\n forgetCrash,\n hasCrashed,\n failedInBranch,\n logFailure,\n reportComponentFailure,\n resolveBeforeFallback,\n} from '../ssrCrashes';\nimport { isRenderableComponentEl } from '../componentResult';\nimport { readPropNames } from './propNames';\nimport { warnBoundProps, warnUnexpectedProps } from './propWarnings';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/**\n * Find the closest element-scoped context we attach in createLoopItem().\n * This is what exposes item(), gIdx(), count(), etc.\n */\n// Warn once per component/tag pair — the same idiom re-renders constantly\n// (e.g. a panel importing Button while using a native <button>), and\n// repeating the warning drowns out real ones.\nconst warnedComponentTags = new Set<string>();\nconst warnedChildDirectives = new WeakSet<PithyNode>();\n\n/** Test-only: forget which tags were warned about, so each render warns as a fresh process would. */\nexport function __resetComponentTagWarnings(): void {\n warnedComponentTags.clear();\n}\n\nfunction nearestCtx(\n el: Element,\n rootCtx: Record<string, unknown>\n): Record<string, unknown> {\n let n: Element | null = el;\n while (n) {\n const local = nodeExpando(n).__pithyCtx;\n if (local) return local;\n n = n.parentElement;\n }\n return rootCtx;\n}\n\n/**\n * Detect whether a node is inside a subtree that represents a NOT-YET-EXPANDED nested loop.\n * Those hosts are tagged in createLoopManager.createLoopItem() via `__pithySkipText`,\n * and real templates may also still carry @for / data-for before expansion.\n * We must *defer* binding for anything under such a host, otherwise expressions like item()\n * will throw ReferenceError (because inner loop ctx isn’t created yet).\n */\nfunction isInsidePendingLoopZone(node: Element): boolean {\n let p: Element | null = node;\n while (p) {\n if (nodeExpando(p).__pithySkipText) return true;\n if (\n p.hasAttribute &&\n (p.hasAttribute('@for') || p.hasAttribute('data-for'))\n ) {\n return true;\n }\n p = p.parentElement;\n }\n return false;\n}\n\n/** Evaluate `expr` in `ctx`. Try engine compiler first, then args-style fallback. */\nfunction evalInCtx(expr: string, ctx: Record<string, unknown>): unknown {\n // 1) Preferred: compileExpression uses `with(ctx) { return (...) }`\n try {\n const f = compileExpression(expr, ctx);\n try {\n return f();\n } catch {\n /* fall through to fallback */\n }\n } catch {\n /* fall through to fallback */\n }\n\n // 2) Fallback: args-style evaluator (robust even if compileExpression throws)\n const keys = Object.keys(ctx);\n const vals = keys.map(k => ctx[k]);\n // eslint-disable-next-line no-new-func -- args-style template expression evaluation is a core framework feature\n const fn = new Function(...keys, `return (${expr});`) as (\n ...args: unknown[]\n ) => unknown;\n return fn(...vals);\n}\n\nfunction extractExpectedPropNames(componentFn: ComponentFn): string[] {\n return readPropNames(componentFn).names;\n}\n\nconst warnedBoundSlots = new Set<string>();\n\nfunction warnBoundAttrs(\n componentFn: ComponentFn,\n el: Element,\n componentName: string\n): void {\n const bound: string[] = [];\n for (const attr of Array.from(el.attributes))\n if (attr.name.startsWith('data-bind-'))\n bound.push(attr.name.slice('data-bind-'.length));\n if (bound.includes('slot') && !warnedBoundSlots.has(componentName)) {\n warnedBoundSlots.add(componentName);\n console.warn(`[PithyJS] ${boundSlotMessage(componentName)}`);\n }\n warnBoundProps(extractExpectedPropNames(componentFn), bound, componentName);\n}\n\n/** DOM a component already rendered: its native tags may share a component's name. */\nfunction inComponentDom(el: Element): boolean {\n for (let n: Element | null = el; n; n = n.parentElement)\n if (nodeExpando(n).__pithyComponentDom) return true;\n return false;\n}\n\n/** Map lowercased DOM attr name to expected prop name (case-insensitive). */\nfunction normalizePropName(\n authoredName: string,\n expectedProps: string[]\n): string {\n if (expectedProps.includes(authoredName)) return authoredName;\n const lower = authoredName.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authoredName;\n}\n\n/**\n * Replace custom component tags (<Counter/>, <NestedComponent/>) with rendered output.\n * - Skips anything under a pending nested loop host (bind after loop expansion)\n * - Evaluates prop expressions in nearest loop ctx\n * - Case-insensitive prop name normalization\n * - No raw-string fallback (prevents things like calling count() on a string)\n */\n/** @codexApi {\"parent\":\"pithy.runtime.components\",\"name\":\"bindComponentTags\",\"stability\":\"stable\",\"signature\":\"(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]) => void\"} */\nexport function bindComponentTags(\n root: Element | DocumentFragment,\n rootCtx: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // case-insensitive tag lookup from context\n const tagMap = new Map<string, unknown>(\n Object.keys(rootCtx).map(k => [k.toLowerCase(), rootCtx[k]])\n );\n\n const scope =\n root instanceof Element ? (root as Element) : (root as DocumentFragment);\n const elements = Array.from(scope.querySelectorAll('*'));\n\n for (const el of elements) {\n // Skip elements removed from the tree by a parent component's render, or\n // hidden by an `@error-boundary` that has since activated.\n if (!scope.contains(el)) {\n // An element that has left the tree contributes nothing to the output, so\n // a crash recorded for it on an earlier detached pass is stale.\n forgetCrash(el);\n continue;\n }\n\n // Defer components inside not-yet-expanded loops\n if (isInsidePendingLoopZone(el)) continue;\n\n // A build's placeholder carries no AST: its children are DOM, which only\n // the AOT binder reads.\n const aotMount = nodeExpando(el).__pithyAotMount;\n if (aotMount) {\n // Marked as below, so the text pass skips what the component rendered.\n for (const node of aotMount(disposers))\n nodeExpando(node).__pithyComponentDom = true;\n continue;\n }\n\n const tag = el.tagName.toLowerCase();\n\n // Check if the parser marked this element as a component\n // This is the authoritative source - it checks originalTagName starts with uppercase\n // AND the tag name exists in importedIdentifiers\n const pithyNode = nodeExpando(el).__pithyNode;\n if (pithyNode) {\n // Parser processed this element - use its isComponent flag\n if (!pithyNode.isComponent) {\n // DEV: Warn if there's a component that matches case-insensitively\n // This helps developers catch typos like <button> when they meant <Button>\n // Skip warning if we're inside a component's render (the component might\n // legitimately use native elements like <button> in its implementation)\n const isInsideComponentRender =\n !!pithyGlobals().__pithyRenderingComponent;\n if (\n import.meta.env?.DEV &&\n !isInsideComponentRender &&\n !inComponentDom(el)\n ) {\n const matchingComponent = tagMap.get(tag);\n if (matchingComponent && typeof matchingComponent === 'function') {\n // Find the actual component name from context\n const componentName = Object.keys(rootCtx).find(\n k => k.toLowerCase() === tag && rootCtx[k] === matchingComponent\n );\n const warnKey = `${componentName}:${pithyNode.originalTagName}`;\n if (\n componentName &&\n componentName !== pithyNode.originalTagName &&\n !warnedComponentTags.has(warnKey)\n ) {\n warnedComponentTags.add(warnKey);\n console.warn(\n `[PithyJS] ⚠️ Component '${componentName}' is imported but used as '<${pithyNode.originalTagName}>'. ` +\n `Components must use PascalCase. Use '<${componentName}>' instead.`\n );\n }\n }\n }\n continue;\n }\n } else {\n // Fallback for elements not processed by our parser:\n // Skip native HTML elements to prevent <button> matching Button component\n if (nativeTags.has(tag)) continue;\n // Rendered already, e.g. a build's slot content.\n if (inComponentDom(el)) continue;\n }\n\n if (\n import.meta.env?.DEV &&\n pithyNode &&\n !warnedChildDirectives.has(pithyNode)\n ) {\n warnedChildDirectives.add(pithyNode);\n for (const name of componentChildDirectives(pithyNode))\n console.warn(\n `[pithy] ${componentChildDirectiveMessage(pithyNode.originalTagName ?? tag, name)}`\n );\n }\n\n let candidate = tagMap.get(tag);\n\n if (!candidate) continue;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') continue;\n // Content a runtime-compiled receiver projected: bound detached, inside the\n // output of the component being rendered.\n const projectedHost =\n !el.closest('[data-error]') && inProjectedContent(el)\n ? pithyGlobals().__pithyComponentContext?.__slotHost\n : undefined;\n // Hidden like a sibling an activated boundary detached: never rendered.\n if (withSlotBoundary(undefined, projectedHost, () => slotContentHidden(el)))\n continue;\n\n // It failed already, and a build never retries (BUG-161).\n if (hasCrashed(el) || failedInBranch(el)) continue;\n\n const componentFn = candidate as ComponentFn;\n resolveBeforeFallback(el);\n const localCtx = nearestCtx(el, rootCtx); // crucial for item(), gIdx(), etc.\n\n // Extract expected props for validation (DEV) and prop name normalization (always)\n // This ensures case-insensitive matching works even when originalAttrs is unavailable\n const { names, fromParam } = readPropNames(componentFn);\n const expectedProps = fromParam ? names : [];\n\n // Preserve originally-authored attribute names/casing from the parsed template\n // (pithyNode already extracted above for isComponent check)\n const originalAttrs: Record<string, string> | undefined =\n pithyNode?.originalAttrs;\n\n const props: Record<string, unknown> = {};\n\n const staleWatchers: (() => void)[] = [];\n\n // Evaluate attributes as expressions in localCtx\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name;\n const raw = attr.value;\n\n // Skip internal/behavioral attributes\n if (name.startsWith('data-')) continue;\n if (name === 'class' || name === 'style' || name === 'slot') continue;\n if (!isTemplateAttr(attr)) continue;\n\n // Prefer originally-authored name (preserve casing), else DOM name\n const authored = originalAttrs?.[name] ?? name;\n const propName = normalizePropName(authored, expectedProps);\n\n try {\n const value = untrack(() => evalInCtx(raw, localCtx));\n props[propName] = value; // only set when evaluation succeeds\n if (import.meta.env?.DEV) {\n staleWatchers.push(() =>\n watchStaleRowProp(\n localCtx,\n pithyNode ?? el,\n pithyNode?.originalTagName || tag,\n propName,\n raw,\n value,\n () => evalInCtx(raw, localCtx),\n disposers\n )\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV) {\n console.warn(propEvalMessage(propName, raw), err);\n }\n // IMPORTANT: do NOT set a raw string fallback here.\n // Leaving it undefined lets the child use defaults and avoids count()-on-string.\n }\n }\n\n // Validate props for all components in DEV mode.\n // Native elements are already filtered out earlier (line 197 for fallback, line 171 for parser).\n if (import.meta.env?.DEV) {\n const displayTag = pithyNode?.originalTagName || tag;\n warnUnexpectedProps(readPropNames(componentFn), props, displayTag);\n warnBoundAttrs(componentFn, el, displayTag);\n }\n\n // Collect content projection SlotMap from component children\n const pithyChildren: PithyNode[] = pithyNode?.children || [];\n const slotMap = collectSlotMap(pithyChildren, localCtx, el, componentFn);\n\n // Create enhanced context with SlotMap for content projection\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: pithyChildren,\n __childFactory: undefined,\n __slotHost: el,\n };\n\n // Find nearest error boundary for this component\n const boundaryEl = el.closest('[data-error]') as Element | null;\n // Projected content is bound detached, during its receiver's render.\n const boundary =\n boundaryForElement(boundaryEl) ??\n (!boundaryEl && inProjectedContent(el) ? currentBoundary() : null);\n\n // Invoke component under boundary context; expect { el, destroy }\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(\n boundary,\n () => {\n // Store the enhanced context globally for the component's html() calls to access.\n // This per-component context contains __slotMap for content projection.\n //\n // In SSR, there are TWO context sources that html() merges:\n // 1. AsyncLocalStorage context (__getComponentContext) - request-level isolation\n // 2. This global context (__pithyComponentContext) - per-component __slotMap\n //\n // Both are needed: AsyncLocalStorage provides request isolation, while this\n // global provides the __slotMap that changes for each component render.\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n g.__pithyComponentContext = componentContext;\n // Mark that we're rendering a component to suppress casing warnings for\n // native elements used in component implementations (e.g., <button> in Button)\n g.__pithyRenderingComponent = true;\n\n try {\n const result = createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n return result;\n } finally {\n // Restore original context\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n }\n },\n el\n );\n } catch (err) {\n // Route sync render errors to the nearest boundary with escalation\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // A boundary being in scope does not mean it accepted the error: an\n // already-active boundary with no free ancestor drops it (React's\n // first-error-wins). A component inside that boundary's `@fallback` is\n // the everyday case, and the fallback is what the user actually sees.\n const message = `❌ Component <${tag}> crashed during render:`;\n const accepted = reportComponentFailure(el, tag, error, boundary, {\n message,\n onCaptured: () => {\n if (import.meta.env?.DEV)\n console.log(\n `[ErrorBoundary] Captured sync render error in <${tag}>:`,\n error.message\n );\n },\n });\n if (!hasCrashed(el)) {\n if (import.meta.env?.DEV) {\n // Say which of the two actually happened. \"Captured\" on a rejected\n // error reports the opposite of the truth, and this branch exists\n // precisely because the two are not the same.\n console.log(\n accepted\n ? `[ErrorBoundary] Captured sync render error in <${tag}>:`\n : `[ErrorBoundary] No boundary took the error from <${tag}>:`,\n error.message\n );\n }\n if (!accepted) logFailure(el, () => console.error(message, error));\n }\n continue;\n }\n\n // No boundary reachable through the DOM. A branch, slot or component\n // built detached knows the one it will sit under (`deferCrash`).\n // Otherwise degrade in both modes.\n //\n // A static/server render additionally records the crash. Nobody reads a\n // console during `pithy-ssg`, so this used to leave the raw <${tag}> in\n // the emitted HTML while the route still counted as rendered and the CLI\n // exited 0 (BUG-018). Anything still recorded when the render finishes\n // makes the SSR renderer throw, and the per-route catch in `vite-ssg.ts`\n // fails that route.\n const error = err instanceof Error ? err : new Error(String(err));\n const message = `❌ Component <${tag}> crashed during render:`;\n const attributed = reportComponentFailure(el, tag, error, null, {\n message,\n onCaptured: () => {\n if (import.meta.env?.DEV)\n console.log(\n `[ErrorBoundary] Captured sync render error in <${tag}>:`,\n error.message\n );\n },\n });\n if (!attributed) logFailure(el, () => console.error(message, err));\n continue;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n const displayTag = pithyNode?.originalTagName || tag;\n logFailure(el, () => console.warn(invalidRenderMessage(displayTag)));\n // Not a throw, but the same outcome as one: the raw <${tag}> is left in\n // the document and the subtree never renders. Under SSR that is content\n // silently missing from the emitted HTML, so it is recorded exactly like\n // a crash (BUG-018). Recorded rather than merely left in place, because\n // this attempt may also be retracting an earlier attempt's record.\n // Same funnel as a throw: a boundary above this component gets the\n // chance to claim it and render its fallback, and only an unclaimed\n // failure is recorded. Bypassing this meant a component under\n // `@error-boundary` that returned garbage failed the route with the\n // boundary signal still null.\n reportComponentFailure(\n el,\n displayTag,\n invalidRenderError(displayTag),\n boundary\n );\n disposeSetup?.();\n continue;\n }\n\n const { el: renderedEl, destroy } = out;\n if (import.meta.env?.DEV) warnUndeclaredSlots(slotMap);\n\n // Capture class and data-* attributes for forwarding to rendered root:\n // directive bindings (data-on-*, data-bind-*, data-class-toggle-*,\n // data-classes, data-style-*) plus any author-written data-* attribute.\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n\n const isFragment = renderedEl.nodeType === Node.DOCUMENT_FRAGMENT_NODE;\n let forwardTarget: HTMLElement | null = null;\n const hasForwardables = !!(forwardedClass || forwardedAttrs.length > 0);\n if (hasForwardables) {\n if (isFragment) {\n forwardTarget = (renderedEl as DocumentFragment)\n .firstElementChild as HTMLElement | null;\n if (import.meta.env?.DEV && !forwardTarget) {\n const displayTag = pithyNode?.originalTagName || tag;\n console.warn(\n `[PithyJS] <${displayTag}> has class or data-* attributes but returns a fragment with no element children — forwarding skipped.`\n );\n }\n } else if (renderedEl.nodeType === Node.ELEMENT_NODE) {\n forwardTarget = renderedEl as HTMLElement;\n }\n }\n\n const renderedNodes = isFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n const slotOwner = nodeExpando(el).__pithySlotOwner;\n for (const node of renderedNodes) {\n const x = nodeExpando(node);\n x.__pithyComponentDom = true;\n if (slotOwner) x.__pithySlotOwner ??= slotOwner;\n }\n\n let replaced = true;\n let hidden = false;\n try {\n // A boundary that caught a crash in this render may have hidden `el`.\n hidden = replaceHidden(el, renderedNodes);\n if (!hidden) el.replaceWith(...renderedNodes);\n } catch (err) {\n // A failed replacement leaves the raw <${tag}> exactly where a crash\n // would have, so it is the same content loss and is recorded the same way.\n replaced = false;\n const error = err instanceof Error ? err : new Error(String(err));\n reportComponentFailure(el, tag, error, boundary);\n console.error(`❌ Failed to replace <${tag}> with rendered DOM:`, err);\n }\n\n // Retracted only here, and in the boundary catch above — never eagerly at\n // the top of an attempt, where any early `continue` added later would\n // silently drop a real record. This is the point at which the component is\n // known to have produced a usable node AND to have reached the document, so\n // an earlier detached attempt's crash is genuinely no longer the outcome.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n for (const watch of staleWatchers) watch();\n\n // Forward class from component tag onto the rendered root element\n if (forwardedClass && forwardTarget) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) forwardTarget.classList.add(cls);\n }\n }\n\n // Before any binding pass below, which can throw.\n const teardown = componentDisposer(\n destroy,\n disposeSetup,\n renderedNodes[0] ?? (replaced ? null : el)\n );\n if (teardown) disposers.push(teardown);\n\n // Forward captured attributes so subsequent binders can attach the bindings\n if (forwardedAttrs.length > 0 && forwardTarget) {\n applyForwardedAttrs(forwardTarget, forwardedAttrs, tag);\n markForwardTarget(\n forwardTarget,\n localCtx,\n new Set(forwardedAttrs.map(([name]) => name))\n );\n const styleProps = Object.keys(pithyNode?.directives?.styleMap ?? {});\n if (styleProps.length)\n nodeExpando(forwardTarget).__styleProps = styleProps;\n const classToggles = Object.keys(pithyNode?.directives?.classMap ?? {});\n if (classToggles.length)\n nodeExpando(forwardTarget).__classToggles = classToggles;\n // Hidden, it is out of reach of this fragment's later passes. An active\n // nested boundary `hideContent` kept in place is still within reach.\n if (hidden && !forwardTarget.parentNode) {\n const detached = document.createDocumentFragment();\n detached.append(forwardTarget);\n bindAfterComponents(detached, localCtx, disposers);\n }\n }\n }\n}\n"]}
|
|
@@ -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;AAqBF;;;;;;;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,CAmD7D;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"}
|
|
@@ -13,7 +13,8 @@ import { bindRefDirectives } from './binds/bindRefDirectives.js';
|
|
|
13
13
|
import { bindErrorBoundary } from './binds/bindErrorBoundary.js';
|
|
14
14
|
import { bindForLoops } from './forLoops/bindForLoops.js';
|
|
15
15
|
import { bindSwitchCases } from './bindSwitchCases.js';
|
|
16
|
-
import {
|
|
16
|
+
import { collectSlotNames } from '@pithyjs/compiler';
|
|
17
|
+
import { declareSlotNames, extractSlotDefs, mountProjection, slotMapOf, } from './contentProjection.js';
|
|
17
18
|
import { bindAfterProjection } from './binds/bindAfterProjection.js';
|
|
18
19
|
import { orderByDocument } from './disposeOrder.js';
|
|
19
20
|
/**
|
|
@@ -61,6 +62,9 @@ export function compileTemplate(html, context, css, scopeId, importedIdentifiers
|
|
|
61
62
|
// Parse into fragment + AST
|
|
62
63
|
const parsed = parseHtml(html, id, context, importedIdentifiers);
|
|
63
64
|
fragment = parsed.fragment;
|
|
65
|
+
const slotMap = import.meta.env?.DEV ? slotMapOf(context) : undefined;
|
|
66
|
+
if (slotMap)
|
|
67
|
+
declareSlotNames(slotMap, collectSlotNames(parsed.pithyNodes));
|
|
64
68
|
const built = fragment;
|
|
65
69
|
withinRender(() => {
|
|
66
70
|
// Structural transforms first (they change the DOM shape and add anchors)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileTemplate.js","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,eAAe,EACf,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE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AAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAE1D,CAAC;IACd,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,eAAe,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,8EAA8E;IAC9E,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.renderer\",\n \"title\": \"Template Compiler & Renderer\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { parseHtml } from './parseHtml';\nimport { withinRender } from './ssrCrashes';\nimport { injectScopedStyle } from './injectScopedStyle';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { bindRefDirectives } from './binds/bindRefDirectives';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { bindSwitchCases } from './bindSwitchCases';\nimport {\n extractSlotDefs,\n mountProjection,\n type SlotMap,\n} from './contentProjection';\nimport { bindAfterProjection } from './binds/bindAfterProjection';\nimport { orderByDocument } from './disposeOrder';\n\n/**\n * Runs all structural directive bindings on a fragment.\n *\n * Ordering:\n * 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM\n * 2) Conditionals (@if/@else) — each branch binds its own nested switches\n * 3) For loops — skips nodes already processed by switches and conditionals\n */\nexport function bindStructuralDirectives(\n nodes: import('@pithyjs/compiler').PithyNode[],\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n const processed = bindSwitchCases(\n nodes,\n fragment,\n context,\n new Set(),\n disposers\n );\n bindConditionals(nodes, fragment, context, processed, disposers);\n bindForLoops(nodes, fragment, context, disposers, processed);\n}\n\n/**\n * Compiles a raw HTML template into live DOM nodes with signal bindings,\n * event handlers, and optional styles.\n *\n * Pipeline overview:\n * 1) parseHtml → returns a DocumentFragment + AST nodes (pithyNodes)\n * 2) structural directives first: @if/@else, @switch, @for (they shape the DOM)\n * 3) inject CSS (scoped)\n * 4) run remaining binders in an order that avoids double-binding and cross-contamination:\n * - refs (so later passes can access refs if needed)\n * - components (instantiate/replace custom tags BEFORE binding into their subtree)\n * - two-way (default model bindings for inputs)\n * - text interpolations\n * - events\n * - classes\n * - bound attributes\n *\n * @param html - Raw HTML template string\n * @param context - Reactive context object (signals, methods, components)\n * @param css - Optional CSS string to scope and inject\n * @param scopeId - Optional scope id for CSS scoping\n * @param importedIdentifiers - Optional set of ids exposed to expressions\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"compileTemplate\",\"stability\":\"stable\",\"signature\":\"(html: string, context: Record<string, any>, css?: string, scopeId?: string, importedIdentifiers?: Set<string>) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function compileTemplate(\n html: string,\n context: Record<string, unknown>,\n css?: string,\n scopeId?: string,\n importedIdentifiers?: Set<string>\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n const id = scopeId ?? `pithy-${Math.random().toString(36).slice(2, 8)}`;\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // Parse into fragment + AST\n const parsed = parseHtml(html, id, context, importedIdentifiers);\n fragment = parsed.fragment;\n\n const built = fragment;\n withinRender(() => {\n // Structural transforms first (they change the DOM shape and add anchors)\n bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);\n\n // Scoped CSS after structure is stable\n if (css) {\n injectScopedStyle(css, id);\n }\n\n // Remaining directives/bindings in carefully chosen order\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers 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 throw err;\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 },\n };\n}\n\n/**\n * Applies all non-structural bindings to the compiled fragment.\n *\n * Ordering rationale:\n * - refs: collected early, sometimes needed by subsequent binders\n * - error boundaries: register boundaries before components render (enables error capture)\n * - projection: mount projected content into slot anchors BEFORE component binding,\n * so nested component tags in projected content get processed\n * - components: instantiate/replace custom tags (including those in projected content);\n * prevents parent binders from walking into raw component tags\n * - two-way: attach default v-model-ish behavior on real inputs (not inside components)\n * - text: {{ ... }} bindings (skips nested loops / component subtrees via flags)\n * - events: add listeners (idempotent; supports modifiers; nearest ctx; $event/$el)\n * - classes: dynamic class toggles\n * - attributes: remaining [attr]=\"...\" bindings\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"bindTemplateDirectives\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, context: Record<string, any>, disposers: (() => void)[]) => void\"} */\nexport function bindTemplateDirectives(\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // 1) refs first — enables grabbing component roots/elements if needed\n bindRefDirectives(fragment, context, disposers);\n\n // 2) error boundaries — register before components so they can catch component errors\n bindErrorBoundary(fragment, context, disposers);\n\n // 3) content projection — mount projected content into slot anchors BEFORE components.\n // Projected content may contain component tags (e.g., nested <Show> inside <Show>).\n // If components ran first, those nested component tags would never be processed.\n // Without a SlotMap (a component called directly) slots still get their fallback.\n // Use 'in' operator to check via Proxy's has() trap without triggering the get() warning\n const slotMap = ('__slotMap' in context ? context.__slotMap : undefined) as\n | SlotMap\n | undefined;\n const slotDefs = extractSlotDefs(fragment);\n if (slotDefs.length > 0) {\n mountProjection(slotDefs, slotMap ?? new Map(), disposers);\n }\n\n // 4-11) components, two-way, text, events, classes, attributes, custom, defer\n bindAfterProjection(fragment, context, disposers);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compileTemplate.js","sourceRoot":"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,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.renderer\",\n \"title\": \"Template Compiler & Renderer\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { parseHtml } from './parseHtml';\nimport { withinRender } from './ssrCrashes';\nimport { injectScopedStyle } from './injectScopedStyle';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { bindRefDirectives } from './binds/bindRefDirectives';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { bindSwitchCases } from './bindSwitchCases';\nimport { collectSlotNames } from '@pithyjs/compiler';\nimport {\n declareSlotNames,\n extractSlotDefs,\n mountProjection,\n slotMapOf,\n type SlotMap,\n} from './contentProjection';\nimport { bindAfterProjection } from './binds/bindAfterProjection';\nimport { orderByDocument } from './disposeOrder';\n\n/**\n * Runs all structural directive bindings on a fragment.\n *\n * Ordering:\n * 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM\n * 2) Conditionals (@if/@else) — each branch binds its own nested switches\n * 3) For loops — skips nodes already processed by switches and conditionals\n */\nexport function bindStructuralDirectives(\n nodes: import('@pithyjs/compiler').PithyNode[],\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n const processed = bindSwitchCases(\n nodes,\n fragment,\n context,\n new Set(),\n disposers\n );\n bindConditionals(nodes, fragment, context, processed, disposers);\n bindForLoops(nodes, fragment, context, disposers, processed);\n}\n\n/**\n * Compiles a raw HTML template into live DOM nodes with signal bindings,\n * event handlers, and optional styles.\n *\n * Pipeline overview:\n * 1) parseHtml → returns a DocumentFragment + AST nodes (pithyNodes)\n * 2) structural directives first: @if/@else, @switch, @for (they shape the DOM)\n * 3) inject CSS (scoped)\n * 4) run remaining binders in an order that avoids double-binding and cross-contamination:\n * - refs (so later passes can access refs if needed)\n * - components (instantiate/replace custom tags BEFORE binding into their subtree)\n * - two-way (default model bindings for inputs)\n * - text interpolations\n * - events\n * - classes\n * - bound attributes\n *\n * @param html - Raw HTML template string\n * @param context - Reactive context object (signals, methods, components)\n * @param css - Optional CSS string to scope and inject\n * @param scopeId - Optional scope id for CSS scoping\n * @param importedIdentifiers - Optional set of ids exposed to expressions\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"compileTemplate\",\"stability\":\"stable\",\"signature\":\"(html: string, context: Record<string, any>, css?: string, scopeId?: string, importedIdentifiers?: Set<string>) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function compileTemplate(\n html: string,\n context: Record<string, unknown>,\n css?: string,\n scopeId?: string,\n importedIdentifiers?: Set<string>\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n const id = scopeId ?? `pithy-${Math.random().toString(36).slice(2, 8)}`;\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // Parse into fragment + AST\n const parsed = parseHtml(html, id, context, importedIdentifiers);\n fragment = parsed.fragment;\n const slotMap = import.meta.env?.DEV ? slotMapOf(context) : undefined;\n if (slotMap) declareSlotNames(slotMap, collectSlotNames(parsed.pithyNodes));\n\n const built = fragment;\n withinRender(() => {\n // Structural transforms first (they change the DOM shape and add anchors)\n bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);\n\n // Scoped CSS after structure is stable\n if (css) {\n injectScopedStyle(css, id);\n }\n\n // Remaining directives/bindings in carefully chosen order\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers 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 throw err;\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 },\n };\n}\n\n/**\n * Applies all non-structural bindings to the compiled fragment.\n *\n * Ordering rationale:\n * - refs: collected early, sometimes needed by subsequent binders\n * - error boundaries: register boundaries before components render (enables error capture)\n * - projection: mount projected content into slot anchors BEFORE component binding,\n * so nested component tags in projected content get processed\n * - components: instantiate/replace custom tags (including those in projected content);\n * prevents parent binders from walking into raw component tags\n * - two-way: attach default v-model-ish behavior on real inputs (not inside components)\n * - text: {{ ... }} bindings (skips nested loops / component subtrees via flags)\n * - events: add listeners (idempotent; supports modifiers; nearest ctx; $event/$el)\n * - classes: dynamic class toggles\n * - attributes: remaining [attr]=\"...\" bindings\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"bindTemplateDirectives\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, context: Record<string, any>, disposers: (() => void)[]) => void\"} */\nexport function bindTemplateDirectives(\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // 1) refs first — enables grabbing component roots/elements if needed\n bindRefDirectives(fragment, context, disposers);\n\n // 2) error boundaries — register before components so they can catch component errors\n bindErrorBoundary(fragment, context, disposers);\n\n // 3) content projection — mount projected content into slot anchors BEFORE components.\n // Projected content may contain component tags (e.g., nested <Show> inside <Show>).\n // If components ran first, those nested component tags would never be processed.\n // Without a SlotMap (a component called directly) slots still get their fallback.\n // Use 'in' operator to check via Proxy's has() trap without triggering the get() warning\n const slotMap = ('__slotMap' in context ? context.__slotMap : undefined) as\n | SlotMap\n | undefined;\n const slotDefs = extractSlotDefs(fragment);\n if (slotDefs.length > 0) {\n mountProjection(slotDefs, slotMap ?? new Map(), disposers);\n }\n\n // 4-11) components, two-way, text, events, classes, attributes, custom, defer\n bindAfterProjection(fragment, context, disposers);\n}\n"]}
|
|
@@ -32,6 +32,45 @@ export declare function warnDuplicateSlot(slotMap: SlotMap | undefined, name: st
|
|
|
32
32
|
/** Test hook: lets each test see its first duplicate-slot warning. */
|
|
33
33
|
/** @codexApi {"parent":"pithy.feature.content-projection","name":"resetDuplicateSlotWarnings","stability":"internal","signature":"() => void"} */
|
|
34
34
|
export declare function resetDuplicateSlotWarnings(): void;
|
|
35
|
+
/**
|
|
36
|
+
* DEV: records `names` as slots the component that `slotMap` fills renders,
|
|
37
|
+
* and that its template or children were looked at, which is what lets
|
|
38
|
+
* `warnUndeclaredSlots` check the rest.
|
|
39
|
+
*/
|
|
40
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlotNames","stability":"internal","signature":"(slotMap: SlotMap | undefined, names: Iterable<string>) => void"} */
|
|
41
|
+
export declare function declareSlotNames(slotMap: SlotMap | undefined, names: Iterable<string>): void;
|
|
42
|
+
/**
|
|
43
|
+
* DEV: a template rendered for `slotMap` without its `<slot>` list, as an
|
|
44
|
+
* older plugin's build or a precompiled library does. `warnUndeclaredSlots`
|
|
45
|
+
* then stays silent for the map, whatever else declared names for it.
|
|
46
|
+
*/
|
|
47
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"markSlotsUnknown","stability":"internal","signature":"(slotMap: SlotMap | undefined) => void"} */
|
|
48
|
+
export declare function markSlotsUnknown(slotMap: SlotMap | undefined): void;
|
|
49
|
+
/**
|
|
50
|
+
* Declares slot names a component reads from its children by hand, such as
|
|
51
|
+
* `slot="fallback"`, so DEV does not report content addressed to them as
|
|
52
|
+
* having nowhere to go, and marks its children as read, so DEV reports the
|
|
53
|
+
* rest. With no names, it only marks them read. Call it during render, before
|
|
54
|
+
* `captureChildren()`, which clears the context it reads. A no-op outside DEV
|
|
55
|
+
* or a render.
|
|
56
|
+
*
|
|
57
|
+
* @param names - The `slot="…"` values the component handles itself
|
|
58
|
+
*/
|
|
59
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlots","stability":"experimental","signature":"(...names: string[]) => void"} */
|
|
60
|
+
export declare function declareSlots(...names: string[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* DEV: warns once per component and slot name for content in `slotMap`
|
|
63
|
+
* addressed to a named slot its component never declared. Silent for a
|
|
64
|
+
* component whose template and children were never looked at, or whose
|
|
65
|
+
* template rendered without its `<slot>` list.
|
|
66
|
+
*/
|
|
67
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"warnUndeclaredSlots","stability":"internal","signature":"(slotMap: SlotMap) => void"} */
|
|
68
|
+
export declare function warnUndeclaredSlots(slotMap: SlotMap): void;
|
|
69
|
+
/** Test hook: lets each test see its first undeclared-slot warning. */
|
|
70
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"resetUndeclaredSlotWarnings","stability":"internal","signature":"() => void"} */
|
|
71
|
+
export declare function resetUndeclaredSlotWarnings(): void;
|
|
72
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"slotMapOf","stability":"internal","signature":"(ctx: Record<string, unknown>) => SlotMap | undefined"} */
|
|
73
|
+
export declare function slotMapOf(ctx: Record<string, unknown>): SlotMap | undefined;
|
|
35
74
|
/**
|
|
36
75
|
* The slot map of the template the children behind `slotMap` were written in:
|
|
37
76
|
* what a `<slot>` among those children receives.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,SAAS,EAKV,MAAM,mBAAmB,CAAC;AAc3B;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CACvB,MAAM,EACN,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,gBAAgB,CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAA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,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,IAAI,CAGN;AAED,gOAAgO;AAChO,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,IAAI,CAAC,EAAE,OAAO,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CA6FT;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA+BrE;AAED,6DAA6D;AAC7D,uJAAuJ;AACvJ,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAItD;AAQD,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAGN"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"category": "feature"
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
|
-
import { duplicateSlotMessage, sharedSlotMessage, sharedSlots, } from '@pithyjs/compiler';
|
|
8
|
+
import { duplicateSlotMessage, sharedSlotMessage, sharedSlots, undeclaredSlotMessage, } from '@pithyjs/compiler';
|
|
9
9
|
import { pithyTreeToDom } from './pithyTreeToDom.js';
|
|
10
10
|
import { bindStructuralDirectives } from './compileTemplate.js';
|
|
11
11
|
import { nodeExpando } from './nodeExpando.js';
|
|
@@ -48,7 +48,81 @@ export function warnDuplicateSlot(slotMap, name, instance) {
|
|
|
48
48
|
export function resetDuplicateSlotWarnings() {
|
|
49
49
|
warnedDuplicates = new WeakMap();
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
const declaredSlots = new WeakMap();
|
|
52
|
+
const seenSlotMaps = new WeakSet();
|
|
53
|
+
const unknownSlotMaps = new WeakSet();
|
|
54
|
+
let warnedUndeclared = new WeakMap();
|
|
55
|
+
/**
|
|
56
|
+
* DEV: records `names` as slots the component that `slotMap` fills renders,
|
|
57
|
+
* and that its template or children were looked at, which is what lets
|
|
58
|
+
* `warnUndeclaredSlots` check the rest.
|
|
59
|
+
*/
|
|
60
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlotNames","stability":"internal","signature":"(slotMap: SlotMap | undefined, names: Iterable<string>) => void"} */
|
|
61
|
+
export function declareSlotNames(slotMap, names) {
|
|
62
|
+
if (!slotMap)
|
|
63
|
+
return;
|
|
64
|
+
let declared = declaredSlots.get(slotMap);
|
|
65
|
+
if (!declared)
|
|
66
|
+
declaredSlots.set(slotMap, (declared = new Set()));
|
|
67
|
+
for (const name of names)
|
|
68
|
+
declared.add(name);
|
|
69
|
+
seenSlotMaps.add(slotMap);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* DEV: a template rendered for `slotMap` without its `<slot>` list, as an
|
|
73
|
+
* older plugin's build or a precompiled library does. `warnUndeclaredSlots`
|
|
74
|
+
* then stays silent for the map, whatever else declared names for it.
|
|
75
|
+
*/
|
|
76
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"markSlotsUnknown","stability":"internal","signature":"(slotMap: SlotMap | undefined) => void"} */
|
|
77
|
+
export function markSlotsUnknown(slotMap) {
|
|
78
|
+
if (slotMap)
|
|
79
|
+
unknownSlotMaps.add(slotMap);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Declares slot names a component reads from its children by hand, such as
|
|
83
|
+
* `slot="fallback"`, so DEV does not report content addressed to them as
|
|
84
|
+
* having nowhere to go, and marks its children as read, so DEV reports the
|
|
85
|
+
* rest. With no names, it only marks them read. Call it during render, before
|
|
86
|
+
* `captureChildren()`, which clears the context it reads. A no-op outside DEV
|
|
87
|
+
* or a render.
|
|
88
|
+
*
|
|
89
|
+
* @param names - The `slot="…"` values the component handles itself
|
|
90
|
+
*/
|
|
91
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"declareSlots","stability":"experimental","signature":"(...names: string[]) => void"} */
|
|
92
|
+
export function declareSlots(...names) {
|
|
93
|
+
if (import.meta.env?.DEV)
|
|
94
|
+
declareSlotNames(pithyGlobals().__pithyComponentContext?.__slotMap, names);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* DEV: warns once per component and slot name for content in `slotMap`
|
|
98
|
+
* addressed to a named slot its component never declared. Silent for a
|
|
99
|
+
* component whose template and children were never looked at, or whose
|
|
100
|
+
* template rendered without its `<slot>` list.
|
|
101
|
+
*/
|
|
102
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"warnUndeclaredSlots","stability":"internal","signature":"(slotMap: SlotMap) => void"} */
|
|
103
|
+
export function warnUndeclaredSlots(slotMap) {
|
|
104
|
+
if (!seenSlotMaps.has(slotMap) || unknownSlotMaps.has(slotMap))
|
|
105
|
+
return;
|
|
106
|
+
const declared = declaredSlots.get(slotMap);
|
|
107
|
+
const tag = slotMapTags.get(slotMap) ?? 'component';
|
|
108
|
+
const key = slotMapOwners.get(slotMap) ?? slotMap;
|
|
109
|
+
let warned = warnedUndeclared.get(key);
|
|
110
|
+
if (!warned)
|
|
111
|
+
warnedUndeclared.set(key, (warned = new Set()));
|
|
112
|
+
for (const name of slotMap.keys()) {
|
|
113
|
+
if (name === '' || declared?.has(name) || warned.has(name))
|
|
114
|
+
continue;
|
|
115
|
+
warned.add(name);
|
|
116
|
+
console.warn(`[PithyJS] ${undeclaredSlotMessage(tag, name)}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Test hook: lets each test see its first undeclared-slot warning. */
|
|
120
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"resetUndeclaredSlotWarnings","stability":"internal","signature":"() => void"} */
|
|
121
|
+
export function resetUndeclaredSlotWarnings() {
|
|
122
|
+
warnedUndeclared = new WeakMap();
|
|
123
|
+
}
|
|
124
|
+
/** @codexApi {"parent":"pithy.feature.content-projection","name":"slotMapOf","stability":"internal","signature":"(ctx: Record<string, unknown>) => SlotMap | undefined"} */
|
|
125
|
+
export function slotMapOf(ctx) {
|
|
52
126
|
return ('__slotMap' in ctx ? ctx.__slotMap : undefined);
|
|
53
127
|
}
|
|
54
128
|
/**
|
|
@@ -319,5 +393,6 @@ function mountSlots(slotDefs, slotMap, disposers) {
|
|
|
319
393
|
// projected "fallback" content is legitimate — it will be mounted when
|
|
320
394
|
// the @else branch activates. Warnings here would be false positives
|
|
321
395
|
// and fire repeatedly on every reactive toggle.
|
|
396
|
+
// warnUndeclaredSlots checks against the whole template after the component returns.
|
|
322
397
|
}
|
|
323
398
|
//# sourceMappingURL=contentProjection.js.map
|