@yak/solid 0.1.0 → 0.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","names":["useTheme","mergeClasses"],"sources":["../runtime/cssLiteral.ts","../runtime/internals/mergeClasses.ts","../runtime/styled.ts","../runtime/atoms.ts","../runtime/keyframes.ts","../runtime/globalStyle.ts","../runtime/internals/unitPostFix.ts","../runtime/internals/mergeCssProp.ts","../runtime/styledDom.ts"],"sourcesContent":["import type { YakTheme } from \"./index.ts\";\nimport type { Accessor } from \"solid-js\";\nimport { ClassCollector, RuntimeStyleProcessor, StyleObject } from \"./publicStyledApi.js\";\n\nexport const yakComponentSymbol = Symbol(\"yak\");\n\n/**\n * Collects class names as a single space-separated string.\n *\n * `add` is the render hot path and stays a plain string append;\n * `has`/`delete` keep a Set-like contract for the rare runtime\n * functions that remove classes again (e.g. atoms).\n */\nexport class Classes implements ClassCollector {\n value: string;\n constructor(initial?: string) {\n this.value = initial || \"\";\n }\n add(name: string) {\n if (!this.value) {\n this.value = name;\n } else if (!this.has(name)) {\n this.value += \" \" + name;\n }\n }\n has(name: string) {\n return (\" \" + this.value + \" \").includes(\" \" + name + \" \");\n }\n delete(name: string) {\n if (this.has(name)) {\n this.value = this.value\n .split(\" \")\n .filter((existing) => existing !== name)\n .join(\" \");\n }\n }\n}\n\nexport type ComponentStyles<TProps> = (props: TProps) => {\n class: string;\n style?: {\n [key: string]: string;\n };\n};\n\nexport type CSSInterpolation<TProps> =\n | string\n | number\n | undefined\n | null\n | false\n | ComponentStyles<TProps>\n | {\n // type only identifier to allow targeting components\n // e.g. styled.svg`${Button}:hover & { fill: red; }`\n [yakComponentSymbol]: any;\n }\n | ((props: TProps) => CSSInterpolation<TProps>);\n\ntype CSSStyles<TProps = {}> = {\n style: { [key: string]: string | ((props: TProps) => string) };\n};\n\ntype CSSFunction = <TProps = {}>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<TProps & { theme: Accessor<YakTheme> }>[]\n) => ComponentStyles<TProps>;\n\nexport type NestedRuntimeStyleProcessor = (\n props: unknown,\n classes: ClassCollector,\n style: StyleObject,\n) =>\n | {\n class?: string;\n style?: StyleObject;\n }\n | void\n | NestedRuntimeStyleProcessor;\n\n/**\n * css() runtime factory of css``\n *\n * /!\\ @yak/solid transpiles css`` and styled``\n *\n * This changes the typings of the css`` and styled`` functions.\n * During development the user of @yak/solid wants to work with the\n * typings BEFORE compilation.\n *\n * Therefore this is only an internal function only and it must be cast to any\n * before exported to the user.\n *\n * The internal functioning of css`` is to return a single callback function that runs all functions\n * (or creates new ones if needed) that are passed as arguments. These functions receive the props, classes, and style object as arguments\n * and operate directly on the classes and style objects.\n */\nexport function css<TProps>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<NoInfer<TProps> & { theme: Accessor<YakTheme> }>[]\n): ComponentStyles<TProps>;\nexport function css<TProps>(...args: Array<any>): RuntimeStyleProcessor<TProps> {\n // Normally this could be an array of strings passed, but as we transpile the usage of css`` ourselves, we control the arguments\n // and ensure that only the first argument is a string (class name of the non-dynamic styles)\n let staticClass: string | undefined;\n const dynamicCssFunctions: NestedRuntimeStyleProcessor[] = [];\n for (const arg of args as Array<string | CSSFunction | CSSStyles<any>>) {\n // A CSS-module class name which got auto generated during build from static css\n // e.g. css`color: red;`\n // compiled -> css(\"yak31e4\")\n if (typeof arg === \"string\") {\n staticClass = arg;\n }\n // Dynamic CSS e.g.\n // css`${props => props.active && css`color: red;`}`\n // compiled -> css((props: { active: boolean }) => props.active && css(\"yak31e4\"))\n else if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg as unknown as NestedRuntimeStyleProcessor);\n }\n // Dynamic CSS with css variables e.g.\n // css`transform: translate(${props => props.x}, ${props => props.y});`\n // compiled -> css(\"yak31e4\", { style: { \"--yakVarX\": props => props.x }, \"--yakVarY\": props => props.y }})\n else if (typeof arg === \"object\" && \"style\" in arg) {\n dynamicCssFunctions.push((props, _, style) => {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n style[key as keyof StyleObject] = String(\n // The value for a css value can be a theme dependent function e.g.:\n // const borderColor = (props: { theme: { mode: \"dark\" | \"light\" } }) => props.theme === \"dark\" ? \"black\" : \"white\";\n // css`border-color: ${borderColor};`\n // Therefore the value has to be extracted recursively\n recursivePropExecution(props, value),\n ) as never;\n } else {\n style[key as keyof StyleObject] = String(value) as never;\n }\n }\n });\n }\n }\n\n // Non Dynamic CSS\n // This is just an optimization for the common case where there are no dynamic css functions\n // `$dynamic: false` lets the styled runtime skip theme lookup and\n // style-object allocation entirely for static components\n if (dynamicCssFunctions.length === 0) {\n return Object.assign(\n (_: unknown, classes: ClassCollector) => {\n if (staticClass) {\n classes.add(staticClass);\n }\n },\n { $dynamic: false },\n );\n }\n\n return Object.assign(\n (props: TProps, classes: ClassCollector, allStyles: StyleObject) => {\n if (staticClass) {\n classes.add(staticClass);\n }\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n unwrapProps(props, dynamicCssFunctions[i], classes, allStyles);\n }\n },\n { $dynamic: true },\n );\n}\n\n// Dynamic CSS with runtime logic\nconst unwrapProps = (\n props: unknown,\n fn: NestedRuntimeStyleProcessor,\n classes: ClassCollector,\n style: StyleObject,\n) => {\n let result = fn(props, classes, style);\n while (result) {\n if (typeof result === \"function\") {\n result = result(props, classes, style);\n continue;\n } else if (typeof result === \"object\") {\n const resultClass = \"class\" in result ? result.class : undefined;\n if (resultClass) {\n classes.add(resultClass);\n }\n if (\"style\" in result && result.style) {\n for (const key in result.style) {\n // This is hard for typescript to infer\n style[key as keyof StyleObject] = result.style[key as keyof StyleObject] as any;\n }\n }\n }\n break;\n }\n};\n\nconst recursivePropExecution = (props: unknown, fn: (props: unknown) => any): string | number => {\n const result = fn(props);\n if (typeof result === \"function\") {\n return recursivePropExecution(props, result);\n }\n // typeof guards first: the `process.env` lookup is a real per-call cost\n // for unbundled Node consumers, so it must only run on the invalid path\n if (typeof result !== \"string\" && typeof result !== \"number\" && !(result instanceof String)) {\n if (process.env.NODE_ENV === \"development\") {\n throw new Error(\n `Dynamic CSS functions must return a string or number but returned ${JSON.stringify(\n result,\n )}\\n\\nDynamic CSS function: ${fn.toString()}\\n`,\n );\n }\n }\n return result;\n};\n","/**\n * Normalize Solid `class` values for string merging.\n * Solid 2 allows strings, arrays and object syntax on the class attribute.\n */\nexport const normalizeClass = (value: unknown): string => {\n if (!value) return \"\";\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) return value.map(normalizeClass).filter(Boolean).join(\" \");\n if (typeof value === \"object\") {\n return Object.keys(value)\n .filter((key) => (value as Record<string, unknown>)[key])\n .join(\" \");\n }\n return String(value);\n};\n\n/**\n * Merges the folded yak class name with a user `class` value.\n *\n * Injected by the compiler (as `__yak_mergeClassNames`) when it replaces a JSX\n * usage of a fully static styled component with a plain element:\n * ```tsx\n * const Card = styled.div`color: red;`;\n * <Card class={active() && \"active\"} />\n * ```\n * becomes\n * ```tsx\n * <div class={__yak_mergeClassNames(\"yX\", active() && \"active\")} />\n * ```\n */\nexport const mergeClasses = (yakClass: string, userClass: unknown): string | undefined => {\n const user = normalizeClass(userClass);\n if (!yakClass) return user || undefined;\n if (!user) return yakClass;\n return yakClass + \" \" + user;\n};\n","import { css, CSSInterpolation, Classes, yakComponentSymbol } from \"./cssLiteral.js\";\nimport type {\n AnyComponent,\n Attrs,\n AttrsMerged,\n Styled,\n YakComponent,\n AttrsFunction,\n StyledFn,\n HtmlTags,\n Substitute,\n StyledLiteral,\n RuntimeStyleProcessor,\n StyleObject,\n} from \"./publicStyledApi.js\";\nimport { createMemo, merge } from \"solid-js\";\nimport { createComponent, Dynamic, type JSX } from \"@solidjs/web\";\nimport { normalizeClass } from \"./internals/mergeClasses.js\";\n// the following import is not relative but the package-level \"@yak/solid/context\"\n// export: it keeps a single context instance shared between the bundled runtime\n// and user code (and lets the vite plugin alias the user's theme context)\nimport { useTheme } from \"@yak/solid/context\";\nimport type { YakTheme } from \"./context/index.js\";\nimport type { Accessor } from \"solid-js\";\n\n//\n// The `styled()` API without `styled.` syntax\n//\n// The API design is inspired by styled-components:\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/constructors/styled.tsx\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/models/StyledComponent.ts\n//\n/**\n * Renders `props.component` (a tag name or component) with the remaining\n * props. Loosely typed on purpose: the runtime passes lazily-merged Proxy\n * props that no concrete component type can describe.\n */\nconst renderDynamic = (props: Record<PropertyKey, unknown>): JSX.Element =>\n createComponent(Dynamic as (props: Record<PropertyKey, unknown>) => JSX.Element, props);\n\nconst styledFactory: StyledFn = (Component) =>\n Object.assign(yakStyled(Component), {\n attrs: (attrs: Attrs<any>) => yakStyled(Component, attrs),\n });\n\n/**\n * The `styled` method works perfectly on all of your own or any third-party component,\n * as long as they attach the passed `class` prop to a DOM element.\n *\n * @usage\n *\n * ```tsx\n * const StyledLink = styled(Link)`\n * color: #BF4F74;\n * font-weight: bold;\n * `;\n * ```\n */\nexport const styled = styledFactory as Styled;\n\ntype PropsWithClassAndStyle = {\n class?: string;\n style?: StyleObject | string;\n theme?: Accessor<YakTheme>;\n} & Record<string, unknown>;\n\nconst yakStyled: StyledInternal = (Component, attrs) => {\n // Probe with a property read, not the `in` operator: in dev, solid-refresh\n // wraps registered components in a Proxy that forwards `get` to the live\n // implementation but has no `has` trap, so `in` would miss the symbol and\n // silently skip chain flattening (breaking attrs override order).\n const isYakComponent =\n typeof Component === \"function\" &&\n (Component as Partial<YakComponent<unknown>>)[yakComponentSymbol] !== undefined;\n\n // if the component that is wrapped is a yak component, we can extract the attrs function\n // and the dynamic style function to merge it with the current attrs function (or dynamic\n // style function) so that the sequence of the attrs functions is preserved\n const [, parentAttrsFn, parentRuntimeStylesFn, parentTarget] = isYakComponent\n ? ((Component as YakComponent<unknown>)[yakComponentSymbol] as unknown as [\n YakComponent<unknown>,\n ExtractAttrsFunction<typeof attrs>,\n RuntimeStyleProcessor<unknown>,\n AnyComponent<any> | string,\n ])\n : [];\n\n // the ultimate render target of the whole styled(styled(...)) chain:\n // attrs and style processors are already merged at construction time, so\n // a chain of N levels renders the target directly in ONE component instead\n // of re-entering every parent wrapper per element\n const targetComponent = (isYakComponent ? parentTarget : Component) as AnyComponent<any> | string;\n\n const mergedAttrsFn = buildRuntimeAttrsProcessor(attrs, parentAttrsFn);\n\n return (styles, ...values) => {\n // combine all interpolated logic into a single function\n // e.g. styled.button`color: ${props => props.color}; margin: ${props => props.margin};`\n const runtimeStylesFn = css(\n styles,\n ...(values as CSSInterpolation<unknown>[]),\n ) as RuntimeStyleProcessor<unknown>;\n const runtimeStyleProcessor = buildRuntimeStylesProcessor(\n runtimeStylesFn,\n parentRuntimeStylesFn,\n );\n\n // decided once per styled component: tag names render through Dynamic\n // (which needs a `component` prop), component targets are called\n // directly so a user prop named `component` reaches them (Dynamic\n // would consume it). `targetProps` is merged BEFORE filterDomProps -\n // the filter proxy must stay the outermost layer (see filterDomProps)\n const isTag = typeof targetComponent === \"string\";\n const targetProps = isTag ? { component: targetComponent } : {};\n const renderTarget = isTag\n ? renderDynamic\n : (finalProps: Record<PropertyKey, unknown>) =>\n createComponent(\n targetComponent as (props: Record<PropertyKey, unknown>) => JSX.Element,\n finalProps,\n );\n\n // fast path for fully static components (no attrs, no dynamic styles;\n // the most common case): contribute the chain's class names through a\n // single reactive `class` getter and strip $-props; skips theme lookup,\n // memo creation and style handling entirely\n const Yak: AnyComponent<PropsWithClassAndStyle> =\n !mergedAttrsFn && !runtimeStyleProcessor.$dynamic\n ? (props) =>\n renderTarget(\n filterDomProps(\n merge(props, targetProps, {\n // reading props.class inside the getter keeps the class\n // binding reactive without re-creating the element\n get class(): string | undefined {\n const classes = new Classes(normalizeClass(props.class));\n runtimeStyleProcessor(props, classes, undefined as unknown as StyleObject);\n return classes.value || undefined;\n },\n }),\n ),\n )\n : (props) => {\n // the component body runs ONCE in Solid: all per-update work\n // lives in memos/getters so only the affected DOM bindings update\n\n // attrs functions and dynamic style functions receive the theme;\n // fully static components take the fast path above and never\n // subscribe to the theme context\n const theme = useTheme();\n\n // getter-preserving merge: compiled prop functions like\n // `({ $bottom }) => ...` destructure this proxy INSIDE the memo\n // below, so every read is tracked at its use-site\n const propsWithTheme = merge({ theme }, props) as PropsWithClassAndStyle & {\n theme: Accessor<YakTheme>;\n };\n\n // The first component which is not wrapped in a yak component executes all attrs\n // functions starting from the innermost yak component to the outermost (itself)\n const attrsProps = mergedAttrsFn\n ? createMemo(() => mergedAttrsFn(propsWithTheme as any) as PropsWithClassAndStyle)\n : undefined;\n\n // input for the style processor: props + theme + attrs output\n const styleInput = attrsProps ? merge(propsWithTheme, attrsProps) : propsWithTheme;\n\n // execute all functions inside the style literal\n // e.g. styled.button`color: ${props => props.color};`\n // only reads inside this memo re-run it; the element itself is\n // never re-created, only its class/style bindings update\n const computed = createMemo(() => {\n const attrsResult = attrsProps?.();\n const classes = new Classes(normalizeClass(props.class));\n const attrsClass = normalizeClass(attrsResult?.class);\n if (attrsClass) {\n classes.add(attrsClass);\n }\n // static processors never write style values, so the incoming\n // style object can be passed through without a defensive copy\n const style =\n runtimeStyleProcessor.$dynamic || attrsResult?.style\n ? { ...unwrapStyle(props.style), ...unwrapStyle(attrsResult?.style) }\n : unwrapStyle(props.style);\n runtimeStyleProcessor(styleInput, classes, style as StyleObject);\n return {\n class: classes.value || undefined,\n style: style && Object.keys(style).length > 0 ? style : undefined,\n };\n });\n\n const merged = merge(props, attrsProps ?? {}, {\n get class(): string | undefined {\n return computed().class;\n },\n get style(): StyleObject | undefined {\n return computed().style;\n },\n });\n\n // keep the theme prop only if an attrs function intentionally\n // replaced it; the context theme itself never reaches the target\n const allowTheme = () => {\n const attrsResult = attrsProps?.();\n return !!attrsResult && \"theme\" in attrsResult && attrsResult.theme !== theme;\n };\n\n // render the chain's target directly; parent wrappers contribute\n // only their (already merged) attrs and style processors\n return renderTarget(filterDomProps(merge(merged, targetProps), allowTheme));\n };\n\n return Object.assign(Yak, {\n [yakComponentSymbol]: [Yak, mergedAttrsFn, runtimeStyleProcessor, targetComponent] as [\n unknown,\n unknown,\n unknown,\n unknown,\n ],\n });\n };\n};\n\n/**\n * Normalize a Solid style prop to an object the style processor can extend.\n * Solid allows string styles on elements; they are converted here so CSS custom\n * properties from dynamic values can be merged in (prefer object styles).\n */\nconst unwrapStyle = (style: StyleObject | string | undefined): StyleObject | undefined => {\n if (typeof style !== \"string\") {\n return style;\n }\n const result: Record<string, string> = {};\n for (const declaration of style.split(\";\")) {\n const colonIndex = declaration.indexOf(\":\");\n if (colonIndex === -1) continue;\n const property = declaration.slice(0, colonIndex).trim();\n const value = declaration.slice(colonIndex + 1).trim();\n if (property && value) {\n result[property] = value;\n }\n }\n return result as StyleObject;\n};\n\nconst isBlockedProp = (key: PropertyKey, allowTheme?: () => boolean): boolean =>\n typeof key === \"string\" &&\n (key.startsWith(\"$\") || (key === \"theme\" && !(allowTheme && allowTheme())));\n\n/**\n * Remove all props that start with a $ sign (plus the internal theme) so\n * they reach neither DOM elements nor custom components.\n *\n * Implemented as a lazy Proxy instead of an eager copy: Solid's compiled\n * spread reads props through getters, and copying would read every prop\n * exactly once and freeze its value, killing reactivity.\n */\nconst filterDomProps = <T extends object>(props: T, allowTheme?: () => boolean): T =>\n new Proxy(props, {\n get: (target, key) => (isBlockedProp(key, allowTheme) ? undefined : Reflect.get(target, key)),\n has: (target, key) => !isBlockedProp(key, allowTheme) && Reflect.has(target, key),\n ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !isBlockedProp(key, allowTheme)),\n getOwnPropertyDescriptor: (target, key) =>\n isBlockedProp(key, allowTheme) ? undefined : Reflect.getOwnPropertyDescriptor(target, key),\n });\n\n// util function to merge class names, as they are concatenated with a space\nconst mergeClasses = (a?: string, b?: string) => {\n if (!a && !b) return undefined;\n if (!a) return b;\n if (!b) return a;\n return a + \" \" + b;\n};\n\n/**\n * merge props and processed props (including class names and styles)\n * e.g.:\\\n * `{ class: \"a\", foo: 1 }` and `{ class: \"b\", bar: 2 }` \\\n * => `{ class: \"a b\", foo: 1, bar: 2 }`\n */\nconst combineProps = <\n T extends {\n class?: string;\n style?: StyleObject | string;\n },\n TOther extends\n | {\n class?: string;\n style?: StyleObject | string;\n }\n | null\n | undefined,\n>(\n props: T,\n newProps: TOther,\n) =>\n newProps\n ? (props.class === newProps.class || !newProps.class) &&\n (props.style === newProps.style || !newProps.style)\n ? // shortcut if no style and class merging is necessary\n {\n ...props,\n ...newProps,\n }\n : // merge class names and styles\n {\n ...props,\n ...newProps,\n class: mergeClasses(props.class, newProps.class),\n style: { ...unwrapStyle(props.style), ...unwrapStyle(newProps.style) },\n }\n : // if no new props are provided, no merging is necessary\n props;\n\n/**\n * Merges the attrs function of the current component with the attrs function of the parent component\n * in order to preserve the sequence of the attrs functions.\n * Note: In theory, the parentAttrsFn can have different types for TAttrsIn and TAttrsOut\n * but as this is only used internally, we can ignore and simplify this case\n * @param attrs The attrs object or function of the current component (if any)\n * @param parentAttrsFn The attrs function of the parent/wrapped component (if any)\n * @returns A function that receives the props and returns the transformed props\n */\nconst buildRuntimeAttrsProcessor = <\n T,\n TAttrsIn extends object,\n TAttrsOut extends AttrsMerged<T, TAttrsIn>,\n>(\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n parentAttrsFn?: AttrsFunction<T, TAttrsIn, TAttrsOut>,\n): AttrsFunction<T, TAttrsIn, TAttrsOut> | undefined => {\n const ownAttrsFn = attrs && (typeof attrs === \"function\" ? attrs : () => attrs);\n\n if (ownAttrsFn && parentAttrsFn) {\n return (props) => {\n const parentProps = parentAttrsFn(props);\n\n // overwrite and merge the parent props with the props received from the attrs function\n // after they went through the parent attrs function.\n //\n // This makes sure the linearity of the attrs functions is preserved and all attrs function receive\n // the whole props object calculated from the previous attrs functions\n return combineProps(\n parentProps as any,\n ownAttrsFn(combineProps(props as any, parentProps as any) as any),\n ) as any;\n };\n }\n\n return ownAttrsFn || parentAttrsFn;\n};\n\n/**\n * Merges the runtime style function of the current component with the runtime style function of the parent component\n * in order to preserve the sequence of the attrs functions.\n * @param runtimeStylesFn The current runtime styles function\n * @param parentRuntimeStylesFn The parent runtime styles function\n * @returns The merged runtime styles function\n */\nconst buildRuntimeStylesProcessor = <T>(\n runtimeStylesFn: RuntimeStyleProcessor<T>,\n parentRuntimeStylesFn?: RuntimeStyleProcessor<T>,\n) => {\n if (runtimeStylesFn && parentRuntimeStylesFn) {\n const combined: RuntimeStyleProcessor<T> = Object.assign(\n (props: T, classes: Parameters<RuntimeStyleProcessor<T>>[1], style: StyleObject) => {\n parentRuntimeStylesFn(props, classes, style);\n runtimeStylesFn(props, classes, style);\n },\n // the chain is dynamic if any level is dynamic\n { $dynamic: runtimeStylesFn.$dynamic || parentRuntimeStylesFn.$dynamic },\n );\n return combined;\n }\n return runtimeStylesFn || parentRuntimeStylesFn;\n};\n\n/**\n * Internal function where attrs are passed to be processed\n */\nexport type StyledInternal = <\n T extends object,\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n>(\n Component: AnyComponent<T> | YakComponent<T> | HtmlTags | string,\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n) => StyledLiteral<Substitute<T, TAttrsIn>>;\n\n/**\n * Utility type to extract the AttrsFunction from the Attrs type\n */\nexport type ExtractAttrsFunction<T> = T extends (p: any) => any ? T : never;\n","import { ComponentStyles, css } from \"./cssLiteral.js\";\nimport { RuntimeStyleProcessor } from \"./publicStyledApi.js\";\n\n/**\n * Allows to use atomic CSS classes in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, atoms } from \"@yak/solid\";\n *\n * const Button = styled.button<{ $primary?: boolean }>`\n * ${atoms(\"text-teal-600\", \"text-base\", \"rounded-md\")}\n * ${props => props.$primary && atoms(\"shadow-md\")}\n * `;\n * ```\n */\nexport const atoms = <T>(\n ...atoms: (string | RuntimeStyleProcessor<T> | false)[]\n): ComponentStyles<T> => {\n const staticClasses: string[] = [];\n const dynamicFunctions: RuntimeStyleProcessor<T>[] = [];\n\n for (const atom of atoms) {\n if (typeof atom === \"string\") {\n staticClasses.push(...atom.split(\" \"));\n } else if (typeof atom === \"function\") {\n dynamicFunctions.push(atom);\n }\n }\n\n const runtimeFunctions: RuntimeStyleProcessor<T>[] =\n staticClasses.length > 0\n ? [\n (_, classes) => {\n staticClasses.forEach((cls) => classes.add(cls));\n },\n ...dynamicFunctions,\n ]\n : dynamicFunctions;\n\n // @ts-expect-error the internal implementation of css is not typed\n return css(...runtimeFunctions);\n};\n","/**\n * Allows to use CSS keyframe animations in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, keyframes } from \"@yak/solid\";\n *\n * const rotate = keyframes`\n * from {\n * transform: rotate(0deg);\n * }\n * to {\n * transform: rotate(360deg);\n * }\n * `;\n *\n * const Spinner = styled.div`\n * animation: ${rotate} 1s linear infinite;\n * `;\n * ```\n */\nexport const keyframes = <T extends (string | number | bigint)[] = never>(\n styles: TemplateStringsArray,\n ..._dynamic: T\n): string => {\n // during compilation all args of keyframe are compiled\n // to a string which references the animation name\n return styles as any as string;\n};\n","import type { ComponentStyles } from \"./cssLiteral.js\";\nimport type { YakComponent } from \"./publicStyledApi.js\";\n\n/**\n * Values that may be interpolated into a `globalStyle` template.\n *\n * Only build-time values are allowed: constants, `keyframes` animation names,\n * static `css` mixins and styled-component selectors. Runtime functions\n * (`${(props) => ...}`) are intentionally excluded: a global rule has no element\n * to attach a CSS variable to. Declare a CSS custom property instead and toggle\n * it via an attribute/class on the root element.\n */\nexport type GlobalStyleInterpolation = string | number | ComponentStyles<{}> | YakComponent<any>;\n\n/**\n * Declares global, unscoped styles that ride the same zero-runtime extraction\n * pipeline as `styled` and `keyframes`.\n *\n * Global styles are **part of the stylesheet, not part of the render tree**.\n * They apply exactly when the module declaring them is included in the bundle,\n * typically by importing it from a layout or entry point. They cannot be\n * conditionally mounted; express conditions in CSS (`@media`, `@supports`,\n * `:root[data-theme]`, `:has()`) or through CSS custom properties.\n *\n * @usage\n *\n * ```tsx\n * import { globalStyle, keyframes } from \"@yak/solid\";\n *\n * const fadeIn = keyframes`\n * from { opacity: 0; }\n * `;\n *\n * globalStyle`\n * :root {\n * --spacing: 4px;\n * }\n *\n * body {\n * margin: 0;\n * }\n *\n * ::view-transition-new(root) {\n * animation: ${fadeIn} 200ms ease;\n * }\n * `;\n * ```\n */\nexport const globalStyle = (\n _styles: TemplateStringsArray,\n ..._values: Array<GlobalStyleInterpolation>\n): void => {\n return undefined;\n};\n","/**\n * Internal helper called by transformed code. Do not use directly.\n *\n * Takes a function and a css unit and returns the result of the function concatenated with the unit\n *\n * ```tsx\n * import { styled } from \"@yak/solid\";\n *\n * const Button = styled.button<{ $width?: boolean }>`\n * width: ${({ $width }) => $width}px;\n * `;\n * ```\n *\n * Which will be transformed to:\n * ```tsx\n * import { styled } from \"@yak/solid/internal\";\n *\n * const Button = styled.button<{ $width?: boolean }>(\n * \"button\", {\n * width: unitPostFix({ $width }) => $width, \"px\")\n * });\n */\nexport const unitPostFix = (arg: unknown, unit: string) => {\n switch (typeof arg) {\n case \"function\":\n return (props: any) => unitPostFix(arg(props), unit);\n case \"number\":\n case \"string\":\n return `${arg}${unit}`;\n // Ignore falsy values\n default:\n return undefined;\n }\n};\n","import { Classes } from \"../cssLiteral.js\";\nimport { RuntimeStyleProcessor } from \"../publicStyledApi.js\";\n\n/**\n * This is an internal helper function to merge relevant props of a native element with a css prop.\n * It's automatically added when using the `css` prop in a JSX element.\n * e.g.:\n * ```tsx\n * <p\n * class=\"foo\"\n * css={css`\n * color: green;\n * `}\n * {...{ style: { padding: \"30px\" }}}\n * />\n */\nexport const mergeCssProp = (\n relevantProps: {\n class?: string;\n style?: Record<string, string>;\n } & Record<string, unknown>,\n cssProp: RuntimeStyleProcessor<unknown> | false | null | undefined,\n) => {\n const classes = new Classes(relevantProps.class);\n\n const existingStyle = relevantProps.style;\n const style = existingStyle ? { ...existingStyle } : {};\n\n // a falsy css prop applies no styles, e.g. `css={on && css`...`}` with `on` false\n if (cssProp) {\n cssProp({}, classes, style);\n }\n\n // Forward all other props (onClick, aria-*, id, …) untouched and only\n // override class/style with the merged result — the transform already\n // built `relevantProps` in JSX attribute order, so this preserves overrides.\n const result: Record<string, unknown> & {\n class?: string;\n style?: Record<string, string>;\n } = { ...relevantProps };\n\n if (Object.keys(style).length > 0) {\n result.style = style;\n } else {\n delete result.style;\n }\n if (classes.value) {\n result.class = classes.value;\n } else {\n delete result.class;\n }\n\n return result;\n};\n","import { styled } from \"./styled.js\";\n/// Internal API to create styled components\n/// Optimization for faster rendering and smaller bundle size in production\n/// thanks to better minification and dead code elimination\n///\n/// List taken from https://github.com/styled-components/styled-components/blob/e0019ba666fab4b5aaa2bff71ba6ad0005a299fd/packages/styled-components/src/utils/domElements.ts#L90\nexport const __yak_a = /*#__PURE__*/ styled(\"a\");\nexport const __yak_abbr = /*#__PURE__*/ styled(\"abbr\");\nexport const __yak_address = /*#__PURE__*/ styled(\"address\");\nexport const __yak_area = /*#__PURE__*/ styled(\"area\");\nexport const __yak_article = /*#__PURE__*/ styled(\"article\");\nexport const __yak_aside = /*#__PURE__*/ styled(\"aside\");\nexport const __yak_audio = /*#__PURE__*/ styled(\"audio\");\nexport const __yak_b = /*#__PURE__*/ styled(\"b\");\nexport const __yak_base = /*#__PURE__*/ styled(\"base\");\nexport const __yak_bdi = /*#__PURE__*/ styled(\"bdi\");\nexport const __yak_bdo = /*#__PURE__*/ styled(\"bdo\");\nexport const __yak_big = /*#__PURE__*/ styled(\"big\");\nexport const __yak_blockquote = /*#__PURE__*/ styled(\"blockquote\");\nexport const __yak_body = /*#__PURE__*/ styled(\"body\");\nexport const __yak_br = /*#__PURE__*/ styled(\"br\");\nexport const __yak_button = /*#__PURE__*/ styled(\"button\");\nexport const __yak_canvas = /*#__PURE__*/ styled(\"canvas\");\nexport const __yak_caption = /*#__PURE__*/ styled(\"caption\");\nexport const __yak_cite = /*#__PURE__*/ styled(\"cite\");\nexport const __yak_code = /*#__PURE__*/ styled(\"code\");\nexport const __yak_col = /*#__PURE__*/ styled(\"col\");\nexport const __yak_colgroup = /*#__PURE__*/ styled(\"colgroup\");\nexport const __yak_data = /*#__PURE__*/ styled(\"data\");\nexport const __yak_datalist = /*#__PURE__*/ styled(\"datalist\");\nexport const __yak_dd = /*#__PURE__*/ styled(\"dd\");\nexport const __yak_del = /*#__PURE__*/ styled(\"del\");\nexport const __yak_details = /*#__PURE__*/ styled(\"details\");\nexport const __yak_dfn = /*#__PURE__*/ styled(\"dfn\");\nexport const __yak_dialog = /*#__PURE__*/ styled(\"dialog\");\nexport const __yak_div = /*#__PURE__*/ styled(\"div\");\nexport const __yak_dl = /*#__PURE__*/ styled(\"dl\");\nexport const __yak_dt = /*#__PURE__*/ styled(\"dt\");\nexport const __yak_em = /*#__PURE__*/ styled(\"em\");\nexport const __yak_embed = /*#__PURE__*/ styled(\"embed\");\nexport const __yak_fieldset = /*#__PURE__*/ styled(\"fieldset\");\nexport const __yak_figcaption = /*#__PURE__*/ styled(\"figcaption\");\nexport const __yak_figure = /*#__PURE__*/ styled(\"figure\");\nexport const __yak_footer = /*#__PURE__*/ styled(\"footer\");\nexport const __yak_form = /*#__PURE__*/ styled(\"form\");\nexport const __yak_h1 = /*#__PURE__*/ styled(\"h1\");\nexport const __yak_h2 = /*#__PURE__*/ styled(\"h2\");\nexport const __yak_h3 = /*#__PURE__*/ styled(\"h3\");\nexport const __yak_h4 = /*#__PURE__*/ styled(\"h4\");\nexport const __yak_h5 = /*#__PURE__*/ styled(\"h5\");\nexport const __yak_h6 = /*#__PURE__*/ styled(\"h6\");\nexport const __yak_header = /*#__PURE__*/ styled(\"header\");\nexport const __yak_hgroup = /*#__PURE__*/ styled(\"hgroup\");\nexport const __yak_hr = /*#__PURE__*/ styled(\"hr\");\nexport const __yak_html = /*#__PURE__*/ styled(\"html\");\nexport const __yak_i = /*#__PURE__*/ styled(\"i\");\nexport const __yak_iframe = /*#__PURE__*/ styled(\"iframe\");\nexport const __yak_img = /*#__PURE__*/ styled(\"img\");\nexport const __yak_input = /*#__PURE__*/ styled(\"input\");\nexport const __yak_ins = /*#__PURE__*/ styled(\"ins\");\nexport const __yak_kbd = /*#__PURE__*/ styled(\"kbd\");\nexport const __yak_keygen = /*#__PURE__*/ styled(\"keygen\");\nexport const __yak_label = /*#__PURE__*/ styled(\"label\");\nexport const __yak_legend = /*#__PURE__*/ styled(\"legend\");\nexport const __yak_li = /*#__PURE__*/ styled(\"li\");\nexport const __yak_link = /*#__PURE__*/ styled(\"link\");\nexport const __yak_main = /*#__PURE__*/ styled(\"main\");\nexport const __yak_map = /*#__PURE__*/ styled(\"map\");\nexport const __yak_mark = /*#__PURE__*/ styled(\"mark\");\nexport const __yak_menu = /*#__PURE__*/ styled(\"menu\");\nexport const __yak_menuitem = /*#__PURE__*/ styled(\"menuitem\");\nexport const __yak_meta = /*#__PURE__*/ styled(\"meta\");\nexport const __yak_meter = /*#__PURE__*/ styled(\"meter\");\nexport const __yak_nav = /*#__PURE__*/ styled(\"nav\");\nexport const __yak_noscript = /*#__PURE__*/ styled(\"noscript\");\nexport const __yak_object = /*#__PURE__*/ styled(\"object\");\nexport const __yak_ol = /*#__PURE__*/ styled(\"ol\");\nexport const __yak_optgroup = /*#__PURE__*/ styled(\"optgroup\");\nexport const __yak_option = /*#__PURE__*/ styled(\"option\");\nexport const __yak_output = /*#__PURE__*/ styled(\"output\");\nexport const __yak_p = /*#__PURE__*/ styled(\"p\");\nexport const __yak_param = /*#__PURE__*/ styled(\"param\");\nexport const __yak_picture = /*#__PURE__*/ styled(\"picture\");\nexport const __yak_pre = /*#__PURE__*/ styled(\"pre\");\nexport const __yak_progress = /*#__PURE__*/ styled(\"progress\");\nexport const __yak_q = /*#__PURE__*/ styled(\"q\");\nexport const __yak_rp = /*#__PURE__*/ styled(\"rp\");\nexport const __yak_rt = /*#__PURE__*/ styled(\"rt\");\nexport const __yak_ruby = /*#__PURE__*/ styled(\"ruby\");\nexport const __yak_s = /*#__PURE__*/ styled(\"s\");\nexport const __yak_samp = /*#__PURE__*/ styled(\"samp\");\nexport const __yak_script = /*#__PURE__*/ styled(\"script\");\nexport const __yak_section = /*#__PURE__*/ styled(\"section\");\nexport const __yak_select = /*#__PURE__*/ styled(\"select\");\nexport const __yak_small = /*#__PURE__*/ styled(\"small\");\nexport const __yak_source = /*#__PURE__*/ styled(\"source\");\nexport const __yak_span = /*#__PURE__*/ styled(\"span\");\nexport const __yak_strong = /*#__PURE__*/ styled(\"strong\");\nexport const __yak_style = /*#__PURE__*/ styled(\"style\");\nexport const __yak_sub = /*#__PURE__*/ styled(\"sub\");\nexport const __yak_summary = /*#__PURE__*/ styled(\"summary\");\nexport const __yak_sup = /*#__PURE__*/ styled(\"sup\");\nexport const __yak_table = /*#__PURE__*/ styled(\"table\");\nexport const __yak_tbody = /*#__PURE__*/ styled(\"tbody\");\nexport const __yak_td = /*#__PURE__*/ styled(\"td\");\nexport const __yak_textarea = /*#__PURE__*/ styled(\"textarea\");\nexport const __yak_tfoot = /*#__PURE__*/ styled(\"tfoot\");\nexport const __yak_th = /*#__PURE__*/ styled(\"th\");\nexport const __yak_thead = /*#__PURE__*/ styled(\"thead\");\nexport const __yak_time = /*#__PURE__*/ styled(\"time\");\nexport const __yak_tr = /*#__PURE__*/ styled(\"tr\");\nexport const __yak_track = /*#__PURE__*/ styled(\"track\");\nexport const __yak_u = /*#__PURE__*/ styled(\"u\");\nexport const __yak_ul = /*#__PURE__*/ styled(\"ul\");\nexport const __yak_use = /*#__PURE__*/ styled(\"use\");\nexport const __yak_var = /*#__PURE__*/ styled(\"var\");\nexport const __yak_video = /*#__PURE__*/ styled(\"video\");\nexport const __yak_wbr = /*#__PURE__*/ styled(\"wbr\");\nexport const __yak_circle = /*#__PURE__*/ styled(\"circle\");\nexport const __yak_clipPath = /*#__PURE__*/ styled(\"clipPath\");\nexport const __yak_defs = /*#__PURE__*/ styled(\"defs\");\nexport const __yak_ellipse = /*#__PURE__*/ styled(\"ellipse\");\nexport const __yak_foreignObject = /*#__PURE__*/ styled(\"foreignObject\");\nexport const __yak_g = /*#__PURE__*/ styled(\"g\");\nexport const __yak_image = /*#__PURE__*/ styled(\"image\");\nexport const __yak_line = /*#__PURE__*/ styled(\"line\");\nexport const __yak_linearGradient = /*#__PURE__*/ styled(\"linearGradient\");\nexport const __yak_marker = /*#__PURE__*/ styled(\"marker\");\nexport const __yak_mask = /*#__PURE__*/ styled(\"mask\");\nexport const __yak_path = /*#__PURE__*/ styled(\"path\");\nexport const __yak_pattern = /*#__PURE__*/ styled(\"pattern\");\nexport const __yak_polygon = /*#__PURE__*/ styled(\"polygon\");\nexport const __yak_polyline = /*#__PURE__*/ styled(\"polyline\");\nexport const __yak_radialGradient = /*#__PURE__*/ styled(\"radialGradient\");\nexport const __yak_rect = /*#__PURE__*/ styled(\"rect\");\nexport const __yak_stop = /*#__PURE__*/ styled(\"stop\");\nexport const __yak_svg = /*#__PURE__*/ styled(\"svg\");\nexport const __yak_text = /*#__PURE__*/ styled(\"text\");\nexport const __yak_tspan = /*#__PURE__*/ styled(\"tspan\");\n"],"mappings":";;;;;AAIA,MAAa,qBAAqB,OAAO,KAAK;AAS9C,IAAa,UAAb,MAA+C;CAC7C;CACA,YAAY,SAAkB;EAC5B,KAAK,QAAQ,WAAW;CAC1B;CACA,IAAI,MAAc;EAChB,IAAI,CAAC,KAAK,OACR,KAAK,QAAQ;OACR,IAAI,CAAC,KAAK,IAAI,IAAI,GACvB,KAAK,SAAS,MAAM;CAExB;CACA,IAAI,MAAc;EAChB,QAAQ,MAAM,KAAK,QAAQ,IAAG,CAAE,SAAS,MAAM,OAAO,GAAG;CAC3D;CACA,OAAO,MAAc;EACnB,IAAI,KAAK,IAAI,IAAI,GACf,KAAK,QAAQ,KAAK,MACf,MAAM,GAAG,CAAC,CACV,QAAQ,aAAa,aAAa,IAAI,CAAC,CACvC,KAAK,GAAG;CAEf;AACF;AAg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,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,gBAA8B,qBAAO,SAAS;AAC3D,MAAa,gBAA8B,qBAAO,SAAS;AAC3D,MAAa,iBAA+B,qBAAO,UAAU;AAC7D,MAAa,uBAAqC,qBAAO,gBAAgB;AACzE,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,YAA0B,qBAAO,KAAK;AACnD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,cAA4B,qBAAO,OAAO"}
1
+ {"version":3,"file":"internal.js","names":["useTheme"],"sources":["../runtime/cssLiteral.ts","../runtime/internals/mergeClasses.ts","../runtime/styled.ts","../runtime/atoms.ts","../runtime/keyframes.ts","../runtime/globalStyle.ts","../runtime/internals/unitPostFix.ts","../runtime/internals/mergeCssProp.ts","../runtime/styledDom.ts"],"sourcesContent":["import type { YakTheme } from \"./index.ts\";\nimport type { Accessor } from \"solid-js\";\nimport { ClassCollector, CompiledStyleProcessor, StyleObject } from \"./publicStyledApi.js\";\n\n// Symbol.for, not Symbol(): the package ships two bundles (the public entry\n// and the internal one the compiler imports) and both contain this module. a\n// styled component created through one must be recognized by the other\nexport const yakComponentSymbol = Symbol.for(\"@yak/solid:component\");\n\n/**\n * the class names of one render, kept as one space-separated string in the\n * order the style block adds them. add() is the hot path: an append, and a\n * duplicate check only once a second name arrives. has() and delete() exist\n * for runtime processors that take a name back out, such as an atom that\n * reverts a class. a Set would need a split and a join per render for the\n * same string\n */\nexport class Classes implements ClassCollector {\n value: string;\n /**\n * false once a name came from the author, such as an atom. compiler names\n * are safe to print as they are; serializeElement in styled.ts escapes the\n * class once this is false\n */\n generated = true;\n constructor(initial?: string) {\n this.value = initial || \"\";\n }\n add(name: string, generated = true) {\n if (!generated) this.generated = false;\n if (!this.value) {\n this.value = name;\n } else if (!this.has(name)) {\n this.value += \" \" + name;\n }\n }\n has(name: string) {\n return (\" \" + this.value + \" \").includes(\" \" + name + \" \");\n }\n delete(name: string) {\n if (this.has(name)) {\n this.value = this.value\n .split(\" \")\n .filter((existing) => existing !== name)\n .join(\" \");\n }\n }\n}\n\nexport type ComponentStyles<TProps> = (props: TProps) => {\n class: string;\n style?: {\n [key: string]: string;\n };\n};\n\nexport type CSSInterpolation<TProps> =\n | string\n | number\n | undefined\n | null\n | false\n | ComponentStyles<TProps>\n | {\n // type only identifier to allow targeting components\n // e.g. styled.svg`${Button}:hover & { fill: red; }`\n [yakComponentSymbol]: any;\n }\n | ((props: TProps) => CSSInterpolation<TProps>);\n\ntype CSSStyles<TProps = {}> = {\n style: { [key: string]: string | ((props: TProps) => string) };\n};\n\nexport type CSSFunction = <TProps>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<NoInfer<TProps> & { theme: Accessor<YakTheme> }>[]\n) => ComponentStyles<TProps>;\n\nexport type NestedRuntimeStyleProcessor = (\n props: unknown,\n classes: ClassCollector,\n style: StyleObject,\n) =>\n | {\n class?: string;\n style?: StyleObject;\n }\n | void\n | false\n | null\n | string\n | number\n | NestedRuntimeStyleProcessor;\n\n/**\n * the runtime behind css``. the compiler rewrites every css`` and styled``\n * call, so what arrives here is never the template the author wrote but its\n * compiled form: class names, callbacks and css-variable maps (examples in\n * the loop below). the public typings describe the call before compilation,\n * which is why this function is internal: mocks/cssLiteral.ts exports the\n * css the author sees, cast to the public type.\n *\n * it returns one processor, (props, classes, style) => void, that runs every\n * compiled piece: class names go into the collector, css values into the\n * style object\n */\nexport function css<TProps>(...args: Array<any>): CompiledStyleProcessor<TProps> {\n let staticClass: string | undefined;\n const dynamicCssFunctions: NestedRuntimeStyleProcessor[] = [];\n for (const arg of args as Array<string | NestedRuntimeStyleProcessor | CSSStyles<any>>) {\n // static css became a css-module class name at build time:\n // css`color: red;` -> css(\"yak31e4\")\n if (typeof arg === \"string\") {\n staticClass = arg;\n }\n // conditional css stays a callback that returns another compiled css():\n // css`${props => props.active && css`color: red;`}`\n // -> css(props => props.active && css(\"yak31e4\"))\n else if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg);\n }\n // a css value became a variable the callback fills at render time:\n // css`transform: translate(${props => props.x});`\n // -> css(\"yak31e4\", { style: { \"--yakVarX\": props => props.x } })\n else if (typeof arg === \"object\" && \"style\" in arg) {\n dynamicCssFunctions.push((props, _, style) => {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n style[key as keyof StyleObject] = String(\n // a callback may return another callback before it yields the\n // value, such as a theme-dependent one:\n // const color = (props) => props.theme().mode === \"dark\" ? \"black\" : \"white\";\n // css`border-color: ${color};`\n recursivePropExecution(props, value),\n ) as never;\n } else {\n style[key as keyof StyleObject] = String(value) as never;\n }\n }\n });\n }\n }\n\n // no dynamic parts, the common case: $dynamic false lets styled() skip the\n // theme lookup and the style object for the component\n if (dynamicCssFunctions.length === 0) {\n return Object.assign(\n (_: unknown, classes: ClassCollector) => {\n if (staticClass) {\n classes.add(staticClass);\n }\n },\n { $dynamic: false as const },\n ) satisfies CompiledStyleProcessor<TProps>;\n }\n\n return Object.assign(\n (props: TProps, classes: ClassCollector, allStyles: StyleObject) => {\n if (staticClass) {\n classes.add(staticClass);\n }\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n runProcessor(props, dynamicCssFunctions[i], classes, allStyles);\n }\n },\n { $dynamic: true as const },\n ) satisfies CompiledStyleProcessor<TProps>;\n}\n\n/** run one processor and fold what it returns into the collector and the style object */\nconst runProcessor = (\n props: unknown,\n fn: NestedRuntimeStyleProcessor,\n classes: ClassCollector,\n style: StyleObject,\n) => {\n let result = fn(props, classes, style);\n while (result) {\n if (typeof result === \"function\") {\n result = result(props, classes, style);\n continue;\n } else if (typeof result === \"object\") {\n const resultClass = \"class\" in result ? result.class : undefined;\n if (resultClass) {\n classes.add(resultClass);\n }\n if (\"style\" in result && result.style) {\n for (const key in result.style) {\n // both objects use StyleObject; typescript loses the key/value relation in this loop\n style[key as keyof StyleObject] = result.style[key as keyof StyleObject] as any;\n }\n }\n }\n break;\n }\n};\n\nconst recursivePropExecution = (props: unknown, fn: (props: unknown) => any): string | number => {\n const result = fn(props);\n if (typeof result === \"function\") {\n return recursivePropExecution(props, result);\n }\n // typeof guards first: the `process.env` lookup is a real per-call cost\n // for unbundled Node consumers, so it must only run on the invalid path\n if (typeof result !== \"string\" && typeof result !== \"number\" && !(result instanceof String)) {\n if (process.env.NODE_ENV === \"development\") {\n throw new Error(\n `Dynamic CSS functions must return a string or number but returned ${JSON.stringify(\n result,\n )}\\n\\nDynamic CSS function: ${fn.toString()}\\n`,\n );\n }\n }\n return result;\n};\n","/**\n * Normalize Solid `class` values for string merging.\n * Solid 2 allows strings, arrays and object syntax on the class attribute.\n */\nexport const normalizeClass = (value: unknown): string => {\n if (!value) return \"\";\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) return value.map(normalizeClass).filter(Boolean).join(\" \");\n if (typeof value === \"object\") {\n return Object.keys(value)\n .filter((key) => (value as Record<string, unknown>)[key])\n .join(\" \");\n }\n return String(value);\n};\n\n/**\n * Merges the folded yak class name with a user `class` value.\n *\n * Injected by the compiler (as `__yak_mergeClassNames`) when it replaces a JSX\n * usage of a fully static styled component with a plain element:\n * ```tsx\n * const Card = styled.div`color: red;`;\n * <Card class={active() && \"active\"} />\n * ```\n * becomes\n * ```tsx\n * <div class={__yak_mergeClassNames(\"yX\", active() && \"active\")} />\n * ```\n * combineProps in styled.ts uses it for two attrs layers' classes as well.\n */\nexport const mergeClasses = (yakClass: string, userClass: unknown): string | undefined => {\n const user = normalizeClass(userClass);\n if (!yakClass) return user || undefined;\n if (!user) return yakClass;\n return yakClass + \" \" + user;\n};\n","// the compiler extracts the css at build time; this file only builds class\n// and style per element, prints the tag on the server and binds it on the\n// client. the map, for a reader who lands in the middle:\n//\n// styled() flattens a chain of styled components and picks one of two\n// component shapes at definition. static: the class is fixed, there is no\n// attrs function and the css block writes no style values at render time,\n// so no memo and no theme read. dynamic: one memo per element resolves\n// attrs, class and style.\n//\n// both hand the target a RenderMeta and a props view. on the server\n// serializeElement (the writer) prints a tag, on the client bindElement\n// spreads onto a cloned template, a component target gets targetProps\n// (a copy or a proxy).\n//\n// the one rule every path keeps: a prop getter may render a child and take\n// hydration keys of its own, so the element takes its key first and reads\n// each getter once, in the target's order.\n//\n// words: author = the app code that writes the css block, renders the\n// component and passes props; target = the tag or component under the\n// styled layer; attrs = the .attrs() values, an object or a function of\n// props; baked = object attrs printed into the tag at definition; view = a\n// proxy over props that adds the theme or attrs; collector = the Classes\n// instance a css block adds its names to; atom = a class name the author\n// passes into a css block via atoms(\"...\"), author text that needs\n// escaping; reactive spread = a {...props} in jsx, which solid compiles to\n// a proxy marked with $PROXY; hole = a slot in a server template that\n// ssr() fills, possibly async; hydration key = the id the server prints on\n// an element so the client can claim the same node\nimport { css, Classes, yakComponentSymbol } from \"./cssLiteral.js\";\nimport type {\n AnyComponent,\n Attrs,\n AttrsMerged,\n Styled,\n YakComponent,\n StyledFn,\n HtmlTags,\n Substitute,\n StyledLiteral,\n CompiledStyleProcessor,\n StaticStyleProcessor,\n StyleObject,\n} from \"./publicStyledApi.js\";\nimport { $PROXY, createMemo } from \"solid-js\";\n// the helpers solid's compiled jsx calls; this file hand-writes what the compiler would emit for a tag\nimport {\n ChildProperties,\n createComponent,\n DOMWithState,\n escape,\n getNextElement,\n insert,\n isServer,\n MathMLElements,\n runHydrationEvents,\n spread,\n ssr,\n ssrClassName,\n ssrHydrationKey,\n ssrStyle,\n SVGElements,\n template,\n type JSX,\n} from \"@solidjs/web\";\nimport { mergeClasses, normalizeClass } from \"./internals/mergeClasses.js\";\n// the runtime and the app share one theme context; vite can alias this export\nimport { useTheme } from \"@yak/solid/context\";\nimport type { YakTheme } from \"./context/index.js\";\nimport type { Accessor } from \"solid-js\";\n\n/** the props a styled component receives from its author; theme is an accessor (the provider's or the author's) */\ntype Props = {\n class?: string;\n style?: StyleObject | string;\n theme?: Accessor<YakTheme>;\n} & Record<PropertyKey, unknown>;\n\n/**\n * the compiled css block: adds its class names to the collector and, when\n * $dynamic, style values for the props; the css itself is extracted at build time\n */\ntype StyleProcessor = CompiledStyleProcessor<unknown>;\n\ntype RuntimeAttrsFn = (props: Props) => Props;\n\n/** the .attrs() values: an object, or a function of the author's props */\ntype RuntimeAttrs = Props | RuntimeAttrsFn;\n\ntype ComputedStyles = {\n class: string | undefined;\n /** true when the class holds generated names only, nothing from the author or attrs; the writer prints it unescaped then */\n generatedClass: boolean;\n style: StyleObject | undefined;\n attrs: Props | undefined;\n};\n\n/**\n * the information to build class and style for one render\n * kept outside of the component props so solid never copies or filters\n * it when it walks the props object\n */\ntype RenderMeta = StaticMeta | DynamicMeta;\n\n/** static component (fixed class, no attrs function, no style values at render time): one meta per component, the class comes from classOf */\ntype StaticMeta = {\n /** keys the target must never see; the rule is `skip` in yakStyled */\n skip: (key: PropertyKey) => boolean;\n compute: undefined;\n classOf: (props: Props) => string | undefined;\n attrsAddKeys: false;\n /** the static class when every name in it is generated, so the writer prints it unescaped; undefined when an atom put author text in it */\n unescapedClass: string | undefined;\n};\n\n/**\n * dynamic component: one memo (run once on the server) holds class,\n * style and attrs, one meta per element. the two meta literals (in\n * createStaticComponent and createDynamicComponent) keep the same keys in\n * the same order so every meta read sees one shape\n */\ntype DynamicMeta = {\n skip: (key: PropertyKey) => boolean;\n compute: () => ComputedStyles;\n classOf: undefined;\n /**\n * an attrs function may add keys at render time, so the target gets a\n * proxy, not a copy. decided at definition: the memo's current attrs say\n * nothing about later runs\n */\n attrsAddKeys: boolean;\n unescapedClass: undefined;\n};\n\n/** what a styled component built on another yak component inherits from it */\ntype ComponentMetadata = readonly [\n attrs: RuntimeAttrs | undefined,\n styles: StyleProcessor,\n target: AnyComponent<any> | string,\n];\n\n/** renders one element of the flattened target: props are the author's raw props, meta says how to build class and style */\ntype TargetRenderer = (props: Props, meta: RenderMeta) => JSX.Element;\n\n/** the loosely typed form of Styled that yakStyled implements; the public overloads live in publicStyledApi */\nexport type StyledInternal = <\n T extends object,\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n>(\n Component: AnyComponent<T> | YakComponent<T> | HtmlTags | string,\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n) => StyledLiteral<Substitute<T, TAttrsIn>>;\n\n/** solid's server regex (not exported); its VoidElements set lacks keygen and menuitem */\nconst VOID_ELEMENTS =\n /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;\n\nconst styledFactory: StyledFn = (Component) =>\n Object.assign(yakStyled(Component), {\n attrs: (attrs: Attrs<any>) => yakStyled(Component, attrs),\n });\n\n/**\n * style a tag or a component that forwards its class prop. styled.div is\n * compiled to styled(\"div\"); the untransformed export in mocks/styled.ts\n * adds the tag properties with a proxy\n */\nexport const styled = styledFactory as Styled;\n\nconst yakStyled: StyledInternal = (Component, attrs) => {\n // solid-refresh forwards reads to the live component, but does not forward `in` checks\n const isYakComponent =\n typeof Component === \"function\" &&\n (Component as Partial<YakComponent<unknown>>)[yakComponentSymbol] !== undefined;\n\n // the public tuple type hides the shape, one cast at the read\n const [parentAttrs, parentRuntimeStylesFn, parentTarget] = isYakComponent\n ? ((Component as YakComponent<unknown>)[yakComponentSymbol] as ComponentMetadata)\n : [];\n\n // the chain renders its final target once, with all attrs and style processors combined\n const targetComponent = parentTarget ?? Component;\n\n const mergedAttrs = composeAttrs(attrs as RuntimeAttrs | undefined, parentAttrs);\n\n return (styles, ...values) => {\n // the interpolations of the style block, e.g.\n // styled.button`color: ${props => props.color}; margin: ${props => props.margin};`\n // arrive compiled: styles and values hold class names, style callbacks\n // and css-variable maps, no css text\n const runtimeStylesFn = css(styles, ...values);\n const runtimeStyleProcessor = composeStyles(runtimeStylesFn, parentRuntimeStylesFn);\n\n const isTag = typeof targetComponent === \"string\";\n // object attrs with plain attribute values bake into the tag's opening\n // string and template; the component stays static. baked keys reach the\n // dom only through that string: skip drops them from the target\n const baked =\n isTag &&\n mergedAttrs &&\n typeof mergedAttrs !== \"function\" &&\n bakeable(targetComponent, mergedAttrs)\n ? mergedAttrs\n : undefined;\n const attrString = baked ? bakeAttributes(baked) : \"\";\n const renderTarget = createTargetRenderer(targetComponent, attrString);\n // static: attrs are none or baked, and the css block writes no style values\n const isStatic = (!mergedAttrs || !!baked) && !runtimeStyleProcessor.$dynamic;\n // the target never sees $-props, the provider theme, or the author class\n // (yak hands it the combined one); a dynamic component merges style in its\n // memo, so the author's style key is dropped here and handed over combined.\n // no symbol passes: solid's merge() flattens any object that answers its\n // private $SOURCES key, which would hand a target's mergeProps() the\n // unfiltered originals; solid's own omit() blocks that key the same way\n const skip = (key: PropertyKey) =>\n typeof key !== \"string\" ||\n key.charCodeAt(0) === 36 /* $ */ ||\n key === \"class\" ||\n key === \"theme\" ||\n (!isStatic && key === \"style\") ||\n // a baked attr wins over the author's prop of the same name, even when its value is null\n (baked !== undefined && Object.hasOwn(baked, key));\n // baked attrs still run inside a dynamic component's memo: style callbacks\n // read them through withAttrs\n const attrsFn =\n typeof mergedAttrs === \"function\" ? mergedAttrs : mergedAttrs && (() => mergedAttrs);\n const Yak = isStatic\n ? createStaticComponent(\n isTag ? targetComponent : undefined,\n renderTarget,\n runtimeStyleProcessor,\n skip,\n attrString,\n )\n : createDynamicComponent(renderTarget, attrsFn, runtimeStyleProcessor, skip, !!baked);\n\n const metadata: ComponentMetadata = [mergedAttrs, runtimeStyleProcessor, targetComponent];\n return Object.assign(Yak, { [yakComponentSymbol]: metadata });\n };\n};\n\n/**\n * object attrs bake when every entry is a plain attribute with a primitive\n * value. rejected keys are the union of what skip drops, what attribute()\n * treats specially, and what solid sets as a dom property (DOMWithState:\n * value, checked, ...), which a template would turn into a markup\n * attribute. enumerable value keys only, so the three walks (here,\n * bakeAttributes, skip) see the same keys; a getter blocks baking and runs\n * at render time\n */\nconst bakeable = (tag: string, attrs: Props): boolean => {\n const stateful = DOMWithState[tag.toUpperCase()];\n return Object.getOwnPropertyNames(attrs).every((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(attrs, key)!;\n if (!descriptor.enumerable || !(\"value\" in descriptor)) return false;\n const type = typeof descriptor.value;\n return (\n (type === \"string\" || type === \"number\" || type === \"boolean\" || descriptor.value == null) &&\n // the name goes into the template and the opening string unescaped; anything\n // else (a computed key with markup in it) takes the writer, whose attribute() escapes names\n ATTRIBUTE_NAME.test(key) &&\n key.charCodeAt(0) !== 36 &&\n key !== \"class\" &&\n key !== \"style\" &&\n key !== \"theme\" &&\n key !== \"ref\" &&\n !ChildProperties.has(key) &&\n !key.startsWith(\"on\") &&\n !key.startsWith(\"prop:\") &&\n !(stateful && key in stateful)\n );\n });\n};\n\n/**\n * the attribute string of baked attrs, built once at definition. the value\n * rules follow attribute(), which prints one prop on the server; the escaping\n * is local because the client build's escape is an empty stub, and the names\n * passed the ATTRIBUTE_NAME check. `<` stays unescaped, harmless in a quoted value\n */\nconst bakeAttributes = (attrs: Props): string => {\n let result = \"\";\n for (const key of Object.keys(attrs)) {\n const value = attrs[key];\n if (value == null || value === false) continue;\n result +=\n value === true || value === \"\" ? ` ${key}` : ` ${key}=\"${escapeAttribute(String(value))}\"`;\n }\n return result;\n};\n\nconst escapeAttribute = (value: string) => value.replaceAll(\"&\", \"&amp;\").replaceAll('\"', \"&quot;\");\n\n/** an attribute name that needs no escaping in markup */\nconst ATTRIBUTE_NAME = /^[A-Za-z_:][\\w:.-]*$/;\n\n/** parent attrs first, then own attrs read and override that result */\nconst composeAttrs = (attrs?: RuntimeAttrs, parent?: RuntimeAttrs): RuntimeAttrs | undefined => {\n if (!attrs) return parent;\n if (!parent) return attrs;\n // two objects without getters combine once here and stay an object; a\n // getter must run per render, inside the memo\n if (\n typeof attrs !== \"function\" &&\n typeof parent !== \"function\" &&\n !hasGetter(attrs) &&\n !hasGetter(parent)\n ) {\n return combineProps(parent, attrs);\n }\n const own = typeof attrs === \"function\" ? attrs : () => attrs;\n const parentFn = typeof parent === \"function\" ? parent : () => parent;\n return (props) => {\n const parentProps = parentFn(props);\n return combineProps(parentProps, own(combineProps(props, parentProps)));\n };\n};\n\n/** parent styles before own styles, with one collector and one style object */\nconst composeStyles = (own: StyleProcessor, parent?: StyleProcessor): StyleProcessor => {\n if (!parent) return own;\n return Object.assign(\n (props: unknown, classes: Parameters<StyleProcessor>[1], style: StyleObject) => {\n parent(props, classes, style);\n own(props, classes, style);\n },\n { $dynamic: own.$dynamic || parent.$dynamic },\n ) as StyleProcessor;\n};\n\n/**\n * attrs override props; class and style values combine, e.g.\n * { class: \"a\", foo: 1 } and { class: \"b\", bar: 2 } -> { class: \"a b\", foo: 1, bar: 2 }\n */\nconst combineProps = (props: Props, newProps: Props | null | undefined): Props => {\n if (!newProps) return props;\n // descriptors, not values: a spread would run every author getter here,\n // and a children getter renders (twice, and with the wrong hydration keys)\n const descriptors = {\n ...Object.getOwnPropertyDescriptors(props),\n ...Object.getOwnPropertyDescriptors(newProps),\n };\n // an equal class counts as nothing: own attrs get the combined props and\n // may hand the same class back, merging it again would duplicate it\n if (newProps.class && props.class !== newProps.class) {\n descriptors.class = valueDescriptor(mergeClasses(normalizeClass(props.class), newProps.class));\n }\n if (newProps.style && props.style !== newProps.style) {\n descriptors.style = valueDescriptor({\n ...unwrapStyle(props.style),\n ...unwrapStyle(newProps.style),\n });\n }\n return Object.defineProperties({}, descriptors) as Props;\n};\n\nconst valueDescriptor = (value: unknown): PropertyDescriptor => ({\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n});\n\nconst hasGetter = (object: object): boolean => {\n for (const key of Object.getOwnPropertyNames(object)) {\n if (!(\"value\" in Object.getOwnPropertyDescriptor(object, key)!)) return true;\n }\n return false;\n};\n\n/** static: no theme, no memo; one class per component, a children-only fast path for a tag */\nconst createStaticComponent = (\n tag: string | undefined,\n renderTarget: TargetRenderer,\n processor: StaticStyleProcessor,\n skip: (key: PropertyKey) => boolean,\n attrString: string,\n): AnyComponent<Props> => {\n const collected = new Classes();\n // a static processor ignores its props argument, it only adds class names\n processor(undefined, collected);\n const staticClass = collected.value || undefined;\n const classOf = (props: Props): string | undefined => {\n const userClass = normalizeClass(props.class);\n if (!userClass) return staticClass;\n // the collector skips generated names the author's class already holds,\n // and an atom may remove one\n const classes = new Classes(userClass);\n processor(props, classes);\n return classes.value || undefined;\n };\n const renderChildrenOnly =\n tag && !VOID_ELEMENTS.test(tag)\n ? createChildrenOnlyRenderer(tag, staticClass, attrString)\n : undefined;\n const meta: RenderMeta = {\n skip,\n compute: undefined,\n classOf,\n attrsAddKeys: false,\n unescapedClass: collected.generated ? staticClass : undefined,\n };\n return (props) => {\n // no props or only children: no skip walk, no props copy, no spread.\n // a reactive spread can add props later and needs the full client binding;\n // on the server props are read once so the proxy check does not matter\n if (renderChildrenOnly && (isServer || !($PROXY in props))) {\n const keys = Object.keys(props);\n if (!keys.length || (keys.length === 1 && keys[0] === \"children\")) {\n return renderChildrenOnly(props, keys.length !== 0);\n }\n }\n return renderTarget(props, meta);\n };\n};\n\n/** tag and class cached per component; only the children need a binding or serialization */\nconst createChildrenOnlyRenderer = (\n tag: string,\n className: string | undefined,\n attrString: string,\n): ((props: Props, hasChildren: boolean) => JSX.Element) => {\n if (isServer) {\n const head = `<${tag}${attrString}`;\n const open = `${className ? ` class=\"${ssrClassName(className)}\"` : \"\"}>`;\n const closing = `</${tag}>`;\n const parts = [head, open, closing];\n // as in childContent: script and style content is not escaped\n const raw = tag === \"script\" || tag === \"style\";\n return (props, hasChildren): { t: string } => {\n // key first: the child getter may render\n const hk = ssrHydrationKey();\n const children = hasChildren ? (raw ? props.children : escape(props.children)) : undefined;\n // text joins in place; anything else goes through ssr() like a compiled\n // template's hole, which handles async children and text separators\n const text = plainContent(children);\n if (text !== undefined) return { t: `${head}${hk}${open}${text}${closing}` };\n return ssr(parts, hk, children);\n };\n }\n const create = createElementTemplate(tag, attrString, className);\n return (props, hasChildren) => {\n const el = getNextElement(create);\n if (hasChildren) {\n // static text arrives as a plain value, not a getter: one insert, no effect.\n // a getter is dynamic and keeps the binding\n const descriptor = Object.getOwnPropertyDescriptor(props, \"children\");\n if (descriptor && \"value\" in descriptor) insert(el, descriptor.value);\n else insert(el, () => props.children);\n }\n runHydrationEvents();\n return el;\n };\n};\n\n/** dynamic: the provider theme plus one memo per element for attrs, class and style */\nconst createDynamicComponent =\n (\n renderTarget: TargetRenderer,\n attrsFn: RuntimeAttrsFn | undefined,\n processor: StyleProcessor,\n skip: (key: PropertyKey) => boolean,\n baked: boolean,\n ): AnyComponent<Props> =>\n (props) => {\n const theme = useTheme();\n // style callbacks see an explicit theme prop before the provider theme\n const propsWithTheme = withTheme(props, theme);\n // one memo per element runs the attrs function and every interpolation\n // of the style block, e.g. styled.button`color: ${props => props.color}`.\n // only reads inside it re-run it; the element is never re-created.\n // attrs and styles share the memo on purpose:\n // a style-only prop change also reruns attrs, still cheaper than\n // two memos per element\n const compute = () => computeStyles(props, propsWithTheme, attrsFn, processor);\n // the server has no updates, so a run-once closure replaces the memo:\n // solid's server createMemo still builds an owner and a node per element.\n // on the client the memo is transparent: it claims no hydration key\n const computed = isServer ? once(compute) : createMemo(compute, { transparent: true });\n // theme reaches the target only when attrs set their own; the provider\n // accessor must not land on the dom element. identity, not `in`: an attrs\n // function that spreads its input hands the provider accessor back\n const allowTheme =\n attrsFn &&\n (() => {\n const attrs = computed().attrs;\n return !!attrs && \"theme\" in attrs && attrs.theme !== theme;\n });\n return renderTarget(props, {\n skip: allowTheme ? (key) => (key === \"theme\" ? !allowTheme() : skip(key)) : skip,\n compute: computed,\n classOf: undefined,\n // baked attrs sit in the template and cannot add keys, the copy path serves them\n attrsAddKeys: !!attrsFn && !baked,\n unescapedClass: undefined,\n });\n };\n\n/** resolve attrs, then run the styles against that props view */\nconst computeStyles = (\n props: Props,\n propsWithTheme: Props,\n attrsFn: RuntimeAttrsFn | undefined,\n processor: StyleProcessor,\n): ComputedStyles => {\n const attrs = attrsFn?.(propsWithTheme);\n const authorClass = normalizeClass(props.class);\n const classes = new Classes(authorClass);\n const attrsClass = normalizeClass(attrs?.class);\n if (attrsClass) classes.add(attrsClass);\n // a static processor writes no style values, so the author's style object\n // passes through without a copy\n const style =\n processor.$dynamic || attrs?.style\n ? { ...unwrapStyle(props.style), ...unwrapStyle(attrs?.style) }\n : unwrapStyle(props.style);\n processor(\n attrs ? withAttrs(propsWithTheme, attrs) : propsWithTheme,\n classes,\n style as StyleObject,\n );\n return {\n class: classes.value || undefined,\n generatedClass: !authorClass && !attrsClass && classes.generated,\n style: style && hasKeys(style) ? style : undefined,\n attrs,\n };\n};\n\n/**\n * backing object of a props view: the author's props, a provider theme to\n * fill in when props has none, and attrs whose values win over props.\n * one shared handler serves both views, so a view costs one proxy and one\n * small object per element and no trap closures\n */\ntype View = { props: Props; theme?: Accessor<YakTheme>; attrs?: Props };\n\nconst viewTraps: ProxyHandler<View> = {\n get: ({ props, theme, attrs }, key) => {\n if (key === \"theme\" && theme && !(\"theme\" in props)) return theme;\n if (attrs && key in attrs) return Reflect.get(attrs, key);\n return Reflect.get(props, key);\n },\n // no props check for theme here: when props has one, Reflect.has says so anyway\n has: ({ props, theme, attrs }, key) =>\n (key === \"theme\" && !!theme) || (!!attrs && key in attrs) || Reflect.has(props, key),\n ownKeys: ({ props, theme, attrs }) => {\n const keys = new Set(Reflect.ownKeys(props));\n if (attrs) for (const key of Reflect.ownKeys(attrs)) keys.add(key);\n if (theme) keys.add(\"theme\");\n return [...keys];\n },\n getOwnPropertyDescriptor: ({ props, theme, attrs }, key) => {\n if (key === \"theme\" && theme && !(\"theme\" in props)) {\n return { value: theme, enumerable: true, configurable: true };\n }\n const descriptor = Reflect.getOwnPropertyDescriptor(attrs && key in attrs ? attrs : props, key);\n // a prop the view adds must report configurable, the backing object has no such key\n return descriptor && { ...descriptor, configurable: true };\n },\n};\n\n/**\n * the provider theme when props has none. a props proxy (a reactive spread)\n * can gain or lose its theme key later, so it always gets the view; a plain\n * object with a theme is used as is\n */\nconst withTheme = (props: Props, theme: Accessor<YakTheme>): Props =>\n (!($PROXY in props) && \"theme\" in props\n ? props\n : new Proxy({ props, theme }, viewTraps)) as Props;\n\n/** style interpolations read attrs over author props, getters only on demand */\nconst withAttrs = (props: Props, attrs: Props): Props =>\n new Proxy({ props, attrs }, viewTraps) as Props;\n\n/** server stand-in for createMemo: run once, no owner and no node */\nconst once = <T extends object>(fn: () => T): (() => T) => {\n let value: T | undefined;\n return () => (value ??= fn());\n};\n\n/** string styles become objects before css variables are added */\nconst unwrapStyle = (style: StyleObject | string | undefined): StyleObject | undefined => {\n if (typeof style !== \"string\") {\n return style;\n }\n const result: Record<string, string> = {};\n for (const declaration of style.split(\";\")) {\n const colonIndex = declaration.indexOf(\":\");\n if (colonIndex === -1) continue;\n const property = declaration.slice(0, colonIndex).trim();\n const value = declaration.slice(colonIndex + 1).trim();\n if (property && value) {\n result[property] = value;\n }\n }\n return result as StyleObject;\n};\n\n/** no array for a yes/no answer */\nconst hasKeys = (object: object): boolean => {\n for (const _ in object) return true;\n return false;\n};\n\n/** the target's render path, chosen once per styled component */\nconst createTargetRenderer = (\n target: AnyComponent<any> | string,\n attrString: string,\n): TargetRenderer => {\n if (typeof target !== \"string\") {\n return (props, meta) => createComponent(target, targetProps(props, meta));\n }\n if (isServer) {\n const head = `<${target}${attrString}`;\n const closing = VOID_ELEMENTS.test(target) ? undefined : `</${target}>`;\n return (props, meta) => serializeElement(target, head, closing, props, meta);\n }\n return createElementRenderer(target, attrString);\n};\n\n/**\n * the server writer: writes the html string by hand instead of using ssrElement.\n * ssrElement needs a filtered props object with getters to keep the\n * read order, that costs more than writing directly\n */\nconst serializeElement = (\n tag: string,\n head: string,\n closing: string | undefined,\n props: Props,\n meta: RenderMeta,\n): { t: string } => {\n // key first: a prop getter may render a child and take keys\n const hk = ssrHydrationKey();\n // one memo read for class, style and attrs. branch on meta.compute, not\n // on computed, so the static writer makes no call here\n let computed: ComputedStyles | undefined;\n let className: string | undefined;\n if (meta.compute) {\n computed = meta.compute();\n className = computed.class;\n } else {\n className = meta.classOf(props);\n }\n const attrs = computed?.attrs;\n const style = computed?.style;\n const skip = meta.skip;\n let result = head + hk;\n let children: unknown;\n // a textarea's value is its content, like solid's ssrElement writes it\n const textarea = tag === \"textarea\";\n // author keys first, an attrs value wins; then the keys only attrs has.\n // two loops on purpose: one loop over both key sets is slower on the\n // attrs path, it needs a push and a second `in` per key.\n // only the first child prop is read, and none on a void tag: a child\n // getter may render and take hydration keys\n for (const key of Object.keys(props)) {\n if (skip(key)) continue;\n const source = attrs && key in attrs ? attrs : props;\n if (!isChildKey(key, textarea)) result += attribute(key, source[key]);\n else if (children === undefined && closing) children = childContent(tag, key, source[key]);\n }\n if (attrs) {\n for (const key of Object.keys(attrs)) {\n if (skip(key) || key in props) continue;\n if (!isChildKey(key, textarea)) result += attribute(key, attrs[key]);\n else if (children === undefined && closing) children = childContent(tag, key, attrs[key]);\n }\n }\n // generated class names need no escaping, an author or attrs class does\n if (className !== undefined) {\n const generated = computed ? computed.generatedClass : className === meta.unescapedClass;\n result += ` class=\"${generated ? className : ssrClassName(className)}\"`;\n }\n if (style !== undefined) result += ` style=\"${ssrStyle(style as Record<string, string>)}\"`;\n // a void tag has no children: the finished string is the node, no ssr() call.\n // the space keeps an unquoted hydration key from swallowing the slash\n if (!closing) return { t: result + \" />\" };\n // text and finished nodes join in place, as solid's own resolver does.\n // functions, arrays and nodes with pending holes go to ssr(): async wrap,\n // error boundary routing, and the separator marker between adjacent\n // text items so the client can claim two text nodes\n const text = plainContent(children);\n if (text !== undefined) return { t: result + \">\" + text + closing };\n return ssr([result + \">\", closing], children);\n};\n\n/** a prop that becomes the element's content: solid's child properties, and a textarea's value */\nconst isChildKey = (key: string, textarea: boolean) =>\n ChildProperties.has(key) || (textarea && (key === \"value\" || key === \"defaultValue\"));\n\n/**\n * the string a child resolves to without ssr(), else undefined. a server\n * node is { t: html, h?: pending async holes }; one with holes needs ssr()\n */\nconst plainContent = (node: unknown): string | undefined => {\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\") return String(node);\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node !== \"object\" || Array.isArray(node)) return undefined;\n const server = node as { t?: unknown; h?: unknown[] };\n if (server.h && server.h.length > 0) return undefined;\n if (typeof server.t === \"string\") return server.t;\n return undefined;\n};\n\n/**\n * one server attribute with its leading space, the value rules of solid's\n * ssrElement; bakeAttributes applies the same rules once at definition\n */\nconst attribute = (prop: string, value: unknown): string => {\n if (prop === \"style\") return ` style=\"${ssrStyle(value as string)}\"`;\n // class never reaches here, skip drops it; the branch stays, the static\n // writer is slower without it (jit code placement)\n if (prop === \"class\") return ` class=\"${ssrClassName(value as string)}\"`;\n // refs, event handlers and prop: bindings only exist on the client\n if (value == undefined || prop === \"ref\" || prop.startsWith(\"on\") || prop.startsWith(\"prop:\")) {\n return \"\";\n }\n if (typeof value === \"boolean\") return value ? ` ${escape(prop)}` : \"\";\n return value === \"\" ? ` ${escape(prop)}` : ` ${escape(prop)}=\"${escape(value, true)}\"`;\n};\n\n/** raw markup stays as is, every other child value is escaped */\nconst childContent = (tag: string, prop: string, value: unknown): unknown =>\n tag === \"script\" || tag === \"style\" || prop === \"innerHTML\" ? value : escape(value);\n\n/** the cached template for a fixed tag; svg and mathml tags parse inside their namespace root */\nconst createElementTemplate = (tag: string, attrString: string, className?: string) => {\n // atoms can put author names into the static class, so the template escapes it\n const classAttribute = className ? ` class=\"${escapeAttribute(className)}\"` : \"\";\n const opening = `<${tag}${attrString}${classAttribute}>`;\n // flag 2 returns firstChild.firstChild\n // skips the <svg>/<math> wrapper we add so the child parses in its namespace\n if (SVGElements.has(tag) && tag !== \"svg\") return template(`<svg>${opening}`, 2);\n if (MathMLElements.has(tag) && tag !== \"math\") return template(`<math>${opening}`, 2);\n return template(opening);\n};\n\n/**\n * bind a fixed client tag without dynamic()'s per-element memo. hydration\n * claims the server node by key; a fresh mount clones the cached template.\n * solid's SVGElements set lacks a, script, style and title, so a fresh\n * mount makes them html elements even inside an <svg>, as solid's own\n * dynamic() does\n */\nconst createElementRenderer = (tag: string, attrString: string): TargetRenderer => {\n const create = createElementTemplate(tag, attrString);\n return (props, meta) => bindElement(getNextElement(create), props, meta);\n};\n\nconst bindElement = (el: Element, props: Props, meta: RenderMeta): Element => {\n const bound = targetProps(props, meta);\n // a proxy can add children later, so it keeps the child binding\n const skipChildren = !($PROXY in bound) && !(\"children\" in bound);\n // no untrack here: a component body runs untracked\n spread(el, bound, skipChildren);\n // replay events once the element's bindings are ready\n runHydrationEvents();\n return el;\n};\n\n/**\n * the props the target sees: author props, attrs output, computed class and style\n * $-props and the provider theme are hidden. solid's omit() takes fixed key\n * names and $-props are open-ended, so the filter is hand-written\n *\n * plain copy when the keys can't change, proxy when attrs or a reactive\n * spread can add keys and downstream omit() has to notice\n * the copy stays unmarked on purpose, a $PROXY mark makes omit()/merge()\n * wrap it again and every read gets slower\n */\nconst targetProps = (props: Props, meta: RenderMeta): Record<PropertyKey, unknown> => {\n if (!meta.attrsAddKeys && !($PROXY in props)) return copyProps(props, meta);\n return proxyProps(props, meta);\n};\n\n/**\n * copies descriptors without reading them: a getter like icon={<Icon />}\n * renders a child and takes hydration keys, the target reads it in its own\n * order. moving the getter is safe, solid's compiled getters do not depend on `this`\n */\nconst copyProps = (props: Props, meta: RenderMeta): Record<PropertyKey, unknown> => {\n const { compute, classOf } = meta;\n const out: Record<PropertyKey, unknown> = {};\n // string keys only, like solid's omit(): a symbol never reaches the target\n for (const key of Object.getOwnPropertyNames(props)) {\n if (meta.skip(key)) continue;\n const descriptor = Reflect.getOwnPropertyDescriptor(props, key)!;\n if (\"value\" in descriptor && descriptor.enumerable) {\n out[key] = descriptor.value;\n } else {\n Object.defineProperty(out, key, descriptor);\n }\n }\n if (isServer) {\n // the values are final on the server: plain values take the value path\n // in solid's omit() and merge() instead of a getter per read\n if (compute) {\n const computed = compute();\n out.class = computed.class;\n if (computed.style !== undefined) out.style = computed.style;\n } else out.class = classOf(props);\n return out;\n }\n const classFn = compute ? () => compute().class : () => classOf(props);\n const styleFn = styleGetter(compute);\n Object.defineProperty(out, \"class\", {\n get: classFn,\n enumerable: true,\n configurable: true,\n });\n if (styleFn) {\n Object.defineProperty(out, \"style\", { get: styleFn, enumerable: true, configurable: true });\n }\n return out;\n};\n\n/**\n * the style accessor a component target receives, or none\n * on the server the value is final, and a target that spreads its props\n * into ssrElement would write style=\"\" for an undefined one; on the client\n * the accessor stays so the memo can set a style later\n */\nconst styleGetter = (\n compute: (() => ComputedStyles) | undefined,\n): (() => StyleObject | undefined) | undefined => {\n if (!compute) return undefined;\n if (isServer && compute().style === undefined) return undefined;\n return () => compute().style;\n};\n\n/**\n * attrs and reactive spreads can add or remove keys; the $PROXY mark keeps\n * downstream omit() calls reactive\n */\nconst proxyProps = (props: Props, meta: RenderMeta): Record<PropertyKey, unknown> => {\n // trap closures per element on purpose, not shared with viewTraps: solid's\n // for-in hits two traps per key, so a backing object would add an\n // indirection to each\n const { skip, compute, classOf } = meta;\n // meta.attrsAddKeys, not the destructured copy: the read narrows meta.compute\n const attrsProps = () => (meta.attrsAddKeys ? meta.compute().attrs : undefined);\n const classFn = compute ? () => compute().class : () => classOf(props);\n const styleFn = styleGetter(compute);\n const contributed = (key: PropertyKey) =>\n key === \"class\" ? classFn : key === \"style\" ? styleFn : undefined;\n const fromAttrs = (key: PropertyKey) => {\n const attrs = attrsProps();\n return attrs && key in attrs ? attrs : undefined;\n };\n return new Proxy(props, {\n get(target, key, receiver) {\n // the receiver, like solid's own props proxies: solid's spread walks\n // a proxy's keys through its traps only when props[$PROXY] === props\n if (key === $PROXY) return receiver;\n const getter = contributed(key);\n if (getter) return getter();\n if (skip(key)) return undefined;\n const attrs = fromAttrs(key);\n return attrs ? attrs[key] : Reflect.get(target, key);\n },\n has(target, key) {\n if (key === $PROXY) return true;\n if (contributed(key)) return true;\n if (skip(key)) return false;\n return Reflect.has(target, key) || fromAttrs(key) !== undefined;\n },\n ownKeys(target) {\n const keys = new Set<string | symbol>();\n for (const key of Reflect.ownKeys(target)) if (!skip(key)) keys.add(key);\n for (const key of Object.keys(attrsProps() ?? {})) if (!skip(key)) keys.add(key);\n // class and style are always own keys, listed after the author keys and attrs\n keys.add(\"class\");\n if (styleFn) keys.add(\"style\");\n return [...keys];\n },\n getOwnPropertyDescriptor(target, key) {\n const getter = contributed(key);\n if (getter) return { enumerable: true, configurable: true, get: getter };\n if (skip(key)) return undefined;\n const attrs = fromAttrs(key);\n if (attrs) {\n return { enumerable: true, configurable: true, get: () => attrsProps()?.[key] };\n }\n return Reflect.getOwnPropertyDescriptor(target, key);\n },\n });\n};\n","import { ComponentStyles, css } from \"./cssLiteral.js\";\nimport { RuntimeStyleProcessor } from \"./publicStyledApi.js\";\n\n/**\n * Allows to use atomic CSS classes in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, atoms } from \"@yak/solid\";\n *\n * const Button = styled.button<{ $primary?: boolean }>`\n * ${atoms(\"text-teal-600\", \"text-base\", \"rounded-md\")}\n * ${props => props.$primary && atoms(\"shadow-md\")}\n * `;\n * ```\n */\nexport const atoms = <T>(\n ...atoms: (string | RuntimeStyleProcessor<T> | false)[]\n): ComponentStyles<T> => {\n const staticClasses: string[] = [];\n const dynamicFunctions: RuntimeStyleProcessor<T>[] = [];\n\n for (const atom of atoms) {\n if (typeof atom === \"string\") {\n staticClasses.push(...atom.split(\" \"));\n } else if (typeof atom === \"function\") {\n dynamicFunctions.push(atom);\n }\n }\n\n const runtimeFunctions: RuntimeStyleProcessor<T>[] =\n staticClasses.length > 0\n ? [\n (_, classes) => {\n // author strings, not compiler names: the server writer must escape them\n staticClasses.forEach((cls) => classes.add(cls, false));\n },\n ...dynamicFunctions,\n ]\n : dynamicFunctions;\n\n // css() is typed for its compiled arguments; the public type describes the\n // interpolation the author writes before compilation\n return css(...runtimeFunctions) as unknown as ComponentStyles<T>;\n};\n","/**\n * Allows to use CSS keyframe animations in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, keyframes } from \"@yak/solid\";\n *\n * const rotate = keyframes`\n * from {\n * transform: rotate(0deg);\n * }\n * to {\n * transform: rotate(360deg);\n * }\n * `;\n *\n * const Spinner = styled.div`\n * animation: ${rotate} 1s linear infinite;\n * `;\n * ```\n */\nexport const keyframes = <T extends (string | number | bigint)[] = never>(\n styles: TemplateStringsArray,\n ..._dynamic: T\n): string => {\n // during compilation all args of keyframe are compiled\n // to a string which references the animation name\n return styles as any as string;\n};\n","import type { ComponentStyles } from \"./cssLiteral.js\";\nimport type { YakComponent } from \"./publicStyledApi.js\";\n\n/**\n * Values that may be interpolated into a `globalStyle` template.\n *\n * Only build-time values are allowed: constants, `keyframes` animation names,\n * static `css` mixins and styled-component selectors. Runtime functions\n * (`${(props) => ...}`) are intentionally excluded: a global rule has no element\n * to attach a CSS variable to. Declare a CSS custom property instead and toggle\n * it via an attribute/class on the root element.\n */\nexport type GlobalStyleInterpolation = string | number | ComponentStyles<{}> | YakComponent<any>;\n\n/**\n * Declares global, unscoped styles that ride the same zero-runtime extraction\n * pipeline as `styled` and `keyframes`.\n *\n * Global styles are **part of the stylesheet, not part of the render tree**.\n * They apply exactly when the module declaring them is included in the bundle,\n * typically by importing it from a layout or entry point. They cannot be\n * conditionally mounted; express conditions in CSS (`@media`, `@supports`,\n * `:root[data-theme]`, `:has()`) or through CSS custom properties.\n *\n * @usage\n *\n * ```tsx\n * import { globalStyle, keyframes } from \"@yak/solid\";\n *\n * const fadeIn = keyframes`\n * from { opacity: 0; }\n * `;\n *\n * globalStyle`\n * :root {\n * --spacing: 4px;\n * }\n *\n * body {\n * margin: 0;\n * }\n *\n * ::view-transition-new(root) {\n * animation: ${fadeIn} 200ms ease;\n * }\n * `;\n * ```\n */\nexport const globalStyle = (\n _styles: TemplateStringsArray,\n ..._values: Array<GlobalStyleInterpolation>\n): void => {\n return undefined;\n};\n","/**\n * Internal helper called by transformed code. Do not use directly.\n *\n * Takes a function and a css unit and returns the result of the function concatenated with the unit\n *\n * ```tsx\n * import { styled } from \"@yak/solid\";\n *\n * const Button = styled.button<{ $width?: boolean }>`\n * width: ${({ $width }) => $width}px;\n * `;\n * ```\n *\n * Which will be transformed to:\n * ```tsx\n * import { styled } from \"@yak/solid/internal\";\n *\n * const Button = styled.button<{ $width?: boolean }>(\n * \"button\", {\n * width: unitPostFix({ $width }) => $width, \"px\")\n * });\n */\nexport const unitPostFix = (arg: unknown, unit: string) => {\n switch (typeof arg) {\n case \"function\":\n return (props: any) => unitPostFix(arg(props), unit);\n case \"number\":\n case \"string\":\n return `${arg}${unit}`;\n // Ignore falsy values\n default:\n return undefined;\n }\n};\n","import { isServer } from \"@solidjs/web\";\nimport { Classes } from \"../cssLiteral.js\";\nimport { RuntimeStyleProcessor, StyleObject } from \"../publicStyledApi.js\";\nimport { normalizeClass } from \"./mergeClasses.js\";\n\ntype Source = Record<PropertyKey, unknown>;\n\n/** the last source that carries the key */\nconst lastWith = (sources: Source[], key: string): Source | undefined => {\n for (let index = sources.length - 1; index >= 0; index--) {\n if (key in sources[index]) return sources[index];\n }\n return undefined;\n};\n\n/**\n * Merges the relevant props of a native element with a css prop. The\n * compiler adds it for the `css` prop:\n * ```tsx\n * <button class=\"a\" {...props} style={s} css={css`color: green;`} />\n * ```\n * compiles to\n * ```tsx\n * <button {...__yak_mergeCssProp(css(\"yak1\"), { class: \"a\" }, props, { style: s })} />\n * ```\n */\nexport const mergeCssProp = (\n cssProp: RuntimeStyleProcessor<unknown> | false | null | undefined,\n ...sources: (Source | null | undefined)[]\n) => {\n const present = sources.filter((source): source is Source => source != null);\n const out: Source = {};\n for (const source of present) {\n for (const key of Reflect.ownKeys(source)) {\n // contributed below, from the last source that carries them\n if (key === \"class\" || key === \"style\") continue;\n const descriptor = Reflect.getOwnPropertyDescriptor(source, key)!;\n if (descriptor.get || descriptor.set || !descriptor.enumerable) {\n Object.defineProperty(out, key, descriptor);\n } else {\n out[key] = descriptor.value;\n }\n }\n }\n // `in` finds the owner without invoking its getter\n const classOwner = lastWith(present, \"class\");\n const styleOwner = lastWith(present, \"style\");\n\n const mergedClass = (): string | undefined => {\n const classes = new Classes(normalizeClass(classOwner?.class));\n // a falsy css prop applies no styles, e.g. `css={on && css`...`}` with `on` false\n if (cssProp) cssProp({}, classes, {} as StyleObject);\n return classes.value || undefined;\n };\n const mergedStyle = (): StyleObject | undefined => {\n const base = styleOwner?.style as StyleObject | undefined;\n const style: StyleObject = base ? { ...base } : {};\n if (cssProp) cssProp({}, new Classes(), style);\n for (const _ in style) return style;\n return undefined;\n };\n\n if (isServer) {\n // The server reads once, so the values are resolved here; a class or\n // style read takes no hydration id. A key left undefined would make\n // `ssrElement` write `class=\"\"`, so only carried values are set.\n const className = mergedClass();\n if (className !== undefined) out.class = className;\n const style = mergedStyle();\n if (style !== undefined) out.style = style;\n return out;\n }\n // on the client the spread reads these inside its effect, so a signal read\n // by a source or by the css prop updates the attribute in place\n if (cssProp || classOwner) {\n Object.defineProperty(out, \"class\", { get: mergedClass, enumerable: true, configurable: true });\n }\n if (cssProp || styleOwner) {\n Object.defineProperty(out, \"style\", { get: mergedStyle, enumerable: true, configurable: true });\n }\n return out;\n};\n","import { styled } from \"./styled.js\";\n/// Internal API to create styled components\n/// Optimization for faster rendering and smaller bundle size in production\n/// thanks to better minification and dead code elimination\n///\n/// List taken from https://github.com/styled-components/styled-components/blob/e0019ba666fab4b5aaa2bff71ba6ad0005a299fd/packages/styled-components/src/utils/domElements.ts#L90\nexport const __yak_a = /*#__PURE__*/ styled(\"a\");\nexport const __yak_abbr = /*#__PURE__*/ styled(\"abbr\");\nexport const __yak_address = /*#__PURE__*/ styled(\"address\");\nexport const __yak_area = /*#__PURE__*/ styled(\"area\");\nexport const __yak_article = /*#__PURE__*/ styled(\"article\");\nexport const __yak_aside = /*#__PURE__*/ styled(\"aside\");\nexport const __yak_audio = /*#__PURE__*/ styled(\"audio\");\nexport const __yak_b = /*#__PURE__*/ styled(\"b\");\nexport const __yak_base = /*#__PURE__*/ styled(\"base\");\nexport const __yak_bdi = /*#__PURE__*/ styled(\"bdi\");\nexport const __yak_bdo = /*#__PURE__*/ styled(\"bdo\");\nexport const __yak_big = /*#__PURE__*/ styled(\"big\");\nexport const __yak_blockquote = /*#__PURE__*/ styled(\"blockquote\");\nexport const __yak_body = /*#__PURE__*/ styled(\"body\");\nexport const __yak_br = /*#__PURE__*/ styled(\"br\");\nexport const __yak_button = /*#__PURE__*/ styled(\"button\");\nexport const __yak_canvas = /*#__PURE__*/ styled(\"canvas\");\nexport const __yak_caption = /*#__PURE__*/ styled(\"caption\");\nexport const __yak_cite = /*#__PURE__*/ styled(\"cite\");\nexport const __yak_code = /*#__PURE__*/ styled(\"code\");\nexport const __yak_col = /*#__PURE__*/ styled(\"col\");\nexport const __yak_colgroup = /*#__PURE__*/ styled(\"colgroup\");\nexport const __yak_data = /*#__PURE__*/ styled(\"data\");\nexport const __yak_datalist = /*#__PURE__*/ styled(\"datalist\");\nexport const __yak_dd = /*#__PURE__*/ styled(\"dd\");\nexport const __yak_del = /*#__PURE__*/ styled(\"del\");\nexport const __yak_details = /*#__PURE__*/ styled(\"details\");\nexport const __yak_dfn = /*#__PURE__*/ styled(\"dfn\");\nexport const __yak_dialog = /*#__PURE__*/ styled(\"dialog\");\nexport const __yak_div = /*#__PURE__*/ styled(\"div\");\nexport const __yak_dl = /*#__PURE__*/ styled(\"dl\");\nexport const __yak_dt = /*#__PURE__*/ styled(\"dt\");\nexport const __yak_em = /*#__PURE__*/ styled(\"em\");\nexport const __yak_embed = /*#__PURE__*/ styled(\"embed\");\nexport const __yak_fieldset = /*#__PURE__*/ styled(\"fieldset\");\nexport const __yak_figcaption = /*#__PURE__*/ styled(\"figcaption\");\nexport const __yak_figure = /*#__PURE__*/ styled(\"figure\");\nexport const __yak_footer = /*#__PURE__*/ styled(\"footer\");\nexport const __yak_form = /*#__PURE__*/ styled(\"form\");\nexport const __yak_h1 = /*#__PURE__*/ styled(\"h1\");\nexport const __yak_h2 = /*#__PURE__*/ styled(\"h2\");\nexport const __yak_h3 = /*#__PURE__*/ styled(\"h3\");\nexport const __yak_h4 = /*#__PURE__*/ styled(\"h4\");\nexport const __yak_h5 = /*#__PURE__*/ styled(\"h5\");\nexport const __yak_h6 = /*#__PURE__*/ styled(\"h6\");\nexport const __yak_header = /*#__PURE__*/ styled(\"header\");\nexport const __yak_hgroup = /*#__PURE__*/ styled(\"hgroup\");\nexport const __yak_hr = /*#__PURE__*/ styled(\"hr\");\nexport const __yak_html = /*#__PURE__*/ styled(\"html\");\nexport const __yak_i = /*#__PURE__*/ styled(\"i\");\nexport const __yak_iframe = /*#__PURE__*/ styled(\"iframe\");\nexport const __yak_img = /*#__PURE__*/ styled(\"img\");\nexport const __yak_input = /*#__PURE__*/ styled(\"input\");\nexport const __yak_ins = /*#__PURE__*/ styled(\"ins\");\nexport const __yak_kbd = /*#__PURE__*/ styled(\"kbd\");\nexport const __yak_keygen = /*#__PURE__*/ styled(\"keygen\");\nexport const __yak_label = /*#__PURE__*/ styled(\"label\");\nexport const __yak_legend = /*#__PURE__*/ styled(\"legend\");\nexport const __yak_li = /*#__PURE__*/ styled(\"li\");\nexport const __yak_link = /*#__PURE__*/ styled(\"link\");\nexport const __yak_main = /*#__PURE__*/ styled(\"main\");\nexport const __yak_map = /*#__PURE__*/ styled(\"map\");\nexport const __yak_mark = /*#__PURE__*/ styled(\"mark\");\nexport const __yak_menu = /*#__PURE__*/ styled(\"menu\");\nexport const __yak_menuitem = /*#__PURE__*/ styled(\"menuitem\");\nexport const __yak_meta = /*#__PURE__*/ styled(\"meta\");\nexport const __yak_meter = /*#__PURE__*/ styled(\"meter\");\nexport const __yak_nav = /*#__PURE__*/ styled(\"nav\");\nexport const __yak_noscript = /*#__PURE__*/ styled(\"noscript\");\nexport const __yak_object = /*#__PURE__*/ styled(\"object\");\nexport const __yak_ol = /*#__PURE__*/ styled(\"ol\");\nexport const __yak_optgroup = /*#__PURE__*/ styled(\"optgroup\");\nexport const __yak_option = /*#__PURE__*/ styled(\"option\");\nexport const __yak_output = /*#__PURE__*/ styled(\"output\");\nexport const __yak_p = /*#__PURE__*/ styled(\"p\");\nexport const __yak_param = /*#__PURE__*/ styled(\"param\");\nexport const __yak_picture = /*#__PURE__*/ styled(\"picture\");\nexport const __yak_pre = /*#__PURE__*/ styled(\"pre\");\nexport const __yak_progress = /*#__PURE__*/ styled(\"progress\");\nexport const __yak_q = /*#__PURE__*/ styled(\"q\");\nexport const __yak_rp = /*#__PURE__*/ styled(\"rp\");\nexport const __yak_rt = /*#__PURE__*/ styled(\"rt\");\nexport const __yak_ruby = /*#__PURE__*/ styled(\"ruby\");\nexport const __yak_s = /*#__PURE__*/ styled(\"s\");\nexport const __yak_samp = /*#__PURE__*/ styled(\"samp\");\nexport const __yak_script = /*#__PURE__*/ styled(\"script\");\nexport const __yak_section = /*#__PURE__*/ styled(\"section\");\nexport const __yak_select = /*#__PURE__*/ styled(\"select\");\nexport const __yak_small = /*#__PURE__*/ styled(\"small\");\nexport const __yak_source = /*#__PURE__*/ styled(\"source\");\nexport const __yak_span = /*#__PURE__*/ styled(\"span\");\nexport const __yak_strong = /*#__PURE__*/ styled(\"strong\");\nexport const __yak_style = /*#__PURE__*/ styled(\"style\");\nexport const __yak_sub = /*#__PURE__*/ styled(\"sub\");\nexport const __yak_summary = /*#__PURE__*/ styled(\"summary\");\nexport const __yak_sup = /*#__PURE__*/ styled(\"sup\");\nexport const __yak_table = /*#__PURE__*/ styled(\"table\");\nexport const __yak_tbody = /*#__PURE__*/ styled(\"tbody\");\nexport const __yak_td = /*#__PURE__*/ styled(\"td\");\nexport const __yak_textarea = /*#__PURE__*/ styled(\"textarea\");\nexport const __yak_tfoot = /*#__PURE__*/ styled(\"tfoot\");\nexport const __yak_th = /*#__PURE__*/ styled(\"th\");\nexport const __yak_thead = /*#__PURE__*/ styled(\"thead\");\nexport const __yak_time = /*#__PURE__*/ styled(\"time\");\nexport const __yak_tr = /*#__PURE__*/ styled(\"tr\");\nexport const __yak_track = /*#__PURE__*/ styled(\"track\");\nexport const __yak_u = /*#__PURE__*/ styled(\"u\");\nexport const __yak_ul = /*#__PURE__*/ styled(\"ul\");\nexport const __yak_use = /*#__PURE__*/ styled(\"use\");\nexport const __yak_var = /*#__PURE__*/ styled(\"var\");\nexport const __yak_video = /*#__PURE__*/ styled(\"video\");\nexport const __yak_wbr = /*#__PURE__*/ styled(\"wbr\");\nexport const __yak_circle = /*#__PURE__*/ styled(\"circle\");\nexport const __yak_clipPath = /*#__PURE__*/ styled(\"clipPath\");\nexport const __yak_defs = /*#__PURE__*/ styled(\"defs\");\nexport const __yak_ellipse = /*#__PURE__*/ styled(\"ellipse\");\nexport const __yak_foreignObject = /*#__PURE__*/ styled(\"foreignObject\");\nexport const __yak_g = /*#__PURE__*/ styled(\"g\");\nexport const __yak_image = /*#__PURE__*/ styled(\"image\");\nexport const __yak_line = /*#__PURE__*/ styled(\"line\");\nexport const __yak_linearGradient = /*#__PURE__*/ styled(\"linearGradient\");\nexport const __yak_marker = /*#__PURE__*/ styled(\"marker\");\nexport const __yak_mask = /*#__PURE__*/ styled(\"mask\");\nexport const __yak_path = /*#__PURE__*/ styled(\"path\");\nexport const __yak_pattern = /*#__PURE__*/ styled(\"pattern\");\nexport const __yak_polygon = /*#__PURE__*/ styled(\"polygon\");\nexport const __yak_polyline = /*#__PURE__*/ styled(\"polyline\");\nexport const __yak_radialGradient = /*#__PURE__*/ styled(\"radialGradient\");\nexport const __yak_rect = /*#__PURE__*/ styled(\"rect\");\nexport const __yak_stop = /*#__PURE__*/ styled(\"stop\");\nexport const __yak_svg = /*#__PURE__*/ styled(\"svg\");\nexport const __yak_text = /*#__PURE__*/ styled(\"text\");\nexport const __yak_tspan = /*#__PURE__*/ styled(\"tspan\");\n"],"mappings":";;;;;AAOA,MAAa,qBAAqB,OAAO,IAAI,sBAAsB;AAUnE,IAAa,UAAb,MAA+C;CAC7C;CAMA,YAAY;CACZ,YAAY,SAAkB;EAC5B,KAAK,QAAQ,WAAW;CAC1B;CACA,IAAI,MAAc,YA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AAO,QAAQ;AACzD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,gBAA8B,qBAAO,SAAS;AAC3D,MAAa,gBAA8B,qBAAO,SAAS;AAC3D,MAAa,iBAA+B,qBAAO,UAAU;AAC7D,MAAa,uBAAqC,qBAAO,gBAAgB;AACzE,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,YAA0B,qBAAO,KAAK;AACnD,MAAa,aAA2B,qBAAO,MAAM;AACrD,MAAa,cAA4B,qBAAO,OAAO"}
@@ -38,7 +38,9 @@ function resolveWorkerPath() {
38
38
  return fileURLToPath(new URL("./worker.ts", import.meta.url));
39
39
  }
