@ecopages/radiant 0.3.0-alpha.23 → 0.3.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/radiant-element-ssr-service.js +2 -2
- package/core/radiant-element-ssr-service.js.map +6 -4
- package/package.json +1 -1
- package/server/host-attribute-serialization.d.ts +46 -0
- package/server/host-attribute-serialization.js +3 -0
- package/server/host-attribute-serialization.js.map +11 -0
- package/server/host-script-composition.d.ts +42 -0
- package/server/host-script-composition.js +3 -0
- package/server/host-script-composition.js.map +10 -0
- package/server/install-light-dom-shim.js +2 -2
- package/server/install-light-dom-shim.js.map +3 -3
- package/server/light-dom-shim.js +2 -2
- package/server/light-dom-shim.js.map +3 -3
- package/server/radiant-element-ssr-bridge.js +2 -2
- package/server/radiant-element-ssr-bridge.js.map +7 -5
- package/server/radiant-element-ssr-runtime.js +2 -2
- package/server/radiant-element-ssr-runtime.js.map +7 -5
- package/server/render-component.js +2 -2
- package/server/render-component.js.map +8 -6
- package/server/render-controller.js +2 -2
- package/server/render-controller.js.map +8 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(z,Q)=>(typeof require<"u"?require:z)[Q]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});function D(q){switch(q){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function E(q){switch(typeof q){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(q))return"array";if(Object.prototype.toString.call(q)==="[object Object]")return"object"}function _(q){switch(q){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function N(q){try{return JSON.parse(q)}catch{throw TypeError("Invalid JSON string")}}var T={array(q){let z=N(q);if(!Array.isArray(z))throw TypeError(`Expected an array but got a value of type "${typeof z}"`);return z},boolean(q){return!(q==="0"||String(q).toLowerCase()==="false")},number(q){return Number(q.replace(/_/g,""))},object(q){let z=JSON.parse(q);if(z===null||typeof z!=="object"||Array.isArray(z))throw TypeError(`expected value of type "object" but instead got value "${q}" of type "${E(z)}"`);return z},string(q){return q}},F={default:G,array:I,object:I};function I(q){return JSON.stringify(q)}function G(q){return`${q}`}function J(q,z){let Q=D(z);if(!Q)throw TypeError(`[radiant-element] Unknown type "${z}"`);return T[Q](q)}function P(q,z){let Q=D(z);if(!Q)throw TypeError(`[radiant-element] Unknown type "${z}"`);return(F[Q]??F.default??G)(q)}function A(q){return typeof q==="boolean"}function S(q){return typeof q==="number"}function g(q){return typeof q==="string"}function f(q){return Array.isArray(q)}function m(q){return typeof q==="object"&&!Array.isArray(q)&&q!==null}function d(q,z){switch(q){case Boolean:return A(z);case Number:return S(z);case String:return g(z);case Array:return f(z);case Object:return m(z);default:return!1}}var p=(q,z,Q,Z)=>{if(z===Boolean){let W=q.getAttribute(Q);if(W===null)return Z;return W===""?!0:J(W,z)}let $=q.getAttribute(Q);return $!==null?J($,z):Z??_(z)};var X=Symbol.for("@ecopages/radiant.customElementTagName");function l(q,z){q[X]=z}function Y(q){return q[X]}function j(q){let z={},Q=new Set;return V(q,z,Q),h(q,z,Q),y(q,z),z}function H(q){return Object.entries(q).map(([z,Q])=>` ${z}="${c(Q)}"`).join("")}function V(q,z,Q){for(let Z of q.getReactiveProperties()){let $=q.getPropertyValue(Z.name);if($===void 0||$===null||$===!1)continue;z[Z.attribute]=String(Z.converter.toAttribute($)),Q.add(Z.attribute)}}function h(q,z,Q){for(let Z of q.getReactivePropDefinitions()){let $=Z.options.attribute??Z.name;if(Q.has($))continue;let W=q.getPropertyValue(Z.name);if(W===void 0||W===null||W===!1)continue;z[$]=String(P(W,Z.options.type)),Q.add($)}}function y(q,z){for(let Q of q.listAttributeNames()){let Z=q.getAttributeValue(Q);if(Z!==null)z[Q]=Z}}function c(q){return q.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var B=Symbol.for("@ecopages/radiant.ssr-context-provider-resolver");function K(){return globalThis}function k(q){K()[B]=q}function u(q){return K()[B]?.(q)}var U;function M(){if(U!==void 0)return U;try{let{AsyncLocalStorage:q}=(()=>{throw new Error("Cannot require module "+"node:async_hooks");})();return U=new q,U}catch{return U=null,null}}var w=Symbol.for("@ecopages/radiant.ssr-context-fallback-stack");function x(){let q=globalThis;return q[w]??=[],q[w]}function L(q){if(q.length===0)return()=>{return};let z=new Map;for(let $ of q)z.set($.getContextKey(),$);let Q=M();if(Q){let $=Q.getStore()??[],W=[...$,z];return Q.enterWith(W),()=>{Q.enterWith($)}}let Z=x();return Z.push(z),()=>{let $=Z.lastIndexOf(z);if($>=0)Z.splice($,1)}}function R(q){let z=M()?.getStore()??x();for(let Q=z.length-1;Q>=0;Q-=1){let Z=z[Q]?.get(q);if(Z)return Z}return}function e(q){let z=R(q);if(!z)return;return z.getContext()}k((q)=>R(q));function C(q,z){if(!z)return`${q.hostContent}${q.authoredHydrationMarkup}${q.slotProjectionScript}`;return`${q.hostContent}${q.slotProjectionScript}${q.hydrationScripts}`}class b{host;constructor(q){this.host=q}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({mode:"hydrate"})}}renderHostToString(q={},z=this.getHostAttributes()){let Q=this.getTagName(),Z=L(this.host.getContextProviders());try{return`<${Q}${H(z)}>${this.renderHostContent(q)}</${Q}>`}finally{Z()}}renderHostContent(q){let z=q.mode==="hydrate"||q.mode===void 0&&q.hydrate===!0,Q=z?this.host.getHydrationBindings().map((Z)=>Z.renderHydrationScriptTag()).filter((Z)=>typeof Z==="string").join(""):"";return C({hostContent:this.host.renderViewToString(q),authoredHydrationMarkup:this.host.getAuthoredHydrationScriptMarkup?.()??"",slotProjectionScript:this.host.getSlotProjectionScriptTag?.()??"",hydrationScripts:Q},z)}getHostAttributes(){return j(this.host)}getTagName(){let q=Y(this.host.constructor);if(!q)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return q}}export{b as RadiantElementSsrService};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=1FF6E00FE495AD5964756E2164756E21
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/attribute-utils.ts", "../src/core/custom-element-metadata.ts", "../src/context/context-ssr-bridge.ts", "../src/server/context-ssr.ts", "../src/core/radiant-element-ssr-service.ts"],
|
|
3
|
+
"sources": ["../src/utils/attribute-utils.ts", "../src/core/custom-element-metadata.ts", "../src/server/host-attribute-serialization.ts", "../src/context/context-ssr-bridge.ts", "../src/server/context-ssr.ts", "../src/server/host-script-composition.ts", "../src/core/radiant-element-ssr-service.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
6
6
|
"export const CUSTOM_ELEMENT_TAG_NAME = Symbol.for('@ecopages/radiant.customElementTagName');\n\ntype CustomElementConstructorWithMetadata = CustomElementConstructor & {\n\t[CUSTOM_ELEMENT_TAG_NAME]?: string;\n};\n\n/**\n * Sets the custom element tag name for a given constructor.\n * This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.\n * @param target The constructor of the custom element.\n * @param tagName The tag name to associate with the custom element.\n */\nexport function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void {\n\t(target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME] = tagName;\n}\n\n/**\n * Retrieves the custom element tag name associated with a given constructor.\n * @param target The constructor of the custom element.\n * @returns The tag name associated with the custom element, or `undefined` if not set.\n */\nexport function getCustomElementTagName(target: CustomElementConstructor): string | undefined {\n\treturn (target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME];\n}\n",
|
|
7
|
+
"import type { ReactiveProperty } from '../core/reactive-prop-core';\nimport type { ReactivePropDefinition } from '../core/reactive-prop-metadata';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\n/**\n * Minimal host shape needed by the attribute serialization policy.\n *\n * This interface defines the narrow contract that the serialization module\n * consumes, keeping it independent of the full {@link RadiantElementSsrHost}.\n */\nexport type HostAttributeSource = {\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\n/**\n * Resolves the final set of SSR host attributes from a Radiant Element Host.\n *\n * ## Source precedence (highest to lowest)\n *\n * 1. **Reactive properties** — legacy attribute reflection via `property.converter`.\n * These are already-registered reactive properties with established converters.\n * Falsy values (`undefined`, `null`, `false`) are omitted.\n *\n * 2. **Reactive prop definitions** — decorator-based definitions. Skipped when the\n * target attribute name was already emitted by source 1 (dedup via `seenAttributes`).\n * Uses `writeAttributeValue` for type-aware conversion.\n *\n * 3. **Authored attributes** — raw host-level attributes from the original markup.\n * These always win if present, regardless of whether sources 1 or 2 already\n * set the same name. This preserves explicit author intent in templates.\n *\n * @param host Host shape providing reactive state and attribute accessors.\n * @returns Flat record of attribute name → serialized value.\n */\nexport function resolveHostAttributes(host: HostAttributeSource): Record<string, string> {\n\tconst attributes: Record<string, string> = {};\n\tconst seenAttributes = new Set<string>();\n\n\tappendReactivePropertyAttributes(host, attributes, seenAttributes);\n\tappendReactivePropDefinitionAttributes(host, attributes, seenAttributes);\n\tappendAuthoredAttributes(host, attributes);\n\n\treturn attributes;\n}\n\n/**\n * Serializes a flat attribute record into an HTML attribute string.\n *\n * Each entry becomes ` name=\"escaped-value\"` with the leading space included.\n * The combined string is safe for direct interpolation into an opening tag.\n *\n * @param attributes Flat attribute record to serialize.\n * @returns HTML attribute string.\n */\nexport function stringifyHostAttributes(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\n/**\n * Source 1: Reactive properties with established converters.\n *\n * Falsy runtime values are omitted — they should not appear as attributes\n * in SSR output.\n */\nfunction appendReactivePropertyAttributes(\n\thost: HostAttributeSource,\n\tattributes: Record<string, string>,\n\tseenAttributes: Set<string>,\n): void {\n\tfor (const property of host.getReactiveProperties()) {\n\t\tconst currentValue = host.getPropertyValue(property.name);\n\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\tseenAttributes.add(property.attribute);\n\t}\n}\n\n/**\n * Source 2: Decorator-based reactive prop definitions.\n *\n * Skipped when the attribute name was already emitted by source 1, preventing\n * duplicate or conflicting attribute values.\n */\nfunction appendReactivePropDefinitionAttributes(\n\thost: HostAttributeSource,\n\tattributes: Record<string, string>,\n\tseenAttributes: Set<string>,\n): void {\n\tfor (const definition of host.getReactivePropDefinitions()) {\n\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\tif (seenAttributes.has(attributeName)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst currentValue = host.getPropertyValue(definition.name);\n\n\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\tseenAttributes.add(attributeName);\n\t}\n}\n\n/**\n * Source 3: Authored attributes from the original markup.\n *\n * These always overwrite — when an author explicitly sets an attribute in\n * markup, that intent takes precedence over reactive property reflection.\n */\nfunction appendAuthoredAttributes(host: HostAttributeSource, attributes: Record<string, string>): void {\n\tfor (const attributeName of host.listAttributeNames()) {\n\t\tconst attributeValue = host.getAttributeValue(attributeName);\n\t\tif (attributeValue !== null) {\n\t\t\tattributes[attributeName] = attributeValue;\n\t\t}\n\t}\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n",
|
|
7
8
|
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
8
9
|
"import type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { installSsrContextProviderResolver } from '../context/context-ssr-bridge';\nimport type { ContextType, UnknownContext } from '../context/types';\n\ntype ProviderFrame = Map<UnknownContext, SsrSerializableContextProvider>;\ntype ProviderStack = ProviderFrame[];\n\nlet resolvedAsyncLocalStorage: AsyncLocalStorage<ProviderStack> | null | undefined;\n\n/**\n * Lazily resolves `AsyncLocalStorage` from `node:async_hooks`.\n *\n * The dynamic `require` is necessary because browser-based SSR tests import\n * this server-oriented module directly. A top-level static import would break\n * those browser bundles even though normal application SSR runs on the server.\n *\n * On the server (Node.js, Bun, Cloudflare Workers) the import always succeeds.\n * In browser test environments where SSR rendering is exercised without a real\n * server, the fallback global stack is used instead.\n */\nfunction getAsyncLocalStorage(): AsyncLocalStorage<ProviderStack> | null {\n\tif (resolvedAsyncLocalStorage !== undefined) {\n\t\treturn resolvedAsyncLocalStorage;\n\t}\n\n\ttry {\n\t\tconst { AsyncLocalStorage: ALS } = require('node:async_hooks') as typeof import('node:async_hooks');\n\t\tresolvedAsyncLocalStorage = new ALS<ProviderStack>();\n\t\treturn resolvedAsyncLocalStorage;\n\t} catch {\n\t\tresolvedAsyncLocalStorage = null;\n\t\treturn null;\n\t}\n}\n\nconst SSR_CONTEXT_FALLBACK_STACK_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-fallback-stack');\n\nfunction getFallbackStack(): ProviderStack {\n\tconst g = globalThis as typeof globalThis & { [SSR_CONTEXT_FALLBACK_STACK_SYMBOL]?: ProviderStack };\n\tg[SSR_CONTEXT_FALLBACK_STACK_SYMBOL] ??= [];\n\treturn g[SSR_CONTEXT_FALLBACK_STACK_SYMBOL];\n}\n\n/**\n * Pushes a temporary provider frame onto the SSR context stack.\n *\n * On the server, each call creates an isolated `AsyncLocalStorage` context so\n * concurrent renders cannot corrupt each other.\n *\n * In browser test environments where `AsyncLocalStorage` is unavailable, a\n * synchronous global stack is used as a fallback.\n */\nexport function withSsrContextProviders(providers: readonly SsrSerializableContextProvider[]): () => void {\n\tif (providers.length === 0) {\n\t\treturn () => undefined;\n\t}\n\n\tconst frame = new Map<UnknownContext, SsrSerializableContextProvider>();\n\n\tfor (const provider of providers) {\n\t\tframe.set(provider.getContextKey(), provider);\n\t}\n\n\tconst als = getAsyncLocalStorage();\n\n\tif (als) {\n\t\tconst parentStack = als.getStore() ?? [];\n\t\tconst childStack = [...parentStack, frame];\n\t\tals.enterWith(childStack);\n\n\t\treturn () => {\n\t\t\tals.enterWith(parentStack);\n\t\t};\n\t}\n\n\tconst stack = getFallbackStack();\n\tstack.push(frame);\n\n\treturn () => {\n\t\tconst index = stack.lastIndexOf(frame);\n\t\tif (index >= 0) stack.splice(index, 1);\n\t};\n}\n\n/**\n * Resolves the nearest SSR-visible provider for a given context token.\n *\n * Lookup walks the provider frames from innermost to outermost so nested host\n * serialization behaves the same way as runtime context resolution in the DOM.\n */\nexport function resolveSsrContextProvider<T extends UnknownContext>(\n\tcontext: T,\n): SsrSerializableContextProvider | undefined {\n\tconst store = getAsyncLocalStorage()?.getStore() ?? getFallbackStack();\n\n\tfor (let index = store.length - 1; index >= 0; index -= 1) {\n\t\tconst provider = store[index]?.get(context);\n\n\t\tif (provider) {\n\t\t\treturn provider;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolves the current SSR-visible value for a given context token.\n *\n * This is the ergonomic helper consumed by SSR-aware decorators and component\n * render paths when they only need the context payload instead of the full\n * provider instance.\n */\nexport function resolveSsrContextValue<T extends UnknownContext>(context: T): ContextType<T> | undefined {\n\tconst provider = resolveSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn undefined;\n\t}\n\n\treturn provider.getContext() as ContextType<T>;\n}\n\ninstallSsrContextProviderResolver((context) => resolveSsrContextProvider(context));\n",
|
|
9
|
-
"
|
|
10
|
+
"/**\n * Host script composition for Radiant SSR.\n *\n * This module owns the mode-sensitive ordering and inclusion rules for the\n * script payloads that appear inside a server-rendered Element Host.\n *\n * ## Composition rules\n *\n * | Mode | Order |\n * |-----------|-----------------------------------------------------------------|\n * | `plain` | view content → authored hydration markup → slot projection |\n * | `hydrate` | view content → slot projection → hydration binding scripts |\n *\n * In **plain** mode, authored hydration markup (script tags pre-authored on the\n * host) is preserved because the component may rely on them for standalone\n * behavior. Hydration binding scripts are omitted because there is no client\n * hydrator to consume them.\n *\n * In **hydrate** mode, authored hydration markup is superseded by the formal\n * hydration binding scripts. Slot projection comes before hydration scripts so\n * the client can reconstruct projected content before binding recovery.\n */\n\n/** Individual content parts that make up a server-rendered host's inner HTML. */\nexport type HostContentParts = {\n\t/** The rendered view HTML from `renderViewToString`. */\n\thostContent: string;\n\t/** Authored hydration script markup pre-existing on the host, if any. */\n\tauthoredHydrationMarkup: string;\n\t/** Slot projection JSON payload script tag, if any. */\n\tslotProjectionScript: string;\n\t/** Hydration binding script tags for client-side recovery, if any. */\n\thydrationScripts: string;\n};\n\n/**\n * Assembles the inner HTML of a server-rendered Element Host from its\n * individual content parts, respecting the mode-sensitive ordering rules.\n *\n * @param parts Individual content parts to compose.\n * @param hydrate Whether the output targets client-side hydration.\n * @returns Assembled inner HTML string.\n */\nexport function composeHostContent(parts: HostContentParts, hydrate: boolean): string {\n\tif (!hydrate) {\n\t\treturn `${parts.hostContent}${parts.authoredHydrationMarkup}${parts.slotProjectionScript}`;\n\t}\n\n\treturn `${parts.hostContent}${parts.slotProjectionScript}${parts.hydrationScripts}`;\n}\n",
|
|
11
|
+
"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 './reactive-prop-core';\nimport type { ReactivePropDefinition } from './reactive-prop-metadata';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { resolveHostAttributes, stringifyHostAttributes } from '../server/host-attribute-serialization';\nimport { composeHostContent } from '../server/host-script-composition';\n\nexport type RadiantElementSsrHost = {\n\tconstructor: CustomElementConstructor;\n\tgetAuthoredHydrationScriptMarkup?: () => string | undefined;\n\tgetContextProviders: () => SsrSerializableContextProvider[];\n\tgetHydrationBindings: () => SsrSerializableHydrationBinding[];\n\tgetSlotProjectionScriptTag?: () => string | undefined;\n\trenderViewToString: (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 RadiantElementSsrService {\n\tconstructor(private readonly host: RadiantElementSsrHost) {}\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}${stringifyHostAttributes(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 hydrate = options.mode === 'hydrate' || (options.mode === undefined && options.hydrate === true);\n\n\t\tconst hydrationScripts = hydrate\n\t\t\t? this.host\n\t\t\t\t\t.getHydrationBindings()\n\t\t\t\t\t.map((binding) => binding.renderHydrationScriptTag())\n\t\t\t\t\t.filter((markup): markup is string => typeof markup === 'string')\n\t\t\t\t\t.join('')\n\t\t\t: '';\n\n\t\treturn composeHostContent(\n\t\t\t{\n\t\t\t\thostContent: this.host.renderViewToString(options),\n\t\t\t\tauthoredHydrationMarkup: this.host.getAuthoredHydrationScriptMarkup?.() ?? '',\n\t\t\t\tslotProjectionScript: this.host.getSlotProjectionScriptTag?.() ?? '',\n\t\t\t\thydrationScripts,\n\t\t\t},\n\t\t\thydrate,\n\t\t);\n\t}\n\n\tpublic getHostAttributes(): Record<string, string> {\n\t\treturn resolveHostAttributes(this.host);\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"
|
|
10
12
|
],
|
|
11
|
-
"mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MA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AAC,IAA6B,OAAO,IAAW,QAAQ,EAC/D,KAAK,EAAE,EACR,GAEH,OAAO,EACN,CACC,YAAa,KAAK,KAAK,mBAAmB,CAAO,EACjD,wBAAyB,KAAK,KAAK,mCAAmC,GAAK,GAC3E,qBAAsB,KAAK,KAAK,6BAA6B,GAAK,GAClE,kBACD,EACA,CACD,EAGM,iBAAiB,EAA2B,CAClD,OAAO,EAAsB,KAAK,IAAI,EAG/B,UAAU,EAAW,CAC5B,IAAM,EAAU,EAAwB,KAAK,KAAK,WAAW,EAE7D,GAAI,CAAC,EACJ,MAAU,MAAM,GAAG,KAAK,KAAK,YAAY,0CAA0C,EAGpF,OAAO,EAET",
|
|
14
|
+
"debugId": "1FF6E00FE495AD5964756E2164756E21",
|
|
13
15
|
"names": []
|
|
14
16
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactiveProperty } from '../core/reactive-prop-core';
|
|
2
|
+
import type { ReactivePropDefinition } from '../core/reactive-prop-metadata';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal host shape needed by the attribute serialization policy.
|
|
5
|
+
*
|
|
6
|
+
* This interface defines the narrow contract that the serialization module
|
|
7
|
+
* consumes, keeping it independent of the full {@link RadiantElementSsrHost}.
|
|
8
|
+
*/
|
|
9
|
+
export type HostAttributeSource = {
|
|
10
|
+
getReactiveProperties: () => ReactiveProperty[];
|
|
11
|
+
getReactivePropDefinitions: () => ReactivePropDefinition[];
|
|
12
|
+
getPropertyValue: (name: string) => unknown;
|
|
13
|
+
listAttributeNames: () => string[];
|
|
14
|
+
getAttributeValue: (name: string) => string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the final set of SSR host attributes from a Radiant Element Host.
|
|
18
|
+
*
|
|
19
|
+
* ## Source precedence (highest to lowest)
|
|
20
|
+
*
|
|
21
|
+
* 1. **Reactive properties** — legacy attribute reflection via `property.converter`.
|
|
22
|
+
* These are already-registered reactive properties with established converters.
|
|
23
|
+
* Falsy values (`undefined`, `null`, `false`) are omitted.
|
|
24
|
+
*
|
|
25
|
+
* 2. **Reactive prop definitions** — decorator-based definitions. Skipped when the
|
|
26
|
+
* target attribute name was already emitted by source 1 (dedup via `seenAttributes`).
|
|
27
|
+
* Uses `writeAttributeValue` for type-aware conversion.
|
|
28
|
+
*
|
|
29
|
+
* 3. **Authored attributes** — raw host-level attributes from the original markup.
|
|
30
|
+
* These always win if present, regardless of whether sources 1 or 2 already
|
|
31
|
+
* set the same name. This preserves explicit author intent in templates.
|
|
32
|
+
*
|
|
33
|
+
* @param host Host shape providing reactive state and attribute accessors.
|
|
34
|
+
* @returns Flat record of attribute name → serialized value.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveHostAttributes(host: HostAttributeSource): Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Serializes a flat attribute record into an HTML attribute string.
|
|
39
|
+
*
|
|
40
|
+
* Each entry becomes ` name="escaped-value"` with the leading space included.
|
|
41
|
+
* The combined string is safe for direct interpolation into an opening tag.
|
|
42
|
+
*
|
|
43
|
+
* @param attributes Flat attribute record to serialize.
|
|
44
|
+
* @returns HTML attribute string.
|
|
45
|
+
*/
|
|
46
|
+
export declare function stringifyHostAttributes(attributes: Record<string, string>): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var K=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(x,z)=>(typeof require<"u"?require:x)[z]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});function Q(q){switch(q){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function X(q){switch(typeof q){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(q))return"array";if(Object.prototype.toString.call(q)==="[object Object]")return"object"}function Y(q){switch(q){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function Z(q){try{return JSON.parse(q)}catch{throw TypeError("Invalid JSON string")}}var _={array(q){let x=Z(q);if(!Array.isArray(x))throw TypeError(`Expected an array but got a value of type "${typeof x}"`);return x},boolean(q){return!(q==="0"||String(q).toLowerCase()==="false")},number(q){return Number(q.replace(/_/g,""))},object(q){let x=JSON.parse(q);if(x===null||typeof x!=="object"||Array.isArray(x))throw TypeError(`expected value of type "object" but instead got value "${q}" of type "${X(x)}"`);return x},string(q){return q}},I={default:U,array:L,object:L};function L(q){return JSON.stringify(q)}function U(q){return`${q}`}function M(q,x){let z=Q(x);if(!z)throw TypeError(`[radiant-element] Unknown type "${x}"`);return _[z](q)}function W(q,x){let z=Q(x);if(!z)throw TypeError(`[radiant-element] Unknown type "${x}"`);return(I[z]??I.default??U)(q)}function $(q){return typeof q==="boolean"}function k(q){return typeof q==="number"}function B(q){return typeof q==="string"}function F(q){return Array.isArray(q)}function P(q){return typeof q==="object"&&!Array.isArray(q)&&q!==null}function j(q,x){switch(q){case Boolean:return $(x);case Number:return k(x);case String:return B(x);case Array:return F(x);case Object:return P(x);default:return!1}}var S=(q,x,z,E)=>{if(x===Boolean){let H=q.getAttribute(z);if(H===null)return E;return H===""?!0:M(H,x)}let G=q.getAttribute(z);return G!==null?M(G,x):E??Y(x)};function T(q){let x={},z=new Set;return R(q,x,z),D(q,x,z),C(q,x),x}function m(q){return Object.entries(q).map(([x,z])=>` ${x}="${J(z)}"`).join("")}function R(q,x,z){for(let E of q.getReactiveProperties()){let G=q.getPropertyValue(E.name);if(G===void 0||G===null||G===!1)continue;x[E.attribute]=String(E.converter.toAttribute(G)),z.add(E.attribute)}}function D(q,x,z){for(let E of q.getReactivePropDefinitions()){let G=E.options.attribute??E.name;if(z.has(G))continue;let H=q.getPropertyValue(E.name);if(H===void 0||H===null||H===!1)continue;x[G]=String(W(H,E.options.type)),z.add(G)}}function C(q,x){for(let z of q.listAttributeNames()){let E=q.getAttributeValue(z);if(E!==null)x[z]=E}}function J(q){return q.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}export{m as stringifyHostAttributes,T as resolveHostAttributes};
|
|
2
|
+
|
|
3
|
+
//# debugId=363DCF2C8EEBB11364756E2164756E21
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/attribute-utils.ts", "../src/server/host-attribute-serialization.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
6
|
+
"import type { ReactiveProperty } from '../core/reactive-prop-core';\nimport type { ReactivePropDefinition } from '../core/reactive-prop-metadata';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\n/**\n * Minimal host shape needed by the attribute serialization policy.\n *\n * This interface defines the narrow contract that the serialization module\n * consumes, keeping it independent of the full {@link RadiantElementSsrHost}.\n */\nexport type HostAttributeSource = {\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\n/**\n * Resolves the final set of SSR host attributes from a Radiant Element Host.\n *\n * ## Source precedence (highest to lowest)\n *\n * 1. **Reactive properties** — legacy attribute reflection via `property.converter`.\n * These are already-registered reactive properties with established converters.\n * Falsy values (`undefined`, `null`, `false`) are omitted.\n *\n * 2. **Reactive prop definitions** — decorator-based definitions. Skipped when the\n * target attribute name was already emitted by source 1 (dedup via `seenAttributes`).\n * Uses `writeAttributeValue` for type-aware conversion.\n *\n * 3. **Authored attributes** — raw host-level attributes from the original markup.\n * These always win if present, regardless of whether sources 1 or 2 already\n * set the same name. This preserves explicit author intent in templates.\n *\n * @param host Host shape providing reactive state and attribute accessors.\n * @returns Flat record of attribute name → serialized value.\n */\nexport function resolveHostAttributes(host: HostAttributeSource): Record<string, string> {\n\tconst attributes: Record<string, string> = {};\n\tconst seenAttributes = new Set<string>();\n\n\tappendReactivePropertyAttributes(host, attributes, seenAttributes);\n\tappendReactivePropDefinitionAttributes(host, attributes, seenAttributes);\n\tappendAuthoredAttributes(host, attributes);\n\n\treturn attributes;\n}\n\n/**\n * Serializes a flat attribute record into an HTML attribute string.\n *\n * Each entry becomes ` name=\"escaped-value\"` with the leading space included.\n * The combined string is safe for direct interpolation into an opening tag.\n *\n * @param attributes Flat attribute record to serialize.\n * @returns HTML attribute string.\n */\nexport function stringifyHostAttributes(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\n/**\n * Source 1: Reactive properties with established converters.\n *\n * Falsy runtime values are omitted — they should not appear as attributes\n * in SSR output.\n */\nfunction appendReactivePropertyAttributes(\n\thost: HostAttributeSource,\n\tattributes: Record<string, string>,\n\tseenAttributes: Set<string>,\n): void {\n\tfor (const property of host.getReactiveProperties()) {\n\t\tconst currentValue = host.getPropertyValue(property.name);\n\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\tseenAttributes.add(property.attribute);\n\t}\n}\n\n/**\n * Source 2: Decorator-based reactive prop definitions.\n *\n * Skipped when the attribute name was already emitted by source 1, preventing\n * duplicate or conflicting attribute values.\n */\nfunction appendReactivePropDefinitionAttributes(\n\thost: HostAttributeSource,\n\tattributes: Record<string, string>,\n\tseenAttributes: Set<string>,\n): void {\n\tfor (const definition of host.getReactivePropDefinitions()) {\n\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\tif (seenAttributes.has(attributeName)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst currentValue = host.getPropertyValue(definition.name);\n\n\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\tseenAttributes.add(attributeName);\n\t}\n}\n\n/**\n * Source 3: Authored attributes from the original markup.\n *\n * These always overwrite — when an author explicitly sets an attribute in\n * markup, that intent takes precedence over reactive property reflection.\n */\nfunction appendAuthoredAttributes(host: HostAttributeSource, attributes: Record<string, string>): void {\n\tfor (const attributeName of host.listAttributeNames()) {\n\t\tconst attributeValue = host.getAttributeValue(attributeName);\n\t\tif (attributeValue !== null) {\n\t\t\tattributes[attributeName] = attributeValue;\n\t\t}\n\t}\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MAAO,cACH,OACJ,MAAO,UAUH,SAAS,CAAyB,CAAC,EAAqC,CAC9E,OAAQ,OAAO,OACT,UACJ,MAAO,cACH,SACJ,MAAO,aACH,SACJ,MAAO,SAGT,GAAI,MAAM,QAAQ,CAAY,EAAG,MAAO,QACxC,GAAI,OAAO,UAAU,SAAS,KAAK,CAAY,IAAM,kBAAmB,MAAO,SASzE,SAAS,CAAmB,CAAC,EAAsC,CACzE,OAAQ,QACF,OACJ,MAAO,QACH,OACJ,MAAO,QACH,QACJ,MAAO,WAEP,OAAO,MASV,SAAS,CAAY,CAAC,EAAkB,CACvC,GAAI,CACH,OAAO,KAAK,MAAM,CAAK,EACtB,KAAM,CACP,MAAU,UAAU,qBAAqB,GAQ3C,IAAM,EAAsC,CAC3C,KAAK,CAAC,EAA0B,CAC/B,IAAM,EAAQ,EAAqB,CAAK,EACxC,GAAI,CAAC,MAAM,QAAQ,CAAK,EACvB,MAAU,UAAU,8CAA8C,OAAO,IAAQ,EAElF,OAAO,GAGR,OAAO,CAAC,EAAwB,CAC/B,MAAO,EAAE,IAAU,KAAO,OAAO,CAAK,EAAE,YAAY,IAAM,UAG3D,MAAM,CAA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,IAAiB,MAAQ,IAAiB,GAC3E,SAGD,EAAW,GAAiB,OAAO,EAAoB,EAAc,EAAW,QAAQ,IAAI,CAAC,EAC7F,EAAe,IAAI,CAAa,GAUlC,SAAS,CAAwB,CAAC,EAA2B,EAA0C,CACtG,QAAW,KAAiB,EAAK,mBAAmB,EAAG,CACtD,IAAM,EAAiB,EAAK,kBAAkB,CAAa,EAC3D,GAAI,IAAmB,KACtB,EAAW,GAAiB,GAK/B,SAAS,CAAe,CAAC,EAAuB,CAC/C,OAAO,EAAM,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,QAAQ,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM",
|
|
9
|
+
"debugId": "363DCF2C8EEBB11364756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host script composition for Radiant SSR.
|
|
3
|
+
*
|
|
4
|
+
* This module owns the mode-sensitive ordering and inclusion rules for the
|
|
5
|
+
* script payloads that appear inside a server-rendered Element Host.
|
|
6
|
+
*
|
|
7
|
+
* ## Composition rules
|
|
8
|
+
*
|
|
9
|
+
* | Mode | Order |
|
|
10
|
+
* |-----------|-----------------------------------------------------------------|
|
|
11
|
+
* | `plain` | view content → authored hydration markup → slot projection |
|
|
12
|
+
* | `hydrate` | view content → slot projection → hydration binding scripts |
|
|
13
|
+
*
|
|
14
|
+
* In **plain** mode, authored hydration markup (script tags pre-authored on the
|
|
15
|
+
* host) is preserved because the component may rely on them for standalone
|
|
16
|
+
* behavior. Hydration binding scripts are omitted because there is no client
|
|
17
|
+
* hydrator to consume them.
|
|
18
|
+
*
|
|
19
|
+
* In **hydrate** mode, authored hydration markup is superseded by the formal
|
|
20
|
+
* hydration binding scripts. Slot projection comes before hydration scripts so
|
|
21
|
+
* the client can reconstruct projected content before binding recovery.
|
|
22
|
+
*/
|
|
23
|
+
/** Individual content parts that make up a server-rendered host's inner HTML. */
|
|
24
|
+
export type HostContentParts = {
|
|
25
|
+
/** The rendered view HTML from `renderViewToString`. */
|
|
26
|
+
hostContent: string;
|
|
27
|
+
/** Authored hydration script markup pre-existing on the host, if any. */
|
|
28
|
+
authoredHydrationMarkup: string;
|
|
29
|
+
/** Slot projection JSON payload script tag, if any. */
|
|
30
|
+
slotProjectionScript: string;
|
|
31
|
+
/** Hydration binding script tags for client-side recovery, if any. */
|
|
32
|
+
hydrationScripts: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Assembles the inner HTML of a server-rendered Element Host from its
|
|
36
|
+
* individual content parts, respecting the mode-sensitive ordering rules.
|
|
37
|
+
*
|
|
38
|
+
* @param parts Individual content parts to compose.
|
|
39
|
+
* @param hydrate Whether the output targets client-side hydration.
|
|
40
|
+
* @returns Assembled inner HTML string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function composeHostContent(parts: HostContentParts, hydrate: boolean): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var w=((j)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(j,{get:(k,q)=>(typeof require<"u"?require:k)[q]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});function z(j,k){if(!k)return`${j.hostContent}${j.authoredHydrationMarkup}${j.slotProjectionScript}`;return`${j.hostContent}${j.slotProjectionScript}${j.hydrationScripts}`}export{z as composeHostContent};
|
|
2
|
+
|
|
3
|
+
//# debugId=F936D9164DED36A464756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/server/host-script-composition.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Host script composition for Radiant SSR.\n *\n * This module owns the mode-sensitive ordering and inclusion rules for the\n * script payloads that appear inside a server-rendered Element Host.\n *\n * ## Composition rules\n *\n * | Mode | Order |\n * |-----------|-----------------------------------------------------------------|\n * | `plain` | view content → authored hydration markup → slot projection |\n * | `hydrate` | view content → slot projection → hydration binding scripts |\n *\n * In **plain** mode, authored hydration markup (script tags pre-authored on the\n * host) is preserved because the component may rely on them for standalone\n * behavior. Hydration binding scripts are omitted because there is no client\n * hydrator to consume them.\n *\n * In **hydrate** mode, authored hydration markup is superseded by the formal\n * hydration binding scripts. Slot projection comes before hydration scripts so\n * the client can reconstruct projected content before binding recovery.\n */\n\n/** Individual content parts that make up a server-rendered host's inner HTML. */\nexport type HostContentParts = {\n\t/** The rendered view HTML from `renderViewToString`. */\n\thostContent: string;\n\t/** Authored hydration script markup pre-existing on the host, if any. */\n\tauthoredHydrationMarkup: string;\n\t/** Slot projection JSON payload script tag, if any. */\n\tslotProjectionScript: string;\n\t/** Hydration binding script tags for client-side recovery, if any. */\n\thydrationScripts: string;\n};\n\n/**\n * Assembles the inner HTML of a server-rendered Element Host from its\n * individual content parts, respecting the mode-sensitive ordering rules.\n *\n * @param parts Individual content parts to compose.\n * @param hydrate Whether the output targets client-side hydration.\n * @returns Assembled inner HTML string.\n */\nexport function composeHostContent(parts: HostContentParts, hydrate: boolean): string {\n\tif (!hydrate) {\n\t\treturn `${parts.hostContent}${parts.authoredHydrationMarkup}${parts.slotProjectionScript}`;\n\t}\n\n\treturn `${parts.hostContent}${parts.slotProjectionScript}${parts.hydrationScripts}`;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "2PA2CO,SAAS,CAAkB,CAAC,EAAyB,EAA0B,CACrF,GAAI,CAAC,EACJ,MAAO,GAAG,EAAM,cAAc,EAAM,0BAA0B,EAAM,uBAGrE,MAAO,GAAG,EAAM,cAAc,EAAM,uBAAuB,EAAM",
|
|
8
|
+
"debugId": "F936D9164DED36A464756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var r=((f)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(f,{get:(O,Q)=>(typeof require<"u"?require:O)[Q]}):f)(function(f){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+f+'" is not supported')});var F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(f){let O=[],Q=0;while(Q<f.length){let $=Q;if(f.startsWith("<!--",Q)){let B=f.indexOf("-->",Q+4);Q=B===-1?f.length:B+3,O.push(f.slice($,Q));continue}if(f[Q]!=="<"){let B=f.indexOf("<",Q);Q=B===-1?f.length:B,O.push(f.slice($,Q));continue}let q=G(f,Q);if(!q){O.push(f.slice($));break}if(q.type!=="open"||q.selfClosing||F.has(q.tagName)){Q=q.end,O.push(f.slice($,Q));continue}Q=q.end;let Z=1;while(Q<f.length&&Z>0){let B=f.indexOf("<",Q);if(B===-1){Q=f.length;break}let V=G(f,B);if(!V){Q=f.length;break}if(Q=V.end,V.type==="comment"||V.type==="declaration")continue;if(V.type==="open"&&!V.selfClosing&&!F.has(V.tagName)){Z+=1;continue}if(V.type==="close")Z-=1}O.push(f.slice($,Q))}return O.filter(($)=>$!=="")}function C(f,O){let Q;for(let $=O+1;$<f.length;$+=1){let q=f[$];if(Q){if(q===Q)Q=void 0;continue}if(q==='"'||q==="'"){Q=q;continue}if(q===">")return $+1}return f.length}function k(f){let O={},Q=/([:^@A-Za-z0-9_.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>/]+)))?/g;for(let $ of f.matchAll(Q)){let[,q,Z,B,V]=$;if(!q)continue;O[q]=Z??B??V??""}return O}function G(f,O){if(f.startsWith("<!--",O)){let y=f.indexOf("-->",O+4);return{end:y===-1?f.length:y+3,type:"comment"}}let Q=C(f,O),$=f.slice(O+1,Q-1).trim();if($==="")return;if($.startsWith("!")||$.startsWith("?"))return{end:Q,type:"declaration"};if($.startsWith("/"))return{end:Q,type:"close"};let q=/\/\s*$/.test($),Z=q?$.replace(/\/\s*$/,"").trim():$,B=Z.split(/[\s/>]/,1)[0]?.toLowerCase()??"",V=B.length,Y=Z.slice(V).trim(),w=q||F.has(B)?"":S(f,O,Q,B);return{attributes:k(Y),end:Q,innerHtml:w,selfClosing:q,tagName:B,type:"open"}}function S(f,O,Q,$){let q=Q,Z=1;while(q<f.length&&Z>0){let B=f.indexOf("<",q);if(B===-1)return f.slice(Q);let V=G(f,B);if(!V)return f.slice(Q);if(V.type==="open"&&V.tagName===$&&!V.selfClosing&&!F.has($))Z+=1;if(V.type==="close"){if(f.slice(B+2,V.end-1).trim().toLowerCase()===$){if(Z-=1,Z===0)return f.slice(Q,B)}}q=V.end}return f.slice(Q)}class _ extends EventTarget{nodeType;static DOCUMENT_NODE=9;static ELEMENT_NODE=1;static TEXT_NODE=3;childNodes=[];ownerDocument;parentNode=null;constructor(f,O=null){super();this.nodeType=f;this.ownerDocument=O}append(...f){for(let O of f)this.appendChild(typeof O==="string"?h(O):O)}appendChild(f){if("parentNode"in f&&f.parentNode&&"removeChild"in f.parentNode)f.parentNode.removeChild(f);return this.childNodes.push(f),f.ownerDocument=this.nodeType===_.DOCUMENT_NODE?this:this.ownerDocument,f.parentNode=this,f}removeChild(f){let O=this.childNodes.indexOf(f);if(O===-1)return f;return this.childNodes.splice(O,1),f.parentNode=null,f}replaceChildren(...f){for(let O of this.childNodes)O.parentNode=null;this.childNodes=[],this.append(...f)}get textContent(){return this.childNodes.map((f)=>f.textContent??"").join("")}set textContent(f){this.replaceChildren(f??"")}getRootNode(){let f=this;while("parentNode"in f&&f.parentNode)f=f.parentNode;return f}}class U extends _{value;constructor(f,O=z()){super(_.TEXT_NODE,O);this.value=f}get textContent(){return this.value}set textContent(f){this.value=f??""}}class H{element;constructor(f){this.element=f}add(...f){let O=new Set(this.readTokens());for(let Q of f)if(Q!=="")O.add(Q);this.writeTokens([...O])}remove(...f){let O=new Set(this.readTokens());for(let Q of f)O.delete(Q);this.writeTokens([...O])}toggle(f,O){let Q=this.contains(f);if(O??!Q)return this.add(f),!0;return this.remove(f),!1}contains(f){return this.readTokens().includes(f)}toString(){return this.value}get value(){return this.element.getAttribute("class")??""}readTokens(){return this.value.split(/\s+/).map((f)=>f.trim()).filter((f)=>f.length>0)}writeTokens(f){if(f.length===0){this.element.removeAttribute("class");return}this.element.setAttribute("class",f.join(" "))}}class R extends _{attributes=new Map;classListValue;datasetValue;fragmentHtml;fragmentText;localName;tagName;constructor(f="div",O=z()){super(_.ELEMENT_NODE,O);this.localName=f.toLowerCase(),this.tagName=this.localName.toUpperCase()}get classList(){return this.classListValue??=new H(this),this.classListValue}get dataset(){return this.datasetValue??=new Proxy({},{deleteProperty:(f,O)=>{if(typeof O!=="string")return!1;return this.removeAttribute(K(O)),!0},get:(f,O)=>{if(typeof O!=="string")return;return this.getAttribute(K(O))??void 0},getOwnPropertyDescriptor:(f,O)=>{if(typeof O!=="string")return;return{configurable:!0,enumerable:!0,value:this.getAttribute(K(O))??void 0,writable:!0}},has:(f,O)=>{return typeof O==="string"&&this.hasAttribute(K(O))},ownKeys:()=>{return this.getAttributeNames().filter((f)=>f.startsWith("data-")).map((f)=>
|
|
1
|
+
var r=((f)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(f,{get:(O,Q)=>(typeof require<"u"?require:O)[Q]}):f)(function(f){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+f+'" is not supported')});var F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(f){let O=[],Q=0;while(Q<f.length){let $=Q;if(f.startsWith("<!--",Q)){let B=f.indexOf("-->",Q+4);Q=B===-1?f.length:B+3,O.push(f.slice($,Q));continue}if(f[Q]!=="<"){let B=f.indexOf("<",Q);Q=B===-1?f.length:B,O.push(f.slice($,Q));continue}let q=G(f,Q);if(!q){O.push(f.slice($));break}if(q.type!=="open"||q.selfClosing||F.has(q.tagName)){Q=q.end,O.push(f.slice($,Q));continue}Q=q.end;let Z=1;while(Q<f.length&&Z>0){let B=f.indexOf("<",Q);if(B===-1){Q=f.length;break}let V=G(f,B);if(!V){Q=f.length;break}if(Q=V.end,V.type==="comment"||V.type==="declaration")continue;if(V.type==="open"&&!V.selfClosing&&!F.has(V.tagName)){Z+=1;continue}if(V.type==="close")Z-=1}O.push(f.slice($,Q))}return O.filter(($)=>$!=="")}function C(f,O){let Q;for(let $=O+1;$<f.length;$+=1){let q=f[$];if(Q){if(q===Q)Q=void 0;continue}if(q==='"'||q==="'"){Q=q;continue}if(q===">")return $+1}return f.length}function k(f){let O={},Q=/([:^@A-Za-z0-9_.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>/]+)))?/g;for(let $ of f.matchAll(Q)){let[,q,Z,B,V]=$;if(!q)continue;O[q]=Z??B??V??""}return O}function G(f,O){if(f.startsWith("<!--",O)){let y=f.indexOf("-->",O+4);return{end:y===-1?f.length:y+3,type:"comment"}}let Q=C(f,O),$=f.slice(O+1,Q-1).trim();if($==="")return;if($.startsWith("!")||$.startsWith("?"))return{end:Q,type:"declaration"};if($.startsWith("/"))return{end:Q,type:"close"};let q=/\/\s*$/.test($),Z=q?$.replace(/\/\s*$/,"").trim():$,B=Z.split(/[\s/>]/,1)[0]?.toLowerCase()??"",V=B.length,Y=Z.slice(V).trim(),w=q||F.has(B)?"":S(f,O,Q,B);return{attributes:k(Y),end:Q,innerHtml:w,selfClosing:q,tagName:B,type:"open"}}function S(f,O,Q,$){let q=Q,Z=1;while(q<f.length&&Z>0){let B=f.indexOf("<",q);if(B===-1)return f.slice(Q);let V=G(f,B);if(!V)return f.slice(Q);if(V.type==="open"&&V.tagName===$&&!V.selfClosing&&!F.has($))Z+=1;if(V.type==="close"){if(f.slice(B+2,V.end-1).trim().toLowerCase()===$){if(Z-=1,Z===0)return f.slice(Q,B)}}q=V.end}return f.slice(Q)}class _ extends EventTarget{nodeType;static DOCUMENT_NODE=9;static ELEMENT_NODE=1;static TEXT_NODE=3;childNodes=[];ownerDocument;parentNode=null;constructor(f,O=null){super();this.nodeType=f;this.ownerDocument=O}append(...f){for(let O of f)this.appendChild(typeof O==="string"?h(O):O)}appendChild(f){if("parentNode"in f&&f.parentNode&&"removeChild"in f.parentNode)f.parentNode.removeChild(f);return this.childNodes.push(f),f.ownerDocument=this.nodeType===_.DOCUMENT_NODE?this:this.ownerDocument,f.parentNode=this,f}removeChild(f){let O=this.childNodes.indexOf(f);if(O===-1)return f;return this.childNodes.splice(O,1),f.parentNode=null,f}replaceChildren(...f){for(let O of this.childNodes)O.parentNode=null;this.childNodes=[],this.append(...f)}get textContent(){return this.childNodes.map((f)=>f.textContent??"").join("")}set textContent(f){this.replaceChildren(f??"")}getRootNode(){let f=this;while("parentNode"in f&&f.parentNode)f=f.parentNode;return f}}class U extends _{value;constructor(f,O=z()){super(_.TEXT_NODE,O);this.value=f}get textContent(){return this.value}set textContent(f){this.value=f??""}}class H{element;constructor(f){this.element=f}add(...f){let O=new Set(this.readTokens());for(let Q of f)if(Q!=="")O.add(Q);this.writeTokens([...O])}remove(...f){let O=new Set(this.readTokens());for(let Q of f)O.delete(Q);this.writeTokens([...O])}toggle(f,O){let Q=this.contains(f);if(O??!Q)return this.add(f),!0;return this.remove(f),!1}contains(f){return this.readTokens().includes(f)}toString(){return this.value}get value(){return this.element.getAttribute("class")??""}readTokens(){return this.value.split(/\s+/).map((f)=>f.trim()).filter((f)=>f.length>0)}writeTokens(f){if(f.length===0){this.element.removeAttribute("class");return}this.element.setAttribute("class",f.join(" "))}}class R extends _{attributes=new Map;classListValue;datasetValue;fragmentHtml;fragmentText;localName;tagName;constructor(f="div",O=z()){super(_.ELEMENT_NODE,O);this.localName=f.toLowerCase(),this.tagName=this.localName.toUpperCase()}get id(){return this.getAttribute("id")??""}set id(f){if(f===""){this.removeAttribute("id");return}this.setAttribute("id",f)}get classList(){return this.classListValue??=new H(this),this.classListValue}get dataset(){return this.datasetValue??=new Proxy({},{deleteProperty:(f,O)=>{if(typeof O!=="string")return!1;return this.removeAttribute(K(O)),!0},get:(f,O)=>{if(typeof O!=="string")return;return this.getAttribute(K(O))??void 0},getOwnPropertyDescriptor:(f,O)=>{if(typeof O!=="string")return;return{configurable:!0,enumerable:!0,value:this.getAttribute(K(O))??void 0,writable:!0}},has:(f,O)=>{return typeof O==="string"&&this.hasAttribute(K(O))},ownKeys:()=>{return this.getAttributeNames().filter((f)=>f.startsWith("data-")).map((f)=>E(f.slice(5)))},set:(f,O,Q)=>{if(typeof O!=="string")return!1;return this.setAttribute(K(O),String(Q)),!0}}),this.datasetValue}hasAttribute(f){return this.attributes.has(f)}getAttribute(f){return this.attributes.get(f)??null}getAttributeNames(){return Array.from(this.attributes.keys())}setAttribute(f,O){this.fragmentHtml=void 0,this.attributes.set(f,String(O))}toggleAttribute(f,O){if(O??!this.hasAttribute(f))return this.setAttribute(f,""),!0;return this.removeAttribute(f),!1}removeAttribute(f){this.fragmentHtml=void 0,this.attributes.delete(f)}querySelector(){return null}querySelectorAll(){return[]}matches(){return!1}get outerHTML(){if(this.fragmentHtml!==void 0)return this.fragmentHtml;let f=Array.from(this.attributes.entries()).map(([O,Q])=>` ${O}="${D(Q)}"`).join("");return`<${this.localName}${f}>${this.innerHTML}</${this.localName}>`}get innerHTML(){return this.childNodes.map((f)=>v(f)).join("")}set innerHTML(f){this.fragmentHtml=void 0,this.fragmentText=void 0,this.replaceChildren(...I(f,this.ownerDocument))}get textContent(){return this.fragmentText??super.textContent??""}set textContent(f){this.fragmentHtml=void 0,this.fragmentText=f??"",super.textContent=f}setSerializedFragment(f,O,Q){this.fragmentHtml=f,this.fragmentText=O,this.attributes=new Map(Object.entries(Q)),this.replaceChildren()}}class A{bubbles;cancelable;composed;type;constructor(f,O={}){this.type=f,this.bubbles=O.bubbles??!1,this.cancelable=O.cancelable??!1,this.composed=O.composed??!1}}class P extends A{detail;constructor(f,O={}){super(f,O);this.detail=O.detail}}class j extends R{isConnected=!1;constructor(f="div",O=z()){super(f,O)}insertAdjacentHTML(f,O){this.append(...I(O,this.ownerDocument))}}class X extends j{constructor(f=z()){super("script",f)}}class b extends _{constructor(){super(_.DOCUMENT_NODE)}createElement(f){return f.toLowerCase()==="script"?new X(this):new j(f,this)}createTextNode(f){return new U(f,this)}querySelector(){return null}querySelectorAll(){return[]}}class L{definitions=new Map;define(f,O){if(this.definitions.has(f))return;this.definitions.set(f,O)}get(f){return this.definitions.get(f)}}var J,W={escape(f){return u(String(f))}};function h(f){return new U(f,z())}function z(){return globalThis.document??null}function T(){let f=globalThis,O=f.customElements;if(typeof f.Node>"u"||typeof f.Document>"u"||typeof f.Element>"u"||typeof f.HTMLElement>"u"||typeof f.document>"u"||!O||typeof O.define!=="function"||typeof O.get!=="function")return;return f.window??{CSS:f.CSS??W,CustomEvent:f.CustomEvent??P,Document:f.Document,Element:f.Element,Event:f.Event??A,EventTarget:f.EventTarget??EventTarget,HTMLScriptElement:f.HTMLScriptElement??f.HTMLElement,HTMLElement:f.HTMLElement,Node:f.Node,document:f.document,customElements:O}}function g(){let f=T();if(f)return f;return s()}function i(){return g(),{prepareHost(f,O={}){if(O.authoredContent!==void 0)f.innerHTML=O.authoredContent}}}function s(){let f=T();if(f)return f;if(J)return J;let O=new L,Q=new b,$=globalThis.Event??A,q=globalThis.CustomEvent??P,Z=b,B=globalThis.EventTarget??EventTarget;return J={CSS:globalThis.CSS??W,CustomEvent:q,Document:Z,Element:R,Event:$,EventTarget:B,HTMLScriptElement:X,HTMLElement:j,Node:_,document:Q,customElements:O},Object.assign(globalThis,{CSS:globalThis.CSS??W,CustomEvent:q,Document:Z,Element:R,Event:$,EventTarget:B,HTMLScriptElement:X,HTMLElement:j,Node:_,document:Q,customElements:O,window:J}),J}function N(f,O,Q){let $=O.tagName==="script"?new X(Q):new j(O.tagName,Q);return $.setSerializedFragment(f,p(O.innerHtml),O.attributes),$}function D(f){return f.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function p(f){return f.replace(/<!--.*?-->/gs,"").replace(/<[^>]+>/g,"")}function I(f,O=z()){return x(f).map((Q)=>{if(!Q.startsWith("<"))return new U(Q,O);let $=G(Q,0);if(!$||$.type!=="open")return new U(Q,O);return N(Q,$,O)})}function K(f){return`data-${f.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function E(f){return f.replace(/-([a-z])/g,(O,Q)=>Q.toUpperCase())}function u(f){let O="";for(let Q=0;Q<f.length;Q+=1){let $=f[Q]??"",q=$.codePointAt(0)??0;if(q===0){O+="�";continue}let Z=q>=1&&q<=31||q===127,B=Q===0&&q>=48&&q<=57,V=Q===1&&q>=48&&q<=57&&(f[0]??"")==="-",Y=Q===0&&$==="-"&&f.length===1;if(Z||B||V){O+=`\\${q.toString(16)} `;continue}if(q>=128||$==="-"||$==="_"||q>=48&&q<=57||q>=65&&q<=90||q>=97&&q<=122){O+=Y?`\\${$}`:$;continue}O+=`\\${$}`}return O}function v(f){if(f.nodeType===_.TEXT_NODE)return f.textContent??"";return"outerHTML"in f&&typeof f.outerHTML==="string"?f.outerHTML:f.textContent??""}s();
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=04ECBE60B467096F64756E2164756E21
|