@jasonshimmy/custom-elements-runtime 2.8.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +223 -73
  2. package/dist/css-utils-Cg4o1MqY.js +643 -0
  3. package/dist/css-utils-Cg4o1MqY.js.map +1 -0
  4. package/dist/css-utils-RqkyBWft.cjs +576 -0
  5. package/dist/css-utils-RqkyBWft.cjs.map +1 -0
  6. package/dist/custom-elements-runtime.cjs.js +3 -3
  7. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -0
  9. package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -0
  10. package/dist/custom-elements-runtime.dom-jit-css.es.js +136 -0
  11. package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -0
  12. package/dist/custom-elements-runtime.es.js +105 -97
  13. package/dist/custom-elements-runtime.es.js.map +1 -1
  14. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
  15. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  16. package/dist/custom-elements-runtime.event-bus.es.js +62 -46
  17. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  18. package/dist/custom-elements-runtime.jit-css.cjs.js +2 -0
  19. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -0
  20. package/dist/custom-elements-runtime.jit-css.es.js +37 -0
  21. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -0
  22. package/dist/custom-elements-runtime.router.cjs.js +20 -20
  23. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  24. package/dist/custom-elements-runtime.router.es.js +472 -458
  25. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  26. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +2 -0
  27. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -0
  28. package/dist/custom-elements-runtime.ssr-middleware.es.js +63 -0
  29. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -0
  30. package/dist/custom-elements-runtime.ssr.cjs.js +3 -1
  31. package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
  32. package/dist/custom-elements-runtime.ssr.es.js +137 -24
  33. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  34. package/dist/custom-elements-runtime.store.cjs.js +1 -1
  35. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  36. package/dist/custom-elements-runtime.store.es.js +21 -16
  37. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  38. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  39. package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
  40. package/dist/custom-elements-runtime.transitions.es.js +279 -7
  41. package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
  42. package/dist/custom-elements-runtime.vite-plugin.cjs.js +2 -0
  43. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -0
  44. package/dist/custom-elements-runtime.vite-plugin.es.js +105 -0
  45. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -0
  46. package/dist/dom-jit-css.d.ts +66 -0
  47. package/dist/event-bus.d.ts +3 -1
  48. package/dist/hooks-B50HhrHh.cjs +6 -0
  49. package/dist/hooks-B50HhrHh.cjs.map +1 -0
  50. package/dist/hooks-Cze3o-F7.js +1462 -0
  51. package/dist/hooks-Cze3o-F7.js.map +1 -0
  52. package/dist/index.d.ts +6 -3
  53. package/dist/jit-css.d.ts +30 -0
  54. package/dist/namespace-helpers-D4wC2-qA.js +61 -0
  55. package/dist/namespace-helpers-D4wC2-qA.js.map +1 -0
  56. package/dist/namespace-helpers-ckeEOxpR.cjs +2 -0
  57. package/dist/namespace-helpers-ckeEOxpR.cjs.map +1 -0
  58. package/dist/router/matcher.d.ts +14 -0
  59. package/dist/router/types.d.ts +4 -2
  60. package/dist/runtime/component/factory.d.ts +16 -2
  61. package/dist/runtime/css-utils.d.ts +33 -0
  62. package/dist/runtime/discovery-state.d.ts +3 -0
  63. package/dist/runtime/hooks.d.ts +78 -0
  64. package/dist/runtime/hydration.d.ts +33 -0
  65. package/dist/runtime/jit-hooks.d.ts +28 -0
  66. package/dist/runtime/render-bridge.d.ts +37 -0
  67. package/dist/runtime/scheduler.d.ts +3 -4
  68. package/dist/runtime/secure-expression-evaluator.d.ts +0 -1
  69. package/dist/runtime/ssr-context.d.ts +45 -0
  70. package/dist/runtime/style.d.ts +84 -26
  71. package/dist/runtime/template-compiler/lru-cache.d.ts +0 -3
  72. package/dist/runtime/types.d.ts +18 -0
  73. package/dist/runtime/vdom-helpers.d.ts +0 -1
  74. package/dist/runtime/vdom-ssr-dsd.d.ts +58 -0
  75. package/dist/ssr-middleware.d.ts +125 -0
  76. package/dist/ssr.d.ts +120 -16
  77. package/dist/{transitions-DMJXs_tY.js → style-BmyOIMcU.js} +904 -1344
  78. package/dist/style-BmyOIMcU.js.map +1 -0
  79. package/dist/style-D40DsIqJ.cjs +55 -0
  80. package/dist/style-D40DsIqJ.cjs.map +1 -0
  81. package/dist/style.css +1 -1
  82. package/dist/template-compiler-Cshhqxyd.cjs +23 -0
  83. package/dist/template-compiler-Cshhqxyd.cjs.map +1 -0
  84. package/dist/template-compiler-DtpNsqE-.js +3744 -0
  85. package/dist/template-compiler-DtpNsqE-.js.map +1 -0
  86. package/dist/variables.css +1 -1
  87. package/dist/vite-plugin.d.ts +142 -0
  88. package/package.json +60 -6
  89. package/dist/namespace-helpers-Ctd_h7j2.cjs +0 -5
  90. package/dist/namespace-helpers-Ctd_h7j2.cjs.map +0 -1
  91. package/dist/namespace-helpers-DhLBqt-7.js +0 -1009
  92. package/dist/namespace-helpers-DhLBqt-7.js.map +0 -1
  93. package/dist/template-compiler-Bvx02nAT.js +0 -4020
  94. package/dist/template-compiler-Bvx02nAT.js.map +0 -1
  95. package/dist/template-compiler-bj-MFC_Y.cjs +0 -23
  96. package/dist/template-compiler-bj-MFC_Y.cjs.map +0 -1
  97. package/dist/transitions-DMJXs_tY.js.map +0 -1
  98. package/dist/transitions-f4KfN29T.cjs +0 -330
  99. package/dist/transitions-f4KfN29T.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-elements-runtime.ssr-middleware.es.js","sources":["../src/lib/ssr-middleware.ts"],"sourcesContent":["/**\n * SSR middleware helpers for Express, Fastify, Hono, and other Node.js HTTP frameworks.\n *\n * Provides two handler factories that wrap the SSR rendering pipeline and\n * emit a complete HTML document response. Both accept a static VNode **or**\n * a per-request factory function so route-specific data can be threaded into\n * the render tree.\n *\n * @example Express — static VNode\n * ```ts\n * import express from 'express';\n * import { createSSRHandler } from '@jasonshimmy/custom-elements-runtime/ssr-middleware';\n * import { html } from '@jasonshimmy/custom-elements-runtime';\n *\n * const app = express();\n * app.get('/', createSSRHandler(html`<my-app />`, {\n * render: { dsd: true, jit: { extendedColors: true } },\n * }));\n * ```\n *\n * @example Express — per-request factory\n * ```ts\n * app.get('*', createSSRHandler(\n * (req) => html`<my-app url=\"${req.url}\" />`,\n * { render: { dsd: true }, head: '<link rel=\"stylesheet\" href=\"/app.css\">' },\n * ));\n * ```\n *\n * @example Streaming variant\n * ```ts\n * app.get('*', createStreamingSSRHandler(\n * (req) => html`<my-app url=\"${req.url}\" />`,\n * ));\n * ```\n */\n\nimport { renderToStringWithJITCSS, renderToStream } from './ssr';\nimport type { VNode } from './runtime/types';\nimport type { RenderOptions } from './runtime/vdom-ssr';\nimport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\nimport type { JITCSSOptions } from './runtime/style';\n\n// ---------------------------------------------------------------------------\n// Minimal framework-agnostic HTTP types\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal request interface compatible with Express, Fastify, Hono, and the\n * raw Node.js `IncomingMessage`. Extend or replace with your framework's\n * request type via the generic parameter on `createSSRHandler`.\n */\nexport interface MinimalRequest {\n url?: string;\n method?: string;\n headers?: Record<string, string | string[] | undefined>;\n}\n\n/**\n * Minimal response interface compatible with Express, Fastify, Hono, and the\n * raw Node.js `ServerResponse`. `write` is optional — handlers fall back to\n * buffering when it is absent.\n */\nexport interface MinimalResponse {\n setHeader(name: string, value: string): void;\n write?(chunk: string): boolean | void;\n end(data?: string): void;\n}\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\n/**\n * Options for {@link createSSRHandler} and {@link createStreamingSSRHandler}.\n */\nexport interface SSRMiddlewareOptions {\n /**\n * Render options forwarded to `renderToStringWithJITCSS`.\n * Defaults to `{ dsd: true }` so DSD output is on by default.\n */\n render?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions };\n /**\n * Additional HTML inserted at the end of the `<head>` tag.\n * Use this to inject `<link>`, `<script>`, `<meta>`, or `<title>` tags.\n */\n head?: string;\n /**\n * When `true` (default), the response is wrapped in a complete\n * `<!DOCTYPE html>` document shell. Set to `false` if you want to\n * assemble the document yourself and only need the rendered fragment.\n */\n document?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction wrapInDocument(\n htmlWithStyles: string,\n head: string | undefined,\n wrapDocument: boolean,\n): string {\n if (!wrapDocument) return htmlWithStyles;\n\n // If the rendered HTML already contains a root <html> tag, inject extra\n // head tags and prepend the DOCTYPE — do not double-wrap.\n if (\n htmlWithStyles.trimStart().toLowerCase().startsWith('<html') ||\n htmlWithStyles.includes('</html>')\n ) {\n const extra = head ?? '';\n const withDoctype = htmlWithStyles.startsWith('<!DOCTYPE')\n ? htmlWithStyles\n : `<!DOCTYPE html>${htmlWithStyles}`;\n if (extra) {\n return withDoctype.includes('</head>')\n ? withDoctype.replace('</head>', `${extra}</head>`)\n : withDoctype;\n }\n return withDoctype;\n }\n\n // Minimal shell\n const headContent = head ?? '';\n return `<!DOCTYPE html><html><head>${headContent}</head><body>${htmlWithStyles}</body></html>`;\n}\n\n// ---------------------------------------------------------------------------\n// Handler factories\n// ---------------------------------------------------------------------------\n\n/**\n * Create a request handler that SSR-renders a VNode tree and sends the full\n * HTML document as the response.\n *\n * Compatible with Express, Fastify, Hono, and any framework that uses an\n * `(req, res)` handler signature. The generic `Req` parameter lets you use\n * your framework's typed request object.\n *\n * @param vnodeOrFactory - A static {@link VNode} **or** a (possibly async)\n * factory function that receives the request and returns the VNode to render.\n * @param options - Render and document-shell options.\n *\n * @example\n * ```ts\n * app.get('*', createSSRHandler(\n * (req) => html`<my-app url=\"${req.url}\" />`,\n * { render: { dsd: true, jit: { extendedColors: true } } },\n * ));\n * ```\n */\nexport function createSSRHandler<Req extends MinimalRequest = MinimalRequest>(\n vnodeOrFactory: VNode | ((req: Req) => VNode | Promise<VNode>),\n options?: SSRMiddlewareOptions,\n): (req: Req, res: MinimalResponse) => Promise<void> {\n const renderOptions: RenderOptions &\n DSDRenderOptions & { jit?: JITCSSOptions } = {\n dsd: true,\n ...options?.render,\n };\n const { head, document: wrapDocument = true } = options ?? {};\n\n return async (req, res) => {\n try {\n const vnode =\n typeof vnodeOrFactory === 'function'\n ? await vnodeOrFactory(req)\n : vnodeOrFactory;\n\n const { htmlWithStyles } = renderToStringWithJITCSS(vnode, renderOptions);\n\n const body = wrapInDocument(htmlWithStyles, head, wrapDocument);\n\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n res.end(body);\n } catch (err) {\n // Ensure the response is always closed to prevent the request hanging.\n // Re-throw so the framework's error handler can set the proper status code.\n try {\n res.setHeader('Content-Type', 'text/plain; charset=utf-8');\n res.end('Internal Server Error');\n } catch {\n // ignore secondary errors during error response\n }\n throw err;\n }\n };\n}\n\n/**\n * Create a request handler that SSR-renders a VNode tree and streams the HTML\n * response using chunked transfer encoding.\n *\n * Each chunk produced by the underlying {@link renderToStream} call is written\n * to the response as it becomes available, minimising Time-to-First-Byte.\n * The document shell preamble (`<!DOCTYPE html>…<body>`) is sent in the first\n * write so the browser can begin parsing immediately.\n *\n * @param vnodeOrFactory - A static {@link VNode} **or** a (possibly async)\n * factory function that receives the request and returns the VNode to render.\n * @param options - Render and document-shell options.\n *\n * @example\n * ```ts\n * app.get('*', createStreamingSSRHandler(\n * (req) => html`<my-app url=\"${req.url}\" />`,\n * { render: { dsd: true } },\n * ));\n * ```\n */\nexport function createStreamingSSRHandler<\n Req extends MinimalRequest = MinimalRequest,\n>(\n vnodeOrFactory: VNode | ((req: Req) => VNode | Promise<VNode>),\n options?: SSRMiddlewareOptions,\n): (req: Req, res: MinimalResponse) => Promise<void> {\n const renderOptions: RenderOptions &\n DSDRenderOptions & { jit?: JITCSSOptions } = {\n dsd: true,\n ...options?.render,\n };\n const { head, document: wrapDocument = true } = options ?? {};\n\n return async (req, res) => {\n try {\n const vnode =\n typeof vnodeOrFactory === 'function'\n ? await vnodeOrFactory(req)\n : vnodeOrFactory;\n\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n\n const stream = renderToStream(vnode, renderOptions);\n const reader = stream.getReader();\n const chunks: string[] = [];\n let done = false;\n\n while (!done) {\n const { value, done: d } = await reader.read();\n if (value) chunks.push(value);\n done = d;\n }\n\n const content = chunks.join('');\n\n if (res.write) {\n // Streaming path: set chunked encoding and write incrementally.\n res.setHeader('Transfer-Encoding', 'chunked');\n if (wrapDocument) {\n res.write(`<!DOCTYPE html><html><head>${head ?? ''}</head><body>`);\n }\n res.write(content);\n if (wrapDocument) {\n res.end('</body></html>');\n } else {\n res.end();\n }\n } else {\n // Buffered fallback: framework does not expose write(); send as one response.\n const body = wrapDocument\n ? `<!DOCTYPE html><html><head>${head ?? ''}</head><body>${content}</body></html>`\n : content;\n res.end(body);\n }\n } catch (err) {\n // Ensure the response is always closed to prevent the request hanging.\n // Re-throw so the framework's error handler can set the proper status code.\n try {\n res.setHeader('Content-Type', 'text/plain; charset=utf-8');\n res.end('Internal Server Error');\n } catch {\n // ignore secondary errors during error response\n }\n throw err;\n }\n };\n}\n"],"names":["wrapInDocument","htmlWithStyles","head","wrapDocument","extra","withDoctype","createSSRHandler","vnodeOrFactory","options","renderOptions","req","res","vnode","renderToStringWithJITCSS","body","err","createSt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D,SAAO,OAAOE,GAAKC,MAAQ;AACzB,QAAI;AACF,YAAMC,IACJ,OAAOL,KAAmB,aACtB,MAAMA,EAAeG,CAAG,IACxBH;AAEN,MAAAI,EAAI,UAAU,gBAAgB,0BAA0B;AAGxD,YAAMM,IADSC,EAAeN,GAAOH,CAAa,EAC5B,UAAA,GAChBU,IAAmB,CAAA;AACzB,UAAIC,IAAO;AAEX,aAAO,CAACA,KAAM;AACZ,cAAM,EAAE,OAAAC,GAAO,MAAMC,MAAM,MAAML,EAAO,KAAA;AACxC,QAAII,KAAOF,EAAO,KAAKE,CAAK,GAC5BD,IAAOE;AAAA,MACT;AAEA,YAAMC,IAAUJ,EAAO,KAAK,EAAE;AAE9B,UAAIR,EAAI;AAEN,QAAAA,EAAI,UAAU,qBAAqB,SAAS,GACxCR,KACFQ,EAAI,MAAM,8BAA8BT,KAAQ,EAAE,eAAe,GAEnES,EAAI,MAAMY,CAAO,GACbpB,IACFQ,EAAI,IAAI,gBAAgB,IAExBA,EAAI,IAAA;AAAA,WAED;AAEL,cAAMG,IAAOX,IACT,8BAA8BD,KAAQ,EAAE,gBAAgBqB,CAAO,mBAC/DA;AACJ,QAAAZ,EAAI,IAAIG,CAAI;AAAA,MACd;AAAA,IACF,SAASC,GAAK;AAGZ,UAAI;AACF,QAAAJ,EAAI,UAAU,gBAAgB,2BAA2B,GACzDA,EAAI,IAAI,uBAAuB;AAAA,MACjC,QAAQ;AAAA,MAER;AACA,YAAMI;AAAA,IACR;AAAA,EACF;AACF;"}