40
40
  function bootWorker() {
41
- const worker = new Worker(resolveWorkerPath(), { workerData: { loaderDataUrl: createLoaderDataUrl() } });
41
+ const workerPath = resolveWorkerPath();
42
+ const loaderDataUrl = createLoaderDataUrl();
43
+ const worker = new Worker(workerPath, { workerData: { loaderDataUrl } });
42
44
  return {
43
45
  worker,
44
46
  ready: new Promise((resolve) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../yak-internals/isolated-source-eval/loader-hooks.ts","../../../yak-internals/isolated-source-eval/evaluator.ts"],"sourcesContent":["/**\n * ESM loader hook source, embedded as a string constant.\n *\n * This MUST be plain JavaScript — not TypeScript. The loader thread receives\n * this code via a `data:` URL passed to `module.register()`. Node's loader\n * thread does not run data: URLs through strip-types, so any TypeScript\n * syntax here would cause a SyntaxError at registration time.\n *\n * The hook uses a MessagePort (received in `initialize`) to communicate\n * collected dependencies back to the worker thread on demand. Dependencies\n * are accumulated in a Set during `resolve()` calls, then flushed as a\n * batch when the worker requests them after an evaluation completes. This\n * batching avoids per-import message overhead and keeps dependency tracking\n * tightly coupled to a single evaluation.\n *\n * Only `file://` URLs outside of `node_modules` are tracked. Node built-ins\n * (`node:*`) and third-party packages are excluded because consumers only\n * need to invalidate on project source file changes.\n *\n * `fileURLToPath` converts `file://` URLs into platform-correct absolute\n * paths (avoids the leading-slash issue `URL.pathname` has on Windows).\n */\nconst LOADER_HOOK_SOURCE = `\nimport { fileURLToPath } from \"node:url\";\n\nlet port;\nconst deps = new Set();\n\nexport function initialize(data) {\n port = data.port;\n port.on(\"message\", (msg) => {\n if (msg === \"getDeps\") {\n port.postMessage([...deps]);\n deps.clear();\n }\n });\n}\n\nexport async function resolve(specifier, context, nextResolve) {\n const result = await nextResolve(specifier);\n if (result.url.startsWith(\"file://\") && !result.url.includes(\"/node_modules/\")) {\n deps.add(fileURLToPath(result.url));\n }\n return result;\n}\n`;\n\n/**\n * Pre-computed data URL for the loader hook source.\n *\n * The same URL is reused across workers — each `module.register()` call\n * creates an independent loader instance with its own dependency Set\n * regardless of URL identity.\n */\nconst LOADER_DATA_URL = `data:text/javascript;base64,${Buffer.from(LOADER_HOOK_SOURCE).toString(\"base64\")}`;\n\n/** Returns the loader hook as a base64 `data:` URL. */\nexport function createLoaderDataUrl(): string {\n return LOADER_DATA_URL;\n}\n","import { existsSync } from \"node:fs\";\nimport { isAbsolute } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Worker } from \"node:worker_threads\";\nimport { createLoaderDataUrl } from \"./loader-hooks.ts\";\n\nexport type EvaluateResult =\n | { ok: true; value: Record<string, unknown>; dependencies: string[] }\n | { ok: false; error: { message: string; stack: string } };\n\nexport interface Evaluator {\n /** Evaluate a module and return its exports plus the full transitive dependency list. */\n evaluate(absolutePath: string): Promise<EvaluateResult>;\n /** Clear cached results for every entry point that transitively depends on the given file(s). */\n invalidate(...absolutePaths: string[]): void;\n /** Clear the entire result cache and swap workers. */\n invalidateAll(): void;\n /** Return entry point paths that would be affected by invalidate(absolutePath). */\n getDependentsOf(absolutePath: string): string[];\n /** Terminate both workers and reject any pending evaluations. */\n dispose(): Promise<void>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n\n/** Wire format for messages from the worker back to the main thread. */\ntype WorkerResult =\n | {\n type: \"result\";\n id: number;\n ok: true;\n value: Record<string, unknown>;\n dependencies: string[];\n }\n | {\n type: \"result\";\n id: number;\n ok: false;\n error: { message: string; stack: string };\n dependencies: string[];\n };\n\ninterface PendingEvaluation {\n id: number;\n absolutePath: string;\n resolve: (result: EvaluateResult) => void;\n reject: (error: Error) => void;\n /** Number of times this evaluation has been retried due to staleness detection. */\n retryCount: number;\n}\n\n/**\n * Resolves the worker entry point path.\n *\n * In production the compiled `.js` file exists in `dist/` — we prefer that.\n * During development (vitest runs against source), only the `.ts` file exists.\n * Node 22.18.0+ handles `.ts` natively via strip-types, so the fallback works\n * without any flags or loaders.\n */\nfunction resolveWorkerPath(): string {\n const jsPath = fileURLToPath(new URL(\"./worker.js\", import.meta.url));\n if (existsSync(jsPath)) {\n return jsPath;\n }\n return fileURLToPath(new URL(\"./worker.ts\", import.meta.url));\n}\n\n/**\n * Boots a worker and returns a handle with a ready promise.\n *\n * The loader hook data URL is passed via `workerData` rather than having\n * the worker import it from a sibling module. This avoids a module\n * resolution mismatch: source files use `.ts` extensions (required by\n * Node strip-types) while compiled output uses `.js` (rewritten by tsc\n * via `rewriteRelativeImportExtensions`). Since the worker file would need\n * to import loader-hooks with the right extension for its context, passing\n * the data URL through workerData eliminates the problem entirely.\n */\nfunction bootWorker(): { worker: Worker; ready: Promise<void> } {\n const workerPath = resolveWorkerPath();\n const loaderDataUrl = createLoaderDataUrl();\n const worker = new Worker(workerPath, {\n workerData: { loaderDataUrl },\n });\n const ready = new Promise<void>((resolve) => {\n const onMessage = (msg: { type: string }) => {\n if (msg.type === \"ready\") {\n worker.off(\"message\", onMessage);\n resolve();\n }\n };\n worker.on(\"message\", onMessage);\n });\n return { worker, ready };\n}\n\n/** Default timeout for a single evaluation in milliseconds. */\nconst DEFAULT_EVAL_TIMEOUT_MS = 30_000;\n\n/** Maximum number of staleness retries before giving up with an error. */\nconst MAX_STALENESS_RETRIES = 3;\n\n/** Creates an evaluator that runs modules in isolated worker threads with dependency tracking. */\nexport async function createEvaluator(): Promise<Evaluator> {\n const resultCache = new Map<string, EvaluateResult>();\n /**\n * Tracks in-flight evaluation promises by path. When `evaluate()` is called\n * for a path that's already queued or being evaluated, the same promise is\n * returned instead of queuing a duplicate. This prevents a second worker\n * evaluation from producing incomplete dependencies (the ESM resolve hook\n * only fires on cache misses — a second import on the same worker would\n * miss transitive deps that are already in the ESM cache).\n */\n const inflight = new Map<string, Promise<EvaluateResult>>();\n\n /**\n * Two dependency maps provide O(1) lookups in both directions:\n *\n * - `reverseDeps`: file path → set of entry points that depend on it.\n * Consulted during `invalidate()` to find which cached results to clear.\n *\n * - `forwardDeps`: entry point → set of all its transitive dependencies.\n * Needed to clean up stale reverse entries when an entry point is\n * re-evaluated and its dependency tree has changed (e.g. an import\n * was removed). Without this, removed dependencies would accumulate\n * phantom reverse entries that never get cleaned up.\n */\n const reverseDeps = new Map<string, Set<string>>();\n const forwardDeps = new Map<string, Set<string>>();\n\n let nextId = 0;\n let currentEval: PendingEvaluation | null = null;\n let currentTimeout: ReturnType<typeof setTimeout> | null = null;\n const queue: PendingEvaluation[] = [];\n /**\n * Tracks files passed to `invalidate()` while an evaluation is in-flight.\n * When an evaluation completes, `handleResult()` checks whether any reported\n * dependency intersects this set. If so, the result is stale — it's discarded,\n * workers are swapped, and the evaluation is retried on a clean worker.\n *\n * This closes the \"cold start\" gap: if `evaluate(\"A\")` is dispatched before\n * `invalidate(\"B\")` is called, and A depends on B, the dependency graph\n * doesn't know about A→B yet. Without this set, the invalidation would be\n * silently missed.\n *\n * Cleared in `swapWorkers()` because the new primary has a clean ESM cache.\n */\n const invalidatedDuringEval = new Set<string>();\n let disposed = false;\n\n /**\n * Two workers are maintained at all times:\n *\n * - **primary**: handles all evaluate() calls. Accumulates Node's ESM\n * module cache over time, making repeated evaluations fast (~1-3ms).\n *\n * - **shadow**: pre-booted but completely idle. Never evaluates anything,\n * so its module cache stays empty. On invalidation, the primary is\n * terminated (stale cache) and the shadow is promoted to primary\n * instantly (no boot latency). A new shadow is booted in the background.\n *\n * This pattern trades ~30ms of background boot time for instant\n * invalidation. The alternative — reusing a single worker and clearing\n * its ESM cache — isn't possible because Node doesn't expose an API\n * to clear the module cache.\n */\n let primary = bootWorker();\n let shadow = bootWorker();\n\n await Promise.all([primary.ready, shadow.ready]);\n\n /**\n * Allow the process to exit naturally when the event loop is otherwise empty.\n * Without this, the workers keep the event loop alive indefinitely — causing\n * hangs in multi-environment Vite builds where no hook reliably disposes\n * the evaluator after all environments are done.\n * Must be called after setupMessageHandler since .on() can re-ref the worker.\n */\n function unrefWorkers(primaryWorker: Worker, shadowWorker: Worker) {\n primaryWorker.unref();\n shadowWorker.unref();\n }\n\n function setupMessageHandler(workerObj: { worker: Worker }) {\n workerObj.worker.on(\"message\", (msg: WorkerResult) => {\n if (msg.type !== \"result\") return;\n handleResult(msg);\n });\n\n workerObj.worker.on(\"error\", (err: Error) => {\n if (currentEval) {\n clearEvalTimeout();\n const pending = currentEval;\n currentEval = null;\n const result: EvaluateResult = {\n ok: false,\n error: { message: err.message, stack: err.stack ?? \"\" },\n };\n updateDeps(pending.absolutePath, [pending.absolutePath]);\n resultCache.set(pending.absolutePath, result);\n inflight.delete(pending.absolutePath);\n pending.resolve(result);\n processQueue();\n }\n });\n }\n\n setupMessageHandler(primary);\n unrefWorkers(primary.worker, shadow.worker);\n\n function clearEvalTimeout() {\n if (currentTimeout !== null) {\n clearTimeout(currentTimeout);\n currentTimeout = null;\n }\n }\n\n function handleResult(msg: WorkerResult) {\n if (!currentEval) return;\n if (msg.id !== currentEval.id) return;\n\n clearEvalTimeout();\n\n const pending = currentEval;\n currentEval = null;\n\n // Staleness check: if a file was invalidated while this evaluation was\n // in-flight and the result depends on it, discard the result and retry\n // on a clean worker. Only checked for successes — errors don't report\n // deps, and the file watcher will trigger another invalidation when the\n // source is fixed.\n if (msg.ok && invalidatedDuringEval.size > 0) {\n const isStale = msg.dependencies.some((dep) => invalidatedDuringEval.has(dep));\n if (isStale) {\n if (pending.retryCount >= MAX_STALENESS_RETRIES) {\n pending.resolve({\n ok: false,\n error: {\n message: `Evaluation of ${pending.absolutePath} exceeded maximum staleness retries (${MAX_STALENESS_RETRIES})`,\n stack: \"\",\n },\n });\n processQueue();\n return;\n }\n pending.retryCount++;\n swapWorkers();\n queue.unshift(pending);\n processQueue();\n return;\n }\n }\n\n let result: EvaluateResult;\n if (msg.ok) {\n result = { ok: true, value: msg.value, dependencies: msg.dependencies };\n updateDeps(pending.absolutePath, msg.dependencies);\n } else {\n result = { ok: false, error: msg.error };\n // Use the partial dependencies reported by the worker (files resolved\n // before the error). This ensures transitive deps are registered in\n // reverseDeps so that fixing a broken file triggers re-evaluation.\n updateDeps(pending.absolutePath, msg.dependencies);\n }\n\n resultCache.set(pending.absolutePath, result);\n inflight.delete(pending.absolutePath);\n pending.resolve(result);\n processQueue();\n }\n\n /**\n * Reconciles the dependency graph after an evaluation.\n *\n * First removes all old reverse entries for this entry point (using\n * forwardDeps as the source of truth), then writes the new forward\n * and reverse mappings. This ensures that if a dependency was removed\n * between evaluations, it no longer points back to this entry point.\n */\n function updateDeps(entryPoint: string, deps: string[]) {\n const oldDeps = forwardDeps.get(entryPoint);\n if (oldDeps) {\n for (const dep of oldDeps) {\n const entries = reverseDeps.get(dep);\n if (entries) {\n entries.delete(entryPoint);\n if (entries.size === 0) {\n reverseDeps.delete(dep);\n }\n }\n }\n }\n\n const depSet = new Set(deps);\n forwardDeps.set(entryPoint, depSet);\n\n for (const dep of depSet) {\n let entries = reverseDeps.get(dep);\n if (!entries) {\n entries = new Set();\n reverseDeps.set(dep, entries);\n }\n entries.add(entryPoint);\n }\n }\n\n /**\n * Evaluations are serialized — one at a time per worker. This prevents\n * interleaved dependency tracking: the loader hook accumulates deps in\n * a single Set and flushes it after each evaluation. Concurrent imports\n * would mix dependencies from different entry points.\n *\n * Waits for the primary worker to be ready before sending work. This\n * matters after a swap: the promoted shadow may still be booting.\n */\n function processQueue() {\n if (currentEval || queue.length === 0 || disposed) return;\n\n const next = queue.shift()!;\n\n // A prior evaluation for the same path may have completed and cached\n // while this item was queued (e.g. after invalidation + re-queue).\n // Resolving from cache avoids dispatching to a worker where the module\n // is already in the ESM cache (which would produce incomplete deps).\n const alreadyCached = resultCache.get(next.absolutePath);\n if (alreadyCached) {\n inflight.delete(next.absolutePath);\n next.resolve(alreadyCached);\n processQueue();\n return;\n }\n\n currentEval = next;\n\n primary.ready.then(() => {\n if (disposed || currentEval !== next) return;\n primary.worker.postMessage({\n type: \"evaluate\",\n id: next.id,\n absolutePath: next.absolutePath,\n });\n\n currentTimeout = setTimeout(() => {\n if (currentEval !== next) return;\n currentEval = null;\n currentTimeout = null;\n\n const result: EvaluateResult = {\n ok: false,\n error: {\n message: `Evaluation of ${next.absolutePath} timed out after ${DEFAULT_EVAL_TIMEOUT_MS}ms`,\n stack: \"\",\n },\n };\n updateDeps(next.absolutePath, [next.absolutePath]);\n resultCache.set(next.absolutePath, result);\n inflight.delete(next.absolutePath);\n next.resolve(result);\n\n swapWorkers();\n processQueue();\n }, DEFAULT_EVAL_TIMEOUT_MS);\n });\n }\n\n /**\n * Terminates the primary (stale module cache), promotes the shadow\n * (clean cache, instant), and boots a new shadow in the background.\n *\n * `removeAllListeners` prevents the terminated worker from delivering\n * late messages or error events that would confuse the result handler.\n */\n function swapWorkers() {\n primary.worker.removeAllListeners();\n primary.worker.terminate();\n\n primary = shadow;\n setupMessageHandler(primary);\n\n shadow = bootWorker();\n unrefWorkers(primary.worker, shadow.worker);\n\n // The new primary has a clean ESM cache, so any previously tracked\n // invalidations are no longer relevant — the fresh worker will\n // re-import everything from disk.\n invalidatedDuringEval.clear();\n }\n\n function evaluate(absolutePath: string): Promise<EvaluateResult> {\n if (disposed) {\n return Promise.reject(new Error(\"Evaluator has been disposed\"));\n }\n\n if (!isAbsolute(absolutePath)) {\n return Promise.reject(\n new Error(`evaluate() requires an absolute path, got: ${absolutePath}`),\n );\n }\n\n const cached = resultCache.get(absolutePath);\n if (cached) {\n return Promise.resolve(cached);\n }\n\n // Deduplicate: if an evaluation is already queued or in-flight for this\n // path, return the same promise. This prevents a second worker evaluation\n // that would produce incomplete dependencies (the ESM resolve hook only\n // fires on cache misses).\n const pending = inflight.get(absolutePath);\n if (pending) return pending;\n\n const promise = new Promise<EvaluateResult>((resolve, reject) => {\n const id = nextId++;\n queue.push({ id, absolutePath, resolve, reject, retryCount: 0 });\n processQueue();\n });\n\n inflight.set(absolutePath, promise);\n return promise;\n }\n\n function invalidate(...absolutePaths: string[]): void {\n if (absolutePaths.length === 0) return;\n\n // Track all invalidations for cold-start detection (in-flight evaluations\n // whose dependency graph isn't populated yet).\n for (const path of absolutePaths) {\n invalidatedDuringEval.add(path);\n }\n\n // Collect all affected entry points across all changed files.\n const allEntryPoints = new Set<string>();\n for (const path of absolutePaths) {\n const entryPoints = reverseDeps.get(path);\n if (entryPoints) {\n for (const entry of entryPoints) {\n allEntryPoints.add(entry);\n }\n }\n }\n\n // If no cached entry points are affected, return early. The cold-start\n // set (invalidatedDuringEval) will catch in-flight evaluations.\n if (allEntryPoints.size === 0) return;\n\n // Clear caches and clean dependency graphs for all affected entry points.\n for (const entry of allEntryPoints) {\n resultCache.delete(entry);\n inflight.delete(entry);\n\n const deps = forwardDeps.get(entry);\n if (deps) {\n for (const dep of deps) {\n const entries = reverseDeps.get(dep);\n if (entries) {\n entries.delete(entry);\n if (entries.size === 0) {\n reverseDeps.delete(dep);\n }\n }\n }\n forwardDeps.delete(entry);\n }\n }\n\n // If an evaluation is in-flight on the worker we're about to terminate,\n // capture it and re-queue at the front. The caller's promise will\n // resolve transparently with the result from the promoted shadow worker.\n clearEvalTimeout();\n const inflightEval = currentEval;\n currentEval = null;\n\n swapWorkers();\n\n if (inflightEval) {\n queue.unshift(inflightEval);\n }\n\n processQueue();\n }\n\n function invalidateAll(): void {\n resultCache.clear();\n inflight.clear();\n forwardDeps.clear();\n reverseDeps.clear();\n\n clearEvalTimeout();\n const inflightEval = currentEval;\n currentEval = null;\n\n swapWorkers();\n\n if (inflightEval) {\n queue.unshift(inflightEval);\n }\n\n processQueue();\n }\n\n function getDependentsOf(absolutePath: string): string[] {\n const entryPoints = reverseDeps.get(absolutePath);\n if (!entryPoints) return [];\n return [...entryPoints];\n }\n\n async function dispose(): Promise<void> {\n if (disposed) return;\n disposed = true;\n\n clearEvalTimeout();\n\n if (currentEval) {\n currentEval.reject(new Error(\"Evaluator has been disposed\"));\n currentEval = null;\n }\n for (const pending of queue) {\n pending.reject(new Error(\"Evaluator has been disposed\"));\n }\n queue.length = 0;\n inflight.clear();\n\n await Promise.all([primary.worker.terminate(), shadow.worker.terminate()]);\n }\n\n return {\n evaluate,\n invalidate,\n invalidateAll,\n getDependentsOf,\n dispose,\n [Symbol.asyncDispose]: dispose,\n };\n}\n"],"mappings":";;;;;AAsDA,MAAM,kBAAkB,+BAA+B,OAAO,KAAK;;;;;;;;;;;;;;;;;;;;;;;CAAkB,CAAC,CAAC,SAAS,QAAQ;AAGxG,SAAgB,sBAA8B;CAC5C,OAAO;AACT;;;ACDA,SAAS,oBAA4B;CACnC,MAAM,SAAS,cAAc,IAAI,IAAI,eAAe,OAAO,KAAK,GAAG,CAAC;CACpE,IAAI,WAAW,MAAM,GACnB,OAAO;CAET,OAAO,cAAc,IAAI,IAAI,eAAe,OAAO,KAAK,GAAG,CAAC;AAC9D;AAaA,SAAS,aAAuD;CAG9D,MAAM,SAAS,IAAI,OAFA,kBAEgB,GAAG,EACpC,YAAY,EAAE,eAFM,oBAEM,EAAE,EAC9B,CAAC;CAUD,OAAO;EAAE;EAAQ,OAAA,IATC,SAAe,YAAY;GAC3C,MAAM,aAAa,QAA0B;IAC3C,IAAI,IAAI,SAAS,SAAS;KACxB,OAAO,IAAI,WAAW,SAAS;KAC/B,QAAQ;IACV;GACF;GACA,OAAO,GAAG,WAAW,SAAS;EAChC,CACqB;CAAE;AACzB;AAGA,MAAM,0BAA0B;AAGhC,MAAM,wBAAwB;AAG9B,eAAsB,k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AS,gBAAgB,cAAgC;EACvD,MAAM,cAAc,YAAY,IAAI,YAAY;EAChD,IAAI,CAAC,aAAa,OAAO,CAAC;EAC1B,OAAO,CAAC,GAAG,WAAW;CACxB;CAEA,eAAe,UAAyB;EACtC,IAAI,UAAU;EACd,WAAW;EAEX,iBAAiB;EAEjB,IAAI,aAAa;GACf,YAAY,uBAAO,IAAI,MAAM,6BAA6B,CAAC;GAC3D,cAAc;EAChB;EACA,KAAK,MAAM,WAAW,OACpB,QAAQ,uBAAO,IAAI,MAAM,6BAA6B,CAAC;EAEzD,MAAM,SAAS;EACf,SAAS,MAAM;EAEf,MAAM,QAAQ,IAAI,CAAC,QAAQ,OAAO,UAAU,GAAG,OAAO,OAAO,UAAU,CAAC,CAAC;CAC3E;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;GACC,OAAO,eAAe;CACzB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../yak-internals/isolated-source-eval/loader-hooks.ts","../../../yak-internals/isolated-source-eval/evaluator.ts"],"sourcesContent":["/**\n * ESM loader hook source, embedded as a string constant.\n *\n * This MUST be plain JavaScript — not TypeScript. The loader thread receives\n * this code via a `data:` URL passed to `module.register()`. Node's loader\n * thread does not run data: URLs through strip-types, so any TypeScript\n * syntax here would cause a SyntaxError at registration time.\n *\n * The hook uses a MessagePort (received in `initialize`) to communicate\n * collected dependencies back to the worker thread on demand. Dependencies\n * are accumulated in a Set during `resolve()` calls, then flushed as a\n * batch when the worker requests them after an evaluation completes. This\n * batching avoids per-import message overhead and keeps dependency tracking\n * tightly coupled to a single evaluation.\n *\n * Only `file://` URLs outside of `node_modules` are tracked. Node built-ins\n * (`node:*`) and third-party packages are excluded because consumers only\n * need to invalidate on project source file changes.\n *\n * `fileURLToPath` converts `file://` URLs into platform-correct absolute\n * paths (avoids the leading-slash issue `URL.pathname` has on Windows).\n */\nconst LOADER_HOOK_SOURCE = `\nimport { fileURLToPath } from \"node:url\";\n\nlet port;\nconst deps = new Set();\n\nexport function initialize(data) {\n port = data.port;\n port.on(\"message\", (msg) => {\n if (msg === \"getDeps\") {\n port.postMessage([...deps]);\n deps.clear();\n }\n });\n}\n\nexport async function resolve(specifier, context, nextResolve) {\n const result = await nextResolve(specifier);\n if (result.url.startsWith(\"file://\") && !result.url.includes(\"/node_modules/\")) {\n deps.add(fileURLToPath(result.url));\n }\n return result;\n}\n`;\n\n/**\n * Pre-computed data URL for the loader hook source.\n *\n * The same URL is reused across workers — each `module.register()` call\n * creates an independent loader instance with its own dependency Set\n * regardless of URL identity.\n */\nconst LOADER_DATA_URL = `data:text/javascript;base64,${Buffer.from(LOADER_HOOK_SOURCE).toString(\"base64\")}`;\n\n/** Returns the loader hook as a base64 `data:` URL. */\nexport function createLoaderDataUrl(): string {\n return LOADER_DATA_URL;\n}\n","import { existsSync } from \"node:fs\";\nimport { isAbsolute } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Worker } from \"node:worker_threads\";\nimport { createLoaderDataUrl } from \"./loader-hooks.ts\";\n\nexport type EvaluateResult =\n | { ok: true; value: Record<string, unknown>; dependencies: string[] }\n | { ok: false; error: { message: string; stack: string } };\n\nexport interface Evaluator {\n /** Evaluate a module and return its exports plus the full transitive dependency list. */\n evaluate(absolutePath: string): Promise<EvaluateResult>;\n /** Clear cached results for every entry point that transitively depends on the given file(s). */\n invalidate(...absolutePaths: string[]): void;\n /** Clear the entire result cache and swap workers. */\n invalidateAll(): void;\n /** Return entry point paths that would be affected by invalidate(absolutePath). */\n getDependentsOf(absolutePath: string): string[];\n /** Terminate both workers and reject any pending evaluations. */\n dispose(): Promise<void>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n\n/** Wire format for messages from the worker back to the main thread. */\ntype WorkerResult =\n | {\n type: \"result\";\n id: number;\n ok: true;\n value: Record<string, unknown>;\n dependencies: string[];\n }\n | {\n type: \"result\";\n id: number;\n ok: false;\n error: { message: string; stack: string };\n dependencies: string[];\n };\n\ninterface PendingEvaluation {\n id: number;\n absolutePath: string;\n resolve: (result: EvaluateResult) => void;\n reject: (error: Error) => void;\n /** Number of times this evaluation has been retried due to staleness detection. */\n retryCount: number;\n}\n\n/**\n * Resolves the worker entry point path.\n *\n * In production the compiled `.js` file exists in `dist/` — we prefer that.\n * During development (vitest runs against source), only the `.ts` file exists.\n * Node 22.18.0+ handles `.ts` natively via strip-types, so the fallback works\n * without any flags or loaders.\n */\nfunction resolveWorkerPath(): string {\n const jsPath = fileURLToPath(new URL(\"./worker.js\", import.meta.url));\n if (existsSync(jsPath)) {\n return jsPath;\n }\n return fileURLToPath(new URL(\"./worker.ts\", import.meta.url));\n}\n\n/**\n * Boots a worker and returns a handle with a ready promise.\n *\n * The loader hook data URL is passed via `workerData` rather than having\n * the worker import it from a sibling module. This avoids a module\n * resolution mismatch: source files use `.ts` extensions (required by\n * Node strip-types) while compiled output uses `.js` (rewritten by tsc\n * via `rewriteRelativeImportExtensions`). Since the worker file would need\n * to import loader-hooks with the right extension for its context, passing\n * the data URL through workerData eliminates the problem entirely.\n */\nfunction bootWorker(): { worker: Worker; ready: Promise<void> } {\n const workerPath = resolveWorkerPath();\n const loaderDataUrl = createLoaderDataUrl();\n const worker = new Worker(workerPath, {\n workerData: { loaderDataUrl },\n });\n const ready = new Promise<void>((resolve) => {\n const onMessage = (msg: { type: string }) => {\n if (msg.type === \"ready\") {\n worker.off(\"message\", onMessage);\n resolve();\n }\n };\n worker.on(\"message\", onMessage);\n });\n return { worker, ready };\n}\n\n/** Default timeout for a single evaluation in milliseconds. */\nconst DEFAULT_EVAL_TIMEOUT_MS = 30_000;\n\n/** Maximum number of staleness retries before giving up with an error. */\nconst MAX_STALENESS_RETRIES = 3;\n\n/** Creates an evaluator that runs modules in isolated worker threads with dependency tracking. */\nexport async function createEvaluator(): Promise<Evaluator> {\n const resultCache = new Map<string, EvaluateResult>();\n /**\n * Tracks in-flight evaluation promises by path. When `evaluate()` is called\n * for a path that's already queued or being evaluated, the same promise is\n * returned instead of queuing a duplicate. This prevents a second worker\n * evaluation from producing incomplete dependencies (the ESM resolve hook\n * only fires on cache misses — a second import on the same worker would\n * miss transitive deps that are already in the ESM cache).\n */\n const inflight = new Map<string, Promise<EvaluateResult>>();\n\n /**\n * Two dependency maps provide O(1) lookups in both directions:\n *\n * - `reverseDeps`: file path → set of entry points that depend on it.\n * Consulted during `invalidate()` to find which cached results to clear.\n *\n * - `forwardDeps`: entry point → set of all its transitive dependencies.\n * Needed to clean up stale reverse entries when an entry point is\n * re-evaluated and its dependency tree has changed (e.g. an import\n * was removed). Without this, removed dependencies would accumulate\n * phantom reverse entries that never get cleaned up.\n */\n const reverseDeps = new Map<string, Set<string>>();\n const forwardDeps = new Map<string, Set<string>>();\n\n let nextId = 0;\n let currentEval: PendingEvaluation | null = null;\n let currentTimeout: ReturnType<typeof setTimeout> | null = null;\n const queue: PendingEvaluation[] = [];\n /**\n * Tracks files passed to `invalidate()` while an evaluation is in-flight.\n * When an evaluation completes, `handleResult()` checks whether any reported\n * dependency intersects this set. If so, the result is stale — it's discarded,\n * workers are swapped, and the evaluation is retried on a clean worker.\n *\n * This closes the \"cold start\" gap: if `evaluate(\"A\")` is dispatched before\n * `invalidate(\"B\")` is called, and A depends on B, the dependency graph\n * doesn't know about A→B yet. Without this set, the invalidation would be\n * silently missed.\n *\n * Cleared in `swapWorkers()` because the new primary has a clean ESM cache.\n */\n const invalidatedDuringEval = new Set<string>();\n let disposed = false;\n\n /**\n * Two workers are maintained at all times:\n *\n * - **primary**: handles all evaluate() calls. Accumulates Node's ESM\n * module cache over time, making repeated evaluations fast (~1-3ms).\n *\n * - **shadow**: pre-booted but completely idle. Never evaluates anything,\n * so its module cache stays empty. On invalidation, the primary is\n * terminated (stale cache) and the shadow is promoted to primary\n * instantly (no boot latency). A new shadow is booted in the background.\n *\n * This pattern trades ~30ms of background boot time for instant\n * invalidation. The alternative — reusing a single worker and clearing\n * its ESM cache — isn't possible because Node doesn't expose an API\n * to clear the module cache.\n */\n let primary = bootWorker();\n let shadow = bootWorker();\n\n await Promise.all([primary.ready, shadow.ready]);\n\n /**\n * Allow the process to exit naturally when the event loop is otherwise empty.\n * Without this, the workers keep the event loop alive indefinitely — causing\n * hangs in multi-environment Vite builds where no hook reliably disposes\n * the evaluator after all environments are done.\n * Must be called after setupMessageHandler since .on() can re-ref the worker.\n */\n function unrefWorkers(primaryWorker: Worker, shadowWorker: Worker) {\n primaryWorker.unref();\n shadowWorker.unref();\n }\n\n function setupMessageHandler(workerObj: { worker: Worker }) {\n workerObj.worker.on(\"message\", (msg: WorkerResult) => {\n if (msg.type !== \"result\") return;\n handleResult(msg);\n });\n\n workerObj.worker.on(\"error\", (err: Error) => {\n if (currentEval) {\n clearEvalTimeout();\n const pending = currentEval;\n currentEval = null;\n const result: EvaluateResult = {\n ok: false,\n error: { message: err.message, stack: err.stack ?? \"\" },\n };\n updateDeps(pending.absolutePath, [pending.absolutePath]);\n resultCache.set(pending.absolutePath, result);\n inflight.delete(pending.absolutePath);\n pending.resolve(result);\n processQueue();\n }\n });\n }\n\n setupMessageHandler(primary);\n unrefWorkers(primary.worker, shadow.worker);\n\n function clearEvalTimeout() {\n if (currentTimeout !== null) {\n clearTimeout(currentTimeout);\n currentTimeout = null;\n }\n }\n\n function handleResult(msg: WorkerResult) {\n if (!currentEval) return;\n if (msg.id !== currentEval.id) return;\n\n clearEvalTimeout();\n\n const pending = currentEval;\n currentEval = null;\n\n // Staleness check: if a file was invalidated while this evaluation was\n // in-flight and the result depends on it, discard the result and retry\n // on a clean worker. Only checked for successes — errors don't report\n // deps, and the file watcher will trigger another invalidation when the\n // source is fixed.\n if (msg.ok && invalidatedDuringEval.size > 0) {\n const isStale = msg.dependencies.some((dep) => invalidatedDuringEval.has(dep));\n if (isStale) {\n if (pending.retryCount >= MAX_STALENESS_RETRIES) {\n pending.resolve({\n ok: false,\n error: {\n message: `Evaluation of ${pending.absolutePath} exceeded maximum staleness retries (${MAX_STALENESS_RETRIES})`,\n stack: \"\",\n },\n });\n processQueue();\n return;\n }\n pending.retryCount++;\n swapWorkers();\n queue.unshift(pending);\n processQueue();\n return;\n }\n }\n\n let result: EvaluateResult;\n if (msg.ok) {\n result = { ok: true, value: msg.value, dependencies: msg.dependencies };\n updateDeps(pending.absolutePath, msg.dependencies);\n } else {\n result = { ok: false, error: msg.error };\n // Use the partial dependencies reported by the worker (files resolved\n // before the error). This ensures transitive deps are registered in\n // reverseDeps so that fixing a broken file triggers re-evaluation.\n updateDeps(pending.absolutePath, msg.dependencies);\n }\n\n resultCache.set(pending.absolutePath, result);\n inflight.delete(pending.absolutePath);\n pending.resolve(result);\n processQueue();\n }\n\n /**\n * Reconciles the dependency graph after an evaluation.\n *\n * First removes all old reverse entries for this entry point (using\n * forwardDeps as the source of truth), then writes the new forward\n * and reverse mappings. This ensures that if a dependency was removed\n * between evaluations, it no longer points back to this entry point.\n */\n function updateDeps(entryPoint: string, deps: string[]) {\n const oldDeps = forwardDeps.get(entryPoint);\n if (oldDeps) {\n for (const dep of oldDeps) {\n const entries = reverseDeps.get(dep);\n if (entries) {\n entries.delete(entryPoint);\n if (entries.size === 0) {\n reverseDeps.delete(dep);\n }\n }\n }\n }\n\n const depSet = new Set(deps);\n forwardDeps.set(entryPoint, depSet);\n\n for (const dep of depSet) {\n let entries = reverseDeps.get(dep);\n if (!entries) {\n entries = new Set();\n reverseDeps.set(dep, entries);\n }\n entries.add(entryPoint);\n }\n }\n\n /**\n * Evaluations are serialized — one at a time per worker. This prevents\n * interleaved dependency tracking: the loader hook accumulates deps in\n * a single Set and flushes it after each evaluation. Concurrent imports\n * would mix dependencies from different entry points.\n *\n * Waits for the primary worker to be ready before sending work. This\n * matters after a swap: the promoted shadow may still be booting.\n */\n function processQueue() {\n if (currentEval || queue.length === 0 || disposed) return;\n\n const next = queue.shift()!;\n\n // A prior evaluation for the same path may have completed and cached\n // while this item was queued (e.g. after invalidation + re-queue).\n // Resolving from cache avoids dispatching to a worker where the module\n // is already in the ESM cache (which would produce incomplete deps).\n const alreadyCached = resultCache.get(next.absolutePath);\n if (alreadyCached) {\n inflight.delete(next.absolutePath);\n next.resolve(alreadyCached);\n processQueue();\n return;\n }\n\n currentEval = next;\n\n primary.ready.then(() => {\n if (disposed || currentEval !== next) return;\n primary.worker.postMessage({\n type: \"evaluate\",\n id: next.id,\n absolutePath: next.absolutePath,\n });\n\n currentTimeout = setTimeout(() => {\n if (currentEval !== next) return;\n currentEval = null;\n currentTimeout = null;\n\n const result: EvaluateResult = {\n ok: false,\n error: {\n message: `Evaluation of ${next.absolutePath} timed out after ${DEFAULT_EVAL_TIMEOUT_MS}ms`,\n stack: \"\",\n },\n };\n updateDeps(next.absolutePath, [next.absolutePath]);\n resultCache.set(next.absolutePath, result);\n inflight.delete(next.absolutePath);\n next.resolve(result);\n\n swapWorkers();\n processQueue();\n }, DEFAULT_EVAL_TIMEOUT_MS);\n });\n }\n\n /**\n * Terminates the primary (stale module cache), promotes the shadow\n * (clean cache, instant), and boots a new shadow in the background.\n *\n * `removeAllListeners` prevents the terminated worker from delivering\n * late messages or error events that would confuse the result handler.\n */\n function swapWorkers() {\n primary.worker.removeAllListeners();\n primary.worker.terminate();\n\n primary = shadow;\n setupMessageHandler(primary);\n\n shadow = bootWorker();\n unrefWorkers(primary.worker, shadow.worker);\n\n // The new primary has a clean ESM cache, so any previously tracked\n // invalidations are no longer relevant — the fresh worker will\n // re-import everything from disk.\n invalidatedDuringEval.clear();\n }\n\n function evaluate(absolutePath: string): Promise<EvaluateResult> {\n if (disposed) {\n return Promise.reject(new Error(\"Evaluator has been disposed\"));\n }\n\n if (!isAbsolute(absolutePath)) {\n return Promise.reject(\n new Error(`evaluate() requires an absolute path, got: ${absolutePath}`),\n );\n }\n\n const cached = resultCache.get(absolutePath);\n if (cached) {\n return Promise.resolve(cached);\n }\n\n // Deduplicate: if an evaluation is already queued or in-flight for this\n // path, return the same promise. This prevents a second worker evaluation\n // that would produce incomplete dependencies (the ESM resolve hook only\n // fires on cache misses).\n const pending = inflight.get(absolutePath);\n if (pending) return pending;\n\n const promise = new Promise<EvaluateResult>((resolve, reject) => {\n const id = nextId++;\n queue.push({ id, absolutePath, resolve, reject, retryCount: 0 });\n processQueue();\n });\n\n inflight.set(absolutePath, promise);\n return promise;\n }\n\n function invalidate(...absolutePaths: string[]): void {\n if (absolutePaths.length === 0) return;\n\n // Track all invalidations for cold-start detection (in-flight evaluations\n // whose dependency graph isn't populated yet).\n for (const path of absolutePaths) {\n invalidatedDuringEval.add(path);\n }\n\n // Collect all affected entry points across all changed files.\n const allEntryPoints = new Set<string>();\n for (const path of absolutePaths) {\n const entryPoints = reverseDeps.get(path);\n if (entryPoints) {\n for (const entry of entryPoints) {\n allEntryPoints.add(entry);\n }\n }\n }\n\n // If no cached entry points are affected, return early. The cold-start\n // set (invalidatedDuringEval) will catch in-flight evaluations.\n if (allEntryPoints.size === 0) return;\n\n // Clear caches and clean dependency graphs for all affected entry points.\n for (const entry of allEntryPoints) {\n resultCache.delete(entry);\n inflight.delete(entry);\n\n const deps = forwardDeps.get(entry);\n if (deps) {\n for (const dep of deps) {\n const entries = reverseDeps.get(dep);\n if (entries) {\n entries.delete(entry);\n if (entries.size === 0) {\n reverseDeps.delete(dep);\n }\n }\n }\n forwardDeps.delete(entry);\n }\n }\n\n // If an evaluation is in-flight on the worker we're about to terminate,\n // capture it and re-queue at the front. The caller's promise will\n // resolve transparently with the result from the promoted shadow worker.\n clearEvalTimeout();\n const inflightEval = currentEval;\n currentEval = null;\n\n swapWorkers();\n\n if (inflightEval) {\n queue.unshift(inflightEval);\n }\n\n processQueue();\n }\n\n function invalidateAll(): void {\n resultCache.clear();\n inflight.clear();\n forwardDeps.clear();\n reverseDeps.clear();\n\n clearEvalTimeout();\n const inflightEval = currentEval;\n currentEval = null;\n\n swapWorkers();\n\n if (inflightEval) {\n queue.unshift(inflightEval);\n }\n\n processQueue();\n }\n\n function getDependentsOf(absolutePath: string): string[] {\n const entryPoints = reverseDeps.get(absolutePath);\n if (!entryPoints) return [];\n return [...entryPoints];\n }\n\n async function dispose(): Promise<void> {\n if (disposed) return;\n disposed = true;\n\n clearEvalTimeout();\n\n if (currentEval) {\n currentEval.reject(new Error(\"Evaluator has been disposed\"));\n currentEval = null;\n }\n for (const pending of queue) {\n pending.reject(new Error(\"Evaluator has been disposed\"));\n }\n queue.length = 0;\n inflight.clear();\n\n await Promise.all([primary.worker.terminate(), shadow.worker.terminate()]);\n }\n\n return {\n evaluate,\n invalidate,\n invalidateAll,\n getDependentsOf,\n dispose,\n [Symbol.asyncDispose]: dispose,\n };\n}\n"],"mappings":";;;;;AAsDA,MAAM,kBAAkB,+BAA+B,OAAO,KAAK;;;;;;;;;;;;;;;;;;;;;;;CAAkB,CAAC,CAAC,SAAS,QAAQ;AAGxG,SAAgB,sBAA8B;CAC5C,OAAO;AACT;;;ACDA,SAAS,oBAA4B;CACnC,MAAM,SAAS,cAAc,IAAI,IAAI,eAAe,YAAY,GAAG,CAAC;CACpE,IAAI,WAAW,MAAM,GACnB,OAAO;CAET,OAAO,cAAc,IAAI,IAAI,eAAe,YAAY,GAAG,CAAC;AAC9D;AAaA,SAAS,aAAuD;CAC9D,MAAM,aAAa,kBAAkB;CACrC,MAAM,gBAAgB,oBAAoB;CAC1C,MAAM,SAAS,IAAI,OAAO,YAAY,EACpC,YAAY,EAAE,cAAc,EAC9B,CAAC;CAUD,OAAO;EAAE;EAAQ,OAAA,IATC,SAAe,YAAY;GAC3C,MAAM,aAAa,QAA0B;IAC3C,IAAI,IAAI,SAAS,SAAS;KACxB,OAAO,IAAI,WAAW,SAAS;KAC/B,QAAQ;IACV;GACF;GACA,OAAO,GAAG,WAAW,SAAS;EAChC,CACqB;CAAE;AACzB;AAGA,MAAM,0BAA0B;AAGhC,MAAM,wBAAwB;AAG9B,eAAsB,kBAAsC;CAC1D,MAAM,8BAAc,IAAI,IAA4B;CASpD,MAAM,2BAAW,IAAI,IAAqC;CAc1D,MAAM,8BAAc,IAAI,IAAyB;CACjD,MAAM,8BAAc,IAAI,IAAyB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A,eAAe,UAAyB;EACtC,IAAI,UAAU;EACd,WAAW;EAEX,iBAAiB;EAEjB,IAAI,aAAa;GACf,YAAY,uBAAO,IAAI,MAAM,6BAA6B,CAAC;GAC3D,cAAc;EAChB;EACA,KAAK,MAAM,WAAW,OACpB,QAAQ,uBAAO,IAAI,MAAM,6BAA6B,CAAC;EAEzD,MAAM,SAAS;EACf,SAAS,MAAM;EAEf,MAAM,QAAQ,IAAI,CAAC,QAAQ,OAAO,UAAU,GAAG,OAAO,OAAO,UAAU,CAAC,CAAC;CAC3E;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;GACC,OAAO,eAAe;CACzB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","names":[],"sources":["../../../yak-internals/isolated-source-eval/worker.ts"],"sourcesContent":["/**\n * Worker thread entry point for isolated module evaluation.\n *\n * Each worker is a full Node.js environment with its own ESM module cache.\n * Modules are loaded via dynamic `import()` — Node 22.18.0+ strips TypeScript\n * types natively, so no compilation step or flags are needed.\n *\n * The loader hook data URL is received via `workerData` rather than\n * importing it from a sibling module. This avoids a cross-file import\n * resolution problem: Node's strip-types requires `.ts` extensions in\n * source, but compiled output uses `.js`. Passing the URL through\n * `workerData` sidesteps this entirely since the worker file has no\n * local imports beyond node built-ins.\n */\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { MessageChannel } from \"node:worker_threads\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * We import `register` from `node:module` instead of calling `module.register()`\n * directly. Node's strip-types parser sees the bare `module` identifier as a\n * CJS global, and combined with top-level `await` (or other ESM syntax), it\n * throws \"Cannot determine intended module format\". Using the explicit import\n * avoids this ambiguity entirely.\n */\nimport { register } from \"node:module\";\n\nif (!parentPort) {\n throw new Error(\"This file must be run as a worker thread\");\n}\n\nconst loaderDataUrl: string = workerData.loaderDataUrl;\n\n/**\n * MessageChannel for communicating with the loader hook.\n * port1 stays in this worker thread; port2 is transferred to the loader\n * thread via `register()`'s transferList. This is the only way to get\n * data out of loader hooks, since they run in an isolated loader thread\n * that cannot access worker_threads.parentPort.\n */\nconst { port1, port2 } = new MessageChannel();\n\nregister(loaderDataUrl, {\n parentURL: import.meta.url,\n data: { port: port2 },\n transferList: [port2],\n});\n\n/**\n * Requests the accumulated dependency list from the loader hook.\n *\n * Called after each `import()` completes. The loader hook clears its\n * internal Set on each request, so dependencies are scoped to the\n * most recent evaluation. This is safe because evaluations are\n * serialized — only one runs at a time per worker.\n */\nfunction requestDeps(): Promise<string[]> {\n return new Promise((resolve) => {\n port1.once(\"message\", (deps: string[]) => {\n resolve(deps);\n });\n port1.postMessage(\"getDeps\");\n });\n}\n\nparentPort.on(\"message\", async (msg: { type: string; id: number; absolutePath: string }) => {\n if (msg.type !== \"evaluate\") return;\n\n try {\n const fileUrl = pathToFileURL(msg.absolutePath).href;\n const ns = await import(fileUrl);\n\n const deps = await requestDeps();\n\n // The entry point may not appear in the loader hook's dependency set\n // if it was already in the ESM cache from a previous evaluation.\n // The resolve hook only fires on cache misses.\n if (!deps.includes(msg.absolutePath)) {\n deps.unshift(msg.absolutePath);\n }\n\n // Module namespace objects are exotic objects that fail structured clone\n // (postMessage would throw). Copying to a plain object is required.\n const value: Record<string, unknown> = {};\n for (const key of Object.keys(ns)) {\n value[key] = ns[key];\n }\n\n parentPort!.postMessage({\n type: \"result\",\n id: msg.id,\n ok: true,\n value,\n dependencies: deps,\n });\n } catch (err: unknown) {\n // Catches both evaluation errors (syntax errors, runtime exceptions)\n // and structured clone failures (e.g. when exports contain functions,\n // Symbols, or other non-cloneable values). Both are returned as\n // { ok: false } results — the caller does not need to distinguish.\n const error =\n err instanceof Error\n ? { message: err.message, stack: err.stack ?? \"\" }\n : { message: String(err), stack: \"\" };\n\n // Flush partial dependencies that the loader hook tracked before the\n // error. This allows the evaluator to register them in the reverse\n // dep map so that fixing the broken file triggers re-evaluation.\n const deps = await requestDeps();\n if (!deps.includes(msg.absolutePath)) {\n deps.unshift(msg.absolutePath);\n }\n\n parentPort!.postMessage({\n type: \"result\",\n id: msg.id,\n ok: false,\n error,\n dependencies: deps,\n });\n }\n});\n\nparentPort.postMessage({ type: \"ready\" });\n"],"mappings":";;;;AA2BA,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,0CAA0C;AAG5D,MAAM,gBAAwB,WAAW;AASzC,MAAM,EAAE,OAAO,UAAU,IAAI,eAAe;AAE5C,SAAS,eAAe;CACtB,WAAW,OAAO,KAAK;CACvB,MAAM,EAAE,MAAM,MAAM;CACpB,cAAc,CAAC,KAAK;AACtB,CAAC;AAUD,SAAS,cAAiC;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,YAAY,SAAmB;GACxC,QAAQ,IAAI;EACd,CAAC;EACD,MAAM,YAAY,SAAS;CAC7B,CAAC;AACH;AAEA,WAAW,GAAG,WAAW,OAAO,QAA4D;CAC1F,IAAI,IAAI,SAAS,YAAY;CAE7B,IAAI;EAEF,MAAM,KAAK,MAAM,OADD,cAAc,IAAI,YAAY,CAAC,CAAC;EAGhD,MAAM,OAAO,MAAM,YAAY;EAK/B,IAAI,CAAC,KAAK,SAAS,IAAI,YAAY,GACjC,KAAK,QAAQ,IAAI,YAAY;EAK/B,MAAM,QAAiC,CAAC;EACxC,KAAK,MAAM,OAAO,OAAO,KAAK,EAAE,GAC9B,MAAM,OAAO,GAAG;EAGlB,WAAY,YAAY;GACtB,MAAM;GACN,IAAI,IAAI;GACR,IAAI;GACJ;GACA,cAAc;EAChB,CAAC;CACH,SAAS,KAAc;EAKrB,MAAM,QACJ,eAAe,QACX;GAAE,SAAS,IAAI;GAAS,OAAO,IAAI,SAAS;EAAG,IAC/C;GAAE,SAAS,OAAO,GAAG;GAAG,OAAO;EAAG;EAKxC,MAAM,OAAO,MAAM,YAAY;EAC/B,IAAI,CAAC,KAAK,SAAS,IAAI,YAAY,GACjC,KAAK,QAAQ,IAAI,YAAY;EAG/B,WAAY,YAAY;GACtB,MAAM;GACN,IAAI,IAAI;GACR,IAAI;GACJ;GACA,cAAc;EAChB,CAAC;CACH;AACF,CAAC;AAED,WAAW,YAAY,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"worker.js","names":[],"sources":["../../../yak-internals/isolated-source-eval/worker.ts"],"sourcesContent":["/**\n * Worker thread entry point for isolated module evaluation.\n *\n * Each worker is a full Node.js environment with its own ESM module cache.\n * Modules are loaded via dynamic `import()` — Node 22.18.0+ strips TypeScript\n * types natively, so no compilation step or flags are needed.\n *\n * The loader hook data URL is received via `workerData` rather than\n * importing it from a sibling module. This avoids a cross-file import\n * resolution problem: Node's strip-types requires `.ts` extensions in\n * source, but compiled output uses `.js`. Passing the URL through\n * `workerData` sidesteps this entirely since the worker file has no\n * local imports beyond node built-ins.\n */\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { MessageChannel } from \"node:worker_threads\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * We import `register` from `node:module` instead of calling `module.register()`\n * directly. Node's strip-types parser sees the bare `module` identifier as a\n * CJS global, and combined with top-level `await` (or other ESM syntax), it\n * throws \"Cannot determine intended module format\". Using the explicit import\n * avoids this ambiguity entirely.\n */\nimport { register } from \"node:module\";\n\nif (!parentPort) {\n throw new Error(\"This file must be run as a worker thread\");\n}\n\nconst loaderDataUrl: string = workerData.loaderDataUrl;\n\n/**\n * MessageChannel for communicating with the loader hook.\n * port1 stays in this worker thread; port2 is transferred to the loader\n * thread via `register()`'s transferList. This is the only way to get\n * data out of loader hooks, since they run in an isolated loader thread\n * that cannot access worker_threads.parentPort.\n */\nconst { port1, port2 } = new MessageChannel();\n\nregister(loaderDataUrl, {\n parentURL: import.meta.url,\n data: { port: port2 },\n transferList: [port2],\n});\n\n/**\n * Requests the accumulated dependency list from the loader hook.\n *\n * Called after each `import()` completes. The loader hook clears its\n * internal Set on each request, so dependencies are scoped to the\n * most recent evaluation. This is safe because evaluations are\n * serialized — only one runs at a time per worker.\n */\nfunction requestDeps(): Promise<string[]> {\n return new Promise((resolve) => {\n port1.once(\"message\", (deps: string[]) => {\n resolve(deps);\n });\n port1.postMessage(\"getDeps\");\n });\n}\n\nparentPort.on(\"message\", async (msg: { type: string; id: number; absolutePath: string }) => {\n if (msg.type !== \"evaluate\") return;\n\n try {\n const fileUrl = pathToFileURL(msg.absolutePath).href;\n const ns = await import(fileUrl);\n\n const deps = await requestDeps();\n\n // The entry point may not appear in the loader hook's dependency set\n // if it was already in the ESM cache from a previous evaluation.\n // The resolve hook only fires on cache misses.\n if (!deps.includes(msg.absolutePath)) {\n deps.unshift(msg.absolutePath);\n }\n\n // Module namespace objects are exotic objects that fail structured clone\n // (postMessage would throw). Copying to a plain object is required.\n const value: Record<string, unknown> = {};\n for (const key of Object.keys(ns)) {\n value[key] = ns[key];\n }\n\n parentPort!.postMessage({\n type: \"result\",\n id: msg.id,\n ok: true,\n value,\n dependencies: deps,\n });\n } catch (err: unknown) {\n // Catches both evaluation errors (syntax errors, runtime exceptions)\n // and structured clone failures (e.g. when exports contain functions,\n // Symbols, or other non-cloneable values). Both are returned as\n // { ok: false } results — the caller does not need to distinguish.\n const error =\n err instanceof Error\n ? { message: err.message, stack: err.stack ?? \"\" }\n : { message: String(err), stack: \"\" };\n\n // Flush partial dependencies that the loader hook tracked before the\n // error. This allows the evaluator to register them in the reverse\n // dep map so that fixing the broken file triggers re-evaluation.\n const deps = await requestDeps();\n if (!deps.includes(msg.absolutePath)) {\n deps.unshift(msg.absolutePath);\n }\n\n parentPort!.postMessage({\n type: \"result\",\n id: msg.id,\n ok: false,\n error,\n dependencies: deps,\n });\n }\n});\n\nparentPort.postMessage({ type: \"ready\" });\n"],"mappings":";;;;AA2BA,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,0CAA0C;AAG5D,MAAM,gBAAwB,WAAW;AASzC,MAAM,EAAE,OAAO,UAAU,IAAI,eAAe;AAE5C,SAAS,eAAe;CACtB,WAAW,YAAY;CACvB,MAAM,EAAE,MAAM,MAAM;CACpB,cAAc,CAAC,KAAK;AACtB,CAAC;AAUD,SAAS,cAAiC;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,YAAY,SAAmB;GACxC,QAAQ,IAAI;EACd,CAAC;EACD,MAAM,YAAY,SAAS;CAC7B,CAAC;AACH;AAEA,WAAW,GAAG,WAAW,OAAO,QAA4D;CAC1F,IAAI,IAAI,SAAS,YAAY;CAE7B,IAAI;EAEF,MAAM,KAAK,MAAM,OADD,cAAc,IAAI,YAAY,CAAC,CAAC;EAGhD,MAAM,OAAO,MAAM,YAAY;EAK/B,IAAI,CAAC,KAAK,SAAS,IAAI,YAAY,GACjC,KAAK,QAAQ,IAAI,YAAY;EAK/B,MAAM,QAAiC,CAAC;EACxC,KAAK,MAAM,OAAO,OAAO,KAAK,EAAE,GAC9B,MAAM,OAAO,GAAG;EAGlB,WAAY,YAAY;GACtB,MAAM;GACN,IAAI,IAAI;GACR,IAAI;GACJ;GACA,cAAc;EAChB,CAAC;CACH,SAAS,KAAc;EAKrB,MAAM,QACJ,eAAe,QACX;GAAE,SAAS,IAAI;GAAS,OAAO,IAAI,SAAS;EAAG,IAC/C;GAAE,SAAS,OAAO,GAAG;GAAG,OAAO;EAAG;EAKxC,MAAM,OAAO,MAAM,YAAY;EAC/B,IAAI,CAAC,KAAK,SAAS,IAAI,YAAY,GACjC,KAAK,QAAQ,IAAI,YAAY;EAG/B,WAAY,YAAY;GACtB,MAAM;GACN,IAAI,IAAI;GACR,IAAI;GACJ;GACA,cAAc;EAChB,CAAC;CACH;AACF,CAAC;AAED,WAAW,YAAY,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { JscConfig, Options } from "@swc/core";
