@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 iR=((R)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(R,{get:(P,g)=>(typeof require<"u"?require:P)[g]}):R)(function(R){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+R+'" is not supported')});var $R=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),jR=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),mR=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function eP(R,P){HR(R,$R,P)}function Rg(R,P){HR(R,jR,P)}function Pg(R){c(R,$R)}function C(R){let P=R;c(R,jR,P[mR]??=new Set)}function HR(R,P,g){let f=R,$=Object.prototype.hasOwnProperty.call(f,P)?f[P]:void 0;if(Array.isArray($)){$.push(g);return}Object.defineProperty(f,P,{value:[g]})}function c(R,P,g,f=Object.getPrototypeOf(R)){if(!f||f===Object.prototype)return;c(R,P,g,Object.getPrototypeOf(f));let $=f[P];if(!Array.isArray($))return;for(let j of $){if(g?.has(j))continue;j(R),g?.add(j)}}function BR(R){switch(R){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function aR(R){switch(typeof R){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(R))return"array";if(Object.prototype.toString.call(R)==="[object Object]")return"object"}function lR(R){switch(R){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function tR(R){try{return JSON.parse(R)}catch{throw TypeError("Invalid JSON string")}}var nR={array(R){let P=tR(R);if(!Array.isArray(P))throw TypeError(`Expected an array but got a value of type "${typeof P}"`);return P},boolean(R){return!(R==="0"||String(R).toLowerCase()==="false")},number(R){return Number(R.replace(/_/g,""))},object(R){let P=JSON.parse(R);if(P===null||typeof P!=="object"||Array.isArray(P))throw TypeError(`expected value of type "object" but instead got value "${R}" of type "${aR(P)}"`);return P},string(R){return R}},qR={default:FR,array:QR,object:QR};function QR(R){return JSON.stringify(R)}function FR(R){return`${R}`}function JR(R,P){let g=BR(P);if(!g)throw TypeError(`[radiant-element] Unknown type "${P}"`);return nR[g](R)}function bR(R,P){let g=BR(P);if(!g)throw TypeError(`[radiant-element] Unknown type "${P}"`);return(qR[g]??qR.default??FR)(R)}function oR(R){return typeof R==="boolean"}function eR(R){return typeof R==="number"}function RP(R){return typeof R==="string"}function PP(R){return Array.isArray(R)}function gP(R){return typeof R==="object"&&!Array.isArray(R)&&R!==null}function fg(R,P){switch(R){case Boolean:return oR(P);case Number:return eR(P);case String:return RP(P);case Array:return PP(P);case Object:return gP(P);default:return!1}}var $g=(R,P,g,f)=>{if(P===Boolean){let j=R.getAttribute(g);if(j===null)return f;return j===""?!0:JR(j,P)}let $=R.getAttribute(g);return $!==null?JR($,P):f??lR(P)};import{getActiveSsrScopeValue as fP,withActiveSsrScopeValue as $P}from"@ecopages/jsx/server";var ZR=Symbol.for("@ecopages/radiant.element-ssr-runtime");function qg(){return fP(ZR)}function Z(R,P){return $P(ZR,R,P)}var WR=Symbol.for("@ecopages/radiant.controllerIdentifier");function p(R,P){R[WR]=P}function XR(R){return R[WR]}var B="data-controller",GR=Symbol.for("@ecopages/radiant.controller-registry-state");function jP(){let R=globalThis,P=R[GR];if(P)return P;let g={activeRuntimes:new Set,controllerRegistrationStrategy:"keep-current",controllerRegistry:new Map};return R[GR]=g,g}var k=jP(),F=k.controllerRegistry,W=k.activeRuntimes;function UR(R){let P=R.getAttribute(B);if(!P)return[];return P.split(/\s+/).map((g)=>g.trim()).filter((g)=>g.length>0)}function I(R,P){if(R instanceof Element&&R.hasAttribute(B))P(R);for(let g of Array.from(R.querySelectorAll(`[${B}]`)))P(g)}class KR{root;controllersByElement=new Map;observer;stopped=!1;constructor(R=document){this.root=R;this.start()}stop(){if(this.stopped)return;this.stopped=!0,this.observer?.disconnect(),this.observer=void 0;for(let[R,P]of this.controllersByElement)for(let[g]of P)this.disconnectController(R,g);W.delete(this)}reconcileRegisteredController(R){I(this.root,(P)=>{if(!UR(P).includes(R))return;this.connectController(P,R)})}replaceRegisteredController(R){for(let[P,g]of Array.from(this.controllersByElement.entries())){if(!g.has(R))continue;this.disconnectController(P,R)}this.reconcileRegisteredController(R)}start(){if(I(this.root,(P)=>{this.reconcileElement(P)}),typeof MutationObserver>"u"){W.add(this);return}this.observer=new MutationObserver((P)=>{for(let g of P){if(g.type==="attributes"&&g.target instanceof Element){this.reconcileElement(g.target);continue}for(let f of Array.from(g.removedNodes)){if(!(f instanceof Element))continue;I(f,($)=>{this.disconnectElementControllers($)})}for(let f of Array.from(g.addedNodes)){if(!(f instanceof Element))continue;I(f,($)=>{this.reconcileElement($)})}}});let R=this.root instanceof Document?this.root.documentElement:this.root;this.observer.observe(R,{attributeFilter:[B],attributes:!0,childList:!0,subtree:!0}),W.add(this)}reconcileElement(R){let P=new Set(UR(R)),g=this.controllersByElement.get(R);if(g){for(let f of g.keys())if(!P.has(f))this.disconnectController(R,f)}for(let f of P)this.connectController(R,f)}connectController(R,P){let g=F.get(P);if(!g)return;let f=this.controllersByElement.get(R);if(!f)f=new Map,this.controllersByElement.set(R,f);if(f.has(P))return;let $=new g(R);f.set(P,$),$.connect()}disconnectController(R,P){let g=this.controllersByElement.get(R);if(!g)return;let f=g.get(P);if(!f)return;if(f.disconnect(),g.delete(P),g.size===0)this.controllersByElement.delete(R)}disconnectElementControllers(R){let P=this.controllersByElement.get(R);if(!P)return;for(let g of Array.from(P.keys()))this.disconnectController(R,g)}}function HP(R,P){let g=F.get(R);if(g)return g;p(P,R),F.set(R,P);for(let f of Array.from(W))f.reconcileRegisteredController(R);return P}function Fg(R){return F.has(R)}function bg(R){return F.get(R)}function qP(R,P){if(F.get(R)===P)return P;p(P,R),F.set(R,P);for(let f of Array.from(W))f.replaceRegisteredController(R);return P}function YR(R){k.controllerRegistrationStrategy=R}function Zg(){YR("replace")}function Wg(){YR("keep-current")}function Xg(R,P){if(k.controllerRegistrationStrategy==="replace")return qP(R,P);return HP(R,P)}function Gg(R=document){return new KR(R)}function Ug(){for(let R of Array.from(W))R.stop()}var xR=Symbol.for("@ecopages/radiant.customElementTagName");function Yg(R,P){R[xR]=P}function D(R){return R[xR]}var r=Symbol.for("@ecopages/radiant.reactivePropDefinitions");function wg(R,P,g){let f=R.constructor,$=f[r]??[];if($.some((j)=>j.name===P))return;$.push({name:P,options:g}),f[r]=$}function wR(R){return(R.constructor[r]??[]).slice()}var hR=Symbol.for("@ecopages/radiant.ssr-context-provider-resolver");function AR(){return globalThis}function yR(R){AR()[hR]=R}function Ag(R){return AR()[hR]?.(R)}var h;function SR(){if(h!==void 0)return h;try{let{AsyncLocalStorage:R}=(()=>{throw new Error("Cannot require module "+"node:async_hooks");})();return h=new R,h}catch{return h=null,null}}var VR=Symbol.for("@ecopages/radiant.ssr-context-fallback-stack");function TR(){let R=globalThis;return R[VR]??=[],R[VR]}function X(R){if(R.length===0)return()=>{return};let P=new Map;for(let $ of R)P.set($.getContextKey(),$);let g=SR();if(g){let $=g.getStore()??[],j=[...$,P];return g.enterWith(j),()=>{g.enterWith($)}}let f=TR();return f.push(P),()=>{let $=f.lastIndexOf(P);if($>=0)f.splice($,1)}}function _R(R){let P=SR()?.getStore()??TR();for(let g=P.length-1;g>=0;g-=1){let f=P[g]?.get(R);if(f)return f}return}function Sg(R){let P=_R(R);if(!P)return;return P.getContext()}yR((R)=>_R(R));class i{host;constructor(R){this.host=R}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({mode:"hydrate"})}}renderHostToString(R={},P=this.getHostAttributes()){let g=this.getTagName(),f=X(this.host.getContextProviders());try{return`<${g}${QP(P)}>${this.renderHostContent(R)}</${g}>`}finally{f()}}renderHostContent(R){let P=this.host.renderViewToString(R),g=this.host.getAuthoredHydrationScriptMarkup?.()??"",f=this.host.getSlotProjectionScriptTag?.()??"";if(!(R.mode==="hydrate"||R.mode===void 0&&R.hydrate===!0))return`${P}${g}${f}`;let j=this.host.getHydrationBindings().map((H)=>H.renderHydrationScriptTag()).filter((H)=>typeof H==="string").join("");return`${P}${f}${j}`}getHostAttributes(){let R={},P=new Set;for(let g of this.host.getReactiveProperties()){let f=this.host.getPropertyValue(g.name);if(f===void 0||f===null||f===!1)continue;R[g.attribute]=String(g.converter.toAttribute(f)),P.add(g.attribute)}for(let g of this.host.getReactivePropDefinitions()){let f=g.options.attribute??g.name;if(P.has(f))continue;let $=this.host.getPropertyValue(g.name);if($===void 0||$===null||$===!1)continue;R[f]=String(bR($,g.options.type)),P.add(f)}for(let g of this.host.listAttributeNames()){let f=this.host.getAttributeValue(g);if(f!==null)R[g]=f}return R}getTagName(){let R=D(this.host.constructor);if(!R)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return R}}function QP(R){return Object.entries(R).map(([P,g])=>` ${P}="${JP(g)}"`).join("")}function JP(R){return R.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function G(R){if(BP(R))return R;return}function BP(R){return typeof R.constructor==="function"&&typeof R.getAttribute==="function"&&typeof R.getAuthoredHydrationScriptMarkup==="function"&&typeof R.getContextProviders==="function"&&typeof R.getHydrationBindings==="function"&&typeof R.getReactiveProperties==="function"&&typeof R.getSlotProjectionScriptTag==="function"&&typeof R.resolveTrackedRenderOutput==="function"&&typeof R.renderViewToString==="function"}function LR(R){let P=G(R);if(!P)throw Error("Radiant SSR runtime requires a server extraction host shape on the component.");return{constructor:P.constructor,getAuthoredHydrationScriptMarkup:()=>P.getAuthoredHydrationScriptMarkup(),getContextProviders:()=>P.getContextProviders(),getHydrationBindings:()=>P.getHydrationBindings(),getSlotProjectionScriptTag:()=>P.getSlotProjectionScriptTag(),renderViewToString:(g)=>P.renderViewToString(g),getReactiveProperties:()=>P.getReactiveProperties(),getReactivePropDefinitions:()=>wR(R),getPropertyValue:(g)=>Reflect.get(R,g),listAttributeNames:()=>P.getAttributeNames(),getAttributeValue:(g)=>P.getAttribute(g)}}import{renderToString as FP}from"@ecopages/jsx/server";import{isServerRenderHydrationActive as CR,withForcedServerCustomElementRendering as bP,withServerCustomElementRenderHook as ZP}from"@ecopages/jsx/server";var E;function IR(R){return new i(LR(R))}function z(R){return{nodeType:1,outerHTML:A(R,{mode:"hydrate"})}}function kR(R){if(y(R))return z(R);if(!O(R))return;return R.renderHost?.()??{nodeType:1,outerHTML:R.renderHostToString({mode:"hydrate"})}}function A(R,P={}){return a(()=>IR(R).renderHostToString(P,zR(R)))}function DR(R,P={}){if(y(R))return A(R,P);if(!O(R))return;return R.renderHostToString(P)}function ER(R,P){if(y(R))return z(R);if(!O(R))return;return R.renderHost?.()??{nodeType:1,outerHTML:P}}function WP(R,P={}){return a(()=>m(()=>FP(GP(R).value,P)))}function zR(R){return IR(R).getHostAttributes()}function XP(R){if(!y(R))return;return{renderHost:()=>z(R),renderHostToString:(P)=>A(R,P)}}function dg(R){return G(R)}function m(R){return bP(()=>ZP(({instance:P})=>{if(y(P))return{nodeType:1,get outerHTML(){let f=CR();return A(P,{hydrate:f,mode:f?"hydrate":"plain"})}};if(!O(P))return;let g=P;return{nodeType:1,get outerHTML(){let f=CR();return g.renderHostToString({hydrate:f,mode:f?"hydrate":"plain"})}}},R))}function GP(R){if(UP(R))return R.resolveTrackedRenderOutput();let P=G(R);if(!P)throw Error("Radiant SSR runtime requires tracked render output support on the component.");return P.resolveTrackedRenderOutput()}function y(R){if(typeof R!=="object"||R===null)return!1;return G(R)!==void 0}function O(R){if(typeof R!=="object"||R===null)return!1;return typeof R.renderHostToString==="function"}function UP(R){if(typeof R!=="object"||R===null)return!1;return typeof R.resolveTrackedRenderOutput==="function"}function U(){if(E)return E;return E={getHostAttributes:zR,renderHost:z,renderHostToString:A,resolveRenderBridge:XP,renderView:WP},E}function a(R){return Z(U(),R)}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function OR(R){let P=[],g=0;while(g<R.length){let f=g;if(R.startsWith("<!--",g)){let H=R.indexOf("-->",g+4);g=H===-1?R.length:H+3,P.push(R.slice(f,g));continue}if(R[g]!=="<"){let H=R.indexOf("<",g);g=H===-1?R.length:H,P.push(R.slice(f,g));continue}let $=V(R,g);if(!$){P.push(R.slice(f));break}if($.type!=="open"||$.selfClosing||N.has($.tagName)){g=$.end,P.push(R.slice(f,g));continue}g=$.end;let j=1;while(g<R.length&&j>0){let H=R.indexOf("<",g);if(H===-1){g=R.length;break}let q=V(R,H);if(!q){g=R.length;break}if(g=q.end,q.type==="comment"||q.type==="declaration")continue;if(q.type==="open"&&!q.selfClosing&&!N.has(q.tagName)){j+=1;continue}if(q.type==="close")j-=1}P.push(R.slice(f,g))}return P.filter((f)=>f!=="")}function KP(R,P){let g;for(let f=P+1;f<R.length;f+=1){let $=R[f];if(g){if($===g)g=void 0;continue}if($==='"'||$==="'"){g=$;continue}if($===">")return f+1}return R.length}function YP(R){let P={},g=/([:^@A-Za-z0-9_.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>/]+)))?/g;for(let f of R.matchAll(g)){let[,$,j,H,q]=f;if(!$)continue;P[$]=j??H??q??""}return P}function V(R,P){if(R.startsWith("<!--",P)){let b=R.indexOf("-->",P+4);return{end:b===-1?R.length:b+3,type:"comment"}}let g=KP(R,P),f=R.slice(P+1,g-1).trim();if(f==="")return;if(f.startsWith("!")||f.startsWith("?"))return{end:g,type:"declaration"};if(f.startsWith("/"))return{end:g,type:"close"};let $=/\/\s*$/.test(f),j=$?f.replace(/\/\s*$/,"").trim():f,H=j.split(/[\s/>]/,1)[0]?.toLowerCase()??"",q=H.length,J=j.slice(q).trim(),x=$||N.has(H)?"":xP(R,P,g,H);return{attributes:YP(J),end:g,innerHtml:x,selfClosing:$,tagName:H,type:"open"}}function xP(R,P,g,f){let $=g,j=1;while($<R.length&&j>0){let H=R.indexOf("<",$);if(H===-1)return R.slice(g);let q=V(R,H);if(!q)return R.slice(g);if(q.type==="open"&&q.tagName===f&&!q.selfClosing&&!N.has(f))j+=1;if(q.type==="close"){if(R.slice(H+2,q.end-1).trim().toLowerCase()===f){if(j-=1,j===0)return R.slice(g,H)}}$=q.end}return R.slice(g)}class Q extends EventTarget{nodeType;static DOCUMENT_NODE=9;static ELEMENT_NODE=1;static TEXT_NODE=3;childNodes=[];ownerDocument;parentNode=null;constructor(R,P=null){super();this.nodeType=R;this.ownerDocument=P}append(...R){for(let P of R)this.appendChild(typeof P==="string"?wP(P):P)}appendChild(R){if("parentNode"in R&&R.parentNode&&"removeChild"in R.parentNode)R.parentNode.removeChild(R);return this.childNodes.push(R),R.ownerDocument=this.nodeType===Q.DOCUMENT_NODE?this:this.ownerDocument,R.parentNode=this,R}removeChild(R){let P=this.childNodes.indexOf(R);if(P===-1)return R;return this.childNodes.splice(P,1),R.parentNode=null,R}replaceChildren(...R){for(let P of this.childNodes)P.parentNode=null;this.childNodes=[],this.append(...R)}get textContent(){return this.childNodes.map((R)=>R.textContent??"").join("")}set textContent(R){this.replaceChildren(R??"")}getRootNode(){let R=this;while("parentNode"in R&&R.parentNode)R=R.parentNode;return R}}class _ extends Q{value;constructor(R,P=Y()){super(Q.TEXT_NODE,P);this.value=R}get textContent(){return this.value}set textContent(R){this.value=R??""}}class NR{element;constructor(R){this.element=R}add(...R){let P=new Set(this.readTokens());for(let g of R)if(g!=="")P.add(g);this.writeTokens([...P])}remove(...R){let P=new Set(this.readTokens());for(let g of R)P.delete(g);this.writeTokens([...P])}toggle(R,P){let g=this.contains(R);if(P??!g)return this.add(R),!0;return this.remove(R),!1}contains(R){return this.readTokens().includes(R)}toString(){return this.value}get value(){return this.element.getAttribute("class")??""}readTokens(){return this.value.split(/\s+/).map((R)=>R.trim()).filter((R)=>R.length>0)}writeTokens(R){if(R.length===0){this.element.removeAttribute("class");return}this.element.setAttribute("class",R.join(" "))}}class M extends Q{attributes=new Map;classListValue;datasetValue;fragmentHtml;fragmentText;localName;tagName;constructor(R="div",P=Y()){super(Q.ELEMENT_NODE,P);this.localName=R.toLowerCase(),this.tagName=this.localName.toUpperCase()}get classList(){return this.classListValue??=new NR(this),this.classListValue}get dataset(){return this.datasetValue??=new Proxy({},{deleteProperty:(R,P)=>{if(typeof P!=="string")return!1;return this.removeAttribute(T(P)),!0},get:(R,P)=>{if(typeof P!=="string")return;return this.getAttribute(T(P))??void 0},getOwnPropertyDescriptor:(R,P)=>{if(typeof P!=="string")return;return{configurable:!0,enumerable:!0,value:this.getAttribute(T(P))??void 0,writable:!0}},has:(R,P)=>{return typeof P==="string"&&this.hasAttribute(T(P))},ownKeys:()=>{return this.getAttributeNames().filter((R)=>R.startsWith("data-")).map((R)=>SP(R.slice(5)))},set:(R,P,g)=>{if(typeof P!=="string")return!1;return this.setAttribute(T(P),String(g)),!0}}),this.datasetValue}hasAttribute(R){return this.attributes.has(R)}getAttribute(R){return this.attributes.get(R)??null}getAttributeNames(){return Array.from(this.attributes.keys())}setAttribute(R,P){this.fragmentHtml=void 0,this.attributes.set(R,String(P))}toggleAttribute(R,P){if(P??!this.hasAttribute(R))return this.setAttribute(R,""),!0;return this.removeAttribute(R),!1}removeAttribute(R){this.fragmentHtml=void 0,this.attributes.delete(R)}querySelector(){return null}querySelectorAll(){return[]}matches(){return!1}get outerHTML(){if(this.fragmentHtml!==void 0)return this.fragmentHtml;let R=Array.from(this.attributes.entries()).map(([P,g])=>` ${P}="${yP(g)}"`).join("");return`<${this.localName}${R}>${this.innerHTML}</${this.localName}>`}get innerHTML(){return this.childNodes.map((R)=>_P(R)).join("")}set innerHTML(R){this.fragmentHtml=void 0,this.fragmentText=void 0,this.replaceChildren(...uR(R,this.ownerDocument))}get textContent(){return this.fragmentText??super.textContent??""}set textContent(R){this.fragmentHtml=void 0,this.fragmentText=R??"",super.textContent=R}setSerializedFragment(R,P,g){this.fragmentHtml=R,this.fragmentText=P,this.attributes=new Map(Object.entries(g)),this.replaceChildren()}}class v{bubbles;cancelable;composed;type;constructor(R,P={}){this.type=R,this.bubbles=P.bubbles??!1,this.cancelable=P.cancelable??!1,this.composed=P.composed??!1}}class n extends v{detail;constructor(R,P={}){super(R,P);this.detail=P.detail}}class K extends M{isConnected=!1;constructor(R="div",P=Y()){super(R,P)}insertAdjacentHTML(R,P){this.append(...uR(P,this.ownerDocument))}}class L extends K{constructor(R=Y()){super("script",R)}}class l extends Q{constructor(){super(Q.DOCUMENT_NODE)}createElement(R){return R.toLowerCase()==="script"?new L(this):new K(R,this)}createTextNode(R){return new _(R,this)}querySelector(){return null}querySelectorAll(){return[]}}class MR{definitions=new Map;define(R,P){if(this.definitions.has(R))return;this.definitions.set(R,P)}get(R){return this.definitions.get(R)}}var S,t={escape(R){return TP(String(R))}};function wP(R){return new _(R,Y())}function Y(){return globalThis.document??null}function vR(){let R=globalThis,P=R.customElements;if(typeof R.Node>"u"||typeof R.Document>"u"||typeof R.Element>"u"||typeof R.HTMLElement>"u"||typeof R.document>"u"||!P||typeof P.define!=="function"||typeof P.get!=="function")return;return R.window??{CSS:R.CSS??t,CustomEvent:R.CustomEvent??n,Document:R.Document,Element:R.Element,Event:R.Event??v,EventTarget:R.EventTarget??EventTarget,HTMLScriptElement:R.HTMLScriptElement??R.HTMLElement,HTMLElement:R.HTMLElement,Node:R.Node,document:R.document,customElements:P}}function o(){let R=vR();if(R)return R;return hP()}function sR(){return o(),{prepareHost(R,P={}){if(P.authoredContent!==void 0)R.innerHTML=P.authoredContent}}}function hP(){let R=vR();if(R)return R;if(S)return S;let P=new MR,g=new l,f=globalThis.Event??v,$=globalThis.CustomEvent??n,j=l,H=globalThis.EventTarget??EventTarget;return S={CSS:globalThis.CSS??t,CustomEvent:$,Document:j,Element:M,Event:f,EventTarget:H,HTMLScriptElement:L,HTMLElement:K,Node:Q,document:g,customElements:P},Object.assign(globalThis,{CSS:globalThis.CSS??t,CustomEvent:$,Document:j,Element:M,Event:f,EventTarget:H,HTMLScriptElement:L,HTMLElement:K,Node:Q,document:g,customElements:P,window:S}),S}function AP(R,P,g){let f=P.tagName==="script"?new L(g):new K(P.tagName,g);return f.setSerializedFragment(R,VP(P.innerHtml),P.attributes),f}function yP(R){return R.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function VP(R){return R.replace(/<!--.*?-->/gs,"").replace(/<[^>]+>/g,"")}function uR(R,P=Y()){return OR(R).map((g)=>{if(!g.startsWith("<"))return new _(g,P);let f=V(g,0);if(!f||f.type!=="open")return new _(g,P);return AP(g,f,P)})}function T(R){return`data-${R.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function SP(R){return R.replace(/-([a-z])/g,(P,g)=>g.toUpperCase())}function TP(R){let P="";for(let g=0;g<R.length;g+=1){let f=R[g]??"",$=f.codePointAt(0)??0;if($===0){P+="�";continue}let j=$>=1&&$<=31||$===127,H=g===0&&$>=48&&$<=57,q=g===1&&$>=48&&$<=57&&(R[0]??"")==="-",J=g===0&&f==="-"&&R.length===1;if(j||H||q){P+=`\\${$.toString(16)} `;continue}if($>=128||f==="-"||f==="_"||$>=48&&$<=57||$>=65&&$<=90||$>=97&&$<=122){P+=J?`\\${f}`:f;continue}P+=`\\${f}`}return P}function _P(R){if(R.nodeType===Q.TEXT_NODE)return R.textContent??"";return"outerHTML"in R&&typeof R.outerHTML==="string"?R.outerHTML:R.textContent??""}function LP(R,P="hydrate"){return{kind:"script-module",src:R,stage:P}}function g1(R){return{kind:"modulepreload",href:R}}function f1(R,P){return P?{kind:"style",href:R,media:P}:{kind:"style",href:R}}async function $1(R,P){return(await s(u(R,P))).markup}async function j1(R,P){return s(u(R,P))}async function H1(R,P){return e(await s(u(R,P)))}async function q1(R,P){return DP(await s(u(R,P)))}async function s(R){return Z(U(),async()=>{let P=R.environment??sR(),g=X(kP(R.ssrContext));try{let f="component"in R?R.component:await R.load(),$=new f;C($),IP(P,$,R.authoredContent,R.prepareHost),R.initialize?.($);let j=R.clientModuleSrc??await R.resolveClientModuleSrc?.(f),H=R.assets??await R.resolveAssets?.(f)??[],q=RR(H,j),J=PR(q)??j,x=R.tagName??MP(f),b=(R.now??EP)().toISOString(),w=gR(R.renderOptions),fR=DR($,w)??NP($,w),rR=CP($,fR);return{markup:fR,metadata:{assets:q,clientModuleUrl:J,generatedAt:b,tagName:x},preview:rR}}finally{g()}})}function CP(R,P){return ER(R,P)??kR(R)??R.renderHost?.()??{nodeType:1,outerHTML:P}}function IP(R,P,g,f){if(!OP(P)){if(g===void 0&&f===void 0)return;throw Error(`${P.constructor.name} cannot prepare SSR host content because it does not expose an innerHTML host surface.`)}R.prepareHost(P,{authoredContent:g}),f?.(P,R)}function kP(R){if(!R||R.length===0)return[];return R.map((P)=>({getContext:()=>P.value,getContextKey:()=>P.context,renderHydrationScript:()=>{return},renderHydrationScriptTag:()=>{return}}))}function e(R){if("metadata"in R)return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,tagName:R.metadata.tagName};let{preview:P,...g}=R;return g}function DP(R){return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,preview:R.preview,tagName:R.metadata.tagName}}function EP(){return new Date}function zP(R){if(!R)return[];return[LP(R)]}function RR(R,P){if(!P)return R;if(R.some((g)=>g.kind==="script-module"&&g.src===P))return R;return[...zP(P),...R]}function PR(R){return R.find((P)=>P.kind==="script-module")?.src}function u(R,P){if(typeof R==="function")return{...P,component:R};return R}function gR(R){if(R?.mode!==void 0||R?.hydrate!==void 0)return R;return{...R,mode:"hydrate"}}function OP(R){return"innerHTML"in R}function NP(R,P){if(typeof R.renderHostToString==="function")return R.renderHostToString(P);throw Error(`${R.constructor.name} cannot be server-rendered without a registered Radiant SSR host or renderHostToString().`)}function MP(R){let P=D(R);if(!P)throw Error(`${R.name} is missing @customElement metadata.`);return P}import{renderToString as vP}from"@ecopages/jsx/server";async function Y1(R,P){return(await d(R,P)).markup}async function x1(R,P){return d(R,P)}async function w1(R,P){return e(await d(R,P))}async function h1(R,P){return sP(await d(R,P))}async function d(R,P){return Z(U(),async()=>{let g=dP(P.tagName),f=cP(g,pP(R,P)),$=new R(f);C($);try{P.initialize?.($),$.runWithSsrLifecycle(()=>$.connect());let j=P.clientModuleSrc??await P.resolveClientModuleSrc?.(R),H=P.assets??await P.resolveAssets?.(R)??[],q=RR(H,j),J=PR(q)??j,x=(P.now??uP)().toISOString(),b=gR(P.renderOptions),w=aP($,g,b);return{markup:w,metadata:{assets:q,clientModuleUrl:J,generatedAt:x,tagName:g},preview:{nodeType:1,outerHTML:w}}}finally{$.disconnect()}})}function sP(R){return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,preview:R.preview,tagName:R.metadata.tagName}}function uP(){return new Date}function dP(R){let P=R.trim().toLowerCase();if(!P)throw Error("Controller SSR host tagName is required.");return P}function cP(R,P){let f=o().document.createElement(R);for(let[$,j]of Object.entries(P)){if(j===void 0||j===null||j===!1)continue;f.setAttribute($,j===!0?"":String(j))}return f}function pP(R,P){let g={},f=P.host,$=iP(P.attributes?.class,f?.class,f?.classes);if($!==void 0)g.class=$;dR(g,"data",f?.data),dR(g,"aria",f?.aria),rP(g,P.attributes);let j=XR(R);if(j&&g[B]==null)g[B]=j;return g}function dR(R,P,g){if(!pR(g))return;for(let[f,$]of Object.entries(g))R[`${P}-${mP(f)}`]=$}function rP(R,P){if(!P)return;for(let[g,f]of Object.entries(P))R[g]=f}function iP(...R){let P=[];for(let g of R)cR(P,g);return P.length===0?void 0:P.join(" ")}function cR(R,P){if(P===void 0||P===null||P===!1||P===!0)return;if(typeof P==="string"){if(P!=="")R.push(P);return}if(typeof P==="number"||typeof P==="bigint"){R.push(String(P));return}if(Array.isArray(P)){for(let g of P)cR(R,g);return}if(!pR(P))return;for(let[g,f]of Object.entries(P))if(f)R.push(g)}function pR(R){return Object.prototype.toString.call(R)==="[object Object]"}function mP(R){return R.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function aP(R,P,g){let f=X(R.getSsrContextProviders());try{let $=m(()=>vP(R.render(),g)),H=g.mode==="hydrate"||g.mode===void 0&&g.hydrate===!0?R.getSsrHydrationBindings().map((q)=>q.renderHydrationScriptTag()).filter((q)=>typeof q==="string").join(""):"";return`<${P}${lP(R.host)}>${$}${H}</${P}>`}finally{f()}}function lP(R){return R.getAttributeNames().map((P)=>tP(P,R.getAttribute(P))).join("")}function tP(R,P){if(P==="")return` ${R}`;return` ${R}="${nP(P??"")}"`}function nP(R){return R.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}export{h1 as renderControllerWithPreview,Y1 as renderControllerToString,w1 as renderControllerToPayload,x1 as renderController};
|
|
1
|
+
var o1=((R)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(R,{get:(P,j)=>(typeof require<"u"?require:P)[j]}):R)(function(R){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+R+'" is not supported')});var $1=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),q1=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),t1=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function FP(R,P){F1(R,$1,P)}function JP(R,P){F1(R,q1,P)}function ZP(R){p(R,$1)}function z(R){let P=R;p(R,q1,P[t1]??=new Set)}function F1(R,P,j){let Q=R,$=Object.prototype.hasOwnProperty.call(Q,P)?Q[P]:void 0;if(Array.isArray($)){$.push(j);return}Object.defineProperty(Q,P,{value:[j]})}function p(R,P,j,Q=Object.getPrototypeOf(R)){if(!Q||Q===Object.prototype)return;p(R,P,j,Object.getPrototypeOf(Q));let $=Q[P];if(!Array.isArray($))return;for(let q of $){if(j?.has(q))continue;q(R),j?.add(q)}}function W1(R){switch(R){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function e1(R){switch(typeof R){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(R))return"array";if(Object.prototype.toString.call(R)==="[object Object]")return"object"}function RR(R){switch(R){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function PR(R){try{return JSON.parse(R)}catch{throw TypeError("Invalid JSON string")}}var jR={array(R){let P=PR(R);if(!Array.isArray(P))throw TypeError(`Expected an array but got a value of type "${typeof P}"`);return P},boolean(R){return!(R==="0"||String(R).toLowerCase()==="false")},number(R){return Number(R.replace(/_/g,""))},object(R){let P=JSON.parse(R);if(P===null||typeof P!=="object"||Array.isArray(P))throw TypeError(`expected value of type "object" but instead got value "${R}" of type "${e1(P)}"`);return P},string(R){return R}},J1={default:X1,array:Z1,object:Z1};function Z1(R){return JSON.stringify(R)}function X1(R){return`${R}`}function B1(R,P){let j=W1(P);if(!j)throw TypeError(`[radiant-element] Unknown type "${P}"`);return jR[j](R)}function G1(R,P){let j=W1(P);if(!j)throw TypeError(`[radiant-element] Unknown type "${P}"`);return(J1[j]??J1.default??X1)(R)}function QR(R){return typeof R==="boolean"}function $R(R){return typeof R==="number"}function qR(R){return typeof R==="string"}function FR(R){return Array.isArray(R)}function JR(R){return typeof R==="object"&&!Array.isArray(R)&&R!==null}function WP(R,P){switch(R){case Boolean:return QR(P);case Number:return $R(P);case String:return qR(P);case Array:return FR(P);case Object:return JR(P);default:return!1}}var XP=(R,P,j,Q)=>{if(P===Boolean){let q=R.getAttribute(j);if(q===null)return Q;return q===""?!0:B1(q,P)}let $=R.getAttribute(j);return $!==null?B1($,P):Q??RR(P)};import{getActiveSsrScopeValue as ZR,withActiveSsrScopeValue as BR}from"@ecopages/jsx/server";var U1=Symbol.for("@ecopages/radiant.element-ssr-runtime");function KP(){return ZR(U1)}function U(R,P){return BR(U1,R,P)}var K1=Symbol.for("@ecopages/radiant.controllerIdentifier");function s(R,P){R[K1]=P}function Y1(R){return R[K1]}var W="data-controller",H1=Symbol.for("@ecopages/radiant.controller-registry-state");function WR(){let R=globalThis,P=R[H1];if(P)return P;let j={activeRuntimes:new Set,controllerRegistrationStrategy:"keep-current",controllerRegistry:new Map};return R[H1]=j,j}var O=WR(),X=O.controllerRegistry,K=O.activeRuntimes;function w1(R){let P=R.getAttribute(W);if(!P)return[];return P.split(/\s+/).map((j)=>j.trim()).filter((j)=>j.length>0)}function S(R,P){if(R instanceof Element&&R.hasAttribute(W))P(R);for(let j of Array.from(R.querySelectorAll(`[${W}]`)))P(j)}class f1{root;controllersByElement=new Map;observer;stopped=!1;constructor(R=document){this.root=R;this.start()}stop(){if(this.stopped)return;this.stopped=!0,this.observer?.disconnect(),this.observer=void 0;for(let[R,P]of this.controllersByElement)for(let[j]of P)this.disconnectController(R,j);K.delete(this)}reconcileRegisteredController(R){S(this.root,(P)=>{if(!w1(P).includes(R))return;this.connectController(P,R)})}replaceRegisteredController(R){for(let[P,j]of Array.from(this.controllersByElement.entries())){if(!j.has(R))continue;this.disconnectController(P,R)}this.reconcileRegisteredController(R)}start(){if(S(this.root,(P)=>{this.reconcileElement(P)}),typeof MutationObserver>"u"){K.add(this);return}this.observer=new MutationObserver((P)=>{for(let j of P){if(j.type==="attributes"&&j.target instanceof Element){this.reconcileElement(j.target);continue}for(let Q of Array.from(j.removedNodes)){if(!(Q instanceof Element))continue;S(Q,($)=>{this.disconnectElementControllers($)})}for(let Q of Array.from(j.addedNodes)){if(!(Q instanceof Element))continue;S(Q,($)=>{this.reconcileElement($)})}}});let R=this.root instanceof Document?this.root.documentElement:this.root;this.observer.observe(R,{attributeFilter:[W],attributes:!0,childList:!0,subtree:!0}),K.add(this)}reconcileElement(R){let P=new Set(w1(R)),j=this.controllersByElement.get(R);if(j){for(let Q of j.keys())if(!P.has(Q))this.disconnectController(R,Q)}for(let Q of P)this.connectController(R,Q)}connectController(R,P){let j=X.get(P);if(!j)return;let Q=this.controllersByElement.get(R);if(!Q)Q=new Map,this.controllersByElement.set(R,Q);if(Q.has(P))return;let $=new j(R);Q.set(P,$),$.connect()}disconnectController(R,P){let j=this.controllersByElement.get(R);if(!j)return;let Q=j.get(P);if(!Q)return;if(Q.disconnect(),j.delete(P),j.size===0)this.controllersByElement.delete(R)}disconnectElementControllers(R){let P=this.controllersByElement.get(R);if(!P)return;for(let j of Array.from(P.keys()))this.disconnectController(R,j)}}function XR(R,P){let j=X.get(R);if(j)return j;s(P,R),X.set(R,P);for(let Q of Array.from(K))Q.reconcileRegisteredController(R);return P}function fP(R){return X.has(R)}function _P(R){return X.get(R)}function GR(R,P){if(X.get(R)===P)return P;s(P,R),X.set(R,P);for(let Q of Array.from(K))Q.replaceRegisteredController(R);return P}function _1(R){O.controllerRegistrationStrategy=R}function xP(){_1("replace")}function IP(){_1("keep-current")}function LP(R,P){if(O.controllerRegistrationStrategy==="replace")return GR(R,P);return XR(R,P)}function VP(R=document){return new f1(R)}function AP(){for(let R of Array.from(K))R.stop()}var x1=Symbol.for("@ecopages/radiant.customElementTagName");function DP(R,P){R[x1]=P}function b(R){return R[x1]}var m=Symbol.for("@ecopages/radiant.reactivePropDefinitions");function CP(R,P,j){let Q=R.constructor,$=Q[m]??[];if($.some((q)=>q.name===P))return;$.push({name:P,options:j}),Q[m]=$}function I1(R){return(R.constructor[m]??[]).slice()}function L1(R){let P={},j=new Set;return UR(R,P,j),KR(R,P,j),YR(R,P),P}function V1(R){return Object.entries(R).map(([P,j])=>` ${P}="${HR(j)}"`).join("")}function UR(R,P,j){for(let Q of R.getReactiveProperties()){let $=R.getPropertyValue(Q.name);if($===void 0||$===null||$===!1)continue;P[Q.attribute]=String(Q.converter.toAttribute($)),j.add(Q.attribute)}}function KR(R,P,j){for(let Q of R.getReactivePropDefinitions()){let $=Q.options.attribute??Q.name;if(j.has($))continue;let q=R.getPropertyValue(Q.name);if(q===void 0||q===null||q===!1)continue;P[$]=String(G1(q,Q.options.type)),j.add($)}}function YR(R,P){for(let j of R.listAttributeNames()){let Q=R.getAttributeValue(j);if(Q!==null)P[j]=Q}}function HR(R){return R.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var A1=Symbol.for("@ecopages/radiant.ssr-context-provider-resolver");function T1(){return globalThis}function D1(R){T1()[A1]=R}function OP(R){return T1()[A1]?.(R)}var V;function C1(){if(V!==void 0)return V;try{let{AsyncLocalStorage:R}=(()=>{throw new Error("Cannot require module "+"node:async_hooks");})();return V=new R,V}catch{return V=null,null}}var k1=Symbol.for("@ecopages/radiant.ssr-context-fallback-stack");function E1(){let R=globalThis;return R[k1]??=[],R[k1]}function Y(R){if(R.length===0)return()=>{return};let P=new Map;for(let $ of R)P.set($.getContextKey(),$);let j=C1();if(j){let $=j.getStore()??[],q=[...$,P];return j.enterWith(q),()=>{j.enterWith($)}}let Q=E1();return Q.push(P),()=>{let $=Q.lastIndexOf(P);if($>=0)Q.splice($,1)}}function z1(R){let P=C1()?.getStore()??E1();for(let j=P.length-1;j>=0;j-=1){let Q=P[j]?.get(R);if(Q)return Q}return}function yP(R){let P=z1(R);if(!P)return;return P.getContext()}D1((R)=>z1(R));function S1(R,P){if(!P)return`${R.hostContent}${R.authoredHydrationMarkup}${R.slotProjectionScript}`;return`${R.hostContent}${R.slotProjectionScript}${R.hydrationScripts}`}class a{host;constructor(R){this.host=R}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({mode:"hydrate"})}}renderHostToString(R={},P=this.getHostAttributes()){let j=this.getTagName(),Q=Y(this.host.getContextProviders());try{return`<${j}${V1(P)}>${this.renderHostContent(R)}</${j}>`}finally{Q()}}renderHostContent(R){let P=R.mode==="hydrate"||R.mode===void 0&&R.hydrate===!0,j=P?this.host.getHydrationBindings().map((Q)=>Q.renderHydrationScriptTag()).filter((Q)=>typeof Q==="string").join(""):"";return S1({hostContent:this.host.renderViewToString(R),authoredHydrationMarkup:this.host.getAuthoredHydrationScriptMarkup?.()??"",slotProjectionScript:this.host.getSlotProjectionScriptTag?.()??"",hydrationScripts:j},P)}getHostAttributes(){return L1(this.host)}getTagName(){let R=b(this.host.constructor);if(!R)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return R}}function H(R){if(wR(R))return R;return}function wR(R){return typeof R.constructor==="function"&&typeof R.getAttribute==="function"&&typeof R.getAuthoredHydrationScriptMarkup==="function"&&typeof R.getContextProviders==="function"&&typeof R.getHydrationBindings==="function"&&typeof R.getReactiveProperties==="function"&&typeof R.getSlotProjectionScriptTag==="function"&&typeof R.resolveTrackedRenderOutput==="function"&&typeof R.renderViewToString==="function"}function O1(R){let P=H(R);if(!P)throw Error("Radiant SSR runtime requires a server extraction host shape on the component.");return{constructor:P.constructor,getAuthoredHydrationScriptMarkup:()=>P.getAuthoredHydrationScriptMarkup(),getContextProviders:()=>P.getContextProviders(),getHydrationBindings:()=>P.getHydrationBindings(),getSlotProjectionScriptTag:()=>P.getSlotProjectionScriptTag(),renderViewToString:(j)=>P.renderViewToString(j),getReactiveProperties:()=>P.getReactiveProperties(),getReactivePropDefinitions:()=>I1(R),getPropertyValue:(j)=>Reflect.get(R,j),listAttributeNames:()=>P.getAttributeNames(),getAttributeValue:(j)=>P.getAttribute(j)}}import{renderToString as fR}from"@ecopages/jsx/server";import{createServerHydrationBindingState as b1,isServerRenderHydrationActive as g1,withForcedServerCustomElementRendering as _R,withServerCustomElementRenderHook as xR,withServerHydrationBindingState as y1}from"@ecopages/jsx/server";var g;function N1(R){return new a(O1(R))}function y(R){return{nodeType:1,outerHTML:w(R,{mode:"hydrate"})}}function h1(R){if(A(R))return y(R);if(!N(R))return;return R.renderHost?.()??{nodeType:1,outerHTML:R.renderHostToString({mode:"hydrate"})}}function w(R,P={}){return r(()=>N1(R).renderHostToString(P,u1(R)))}function M1(R,P={}){if(A(R))return w(R,P);if(!N(R))return;return R.renderHostToString(P)}function v1(R,P){if(A(R))return y(R);if(!N(R))return;return R.renderHost?.()??{nodeType:1,outerHTML:P}}function IR(R,P={}){return r(()=>l(()=>fR(VR(R).value,P)))}function u1(R){return N1(R).getHostAttributes()}function LR(R){if(!A(R))return;return{renderHost:()=>y(R),renderHostToString:(P)=>w(R,P)}}function eP(R){return H(R)}function l(R){return _R(()=>xR(({instance:P})=>{if(A(P))return{nodeType:1,get outerHTML(){let Q=g1(),$={hydrate:Q,mode:Q?"hydrate":"plain"};if(!Q)return w(P,$);return y1(b1(),()=>w(P,$))}};if(!N(P))return;let j=P;return{nodeType:1,get outerHTML(){let Q=g1();if(!Q)return j.renderHostToString({hydrate:Q,mode:Q?"hydrate":"plain"});return y1(b1(),()=>j.renderHostToString({hydrate:Q,mode:Q?"hydrate":"plain"}))}}},R))}function VR(R){if(AR(R))return R.resolveTrackedRenderOutput();let P=H(R);if(!P)throw Error("Radiant SSR runtime requires tracked render output support on the component.");return P.resolveTrackedRenderOutput()}function A(R){if(typeof R!=="object"||R===null)return!1;return H(R)!==void 0}function N(R){if(typeof R!=="object"||R===null)return!1;return typeof R.renderHostToString==="function"}function AR(R){if(typeof R!=="object"||R===null)return!1;return typeof R.resolveTrackedRenderOutput==="function"}function f(){if(g)return g;return g={getHostAttributes:u1,renderHost:y,renderHostToString:w,resolveRenderBridge:LR,renderView:IR},g}function r(R){return U(f(),R)}var h=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function c1(R){let P=[],j=0;while(j<R.length){let Q=j;if(R.startsWith("<!--",j)){let J=R.indexOf("-->",j+4);j=J===-1?R.length:J+3,P.push(R.slice(Q,j));continue}if(R[j]!=="<"){let J=R.indexOf("<",j);j=J===-1?R.length:J,P.push(R.slice(Q,j));continue}let $=T(R,j);if(!$){P.push(R.slice(Q));break}if($.type!=="open"||$.selfClosing||h.has($.tagName)){j=$.end,P.push(R.slice(Q,j));continue}j=$.end;let q=1;while(j<R.length&&q>0){let J=R.indexOf("<",j);if(J===-1){j=R.length;break}let F=T(R,J);if(!F){j=R.length;break}if(j=F.end,F.type==="comment"||F.type==="declaration")continue;if(F.type==="open"&&!F.selfClosing&&!h.has(F.tagName)){q+=1;continue}if(F.type==="close")q-=1}P.push(R.slice(Q,j))}return P.filter((Q)=>Q!=="")}function TR(R,P){let j;for(let Q=P+1;Q<R.length;Q+=1){let $=R[Q];if(j){if($===j)j=void 0;continue}if($==='"'||$==="'"){j=$;continue}if($===">")return Q+1}return R.length}function DR(R){let P={},j=/([:^@A-Za-z0-9_.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>/]+)))?/g;for(let Q of R.matchAll(j)){let[,$,q,J,F]=Q;if(!$)continue;P[$]=q??J??F??""}return P}function T(R,P){if(R.startsWith("<!--",P)){let G=R.indexOf("-->",P+4);return{end:G===-1?R.length:G+3,type:"comment"}}let j=TR(R,P),Q=R.slice(P+1,j-1).trim();if(Q==="")return;if(Q.startsWith("!")||Q.startsWith("?"))return{end:j,type:"declaration"};if(Q.startsWith("/"))return{end:j,type:"close"};let $=/\/\s*$/.test(Q),q=$?Q.replace(/\/\s*$/,"").trim():Q,J=q.split(/[\s/>]/,1)[0]?.toLowerCase()??"",F=J.length,B=q.slice(F).trim(),I=$||h.has(J)?"":kR(R,P,j,J);return{attributes:DR(B),end:j,innerHtml:I,selfClosing:$,tagName:J,type:"open"}}function kR(R,P,j,Q){let $=j,q=1;while($<R.length&&q>0){let J=R.indexOf("<",$);if(J===-1)return R.slice(j);let F=T(R,J);if(!F)return R.slice(j);if(F.type==="open"&&F.tagName===Q&&!F.selfClosing&&!h.has(Q))q+=1;if(F.type==="close"){if(R.slice(J+2,F.end-1).trim().toLowerCase()===Q){if(q-=1,q===0)return R.slice(j,J)}}$=F.end}return R.slice(j)}class Z extends EventTarget{nodeType;static DOCUMENT_NODE=9;static ELEMENT_NODE=1;static TEXT_NODE=3;childNodes=[];ownerDocument;parentNode=null;constructor(R,P=null){super();this.nodeType=R;this.ownerDocument=P}append(...R){for(let P of R)this.appendChild(typeof P==="string"?CR(P):P)}appendChild(R){if("parentNode"in R&&R.parentNode&&"removeChild"in R.parentNode)R.parentNode.removeChild(R);return this.childNodes.push(R),R.ownerDocument=this.nodeType===Z.DOCUMENT_NODE?this:this.ownerDocument,R.parentNode=this,R}removeChild(R){let P=this.childNodes.indexOf(R);if(P===-1)return R;return this.childNodes.splice(P,1),R.parentNode=null,R}replaceChildren(...R){for(let P of this.childNodes)P.parentNode=null;this.childNodes=[],this.append(...R)}get textContent(){return this.childNodes.map((R)=>R.textContent??"").join("")}set textContent(R){this.replaceChildren(R??"")}getRootNode(){let R=this;while("parentNode"in R&&R.parentNode)R=R.parentNode;return R}}class C extends Z{value;constructor(R,P=x()){super(Z.TEXT_NODE,P);this.value=R}get textContent(){return this.value}set textContent(R){this.value=R??""}}class d1{element;constructor(R){this.element=R}add(...R){let P=new Set(this.readTokens());for(let j of R)if(j!=="")P.add(j);this.writeTokens([...P])}remove(...R){let P=new Set(this.readTokens());for(let j of R)P.delete(j);this.writeTokens([...P])}toggle(R,P){let j=this.contains(R);if(P??!j)return this.add(R),!0;return this.remove(R),!1}contains(R){return this.readTokens().includes(R)}toString(){return this.value}get value(){return this.element.getAttribute("class")??""}readTokens(){return this.value.split(/\s+/).map((R)=>R.trim()).filter((R)=>R.length>0)}writeTokens(R){if(R.length===0){this.element.removeAttribute("class");return}this.element.setAttribute("class",R.join(" "))}}class M extends Z{attributes=new Map;classListValue;datasetValue;fragmentHtml;fragmentText;localName;tagName;constructor(R="div",P=x()){super(Z.ELEMENT_NODE,P);this.localName=R.toLowerCase(),this.tagName=this.localName.toUpperCase()}get id(){return this.getAttribute("id")??""}set id(R){if(R===""){this.removeAttribute("id");return}this.setAttribute("id",R)}get classList(){return this.classListValue??=new d1(this),this.classListValue}get dataset(){return this.datasetValue??=new Proxy({},{deleteProperty:(R,P)=>{if(typeof P!=="string")return!1;return this.removeAttribute(k(P)),!0},get:(R,P)=>{if(typeof P!=="string")return;return this.getAttribute(k(P))??void 0},getOwnPropertyDescriptor:(R,P)=>{if(typeof P!=="string")return;return{configurable:!0,enumerable:!0,value:this.getAttribute(k(P))??void 0,writable:!0}},has:(R,P)=>{return typeof P==="string"&&this.hasAttribute(k(P))},ownKeys:()=>{return this.getAttributeNames().filter((R)=>R.startsWith("data-")).map((R)=>bR(R.slice(5)))},set:(R,P,j)=>{if(typeof P!=="string")return!1;return this.setAttribute(k(P),String(j)),!0}}),this.datasetValue}hasAttribute(R){return this.attributes.has(R)}getAttribute(R){return this.attributes.get(R)??null}getAttributeNames(){return Array.from(this.attributes.keys())}setAttribute(R,P){this.fragmentHtml=void 0,this.attributes.set(R,String(P))}toggleAttribute(R,P){if(P??!this.hasAttribute(R))return this.setAttribute(R,""),!0;return this.removeAttribute(R),!1}removeAttribute(R){this.fragmentHtml=void 0,this.attributes.delete(R)}querySelector(){return null}querySelectorAll(){return[]}matches(){return!1}get outerHTML(){if(this.fragmentHtml!==void 0)return this.fragmentHtml;let R=Array.from(this.attributes.entries()).map(([P,j])=>` ${P}="${SR(j)}"`).join("");return`<${this.localName}${R}>${this.innerHTML}</${this.localName}>`}get innerHTML(){return this.childNodes.map((R)=>yR(R)).join("")}set innerHTML(R){this.fragmentHtml=void 0,this.fragmentText=void 0,this.replaceChildren(...a1(R,this.ownerDocument))}get textContent(){return this.fragmentText??super.textContent??""}set textContent(R){this.fragmentHtml=void 0,this.fragmentText=R??"",super.textContent=R}setSerializedFragment(R,P,j){this.fragmentHtml=R,this.fragmentText=P,this.attributes=new Map(Object.entries(j)),this.replaceChildren()}}class v{bubbles;cancelable;composed;type;constructor(R,P={}){this.type=R,this.bubbles=P.bubbles??!1,this.cancelable=P.cancelable??!1,this.composed=P.composed??!1}}class o extends v{detail;constructor(R,P={}){super(R,P);this.detail=P.detail}}class _ extends M{isConnected=!1;constructor(R="div",P=x()){super(R,P)}insertAdjacentHTML(R,P){this.append(...a1(P,this.ownerDocument))}}class E extends _{constructor(R=x()){super("script",R)}}class i extends Z{constructor(){super(Z.DOCUMENT_NODE)}createElement(R){return R.toLowerCase()==="script"?new E(this):new _(R,this)}createTextNode(R){return new C(R,this)}querySelector(){return null}querySelectorAll(){return[]}}class p1{definitions=new Map;define(R,P){if(this.definitions.has(R))return;this.definitions.set(R,P)}get(R){return this.definitions.get(R)}}var D,n={escape(R){return gR(String(R))}};function CR(R){return new C(R,x())}function x(){return globalThis.document??null}function s1(){let R=globalThis,P=R.customElements;if(typeof R.Node>"u"||typeof R.Document>"u"||typeof R.Element>"u"||typeof R.HTMLElement>"u"||typeof R.document>"u"||!P||typeof P.define!=="function"||typeof P.get!=="function")return;return R.window??{CSS:R.CSS??n,CustomEvent:R.CustomEvent??o,Document:R.Document,Element:R.Element,Event:R.Event??v,EventTarget:R.EventTarget??EventTarget,HTMLScriptElement:R.HTMLScriptElement??R.HTMLElement,HTMLElement:R.HTMLElement,Node:R.Node,document:R.document,customElements:P}}function t(){let R=s1();if(R)return R;return ER()}function m1(){return t(),{prepareHost(R,P={}){if(P.authoredContent!==void 0)R.innerHTML=P.authoredContent}}}function ER(){let R=s1();if(R)return R;if(D)return D;let P=new p1,j=new i,Q=globalThis.Event??v,$=globalThis.CustomEvent??o,q=i,J=globalThis.EventTarget??EventTarget;return D={CSS:globalThis.CSS??n,CustomEvent:$,Document:q,Element:M,Event:Q,EventTarget:J,HTMLScriptElement:E,HTMLElement:_,Node:Z,document:j,customElements:P},Object.assign(globalThis,{CSS:globalThis.CSS??n,CustomEvent:$,Document:q,Element:M,Event:Q,EventTarget:J,HTMLScriptElement:E,HTMLElement:_,Node:Z,document:j,customElements:P,window:D}),D}function zR(R,P,j){let Q=P.tagName==="script"?new E(j):new _(P.tagName,j);return Q.setSerializedFragment(R,OR(P.innerHtml),P.attributes),Q}function SR(R){return R.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function OR(R){return R.replace(/<!--.*?-->/gs,"").replace(/<[^>]+>/g,"")}function a1(R,P=x()){return c1(R).map((j)=>{if(!j.startsWith("<"))return new C(j,P);let Q=T(j,0);if(!Q||Q.type!=="open")return new C(j,P);return zR(j,Q,P)})}function k(R){return`data-${R.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function bR(R){return R.replace(/-([a-z])/g,(P,j)=>j.toUpperCase())}function gR(R){let P="";for(let j=0;j<R.length;j+=1){let Q=R[j]??"",$=Q.codePointAt(0)??0;if($===0){P+="�";continue}let q=$>=1&&$<=31||$===127,J=j===0&&$>=48&&$<=57,F=j===1&&$>=48&&$<=57&&(R[0]??"")==="-",B=j===0&&Q==="-"&&R.length===1;if(q||J||F){P+=`\\${$.toString(16)} `;continue}if($>=128||Q==="-"||Q==="_"||$>=48&&$<=57||$>=65&&$<=90||$>=97&&$<=122){P+=B?`\\${Q}`:Q;continue}P+=`\\${Q}`}return P}function yR(R){if(R.nodeType===Z.TEXT_NODE)return R.textContent??"";return"outerHTML"in R&&typeof R.outerHTML==="string"?R.outerHTML:R.textContent??""}function NR(R,P="hydrate"){return{kind:"script-module",src:R,stage:P}}function U0(R){return{kind:"modulepreload",href:R}}function K0(R,P){return P?{kind:"style",href:R,media:P}:{kind:"style",href:R}}async function Y0(R,P){return(await u(c(R,P))).markup}async function H0(R,P){return u(c(R,P))}async function w0(R,P){return e(await u(c(R,P)))}async function f0(R,P){return uR(await u(c(R,P)))}async function u(R){return U(f(),async()=>{let P=R.environment??m1(),j=Y(vR(R.ssrContext));try{let Q="component"in R?R.component:await R.load(),$=new Q;z($),MR(P,$,R.authoredContent,R.prepareHost),R.initialize?.($);let q=R.clientModuleSrc??await R.resolveClientModuleSrc?.(Q),J=R.assets??await R.resolveAssets?.(Q)??[],F=R1(J,q),B=P1(F)??q,I=R.tagName??mR(Q),G=(R.now??cR)().toISOString(),L=j1(R.renderOptions),Q1=M1($,L)??sR($,L),n1=hR($,Q1);return{markup:Q1,metadata:{assets:F,clientModuleUrl:B,generatedAt:G,tagName:I},preview:n1}}finally{j()}})}function hR(R,P){return v1(R,P)??h1(R)??R.renderHost?.()??{nodeType:1,outerHTML:P}}function MR(R,P,j,Q){if(!pR(P)){if(j===void 0&&Q===void 0)return;throw Error(`${P.constructor.name} cannot prepare SSR host content because it does not expose an innerHTML host surface.`)}R.prepareHost(P,{authoredContent:j}),Q?.(P,R)}function vR(R){if(!R||R.length===0)return[];return R.map((P)=>({getContext:()=>P.value,getContextKey:()=>P.context,renderHydrationScript:()=>{return},renderHydrationScriptTag:()=>{return}}))}function e(R){if("metadata"in R)return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,tagName:R.metadata.tagName};let{preview:P,...j}=R;return j}function uR(R){return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,preview:R.preview,tagName:R.metadata.tagName}}function cR(){return new Date}function dR(R){if(!R)return[];return[NR(R)]}function R1(R,P){if(!P)return R;if(R.some((j)=>j.kind==="script-module"&&j.src===P))return R;return[...dR(P),...R]}function P1(R){return R.find((P)=>P.kind==="script-module")?.src}function c(R,P){if(typeof R==="function")return{...P,component:R};return R}function j1(R){if(R?.mode!==void 0||R?.hydrate!==void 0)return R;return{...R,mode:"hydrate"}}function pR(R){return"innerHTML"in R}function sR(R,P){if(typeof R.renderHostToString==="function")return R.renderHostToString(P);throw Error(`${R.constructor.name} cannot be server-rendered without a registered Radiant SSR host or renderHostToString().`)}function mR(R){let P=b(R);if(!P)throw Error(`${R.name} is missing @customElement metadata.`);return P}import{renderToString as aR}from"@ecopages/jsx/server";async function z0(R,P){return(await d(R,P)).markup}async function S0(R,P){return d(R,P)}async function O0(R,P){return e(await d(R,P))}async function b0(R,P){return lR(await d(R,P))}async function d(R,P){return U(f(),async()=>{let j=iR(P.tagName),Q=nR(j,oR(R,P)),$=new R(Q);z($);try{P.initialize?.($),$.runWithSsrLifecycle(()=>$.connect());let q=P.clientModuleSrc??await P.resolveClientModuleSrc?.(R),J=P.assets??await P.resolveAssets?.(R)??[],F=R1(J,q),B=P1(F)??q,I=(P.now??rR)().toISOString(),G=j1(P.renderOptions),L=PP($,j,G);return{markup:L,metadata:{assets:F,clientModuleUrl:B,generatedAt:I,tagName:j},preview:{nodeType:1,outerHTML:L}}}finally{$.disconnect()}})}function lR(R){return{assets:R.metadata.assets,clientModuleSrc:R.metadata.clientModuleUrl,generatedAt:R.metadata.generatedAt,markup:R.markup,preview:R.preview,tagName:R.metadata.tagName}}function rR(){return new Date}function iR(R){let P=R.trim().toLowerCase();if(!P)throw Error("Controller SSR host tagName is required.");return P}function nR(R,P){let Q=t().document.createElement(R);for(let[$,q]of Object.entries(P)){if(q===void 0||q===null||q===!1)continue;Q.setAttribute($,q===!0?"":String(q))}return Q}function oR(R,P){let j={},Q=P.host,$=eR(P.attributes?.class,Q?.class,Q?.classes);if($!==void 0)j.class=$;l1(j,"data",Q?.data),l1(j,"aria",Q?.aria),tR(j,P.attributes);let q=Y1(R);if(q&&j[W]==null)j[W]=q;return j}function l1(R,P,j){if(!i1(j))return;for(let[Q,$]of Object.entries(j))R[`${P}-${RP(Q)}`]=$}function tR(R,P){if(!P)return;for(let[j,Q]of Object.entries(P))R[j]=Q}function eR(...R){let P=[];for(let j of R)r1(P,j);return P.length===0?void 0:P.join(" ")}function r1(R,P){if(P===void 0||P===null||P===!1||P===!0)return;if(typeof P==="string"){if(P!=="")R.push(P);return}if(typeof P==="number"||typeof P==="bigint"){R.push(String(P));return}if(Array.isArray(P)){for(let j of P)r1(R,j);return}if(!i1(P))return;for(let[j,Q]of Object.entries(P))if(Q)R.push(j)}function i1(R){return Object.prototype.toString.call(R)==="[object Object]"}function RP(R){return R.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function PP(R,P,j){let Q=Y(R.getSsrContextProviders());try{let $=l(()=>aR(R.render(),j)),J=j.mode==="hydrate"||j.mode===void 0&&j.hydrate===!0?R.getSsrHydrationBindings().map((F)=>F.renderHydrationScriptTag()).filter((F)=>typeof F==="string").join(""):"";return`<${P}${jP(R.host)}>${$}${J}</${P}>`}finally{Q()}}function jP(R){return R.getAttributeNames().map((P)=>QP(P,R.getAttribute(P))).join("")}function QP(R,P){if(P==="")return` ${R}`;return` ${R}="${$P(P??"")}"`}function $P(R){return R.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}export{b0 as renderControllerWithPreview,z0 as renderControllerToString,O0 as renderControllerToPayload,S0 as renderController};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=6AED500EA3C2DA1E64756E2164756E21
|