@@ -1,2 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./namespace-helpers-Ctd_h7j2.cjs"),h=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function c(r,n){if(typeof r=="string")return t.escapeHTML(r);if(r.tag==="#text")return typeof r.children=="string"?t.escapeHTML(r.children):"";if(r.tag==="#anchor")return(Array.isArray(r.children)?r.children.filter(a=>a!=null):[]).map(a=>c(a,n)).join("");if(r.tag==="#raw")return typeof r.children=="string"?r.children:"";let e={};r.props&&r.props.attrs&&(e={...r.props.attrs});const s=n?.injectSvgNamespace??!0,g=n?.injectKnownNamespaces??s;s&&r.tag==="svg"&&!("xmlns"in e)?e.xmlns=t.SVG_NS:g&&r.tag in t.TAG_NAMESPACE_MAP&&!("xmlns"in e)&&(e.xmlns=t.TAG_NAMESPACE_MAP[r.tag]);const l=Object.entries(e).map(([i,a])=>` ${i}="${t.escapeHTML(String(a))}"`).join("");if(h.has(r.tag))return`<${r.tag}${l}>`;const p=Array.isArray(r.children)?r.children.filter(i=>i!=null).map(i=>c(i,n)).join(""):typeof r.children=="string"?t.escapeHTML(r.children):r.children?c(r.children,n):"";return`<${r.tag}${l}>${p}</${r.tag}>`}exports.clearRegisteredEntityMap=t.clearRegisteredEntityMap;exports.loadEntityMap=t.loadEntityMap;exports.registerEntityMap=t.registerEntityMap;exports.renderToString=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./hooks-B50HhrHh.cjs"),d=require("./namespace-helpers-ckeEOxpR.cjs"),$=require("./style-D40DsIqJ.cjs"),j=require("./css-utils-RqkyBWft.cjs"),E=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function f(t,r){if(typeof t=="string")return o.escapeHTML(t);if(t.tag==="#text")return typeof t.children=="string"?o.escapeHTML(t.children):"";if(t.tag==="#anchor")return(Array.isArray(t.children)?t.children.filter(l=>l!=null):[]).map(l=>f(l,r)).join("");if(t.tag==="#raw")return typeof t.children=="string"?t.children:"";let e={};t.props&&t.props.attrs&&(e={...t.props.attrs});const n=r?.injectSvgNamespace??!0,i=r?.injectKnownNamespaces??n;n&&t.tag==="svg"&&!("xmlns"in e)?e.xmlns=d.SVG_NS:i&&t.tag in d.TAG_NAMESPACE_MAP&&!("xmlns"in e)&&(e.xmlns=d.TAG_NAMESPACE_MAP[t.tag]);const s=Object.entries(e).map(([c,l])=>` ${c}="${o.escapeHTML(String(l))}"`).join("");if(E.has(t.tag))return`<${t.tag}${s}>`;const a=Array.isArray(t.children)?t.children.filter(c=>c!=null).map(c=>f(c,r)).join(""):typeof t.children=="string"?o.escapeHTML(t.children):t.children?f(t.children,r):"";return`<${t.tag}${s}>${a}</${t.tag}>`}const w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),p="<script>(function(){if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;document.querySelectorAll('template[shadowrootmode]').forEach(function(t){var m=t.getAttribute('shadowrootmode');var s=t.parentElement.attachShadow({mode:m});s.appendChild(t.content);t.remove();});})()<\/script>";function C(t){return t.includes("-")&&d.registry.has(t)}function D(t,r){const e=r.injectSvgNamespace??!0,n=r.injectKnownNamespaces??e,i={...t},s=i._tag;return s&&delete i._tag,e&&s==="svg"&&!("xmlns"in i)?i.xmlns=d.SVG_NS:n&&s&&s in d.TAG_NAMESPACE_MAP&&!("xmlns"in i)&&(i.xmlns=d.TAG_NAMESPACE_MAP[s]),Object.entries(i).map(([a,c])=>` ${a}="${o.escapeHTML(String(c))}"`).join("")}function _(t,r){const e=[j.baseReset];t.trim()&&e.push(t);const n=$.jitCSS(r);n.trim()&&e.push(n);const i=j.minifyCSS(e.join(`
2
+ `));return i?`<style>${i}</style>`:""}function h(t,r){if(!r.dsd)return f(t,r);if(typeof t=="string")return o.escapeHTML(t);const e=t.tag;if(e==="#text"||e==="#anchor"||e==="#raw")return f(t,r);if(C(e))return L(t,r);const n=t.props?.attrs?{...t.props.attrs,_tag:e}:{_tag:e},i=D(n,r);if(w.has(e))return`<${e}${i}>`;const s=T(t.children,r);return`<${e}${i}>${s}</${e}>`}function L(t,r){const e=t.tag,n=d.registry.get(e),i=t.props?.attrs??{},s=Object.entries(i).map(([m,A])=>` ${m}="${o.escapeHTML(String(A))}"`).join(""),a=n?.hydrate,c=a&&a!=="load"?` data-cer-hydrate="${a}"`:"";if(!n){const m=T(t.children,r);return`<${e}${s}${c}><template shadowrootmode="open"></template>${m}</${e}>`}const{shadowVNode:l,useStyleCSS:g}=o.runComponentSSRRender(n,i,e);let u="";l!=null&&(Array.isArray(l)?u=l.map(m=>h(m,r)).join(""):u=h(l,r));const S=_(g,u),y=T(t.children,r);return`<${e}${s}${c}><template shadowrootmode="open">${S}${u}</template>${y}</${e}>`}function T(t,r){return t?typeof t=="string"?o.escapeHTML(t):Array.isArray(t)?t.filter(e=>e!=null).map(e=>h(e,r)).join(""):h(t,r):""}function M(t,r){const e={dsd:!0,...r},n=h(t,e);return e.dsdPolyfill!==!1?n.includes("</body>")?n.replace("</body>",`${p}</body>`):n+p:n}function b(t,r){const{jit:e,dsd:n,dsdPolyfill:i,...s}=r??{};e&&$.enableJITCSS(e),o.beginSSRGlobalStyleCollection();let a,c;try{n?a=M(t,{...s,dsd:!0,dsdPolyfill:!1}):a=f(t,s)}finally{c=o.endSSRGlobalStyleCollection()}const l=$.jitCSS(a),g=c.join(`
3
+ `),u=[];l&&u.push(`<style id="cer-ssr-jit">${l}</style>`),g.trim()&&u.push(`<style id="cer-ssr-global">${g}</style>`);let S=a;if(u.length){const y=u.join("");S=a.includes("</head>")?a.replace("</head>",`${y}</head>`):`${y}${a}`}return n&&i!==!1&&(S=S.includes("</body>")?S.replace("</body>",`${p}</body>`):S+p),{html:a,css:l,globalStyles:g,htmlWithStyles:S}}function P(t,r){return b(t,{...r,dsd:!0})}function O(t,r){return new ReadableStream({start(e){try{const{htmlWithStyles:n}=b(t,r);e.enqueue(n),e.close()}catch(n){e.error(n)}}})}exports.clearRegisteredEntityMap=o.clearRegisteredEntityMap;exports.loadEntityMap=o.loadEntityMap;exports.registerEntityMap=o.registerEntityMap;exports.DSD_POLYFILL_SCRIPT=p;exports.renderToStream=O;exports.renderToString=f;exports.renderToStringDSD=M;exports.renderToStringWithJITCSS=b;exports.renderToStringWithJITCSSDSD=P;
2
4
  //# sourceMappingURL=custom-elements-runtime.ssr.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.ssr.cjs.js","sources":["../src/lib/runtime/vdom-ssr.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\n// HTML void elements that should be self-closing\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n let attrsObj: Record<string, unknown> = {};\n if (vnode.props && vnode.props.attrs) {\n attrsObj = { ...vnode.props.attrs };\n }\n\n const inject = opts?.injectSvgNamespace ?? true;\n const injectKnown = opts?.injectKnownNamespaces ?? inject;\n\n // Inject namespace for well-known tags when missing. By default we\n // preserve previous behavior (SVG injected) and also allow injecting\n // other known namespaces (MathML) when injectKnownNamespaces is true.\n if (inject && vnode.tag === 'svg' && !('xmlns' in attrsObj)) {\n attrsObj.xmlns = SVG_NS;\n } else if (\n injectKnown &&\n vnode.tag in TAG_NAMESPACE_MAP &&\n !('xmlns' in attrsObj)\n ) {\n attrsObj.xmlns = TAG_NAMESPACE_MAP[vnode.tag];\n }\n\n const attrsString = Object.entries(attrsObj)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n"],"names":["VOID_ELEMENTS","renderToString","vnode","opts","escapeHTML","c","attrsObj","inject","injectKnown","SVG_NS","TAG_NAMESPACE_MAP","attrsString","k","v","children"],"mappings":"oIAmBMA,MAAoB,IAAI,CAC5B,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,QACA,SACA,QACA,KACF,CAAC,EAEM,SAASC,EAAeC,EAAcC,EAA8B,CACzE,GAAI,OAAOD,GAAU,SAAU,OAAOE,EAAAA,WAAWF,CAAK,EAEtD,GAAIA,EAAM,MAAQ,QAChB,OAAO,OAAOA,EAAM,UAAa,SAC5BE,EAAAA,WAAWF,EAAM,QAAQ,EAC1B,GAGN,GAAIA,EAAM,MAAQ,UAQhB,OAHiB,MAAM,QAAQA,EAAM,QAA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../src/lib/runtime/vdom-ssr-dsd.ts","../src/lib/ssr.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\n// HTML void elements that should be self-closing\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n let attrsObj: Record<string, unknown> = {};\n if (vnode.props && vnode.props.attrs) {\n attrsObj = { ...vnode.props.attrs };\n }\n\n const inject = opts?.injectSvgNamespace ?? true;\n const injectKnown = opts?.injectKnownNamespaces ?? inject;\n\n // Inject namespace for well-known tags when missing. By default we\n // preserve previous behavior (SVG injected) and also allow injecting\n // other known namespaces (MathML) when injectKnownNamespaces is true.\n if (inject && vnode.tag === 'svg' && !('xmlns' in attrsObj)) {\n attrsObj.xmlns = SVG_NS;\n } else if (\n injectKnown &&\n vnode.tag in TAG_NAMESPACE_MAP &&\n !('xmlns' in attrsObj)\n ) {\n attrsObj.xmlns = TAG_NAMESPACE_MAP[vnode.tag];\n }\n\n const attrsString = Object.entries(attrsObj)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n","/**\n * Declarative Shadow DOM (DSD) SSR renderer.\n *\n * When `dsd: true` is passed to the render options, registered custom elements\n * are serialised as:\n *\n * ```html\n * <my-element attr=\"val\">\n * <template shadowrootmode=\"open\">\n * <style>\n * /* baseReset + useStyle() output + JIT utility CSS *\\/\n * </style>\n * <!-- shadow DOM from component render function -->\n * </template>\n * <!-- light DOM / slotted children from vnode.children -->\n * </my-element>\n * ```\n *\n * The browser parses the `<template shadowrootmode=\"open\">` block and attaches\n * a real shadow root before any JavaScript executes. All CSS layers are present\n * at first paint — eliminating both FOUC and layout shift.\n *\n * Non-custom-element VNodes are rendered identically to renderToString() but\n * with DSD recursion active for any custom elements nested inside them.\n */\n\nimport type { VNode } from './types';\nimport { renderToString, type RenderOptions } from './vdom-ssr';\nimport { registry } from './component/registry';\nimport { runComponentSSRRender } from './ssr-context';\nimport { jitCSS } from './style';\nimport { baseReset, minifyCSS } from './css-utils';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type DSDRenderOptions = RenderOptions & {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * Shadow content is serialised inside `<template shadowrootmode=\"open\">`,\n * with a complete CSS layer stack (`baseReset` + `useStyle` + JIT CSS)\n * injected as a `<style>` block so styles are available at first paint.\n * @default false\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support\n * (Firefox < 123). Only meaningful when `dsd` is true.\n * @default true\n */\n dsdPolyfill?: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Minified DSD polyfill for browsers without native Declarative Shadow DOM.\n * Processes all `<template shadowrootmode>` elements synchronously.\n */\nexport const DSD_POLYFILL_SCRIPT =\n '<script>(function(){' +\n \"if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;\" +\n \"document.querySelectorAll('template[shadowrootmode]').forEach(function(t){\" +\n \"var m=t.getAttribute('shadowrootmode');\" +\n 'var s=t.parentElement.attachShadow({mode:m});' +\n 's.appendChild(t.content);t.remove();' +\n '});})()' +\n '</script>';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction isRegisteredCustomElement(tag: string): boolean {\n return tag.includes('-') && registry.has(tag);\n}\n\nfunction buildAttrsString(\n attrs: Record<string, unknown>,\n opts: DSDRenderOptions,\n): string {\n const inject = opts.injectSvgNamespace ?? true;\n const injectKnown = opts.injectKnownNamespaces ?? inject;\n\n const merged = { ...attrs };\n\n // Mirror namespace injection logic from renderToString\n const tag = (merged as { _tag?: string })._tag;\n if (tag) delete merged._tag;\n\n if (inject && tag === 'svg' && !('xmlns' in merged)) {\n merged['xmlns'] = SVG_NS;\n } else if (injectKnown && tag && tag in TAG_NAMESPACE_MAP && !('xmlns' in merged)) {\n merged['xmlns'] = TAG_NAMESPACE_MAP[tag];\n }\n\n return Object.entries(merged)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n\n/**\n * Build the combined `<style>` block for a shadow root.\n *\n * Layer order (matches the runtime adoptedStyleSheets order):\n * 1. baseReset — global reset + CSS custom properties\n * 2. useStyle() output — component-defined rules (:host, ::slotted, etc.)\n * 3. JIT CSS — utility classes extracted from the shadow HTML\n */\nfunction buildShadowStyleBlock(\n useStyleCSS: string,\n shadowHTML: string,\n): string {\n const parts: string[] = [baseReset];\n\n if (useStyleCSS.trim()) {\n parts.push(useStyleCSS);\n }\n\n const jit = jitCSS(shadowHTML);\n if (jit.trim()) {\n parts.push(jit);\n }\n\n const combined = minifyCSS(parts.join('\\n'));\n return combined ? `<style>${combined}</style>` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Core renderer\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to an HTML string with Declarative Shadow DOM output\n * for all registered custom elements encountered in the tree.\n */\nexport function renderToDSD(vnode: VNode, opts: DSDRenderOptions): string {\n if (!opts.dsd) {\n return renderToString(vnode, opts);\n }\n\n // Primitive string nodes\n if (typeof vnode === 'string') {\n return escapeHTML(vnode) as string;\n }\n\n const tag = (vnode as VNode).tag;\n\n // Special virtual node types — delegate entirely to the base renderer\n if (tag === '#text' || tag === '#anchor' || tag === '#raw') {\n return renderToString(vnode, opts);\n }\n\n // Custom element — emit DSD wrapper\n if (isRegisteredCustomElement(tag)) {\n return renderCustomElementDSD(vnode, opts);\n }\n\n // Regular element — recurse with DSD mode on\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs, _tag: tag }\n : { _tag: tag };\n\n const attrsString = buildAttrsString(attrsObj, opts);\n\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrsString}>`;\n }\n\n const children = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}>${children}</${tag}>`;\n}\n\nfunction renderCustomElementDSD(vnode: VNode, opts: DSDRenderOptions): string {\n const tag = vnode.tag;\n const config = registry.get(tag);\n\n // Build the plain attribute string (no namespace injection for custom elements)\n const rawAttrs = vnode.props?.attrs ?? {};\n const attrsString = Object.entries(rawAttrs)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Emit data-cer-hydrate when a non-default strategy is configured.\n // 'load' is the default and doesn't need to be serialised.\n const hydrateStrategy = config?.hydrate;\n const hydrateAttr =\n hydrateStrategy && hydrateStrategy !== 'load'\n ? ` data-cer-hydrate=\"${hydrateStrategy}\"`\n : '';\n\n if (!config) {\n // Component not in registry on server (e.g. dynamic import not yet run).\n // Emit a shell with an empty DSD template so the client hydrates normally.\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}${hydrateAttr}><template shadowrootmode=\"open\"></template>${lightDOM}</${tag}>`;\n }\n\n // Run the component's render function in a minimal SSR context to get the\n // shadow DOM VNode tree and capture any useStyle() output.\n const { shadowVNode, useStyleCSS } = runComponentSSRRender(config, rawAttrs, tag);\n\n // Render the shadow DOM VNode tree to HTML (DSD-recursive for nested elements)\n let shadowHTML = '';\n if (shadowVNode !== null && shadowVNode !== undefined) {\n if (Array.isArray(shadowVNode)) {\n shadowHTML = (shadowVNode as VNode[])\n .map((n) => renderToDSD(n, opts))\n .join('');\n } else {\n shadowHTML = renderToDSD(shadowVNode as VNode, opts);\n }\n }\n\n const styleBlock = buildShadowStyleBlock(useStyleCSS, shadowHTML);\n\n // Light DOM children become slotted content — rendered outside the template\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n\n return (\n `<${tag}${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\">${styleBlock}${shadowHTML}</template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n}\n\nfunction renderChildrenDSD(\n children: VNode['children'],\n opts: DSDRenderOptions,\n): string {\n if (!children) return '';\n if (typeof children === 'string') return escapeHTML(children) as string;\n if (Array.isArray(children)) {\n return children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToDSD(c as VNode, opts))\n .join('');\n }\n return renderToDSD(children as VNode, opts);\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a DSD HTML string and optionally append the\n * DSD polyfill script for older browsers.\n */\nexport function renderToStringDSD(\n vnode: VNode,\n opts?: DSDRenderOptions,\n): string {\n const effectiveOpts: DSDRenderOptions = { dsd: true, ...opts };\n const html = renderToDSD(vnode, effectiveOpts);\n\n if (effectiveOpts.dsdPolyfill !== false) {\n // Inject polyfill before </body> if present, otherwise append\n if (html.includes('</body>')) {\n return html.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`);\n }\n return html + DSD_POLYFILL_SCRIPT;\n }\n\n return html;\n}\n","/**\n * SSR entry point — import from `@jasonshimmy/custom-elements-runtime/ssr`.\n *\n * Provides four rendering modes:\n *\n * 1. **renderToString** — baseline HTML serialisation (no shadow DOM content).\n * Backwards-compatible with the original API.\n *\n * 2. **renderToStringWithJITCSS** — HTML + pre-generated JIT CSS injected into\n * `<head>` to prevent FOUC. Supports `dsd: true` for DSD output.\n *\n * 3. **renderToStringWithJITCSSDSD** — convenience alias for DSD mode.\n * Full Declarative Shadow DOM output with per-shadow-root CSS layer stack\n * (baseReset + useStyle() + JIT CSS). Enables true hydration, zero FOUC.\n *\n * 4. **renderToStream** — ReadableStream variant for streaming SSR.\n *\n * Entity map utilities are also exported for full HTML5 named-entity support.\n *\n * @example DSD usage (recommended)\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * res.send(`<!DOCTYPE html><html><head>${head}</head><body>${htmlWithStyles}</body></html>`);\n * ```\n */\n\n// ---------------------------------------------------------------------------\n// Re-exports — backwards-compatible\n// ---------------------------------------------------------------------------\n\nexport { renderToString } from './runtime/vdom-ssr';\nexport type { VNode } from './runtime/types';\nexport type { RenderOptions } from './runtime/vdom-ssr';\n\nexport {\n registerEntityMap,\n loadEntityMap,\n clearRegisteredEntityMap,\n} from './runtime/helpers';\n\nexport {\n renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nexport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\n\n// ---------------------------------------------------------------------------\n// Internal imports\n// ---------------------------------------------------------------------------\n\nimport { renderToString as _render } from './runtime/vdom-ssr';\nimport {\n renderToStringDSD as _renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nimport { jitCSS, enableJITCSS, type JITCSSOptions } from './runtime/style';\nimport type { VNode } from './runtime/types';\nimport type { RenderOptions } from './runtime/vdom-ssr';\nimport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\nimport {\n beginSSRGlobalStyleCollection,\n endSSRGlobalStyleCollection,\n} from './runtime/ssr-context';\n\n// ---------------------------------------------------------------------------\n// Result type\n// ---------------------------------------------------------------------------\n\n/**\n * Result of `renderToStringWithJITCSS()` and `renderToStringWithJITCSSDSD()`.\n */\nexport interface SSRJITResult {\n /** The rendered HTML string (styles not yet injected). */\n html: string;\n /**\n * Global JIT CSS extracted from the rendered HTML.\n * For DSD renders, each shadow root embeds its own scoped styles; this field\n * holds any residual light-DOM utility CSS.\n */\n css: string;\n /**\n * CSS captured from `useGlobalStyle()` calls during this render pass\n * (e.g. `@font-face`, `:root` custom properties).\n * Inject in a `<style id=\"cer-ssr-global\">` in `<head>`.\n */\n globalStyles: string;\n /**\n * Convenience: `html` with both `<style>` tags injected before `</head>`.\n * If no `</head>` is found, the styles are prepended.\n */\n htmlWithStyles: string;\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSS — primary API, supports both modes\n// ---------------------------------------------------------------------------\n\n/**\n * Server-side render a VNode tree and simultaneously pre-generate JIT CSS.\n *\n * Pass `dsd: true` to enable Declarative Shadow DOM output with full per-shadow-\n * root CSS layer extraction (recommended for new apps).\n *\n * @example Standard (no DSD)\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode);\n * ```\n *\n * @example With DSD\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, {\n * dsd: true,\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSS(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): SSRJITResult {\n const { jit, dsd, dsdPolyfill, ...renderOptions } = options ?? {};\n\n if (jit) enableJITCSS(jit);\n\n beginSSRGlobalStyleCollection();\n\n let html!: string;\n let globalStylesCaptured!: string[];\n try {\n if (dsd) {\n // renderToStringDSD handles DSD wrapping but skips the polyfill so we can\n // place it correctly relative to other injected style tags below.\n html = _renderToStringDSD(vnode, {\n ...renderOptions,\n dsd: true,\n dsdPolyfill: false,\n });\n } else {\n html = _render(vnode, renderOptions);\n }\n } finally {\n // Always end collection — even when the render throws — so the collector\n // is never left non-null, which would cause subsequent non-SSR\n // useGlobalStyle() calls to silently skip DOM injection.\n globalStylesCaptured = endSSRGlobalStyleCollection();\n }\n\n const css = jitCSS(html);\n const globalStyles = globalStylesCaptured.join('\\n');\n\n const styleTags: string[] = [];\n if (css) styleTags.push(`<style id=\"cer-ssr-jit\">${css}</style>`);\n if (globalStyles.trim())\n styleTags.push(`<style id=\"cer-ssr-global\">${globalStyles}</style>`);\n\n let htmlWithStyles = html;\n if (styleTags.length) {\n const injection = styleTags.join('');\n htmlWithStyles = html.includes('</head>')\n ? html.replace('</head>', `${injection}</head>`)\n : `${injection}${html}`;\n }\n\n // Append DSD polyfill script inside </body> when in DSD mode\n if (dsd && dsdPolyfill !== false) {\n htmlWithStyles = htmlWithStyles.includes('</body>')\n ? htmlWithStyles.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`)\n : htmlWithStyles + DSD_POLYFILL_SCRIPT;\n }\n\n return { html, css, globalStyles, htmlWithStyles };\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStringWithJITCSS(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output, full per-shadow-root CSS layer\n * extraction, and the DSD browser polyfill. This is the recommended function\n * for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n 'dsd'\n >,\n): SSRJITResult {\n return renderToStringWithJITCSS(vnode, { ...options, dsd: true });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStream — streaming SSR\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a `ReadableStream<string>`.\n *\n * The current implementation flushes the complete rendered output as a single\n * chunk, providing the streaming API surface for framework adapters. True\n * incremental streaming (flush shell immediately, resolve async components\n * progressively) is planned for a future release.\n *\n * @example Node.js\n * ```ts\n * import { renderToStream } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStream(appVNode, { dsd: true });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStream(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): ReadableStream<string> {\n return new ReadableStream<string>({\n start(controller) {\n try {\n const { htmlWithStyles } = renderToStringWithJITCSS(vnode, options);\n controller.enqueue(htmlWithStyles);\n controller.close();\n } catch (err) {\n controller.error(err);\n }\n },\n });\n}\n"],"names":["VOID_ELEMENTS","renderToString","vnode","opts","escapeHTML","c","attrsObj","inject","injectKnown","SVG_NS","TAG_NAMESPACE_MAP","attrsString","k","v","children","DSD_POLYFILL_SCRIPT","isRegisteredCustomElement","tag","registry","buildAttrsString","attrs","merged","buildShadowStyleBlock","useStyleCSS","shadowHTML","parts","baseReset","jit","jitCSS","combined","minifyCSS","renderToDSD","renderCustomElementDSD","renderChildrenDSD","config","rawAttrs","hydrateStrategy","hydrateAttr","lightDOM","shadowVNode","runComponentSSRRender","n","styleBlock","renderToStringDSD","effectiveOpts","html","renderToStringWithJITCSS","options","dsd","dsdPolyfill","renderOptions","beginSSRGlobalStyleCollection","globalStylesCaptured","_renderToStringDSD","_render","endSSRGlobalStyleCollection","css","globalStyles","styleTags","htmlWithStyles","injection","renderToStringWithJITCSSDSD","renderToStream","controller","err"],"mappings":"8OAmBMA,MAAoB,IAAI,CAC5B,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,QACA,SACA,QACA,KACF,CAAC,EAEM,SAASC,EAAeC,EAAcC,EAA8B,CACzE,GAAI,OAAOD,GAAU,SAAU,OAAOE,EAAAA,WAAWF,CAAK,EAEtD,GAAIA,EAAM,MAAQ,QAChB,OAAO,OAAOA,EAAM,UAAa,SAC5BE,EAAAA,WAAWF,EAAM,QAAQ,EAC1B,GAGN,GAAIA,EAAM,MAAQ,UAQhB,OAHiB,MAAM,QAAQA,EAAM,QAAQ,EACzCA,EAAM,SAAS,OAAQG,GAAMA,GAAM,IAAuB,EAC1D,CAAA,GACY,IAAKA,GAAMJ,EAAeI,EAAGF,CAAI,CAAC,EAAE,KAAK,E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AME,EAAYF,EAAU,KAAK,EAAE,EACnCC,EAAiBd,EAAK,SAAS,SAAS,EACpCA,EAAK,QAAQ,UAAW,GAAGe,CAAS,SAAS,EAC7C,GAAGA,CAAS,GAAGf,CAAI,EACzB,CAGA,OAAIG,GAAOC,IAAgB,KACzBU,EAAiBA,EAAe,SAAS,SAAS,EAC9CA,EAAe,QAAQ,UAAW,GAAG5C,CAAmB,SAAS,EACjE4C,EAAiB5C,GAGhB,CAAE,KAAA8B,EAAM,IAAAW,EAAK,aAAAC,EAAc,eAAAE,CAAA,CACpC,CAsBO,SAASE,EACd3D,EACA6C,EAIc,CACd,OAAOD,EAAyB5C,EAAO,CAAE,GAAG6C,EAAS,IAAK,GAAM,CAClE,CA+BO,SAASe,EACd5D,EACA6C,EACwB,CACxB,OAAO,IAAI,eAAuB,CAChC,MAAMgB,EAAY,CAChB,GAAI,CACF,KAAM,CAAE,eAAAJ,CAAA,EAAmBb,EAAyB5C,EAAO6C,CAAO,EAClEgB,EAAW,QAAQJ,CAAc,EACjCI,EAAW,MAAA,CACb,OAASC,EAAK,CACZD,EAAW,MAAMC,CAAG,CACtB,CACF,CAAA,CACD,CACH"}