2
+ import "vite";
2
3
  //#region ../yak-internals/config.d.ts
3
4
  type YakConfigOptions = {
4
5
  /**
@@ -84,12 +85,6 @@ type SwcOverrides = Omit<Options, "filename" | "sourceFileName" | "inputSourceMa
84
85
  experimental?: Omit<NonNullable<JscConfig["experimental"]>, "plugins">;
85
86
  };
86
87
  };
87
- /**
88
- * @internal Describes a yak runtime package (e.g. "next-yak", "@yak/solid").
89
- * The yak-swc compiler detects the package from the import source on its own.
90
- * This only controls the vite-plugin side (filtering, context alias, HMR).
91
- * Not part of the public API
92
- */
93
88
  //#endregion
94
89
  //#region loaders/vite-plugin.d.ts
95
90
  /**
@@ -102,7 +97,7 @@ type SwcOverrides = Omit<Options, "filename" | "sourceFileName" | "inputSourceMa
102
97
  * ```ts
103
98
  * // vite.config.ts
104
99
  * import { defineConfig } from "vite";
105
- * import solid from "vite-plugin-solid";
100
+ * import solid from "@solidjs/vite-plugin";
106
101
  * import { yak } from "@yak/solid/vite";
107
102
  *
108
103
  * export default defineConfig({