@ecopages/radiant 0.3.0-alpha.1 → 0.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunk-gpv1n74a.js +4 -0
- package/dist/{chunk-4e559cy5.js.map → chunk-gpv1n74a.js.map} +3 -3
- package/dist/chunk-zygdebw8.js +4 -0
- package/dist/chunk-zygdebw8.js.map +10 -0
- package/dist/core/radiant-component-ssr.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server/radiant-component-ssr-runtime.js +1 -1
- package/dist/server/render-component.js +2 -2
- package/dist/server/render-component.js.map +3 -3
- package/package.json +5 -1
- package/size-budget.json +1 -1
- package/dist/chunk-3ryr5wx2.js +0 -4
- package/dist/chunk-3ryr5wx2.js.map +0 -10
- package/dist/chunk-4e559cy5.js +0 -4
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ Use `@onUpdated(...)` with `update()` or `requestUpdate()` when the reactive cha
|
|
|
149
149
|
|
|
150
150
|
In practice, `renderHostToString()` is the right default for full component SSR because it emits `<my-element>...</my-element>` instead of only the view fragment.
|
|
151
151
|
|
|
152
|
-
`
|
|
152
|
+
`mode: 'hydrate'` adds hydration markers for the component view. First-connect hydration is now explicit: SSR pages should import `@ecopages/radiant/client/install-hydrator` before loading component modules, or call `installRadiantHydrator()` from `@ecopages/radiant/client/hydrator` before custom elements upgrade. Without that client hydrator gate, SSR hosts fall back to a fresh client render on first connect.
|
|
153
153
|
|
|
154
154
|
For component-owned SSR, the instance methods still work. For adapters, fragment responses, and shared server utilities, prefer the explicit helpers under `@ecopages/radiant/server/render-component`.
|
|
155
155
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{g as I}from"./chunk-zygdebw8.js";import{Ta as D,Ua as F}from"./chunk-e0r6ca2g.js";import{Za as G}from"./chunk-9mqtp3js.js";import{renderToString as N}from"@ecopages/jsx/server";import{withServerCustomElementRenderHook as O}from"@ecopages/jsx/server";var P=Symbol.for("@ecopages/jsx.active-ssr-hydrate"),A=new WeakSet;function Q(f){return{nodeType:1,outerHTML:J(f,{mode:"hydrate"})}}function J(f,j={}){return L(f).renderHostToString(j,K(f))}function K(f){let j=f;if(A.has(f))return L(f).getHostAttributes();A.add(f);try{return j.getHostSsrAttributes()}finally{A.delete(f)}}function L(f){let j=f;return new I({constructor:j.constructor,getAuthoredHydrationScriptMarkup:()=>j.getAuthoredHydrationScriptMarkup(),getHydrationBindings:()=>j.getHydrationBindings(),getSlotProjectionScriptTag:()=>j.getSlotProjectionScriptTag(),renderToString:(k)=>j.renderToString(k),getContextProviders:()=>j.getContextProviders(),getReactiveProperties:()=>j.getReactiveProperties(),getReactivePropDefinitions:()=>G(f),getPropertyValue:(k)=>j[k],listAttributeNames:()=>typeof j.getAttributeNames==="function"?j.getAttributeNames():[],getAttributeValue:(k)=>j.getAttribute(k)})}function U(f){return O(({instance:j})=>{let k=M(j);if(!k?.renderHostToString)return;let z=k.renderHostToString;return{nodeType:1,get outerHTML(){let q=V();return z({hydrate:q,mode:q?"hydrate":"plain"})}}},f)}function M(f){return f.resolveSsrRenderBridge?.()}function V(){return globalThis[P]===!0}function W(){let f=D();if(f)return f;let j={getHostAttributes:K,renderHost:Q,renderHostToString:J,resolveRenderBridge:M,renderView:(k,z={})=>{let q=k;return U(()=>N(q.resolveTrackedRenderOutput().value,z))}};return F(j),j}W();
|
|
2
|
+
export{W as f};
|
|
3
|
+
|
|
4
|
+
//# debugId=6D634BADD4BBC3EB64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/server/radiant-component-ssr-runtime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { JsxRenderable } from '@ecopages/jsx';\nimport { renderToString as renderJsxToString } from '@ecopages/jsx/server';\nimport { withServerCustomElementRenderHook } from '@ecopages/jsx/server';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport { getReactivePropDefinitions } from '../core/reactive-prop-metadata';\nimport { RadiantComponentSsrService } from '../core/radiant-component-ssr';\nimport {\n\tgetRadiantComponentSsrRuntime,\n\tregisterRadiantComponentSsrRuntime,\n\ttype RadiantComponentRenderBridge,\n\ttype RadiantComponentSsrCapable,\n\ttype RadiantComponentSsrRuntime,\n} from '../core/radiant-component-ssr-registry';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport type { ReactiveProperty } from '../core/radiant-element';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\n\ntype RadiantComponentSsrHostBridge = Record<string, unknown> & {\n\tconstructor: CustomElementConstructor;\n\tgetAttribute(name: string): string | null;\n\tgetAttributeNames?(): string[];\n\tgetAuthoredHydrationScriptMarkup(): string | undefined;\n\tgetContextProviders(): SsrSerializableContextProvider[];\n\tgetHostSsrAttributes(): Record<string, string>;\n\tgetHydrationBindings(): SsrSerializableHydrationBinding[];\n\tgetReactiveProperties(): ReactiveProperty[];\n\tgetSlotProjectionScriptTag(): string | undefined;\n\tresolveTrackedRenderOutput(): { containsSlots: boolean; value: JsxRenderable };\n\trenderToString(options?: RenderToStringOptions): string;\n\tresolveSsrRenderBridge(): RadiantComponentRenderBridge;\n};\n\nconst ACTIVE_SSR_HYDRATE_SYMBOL = Symbol.for('@ecopages/jsx.active-ssr-hydrate');\nconst hostAttributeResolutionInProgress = new WeakSet<object>();\n\n/**\n * Produces a JSX-compatible host preview for a Radiant component.\n *\n * The preview always serializes with hydration enabled because it is intended\n * for shell composition, where nested client islands must preserve hydration\n * markers when embedded into a larger SSR document.\n */\nfunction renderRadiantComponentHost(component: RadiantComponentSsrCapable): JsxRenderable {\n\treturn {\n\t\tnodeType: 1,\n\t\touterHTML: renderRadiantComponentHostToString(component, {
|
|
5
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport { renderToString as renderJsxToString } from '@ecopages/jsx/server';\nimport { withServerCustomElementRenderHook } from '@ecopages/jsx/server';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport { getReactivePropDefinitions } from '../core/reactive-prop-metadata';\nimport { RadiantComponentSsrService } from '../core/radiant-component-ssr';\nimport {\n\tgetRadiantComponentSsrRuntime,\n\tregisterRadiantComponentSsrRuntime,\n\ttype RadiantComponentRenderBridge,\n\ttype RadiantComponentSsrCapable,\n\ttype RadiantComponentSsrRuntime,\n} from '../core/radiant-component-ssr-registry';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport type { ReactiveProperty } from '../core/radiant-element';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\n\ntype RadiantComponentSsrHostBridge = Record<string, unknown> & {\n\tconstructor: CustomElementConstructor;\n\tgetAttribute(name: string): string | null;\n\tgetAttributeNames?(): string[];\n\tgetAuthoredHydrationScriptMarkup(): string | undefined;\n\tgetContextProviders(): SsrSerializableContextProvider[];\n\tgetHostSsrAttributes(): Record<string, string>;\n\tgetHydrationBindings(): SsrSerializableHydrationBinding[];\n\tgetReactiveProperties(): ReactiveProperty[];\n\tgetSlotProjectionScriptTag(): string | undefined;\n\tresolveTrackedRenderOutput(): { containsSlots: boolean; value: JsxRenderable };\n\trenderToString(options?: RenderToStringOptions): string;\n\tresolveSsrRenderBridge(): RadiantComponentRenderBridge;\n};\n\nconst ACTIVE_SSR_HYDRATE_SYMBOL = Symbol.for('@ecopages/jsx.active-ssr-hydrate');\nconst hostAttributeResolutionInProgress = new WeakSet<object>();\n\n/**\n * Produces a JSX-compatible host preview for a Radiant component.\n *\n * The preview always serializes with hydration enabled because it is intended\n * for shell composition, where nested client islands must preserve hydration\n * markers when embedded into a larger SSR document.\n */\nfunction renderRadiantComponentHost(component: RadiantComponentSsrCapable): JsxRenderable {\n\treturn {\n\t\tnodeType: 1,\n\t\touterHTML: renderRadiantComponentHostToString(component, { mode: 'hydrate' }),\n\t};\n}\n\n/**\n * Serializes a Radiant component host through the shared SSR service.\n *\n * This path centralizes host serialization so direct component renders and\n * nested JSX custom-element renders follow the same attribute and hydration\n * rules.\n */\nfunction renderRadiantComponentHostToString(\n\tcomponent: RadiantComponentSsrCapable,\n\toptions: RenderToStringOptions = {},\n): string {\n\treturn createRadiantComponentSsrService(component).renderHostToString(\n\t\toptions,\n\t\tgetRadiantComponentHostSsrAttributes(component),\n\t);\n}\n\n/**\n * Resolves the final host attribute map for a Radiant component.\n *\n * The recursion guard is required because `getHostSsrAttributes()` can itself\n * delegate back into the shared runtime. When that happens, the runtime falls\n * back to the raw SSR service attribute collector for the current call.\n */\nfunction getRadiantComponentHostSsrAttributes(component: RadiantComponentSsrCapable): Record<string, string> {\n\tconst bridge = component as unknown as RadiantComponentSsrHostBridge;\n\n\tif (hostAttributeResolutionInProgress.has(component)) {\n\t\treturn createRadiantComponentSsrService(component).getHostAttributes();\n\t}\n\n\thostAttributeResolutionInProgress.add(component);\n\n\ttry {\n\t\treturn bridge.getHostSsrAttributes();\n\t} finally {\n\t\thostAttributeResolutionInProgress.delete(component);\n\t}\n}\n\n/**\n * Adapts a `RadiantComponent` instance to the older `RadiantComponentSsrService`\n * contract.\n *\n * Keeping this adapter local lets the base class shed its eager SSR service\n * instance while preserving the established host serialization behavior.\n */\nfunction createRadiantComponentSsrService(component: RadiantComponentSsrCapable): RadiantComponentSsrService {\n\tconst bridge = component as unknown as RadiantComponentSsrHostBridge;\n\n\treturn new RadiantComponentSsrService({\n\t\tconstructor: bridge.constructor,\n\t\tgetAuthoredHydrationScriptMarkup: () => bridge.getAuthoredHydrationScriptMarkup(),\n\t\tgetHydrationBindings: () => bridge.getHydrationBindings(),\n\t\tgetSlotProjectionScriptTag: () => bridge.getSlotProjectionScriptTag(),\n\t\trenderToString: (options) => bridge.renderToString(options),\n\t\tgetContextProviders: () => bridge.getContextProviders(),\n\t\tgetReactiveProperties: () => bridge.getReactiveProperties(),\n\t\tgetReactivePropDefinitions: () => getReactivePropDefinitions(component),\n\t\tgetPropertyValue: (name) => bridge[name],\n\t\tlistAttributeNames: () => (typeof bridge.getAttributeNames === 'function' ? bridge.getAttributeNames() : []),\n\t\tgetAttributeValue: (name) => bridge.getAttribute(name),\n\t});\n}\n\n/**\n * Installs a temporary JSX custom-element render hook that understands\n * `RadiantComponent` SSR bridges.\n *\n * This makes nested intrinsic custom-element renders honor explicit host SSR\n * overrides instead of always falling back to the inherited JSX runtime path.\n */\nfunction withRadiantServerCustomElementRenderBridge<T>(render: () => T): T {\n\treturn withServerCustomElementRenderHook(({ instance }) => {\n\t\tconst nestedBridge = resolveRadiantComponentRenderBridge(instance as unknown as RadiantComponentSsrCapable);\n\n\t\tif (!nestedBridge?.renderHostToString) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst renderHostToString = nestedBridge.renderHostToString;\n\n\t\treturn {\n\t\t\tnodeType: 1,\n\t\t\tget outerHTML() {\n\t\t\t\tconst hydrate = isActiveSsrHydrateMode();\n\t\t\t\treturn renderHostToString({ hydrate, mode: hydrate ? 'hydrate' : 'plain' });\n\t\t\t},\n\t\t};\n\t}, render);\n}\n\n/**\n * Resolves the SSR bridge exposed by a component instance, when present.\n */\nfunction resolveRadiantComponentRenderBridge(\n\tcomponent: RadiantComponentSsrCapable,\n): RadiantComponentRenderBridge | undefined {\n\treturn component.resolveSsrRenderBridge?.();\n}\n\n/**\n * Reads the active JSX SSR hydrate flag from `globalThis`.\n *\n * Nested custom-element serialization mirrors the hydrate mode of the current\n * top-level render so host and child markup stay consistent.\n */\nfunction isActiveSsrHydrateMode(): boolean {\n\treturn (globalThis as typeof globalThis & Record<PropertyKey, unknown>)[ACTIVE_SSR_HYDRATE_SYMBOL] === true;\n}\n\n/**\n * Registers the shared Radiant SSR runtime if it is not already present.\n *\n * Server entrypoints call this eagerly so instance SSR methods, nested JSX\n * custom-element SSR, and portable server helpers all share one implementation\n * and one bridge-resolution strategy.\n */\nexport function ensureRadiantComponentSsrRuntimeRegistered() {\n\tconst existingRuntime = getRadiantComponentSsrRuntime();\n\n\tif (existingRuntime) {\n\t\treturn existingRuntime;\n\t}\n\n\tconst runtime: RadiantComponentSsrRuntime = {\n\t\tgetHostAttributes: getRadiantComponentHostSsrAttributes,\n\t\trenderHost: renderRadiantComponentHost,\n\t\trenderHostToString: renderRadiantComponentHostToString,\n\t\tresolveRenderBridge: resolveRadiantComponentRenderBridge,\n\t\trenderView: (component, options = {}) => {\n\t\t\tconst bridge = component as unknown as RadiantComponentSsrHostBridge;\n\n\t\t\treturn withRadiantServerCustomElementRenderBridge(() =>\n\t\t\t\trenderJsxToString(bridge.resolveTrackedRenderOutput().value, options),\n\t\t\t);\n\t\t},\n\t};\n\n\tregisterRadiantComponentSsrRuntime(runtime);\n\treturn runtime;\n}\n\nensureRadiantComponentSsrRuntimeRegistered();\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "8IACA,mBAAS,uBACT,4CAAS,6BA8BT,IAAM,EAA4B,OAAO,IAAI,kCAAkC,EACzE,EAAoC,IAAI,QAS9C,SAAS,CAA0B,CAAC,EAAsD,CACzF,MAAO,CACN,SAAU,EACV,UAAW,EAAmC,EAAW,CAAE,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "8IACA,mBAAS,uBACT,4CAAS,6BA8BT,IAAM,EAA4B,OAAO,IAAI,kCAAkC,EACzE,EAAoC,IAAI,QAS9C,SAAS,CAA0B,CAAC,EAAsD,CACzF,MAAO,CACN,SAAU,EACV,UAAW,EAAmC,EAAW,CAAE,KAAM,SAAU,CAAC,CAC7E,EAUD,SAAS,CAAkC,CAC1C,EACA,EAAiC,CAAC,EACzB,CACT,OAAO,EAAiC,CAAS,EAAE,mBAClD,EACA,EAAqC,CAAS,CAC/C,EAUD,SAAS,CAAoC,CAAC,EAA+D,CAC5G,IAAM,EAAS,EAEf,GAAI,EAAkC,IAAI,CAAS,EAClD,OAAO,EAAiC,CAAS,EAAE,kBAAkB,EAGtE,EAAkC,IAAI,CAAS,EAE/C,GAAI,CACH,OAAO,EAAO,qBAAqB,SAClC,C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O,CACrE,EAEF,EAGA,OADA,EAAmC,CAAO,EACnC,EAGR,EAA2C",
|
|
8
|
+
"debugId": "6D634BADD4BBC3EB64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{h as g}from"./chunk-ssnnxzrj.js";import{Xa as a}from"./chunk-hztr86b4.js";import{eb as s}from"./chunk-66e6s792.js";class c{host;constructor(t){this.host=t}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({mode:"hydrate"})}}renderHostToString(t={},i=this.getHostAttributes()){let e=this.getTagName(),r=g(this.host.getContextProviders());try{return`<${e}${d(i)}>${this.renderHostContent(t)}</${e}>`}finally{r()}}renderHostContent(t){let i=this.host.renderToString(t),e=this.host.getAuthoredHydrationScriptMarkup?.()??"",r=this.host.getSlotProjectionScriptTag?.()??"";if(!(t.mode==="hydrate"||t.mode===void 0&&t.hydrate===!0))return`${i}${e}${r}`;let u=this.host.getHydrationBindings().map((o)=>o.renderHydrationScriptTag()).filter((o)=>typeof o==="string").join("");return`${i}${r}${u}`}getHostAttributes(){let t={},i=new Set;for(let e of this.host.getReactiveProperties()){let r=this.host.getPropertyValue(e.name);if(r===void 0||r===null||r===!1)continue;t[e.attribute]=String(e.converter.toAttribute(r)),i.add(e.attribute)}for(let e of this.host.getReactivePropDefinitions()){let r=e.options.attribute??e.name;if(i.has(r))continue;let n=this.host.getPropertyValue(e.name);if(n===void 0||n===null||n===!1)continue;t[r]=String(s(n,e.options.type)),i.add(r)}for(let e of this.host.listAttributeNames()){let r=this.host.getAttributeValue(e);if(r!==null)t[e]=r}return t}getTagName(){let t=a(this.host.constructor);if(!t)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return t}}function d(t){return Object.entries(t).map(([i,e])=>` ${i}="${p(e)}"`).join("")}function p(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}
|
|
2
|
+
export{c as g};
|
|
3
|
+
|
|
4
|
+
//# debugId=C61D9BA2C0EBB8CC64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/radiant-component-ssr.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { withSsrContextProviders } from '../server/context-ssr';\nimport { getCustomElementTagName } from './custom-element-metadata';\nimport type { ReactiveProperty } from './radiant-element';\nimport type { ReactivePropDefinition } from './reactive-prop-metadata';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\ntype RadiantComponentSsrHost = {\n\tconstructor: CustomElementConstructor;\n\tgetAuthoredHydrationScriptMarkup?: () => string | undefined;\n\tgetContextProviders: () => SsrSerializableContextProvider[];\n\tgetHydrationBindings: () => SsrSerializableHydrationBinding[];\n\tgetSlotProjectionScriptTag?: () => string | undefined;\n\trenderToString: (options?: RenderToStringOptions) => string;\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\nexport class RadiantComponentSsrService {\n\tconstructor(private readonly host: RadiantComponentSsrHost) {}\n\n\tpublic renderHost(): JsxRenderable {\n\t\treturn {\n\t\t\tnodeType: 1,\n\t\t\touterHTML: this.renderHostToString({ mode: 'hydrate' }),\n\t\t};\n\t}\n\n\tpublic renderHostToString(options: RenderToStringOptions = {}, attributes = this.getHostAttributes()): string {\n\t\tconst tagName = this.getTagName();\n\t\tconst restoreSsrContexts = withSsrContextProviders(this.host.getContextProviders());\n\n\t\ttry {\n\t\t\treturn `<${tagName}${serializeHostAttributes(attributes)}>${this.renderHostContent(options)}</${tagName}>`;\n\t\t} finally {\n\t\t\trestoreSsrContexts();\n\t\t}\n\t}\n\n\tprivate renderHostContent(options: RenderToStringOptions): string {\n\t\tconst hostContent = this.host.renderToString(options);\n\t\tconst authoredHydrationMarkup = this.host.getAuthoredHydrationScriptMarkup?.() ?? '';\n\t\tconst slotProjectionScript = this.host.getSlotProjectionScriptTag?.() ?? '';\n\t\tconst hydrate = options.mode === 'hydrate' || (options.mode === undefined && options.hydrate === true);\n\n\t\tif (!hydrate) {\n\t\t\treturn `${hostContent}${authoredHydrationMarkup}${slotProjectionScript}`;\n\t\t}\n\n\t\tconst hydrationScripts = this.host\n\t\t\t.getHydrationBindings()\n\t\t\t.map((binding) => binding.renderHydrationScriptTag())\n\t\t\t.filter((markup): markup is string => typeof markup === 'string')\n\t\t\t.join('');\n\n\t\treturn `${hostContent}${slotProjectionScript}${hydrationScripts}`;\n\t}\n\n\tpublic getHostAttributes(): Record<string, string> {\n\t\tconst attributes: Record<string, string> = {};\n\t\tconst seenAttributes = new Set<string>();\n\n\t\tfor (const property of this.host.getReactiveProperties()) {\n\t\t\tconst currentValue = this.host.getPropertyValue(property.name);\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\t\tseenAttributes.add(property.attribute);\n\t\t}\n\n\t\tfor (const definition of this.host.getReactivePropDefinitions()) {\n\t\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\t\tif (seenAttributes.has(attributeName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst currentValue = this.host.getPropertyValue(definition.name);\n\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\t\tseenAttributes.add(attributeName);\n\t\t}\n\n\t\tfor (const attributeName of this.host.listAttributeNames()) {\n\t\t\tconst attributeValue = this.host.getAttributeValue(attributeName);\n\t\t\tif (attributeValue !== null) {\n\t\t\t\tattributes[attributeName] = attributeValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tprivate getTagName(): string {\n\t\tconst tagName = getCustomElementTagName(this.host.constructor);\n\n\t\tif (!tagName) {\n\t\t\tthrow new Error(`${this.host.constructor.name} is missing @customElement metadata.`);\n\t\t}\n\n\t\treturn tagName;\n\t}\n}\n\nfunction serializeHostAttributes(attributes: Record<string, string>): string {\n\treturn Object.entries(attributes)\n\t\t.map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n\t\t.join('');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "sIAwBO,AAAM,LAA2B,CACV,KAA7B,WAAW,CAAkB,EAA+B,CAA/B,YAEtB,UAAU,EAAkB,CAClC,MAAO,CACN,SAAU,EACV,UAAW,KAAK,mBAAmB,CAAE,KAAM,SAAU,CAAC,CACvD,EAGM,kBAAkB,CAAC,EAAiC,CAAC,EAAG,EAAa,KAAK,kBAAkB,EAAW,CAC7G,IAAM,EAAU,KAAK,WAAW,EAC1B,EAAqB,EAAwB,KAAK,KAAK,oBAAoB,CAAC,EAElF,GAAI,CACH,MAAO,IAAI,IAAU,EAAwB,CAAU,KAAK,KAAK,kBAAkB,CAAO,MAAM,YAC/F,CACD,EAAmB,GAIb,iBAAiB,CAAC,EAAwC,CACjE,IAAM,EAAc,KAAK,KAAK,eAAe,CAAO,EAC9C,EAA0B,KAAK,KAAK,mCAAmC,GAAK,GAC5E,EAAuB,KAAK,KAAK,6BAA6B,GAAK,GAGzE,GAAI,EAFY,EAAQ,OAAS,WAAc,EAAQ,OAAS,QAAa,EAAQ,UAAY,IAGhG,MAAO,GAAG,IAAc,IAA0B,IAGnD,IAAM,EAAmB,KAAK,KA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,SAAS,CAAe,CAAC,EAAuB,CAC/C,OAAO,EAAM,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,QAAQ,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM",
|
|
8
|
+
"debugId": "C61D9BA2C0EBB8CC64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{g as a}from"../chunk-
|
|
1
|
+
import{g as a}from"../chunk-zygdebw8.js";import"../chunk-ssnnxzrj.js";import"../chunk-hztr86b4.js";import"../chunk-t8xtvgyg.js";import"../chunk-66e6s792.js";import"../chunk-vgtggzb6.js";export{a as RadiantComponentSsrService};
|
|
2
2
|
|
|
3
3
|
//# debugId=F6B36BC49A26138E64756E2164756E21
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './decorators/signal';
|
|
|
14
14
|
export * from './decorators/state';
|
|
15
15
|
export * from './context/context-provider';
|
|
16
16
|
export * from './context/create-context';
|
|
17
|
+
export * from './context/events';
|
|
17
18
|
export * from './context/decorators/consume-context';
|
|
18
19
|
export * from './context/decorators/context-selector';
|
|
19
20
|
export * from './context/decorators/on-context-update';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as
|
|
1
|
+
import{t as s}from"./chunk-3ynk7e1e.js";import"./chunk-nctznxyz.js";import{v as e}from"./chunk-wds4href.js";import"./chunk-r33zvvda.js";import"./chunk-fs4j94bk.js";import"./chunk-5qeaq3tj.js";import{z as c}from"./chunk-30x4hggg.js";import{A as r}from"./chunk-qe0eww1n.js";import{B as t}from"./chunk-g5n3m11h.js";import"./chunk-s09s5ayx.js";import"./chunk-g2z3mm6b.js";import"./chunk-x2k0ngpz.js";import"./chunk-kakpjgzf.js";import"./chunk-5bkat72n.js";import"./chunk-p8k4g99a.js";import"./chunk-ek664x1c.js";import{P as T}from"./chunk-s5p5z3z4.js";import{Q as U}from"./chunk-z9kxfckm.js";import{R as o}from"./chunk-21a7jask.js";import{S as a,T as n,U as p,V as l}from"./chunk-kmebacvv.js";import"./chunk-c0qyz98c.js";import{Y as S}from"./chunk-gdkte2vd.js";import{Z as u}from"./chunk-ndw3hc3v.js";import"./chunk-mpsj3cjs.js";import"./chunk-0bswvy25.js";import{aa as v}from"./chunk-pkszgjqf.js";import"./chunk-x457d0ap.js";import"./chunk-vk48hgm4.js";import{da as Z}from"./chunk-0btkzzyc.js";import"./chunk-qdz5sncz.js";import"./chunk-w8s5fnsq.js";import{ga as V}from"./chunk-j864sv4w.js";import"./chunk-y139ycfm.js";import"./chunk-rkh1vkb9.js";import{ja as X}from"./chunk-nvr37vma.js";import"./chunk-h9k7crjc.js";import"./chunk-8d5ddvvf.js";import{ma as d}from"./chunk-0g0j9re6.js";import"./chunk-8e9fgtbn.js";import"./chunk-bk2nbmcd.js";import{pa as W}from"./chunk-c52qhh0j.js";import"./chunk-25zjh0kg.js";import"./chunk-mp2vtrkg.js";import{sa as $}from"./chunk-1x26p09c.js";import"./chunk-9rj2rwes.js";import"./chunk-v3ta7hnv.js";import{va as y}from"./chunk-eevw1j2q.js";import"./chunk-knqsm6v3.js";import"./chunk-eyw14d6y.js";import"./chunk-v92hp9g0.js";import{Ba as i}from"./chunk-xbhtzkre.js";import"./chunk-atms6yrh.js";import"./chunk-n4p2542b.js";import"./chunk-nnnb6pac.js";import"./chunk-dabagjk6.js";import{Ja as h}from"./chunk-j3v7rca5.js";import"./chunk-hvy4zvcc.js";import"./chunk-79jg8q67.js";import"./chunk-cnyxrh9r.js";import"./chunk-q9z6tnzw.js";import"./chunk-gg74gdpv.js";import"./chunk-e0r6ca2g.js";import"./chunk-hztr86b4.js";import"./chunk-9mqtp3js.js";import"./chunk-t8xtvgyg.js";import"./chunk-66e6s792.js";import"./chunk-3xxvmd5c.js";import"./chunk-hpzgnxgq.js";import"./chunk-nssj2x13.js";import{xb as Y}from"./chunk-rrg759ht.js";import"./chunk-wvd1ffe4.js";import"./chunk-wd23rn4q.js";import{Ab as x}from"./chunk-bk6qkvfp.js";import{Bb as q}from"./chunk-wwbjz9k4.js";import{Cb as _}from"./chunk-hrjc8b1y.js";import"./chunk-vgtggzb6.js";export{h as state,v as signal,y as querySlot,u as query,e as provideContext,i as prop,d as onUpdated,$ as onEvent,r as onContextUpdate,Z as event,X as debounce,W as customElement,x as createQuerySlot,q as createQuery,_ as createEventListener,Y as createEvent,c as createContext,t as contextSelector,s as consumeContext,V as bound,U as bindReactiveValue,S as RadiantElement,T as RadiantComponent,l as ContextSubscriptionRequestEvent,n as ContextRequestEvent,o as ContextProvider,p as ContextOnMountEvent,a as ContextEventsTypes};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=9514635D470276B764756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as a}from"../chunk-
|
|
1
|
+
import{f as a}from"../chunk-gpv1n74a.js";import"../chunk-zygdebw8.js";import"../chunk-ssnnxzrj.js";import"../chunk-e0r6ca2g.js";import"../chunk-hztr86b4.js";import"../chunk-9mqtp3js.js";import"../chunk-t8xtvgyg.js";import"../chunk-66e6s792.js";import"../chunk-vgtggzb6.js";export{a as ensureRadiantComponentSsrRuntimeRegistered};
|
|
2
2
|
|
|
3
3
|
//# debugId=76B602B01D2826A664756E2164756E21
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as V}from"../chunk-
|
|
1
|
+
import{f as V}from"../chunk-gpv1n74a.js";import"../chunk-zygdebw8.js";import{h as W}from"../chunk-ssnnxzrj.js";import{l as x}from"../chunk-sf4a2gy5.js";import"../chunk-5b1en9vz.js";import{Ta as I}from"../chunk-e0r6ca2g.js";import{Xa as U}from"../chunk-hztr86b4.js";import"../chunk-9mqtp3js.js";import"../chunk-t8xtvgyg.js";import"../chunk-66e6s792.js";import"../chunk-vgtggzb6.js";var D="x-generated-at",H="x-radiant-tag-name",R="x-radiant-client-module",f="x-radiant-assets";V();function N(j,q="hydrate"){return{kind:"script-module",src:j,stage:q}}function d(j){return{kind:"modulepreload",href:j}}function s(j,q){return q?{kind:"style",href:j,media:q}:{kind:"style",href:j}}async function i(j,q){return(await K(Q(j,q))).markup}async function t(j,q){return K(Q(j,q))}async function o(j,q){return h(await K(Q(j,q)))}async function r(j,q){return M(await K(Q(j,q)))}async function K(j){V();let q=j.environment??x(),F=W(B(j.ssrContext));try{let G="component"in j?j.component:await j.load(),J=new G;v(q,J,j.authoredContent,j.prepareHost),j.initialize?.(J);let X=j.clientModuleSrc??await j.resolveClientModuleSrc?.(G),w=j.assets??await j.resolveAssets?.(G)??[],Y=S(w,X),T=u(Y)??X,A=j.tagName??O(G),P=(j.now??C)().toISOString(),Z=g(j.renderOptions),$=k(J),b=$?.renderHostToString?.(Z)??J.renderHostToString(Z),_=E(J,$,b);return{markup:b,metadata:{assets:Y,clientModuleUrl:T,generatedAt:P,tagName:A},preview:_}}finally{F()}}function k(j){return I()?.resolveRenderBridge(j)}function E(j,q,F){if(!q)return j.renderHost?.()??{nodeType:1,outerHTML:F};if(!q.renderHostToString&&q.renderHost)return{nodeType:1,outerHTML:F};return q.renderHost?.()??j.renderHost?.()??{nodeType:1,outerHTML:F}}function v(j,q,F,G){if(!z(q)){if(F===void 0&&G===void 0)return;throw Error(`${q.constructor.name} cannot prepare SSR host content because it does not expose an innerHTML host surface.`)}j.prepareHost(q,{authoredContent:F}),G?.(q,j)}function B(j){if(!j||j.length===0)return[];return j.map((q)=>({getContext:()=>q.value,getContextKey:()=>q.context,renderHydrationScript:()=>{return},renderHydrationScriptTag:()=>{return}}))}function h(j){if("metadata"in j)return{assets:j.metadata.assets,clientModuleSrc:j.metadata.clientModuleUrl,generatedAt:j.metadata.generatedAt,markup:j.markup,tagName:j.metadata.tagName};let{preview:q,...F}=j;return F}function n(j){let q=y(j);return{...q.assets.length>0?{[f]:JSON.stringify(q.assets)}:{},...q.clientModuleUrl?{[R]:q.clientModuleUrl}:{},[D]:q.generatedAt,[H]:q.tagName}}function y(j){if("metadata"in j)return j.metadata;if("markup"in j)return{assets:j.assets??L(j.clientModuleSrc),clientModuleUrl:j.clientModuleSrc,generatedAt:j.generatedAt,tagName:j.tagName};return j}function M(j){return{assets:j.metadata.assets,clientModuleSrc:j.metadata.clientModuleUrl,generatedAt:j.metadata.generatedAt,markup:j.markup,preview:j.preview,tagName:j.metadata.tagName}}function C(){return new Date}function L(j){if(!j)return[];return[N(j)]}function S(j,q){if(!q)return j;if(j.some((F)=>F.kind==="script-module"&&F.src===q))return j;return[...L(q),...j]}function u(j){return j.find((q)=>q.kind==="script-module")?.src}function Q(j,q){if(typeof j==="function")return{...q,component:j};return j}function g(j){if(j?.mode!==void 0||j?.hydrate!==void 0)return j;return{...j,mode:"hydrate"}}function z(j){return"innerHTML"in j}function O(j){let q=U(j);if(!q)throw Error(`${j.name} is missing @customElement metadata.`);return q}export{h as toRenderedComponentPayload,s as styleAsset,N as scriptModuleAsset,r as renderComponentWithPreview,i as renderComponentToString,o as renderComponentToPayload,t as renderComponent,d as modulePreloadAsset,n as createRenderedComponentHeaders,H as RENDERED_COMPONENT_TAG_NAME_HEADER,D as RENDERED_COMPONENT_GENERATED_AT_HEADER,R as RENDERED_COMPONENT_CLIENT_MODULE_HEADER,f as RENDERED_COMPONENT_ASSETS_HEADER};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=B4BAE5F6362D0BB164756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/server/render-component.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport {\n\tgetRadiantComponentSsrRuntime,\n\ttype RadiantComponentRenderBridge,\n\ttype RadiantComponentSsrCapable,\n} from '../core/radiant-component-ssr-registry';\nimport { withSsrContextProviders } from './context-ssr';\nimport type { ContextType, UnknownContext } from '../context/types';\nimport { getCustomElementTagName } from '../core/custom-element-metadata';\nimport { createServerRenderEnvironment, type ServerRenderEnvironment } from './light-dom-shim';\nimport { ensureRadiantComponentSsrRuntimeRegistered } from './radiant-component-ssr-runtime';\n\n/** Default response header carrying the fragment render timestamp. */\nexport const RENDERED_COMPONENT_GENERATED_AT_HEADER = 'x-generated-at';\n\n/** Default response header carrying the custom-element tag name for the fragment. */\nexport const RENDERED_COMPONENT_TAG_NAME_HEADER = 'x-radiant-tag-name';\n\n/** Default response header carrying the client module URL for the fragment. */\nexport const RENDERED_COMPONENT_CLIENT_MODULE_HEADER = 'x-radiant-client-module';\n\n/** Default response header carrying serialized fragment asset metadata. */\nexport const RENDERED_COMPONENT_ASSETS_HEADER = 'x-radiant-assets';\n\nensureRadiantComponentSsrRuntimeRegistered();\n\n/** Asset dependency emitted by a rendered fragment. */\nexport type RenderedComponentAsset =\n\t| {\n\t\t\t/** Browser module specifier that must be loaded to activate the fragment. */\n\t\t\tkind: 'script-module';\n\t\t\t/** Runtime loading policy for the module. */\n\t\t\tstage?: 'hydrate' | 'idle' | 'immediate';\n\t\t\t/** Module specifier or browser-importable URL. */\n\t\t\tsrc: string;\n\t }\n\t| {\n\t\t\t/** Module graph preload hint for adapters that control the document head. */\n\t\t\tkind: 'modulepreload';\n\t\t\t/** Module specifier or browser-importable URL. */\n\t\t\thref: string;\n\t }\n\t| {\n\t\t\t/** Stylesheet dependency required by the rendered fragment. */\n\t\t\tkind: 'style';\n\t\t\t/** Browser-importable stylesheet URL. */\n\t\t\thref: string;\n\t\t\t/** Optional media query applied to the stylesheet link. */\n\t\t\tmedia?: string;\n\t };\n\n/** Creates a module asset entry for a rendered fragment. */\nexport function scriptModuleAsset(\n\tsrc: string,\n\tstage: 'hydrate' | 'idle' | 'immediate' = 'hydrate',\n): RenderedComponentAsset {\n\treturn { kind: 'script-module', src, stage };\n}\n\n/** Creates a modulepreload hint for a rendered fragment. */\nexport function modulePreloadAsset(href: string): RenderedComponentAsset {\n\treturn { kind: 'modulepreload', href };\n}\n\n/** Creates a stylesheet asset entry for a rendered fragment. */\nexport function styleAsset(href: string, media?: string): RenderedComponentAsset {\n\treturn media ? { kind: 'style', href, media } : { kind: 'style', href };\n}\n\n/** Portable metadata for a server-rendered custom-element fragment. */\nexport type RenderedComponentMetadata = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets: readonly RenderedComponentAsset[];\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleUrl?: string;\n\t/** ISO timestamp describing when the fragment was rendered. */\n\tgeneratedAt: string;\n\t/** Custom-element tag name emitted at the fragment root. */\n\ttagName: string;\n};\n\n/** Canonical server render result returned by `renderComponent()`. */\nexport type RenderedComponent = {\n\t/** Serialized custom-element host markup. */\n\tmarkup: string;\n\t/** Transport-agnostic metadata that adapters can map onto headers or JSON. */\n\tmetadata: RenderedComponentMetadata;\n\t/** JSX-compatible preview value that can be embedded into a larger SSR shell. */\n\tpreview: JsxRenderable;\n};\n\n/** Serializable metadata for a server-rendered custom-element fragment. */\nexport type RenderedComponentPayload = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets?: readonly RenderedComponentAsset[];\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleSrc?: string;\n\t/** ISO timestamp describing when the fragment was rendered. */\n\tgeneratedAt: string;\n\t/** Serialized custom-element host markup. */\n\tmarkup: string;\n\t/** Custom-element tag name emitted at the fragment root. */\n\ttagName: string;\n};\n\n/** Full SSR result including a JSX-compatible preview value for shell composition. */\nexport type RenderedComponentWithPreview = RenderedComponentPayload & {\n\t/** JSX-compatible preview value that can be embedded into a larger SSR shell. */\n\tpreview: JsxRenderable;\n};\n\n/** Minimal component contract needed for framework-agnostic SSR helpers. */\nexport type ServerRenderableComponent = {\n\trenderHost?: () => JsxRenderable;\n\trenderHostToString: (options?: RenderToStringOptions) => string;\n};\n\n/** Constructor shape for a server-renderable component. */\nexport type ServerRenderableComponentConstructor<TComponent extends ServerRenderableComponent> =\n\tCustomElementConstructor & {\n\t\tnew (): TComponent;\n\t};\n\n/**\n * Resolves the browser-importable client module URL for a component constructor.\n *\n * Use this when the server adapter can derive the client entry lazily instead of\n * hardcoding `clientModuleSrc` for every render call.\n */\nexport type ResolveRenderedComponentClientModule<TComponent extends ServerRenderableComponent> = (\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n) => string | undefined | Promise<string | undefined>;\n\n/**\n * Resolves fragment assets for a component constructor.\n *\n * Prefer this over `resolveClientModuleSrc(...)` for new adapters so assets can\n * describe scripts, styles, and preload hints through one transport-agnostic shape.\n */\nexport type ResolveRenderedComponentAssets<TComponent extends ServerRenderableComponent> = (\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n) => readonly RenderedComponentAsset[] | undefined | Promise<readonly RenderedComponentAsset[] | undefined>;\n\n/**\n * Prepares a component host before SSR so slot-aware logic can observe authored\n * light-DOM content during render.\n */\nexport type PrepareRenderedComponentHost<TComponent extends ServerRenderableComponent> = (\n\thost: TComponent & HTMLElement,\n\tenvironment: ServerRenderEnvironment,\n) => void;\n\n/**\n * Ambient SSR context value visible while a standalone component render runs.\n *\n * This lets adapters provide ancestor-like context to `consumeContext(...)` and\n * `contextSelector(...)` without needing to instantiate a real provider host.\n */\nexport type RenderComponentSsrContextEntry<TContext extends UnknownContext = UnknownContext> = {\n\tcontext: TContext;\n\tvalue: ContextType<TContext>;\n};\n\ntype RenderComponentSharedOptions<TComponent extends ServerRenderableComponent> = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets?: readonly RenderedComponentAsset[];\n\t/** Serialized authored light-DOM content to attach to the host before rendering. */\n\tauthoredContent?: string;\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleSrc?: string;\n\t/** Initializes the component instance before the host is rendered. */\n\tinitialize?: (component: TComponent) => void;\n\t/** SSR environment responsible for preparing the host runtime and authored content. */\n\tenvironment?: ServerRenderEnvironment;\n\t/**\n\t * Dedicated host-preparation hook for slot-aware SSR.\n\t *\n\t * Use this when the server needs to append or mutate authored light-DOM\n\t * nodes directly instead of passing `authoredContent` as a string.\n\t */\n\tprepareHost?: PrepareRenderedComponentHost<TComponent>;\n\t/**\n\t * Ambient SSR context entries that should be visible while the component is\n\t * instantiated and rendered.\n\t *\n\t * This solves standalone fragment renders that need to consume context from a\n\t * parent-like server environment.\n\t */\n\tssrContext?: readonly RenderComponentSsrContextEntry[];\n\t/** Clock override used by tests and adapters that need deterministic timestamps. */\n\tnow?: () => Date;\n\t/** JSX server-renderer options forwarded to `renderHostToString()`. */\n\trenderOptions?: RenderToStringOptions;\n\t/** Lazy asset resolver used when `assets` are not provided directly. */\n\tresolveAssets?: ResolveRenderedComponentAssets<TComponent>;\n\t/** Lazy client-module resolver used when `clientModuleSrc` is not provided directly. */\n\tresolveClientModuleSrc?: ResolveRenderedComponentClientModule<TComponent>;\n\t/** Explicit tag-name override when `@customElement(...)` metadata is not desired. */\n\ttagName?: string;\n};\n\n/** Options accepted by the reusable SSR component rendering helpers. */\nexport type RenderComponentOptions<TComponent extends ServerRenderableComponent> =\n\tRenderComponentSharedOptions<TComponent> &\n\t\t(\n\t\t\t| {\n\t\t\t\t\tcomponent: ServerRenderableComponentConstructor<TComponent>;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tload: () => Promise<ServerRenderableComponentConstructor<TComponent>>;\n\t\t\t }\n\t\t);\n\n/** Call-site options used when the component constructor is passed directly. */\nexport type RenderComponentCallOptions<TComponent extends ServerRenderableComponent> =\n\tRenderComponentSharedOptions<TComponent>;\n\n/**\n * Serializes a custom element into HTML, inferring its tag name from\n * `@customElement(...)` metadata when the caller does not provide one.\n */\nexport function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<string>;\n\nexport function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<string>;\n\nexport async function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<string> {\n\treturn (await renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options))).markup;\n}\n\n/**\n * Renders a custom element into the canonical portable server-rendered shape,\n * separating transport-agnostic metadata from any HTTP-specific adapter.\n */\nexport function renderComponent<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponent>;\n\nexport function renderComponent<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponent>;\n\nexport async function renderComponent<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponent> {\n\treturn renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options));\n}\n\n/**\n * Serializes a custom element into a fragment payload that frameworks can\n * attach to any response shape they prefer.\n */\nexport function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentPayload>;\n\nexport function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponentPayload>;\n\nexport async function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentPayload> {\n\treturn toRenderedComponentPayload(\n\t\tawait renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options)),\n\t);\n}\n\n/**\n * Renders a component into both fragment metadata and a JSX-compatible preview\n * value that can be embedded into a larger server-rendered shell.\n */\nexport function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentWithPreview>;\n\nexport function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponentWithPreview>;\n\nexport async function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentWithPreview> {\n\treturn toRenderedComponentWithPreview(\n\t\tawait renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options)),\n\t);\n}\n\nasync function renderResolvedComponent<TComponent extends ServerRenderableComponent>(\n\tnormalizedOptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponent> {\n\tensureRadiantComponentSsrRuntimeRegistered();\n\n\tconst environment = normalizedOptions.environment ?? createServerRenderEnvironment();\n\tconst restoreAmbientContext = withSsrContextProviders(\n\t\tcreateAmbientSsrContextProviders(normalizedOptions.ssrContext),\n\t);\n\n\ttry {\n\t\tconst Component =\n\t\t\t'component' in normalizedOptions ? normalizedOptions.component : await normalizedOptions.load();\n\t\tconst component = new Component();\n\t\tprepareRenderedComponentHost(\n\t\t\tenvironment,\n\t\t\tcomponent,\n\t\t\tnormalizedOptions.authoredContent,\n\t\t\tnormalizedOptions.prepareHost,\n\t\t);\n\t\tnormalizedOptions.initialize?.(component);\n\n\t\tconst legacyClientModuleSrc =\n\t\t\tnormalizedOptions.clientModuleSrc ?? (await normalizedOptions.resolveClientModuleSrc?.(Component));\n\t\tconst resolvedAssets = normalizedOptions.assets ?? (await normalizedOptions.resolveAssets?.(Component)) ?? [];\n\t\tconst assets = mergeRenderedComponentAssets(resolvedAssets, legacyClientModuleSrc);\n\t\tconst clientModuleSrc = resolvePrimaryClientModuleSrc(assets) ?? legacyClientModuleSrc;\n\t\tconst tagName = normalizedOptions.tagName ?? resolveRenderedComponentTagName(Component);\n\t\tconst generatedAt = (normalizedOptions.now ?? createDefaultRenderTimestamp)().toISOString();\n\t\tconst renderOptions = normalizeRenderOptions(normalizedOptions.renderOptions);\n\t\tconst radiantSsrBridge = getRadiantComponentRenderBridge(component as unknown as RadiantComponentSsrCapable);\n\t\tconst markup =\n\t\t\tradiantSsrBridge?.renderHostToString?.(renderOptions) ?? component.renderHostToString(renderOptions);\n\t\tconst preview = resolveRenderedComponentPreview(component, radiantSsrBridge, markup);\n\n\t\treturn {\n\t\t\tmarkup,\n\t\t\tmetadata: {\n\t\t\t\tassets,\n\t\t\t\tclientModuleUrl: clientModuleSrc,\n\t\t\t\tgeneratedAt,\n\t\t\t\ttagName,\n\t\t\t},\n\t\t\tpreview,\n\t\t};\n\t} finally {\n\t\trestoreAmbientContext();\n\t}\n}\n\nfunction getRadiantComponentRenderBridge(\n\tcomponent: RadiantComponentSsrCapable,\n): RadiantComponentRenderBridge | undefined {\n\treturn getRadiantComponentSsrRuntime()?.resolveRenderBridge(component);\n}\n\n/**\n * Chooses the preview renderable returned by `renderComponent()`.\n *\n * When a component overrides only `renderHostToString()`, the inherited\n * `renderHost()` implementation would otherwise generate a different preview\n * tree than the final serialized markup. In that case the preview falls back to\n * the already-computed markup so shell composition stays aligned with the real\n * SSR output.\n */\nfunction resolveRenderedComponentPreview<TComponent extends ServerRenderableComponent>(\n\tcomponent: TComponent,\n\tradiantSsrBridge: RadiantComponentRenderBridge | undefined,\n\tmarkup: string,\n): JsxRenderable {\n\tif (!radiantSsrBridge) {\n\t\treturn component.renderHost?.() ?? { nodeType: 1, outerHTML: markup };\n\t}\n\n\tif (!radiantSsrBridge.renderHostToString && radiantSsrBridge.renderHost) {\n\t\treturn { nodeType: 1, outerHTML: markup };\n\t}\n\n\treturn radiantSsrBridge.renderHost?.() ?? component.renderHost?.() ?? { nodeType: 1, outerHTML: markup };\n}\n\nfunction prepareRenderedComponentHost<TComponent extends ServerRenderableComponent>(\n\tenvironment: ServerRenderEnvironment,\n\tcomponent: TComponent,\n\tauthoredContent: string | undefined,\n\tprepareHost: PrepareRenderedComponentHost<TComponent> | undefined,\n): void {\n\tif (!canPrepareSsrHost(component)) {\n\t\tif (authoredContent === undefined && prepareHost === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`${component.constructor.name} cannot prepare SSR host content because it does not expose an innerHTML host surface.`,\n\t\t);\n\t}\n\n\tenvironment.prepareHost(component, { authoredContent });\n\tprepareHost?.(component, environment);\n}\n\n/**\n * Wraps ad-hoc `ssrContext` values in provider-like objects so the existing SSR\n * context stack can resolve them exactly like real ancestor providers.\n */\nfunction createAmbientSsrContextProviders(\n\tentries: readonly RenderComponentSsrContextEntry[] | undefined,\n): SsrSerializableContextProvider[] {\n\tif (!entries || entries.length === 0) {\n\t\treturn [];\n\t}\n\n\treturn entries.map((entry) => ({\n\t\tgetContext: () => entry.value,\n\t\tgetContextKey: () => entry.context,\n\t\trenderHydrationScript: () => undefined,\n\t\trenderHydrationScriptTag: () => undefined,\n\t}));\n}\n\n/**\n * Drops the preview renderable so the result can be sent through lightweight\n * framework adapters or JSON/HTML fragment endpoints.\n */\nexport function toRenderedComponentPayload(\n\trender: RenderedComponentWithPreview | RenderedComponent,\n): RenderedComponentPayload {\n\tif ('metadata' in render) {\n\t\treturn {\n\t\t\tassets: render.metadata.assets,\n\t\t\tclientModuleSrc: render.metadata.clientModuleUrl,\n\t\t\tgeneratedAt: render.metadata.generatedAt,\n\t\t\tmarkup: render.markup,\n\t\t\ttagName: render.metadata.tagName,\n\t\t};\n\t}\n\n\tconst { preview: _preview, ...payload } = render;\n\treturn payload;\n}\n\n/**\n * Converts a rendered fragment payload into the standard metadata headers used\n * by client-side fragment loaders.\n */\nexport function createRenderedComponentHeaders(\n\trender: RenderedComponent | RenderedComponentMetadata | RenderedComponentPayload | RenderedComponentWithPreview,\n): Record<string, string> {\n\tconst metadata = toRenderedComponentMetadata(render);\n\n\treturn {\n\t\t...(metadata.assets.length > 0 ? { [RENDERED_COMPONENT_ASSETS_HEADER]: JSON.stringify(metadata.assets) } : {}),\n\t\t...(metadata.clientModuleUrl ? { [RENDERED_COMPONENT_CLIENT_MODULE_HEADER]: metadata.clientModuleUrl } : {}),\n\t\t[RENDERED_COMPONENT_GENERATED_AT_HEADER]: metadata.generatedAt,\n\t\t[RENDERED_COMPONENT_TAG_NAME_HEADER]: metadata.tagName,\n\t};\n}\n\nfunction toRenderedComponentMetadata(\n\trender: RenderedComponent | RenderedComponentMetadata | RenderedComponentPayload | RenderedComponentWithPreview,\n): RenderedComponentMetadata {\n\tif ('metadata' in render) {\n\t\treturn render.metadata;\n\t}\n\n\tif ('markup' in render) {\n\t\treturn {\n\t\t\tassets: render.assets ?? createLegacyRenderedComponentAssets(render.clientModuleSrc),\n\t\t\tclientModuleUrl: render.clientModuleSrc,\n\t\t\tgeneratedAt: render.generatedAt,\n\t\t\ttagName: render.tagName,\n\t\t};\n\t}\n\n\treturn render;\n}\n\nfunction toRenderedComponentWithPreview(render: RenderedComponent): RenderedComponentWithPreview {\n\treturn {\n\t\tassets: render.metadata.assets,\n\t\tclientModuleSrc: render.metadata.clientModuleUrl,\n\t\tgeneratedAt: render.metadata.generatedAt,\n\t\tmarkup: render.markup,\n\t\tpreview: render.preview,\n\t\ttagName: render.metadata.tagName,\n\t};\n}\n\nfunction createDefaultRenderTimestamp(): Date {\n\treturn new Date();\n}\n\nfunction createLegacyRenderedComponentAssets(clientModuleSrc: string | undefined): readonly RenderedComponentAsset[] {\n\tif (!clientModuleSrc) {\n\t\treturn [];\n\t}\n\n\treturn [scriptModuleAsset(clientModuleSrc)];\n}\n\nfunction mergeRenderedComponentAssets(\n\tassets: readonly RenderedComponentAsset[],\n\tlegacyClientModuleSrc: string | undefined,\n): readonly RenderedComponentAsset[] {\n\tif (!legacyClientModuleSrc) {\n\t\treturn assets;\n\t}\n\n\tif (assets.some((asset) => asset.kind === 'script-module' && asset.src === legacyClientModuleSrc)) {\n\t\treturn assets;\n\t}\n\n\treturn [...createLegacyRenderedComponentAssets(legacyClientModuleSrc), ...assets];\n}\n\nfunction resolvePrimaryClientModuleSrc(assets: readonly RenderedComponentAsset[]): string | undefined {\n\treturn assets.find((asset) => asset.kind === 'script-module')?.src;\n}\n\nfunction normalizeRenderComponentOptions<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): RenderComponentOptions<TComponent> {\n\tif (typeof componentOrOptions === 'function') {\n\t\treturn {\n\t\t\t...options,\n\t\t\tcomponent: componentOrOptions,\n\t\t};\n\t}\n\n\treturn componentOrOptions;\n}\n\nfunction normalizeRenderOptions(options: RenderToStringOptions | undefined): RenderToStringOptions {\n\tif (options?.hydrate !== undefined) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\thydrate: true,\n\t};\n}\n\nfunction canPrepareSsrHost<TComponent extends ServerRenderableComponent>(\n\tcomponent: TComponent,\n): component is TComponent & HTMLElement {\n\treturn 'innerHTML' in component;\n}\n\nfunction resolveRenderedComponentTagName(target: CustomElementConstructor): string {\n\tconst tagName = getCustomElementTagName(target);\n\n\tif (!tagName) {\n\t\tthrow new Error(`${target.name} is missing @customElement metadata.`);\n\t}\n\n\treturn tagName;\n}\n"
|
|
5
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport {\n\tgetRadiantComponentSsrRuntime,\n\ttype RadiantComponentRenderBridge,\n\ttype RadiantComponentSsrCapable,\n} from '../core/radiant-component-ssr-registry';\nimport { withSsrContextProviders } from './context-ssr';\nimport type { ContextType, UnknownContext } from '../context/types';\nimport { getCustomElementTagName } from '../core/custom-element-metadata';\nimport { createServerRenderEnvironment, type ServerRenderEnvironment } from './light-dom-shim';\nimport { ensureRadiantComponentSsrRuntimeRegistered } from './radiant-component-ssr-runtime';\n\n/** Default response header carrying the fragment render timestamp. */\nexport const RENDERED_COMPONENT_GENERATED_AT_HEADER = 'x-generated-at';\n\n/** Default response header carrying the custom-element tag name for the fragment. */\nexport const RENDERED_COMPONENT_TAG_NAME_HEADER = 'x-radiant-tag-name';\n\n/** Default response header carrying the client module URL for the fragment. */\nexport const RENDERED_COMPONENT_CLIENT_MODULE_HEADER = 'x-radiant-client-module';\n\n/** Default response header carrying serialized fragment asset metadata. */\nexport const RENDERED_COMPONENT_ASSETS_HEADER = 'x-radiant-assets';\n\nensureRadiantComponentSsrRuntimeRegistered();\n\n/** Asset dependency emitted by a rendered fragment. */\nexport type RenderedComponentAsset =\n\t| {\n\t\t\t/** Browser module specifier that must be loaded to activate the fragment. */\n\t\t\tkind: 'script-module';\n\t\t\t/** Runtime loading policy for the module. */\n\t\t\tstage?: 'hydrate' | 'idle' | 'immediate';\n\t\t\t/** Module specifier or browser-importable URL. */\n\t\t\tsrc: string;\n\t }\n\t| {\n\t\t\t/** Module graph preload hint for adapters that control the document head. */\n\t\t\tkind: 'modulepreload';\n\t\t\t/** Module specifier or browser-importable URL. */\n\t\t\thref: string;\n\t }\n\t| {\n\t\t\t/** Stylesheet dependency required by the rendered fragment. */\n\t\t\tkind: 'style';\n\t\t\t/** Browser-importable stylesheet URL. */\n\t\t\thref: string;\n\t\t\t/** Optional media query applied to the stylesheet link. */\n\t\t\tmedia?: string;\n\t };\n\n/** Creates a module asset entry for a rendered fragment. */\nexport function scriptModuleAsset(\n\tsrc: string,\n\tstage: 'hydrate' | 'idle' | 'immediate' = 'hydrate',\n): RenderedComponentAsset {\n\treturn { kind: 'script-module', src, stage };\n}\n\n/** Creates a modulepreload hint for a rendered fragment. */\nexport function modulePreloadAsset(href: string): RenderedComponentAsset {\n\treturn { kind: 'modulepreload', href };\n}\n\n/** Creates a stylesheet asset entry for a rendered fragment. */\nexport function styleAsset(href: string, media?: string): RenderedComponentAsset {\n\treturn media ? { kind: 'style', href, media } : { kind: 'style', href };\n}\n\n/** Portable metadata for a server-rendered custom-element fragment. */\nexport type RenderedComponentMetadata = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets: readonly RenderedComponentAsset[];\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleUrl?: string;\n\t/** ISO timestamp describing when the fragment was rendered. */\n\tgeneratedAt: string;\n\t/** Custom-element tag name emitted at the fragment root. */\n\ttagName: string;\n};\n\n/** Canonical server render result returned by `renderComponent()`. */\nexport type RenderedComponent = {\n\t/** Serialized custom-element host markup. */\n\tmarkup: string;\n\t/** Transport-agnostic metadata that adapters can map onto headers or JSON. */\n\tmetadata: RenderedComponentMetadata;\n\t/** JSX-compatible preview value that can be embedded into a larger SSR shell. */\n\tpreview: JsxRenderable;\n};\n\n/** Serializable metadata for a server-rendered custom-element fragment. */\nexport type RenderedComponentPayload = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets?: readonly RenderedComponentAsset[];\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleSrc?: string;\n\t/** ISO timestamp describing when the fragment was rendered. */\n\tgeneratedAt: string;\n\t/** Serialized custom-element host markup. */\n\tmarkup: string;\n\t/** Custom-element tag name emitted at the fragment root. */\n\ttagName: string;\n};\n\n/** Full SSR result including a JSX-compatible preview value for shell composition. */\nexport type RenderedComponentWithPreview = RenderedComponentPayload & {\n\t/** JSX-compatible preview value that can be embedded into a larger SSR shell. */\n\tpreview: JsxRenderable;\n};\n\n/** Minimal component contract needed for framework-agnostic SSR helpers. */\nexport type ServerRenderableComponent = {\n\trenderHost?: () => JsxRenderable;\n\trenderHostToString: (options?: RenderToStringOptions) => string;\n};\n\n/** Constructor shape for a server-renderable component. */\nexport type ServerRenderableComponentConstructor<TComponent extends ServerRenderableComponent> =\n\tCustomElementConstructor & {\n\t\tnew (): TComponent;\n\t};\n\n/**\n * Resolves the browser-importable client module URL for a component constructor.\n *\n * Use this when the server adapter can derive the client entry lazily instead of\n * hardcoding `clientModuleSrc` for every render call.\n */\nexport type ResolveRenderedComponentClientModule<TComponent extends ServerRenderableComponent> = (\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n) => string | undefined | Promise<string | undefined>;\n\n/**\n * Resolves fragment assets for a component constructor.\n *\n * Prefer this over `resolveClientModuleSrc(...)` for new adapters so assets can\n * describe scripts, styles, and preload hints through one transport-agnostic shape.\n */\nexport type ResolveRenderedComponentAssets<TComponent extends ServerRenderableComponent> = (\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n) => readonly RenderedComponentAsset[] | undefined | Promise<readonly RenderedComponentAsset[] | undefined>;\n\n/**\n * Prepares a component host before SSR so slot-aware logic can observe authored\n * light-DOM content during render.\n */\nexport type PrepareRenderedComponentHost<TComponent extends ServerRenderableComponent> = (\n\thost: TComponent & HTMLElement,\n\tenvironment: ServerRenderEnvironment,\n) => void;\n\n/**\n * Ambient SSR context value visible while a standalone component render runs.\n *\n * This lets adapters provide ancestor-like context to `consumeContext(...)` and\n * `contextSelector(...)` without needing to instantiate a real provider host.\n */\nexport type RenderComponentSsrContextEntry<TContext extends UnknownContext = UnknownContext> = {\n\tcontext: TContext;\n\tvalue: ContextType<TContext>;\n};\n\ntype RenderComponentSharedOptions<TComponent extends ServerRenderableComponent> = {\n\t/** Asset dependencies required by the rendered fragment. */\n\tassets?: readonly RenderedComponentAsset[];\n\t/** Serialized authored light-DOM content to attach to the host before rendering. */\n\tauthoredContent?: string;\n\t/** Browser-importable client module URL used to register the component before hydration. */\n\tclientModuleSrc?: string;\n\t/** Initializes the component instance before the host is rendered. */\n\tinitialize?: (component: TComponent) => void;\n\t/** SSR environment responsible for preparing the host runtime and authored content. */\n\tenvironment?: ServerRenderEnvironment;\n\t/**\n\t * Dedicated host-preparation hook for slot-aware SSR.\n\t *\n\t * Use this when the server needs to append or mutate authored light-DOM\n\t * nodes directly instead of passing `authoredContent` as a string.\n\t */\n\tprepareHost?: PrepareRenderedComponentHost<TComponent>;\n\t/**\n\t * Ambient SSR context entries that should be visible while the component is\n\t * instantiated and rendered.\n\t *\n\t * This solves standalone fragment renders that need to consume context from a\n\t * parent-like server environment.\n\t */\n\tssrContext?: readonly RenderComponentSsrContextEntry[];\n\t/** Clock override used by tests and adapters that need deterministic timestamps. */\n\tnow?: () => Date;\n\t/** JSX server-renderer options forwarded to `renderHostToString()`. */\n\trenderOptions?: RenderToStringOptions;\n\t/** Lazy asset resolver used when `assets` are not provided directly. */\n\tresolveAssets?: ResolveRenderedComponentAssets<TComponent>;\n\t/** Lazy client-module resolver used when `clientModuleSrc` is not provided directly. */\n\tresolveClientModuleSrc?: ResolveRenderedComponentClientModule<TComponent>;\n\t/** Explicit tag-name override when `@customElement(...)` metadata is not desired. */\n\ttagName?: string;\n};\n\n/** Options accepted by the reusable SSR component rendering helpers. */\nexport type RenderComponentOptions<TComponent extends ServerRenderableComponent> =\n\tRenderComponentSharedOptions<TComponent> &\n\t\t(\n\t\t\t| {\n\t\t\t\t\tcomponent: ServerRenderableComponentConstructor<TComponent>;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tload: () => Promise<ServerRenderableComponentConstructor<TComponent>>;\n\t\t\t }\n\t\t);\n\n/** Call-site options used when the component constructor is passed directly. */\nexport type RenderComponentCallOptions<TComponent extends ServerRenderableComponent> =\n\tRenderComponentSharedOptions<TComponent>;\n\n/**\n * Serializes a custom element into HTML, inferring its tag name from\n * `@customElement(...)` metadata when the caller does not provide one.\n */\nexport function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<string>;\n\nexport function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<string>;\n\nexport async function renderComponentToString<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<string> {\n\treturn (await renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options))).markup;\n}\n\n/**\n * Renders a custom element into the canonical portable server-rendered shape,\n * separating transport-agnostic metadata from any HTTP-specific adapter.\n */\nexport function renderComponent<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponent>;\n\nexport function renderComponent<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponent>;\n\nexport async function renderComponent<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponent> {\n\treturn renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options));\n}\n\n/**\n * Serializes a custom element into a fragment payload that frameworks can\n * attach to any response shape they prefer.\n */\nexport function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentPayload>;\n\nexport function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponentPayload>;\n\nexport async function renderComponentToPayload<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentPayload> {\n\treturn toRenderedComponentPayload(\n\t\tawait renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options)),\n\t);\n}\n\n/**\n * Renders a component into both fragment metadata and a JSX-compatible preview\n * value that can be embedded into a larger server-rendered shell.\n */\nexport function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\tcomponent: ServerRenderableComponentConstructor<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentWithPreview>;\n\nexport function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\toptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponentWithPreview>;\n\nexport async function renderComponentWithPreview<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): Promise<RenderedComponentWithPreview> {\n\treturn toRenderedComponentWithPreview(\n\t\tawait renderResolvedComponent(normalizeRenderComponentOptions(componentOrOptions, options)),\n\t);\n}\n\nasync function renderResolvedComponent<TComponent extends ServerRenderableComponent>(\n\tnormalizedOptions: RenderComponentOptions<TComponent>,\n): Promise<RenderedComponent> {\n\tensureRadiantComponentSsrRuntimeRegistered();\n\n\tconst environment = normalizedOptions.environment ?? createServerRenderEnvironment();\n\tconst restoreAmbientContext = withSsrContextProviders(\n\t\tcreateAmbientSsrContextProviders(normalizedOptions.ssrContext),\n\t);\n\n\ttry {\n\t\tconst Component =\n\t\t\t'component' in normalizedOptions ? normalizedOptions.component : await normalizedOptions.load();\n\t\tconst component = new Component();\n\t\tprepareRenderedComponentHost(\n\t\t\tenvironment,\n\t\t\tcomponent,\n\t\t\tnormalizedOptions.authoredContent,\n\t\t\tnormalizedOptions.prepareHost,\n\t\t);\n\t\tnormalizedOptions.initialize?.(component);\n\n\t\tconst legacyClientModuleSrc =\n\t\t\tnormalizedOptions.clientModuleSrc ?? (await normalizedOptions.resolveClientModuleSrc?.(Component));\n\t\tconst resolvedAssets = normalizedOptions.assets ?? (await normalizedOptions.resolveAssets?.(Component)) ?? [];\n\t\tconst assets = mergeRenderedComponentAssets(resolvedAssets, legacyClientModuleSrc);\n\t\tconst clientModuleSrc = resolvePrimaryClientModuleSrc(assets) ?? legacyClientModuleSrc;\n\t\tconst tagName = normalizedOptions.tagName ?? resolveRenderedComponentTagName(Component);\n\t\tconst generatedAt = (normalizedOptions.now ?? createDefaultRenderTimestamp)().toISOString();\n\t\tconst renderOptions = normalizeRenderOptions(normalizedOptions.renderOptions);\n\t\tconst radiantSsrBridge = getRadiantComponentRenderBridge(component as unknown as RadiantComponentSsrCapable);\n\t\tconst markup =\n\t\t\tradiantSsrBridge?.renderHostToString?.(renderOptions) ?? component.renderHostToString(renderOptions);\n\t\tconst preview = resolveRenderedComponentPreview(component, radiantSsrBridge, markup);\n\n\t\treturn {\n\t\t\tmarkup,\n\t\t\tmetadata: {\n\t\t\t\tassets,\n\t\t\t\tclientModuleUrl: clientModuleSrc,\n\t\t\t\tgeneratedAt,\n\t\t\t\ttagName,\n\t\t\t},\n\t\t\tpreview,\n\t\t};\n\t} finally {\n\t\trestoreAmbientContext();\n\t}\n}\n\nfunction getRadiantComponentRenderBridge(\n\tcomponent: RadiantComponentSsrCapable,\n): RadiantComponentRenderBridge | undefined {\n\treturn getRadiantComponentSsrRuntime()?.resolveRenderBridge(component);\n}\n\n/**\n * Chooses the preview renderable returned by `renderComponent()`.\n *\n * When a component overrides only `renderHostToString()`, the inherited\n * `renderHost()` implementation would otherwise generate a different preview\n * tree than the final serialized markup. In that case the preview falls back to\n * the already-computed markup so shell composition stays aligned with the real\n * SSR output.\n */\nfunction resolveRenderedComponentPreview<TComponent extends ServerRenderableComponent>(\n\tcomponent: TComponent,\n\tradiantSsrBridge: RadiantComponentRenderBridge | undefined,\n\tmarkup: string,\n): JsxRenderable {\n\tif (!radiantSsrBridge) {\n\t\treturn component.renderHost?.() ?? { nodeType: 1, outerHTML: markup };\n\t}\n\n\tif (!radiantSsrBridge.renderHostToString && radiantSsrBridge.renderHost) {\n\t\treturn { nodeType: 1, outerHTML: markup };\n\t}\n\n\treturn radiantSsrBridge.renderHost?.() ?? component.renderHost?.() ?? { nodeType: 1, outerHTML: markup };\n}\n\nfunction prepareRenderedComponentHost<TComponent extends ServerRenderableComponent>(\n\tenvironment: ServerRenderEnvironment,\n\tcomponent: TComponent,\n\tauthoredContent: string | undefined,\n\tprepareHost: PrepareRenderedComponentHost<TComponent> | undefined,\n): void {\n\tif (!canPrepareSsrHost(component)) {\n\t\tif (authoredContent === undefined && prepareHost === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`${component.constructor.name} cannot prepare SSR host content because it does not expose an innerHTML host surface.`,\n\t\t);\n\t}\n\n\tenvironment.prepareHost(component, { authoredContent });\n\tprepareHost?.(component, environment);\n}\n\n/**\n * Wraps ad-hoc `ssrContext` values in provider-like objects so the existing SSR\n * context stack can resolve them exactly like real ancestor providers.\n */\nfunction createAmbientSsrContextProviders(\n\tentries: readonly RenderComponentSsrContextEntry[] | undefined,\n): SsrSerializableContextProvider[] {\n\tif (!entries || entries.length === 0) {\n\t\treturn [];\n\t}\n\n\treturn entries.map((entry) => ({\n\t\tgetContext: () => entry.value,\n\t\tgetContextKey: () => entry.context,\n\t\trenderHydrationScript: () => undefined,\n\t\trenderHydrationScriptTag: () => undefined,\n\t}));\n}\n\n/**\n * Drops the preview renderable so the result can be sent through lightweight\n * framework adapters or JSON/HTML fragment endpoints.\n */\nexport function toRenderedComponentPayload(\n\trender: RenderedComponentWithPreview | RenderedComponent,\n): RenderedComponentPayload {\n\tif ('metadata' in render) {\n\t\treturn {\n\t\t\tassets: render.metadata.assets,\n\t\t\tclientModuleSrc: render.metadata.clientModuleUrl,\n\t\t\tgeneratedAt: render.metadata.generatedAt,\n\t\t\tmarkup: render.markup,\n\t\t\ttagName: render.metadata.tagName,\n\t\t};\n\t}\n\n\tconst { preview: _preview, ...payload } = render;\n\treturn payload;\n}\n\n/**\n * Converts a rendered fragment payload into the standard metadata headers used\n * by client-side fragment loaders.\n */\nexport function createRenderedComponentHeaders(\n\trender: RenderedComponent | RenderedComponentMetadata | RenderedComponentPayload | RenderedComponentWithPreview,\n): Record<string, string> {\n\tconst metadata = toRenderedComponentMetadata(render);\n\n\treturn {\n\t\t...(metadata.assets.length > 0 ? { [RENDERED_COMPONENT_ASSETS_HEADER]: JSON.stringify(metadata.assets) } : {}),\n\t\t...(metadata.clientModuleUrl ? { [RENDERED_COMPONENT_CLIENT_MODULE_HEADER]: metadata.clientModuleUrl } : {}),\n\t\t[RENDERED_COMPONENT_GENERATED_AT_HEADER]: metadata.generatedAt,\n\t\t[RENDERED_COMPONENT_TAG_NAME_HEADER]: metadata.tagName,\n\t};\n}\n\nfunction toRenderedComponentMetadata(\n\trender: RenderedComponent | RenderedComponentMetadata | RenderedComponentPayload | RenderedComponentWithPreview,\n): RenderedComponentMetadata {\n\tif ('metadata' in render) {\n\t\treturn render.metadata;\n\t}\n\n\tif ('markup' in render) {\n\t\treturn {\n\t\t\tassets: render.assets ?? createLegacyRenderedComponentAssets(render.clientModuleSrc),\n\t\t\tclientModuleUrl: render.clientModuleSrc,\n\t\t\tgeneratedAt: render.generatedAt,\n\t\t\ttagName: render.tagName,\n\t\t};\n\t}\n\n\treturn render;\n}\n\nfunction toRenderedComponentWithPreview(render: RenderedComponent): RenderedComponentWithPreview {\n\treturn {\n\t\tassets: render.metadata.assets,\n\t\tclientModuleSrc: render.metadata.clientModuleUrl,\n\t\tgeneratedAt: render.metadata.generatedAt,\n\t\tmarkup: render.markup,\n\t\tpreview: render.preview,\n\t\ttagName: render.metadata.tagName,\n\t};\n}\n\nfunction createDefaultRenderTimestamp(): Date {\n\treturn new Date();\n}\n\nfunction createLegacyRenderedComponentAssets(clientModuleSrc: string | undefined): readonly RenderedComponentAsset[] {\n\tif (!clientModuleSrc) {\n\t\treturn [];\n\t}\n\n\treturn [scriptModuleAsset(clientModuleSrc)];\n}\n\nfunction mergeRenderedComponentAssets(\n\tassets: readonly RenderedComponentAsset[],\n\tlegacyClientModuleSrc: string | undefined,\n): readonly RenderedComponentAsset[] {\n\tif (!legacyClientModuleSrc) {\n\t\treturn assets;\n\t}\n\n\tif (assets.some((asset) => asset.kind === 'script-module' && asset.src === legacyClientModuleSrc)) {\n\t\treturn assets;\n\t}\n\n\treturn [...createLegacyRenderedComponentAssets(legacyClientModuleSrc), ...assets];\n}\n\nfunction resolvePrimaryClientModuleSrc(assets: readonly RenderedComponentAsset[]): string | undefined {\n\treturn assets.find((asset) => asset.kind === 'script-module')?.src;\n}\n\nfunction normalizeRenderComponentOptions<TComponent extends ServerRenderableComponent>(\n\tcomponentOrOptions: ServerRenderableComponentConstructor<TComponent> | RenderComponentOptions<TComponent>,\n\toptions?: RenderComponentCallOptions<TComponent>,\n): RenderComponentOptions<TComponent> {\n\tif (typeof componentOrOptions === 'function') {\n\t\treturn {\n\t\t\t...options,\n\t\t\tcomponent: componentOrOptions,\n\t\t};\n\t}\n\n\treturn componentOrOptions;\n}\n\nfunction normalizeRenderOptions(options: RenderToStringOptions | undefined): RenderToStringOptions {\n\tif (options?.mode !== undefined || options?.hydrate !== undefined) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\tmode: 'hydrate',\n\t};\n}\n\nfunction canPrepareSsrHost<TComponent extends ServerRenderableComponent>(\n\tcomponent: TComponent,\n): component is TComponent & HTMLElement {\n\treturn 'innerHTML' in component;\n}\n\nfunction resolveRenderedComponentTagName(target: CustomElementConstructor): string {\n\tconst tagName = getCustomElementTagName(target);\n\n\tif (!tagName) {\n\t\tthrow new Error(`${target.name} is missing @customElement metadata.`);\n\t}\n\n\treturn tagName;\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "+aAeO,DAAM,HAAyC,YAGzC,HAAqC,gBAGrC,HAA0C,qBAG1C,HAAmC,cAEhD,HAA2C,EA4BpC,SAAS,CAAiB,CAChC,EACA,EAA0C,UACjB,CACzB,MAAO,CAAE,KAAM,gBAAiB,MAAK,OAAM,EAIrC,SAAS,CAAkB,CAAC,EAAsC,CACxE,MAAO,CAAE,KAAM,gBAAiB,MAAK,EAI/B,SAAS,C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EAAoC,CAAqB,EAAG,GAAG,CAAM,EAGjF,SAAS,CAA6B,CAAC,EAA+D,CACrG,OAAO,EAAO,KAAK,CAAC,IAAU,EAAM,OAAS,eAAe,GAAG,IAGhE,SAAS,CAA6E,CACrF,EACA,EACqC,CACrC,GAAI,OAAO,IAAuB,WACjC,MAAO,IACH,EACH,UAAW,CACZ,EAGD,OAAO,EAGR,SAAS,CAAsB,CAAC,EAAmE,CAClG,GAAI,GAAS,OAAS,QAAa,GAAS,UAAY,OACvD,OAAO,EAGR,MAAO,IACH,EACH,KAAM,SACP,EAGD,SAAS,CAA+D,CACvE,EACwC,CACxC,MAAO,cAAe,EAGvB,SAAS,CAA+B,CAAC,EAA0C,CAClF,IAAM,EAAU,EAAwB,CAAM,EAE9C,GAAI,CAAC,EACJ,MAAU,MAAM,GAAG,EAAO,0CAA0C,EAGrE,OAAO",
|
|
8
|
+
"debugId": "B4BAE5F6362D0BB164756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/radiant",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/ecopages/radiant.git"
|
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
"types": "./dist/context/decorators/on-context-update.d.ts",
|
|
88
88
|
"import": "./dist/context/decorators/on-context-update.js"
|
|
89
89
|
},
|
|
90
|
+
"./context/events": {
|
|
91
|
+
"types": "./dist/context/events.d.ts",
|
|
92
|
+
"import": "./dist/context/events.js"
|
|
93
|
+
},
|
|
90
94
|
"./core/radiant-element": {
|
|
91
95
|
"types": "./dist/core/radiant-element.d.ts",
|
|
92
96
|
"import": "./dist/core/radiant-element.js"
|
package/size-budget.json
CHANGED
package/dist/chunk-3ryr5wx2.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{h as g}from"./chunk-ssnnxzrj.js";import{Xa as a}from"./chunk-hztr86b4.js";import{eb as s}from"./chunk-66e6s792.js";class p{host;constructor(e){this.host=e}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({hydrate:!0})}}renderHostToString(e={},i=this.getHostAttributes()){let t=this.getTagName(),r=g(this.host.getContextProviders());try{return`<${t}${u(i)}>${this.renderHostContent(e)}</${t}>`}finally{r()}}renderHostContent(e){let i=this.host.renderToString(e),t=this.host.getAuthoredHydrationScriptMarkup?.()??"",r=this.host.getSlotProjectionScriptTag?.()??"";if(!e.hydrate)return`${i}${t}${r}`;let n=this.host.getHydrationBindings().map((o)=>o.renderHydrationScriptTag()).filter((o)=>typeof o==="string").join("");return`${i}${r}${n}`}getHostAttributes(){let e={},i=new Set;for(let t of this.host.getReactiveProperties()){let r=this.host.getPropertyValue(t.name);if(r===void 0||r===null||r===!1)continue;e[t.attribute]=String(t.converter.toAttribute(r)),i.add(t.attribute)}for(let t of this.host.getReactivePropDefinitions()){let r=t.options.attribute??t.name;if(i.has(r))continue;let n=this.host.getPropertyValue(t.name);if(n===void 0||n===null||n===!1)continue;e[r]=String(s(n,t.options.type)),i.add(r)}for(let t of this.host.listAttributeNames()){let r=this.host.getAttributeValue(t);if(r!==null)e[t]=r}return e}getTagName(){let e=a(this.host.constructor);if(!e)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return e}}function u(e){return Object.entries(e).map(([i,t])=>` ${i}="${c(t)}"`).join("")}function c(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}
|
|
2
|
-
export{p as g};
|
|
3
|
-
|
|
4
|
-
//# debugId=6FBBF457664117B864756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/core/radiant-component-ssr.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { withSsrContextProviders } from '../server/context-ssr';\nimport { getCustomElementTagName } from './custom-element-metadata';\nimport type { ReactiveProperty } from './radiant-element';\nimport type { ReactivePropDefinition } from './reactive-prop-metadata';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\ntype RadiantComponentSsrHost = {\n\tconstructor: CustomElementConstructor;\n\tgetAuthoredHydrationScriptMarkup?: () => string | undefined;\n\tgetContextProviders: () => SsrSerializableContextProvider[];\n\tgetHydrationBindings: () => SsrSerializableHydrationBinding[];\n\tgetSlotProjectionScriptTag?: () => string | undefined;\n\trenderToString: (options?: RenderToStringOptions) => string;\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\nexport class RadiantComponentSsrService {\n\tconstructor(private readonly host: RadiantComponentSsrHost) {}\n\n\tpublic renderHost(): JsxRenderable {\n\t\treturn {\n\t\t\tnodeType: 1,\n\t\t\touterHTML: this.renderHostToString({ hydrate: true }),\n\t\t};\n\t}\n\n\tpublic renderHostToString(options: RenderToStringOptions = {}, attributes = this.getHostAttributes()): string {\n\t\tconst tagName = this.getTagName();\n\t\tconst restoreSsrContexts = withSsrContextProviders(this.host.getContextProviders());\n\n\t\ttry {\n\t\t\treturn `<${tagName}${serializeHostAttributes(attributes)}>${this.renderHostContent(options)}</${tagName}>`;\n\t\t} finally {\n\t\t\trestoreSsrContexts();\n\t\t}\n\t}\n\n\tprivate renderHostContent(options: RenderToStringOptions): string {\n\t\tconst hostContent = this.host.renderToString(options);\n\t\tconst authoredHydrationMarkup = this.host.getAuthoredHydrationScriptMarkup?.() ?? '';\n\t\tconst slotProjectionScript = this.host.getSlotProjectionScriptTag?.() ?? '';\n\n\t\tif (!options.hydrate) {\n\t\t\treturn `${hostContent}${authoredHydrationMarkup}${slotProjectionScript}`;\n\t\t}\n\n\t\tconst hydrationScripts = this.host\n\t\t\t.getHydrationBindings()\n\t\t\t.map((binding) => binding.renderHydrationScriptTag())\n\t\t\t.filter((markup): markup is string => typeof markup === 'string')\n\t\t\t.join('');\n\n\t\treturn `${hostContent}${slotProjectionScript}${hydrationScripts}`;\n\t}\n\n\tpublic getHostAttributes(): Record<string, string> {\n\t\tconst attributes: Record<string, string> = {};\n\t\tconst seenAttributes = new Set<string>();\n\n\t\tfor (const property of this.host.getReactiveProperties()) {\n\t\t\tconst currentValue = this.host.getPropertyValue(property.name);\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\t\tseenAttributes.add(property.attribute);\n\t\t}\n\n\t\tfor (const definition of this.host.getReactivePropDefinitions()) {\n\t\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\t\tif (seenAttributes.has(attributeName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst currentValue = this.host.getPropertyValue(definition.name);\n\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\t\tseenAttributes.add(attributeName);\n\t\t}\n\n\t\tfor (const attributeName of this.host.listAttributeNames()) {\n\t\t\tconst attributeValue = this.host.getAttributeValue(attributeName);\n\t\t\tif (attributeValue !== null) {\n\t\t\t\tattributes[attributeName] = attributeValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tprivate getTagName(): string {\n\t\tconst tagName = getCustomElementTagName(this.host.constructor);\n\n\t\tif (!tagName) {\n\t\t\tthrow new Error(`${this.host.constructor.name} is missing @customElement metadata.`);\n\t\t}\n\n\t\treturn tagName;\n\t}\n}\n\nfunction serializeHostAttributes(attributes: Record<string, string>): string {\n\treturn Object.entries(attributes)\n\t\t.map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n\t\t.join('');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": "sIAwBO,AAAM,LAA2B,CACV,KAA7B,WAAW,CAAkB,EAA+B,CAA/B,YAEtB,UAAU,EAAkB,CAClC,MAAO,CACN,SAAU,EACV,UAAW,KAAK,mBAAmB,CAAE,QAAS,EAAK,CAAC,CACrD,EAGM,kBAAkB,CAAC,EAAiC,CAAC,EAAG,EAAa,KAAK,kBAAkB,EAAW,CAC7G,IAAM,EAAU,KAAK,WAAW,EAC1B,EAAqB,EAAwB,KAAK,KAAK,oBAAoB,CAAC,EAElF,GAAI,CACH,MAAO,IAAI,IAAU,EAAwB,CAAU,KAAK,KAAK,kBAAkB,CAAO,MAAM,YAC/F,CACD,EAAmB,GAIb,iBAAiB,CAAC,EAAwC,CACjE,IAAM,EAAc,KAAK,KAAK,eAAe,CAAO,EAC9C,EAA0B,KAAK,KAAK,mCAAmC,GAAK,GAC5E,EAAuB,KAAK,KAAK,6BAA6B,GAAK,GAEzE,GAAI,CAAC,EAAQ,QACZ,MAAO,GAAG,IAAc,IAA0B,IAGnD,IAAM,EAAmB,KAAK,KAC5B,qBAAqB,EACrB,IAAI,CAAC,IAAY,EAAQ,yBAAyB,CAAC,EACnD,OAAO,CAAC,IAA6B,OAAO,IAAW,QAAQ,EAC/D,KAAK,EAAE,EAET,MAAO,GAAG,IAAc,IAAuB,IAGzC,iBAAiB,EAA2B,CAClD,IAAM,EAAqC,CAAC,EACtC,EAAiB,IAAI,IAE3B,QAAW,KAAY,KAAK,KAAK,sBAAsB,EAAG,CACzD,IAAM,EAAe,KAAK,KAAK,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unk-3ryr5wx2.js";import{Ta as z,Ua as A}from"./chunk-e0r6ca2g.js";import{Za as D}from"./chunk-9mqtp3js.js";import{renderToString as M}from"@ecopages/jsx/server";import{withServerCustomElementRenderHook as N}from"@ecopages/jsx/server";var O=Symbol.for("@ecopages/jsx.active-ssr-hydrate"),y=new WeakSet;function P(f){return{nodeType:1,outerHTML:G(f,{hydrate:!0})}}function G(f,j={}){return J(f).renderHostToString(j,I(f))}function I(f){let j=f;if(y.has(f))return J(f).getHostAttributes();y.add(f);try{return j.getHostSsrAttributes()}finally{y.delete(f)}}function J(f){let j=f;return new F({constructor:j.constructor,getAuthoredHydrationScriptMarkup:()=>j.getAuthoredHydrationScriptMarkup(),getHydrationBindings:()=>j.getHydrationBindings(),getSlotProjectionScriptTag:()=>j.getSlotProjectionScriptTag(),renderToString:(k)=>j.renderToString(k),getContextProviders:()=>j.getContextProviders(),getReactiveProperties:()=>j.getReactiveProperties(),getReactivePropDefinitions:()=>D(f),getPropertyValue:(k)=>j[k],listAttributeNames:()=>typeof j.getAttributeNames==="function"?j.getAttributeNames():[],getAttributeValue:(k)=>j.getAttribute(k)})}function Q(f){return N(({instance:j})=>{let k=K(j);if(!k?.renderHostToString)return;let q=k.renderHostToString;return{nodeType:1,get outerHTML(){return q({hydrate:U()})}}},f)}function K(f){return f.resolveSsrRenderBridge?.()}function U(){return globalThis[O]===!0}function V(){let f=z();if(f)return f;let j={getHostAttributes:I,renderHost:P,renderHostToString:G,resolveRenderBridge:K,renderView:(k,q={})=>{let L=k;return Q(()=>M(L.resolveTrackedRenderOutput().value,q))}};return A(j),j}V();
|
|
2
|
-
export{V as f};
|
|
3
|
-
|
|
4
|
-
//# debugId=662F75D20A3DD1AA64756E2164756E21
|