@@ -1,6 +1,9 @@
1
- import { e, S as f, T as g } from "./namespace-helpers-DhLBqt-7.js";
2
- import { g as j, l as A, h as E } from "./namespace-helpers-DhLBqt-7.js";
3
- const m = /* @__PURE__ */ new Set([
1
+ import { Q as f, S as D, T as E, U as C } from "./hooks-Cze3o-F7.js";
2
+ import { V as F, W as Q, X as U } from "./hooks-Cze3o-F7.js";
3
+ import { S as b, T as p, a as j } from "./namespace-helpers-D4wC2-qA.js";
4
+ import { j as w, e as M } from "./style-BmyOIMcU.js";
5
+ import { m as O, b as x } from "./css-utils-Cg4o1MqY.js";
6
+ const _ = /* @__PURE__ */ new Set([
4
7
  "area",
5
8
  "base",
6
9
  "br",
@@ -16,28 +19,138 @@ const m = /* @__PURE__ */ new Set([
16
19
  "track",
17
20
  "wbr"
18
21
  ]);
19
- function s(r, n) {
20
- if (typeof r == "string") return e(r);
21
- if (r.tag === "#text")
22
- return typeof r.children == "string" ? e(r.children) : "";
23
- if (r.tag === "#anchor")
24
- return (Array.isArray(r.children) ? r.children.filter((a) => a != null) : []).map((a) => s(a, n)).join("");
25
- if (r.tag === "#raw")
26
- return typeof r.children == "string" ? r.children : "";
27
- let i = {};
28
- r.props && r.props.attrs && (i = { ...r.props.attrs });
29
- const c = n?.injectSvgNamespace ?? !0, p = n?.injectKnownNamespaces ?? c;
30
- c && r.tag === "svg" && !("xmlns" in i) ? i.xmlns = f : p && r.tag in g && !("xmlns" in i) && (i.xmlns = g[r.tag]);
31
- const l = Object.entries(i).map(([t, a]) => ` ${t}="${e(String(a))}"`).join("");
32
- if (m.has(r.tag))
33
- return `<${r.tag}${l}>`;
34
- const h = Array.isArray(r.children) ? r.children.filter((t) => t != null).map((t) => s(t, n)).join("") : typeof r.children == "string" ? e(r.children) : r.children ? s(r.children, n) : "";
35
- return `<${r.tag}${l}>${h}</${r.tag}>`;
22
+ function m(t, e) {
23
+ if (typeof t == "string") return f(t);
24
+ if (t.tag === "#text")
25
+ return typeof t.children == "string" ? f(t.children) : "";
26
+ if (t.tag === "#anchor")
27
+ return (Array.isArray(t.children) ? t.children.filter((l) => l != null) : []).map((l) => m(l, e)).join("");
28
+ if (t.tag === "#raw")
29
+ return typeof t.children == "string" ? t.children : "";
30
+ let r = {};
31
+ t.props && t.props.attrs && (r = { ...t.props.attrs });
32
+ const n = e?.injectSvgNamespace ?? !0, i = e?.injectKnownNamespaces ?? n;
33
+ n && t.tag === "svg" && !("xmlns" in r) ? r.xmlns = b : i && t.tag in p && !("xmlns" in r) && (r.xmlns = p[t.tag]);
34
+ const s = Object.entries(r).map(([o, l]) => ` ${o}="${f(String(l))}"`).join("");
35
+ if (_.has(t.tag))
36
+ return `<${t.tag}${s}>`;
37
+ const a = Array.isArray(t.children) ? t.children.filter((o) => o != null).map((o) => m(o, e)).join("") : typeof t.children == "string" ? f(t.children) : t.children ? m(t.children, e) : "";
38
+ return `<${t.tag}${s}>${a}</${t.tag}>`;
39
+ }
40
+ const R = /* @__PURE__ */ new Set([
41
+ "area",
42
+ "base",
43
+ "br",
44
+ "col",
45
+ "embed",
46
+ "hr",
47
+ "img",
48
+ "input",
49
+ "link",
50
+ "meta",
51
+ "param",
52
+ "source",
53
+ "track",
54
+ "wbr"
55
+ ]), y = "<script>(function(){if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;document.querySelectorAll('template[shadowrootmode]').forEach(function(t){var m=t.getAttribute('shadowrootmode');var s=t.parentElement.attachShadow({mode:m});s.appendChild(t.content);t.remove();});})()<\/script>";
56
+ function N(t) {
57
+ return t.includes("-") && j.has(t);
58
+ }
59
+ function L(t, e) {
60
+ const r = e.injectSvgNamespace ?? !0, n = e.injectKnownNamespaces ?? r, i = { ...t }, s = i._tag;
61
+ return s && delete i._tag, r && s === "svg" && !("xmlns" in i) ? i.xmlns = b : n && s && s in p && !("xmlns" in i) && (i.xmlns = p[s]), Object.entries(i).map(([a, o]) => ` ${a}="${f(String(o))}"`).join("");
62
+ }
63
+ function P(t, e) {
64
+ const r = [x];
65
+ t.trim() && r.push(t);
66
+ const n = w(e);
67
+ n.trim() && r.push(n);
68
+ const i = O(r.join(`
69
+ `));
70
+ return i ? `<style>${i}</style>` : "";
71
+ }
72
+ function h(t, e) {
73
+ if (!e.dsd)
74
+ return m(t, e);
75
+ if (typeof t == "string")
76
+ return f(t);
77
+ const r = t.tag;
78
+ if (r === "#text" || r === "#anchor" || r === "#raw")
79
+ return m(t, e);
80
+ if (N(r))
81
+ return I(t, e);
82
+ const n = t.props?.attrs ? { ...t.props.attrs, _tag: r } : { _tag: r }, i = L(n, e);
83
+ if (R.has(r))
84
+ return `<${r}${i}>`;
85
+ const s = $(t.children, e);
86
+ return `<${r}${i}>${s}</${r}>`;
87
+ }
88
+ function I(t, e) {
89
+ const r = t.tag, n = j.get(r), i = t.props?.attrs ?? {}, s = Object.entries(i).map(([g, A]) => ` ${g}="${f(String(A))}"`).join(""), a = n?.hydrate, o = a && a !== "load" ? ` data-cer-hydrate="${a}"` : "";
90
+ if (!n) {
91
+ const g = $(t.children, e);
92
+ return `<${r}${s}${o}><template shadowrootmode="open"></template>${g}</${r}>`;
93
+ }
94
+ const { shadowVNode: l, useStyleCSS: d } = D(n, i, r);
95
+ let c = "";
96
+ l != null && (Array.isArray(l) ? c = l.map((g) => h(g, e)).join("") : c = h(l, e));
97
+ const u = P(d, c), S = $(t.children, e);
98
+ return `<${r}${s}${o}><template shadowrootmode="open">${u}${c}</template>${S}</${r}>`;
99
+ }
100
+ function $(t, e) {
101
+ return t ? typeof t == "string" ? f(t) : Array.isArray(t) ? t.filter((r) => r != null).map((r) => h(r, e)).join("") : h(t, e) : "";
102
+ }
103
+ function k(t, e) {
104
+ const r = { dsd: !0, ...e }, n = h(t, r);
105
+ return r.dsdPolyfill !== !1 ? n.includes("</body>") ? n.replace("</body>", `${y}</body>`) : n + y : n;
106
+ }
107
+ function T(t, e) {
108
+ const { jit: r, dsd: n, dsdPolyfill: i, ...s } = e ?? {};
109
+ r && M(r), E();
110
+ let a, o;
111
+ try {
112
+ n ? a = k(t, {
113
+ ...s,
114
+ dsd: !0,
115
+ dsdPolyfill: !1
116
+ }) : a = m(t, s);
117
+ } finally {
118
+ o = C();
119
+ }
120
+ const l = w(a), d = o.join(`
121
+ `), c = [];
122
+ l && c.push(`<style id="cer-ssr-jit">${l}</style>`), d.trim() && c.push(`<style id="cer-ssr-global">${d}</style>`);
123
+ let u = a;
124
+ if (c.length) {
125
+ const S = c.join("");
126
+ u = a.includes("</head>") ? a.replace("</head>", `${S}</head>`) : `${S}${a}`;
127
+ }
128
+ return n && i !== !1 && (u = u.includes("</body>") ? u.replace("</body>", `${y}</body>`) : u + y), { html: a, css: l, globalStyles: d, htmlWithStyles: u };
129
+ }
130
+ function H(t, e) {
131
+ return T(t, { ...e, dsd: !0 });
132
+ }
133
+ function J(t, e) {
134
+ return new ReadableStream({
135
+ start(r) {
136
+ try {
137
+ const { htmlWithStyles: n } = T(t, e);
138
+ r.enqueue(n), r.close();
139
+ } catch (n) {
140
+ r.error(n);
141
+ }
142
+ }
143
+ });
36
144
  }
37
145
  export {
38
- j as clearRegisteredEntityMap,
39
- A as loadEntityMap,
40
- E as registerEntityMap,
41
- s as renderToString
146
+ y as DSD_POLYFILL_SCRIPT,
147
+ F as clearRegisteredEntityMap,
148
+ Q as loadEntityMap,
149
+ U as registerEntityMap,
150
+ J as renderToStream,
151
+ m as renderToString,
152
+ k as renderToStringDSD,
153
+ T as renderToStringWithJITCSS,
154
+ H as renderToStringWithJITCSSDSD
42
155
  };
43
156
  //# sourceMappingURL=custom-elements-runtime.ssr.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.ssr.es.js","sources":["../src/lib/runtime/vdom-ssr.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\n// HTML void elements that should be self-closing\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n let attrsObj: Record<string, unknown> = {};\n if (vnode.props && vnode.props.attrs) {\n attrsObj = { ...vnode.props.attrs };\n }\n\n const inject = opts?.injectSvgNamespace ?? true;\n const injectKnown = opts?.injectKnownNamespaces ?? inject;\n\n // Inject namespace for well-known tags when missing. By default we\n // preserve previous behavior (SVG injected) and also allow injecting\n // other known namespaces (MathML) when injectKnownNamespaces is true.\n if (inject && vnode.tag === 'svg' && !('xmlns' in attrsObj)) {\n attrsObj.xmlns = SVG_NS;\n } else if (\n injectKnown &&\n vnode.tag in TAG_NAMESPACE_MAP &&\n !('xmlns' in attrsObj)\n ) {\n attrsObj.xmlns = TAG_NAMESPACE_MAP[vnode.tag];\n }\n\n const attrsString = Object.entries(attrsObj)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n"],"names":["VOID_ELEMENTS","renderToString","vnode","opts","escapeHTML","c","attrsObj","inject","injectKnown","SVG_NS","TAG_NAMESPACE_MAP","attrsString","k","v","children"],"mappings":";;AAmBA,MAAMA,wBAAoB,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,SAASC,EAAeC,GAAcC,GAA8B;AACzE,MAAI,OAAOD,KAAU,SAAU,QAAOE,EAAWF,CAAK;AAEtD,MAAIA,EAAM,QAAQ;AAChB,WAAO,OAAOA,EAAM,YAAa,WAC5BE,EAAWF,EAAM,QAAQ,IAC1B;AAGN,MAAIA,EAAM,QAAQ;AAQhB,YAHiB,MAAM,QAAQA,EAAM,QAAQ,IACzCA,EAAM,SAAS,OAAO,CAACG,MAAMA,KAAM,IAAuB,IAC1D,CAAA,GACY,IAAI,CAACA,MAAMJ,EAAeI,GAAGF,CAAI,CAAC,EAAE,KAAK,EAAE;AAG7D,MAAID,EAAM,QAAQ;AAChB,WAAO,OAAOA,EAAM,YAAa,WAAWA,EAAM,WAAW;AAO/D,MAAII,IAAoC,CAAA;AACxC,EAAIJ,EAAM,SAASA,EAAM,MAAM,UAC7BI,IAAW,EAAE,GAAGJ,EAAM,MAAM,MAAA;AAG9B,QAAMK,IAASJ,GAAM,sBAAsB,IACrCK,IAAcL,GAAM,yBAAyBI;AAKnD,EAAIA,KAAUL,EAAM,QAAQ,SAAS,EAAE,WAAWI,KAChDA,EAAS,QAAQG,IAEjBD,KACAN,EAAM,OAAOQ,KACb,EAAE,WAAWJ,OAEbA,EAAS,QAAQI,EAAkBR,EAAM,GAAG;AAG9C,QAAMS,IAAc,OAAO,QAAQL,CAAQ,EACxC,IAAI,CAAC,CAACM,GAAGC,CAAC,MAAM,IAAID,CAAC,KAAKR,EAAW,OAAOS,CAAC,CAAC,CAAC,GAAG,EAClD,KAAK,EAAE;AAGV,MAAIb,EAAc,IAAIE,EAAM,GAAG;AAC7B,WAAO,IAAIA,EAAM,GAAG,GAAGS,CAAW;AAGpC,QAAMG,IAAW,MAAM,QAAQZ,EAAM,QAAQ,IACzCA,EAAM,SACH,OAAO,CAACG,MAAMA,KAAM,IAAuB,EAC3C,IAAI,CAACA,MAAMJ,EAAeI,GAAGF,CAAI,CAAC,EAClC,KAAK,EAAE,IACV,OAAOD,EAAM,YAAa,WACxBE,EAAWF,EAAM,QAAQ,IACzBA,EAAM,WACJD,EAAeC,EAAM,UAAUC,CAAI,IACnC;AAER,SAAO,IAAID,EAAM,GAAG,GAAGS,CAAW,IAAIG,CAAQ,KAAKZ,EAAM,GAAG;AAC9D;"}
1
+ {"version":3,"file":"custom-elements-runtime.ssr.es.js","sources":["../src/lib/runtime/vdom-ssr.ts","../src/lib/runtime/vdom-ssr-dsd.ts","../src/lib/ssr.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n/**\n * Render a VNode to a string (SSR).\n * Kept intentionally minimal: only serializes attributes under `props.attrs`\n * to avoid leaking runtime-only values (functions, reactive state, directives).\n * @param vnode The virtual node to render.\n * @returns The rendered HTML string.\n */\nexport type RenderOptions = {\n /** Backwards-compatible: whether to inject the SVG namespace on <svg> nodes (default true) */\n injectSvgNamespace?: boolean;\n /** Inject known well-known namespaces for tags like <math> when missing (default follows injectSvgNamespace) */\n injectKnownNamespaces?: boolean;\n};\n\n// HTML void elements that should be self-closing\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport function renderToString(vnode: VNode, opts?: RenderOptions): string {\n if (typeof vnode === 'string') return escapeHTML(vnode) as string;\n\n if (vnode.tag === '#text') {\n return typeof vnode.children === 'string'\n ? (escapeHTML(vnode.children) as string)\n : '';\n }\n\n if (vnode.tag === '#anchor') {\n // Preserve meaningful falsy children (0, false, '') while filtering out\n // only null and undefined. Anchor blocks are normalized by the compiler\n // to exclude null/undefined; SSR should follow the same rule to avoid\n // hydration mismatches where falsy values are significant.\n const children = Array.isArray(vnode.children)\n ? vnode.children.filter((c) => c !== null && c !== undefined)\n : [];\n return children.map((c) => renderToString(c, opts)).join('');\n }\n\n if (vnode.tag === '#raw') {\n return typeof vnode.children === 'string' ? vnode.children : '';\n }\n\n // Collect attributes from props.attrs. For SSR we mirror vnode.attrs\n // but ensure SVG nodes behave like client-side: if this is an <svg>\n // and no xmlns was provided, inject the standard SVG namespace so\n // server markup matches client-created DOM namespace.\n let attrsObj: Record<string, unknown> = {};\n if (vnode.props && vnode.props.attrs) {\n attrsObj = { ...vnode.props.attrs };\n }\n\n const inject = opts?.injectSvgNamespace ?? true;\n const injectKnown = opts?.injectKnownNamespaces ?? inject;\n\n // Inject namespace for well-known tags when missing. By default we\n // preserve previous behavior (SVG injected) and also allow injecting\n // other known namespaces (MathML) when injectKnownNamespaces is true.\n if (inject && vnode.tag === 'svg' && !('xmlns' in attrsObj)) {\n attrsObj.xmlns = SVG_NS;\n } else if (\n injectKnown &&\n vnode.tag in TAG_NAMESPACE_MAP &&\n !('xmlns' in attrsObj)\n ) {\n attrsObj.xmlns = TAG_NAMESPACE_MAP[vnode.tag];\n }\n\n const attrsString = Object.entries(attrsObj)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Handle void elements (self-closing tags)\n if (VOID_ELEMENTS.has(vnode.tag)) {\n return `<${vnode.tag}${attrsString}>`;\n }\n\n const children = Array.isArray(vnode.children)\n ? vnode.children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToString(c, opts))\n .join('')\n : typeof vnode.children === 'string'\n ? escapeHTML(vnode.children)\n : vnode.children\n ? renderToString(vnode.children, opts)\n : '';\n\n return `<${vnode.tag}${attrsString}>${children}</${vnode.tag}>`;\n}\n","/**\n * Declarative Shadow DOM (DSD) SSR renderer.\n *\n * When `dsd: true` is passed to the render options, registered custom elements\n * are serialised as:\n *\n * ```html\n * <my-element attr=\"val\">\n * <template shadowrootmode=\"open\">\n * <style>\n * /* baseReset + useStyle() output + JIT utility CSS *\\/\n * </style>\n * <!-- shadow DOM from component render function -->\n * </template>\n * <!-- light DOM / slotted children from vnode.children -->\n * </my-element>\n * ```\n *\n * The browser parses the `<template shadowrootmode=\"open\">` block and attaches\n * a real shadow root before any JavaScript executes. All CSS layers are present\n * at first paint — eliminating both FOUC and layout shift.\n *\n * Non-custom-element VNodes are rendered identically to renderToString() but\n * with DSD recursion active for any custom elements nested inside them.\n */\n\nimport type { VNode } from './types';\nimport { renderToString, type RenderOptions } from './vdom-ssr';\nimport { registry } from './component/registry';\nimport { runComponentSSRRender } from './ssr-context';\nimport { jitCSS } from './style';\nimport { baseReset, minifyCSS } from './css-utils';\nimport { escapeHTML } from './helpers';\nimport { TAG_NAMESPACE_MAP, SVG_NS } from './namespace-helpers';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type DSDRenderOptions = RenderOptions & {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * Shadow content is serialised inside `<template shadowrootmode=\"open\">`,\n * with a complete CSS layer stack (`baseReset` + `useStyle` + JIT CSS)\n * injected as a `<style>` block so styles are available at first paint.\n * @default false\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support\n * (Firefox < 123). Only meaningful when `dsd` is true.\n * @default true\n */\n dsdPolyfill?: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Minified DSD polyfill for browsers without native Declarative Shadow DOM.\n * Processes all `<template shadowrootmode>` elements synchronously.\n */\nexport const DSD_POLYFILL_SCRIPT =\n '<script>(function(){' +\n \"if(HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))return;\" +\n \"document.querySelectorAll('template[shadowrootmode]').forEach(function(t){\" +\n \"var m=t.getAttribute('shadowrootmode');\" +\n 'var s=t.parentElement.attachShadow({mode:m});' +\n 's.appendChild(t.content);t.remove();' +\n '});})()' +\n '</script>';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction isRegisteredCustomElement(tag: string): boolean {\n return tag.includes('-') && registry.has(tag);\n}\n\nfunction buildAttrsString(\n attrs: Record<string, unknown>,\n opts: DSDRenderOptions,\n): string {\n const inject = opts.injectSvgNamespace ?? true;\n const injectKnown = opts.injectKnownNamespaces ?? inject;\n\n const merged = { ...attrs };\n\n // Mirror namespace injection logic from renderToString\n const tag = (merged as { _tag?: string })._tag;\n if (tag) delete merged._tag;\n\n if (inject && tag === 'svg' && !('xmlns' in merged)) {\n merged['xmlns'] = SVG_NS;\n } else if (injectKnown && tag && tag in TAG_NAMESPACE_MAP && !('xmlns' in merged)) {\n merged['xmlns'] = TAG_NAMESPACE_MAP[tag];\n }\n\n return Object.entries(merged)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n}\n\n/**\n * Build the combined `<style>` block for a shadow root.\n *\n * Layer order (matches the runtime adoptedStyleSheets order):\n * 1. baseReset — global reset + CSS custom properties\n * 2. useStyle() output — component-defined rules (:host, ::slotted, etc.)\n * 3. JIT CSS — utility classes extracted from the shadow HTML\n */\nfunction buildShadowStyleBlock(\n useStyleCSS: string,\n shadowHTML: string,\n): string {\n const parts: string[] = [baseReset];\n\n if (useStyleCSS.trim()) {\n parts.push(useStyleCSS);\n }\n\n const jit = jitCSS(shadowHTML);\n if (jit.trim()) {\n parts.push(jit);\n }\n\n const combined = minifyCSS(parts.join('\\n'));\n return combined ? `<style>${combined}</style>` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Core renderer\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to an HTML string with Declarative Shadow DOM output\n * for all registered custom elements encountered in the tree.\n */\nexport function renderToDSD(vnode: VNode, opts: DSDRenderOptions): string {\n if (!opts.dsd) {\n return renderToString(vnode, opts);\n }\n\n // Primitive string nodes\n if (typeof vnode === 'string') {\n return escapeHTML(vnode) as string;\n }\n\n const tag = (vnode as VNode).tag;\n\n // Special virtual node types — delegate entirely to the base renderer\n if (tag === '#text' || tag === '#anchor' || tag === '#raw') {\n return renderToString(vnode, opts);\n }\n\n // Custom element — emit DSD wrapper\n if (isRegisteredCustomElement(tag)) {\n return renderCustomElementDSD(vnode, opts);\n }\n\n // Regular element — recurse with DSD mode on\n const attrsObj: Record<string, unknown> = vnode.props?.attrs\n ? { ...vnode.props.attrs, _tag: tag }\n : { _tag: tag };\n\n const attrsString = buildAttrsString(attrsObj, opts);\n\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrsString}>`;\n }\n\n const children = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}>${children}</${tag}>`;\n}\n\nfunction renderCustomElementDSD(vnode: VNode, opts: DSDRenderOptions): string {\n const tag = vnode.tag;\n const config = registry.get(tag);\n\n // Build the plain attribute string (no namespace injection for custom elements)\n const rawAttrs = vnode.props?.attrs ?? {};\n const attrsString = Object.entries(rawAttrs)\n .map(([k, v]) => ` ${k}=\"${escapeHTML(String(v))}\"`)\n .join('');\n\n // Emit data-cer-hydrate when a non-default strategy is configured.\n // 'load' is the default and doesn't need to be serialised.\n const hydrateStrategy = config?.hydrate;\n const hydrateAttr =\n hydrateStrategy && hydrateStrategy !== 'load'\n ? ` data-cer-hydrate=\"${hydrateStrategy}\"`\n : '';\n\n if (!config) {\n // Component not in registry on server (e.g. dynamic import not yet run).\n // Emit a shell with an empty DSD template so the client hydrates normally.\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n return `<${tag}${attrsString}${hydrateAttr}><template shadowrootmode=\"open\"></template>${lightDOM}</${tag}>`;\n }\n\n // Run the component's render function in a minimal SSR context to get the\n // shadow DOM VNode tree and capture any useStyle() output.\n const { shadowVNode, useStyleCSS } = runComponentSSRRender(config, rawAttrs, tag);\n\n // Render the shadow DOM VNode tree to HTML (DSD-recursive for nested elements)\n let shadowHTML = '';\n if (shadowVNode !== null && shadowVNode !== undefined) {\n if (Array.isArray(shadowVNode)) {\n shadowHTML = (shadowVNode as VNode[])\n .map((n) => renderToDSD(n, opts))\n .join('');\n } else {\n shadowHTML = renderToDSD(shadowVNode as VNode, opts);\n }\n }\n\n const styleBlock = buildShadowStyleBlock(useStyleCSS, shadowHTML);\n\n // Light DOM children become slotted content — rendered outside the template\n const lightDOM = renderChildrenDSD(vnode.children, opts);\n\n return (\n `<${tag}${attrsString}${hydrateAttr}>` +\n `<template shadowrootmode=\"open\">${styleBlock}${shadowHTML}</template>` +\n `${lightDOM}` +\n `</${tag}>`\n );\n}\n\nfunction renderChildrenDSD(\n children: VNode['children'],\n opts: DSDRenderOptions,\n): string {\n if (!children) return '';\n if (typeof children === 'string') return escapeHTML(children) as string;\n if (Array.isArray(children)) {\n return children\n .filter((c) => c !== null && c !== undefined)\n .map((c) => renderToDSD(c as VNode, opts))\n .join('');\n }\n return renderToDSD(children as VNode, opts);\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a DSD HTML string and optionally append the\n * DSD polyfill script for older browsers.\n */\nexport function renderToStringDSD(\n vnode: VNode,\n opts?: DSDRenderOptions,\n): string {\n const effectiveOpts: DSDRenderOptions = { dsd: true, ...opts };\n const html = renderToDSD(vnode, effectiveOpts);\n\n if (effectiveOpts.dsdPolyfill !== false) {\n // Inject polyfill before </body> if present, otherwise append\n if (html.includes('</body>')) {\n return html.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`);\n }\n return html + DSD_POLYFILL_SCRIPT;\n }\n\n return html;\n}\n","/**\n * SSR entry point — import from `@jasonshimmy/custom-elements-runtime/ssr`.\n *\n * Provides four rendering modes:\n *\n * 1. **renderToString** — baseline HTML serialisation (no shadow DOM content).\n * Backwards-compatible with the original API.\n *\n * 2. **renderToStringWithJITCSS** — HTML + pre-generated JIT CSS injected into\n * `<head>` to prevent FOUC. Supports `dsd: true` for DSD output.\n *\n * 3. **renderToStringWithJITCSSDSD** — convenience alias for DSD mode.\n * Full Declarative Shadow DOM output with per-shadow-root CSS layer stack\n * (baseReset + useStyle() + JIT CSS). Enables true hydration, zero FOUC.\n *\n * 4. **renderToStream** — ReadableStream variant for streaming SSR.\n *\n * Entity map utilities are also exported for full HTML5 named-entity support.\n *\n * @example DSD usage (recommended)\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * res.send(`<!DOCTYPE html><html><head>${head}</head><body>${htmlWithStyles}</body></html>`);\n * ```\n */\n\n// ---------------------------------------------------------------------------\n// Re-exports — backwards-compatible\n// ---------------------------------------------------------------------------\n\nexport { renderToString } from './runtime/vdom-ssr';\nexport type { VNode } from './runtime/types';\nexport type { RenderOptions } from './runtime/vdom-ssr';\n\nexport {\n registerEntityMap,\n loadEntityMap,\n clearRegisteredEntityMap,\n} from './runtime/helpers';\n\nexport {\n renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nexport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\n\n// ---------------------------------------------------------------------------\n// Internal imports\n// ---------------------------------------------------------------------------\n\nimport { renderToString as _render } from './runtime/vdom-ssr';\nimport {\n renderToStringDSD as _renderToStringDSD,\n DSD_POLYFILL_SCRIPT,\n} from './runtime/vdom-ssr-dsd';\nimport { jitCSS, enableJITCSS, type JITCSSOptions } from './runtime/style';\nimport type { VNode } from './runtime/types';\nimport type { RenderOptions } from './runtime/vdom-ssr';\nimport type { DSDRenderOptions } from './runtime/vdom-ssr-dsd';\nimport {\n beginSSRGlobalStyleCollection,\n endSSRGlobalStyleCollection,\n} from './runtime/ssr-context';\n\n// ---------------------------------------------------------------------------\n// Result type\n// ---------------------------------------------------------------------------\n\n/**\n * Result of `renderToStringWithJITCSS()` and `renderToStringWithJITCSSDSD()`.\n */\nexport interface SSRJITResult {\n /** The rendered HTML string (styles not yet injected). */\n html: string;\n /**\n * Global JIT CSS extracted from the rendered HTML.\n * For DSD renders, each shadow root embeds its own scoped styles; this field\n * holds any residual light-DOM utility CSS.\n */\n css: string;\n /**\n * CSS captured from `useGlobalStyle()` calls during this render pass\n * (e.g. `@font-face`, `:root` custom properties).\n * Inject in a `<style id=\"cer-ssr-global\">` in `<head>`.\n */\n globalStyles: string;\n /**\n * Convenience: `html` with both `<style>` tags injected before `</head>`.\n * If no `</head>` is found, the styles are prepended.\n */\n htmlWithStyles: string;\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSS — primary API, supports both modes\n// ---------------------------------------------------------------------------\n\n/**\n * Server-side render a VNode tree and simultaneously pre-generate JIT CSS.\n *\n * Pass `dsd: true` to enable Declarative Shadow DOM output with full per-shadow-\n * root CSS layer extraction (recommended for new apps).\n *\n * @example Standard (no DSD)\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode);\n * ```\n *\n * @example With DSD\n * ```ts\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, {\n * dsd: true,\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSS(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): SSRJITResult {\n const { jit, dsd, dsdPolyfill, ...renderOptions } = options ?? {};\n\n if (jit) enableJITCSS(jit);\n\n beginSSRGlobalStyleCollection();\n\n let html!: string;\n let globalStylesCaptured!: string[];\n try {\n if (dsd) {\n // renderToStringDSD handles DSD wrapping but skips the polyfill so we can\n // place it correctly relative to other injected style tags below.\n html = _renderToStringDSD(vnode, {\n ...renderOptions,\n dsd: true,\n dsdPolyfill: false,\n });\n } else {\n html = _render(vnode, renderOptions);\n }\n } finally {\n // Always end collection — even when the render throws — so the collector\n // is never left non-null, which would cause subsequent non-SSR\n // useGlobalStyle() calls to silently skip DOM injection.\n globalStylesCaptured = endSSRGlobalStyleCollection();\n }\n\n const css = jitCSS(html);\n const globalStyles = globalStylesCaptured.join('\\n');\n\n const styleTags: string[] = [];\n if (css) styleTags.push(`<style id=\"cer-ssr-jit\">${css}</style>`);\n if (globalStyles.trim())\n styleTags.push(`<style id=\"cer-ssr-global\">${globalStyles}</style>`);\n\n let htmlWithStyles = html;\n if (styleTags.length) {\n const injection = styleTags.join('');\n htmlWithStyles = html.includes('</head>')\n ? html.replace('</head>', `${injection}</head>`)\n : `${injection}${html}`;\n }\n\n // Append DSD polyfill script inside </body> when in DSD mode\n if (dsd && dsdPolyfill !== false) {\n htmlWithStyles = htmlWithStyles.includes('</body>')\n ? htmlWithStyles.replace('</body>', `${DSD_POLYFILL_SCRIPT}</body>`)\n : htmlWithStyles + DSD_POLYFILL_SCRIPT;\n }\n\n return { html, css, globalStyles, htmlWithStyles };\n}\n\n// ---------------------------------------------------------------------------\n// renderToStringWithJITCSSDSD — convenience alias\n// ---------------------------------------------------------------------------\n\n/**\n * Convenience alias: `renderToStringWithJITCSS(vnode, { dsd: true, ...options })`.\n *\n * Renders with Declarative Shadow DOM output, full per-shadow-root CSS layer\n * extraction, and the DSD browser polyfill. This is the recommended function\n * for all new server-rendered applications.\n *\n * @example\n * ```ts\n * import { renderToStringWithJITCSSDSD } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSSDSD(appVNode, {\n * jit: { extendedColors: true },\n * });\n * ```\n */\nexport function renderToStringWithJITCSSDSD(\n vnode: VNode,\n options?: Omit<\n RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n 'dsd'\n >,\n): SSRJITResult {\n return renderToStringWithJITCSS(vnode, { ...options, dsd: true });\n}\n\n// ---------------------------------------------------------------------------\n// renderToStream — streaming SSR\n// ---------------------------------------------------------------------------\n\n/**\n * Render a VNode tree to a `ReadableStream<string>`.\n *\n * The current implementation flushes the complete rendered output as a single\n * chunk, providing the streaming API surface for framework adapters. True\n * incremental streaming (flush shell immediately, resolve async components\n * progressively) is planned for a future release.\n *\n * @example Node.js\n * ```ts\n * import { renderToStream } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * app.get('/', (req, res) => {\n * const stream = renderToStream(appVNode, { dsd: true });\n * const reader = stream.getReader();\n * const pump = () =>\n * reader.read().then(({ value, done }) => {\n * if (done) { res.end(); return; }\n * res.write(value);\n * pump();\n * });\n * pump();\n * });\n * ```\n */\nexport function renderToStream(\n vnode: VNode,\n options?: RenderOptions & DSDRenderOptions & { jit?: JITCSSOptions },\n): ReadableStream<string> {\n return new ReadableStream<string>({\n start(controller) {\n try {\n const { htmlWithStyles } = renderToStringWithJITCSS(vnode, options);\n controller.enqueue(htmlWithStyles);\n controller.close();\n } catch (err) {\n controller.error(err);\n }\n },\n });\n}\n"],"names":["VOID_ELEMENTS","renderToString","vnode","opts","escapeHTML","c","attrsObj","inject","injectKnown","SVG_NS","TAG_NAMESPACE_MAP","attrsString","k","v","children","DSD_POLYFILL_SCRIPT","isRegisteredCustomElement","tag","registry","buildAttrsString","attrs","merged","buildShadowStyleBlock","useStyleCSS","shadowHTML","parts","baseReset","jit","jitCSS","combined","minifyCSS","renderToDSD","renderCustomElementDSD","renderChildrenDSD","config","rawAttrs","hydrateStrategy","hydrateAttr","lightDOM","shadowVNode","runComponentSSRRender","n","styleBlock","renderToStringDSD","effectiveOpts","html","renderToStringWithJITCSS","options","dsd","dsdPolyfill","renderOptions","beginSSRGlobalStyleCollection","globalStylesCaptured","_renderToStringDSD","_render","endSSRGlobalStyleCollection","css","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O,IAAI,eAAuB;AAAA,IAChC,MAAMgB,GAAY;AAChB,UAAI;AACF,cAAM,EAAE,gBAAAJ,EAAA,IAAmBb,EAAyB5C,GAAO6C,CAAO;AAClE,QAAAgB,EAAW,QAAQJ,CAAc,GACjCI,EAAW,MAAA;AAAA,MACb,SAASC,GAAK;AACZ,QAAAD,EAAW,MAAMC,CAAG;AAAA,MACtB;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(c){let e={...c};const n=[];function f(t){return n.push(t),t(e),()=>{const o=n.indexOf(t);o!==-1&&n.splice(o,1)}}function u(){return e}function r(t){const o=typeof t=="function"?t(e):t;e={...e,...o},i()}function i(){for(const t of n)t(e)}return{subscribe:f,getState:u,setState:r}}exports.createStore=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./logger-CSALKaYm.cjs"),f=50;function d(o){let t={...o};const n=[];function s(e){return n.push(e),n.length>=f&&a.devWarn(`[store] ${n.length} active subscriptions detected. This may indicate orphaned listeners from components that were destroyed without calling their unsubscribe function. Check that every subscribe() call is paired with the returned unsubscribe in a disconnect/cleanup handler.`),e(t),()=>{const c=n.indexOf(e);c!==-1&&n.splice(c,1)}}function i(){return t}function r(e){const c=typeof e=="function"?e(t):e;t={...t,...c},u()}function u(){const e=n.slice();for(const c of e)c(t)}return{subscribe:s,getState:i,setState:r}}exports.createStore=d;
2
2
  //# sourceMappingURL=custom-elements-runtime.store.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.store.cjs.js","sources":["../src/lib/store.ts"],"sourcesContent":["type Listener<T> = (state: T) => void;\n\nexport interface Store<T extends object> {\n /**\n * Subscribe to store updates.\n * Returns an unsubscribe function to remove the listener.\n */\n subscribe(listener: Listener<T>): () => void;\n getState(): T;\n setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;\n}\n\nexport function createStore<T extends object>(initial: T): Store<T> {\n let state = { ...initial } as T; // no Proxy needed if we update via setState\n const listeners: Listener<T>[] = [];\n\n function subscribe(listener: Listener<T>) {\n listeners.push(listener);\n listener(state); // initial push\n\n // Return unsubscribe function\n return () => {\n const idx = listeners.indexOf(listener);\n if (idx !== -1) listeners.splice(idx, 1);\n };\n }\n\n function getState(): T {\n return state;\n }\n\n function setState(partial: Partial<T> | ((prev: T) => Partial<T>)) {\n const next = typeof partial === 'function' ? partial(state) : partial;\n\n state = { ...state, ...next };\n notify();\n }\n\n function notify() {\n for (const fn of listeners) fn(state);\n }\n\n return { subscribe, getState, setState };\n}\n"],"names":["createStore","initial","state","listeners","subscribe","listener","idx","getState","setState","partial","next","notify","fn"],"mappings":"gFAYO,SAASA,EAA8BC,EAAsB,CAClE,IAAIC,EAAQ,CAAE,GAAGD,CAAA,EACjB,MAAME,EAA2B,CAAA,EAEjC,SAASC,EAAUC,EAAuB,CACxC,OAAAF,EAAU,KAAKE,CAAQ,EACvBA,EAASH,CAAK,EAGP,IAAM,CACX,MAAMI,EAAMH,EAAU,QAAQE,CAAQ,EAClCC,IAAQ,IAAIH,EAAU,OAAOG,EAAK,CAAC,CACzC,CACF,CAEA,SAASC,GAAc,CACrB,OAAOL,CACT,CAEA,SAASM,EAASC,EAAiD,CACjE,MAAMC,EAAO,OAAOD,GAAY,WAAaA,EAAQP,CAAK,EAAIO,EAE9DP,EAAQ,CAAE,GAAGA,EAAO,GAAGQ,CAAA,EACvBC,EAAA,CACF,CAEA,SAASA,GAAS,CAChB,UAAWC,KAAMT,EAAWS,EAAGV,CAAK,CACtC,CAEA,MAAO,CAAE,UAAAE,EAAW,SAAAG,EAAU,SAAAC,CAAA,CAChC"}
1
+ {"version":3,"file":"custom-elements-runtime.store.cjs.js","sources":["../src/lib/store.ts"],"sourcesContent":["type Listener<T> = (state: T) => void;\n\nimport { devWarn } from './runtime/logger';\n\nconst STORE_LISTENER_WARN_THRESHOLD = 50;\n\nexport interface Store<T extends object> {\n /**\n * Subscribe to store updates.\n * Returns an unsubscribe function to remove the listener.\n */\n subscribe(listener: Listener<T>): () => void;\n getState(): T;\n setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;\n}\n\nexport function createStore<T extends object>(initial: T): Store<T> {\n let state = { ...initial } as T; // no Proxy needed if we update via setState\n const listeners: Listener<T>[] = [];\n\n function subscribe(listener: Listener<T>) {\n listeners.push(listener);\n if (listeners.length >= STORE_LISTENER_WARN_THRESHOLD) {\n devWarn(\n `[store] ${listeners.length} active subscriptions detected. ` +\n 'This may indicate orphaned listeners from components that were destroyed ' +\n 'without calling their unsubscribe function. Check that every subscribe() ' +\n 'call is paired with the returned unsubscribe in a disconnect/cleanup handler.',\n );\n }\n listener(state); // initial push\n\n // Return unsubscribe function\n return () => {\n const idx = listeners.indexOf(listener);\n if (idx !== -1) listeners.splice(idx, 1);\n };\n }\n\n function getState(): T {\n return state;\n }\n\n function setState(partial: Partial<T> | ((prev: T) => Partial<T>)) {\n const next = typeof partial === 'function' ? partial(state) : partial;\n\n state = { ...state, ...next };\n notify();\n }\n\n function notify() {\n // Snapshot the listeners array before iterating so that a listener calling\n // setState() (re-entrant notify) cannot corrupt the current iteration.\n const snapshot = listeners.slice();\n for (const fn of snapshot) fn(state);\n }\n\n return { subscribe, getState, setState };\n}\n"],"names":["STORE_LISTENER_WARN_THRESHOLD","createStore","initial","state","listeners","subscribe","listener","devWarn","idx","getState","setState","partial","next","notify","snapshot","fn"],"mappings":"yHAIMA,EAAgC,GAY/B,SAASC,EAA8BC,EAAsB,CAClE,IAAIC,EAAQ,CAAE,GAAGD,CAAA,EACjB,MAAME,EAA2B,CAAA,EAEjC,SAASC,EAAUC,EAAuB,CACxC,OAAAF,EAAU,KAAKE,CAAQ,EACnBF,EAAU,QAAUJ,GACtBO,EAAAA,QACE,WAAWH,EAAU,MAAM,iQAAA,EAM/BE,EAASH,CAAK,EAGP,IAAM,CACX,MAAMK,EAAMJ,EAAU,QAAQE,CAAQ,EAClCE,IAAQ,IAAIJ,EAAU,OAAOI,EAAK,CAAC,CACzC,CACF,CAEA,SAASC,GAAc,CACrB,OAAON,CACT,CAEA,SAASO,EAASC,EAAiD,CACjE,MAAMC,EAAO,OAAOD,GAAY,WAAaA,EAAQR,CAAK,EAAIQ,EAE9DR,EAAQ,CAAE,GAAGA,EAAO,GAAGS,CAAA,EACvBC,EAAA,CACF,CAEA,SAASA,GAAS,CAGhB,MAAMC,EAAWV,EAAU,MAAA,EAC3B,UAAWW,KAAMD,EAAUC,EAAGZ,CAAK,CACrC,CAEA,MAAO,CAAE,UAAAE,EAAW,SAAAI,EAAU,SAAAC,CAAA,CAChC"}
@@ -1,25 +1,30 @@
1
- function r(c) {
2
- let n = { ...c };
3
- const e = [];
4
- function f(t) {
5
- return e.push(t), t(n), () => {
6
- const o = e.indexOf(t);
7
- o !== -1 && e.splice(o, 1);
1
+ import { a as f } from "./logger-BvkEbVM4.js";
2
+ const a = 50;
3
+ function d(c) {
4
+ let e = { ...c };
5
+ const n = [];
6
+ function i(t) {
7
+ return n.push(t), n.length >= a && f(
8
+ `[store] ${n.length} active subscriptions detected. This may indicate orphaned listeners from components that were destroyed without calling their unsubscribe function. Check that every subscribe() call is paired with the returned unsubscribe in a disconnect/cleanup handler.`
9
+ ), t(e), () => {
10
+ const s = n.indexOf(t);
11
+ s !== -1 && n.splice(s, 1);
8
12
  };
9
13
  }
10
- function u() {
11
- return n;
14
+ function o() {
15
+ return e;
12
16
  }
13
- function s(t) {
14
- const o = typeof t == "function" ? t(n) : t;
15
- n = { ...n, ...o }, i();
17
+ function r(t) {
18
+ const s = typeof t == "function" ? t(e) : t;
19
+ e = { ...e, ...s }, u();
16
20
  }
17
- function i() {
18
- for (const t of e) t(n);
21
+ function u() {
22
+ const t = n.slice();
23
+ for (const s of t) s(e);
19
24
  }
20
- return { subscribe: f, getState: u, setState: s };
25
+ return { subscribe: i, getState: o, setState: r };
21
26
  }
22
27
  export {
23
- r as createStore
28
+ d as createStore
24
29
  };
25
30
  //# sourceMappingURL=custom-elements-runtime.store.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.store.es.js","sources":["../src/lib/store.ts"],"sourcesContent":["type Listener<T> = (state: T) => void;\n\nexport interface Store<T extends object> {\n /**\n * Subscribe to store updates.\n * Returns an unsubscribe function to remove the listener.\n */\n subscribe(listener: Listener<T>): () => void;\n getState(): T;\n setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;\n}\n\nexport function createStore<T extends object>(initial: T): Store<T> {\n let state = { ...initial } as T; // no Proxy needed if we update via setState\n const listeners: Listener<T>[] = [];\n\n function subscribe(listener: Listener<T>) {\n listeners.push(listener);\n listener(state); // initial push\n\n // Return unsubscribe function\n return () => {\n const idx = listeners.indexOf(listener);\n if (idx !== -1) listeners.splice(idx, 1);\n };\n }\n\n function getState(): T {\n return state;\n }\n\n function setState(partial: Partial<T> | ((prev: T) => Partial<T>)) {\n const next = typeof partial === 'function' ? partial(state) : partial;\n\n state = { ...state, ...next };\n notify();\n }\n\n function notify() {\n for (const fn of listeners) fn(state);\n }\n\n return { subscribe, getState, setState };\n}\n"],"names":["createStore","initial","state","listeners","subscribe","listener","idx","getState","setState","partial","next","notify","fn"],"mappings":"AAYO,SAASA,EAA8BC,GAAsB;AAClE,MAAIC,IAAQ,EAAE,GAAGD,EAAA;AACjB,QAAME,IAA2B,CAAA;AAEjC,WAASC,EAAUC,GAAuB;AACxC,WAAAF,EAAU,KAAKE,CAAQ,GACvBA,EAASH,CAAK,GAGP,MAAM;AACX,YAAMI,IAAMH,EAAU,QAAQE,CAAQ;AACtC,MAAIC,MAAQ,MAAIH,EAAU,OAAOG,GAAK,CAAC;AAAA,IACzC;AAAA,EACF;AAEA,WAASC,IAAc;AACrB,WAAOL;AAAA,EACT;AAEA,WAASM,EAASC,GAAiD;AACjE,UAAMC,IAAO,OAAOD,KAAY,aAAaA,EAAQP,CAAK,IAAIO;AAE9D,IAAAP,IAAQ,EAAE,GAAGA,GAAO,GAAGQ,EAAA,GACvBC,EAAA;AAAA,EACF;AAEA,WAASA,IAAS;AAChB,eAAWC,KAAMT,EAAW,CAAAS,EAAGV,CAAK;AAAA,EACtC;AAEA,SAAO,EAAE,WAAAE,GAAW,UAAAG,GAAU,UAAAC,EAAA;AAChC;"}
1
+ {"version":3,"file":"custom-elements-runtime.store.es.js","sources":["../src/lib/store.ts"],"sourcesContent":["type Listener<T> = (state: T) => void;\n\nimport { devWarn } from './runtime/logger';\n\nconst STORE_LISTENER_WARN_THRESHOLD = 50;\n\nexport interface Store<T extends object> {\n /**\n * Subscribe to store updates.\n * Returns an unsubscribe function to remove the listener.\n */\n subscribe(listener: Listener<T>): () => void;\n getState(): T;\n setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;\n}\n\nexport function createStore<T extends object>(initial: T): Store<T> {\n let state = { ...initial } as T; // no Proxy needed if we update via setState\n const listeners: Listener<T>[] = [];\n\n function subscribe(listener: Listener<T>) {\n listeners.push(listener);\n if (listeners.length >= STORE_LISTENER_WARN_THRESHOLD) {\n devWarn(\n `[store] ${listeners.length} active subscriptions detected. ` +\n 'This may indicate orphaned listeners from components that were destroyed ' +\n 'without calling their unsubscribe function. Check that every subscribe() ' +\n 'call is paired with the returned unsubscribe in a disconnect/cleanup handler.',\n );\n }\n listener(state); // initial push\n\n // Return unsubscribe function\n return () => {\n const idx = listeners.indexOf(listener);\n if (idx !== -1) listeners.splice(idx, 1);\n };\n }\n\n function getState(): T {\n return state;\n }\n\n function setState(partial: Partial<T> | ((prev: T) => Partial<T>)) {\n const next = typeof partial === 'function' ? partial(state) : partial;\n\n state = { ...state, ...next };\n notify();\n }\n\n function notify() {\n // Snapshot the listeners array before iterating so that a listener calling\n // setState() (re-entrant notify) cannot corrupt the current iteration.\n const snapshot = listeners.slice();\n for (const fn of snapshot) fn(state);\n }\n\n return { subscribe, getState, setState };\n}\n"],"names":["STORE_LISTENER_WARN_THRESHOLD","createStore","initial","state","listeners","subscribe","listener","devWarn","idx","getState","setState","partial","next","notify","snapshot","fn"],"mappings":";AAIA,MAAMA,IAAgC;AAY/B,SAASC,EAA8BC,GAAsB;AAClE,MAAIC,IAAQ,EAAE,GAAGD,EAAA;AACjB,QAAME,IAA2B,CAAA;AAEjC,WAASC,EAAUC,GAAuB;AACxC,WAAAF,EAAU,KAAKE,CAAQ,GACnBF,EAAU,UAAUJ,KACtBO;AAAA,MACE,WAAWH,EAAU,MAAM;AAAA,IAAA,GAM/BE,EAASH,CAAK,GAGP,MAAM;AACX,YAAMK,IAAMJ,EAAU,QAAQE,CAAQ;AACtC,MAAIE,MAAQ,MAAIJ,EAAU,OAAOI,GAAK,CAAC;AAAA,IACzC;AAAA,EACF;AAEA,WAASC,IAAc;AACrB,WAAON;AAAA,EACT;AAEA,WAASO,EAASC,GAAiD;AACjE,UAAMC,IAAO,OAAOD,KAAY,aAAaA,EAAQR,CAAK,IAAIQ;AAE9D,IAAAR,IAAQ,EAAE,GAAGA,GAAO,GAAGS,EAAA,GACvBC,EAAA;AAAA,EACF;AAEA,WAASA,IAAS;AAGhB,UAAMC,IAAWV,EAAU,MAAA;AAC3B,eAAWW,KAAMD,EAAU,CAAAC,EAAGZ,CAAK;AAAA,EACrC;AAEA,SAAO,EAAE,WAAAE,GAAW,UAAAI,GAAU,UAAAC,EAAA;AAChC;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./custom-elements-runtime.directives.cjs.js");const t=require("./transitions-f4KfN29T.cjs");exports.Transition=t.Transition;exports.TransitionGroup=t.TransitionGroup;exports.createTransitionPreset=t.createTransitionPreset;exports.getTransitionStyleSheet=t.getTransitionStyleSheet;exports.transitionPresets=t.transitionPresets;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./custom-elements-runtime.directives.cjs.js"),q=require("./css-utils-RqkyBWft.cjs"),d={fade:{enterFrom:"opacity-0",enterActive:"transition-opacity duration-300 ease-out",enterTo:"opacity-100",leaveFrom:"opacity-100",leaveActive:"transition-opacity duration-200 ease-in",leaveTo:"opacity-0"},"slide-right":{enterFrom:"translate-x-[100%] opacity-0",enterActive:"transition-all duration-300 ease-out",enterTo:"translate-x-[0%] opacity-100",leaveFrom:"translate-x-[0%] opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"translate-x-[100%] opacity-0"},"slide-left":{enterFrom:"translate-x-[-100%] opacity-0",enterActive:"transition-all duration-300 ease-out",enterTo:"translate-x-[0%] opacity-100",leaveFrom:"translate-x-[0%] opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"translate-x-[-100%] opacity-0"},"slide-up":{enterFrom:"translate-y-[100%] opacity-0",enterActive:"transition-all duration-300 ease-out",enterTo:"translate-y-[0%] opacity-100",leaveFrom:"translate-y-[0%] opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"translate-y-[100%] opacity-0"},"slide-down":{enterFrom:"translate-y-[-100%] opacity-0",enterActive:"transition-all duration-300 ease-out",enterTo:"translate-y-[0%] opacity-100",leaveFrom:"translate-y-[0%] opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"translate-y-[-100%] opacity-0"},scale:{enterFrom:"scale-95 opacity-0",enterActive:"transition-all duration-200 ease-out",enterTo:"scale-100 opacity-100",leaveFrom:"scale-100 opacity-100",leaveActive:"transition-all duration-150 ease-in",leaveTo:"scale-95 opacity-0"},"scale-down":{enterFrom:"scale-105 opacity-0",enterActive:"transition-all duration-200 ease-out",enterTo:"scale-100 opacity-100",leaveFrom:"scale-100 opacity-100",leaveActive:"transition-all duration-150 ease-in",leaveTo:"scale-105 opacity-0"},bounce:{enterFrom:"scale-0 opacity-0",enterActive:"transition-all duration-500 ease-out",enterTo:"scale-100 opacity-100",leaveFrom:"scale-100 opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"scale-0 opacity-0"},zoom:{enterFrom:"scale-0 opacity-0",enterActive:"transition-all duration-300 ease-out",enterTo:"scale-100 opacity-100",leaveFrom:"scale-100 opacity-100",leaveActive:"transition-all duration-200 ease-in",leaveTo:"scale-0 opacity-0"},flip:{enterFrom:"rotate-[90deg] opacity-0",enterActive:"transition-all duration-400 ease-out",enterTo:"rotate-[0deg] opacity-100",leaveFrom:"rotate-[0deg] opacity-100",leaveActive:"transition-all duration-300 ease-in",leaveTo:"rotate-[90deg] opacity-0"}};function N(t,s){const{preset:o,show:e,mode:l="default",duration:k,appear:E=!1,css:b=!0,name:x,enterFrom:f,enterActive:m,enterTo:u,leaveFrom:r,leaveActive:c,leaveTo:v,onBeforeEnter:T,onEnter:A,onAfterEnter:h,onEnterCancelled:F,onBeforeLeave:L,onLeave:j,onAfterLeave:w,onLeaveCancelled:B}=t;let a;o&&d[o]?(a={...d[o]},f&&(a.enterFrom=f),m&&(a.enterActive=m),u&&(a.enterTo=u),r&&(a.leaveFrom=r),c&&(a.leaveActive=c),v&&(a.leaveTo=v)):a={enterFrom:f,enterActive:m,enterTo:u,leaveFrom:r,leaveActive:c,leaveTo:v};const P=e&&typeof s=="function"?s():s,S=x||(o?`transition-${o}`:"transition"),g=_.anchorBlock(e?P:[],S);return g._transition={name:S,classes:a,mode:l,duration:k,appear:E,css:b,state:e?"visible":"hidden",hooks:{onBeforeEnter:T,onEnter:A,onAfterEnter:h,onEnterCancelled:F,onBeforeLeave:L,onLeave:j,onAfterLeave:w,onLeaveCancelled:B}},g}function R(t,s){const{tag:o="div",moveClass:e="transition-transform duration-300",preset:l,show:k=!0,mode:E="default",duration:b,appear:x=!1,css:f=!0,name:m,class:u,style:r,enterFrom:c,enterActive:v,enterTo:T,leaveFrom:A,leaveActive:h,leaveTo:F,onBeforeEnter:L,onEnter:j,onAfterEnter:w,onEnterCancelled:B,onBeforeLeave:a,onLeave:P,onAfterLeave:S,onLeaveCancelled:g}=t;let i;l&&d[l]?(i={...d[l]},c&&(i.enterFrom=c),v&&(i.enterActive=v),T&&(i.enterTo=T),A&&(i.leaveFrom=A),h&&(i.leaveActive=h),F&&(i.leaveTo=F)):i={enterFrom:c,enterActive:v,enterTo:T,leaveFrom:A,leaveActive:h,leaveTo:F};const G=m||(l?`transition-group-${l}`:"transition-group"),C=[];for(const n of k?s:[])if(n&&typeof n=="object"&&n.tag==="#anchor"){const $=Array.isArray(n.children)?n.children:[];for(const p of $)if(p&&typeof p=="object"){const O={...p,key:n.key||p.key,props:{...p.props,_anchorKey:n.key}};C.push(O)}else C.push(p)}else C.push(n);const K=(()=>{if(r)return typeof r=="string"?r:Object.entries(r).map(([n,$])=>`${n}: ${$}`).join("; ")})();return{tag:o,children:C,key:G,props:{attrs:{...u?{class:u}:{},...K?{style:K}:{}},_transitionGroup:{name:G,classes:i,moveClass:e,mode:E,duration:b,appear:x,css:f,hooks:{onBeforeEnter:L,onEnter:j,onAfterEnter:w,onEnterCancelled:B,onBeforeLeave:a,onLeave:P,onAfterLeave:S,onLeaveCancelled:g}}}}}function z(t){return{...t}}let y=null;function H(){if(!y){if(typeof CSSStyleSheet>"u")return y={cssRules:[],replaceSync:()=>{},toString:()=>""},y;const t=[];Object.values(d).forEach(e=>{e.enterFrom&&t.push(e.enterFrom),e.enterActive&&t.push(e.enterActive),e.enterTo&&t.push(e.enterTo),e.leaveFrom&&t.push(e.leaveFrom),e.leaveActive&&t.push(e.leaveActive),e.leaveTo&&t.push(e.leaveTo)});const s=`<div class="${t.join(" ")}"></div>`,o=q.processJITCSS(s);try{y=new CSSStyleSheet,y.replaceSync(o)}catch{y={cssRules:[],replaceSync:()=>{},toString:()=>o||""}}}return y}exports.Transition=N;exports.TransitionGroup=R;exports.createTransitionPreset=z;exports.getTransitionStyleSheet=H;exports.transitionPresets=d;
2
2
  //# sourceMappingURL=custom-elements-runtime.transitions.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.transitions.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"custom-elements-runtime.transitions.cjs.js","sources":["../src/lib/transitions.ts"],"sourcesContent":["/**\n * Transitions module (top-level). This file provides the public Transition\n * and TransitionGroup APIs. It is an explicit entry used by the build so\n * consumers can import transitions separately: `.../transitions`.\n */\n/**\n * Transitions Module\n * Vue-like transition system integrated with JIT CSS\n * Provides Transition and TransitionGroup components for enter/leave animations\n */\n\nimport { anchorBlock } from './directives';\nimport type { VNode } from './runtime/types';\nimport { processJITCSS } from './runtime/render-bridge';\n\n/* --- Types --- */\n\n/**\n * Transition class names for different animation phases\n * All values should be JIT CSS utility classes\n */\nexport interface TransitionClasses {\n /** Classes applied at the start of enter transition */\n enterFrom?: string;\n /** Classes applied during entire enter transition */\n enterActive?: string;\n /** Classes applied at the end of enter transition */\n enterTo?: string;\n /** Classes applied at the start of leave transition */\n leaveFrom?: string;\n /** Classes applied during entire leave transition */\n leaveActive?: string;\n /** Classes applied at the end of leave transition */\n leaveTo?: string;\n}\n\n/**\n * Lifecycle hooks for transition events\n */\nexport interface TransitionHooks {\n /** Called before enter transition starts */\n onBeforeEnter?: (el: HTMLElement) => void;\n /** Called during enter transition (with done callback for manual control) */\n onEnter?: (el: HTMLElement, done: () => void) => void;\n /** Called after enter transition completes */\n onAfterEnter?: (el: HTMLElement) => void;\n /** Called if enter transition is cancelled */\n onEnterCancelled?: (el: HTMLElement) => void;\n /** Called before leave transition starts */\n onBeforeLeave?: (el: HTMLElement) => void;\n /** Called during leave transition (with done callback for manual control) */\n onLeave?: (el: HTMLElement, done: () => void) => void;\n /** Called after leave transition completes */\n onAfterLeave?: (el: HTMLElement) => void;\n /** Called if leave transition is cancelled */\n onLeaveCancelled?: (el: HTMLElement) => void;\n}\n\n/**\n * Options for Transition component\n */\nexport interface TransitionOptions extends TransitionClasses, TransitionHooks {\n /** Preset name (fade, slide-right, scale, etc.) */\n preset?: keyof typeof transitionPresets;\n /** Whether to show the content */\n show: boolean;\n /** Transition mode: default, out-in (leave before enter), in-out (enter before leave) */\n mode?: 'default' | 'out-in' | 'in-out';\n /** Custom duration override (ms) */\n duration?: number | { enter: number; leave: number };\n /** Whether to apply transition on initial render */\n appear?: boolean;\n /** Whether to use CSS transitions (true) or JS-only hooks (false) */\n css?: boolean;\n /** Optional name for debugging */\n name?: string;\n}\n\n/**\n * Options for TransitionGroup component\n */\nexport interface TransitionGroupOptions extends Omit<\n TransitionOptions,\n 'show'\n> {\n /** HTML tag for the wrapper element */\n tag?: string;\n /** Class applied during move transitions (when items reorder) */\n moveClass?: string;\n /** Whether to show the group (defaults to true for TransitionGroup) */\n show?: boolean;\n /** CSS classes to apply to the wrapper element (e.g., 'flex gap-4' or 'grid grid-cols-3') */\n class?: string;\n /** Inline styles to apply to the wrapper element */\n style?: string | Record<string, string>;\n}\n\n/* --- Transition Presets --- */\n\n/**\n * Pre-defined transition presets using JIT CSS classes\n * Users can reference these by name or define custom classes\n */\nexport const transitionPresets = {\n /** Simple fade in/out */\n fade: {\n enterFrom: 'opacity-0',\n enterActive: 'transition-opacity duration-300 ease-out',\n enterTo: 'opacity-100',\n leaveFrom: 'opacity-100',\n leaveActive: 'transition-opacity duration-200 ease-in',\n leaveTo: 'opacity-0',\n },\n\n /** Slide in from right */\n 'slide-right': {\n enterFrom: 'translate-x-[100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-x-[0%] opacity-100',\n leaveFrom: 'translate-x-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-x-[100%] opacity-0',\n },\n\n /** Slide in from left */\n 'slide-left': {\n enterFrom: 'translate-x-[-100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-x-[0%] opacity-100',\n leaveFrom: 'translate-x-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-x-[-100%] opacity-0',\n },\n\n /** Slide up from bottom */\n 'slide-up': {\n enterFrom: 'translate-y-[100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-y-[0%] opacity-100',\n leaveFrom: 'translate-y-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-y-[100%] opacity-0',\n },\n\n /** Slide down from top */\n 'slide-down': {\n enterFrom: 'translate-y-[-100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-y-[0%] opacity-100',\n leaveFrom: 'translate-y-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-y-[-100%] opacity-0',\n },\n\n /** Scale up from center */\n scale: {\n enterFrom: 'scale-95 opacity-0',\n enterActive: 'transition-all duration-200 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-150 ease-in',\n leaveTo: 'scale-95 opacity-0',\n },\n\n /** Scale down to center */\n 'scale-down': {\n enterFrom: 'scale-105 opacity-0',\n enterActive: 'transition-all duration-200 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-150 ease-in',\n leaveTo: 'scale-105 opacity-0',\n },\n\n /** Bounce effect */\n bounce: {\n enterFrom: 'scale-0 opacity-0',\n enterActive: 'transition-all duration-500 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'scale-0 opacity-0',\n },\n\n /** Zoom and fade */\n zoom: {\n enterFrom: 'scale-0 opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'scale-0 opacity-0',\n },\n\n /** Flip in */\n flip: {\n enterFrom: 'rotate-[90deg] opacity-0',\n enterActive: 'transition-all duration-400 ease-out',\n enterTo: 'rotate-[0deg] opacity-100',\n leaveFrom: 'rotate-[0deg] opacity-100',\n leaveActive: 'transition-all duration-300 ease-in',\n leaveTo: 'rotate-[90deg] opacity-0',\n },\n} as const;\n\n/* --- Core Functions --- */\n\n/**\n * Transition component - wraps content with enter/leave animations\n *\n * @example\n * ```ts\n * // Using a preset\n * ${Transition({ preset: 'fade', show: isVisible.value }, html`<div>Content</div>`)}\n *\n * // Using custom JIT classes\n * ${Transition({\n * show: isVisible.value,\n * enterFrom: 'opacity-0 scale-95',\n * enterActive: 'transition-all duration-300',\n * enterTo: 'opacity-100 scale-100',\n * leaveFrom: 'opacity-100 scale-100',\n * leaveActive: 'transition-all duration-200',\n * leaveTo: 'opacity-0 scale-95'\n * }, html`<div>Content</div>`)}\n *\n * // With lifecycle hooks\n * ${Transition({\n * preset: 'slide-right',\n * show: isVisible.value,\n * onAfterEnter: (el) => console.log('Entered!'),\n * onAfterLeave: (el) => console.log('Left!')\n * }, html`<div>Content</div>`)}\n *\n * // Lazy factory — only evaluated when show is true (avoids constructing\n * // expensive VNode trees when the content is hidden)\n * ${Transition({ show: isVisible.value }, () => html`<div>Expensive content</div>`)}\n * ```\n */\nexport function Transition(\n options: TransitionOptions,\n content: VNode | VNode[] | (() => VNode | VNode[]),\n): VNode {\n const {\n preset,\n show,\n mode = 'default',\n duration,\n appear = false,\n css = true,\n name,\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n } = options;\n\n // Resolve classes from preset or explicit values\n let transitionClasses: TransitionClasses;\n if (preset && transitionPresets[preset]) {\n transitionClasses = { ...transitionPresets[preset] };\n // Allow overriding preset classes\n if (enterFrom) transitionClasses.enterFrom = enterFrom;\n if (enterActive) transitionClasses.enterActive = enterActive;\n if (enterTo) transitionClasses.enterTo = enterTo;\n if (leaveFrom) transitionClasses.leaveFrom = leaveFrom;\n if (leaveActive) transitionClasses.leaveActive = leaveActive;\n if (leaveTo) transitionClasses.leaveTo = leaveTo;\n } else {\n transitionClasses = {\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n };\n }\n\n // Resolve content: only call the factory when show is true so that expensive\n // VNode trees (e.g. those that trigger calender builds or heavy computeds)\n // are never constructed while the transition is hidden. Leave animations\n // operate on existing DOM nodes and do not require the content VNode.\n const resolvedContent: VNode | VNode[] =\n show && typeof content === 'function'\n ? content()\n : (content as VNode | VNode[]);\n\n // Create anchor block with transition metadata\n const transitionKey =\n name || (preset ? `transition-${preset}` : 'transition');\n const transitionVNode = anchorBlock(\n show ? resolvedContent : [],\n transitionKey,\n );\n\n // Attach metadata for VDOM to consume during patching\n (transitionVNode as VNode & { _transition?: unknown })._transition = {\n name: transitionKey,\n classes: transitionClasses,\n mode,\n duration,\n appear,\n css,\n state: show ? 'visible' : 'hidden',\n hooks: {\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n },\n };\n\n return transitionVNode;\n}\n\n/**\n * TransitionGroup component - animates lists with enter/leave/move transitions\n *\n * @example\n * ```ts\n * // Basic usage\n * ${TransitionGroup({\n * preset: 'slide-right',\n * tag: 'ul',\n * moveClass: 'transition-transform duration-300'\n * }, each(items.value, (item) => html`\n * <li key=\"${item.id}\">${item.text}</li>\n * `))}\n *\n * // With flex layout\n * ${TransitionGroup({\n * preset: 'fade',\n * class: 'flex gap-4 flex-wrap'\n * }, each(items.value, (item) => html`\n * <div key=\"${item.id}\" class=\"shrink-0\">${item.text}</div>\n * `))}\n *\n * // With grid layout\n * ${TransitionGroup({\n * preset: 'scale',\n * class: 'grid grid-cols-3 gap-4'\n * }, each(items.value, (item) => html`\n * <div key=\"${item.id}\">${item.text}</div>\n * `))}\n * ```\n */\nexport function TransitionGroup(\n options: TransitionGroupOptions,\n children: VNode[],\n): VNode {\n const {\n tag = 'div',\n moveClass = 'transition-transform duration-300',\n preset,\n show = true,\n mode = 'default',\n duration,\n appear = false,\n css = true,\n name,\n class: className,\n style,\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n } = options;\n\n // Resolve classes from preset or explicit values\n let transitionClasses: TransitionClasses;\n if (preset && transitionPresets[preset]) {\n transitionClasses = { ...transitionPresets[preset] };\n // Allow overriding preset classes\n if (enterFrom) transitionClasses.enterFrom = enterFrom;\n if (enterActive) transitionClasses.enterActive = enterActive;\n if (enterTo) transitionClasses.enterTo = enterTo;\n if (leaveFrom) transitionClasses.leaveFrom = leaveFrom;\n if (leaveActive) transitionClasses.leaveActive = leaveActive;\n if (leaveTo) transitionClasses.leaveTo = leaveTo;\n } else {\n transitionClasses = {\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n };\n }\n\n // Create wrapper element with transition group metadata\n const groupKey =\n name || (preset ? `transition-group-${preset}` : 'transition-group');\n\n // Flatten anchor block children to enable proper keyed diffing\n // When each() is used, it creates anchor blocks. We need to extract the actual elements\n // and give them keys from their anchor blocks for proper reordering\n const flattenedChildren: VNode[] = [];\n for (const child of show ? children : []) {\n if (child && typeof child === 'object' && child.tag === '#anchor') {\n // Extract children from anchor block\n const anchorChildren = Array.isArray(child.children)\n ? child.children\n : [];\n for (const anchorChild of anchorChildren) {\n if (anchorChild && typeof anchorChild === 'object') {\n // Use anchor block's key for the child element\n const keyedChild = {\n ...anchorChild,\n key: child.key || anchorChild.key,\n props: {\n ...anchorChild.props,\n _anchorKey: child.key, // Preserve original anchor key\n },\n };\n flattenedChildren.push(keyedChild);\n } else {\n flattenedChildren.push(anchorChild);\n }\n }\n } else {\n flattenedChildren.push(child);\n }\n }\n\n // Serialize style object to a CSS string for the attrs record so it matches\n // the expected primitive attribute value types.\n const styleAttr = (() => {\n if (!style) return undefined;\n if (typeof style === 'string') return style;\n return Object.entries(style)\n .map(([k, v]) => `${k}: ${v}`)\n .join('; ');\n })();\n\n return {\n tag,\n children: flattenedChildren,\n key: groupKey,\n props: {\n attrs: {\n ...(className ? { class: className } : {}),\n ...(styleAttr ? { style: styleAttr } : {}),\n },\n _transitionGroup: {\n name: groupKey,\n classes: transitionClasses,\n moveClass,\n mode,\n duration,\n appear,\n css,\n hooks: {\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n },\n },\n },\n };\n}\n\n/**\n * Helper to create custom transition presets\n *\n * @example\n * ```ts\n * const customFade = createTransitionPreset({\n * enterFrom: 'opacity-0',\n * enterActive: 'transition-opacity duration-500 ease-out',\n * enterTo: 'opacity-100',\n * leaveFrom: 'opacity-100',\n * leaveActive: 'transition-opacity duration-300 ease-in',\n * leaveTo: 'opacity-0'\n * });\n *\n * ${Transition({ ...customFade, show: visible.value }, content)}\n * ```\n */\nexport function createTransitionPreset(\n classes: TransitionClasses,\n): TransitionClasses {\n return { ...classes };\n}\n\n/**\n * Pre-generate CSS for all transition preset classes\n * This ensures the JIT CSS system has the styles ready when transitions are used\n */\nlet transitionStyleSheet: CSSStyleSheet | null = null;\n\n/**\n * Get the global transition stylesheet (creates it if needed)\n */\nexport function getTransitionStyleSheet(): CSSStyleSheet {\n if (!transitionStyleSheet) {\n // If constructable stylesheets aren't available (SSR / old browsers),\n // return a no-op stub to avoid throwing during import or server render.\n if (typeof CSSStyleSheet === 'undefined') {\n transitionStyleSheet = {\n cssRules: [],\n replaceSync: () => {},\n toString: () => '',\n } as unknown as CSSStyleSheet;\n return transitionStyleSheet;\n }\n\n const allClasses: string[] = [];\n\n // Collect all classes from presets\n Object.values(transitionPresets).forEach((preset) => {\n if (preset.enterFrom) allClasses.push(preset.enterFrom);\n if (preset.enterActive) allClasses.push(preset.enterActive);\n if (preset.enterTo) allClasses.push(preset.enterTo);\n if (preset.leaveFrom) allClasses.push(preset.leaveFrom);\n if (preset.leaveActive) allClasses.push(preset.leaveActive);\n if (preset.leaveTo) allClasses.push(preset.leaveTo);\n });\n\n // Create a fake HTML string with all transition classes\n const fakeHtml = `<div class=\"${allClasses.join(' ')}\"></div>`;\n\n // Trigger JIT CSS generation (no-op if JIT CSS engine is not loaded)\n const generatedCSS = processJITCSS(fakeHtml);\n\n // Create stylesheet\n try {\n transitionStyleSheet = new CSSStyleSheet();\n transitionStyleSheet.replaceSync(generatedCSS);\n } catch {\n // If creating a constructable stylesheet fails for any reason,\n // fallback to a stub to avoid breaking SSR or older environments.\n transitionStyleSheet = {\n cssRules: [],\n replaceSync: () => {},\n toString: () => generatedCSS || '',\n } as unknown as CSSStyleSheet;\n }\n }\n\n return transitionStyleSheet;\n}\n\n"],"names":["transitionPresets","Transition","options","content","preset","show","mode","duration","appear","css","name","enterFrom","enterActive","enterTo","leaveFrom","leaveActive","leaveTo","onBeforeEnter","onEnter","onAfterEnter","onEnterCancelled","onBeforeLeave","onLeave","onAfterLeave","onLeaveCancelled","transitionClasses","resolvedContent","transitionKey","transitionVNode","anchorBlock","TransitionGroup","children","tag","moveClass","className","style","groupKey","flattenedChildren","child","anchorChildren","anchorChild","keyedChild","styleAttr","k","v","createTransitionPreset","classes","transitionStyleSheet","getTransitionStyleSheet","allClasses","fakeHtml","generatedCSS","processJITCSS"],"mappings":"qLAuGaA,EAAoB,CAE/B,KAAM,CACJ,UAAW,YACX,YAAa,2CACb,QAAS,cACT,UAAW,cACX,YAAa,0CACb,QAAS,WAAA,EAIX,cAAe,CACb,UAAW,+BACX,YAAa,uCACb,QAAS,+BACT,UAAW,+BACX,YAAa,sCACb,QAAS,8BAAA,EAIX,aAAc,CACZ,UAAW,gCACX,YAAa,uCACb,QAAS,+BACT,UAAW,+BACX,YAAa,sCACb,QAAS,+BAAA,EAIX,WAAY,CACV,UAAW,+BACX,YAAa,uCACb,QAAS,+BACT,UAAW,+BACX,YAAa,sCACb,QAAS,8BAAA,EAIX,aAAc,CACZ,UAAW,gCACX,YAAa,uCACb,QAAS,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