@ecopages/lit 0.2.0-beta.31 → 0.2.0-beta.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/lit",
3
- "version": "0.2.0-beta.31",
3
+ "version": "0.2.0-beta.32",
4
4
  "description": "Ecopages lit integration",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -39,7 +39,7 @@
39
39
  "directory": "packages/integrations/lit"
40
40
  },
41
41
  "peerDependencies": {
42
- "@ecopages/core": "0.2.0-beta.31",
42
+ "@ecopages/core": "0.2.0-beta.32",
43
43
  "@lit-labs/ssr": "^3.3.0",
44
44
  "@lit-labs/ssr-client": "^1.1.7",
45
45
  "lit": "^3.2.1"
package/src/console.js CHANGED
@@ -1,9 +1,15 @@
1
+ "use strict";
1
2
  const originalConsoleWarn = console.warn;
3
+ /**
4
+ * Suppresses the warning about CustomElementRegistry already being defined in ssr-dom-shim by lit
5
+ * https://github.com/lit/lit/blob/bd881370b83d366f7654dd510731242a68949a20/packages/labs/ssr-dom-shim/src/index.ts#L140
6
+ * Complete Error Log:
7
+ * 'CustomElementRegistry' already has "lit-counter" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
8
+ * Make sure to test your application with a production build as repeat registrations will throw in production.
9
+ */
2
10
  console.warn = (...messages) => {
3
- if (messages.some(
4
- (message) => typeof message === "string" && message.includes("'CustomElementRegistry' already has")
5
- )) {
6
- return;
7
- }
8
- originalConsoleWarn.apply(console, messages);
11
+ if (messages.some((message) => typeof message === 'string' && message.includes("'CustomElementRegistry' already has"))) {
12
+ return;
13
+ }
14
+ originalConsoleWarn.apply(console, messages);
9
15
  };
package/src/dom-shim.js CHANGED
@@ -1,13 +1,14 @@
1
- import { installWindowOnGlobal } from "@lit-labs/ssr/lib/dom-shim.js";
2
- import "@lit-labs/ssr/lib/install-global-dom-shim.js";
3
- if (typeof globalThis.document?.createTreeWalker !== "function") {
4
- if (typeof globalThis.window === "undefined") {
5
- installWindowOnGlobal();
6
- } else {
7
- Object.defineProperty(globalThis.document, "createTreeWalker", {
8
- configurable: true,
9
- writable: true,
10
- value: () => ({})
11
- });
12
- }
1
+ import { installWindowOnGlobal } from '@lit-labs/ssr/lib/dom-shim.js';
2
+ import '@lit-labs/ssr/lib/install-global-dom-shim.js';
3
+ if (typeof globalThis.document?.createTreeWalker !== 'function') {
4
+ if (typeof globalThis.window === 'undefined') {
5
+ installWindowOnGlobal();
6
+ }
7
+ else {
8
+ Object.defineProperty(globalThis.document, 'createTreeWalker', {
9
+ configurable: true,
10
+ writable: true,
11
+ value: () => ({}),
12
+ });
13
+ }
13
14
  }
@@ -1,4 +1 @@
1
- const litElementHydrateScript = 'var k=globalThis,y=k.trustedTypes,p=y?y.createPolicy("lit-html",{createHTML:(q)=>q}):void 0;var P=`lit$${Math.random().toFixed(9).slice(2)}$`,v="?"+P,Kq=`<${v}>`,x=document,C=()=>x.createComment(""),S=(q)=>q===null||typeof q!="object"&&typeof q!="function",L=Array.isArray,h=(q)=>L(q)||typeof q?.[Symbol.iterator]=="function";var U=/<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g,m=/-->/g,a=/>/g,$=/>|[ \\t\\n\\f\\r](?:([^\\s"\'>=\\/]+)([ \\t\\n\\f\\r]*=[ \\t\\n\\f\\r]*(?:[^ \\t\\n\\f\\r"\'\\`<>=]|("|\')|))|$)/g,c=/\'/g,l=/"/g,r=/^(?:script|style|textarea|title)$/i,M=(q)=>(D,...F)=>({_$litType$:q,strings:D,values:F}),Aq=M(1),Pq=M(2),Vq=M(3),V=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),n=new WeakMap,w=x.createTreeWalker(x,129);function o(q,D){if(!L(q)||!q.hasOwnProperty("raw"))throw Error("invalid template strings array");return p!==void 0?p.createHTML(D):D}var e=(q,D)=>{let F=q.length-1,J=[],G,O=D===2?"<svg>":D===3?"<math>":"",K=U;for(let W=0;W<F;W++){let Q=q[W],Y,X,b=-1,A=0;while(A<Q.length&&(K.lastIndex=A,X=K.exec(Q),X!==null))A=K.lastIndex,K===U?X[1]==="!--"?K=m:X[1]!==void 0?K=a:X[2]!==void 0?(r.test(X[2])&&(G=RegExp("</"+X[2],"g")),K=$):X[3]!==void 0&&(K=$):K===$?X[0]===">"?(K=G??U,b=-1):X[1]===void 0?b=-2:(b=K.lastIndex-X[2].length,Y=X[1],K=X[3]===void 0?$:X[3]===\'"\'?l:c):K===l||K===c?K=$:K===m||K===a?K=U:(K=$,G=void 0);const _=K===$&&q[W+1].startsWith("/>")?" ":"";O+=K===U?Q+Kq:b>=0?(J.push(Y),Q.slice(0,b)+"$lit$"+Q.slice(b)+P+_):Q+P+(b===-2?W:_)}return[o(q,O+(q[F]||"<?>")+(D===2?"</svg>":D===3?"</math>":"")),J]};class g{constructor({strings:q,_$litType$:D},F){let J;this.parts=[];let G=0,O=0,K=q.length-1,W=this.parts,[Q,Y]=e(q,D);if(this.el=g.createElement(Q,F),w.currentNode=this.el.content,D===2||D===3){const X=this.el.content.firstChild;X.replaceWith(...X.childNodes)}while((J=w.nextNode())!==null&&W.length<K){if(J.nodeType===1){if(J.hasAttributes())for(const X of J.getAttributeNames())if(X.endsWith("$lit$")){const b=Y[O++],A=J.getAttribute(X).split(P),_=/([.?@])?(.*)/.exec(b);W.push({type:1,index:G,name:_[2],strings:A,ctor:_[1]==="."?R:_[1]==="?"?E:_[1]==="@"?d:I}),J.removeAttribute(X)}else X.startsWith(P)&&(W.push({type:6,index:G}),J.removeAttribute(X));if(r.test(J.tagName)){const X=J.textContent.split(P),b=X.length-1;if(b>0){J.textContent=y?y.emptyScript:"";for(let A=0;A<b;A++)J.append(X[A],C()),w.nextNode(),W.push({type:2,index:++G});J.append(X[b],C())}}}else if(J.nodeType===8)if(J.data===v)W.push({type:2,index:G});else{let X=-1;while((X=J.data.indexOf(P,X+1))!==-1)W.push({type:7,index:G}),X+=P.length-1}G++}}static createElement(q,D){const F=x.createElement("template");return F.innerHTML=q,F}}function z(q,D,F=q,J){if(D===V)return D;let G=J!==void 0?F._$Co?.[J]:F._$Cl,O=S(D)?void 0:D._$litDirective$;return G?.constructor!==O&&(G?._$AO?.(!1),O===void 0?G=void 0:(G=new O(q),G._$AT(q,F,J)),J!==void 0?(F._$Co??=[])[J]=G:F._$Cl=G),G!==void 0&&(D=z(q,G._$AS(q,D.values),G,J)),D}class j{constructor(q,D){this._$AV=[],this._$AN=void 0,this._$AD=q,this._$AM=D}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(q){const{el:{content:D},parts:F}=this._$AD,J=(q?.creationScope??x).importNode(D,!0);w.currentNode=J;let G=w.nextNode(),O=0,K=0,W=F[0];while(W!==void 0){if(O===W.index){let Q;W.type===2?Q=new H(G,G.nextSibling,this,q):W.type===1?Q=new W.ctor(G,W.name,W.strings,this,q):W.type===6&&(Q=new f(G,this,q)),this._$AV.push(Q),W=F[++K]}O!==W?.index&&(G=w.nextNode(),O++)}return w.currentNode=x,J}p(q){let D=0;for(const F of this._$AV)F!==void 0&&(F.strings!==void 0?(F._$AI(q,F,D),D+=F.strings.length-2):F._$AI(q[D])),D++}}class H{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(q,D,F,J){this.type=2,this._$AH=B,this._$AN=void 0,this._$AA=q,this._$AB=D,this._$AM=F,this.options=J,this._$Cv=J?.isConnected??!0}get parentNode(){let q=this._$AA.parentNode,D=this._$AM;return D!==void 0&&q?.nodeType===11&&(q=D.parentNode),q}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(q,D=this){q=z(this,q,D),S(q)?q===B||q==null||q===""?(this._$AH!==B&&this._$AR(),this._$AH=B):q!==this._$AH&&q!==V&&this._(q):q._$litType$!==void 0?this.$(q):q.nodeType!==void 0?this.T(q):h(q)?this.k(q):this._(q)}O(q){return this._$AA.parentNode.insertBefore(q,this._$AB)}T(q){this._$AH!==q&&(this._$AR(),this._$AH=this.O(q))}_(q){this._$AH!==B&&S(this._$AH)?this._$AA.nextSibling.data=q:this.T(x.createTextNode(q)),this._$AH=q}$(q){const{values:D,_$litType$:F}=q,J=typeof F=="number"?this._$AC(q):(F.el===void 0&&(F.el=g.createElement(o(F.h,F.h[0]),this.options)),F);if(this._$AH?._$AD===J)this._$AH.p(D);else{const G=new j(J,this),O=G.u(this.options);G.p(D),this.T(O),this._$AH=G}}_$AC(q){let D=n.get(q.strings);return D===void 0&&n.set(q.strings,D=new g(q)),D}k(q){L(this._$AH)||(this._$AH=[],this._$AR());let D=this._$AH,F,J=0;for(const G of q)J===D.length?D.push(F=new H(this.O(C()),this.O(C()),this,this.options)):F=D[J],F._$AI(G),J++;J<D.length&&(this._$AR(F&&F._$AB.nextSibling,J),D.length=J)}_$AR(q=this._$AA.nextSibling,D){for(this._$AP?.(!1,!0,D);q&&q!==this._$AB;){const F=q.nextSibling;q.remove(),q=F}}setConnected(q){this._$AM===void 0&&(this._$Cv=q,this._$AP?.(q))}}class I{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(q,D,F,J,G){this.type=1,this._$AH=B,this._$AN=void 0,this.element=q,this.name=D,this._$AM=J,this.options=G,F.length>2||F[0]!==""||F[1]!==""?(this._$AH=Array(F.length-1).fill(new String),this.strings=F):this._$AH=B}_$AI(q,D=this,F,J){let G=this.strings,O=!1;if(G===void 0)q=z(this,q,D,0),O=!S(q)||q!==this._$AH&&q!==V,O&&(this._$AH=q);else{let K=q,W,Q;for(q=G[0],W=0;W<G.length-1;W++)Q=z(this,K[F+W],D,W),Q===V&&(Q=this._$AH[W]),O||=!S(Q)||Q!==this._$AH[W],Q===B?q=B:q!==B&&(q+=(Q??"")+G[W+1]),this._$AH[W]=Q}O&&!J&&this.j(q)}j(q){q===B?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,q??"")}}class R extends I{constructor(){super(...arguments),this.type=3}j(q){this.element[this.name]=q===B?void 0:q}}class E extends I{constructor(){super(...arguments),this.type=4}j(q){this.element.toggleAttribute(this.name,!!q&&q!==B)}}class d extends I{constructor(q,D,F,J,G){super(q,D,F,J,G),this.type=5}_$AI(q,D=this){if((q=z(this,q,D,0)??B)===V)return;const F=this._$AH,J=q===B&&F!==B||q.capture!==F.capture||q.once!==F.once||q.passive!==F.passive,G=q!==B&&(F===B||J);J&&this.element.removeEventListener(this.name,this,F),G&&this.element.addEventListener(this.name,this,q),this._$AH=q}handleEvent(q){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,q):this._$AH.handleEvent(q)}}class f{constructor(q,D,F){this.element=q,this.type=6,this._$AN=void 0,this._$AM=D,this.options=F}get _$AU(){return this._$AM._$AU}_$AI(q){z(this,q)}}var Z={M:"$lit$",P,A:v,C:1,L:e,R:j,D:h,V:z,I:H,H:I,N:E,U:d,B:R,F:f},Oq=k.litHtmlPolyfillSupport;Oq?.(g,H),(k.litHtmlVersions??=[]).push("3.2.1");var i=(q,D,F)=>{let J=F?.renderBefore??D,G=J._$litPart$;if(G===void 0){const O=F?.renderBefore??null;J._$litPart$=G=new H(D.insertBefore(C(),O),O,void 0,F??{})}return G._$AI(q),G};var u=null,s={boundAttributeSuffix:Z.M,marker:Z.P,markerMatch:Z.A,HTML_RESULT:Z.C,getTemplateHtml:Z.L,overrideDirectiveResolve:(q,D)=>class extends q{_$AS(F,J){return D(this,J)}},patchDirectiveResolve:(q,D)=>{if(q.prototype._$AS!==D){u??=q.prototype._$AS.name;for(let F=q.prototype;F!==Object.prototype;F=Object.getPrototypeOf(F))if(F.hasOwnProperty(u))return void(F[u]=D);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(q,D){q._$litDirective$=D},getAttributePartCommittedValue:(q,D,F)=>{let J=V;return q.j=(G)=>J=G,q._$AI(D,q,F),J},connectedDisconnectable:(q)=>({...q,_$AU:!0}),resolveDirective:Z.V,AttributePart:Z.H,PropertyPart:Z.B,BooleanAttributePart:Z.N,EventPart:Z.U,ElementPart:Z.F,TemplateInstance:Z.R,isIterable:Z.D,ChildPart:Z.I};var T={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6};var t=(q)=>q===null||typeof q!="object"&&typeof q!="function";var qq=(q,D)=>D===void 0?q?._$litType$!==void 0:q?._$litType$===D,Dq=(q)=>q?._$litType$?.h!=null;var Fq=(q)=>q.strings===void 0;var{TemplateInstance:Qq,isIterable:Wq,resolveDirective:Gq,ChildPart:N,ElementPart:Xq}=s,Jq=(q,D,F={})=>{if(D._$litPart$!==void 0)throw Error("container already contains a live render");let J,G,O,K=[],W=document.createTreeWalker(D,NodeFilter.SHOW_COMMENT),Q;while((Q=W.nextNode())!==null){const Y=Q.data;if(Y.startsWith("lit-part")){if(K.length===0&&J!==void 0)throw Error(`There must be only one root part per container. Found a part marker (${Q}) when we already have a root part marker (${G})`);O=Yq(q,Q,K,F),J===void 0&&(J=O),G??=Q}else if(Y.startsWith("lit-node"))Zq(Q,K,F);else if(Y.startsWith("/lit-part")){if(K.length===1&&O!==J)throw Error("internal error");O=Bq(Q,O,K)}}if(J===void 0){const Y=D instanceof ShadowRoot?"{container.host.localName}\'s shadow root":D instanceof DocumentFragment?"DocumentFragment":D.localName;console.error(`There should be exactly one root part in a render container, but we didn\'t find any in ${Y}.`)}D._$litPart$=J},Yq=(q,D,F,J)=>{let G,O;if(F.length===0)O=new N(D,null,void 0,J),G=q;else{const K=F[F.length-1];if(K.type==="template-instance")O=new N(D,null,K.instance,J),K.instance._$AV.push(O),G=K.result.values[K.instancePartIndex++],K.templatePartIndex++;else if(K.type==="iterable"){O=new N(D,null,K.part,J);const W=K.iterator.next();if(W.done)throw G=void 0,K.done=!0,Error("Unhandled shorter than expected iterable");G=W.value,K.part._$AH.push(O)}else O=new N(D,null,K.part,J)}if(G=Gq(O,G),G===V)F.push({part:O,type:"leaf"});else if(t(G))F.push({part:O,type:"leaf"}),O._$AH=G;else if(qq(G)){if(Dq(G))throw Error("compiled templates are not supported");const K="lit-part "+bq(G);if(D.data!==K)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const W=N.prototype._$AC(G),Q=new Qq(W,O);F.push({type:"template-instance",instance:Q,part:O,templatePartIndex:0,instancePartIndex:0,result:G}),O._$AH=Q}}else Wq(G)?(F.push({part:O,type:"iterable",value:G,iterator:G[Symbol.iterator](),done:!1}),O._$AH=[]):(F.push({part:O,type:"leaf"}),O._$AH=G??"");return O},Bq=(q,D,F)=>{if(D===void 0)throw Error("unbalanced part marker");D._$AB=q;const J=F.pop();if(J.type==="iterable"&&!J.iterator.next().done)throw Error("unexpected longer than expected iterable");if(F.length>0)return F[F.length-1].part},Zq=(q,D,F)=>{const J=/lit-node (\\d+)/.exec(q.data),G=Number.parseInt(J[1]),O=q.nextElementSibling;if(O===null)throw Error("could not find node for attribute parts");O.removeAttribute("defer-hydration");const K=D[D.length-1];if(K.type!=="template-instance")throw Error("Hydration value mismatch: Primitive found where TemplateResult expected. This usually occurs due to conditional rendering that resulted in a different value or template being rendered between the server and client.");{const W=K.instance;for(;;){const Q=W._$AD.parts[K.templatePartIndex];if(Q===void 0||Q.type!==T.ATTRIBUTE&&Q.type!==T.ELEMENT||Q.index!==G)break;if(Q.type===T.ATTRIBUTE){const Y=new Q.ctor(O,Q.name,Q.strings,K.instance,F),X=Fq(Y)?K.result.values[K.instancePartIndex]:K.result.values,b=!(Y.type===T.EVENT||Y.type===T.PROPERTY);Y._$AI(X,Y,K.instancePartIndex,b),K.instancePartIndex+=Q.strings.length-1,W._$AV.push(Y)}else{const Y=new Xq(O,K.instance,F);Gq(Y,K.result.values[K.instancePartIndex++]),W._$AV.push(Y)}K.templatePartIndex++}}},bq=(q)=>{const D=new Uint32Array(2).fill(5381);for(const J of q.strings)for(let G=0;G<J.length;G++)D[G%2]=33*D[G%2]^J.charCodeAt(G);const F=String.fromCharCode(...new Uint8Array(D.buffer));return btoa(F)};globalThis.litElementHydrateSupport=({LitElement:q})=>{const D=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(q),"observedAttributes").get;Object.defineProperty(q,"observedAttributes",{get(){return[...D.call(this),"defer-hydration"]}});const F=q.prototype.attributeChangedCallback;q.prototype.attributeChangedCallback=function(K,W,Q){K==="defer-hydration"&&Q===null&&J.call(this),F.call(this,K,W,Q)};const J=q.prototype.connectedCallback;q.prototype.connectedCallback=function(){this.hasAttribute("defer-hydration")||J.call(this)};const G=q.prototype.createRenderRoot;q.prototype.createRenderRoot=function(){return this.shadowRoot?(this._$AG=!0,this.shadowRoot):G.call(this)};const O=Object.getPrototypeOf(q.prototype).update;q.prototype.update=function(K){const W=this.render();if(O.call(this,K),this._$AG){this._$AG=!1;for(let Q=0;Q<this.attributes.length;Q++){const Y=this.attributes[Q];if(Y.name.startsWith("hydrate-internals-")){const X=Y.name.slice(18);this.removeAttribute(X),this.removeAttribute(Y.name)}}Jq(W,this.renderRoot,this.renderOptions)}else i(W,this.renderRoot,this.renderOptions)}};';
2
- export {
3
- litElementHydrateScript
4
- };
1
+ export const litElementHydrateScript = 'var k=globalThis,y=k.trustedTypes,p=y?y.createPolicy("lit-html",{createHTML:(q)=>q}):void 0;var P=`lit$${Math.random().toFixed(9).slice(2)}$`,v="?"+P,Kq=`<${v}>`,x=document,C=()=>x.createComment(""),S=(q)=>q===null||typeof q!="object"&&typeof q!="function",L=Array.isArray,h=(q)=>L(q)||typeof q?.[Symbol.iterator]=="function";var U=/<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g,m=/-->/g,a=/>/g,$=/>|[ \\t\\n\\f\\r](?:([^\\s"\'>=\\/]+)([ \\t\\n\\f\\r]*=[ \\t\\n\\f\\r]*(?:[^ \\t\\n\\f\\r"\'\\`<>=]|("|\')|))|$)/g,c=/\'/g,l=/"/g,r=/^(?:script|style|textarea|title)$/i,M=(q)=>(D,...F)=>({_$litType$:q,strings:D,values:F}),Aq=M(1),Pq=M(2),Vq=M(3),V=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),n=new WeakMap,w=x.createTreeWalker(x,129);function o(q,D){if(!L(q)||!q.hasOwnProperty("raw"))throw Error("invalid template strings array");return p!==void 0?p.createHTML(D):D}var e=(q,D)=>{let F=q.length-1,J=[],G,O=D===2?"<svg>":D===3?"<math>":"",K=U;for(let W=0;W<F;W++){let Q=q[W],Y,X,b=-1,A=0;while(A<Q.length&&(K.lastIndex=A,X=K.exec(Q),X!==null))A=K.lastIndex,K===U?X[1]==="!--"?K=m:X[1]!==void 0?K=a:X[2]!==void 0?(r.test(X[2])&&(G=RegExp("</"+X[2],"g")),K=$):X[3]!==void 0&&(K=$):K===$?X[0]===">"?(K=G??U,b=-1):X[1]===void 0?b=-2:(b=K.lastIndex-X[2].length,Y=X[1],K=X[3]===void 0?$:X[3]===\'"\'?l:c):K===l||K===c?K=$:K===m||K===a?K=U:(K=$,G=void 0);const _=K===$&&q[W+1].startsWith("/>")?" ":"";O+=K===U?Q+Kq:b>=0?(J.push(Y),Q.slice(0,b)+"$lit$"+Q.slice(b)+P+_):Q+P+(b===-2?W:_)}return[o(q,O+(q[F]||"<?>")+(D===2?"</svg>":D===3?"</math>":"")),J]};class g{constructor({strings:q,_$litType$:D},F){let J;this.parts=[];let G=0,O=0,K=q.length-1,W=this.parts,[Q,Y]=e(q,D);if(this.el=g.createElement(Q,F),w.currentNode=this.el.content,D===2||D===3){const X=this.el.content.firstChild;X.replaceWith(...X.childNodes)}while((J=w.nextNode())!==null&&W.length<K){if(J.nodeType===1){if(J.hasAttributes())for(const X of J.getAttributeNames())if(X.endsWith("$lit$")){const b=Y[O++],A=J.getAttribute(X).split(P),_=/([.?@])?(.*)/.exec(b);W.push({type:1,index:G,name:_[2],strings:A,ctor:_[1]==="."?R:_[1]==="?"?E:_[1]==="@"?d:I}),J.removeAttribute(X)}else X.startsWith(P)&&(W.push({type:6,index:G}),J.removeAttribute(X));if(r.test(J.tagName)){const X=J.textContent.split(P),b=X.length-1;if(b>0){J.textContent=y?y.emptyScript:"";for(let A=0;A<b;A++)J.append(X[A],C()),w.nextNode(),W.push({type:2,index:++G});J.append(X[b],C())}}}else if(J.nodeType===8)if(J.data===v)W.push({type:2,index:G});else{let X=-1;while((X=J.data.indexOf(P,X+1))!==-1)W.push({type:7,index:G}),X+=P.length-1}G++}}static createElement(q,D){const F=x.createElement("template");return F.innerHTML=q,F}}function z(q,D,F=q,J){if(D===V)return D;let G=J!==void 0?F._$Co?.[J]:F._$Cl,O=S(D)?void 0:D._$litDirective$;return G?.constructor!==O&&(G?._$AO?.(!1),O===void 0?G=void 0:(G=new O(q),G._$AT(q,F,J)),J!==void 0?(F._$Co??=[])[J]=G:F._$Cl=G),G!==void 0&&(D=z(q,G._$AS(q,D.values),G,J)),D}class j{constructor(q,D){this._$AV=[],this._$AN=void 0,this._$AD=q,this._$AM=D}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(q){const{el:{content:D},parts:F}=this._$AD,J=(q?.creationScope??x).importNode(D,!0);w.currentNode=J;let G=w.nextNode(),O=0,K=0,W=F[0];while(W!==void 0){if(O===W.index){let Q;W.type===2?Q=new H(G,G.nextSibling,this,q):W.type===1?Q=new W.ctor(G,W.name,W.strings,this,q):W.type===6&&(Q=new f(G,this,q)),this._$AV.push(Q),W=F[++K]}O!==W?.index&&(G=w.nextNode(),O++)}return w.currentNode=x,J}p(q){let D=0;for(const F of this._$AV)F!==void 0&&(F.strings!==void 0?(F._$AI(q,F,D),D+=F.strings.length-2):F._$AI(q[D])),D++}}class H{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(q,D,F,J){this.type=2,this._$AH=B,this._$AN=void 0,this._$AA=q,this._$AB=D,this._$AM=F,this.options=J,this._$Cv=J?.isConnected??!0}get parentNode(){let q=this._$AA.parentNode,D=this._$AM;return D!==void 0&&q?.nodeType===11&&(q=D.parentNode),q}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(q,D=this){q=z(this,q,D),S(q)?q===B||q==null||q===""?(this._$AH!==B&&this._$AR(),this._$AH=B):q!==this._$AH&&q!==V&&this._(q):q._$litType$!==void 0?this.$(q):q.nodeType!==void 0?this.T(q):h(q)?this.k(q):this._(q)}O(q){return this._$AA.parentNode.insertBefore(q,this._$AB)}T(q){this._$AH!==q&&(this._$AR(),this._$AH=this.O(q))}_(q){this._$AH!==B&&S(this._$AH)?this._$AA.nextSibling.data=q:this.T(x.createTextNode(q)),this._$AH=q}$(q){const{values:D,_$litType$:F}=q,J=typeof F=="number"?this._$AC(q):(F.el===void 0&&(F.el=g.createElement(o(F.h,F.h[0]),this.options)),F);if(this._$AH?._$AD===J)this._$AH.p(D);else{const G=new j(J,this),O=G.u(this.options);G.p(D),this.T(O),this._$AH=G}}_$AC(q){let D=n.get(q.strings);return D===void 0&&n.set(q.strings,D=new g(q)),D}k(q){L(this._$AH)||(this._$AH=[],this._$AR());let D=this._$AH,F,J=0;for(const G of q)J===D.length?D.push(F=new H(this.O(C()),this.O(C()),this,this.options)):F=D[J],F._$AI(G),J++;J<D.length&&(this._$AR(F&&F._$AB.nextSibling,J),D.length=J)}_$AR(q=this._$AA.nextSibling,D){for(this._$AP?.(!1,!0,D);q&&q!==this._$AB;){const F=q.nextSibling;q.remove(),q=F}}setConnected(q){this._$AM===void 0&&(this._$Cv=q,this._$AP?.(q))}}class I{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(q,D,F,J,G){this.type=1,this._$AH=B,this._$AN=void 0,this.element=q,this.name=D,this._$AM=J,this.options=G,F.length>2||F[0]!==""||F[1]!==""?(this._$AH=Array(F.length-1).fill(new String),this.strings=F):this._$AH=B}_$AI(q,D=this,F,J){let G=this.strings,O=!1;if(G===void 0)q=z(this,q,D,0),O=!S(q)||q!==this._$AH&&q!==V,O&&(this._$AH=q);else{let K=q,W,Q;for(q=G[0],W=0;W<G.length-1;W++)Q=z(this,K[F+W],D,W),Q===V&&(Q=this._$AH[W]),O||=!S(Q)||Q!==this._$AH[W],Q===B?q=B:q!==B&&(q+=(Q??"")+G[W+1]),this._$AH[W]=Q}O&&!J&&this.j(q)}j(q){q===B?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,q??"")}}class R extends I{constructor(){super(...arguments),this.type=3}j(q){this.element[this.name]=q===B?void 0:q}}class E extends I{constructor(){super(...arguments),this.type=4}j(q){this.element.toggleAttribute(this.name,!!q&&q!==B)}}class d extends I{constructor(q,D,F,J,G){super(q,D,F,J,G),this.type=5}_$AI(q,D=this){if((q=z(this,q,D,0)??B)===V)return;const F=this._$AH,J=q===B&&F!==B||q.capture!==F.capture||q.once!==F.once||q.passive!==F.passive,G=q!==B&&(F===B||J);J&&this.element.removeEventListener(this.name,this,F),G&&this.element.addEventListener(this.name,this,q),this._$AH=q}handleEvent(q){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,q):this._$AH.handleEvent(q)}}class f{constructor(q,D,F){this.element=q,this.type=6,this._$AN=void 0,this._$AM=D,this.options=F}get _$AU(){return this._$AM._$AU}_$AI(q){z(this,q)}}var Z={M:"$lit$",P,A:v,C:1,L:e,R:j,D:h,V:z,I:H,H:I,N:E,U:d,B:R,F:f},Oq=k.litHtmlPolyfillSupport;Oq?.(g,H),(k.litHtmlVersions??=[]).push("3.2.1");var i=(q,D,F)=>{let J=F?.renderBefore??D,G=J._$litPart$;if(G===void 0){const O=F?.renderBefore??null;J._$litPart$=G=new H(D.insertBefore(C(),O),O,void 0,F??{})}return G._$AI(q),G};var u=null,s={boundAttributeSuffix:Z.M,marker:Z.P,markerMatch:Z.A,HTML_RESULT:Z.C,getTemplateHtml:Z.L,overrideDirectiveResolve:(q,D)=>class extends q{_$AS(F,J){return D(this,J)}},patchDirectiveResolve:(q,D)=>{if(q.prototype._$AS!==D){u??=q.prototype._$AS.name;for(let F=q.prototype;F!==Object.prototype;F=Object.getPrototypeOf(F))if(F.hasOwnProperty(u))return void(F[u]=D);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(q,D){q._$litDirective$=D},getAttributePartCommittedValue:(q,D,F)=>{let J=V;return q.j=(G)=>J=G,q._$AI(D,q,F),J},connectedDisconnectable:(q)=>({...q,_$AU:!0}),resolveDirective:Z.V,AttributePart:Z.H,PropertyPart:Z.B,BooleanAttributePart:Z.N,EventPart:Z.U,ElementPart:Z.F,TemplateInstance:Z.R,isIterable:Z.D,ChildPart:Z.I};var T={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6};var t=(q)=>q===null||typeof q!="object"&&typeof q!="function";var qq=(q,D)=>D===void 0?q?._$litType$!==void 0:q?._$litType$===D,Dq=(q)=>q?._$litType$?.h!=null;var Fq=(q)=>q.strings===void 0;var{TemplateInstance:Qq,isIterable:Wq,resolveDirective:Gq,ChildPart:N,ElementPart:Xq}=s,Jq=(q,D,F={})=>{if(D._$litPart$!==void 0)throw Error("container already contains a live render");let J,G,O,K=[],W=document.createTreeWalker(D,NodeFilter.SHOW_COMMENT),Q;while((Q=W.nextNode())!==null){const Y=Q.data;if(Y.startsWith("lit-part")){if(K.length===0&&J!==void 0)throw Error(`There must be only one root part per container. Found a part marker (${Q}) when we already have a root part marker (${G})`);O=Yq(q,Q,K,F),J===void 0&&(J=O),G??=Q}else if(Y.startsWith("lit-node"))Zq(Q,K,F);else if(Y.startsWith("/lit-part")){if(K.length===1&&O!==J)throw Error("internal error");O=Bq(Q,O,K)}}if(J===void 0){const Y=D instanceof ShadowRoot?"{container.host.localName}\'s shadow root":D instanceof DocumentFragment?"DocumentFragment":D.localName;console.error(`There should be exactly one root part in a render container, but we didn\'t find any in ${Y}.`)}D._$litPart$=J},Yq=(q,D,F,J)=>{let G,O;if(F.length===0)O=new N(D,null,void 0,J),G=q;else{const K=F[F.length-1];if(K.type==="template-instance")O=new N(D,null,K.instance,J),K.instance._$AV.push(O),G=K.result.values[K.instancePartIndex++],K.templatePartIndex++;else if(K.type==="iterable"){O=new N(D,null,K.part,J);const W=K.iterator.next();if(W.done)throw G=void 0,K.done=!0,Error("Unhandled shorter than expected iterable");G=W.value,K.part._$AH.push(O)}else O=new N(D,null,K.part,J)}if(G=Gq(O,G),G===V)F.push({part:O,type:"leaf"});else if(t(G))F.push({part:O,type:"leaf"}),O._$AH=G;else if(qq(G)){if(Dq(G))throw Error("compiled templates are not supported");const K="lit-part "+bq(G);if(D.data!==K)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const W=N.prototype._$AC(G),Q=new Qq(W,O);F.push({type:"template-instance",instance:Q,part:O,templatePartIndex:0,instancePartIndex:0,result:G}),O._$AH=Q}}else Wq(G)?(F.push({part:O,type:"iterable",value:G,iterator:G[Symbol.iterator](),done:!1}),O._$AH=[]):(F.push({part:O,type:"leaf"}),O._$AH=G??"");return O},Bq=(q,D,F)=>{if(D===void 0)throw Error("unbalanced part marker");D._$AB=q;const J=F.pop();if(J.type==="iterable"&&!J.iterator.next().done)throw Error("unexpected longer than expected iterable");if(F.length>0)return F[F.length-1].part},Zq=(q,D,F)=>{const J=/lit-node (\\d+)/.exec(q.data),G=Number.parseInt(J[1]),O=q.nextElementSibling;if(O===null)throw Error("could not find node for attribute parts");O.removeAttribute("defer-hydration");const K=D[D.length-1];if(K.type!=="template-instance")throw Error("Hydration value mismatch: Primitive found where TemplateResult expected. This usually occurs due to conditional rendering that resulted in a different value or template being rendered between the server and client.");{const W=K.instance;for(;;){const Q=W._$AD.parts[K.templatePartIndex];if(Q===void 0||Q.type!==T.ATTRIBUTE&&Q.type!==T.ELEMENT||Q.index!==G)break;if(Q.type===T.ATTRIBUTE){const Y=new Q.ctor(O,Q.name,Q.strings,K.instance,F),X=Fq(Y)?K.result.values[K.instancePartIndex]:K.result.values,b=!(Y.type===T.EVENT||Y.type===T.PROPERTY);Y._$AI(X,Y,K.instancePartIndex,b),K.instancePartIndex+=Q.strings.length-1,W._$AV.push(Y)}else{const Y=new Xq(O,K.instance,F);Gq(Y,K.result.values[K.instancePartIndex++]),W._$AV.push(Y)}K.templatePartIndex++}}},bq=(q)=>{const D=new Uint32Array(2).fill(5381);for(const J of q.strings)for(let G=0;G<J.length;G++)D[G%2]=33*D[G%2]^J.charCodeAt(G);const F=String.fromCharCode(...new Uint8Array(D.buffer));return btoa(F)};globalThis.litElementHydrateSupport=({LitElement:q})=>{const D=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(q),"observedAttributes").get;Object.defineProperty(q,"observedAttributes",{get(){return[...D.call(this),"defer-hydration"]}});const F=q.prototype.attributeChangedCallback;q.prototype.attributeChangedCallback=function(K,W,Q){K==="defer-hydration"&&Q===null&&J.call(this),F.call(this,K,W,Q)};const J=q.prototype.connectedCallback;q.prototype.connectedCallback=function(){this.hasAttribute("defer-hydration")||J.call(this)};const G=q.prototype.createRenderRoot;q.prototype.createRenderRoot=function(){return this.shadowRoot?(this._$AG=!0,this.shadowRoot):G.call(this)};const O=Object.getPrototypeOf(q.prototype).update;q.prototype.update=function(K){const W=this.render();if(O.call(this,K),this._$AG){this._$AG=!1;for(let Q=0;Q<this.attributes.length;Q++){const Y=this.attributes[Q];if(Y.name.startsWith("hydrate-internals-")){const X=Y.name.slice(18);this.removeAttribute(X),this.removeAttribute(Y.name)}}Jq(W,this.renderRoot,this.renderOptions)}else i(W,this.renderRoot,this.renderOptions)}};';
@@ -1,246 +1,227 @@
1
- import "./dom-shim.js";
2
- import {
3
- IntegrationRenderer
4
- } from "@ecopages/core/route-renderer/orchestration/integration-renderer";
5
- import {
6
- getForeignSubtreeResolutionContextKey,
7
- resolveOwningIntegrationRenderer
8
- } from "@ecopages/core/route-renderer/orchestration/foreign-child/owning-renderer-resolution";
9
- import { LitSsrLazyPreloader } from "./lit-ssr-lazy-preloader.js";
10
- import { LIT_PLUGIN_NAME } from "./lit.constants.js";
11
- import {
12
- injectLitRenderedChildren,
13
- LIT_COMPONENT_CHILDREN_SLOT_MARKER,
14
- normalizeLitHtml,
15
- renderLitValueToString
16
- } from "./utils/lit-html-rendering.js";
17
- class LitRenderer extends IntegrationRenderer {
18
- name = LIT_PLUGIN_NAME;
19
- getRenderSession;
20
- constructor(options) {
21
- const { getRenderSession, ...rendererOptions } = options;
22
- super(rendererOptions);
23
- this.getRenderSession = getRenderSession;
24
- }
25
- /**
26
- * Renders a Lit page route, preferring the plugin worker when available.
27
- *
28
- * @remarks
29
- * Activates the integration runtime before reading {@link getRenderSession}
30
- * so a renderer constructed before plugin setup still sees the session.
31
- * When `options.locals` is present, rendering stays in-process: request locals
32
- * are not structured-cloned across the worker boundary.
33
- */
34
- async execute(options) {
35
- await this.ensureIntegrationRuntimeActivated();
36
- const renderSession = this.getRenderSession?.();
37
- if (renderSession && options.locals === void 0) {
38
- const params = options.params ?? {};
39
- const result = await renderSession.renderPageInWorker({
40
- filePath: options.file,
41
- params,
42
- query: options.query
43
- });
44
- return {
45
- body: result.html,
46
- cacheStrategy: result.cacheStrategy
47
- };
1
+ /**
2
+ * This module contains the Lit renderer
3
+ * @module
4
+ */
5
+ import './dom-shim.js';
6
+ import { IntegrationRenderer, } from '@ecopages/core/route-renderer/orchestration/integration-renderer';
7
+ import { getForeignSubtreeResolutionContextKey, resolveOwningIntegrationRenderer, } from '@ecopages/core/route-renderer/orchestration/foreign-child/owning-renderer-resolution';
8
+ import { LitSsrLazyPreloader } from './lit-ssr-lazy-preloader.js';
9
+ import { LIT_PLUGIN_NAME } from './lit.constants.js';
10
+ import { injectLitRenderedChildren, LIT_COMPONENT_CHILDREN_SLOT_MARKER, normalizeLitHtml, renderLitValueToString, } from './utils/lit-html-rendering.js';
11
+ /**
12
+ * A renderer for the Lit integration.
13
+ */
14
+ export class LitRenderer extends IntegrationRenderer {
15
+ name = LIT_PLUGIN_NAME;
16
+ getRenderSession;
17
+ constructor(options) {
18
+ const { getRenderSession, ...rendererOptions } = options;
19
+ super(rendererOptions);
20
+ this.getRenderSession = getRenderSession;
48
21
  }
49
- return super.execute(options);
50
- }
51
- isFunctionComponent(component) {
52
- return typeof component === "function";
53
- }
54
- async resolveQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken) {
55
- if (children === void 0) {
56
- return void 0;
22
+ /**
23
+ * Renders a Lit page route, preferring the plugin worker when available.
24
+ *
25
+ * @remarks
26
+ * Activates the integration runtime before reading {@link getRenderSession}
27
+ * so a renderer constructed before plugin setup still sees the session.
28
+ * When `options.locals` is present, rendering stays in-process: request locals
29
+ * are not structured-cloned across the worker boundary.
30
+ */
31
+ async execute(options) {
32
+ await this.ensureIntegrationRuntimeActivated();
33
+ const renderSession = this.getRenderSession?.();
34
+ if (renderSession && options.locals === undefined) {
35
+ const params = options.params ?? {};
36
+ const result = await renderSession.renderPageInWorker({
37
+ filePath: options.file,
38
+ params,
39
+ query: options.query,
40
+ });
41
+ return {
42
+ body: result.html,
43
+ cacheStrategy: result.cacheStrategy,
44
+ };
45
+ }
46
+ return super.execute(options);
57
47
  }
58
- if (typeof children !== "string") {
59
- return children;
48
+ isFunctionComponent(component) {
49
+ return typeof component === 'function';
60
50
  }
61
- let renderedChildren = children;
62
- renderedChildren = await this.foreignSubtreeExecutionService.resolveQueuedTokens(
63
- renderedChildren,
64
- queuedResolutionsByToken,
65
- resolveToken
66
- );
67
- return renderedChildren;
68
- }
69
- async renderLitQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken) {
70
- const renderedChildren = await this.resolveQueuedForeignSubtreeChildren(
71
- children,
72
- queuedResolutionsByToken,
73
- resolveToken
74
- );
75
- if (typeof renderedChildren !== "string") {
76
- return {
77
- assets: [],
78
- children: renderedChildren
79
- };
51
+ async resolveQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken) {
52
+ if (children === undefined) {
53
+ return undefined;
54
+ }
55
+ if (typeof children !== 'string') {
56
+ return children;
57
+ }
58
+ let renderedChildren = children;
59
+ renderedChildren = await this.foreignSubtreeExecutionService.resolveQueuedTokens(renderedChildren, queuedResolutionsByToken, resolveToken);
60
+ return renderedChildren;
80
61
  }
81
- return {
82
- assets: [],
83
- html: renderedChildren
84
- };
85
- }
86
- /**
87
- * Renders a Lit component for component-level orchestration.
88
- *
89
- * SSR-eligible lazy scripts are preloaded first so custom elements registered
90
- * by the component can render their server markup even when the Lit renderer is
91
- * entered through cross-integration foreign-child handoff.
92
- *
93
- * Includes component-scoped dependency assets when declared.
94
- */
95
- async renderComponent(input) {
96
- await this.preloadSsrLazyScripts([input.component]);
97
- if (!this.isFunctionComponent(input.component)) {
98
- throw new TypeError("Lit renderer expected a callable component.");
62
+ async renderLitQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken) {
63
+ const renderedChildren = await this.resolveQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken);
64
+ if (typeof renderedChildren !== 'string') {
65
+ return {
66
+ assets: [],
67
+ children: renderedChildren,
68
+ };
69
+ }
70
+ return {
71
+ assets: [],
72
+ html: renderedChildren,
73
+ };
99
74
  }
100
- const component = input.component;
101
- let renderedChildren;
102
- if (input.children !== void 0) {
103
- renderedChildren = typeof input.children === "string" ? input.children : await renderLitValueToString(input.children);
75
+ /**
76
+ * Renders a Lit component for component-level orchestration.
77
+ *
78
+ * SSR-eligible lazy scripts are preloaded first so custom elements registered
79
+ * by the component can render their server markup even when the Lit renderer is
80
+ * entered through cross-integration foreign-child handoff.
81
+ *
82
+ * Includes component-scoped dependency assets when declared.
83
+ */
84
+ async renderComponent(input) {
85
+ await this.preloadSsrLazyScripts([input.component]);
86
+ if (!this.isFunctionComponent(input.component)) {
87
+ throw new TypeError('Lit renderer expected a callable component.');
88
+ }
89
+ const component = input.component;
90
+ let renderedChildren;
91
+ if (input.children !== undefined) {
92
+ renderedChildren =
93
+ typeof input.children === 'string' ? input.children : await renderLitValueToString(input.children);
94
+ }
95
+ let props = input.props;
96
+ if (renderedChildren !== undefined) {
97
+ props = {
98
+ ...input.props,
99
+ children: LIT_COMPONENT_CHILDREN_SLOT_MARKER,
100
+ };
101
+ }
102
+ const content = await component(props);
103
+ const renderedHtml = await renderLitValueToString(content);
104
+ const html = renderedChildren === undefined ? renderedHtml : injectLitRenderedChildren(renderedHtml, renderedChildren);
105
+ const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveQueuedHtml({
106
+ currentIntegrationName: this.name,
107
+ html,
108
+ runtimeContext: this.foreignSubtreeExecutionService.getQueuedRuntimeContext(input, getForeignSubtreeResolutionContextKey(this.name)),
109
+ queueLabel: 'Lit',
110
+ getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
111
+ appConfig: this.appConfig,
112
+ runtimeOrigin: this.runtimeOrigin,
113
+ currentIntegrationName: this.name,
114
+ currentRenderer: this,
115
+ integrationName,
116
+ cache: rendererCache,
117
+ }),
118
+ applyAttributesToFirstElement: (resolvedHtml, attributes) => this.htmlTransformer.applyAttributesToFirstElement(resolvedHtml, attributes),
119
+ dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
120
+ renderQueuedChildren: (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => this.renderLitQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken),
121
+ });
122
+ const hasDependencies = Boolean(input.component.config?.dependencies);
123
+ const canResolveAssets = typeof this.assetProcessingService?.processDependencies === 'function';
124
+ const assets = hasDependencies && canResolveAssets
125
+ ? await this.processComponentDependencies([input.component])
126
+ : undefined;
127
+ return this.finalizeIslandComponentRender(input, {
128
+ html: queuedForeignSubtreeResolution.html,
129
+ canAttachAttributes: true,
130
+ rootTag: this.getRootTagName(queuedForeignSubtreeResolution.html),
131
+ integrationName: this.name,
132
+ assets: this.htmlTransformer.dedupeProcessedAssets([
133
+ ...(assets ?? []),
134
+ ...queuedForeignSubtreeResolution.assets,
135
+ ]),
136
+ });
104
137
  }
105
- let props = input.props;
106
- if (renderedChildren !== void 0) {
107
- props = {
108
- ...input.props,
109
- children: LIT_COMPONENT_CHILDREN_SLOT_MARKER
110
- };
111
- }
112
- const content = await component(props);
113
- const renderedHtml = await renderLitValueToString(content);
114
- const html = renderedChildren === void 0 ? renderedHtml : injectLitRenderedChildren(renderedHtml, renderedChildren);
115
- const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveQueuedHtml({
116
- currentIntegrationName: this.name,
117
- html,
118
- runtimeContext: this.foreignSubtreeExecutionService.getQueuedRuntimeContext(
119
- input,
120
- getForeignSubtreeResolutionContextKey(this.name)
121
- ),
122
- queueLabel: "Lit",
123
- getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
124
- appConfig: this.appConfig,
125
- runtimeOrigin: this.runtimeOrigin,
126
- currentIntegrationName: this.name,
127
- currentRenderer: this,
128
- integrationName,
129
- cache: rendererCache
130
- }),
131
- applyAttributesToFirstElement: (resolvedHtml, attributes) => this.htmlTransformer.applyAttributesToFirstElement(resolvedHtml, attributes),
132
- dedupeProcessedAssets: (assets2) => this.htmlTransformer.dedupeProcessedAssets(assets2),
133
- renderQueuedChildren: (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => this.renderLitQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken)
138
+ ssrLazyPreloader = new LitSsrLazyPreloader({
139
+ resolveDependencyPath: this.resolveDependencyPath.bind(this),
140
+ processDependencies: this.assetProcessingService?.processDependencies?.bind(this.assetProcessingService),
134
141
  });
135
- const hasDependencies = Boolean(input.component.config?.dependencies);
136
- const canResolveAssets = typeof this.assetProcessingService?.processDependencies === "function";
137
- const assets = hasDependencies && canResolveAssets ? await this.processComponentDependencies([input.component]) : void 0;
138
- return {
139
- html: queuedForeignSubtreeResolution.html,
140
- canAttachAttributes: true,
141
- rootTag: this.getRootTagName(queuedForeignSubtreeResolution.html),
142
- integrationName: this.name,
143
- assets: this.htmlTransformer.dedupeProcessedAssets([
144
- ...assets ?? [],
145
- ...queuedForeignSubtreeResolution.assets
146
- ])
147
- };
148
- }
149
- ssrLazyPreloader = new LitSsrLazyPreloader({
150
- resolveDependencyPath: this.resolveDependencyPath.bind(this),
151
- processDependencies: this.assetProcessingService?.processDependencies?.bind(this.assetProcessingService)
152
- });
153
- /**
154
- * Detects preload failures that are expected for browser-only modules.
155
- *
156
- * These errors are treated as non-fatal during SSR preload because some
157
- * lazy client scripts intentionally depend on browser globals.
158
- */
159
- isExpectedSsrPreloadError(error) {
160
- return this.ssrLazyPreloader.isExpectedSsrPreloadError(error);
161
- }
162
- /**
163
- * Collects lazy script file paths eligible for SSR preloading.
164
- *
165
- * Only per-entry lazy script dependencies with `ssr: true` are collected.
166
- * File-backed entries are required (`src` must be present);
167
- * inline content lazy entries are intentionally skipped.
168
- */
169
- collectSsrPreloadScripts(components) {
170
- return this.ssrLazyPreloader.collectSsrPreloadScripts(components);
171
- }
172
- /**
173
- * Preloads SSR-eligible lazy scripts to register custom elements before render.
174
- */
175
- async preloadSsrLazyScripts(components) {
176
- const renderSession = this.getRenderSession?.();
177
- if (renderSession) {
178
- await renderSession.preloadSsrLazyScripts(components);
179
- return;
142
+ /**
143
+ * Detects preload failures that are expected for browser-only modules.
144
+ *
145
+ * These errors are treated as non-fatal during SSR preload because some
146
+ * lazy client scripts intentionally depend on browser globals.
147
+ */
148
+ isExpectedSsrPreloadError(error) {
149
+ return this.ssrLazyPreloader.isExpectedSsrPreloadError(error);
150
+ }
151
+ /**
152
+ * Collects lazy script file paths eligible for SSR preloading.
153
+ *
154
+ * Only per-entry lazy script dependencies with `ssr: true` are collected.
155
+ * File-backed entries are required (`src` must be present);
156
+ * inline content lazy entries are intentionally skipped.
157
+ */
158
+ collectSsrPreloadScripts(components) {
159
+ return this.ssrLazyPreloader.collectSsrPreloadScripts(components);
160
+ }
161
+ /**
162
+ * Preloads SSR-eligible lazy scripts to register custom elements before render.
163
+ */
164
+ async preloadSsrLazyScripts(components) {
165
+ const renderSession = this.getRenderSession?.();
166
+ if (renderSession) {
167
+ await renderSession.preloadSsrLazyScripts(components);
168
+ return;
169
+ }
170
+ await this.ssrLazyPreloader.preloadSsrLazyScripts(components);
171
+ }
172
+ /**
173
+ * Resolves the concrete JS entrypoint used for SSR preloading.
174
+ *
175
+ * Scripts are passed through the asset pipeline so preload imports can use
176
+ * the same processed output shape as runtime dependencies.
177
+ */
178
+ async resolveSsrPreloadEntrypoint(scriptPath) {
179
+ return this.ssrLazyPreloader.resolveSsrPreloadEntrypoint(scriptPath);
180
180
  }
181
- await this.ssrLazyPreloader.preloadSsrLazyScripts(components);
182
- }
183
- /**
184
- * Resolves the concrete JS entrypoint used for SSR preloading.
185
- *
186
- * Scripts are passed through the asset pipeline so preload imports can use
187
- * the same processed output shape as runtime dependencies.
188
- */
189
- async resolveSsrPreloadEntrypoint(scriptPath) {
190
- return this.ssrLazyPreloader.resolveSsrPreloadEntrypoint(scriptPath);
191
- }
192
- async render({
193
- params,
194
- query,
195
- props,
196
- locals,
197
- metadata,
198
- Page,
199
- Layout,
200
- HtmlTemplate
201
- }) {
202
- try {
203
- await this.preloadSsrLazyScripts([Page, Layout]);
204
- return await this.renderPageWithDocumentShell({
205
- page: {
206
- component: Page,
207
- props: {
208
- params,
209
- query,
210
- ...props,
211
- locals
212
- }
213
- },
214
- layout: Layout ? {
215
- component: Layout,
216
- props: locals ? { locals } : {}
217
- } : void 0,
218
- htmlTemplate: HtmlTemplate,
219
- metadata,
220
- pageProps: props || {},
221
- transformDocumentHtml: normalizeLitHtml
222
- });
223
- } catch (error) {
224
- throw this.createRenderError("Error rendering page", error);
181
+ async render({ params, query, props, locals, metadata, Page, Layout, HtmlTemplate, }) {
182
+ try {
183
+ await this.preloadSsrLazyScripts([Page, Layout]);
184
+ return await this.renderPageWithDocumentShell({
185
+ page: {
186
+ component: Page,
187
+ props: {
188
+ params,
189
+ query,
190
+ ...props,
191
+ locals,
192
+ },
193
+ },
194
+ layout: Layout
195
+ ? {
196
+ component: Layout,
197
+ props: locals ? { locals } : {},
198
+ }
199
+ : undefined,
200
+ htmlTemplate: HtmlTemplate,
201
+ metadata,
202
+ pageProps: props || {},
203
+ transformDocumentHtml: normalizeLitHtml,
204
+ });
205
+ }
206
+ catch (error) {
207
+ throw this.createRenderError('Error rendering page', error);
208
+ }
225
209
  }
226
- }
227
- async renderToResponse(view, props, ctx) {
228
- try {
229
- const layouts = view.config?.layouts;
230
- const Layout = layouts?.[layouts.length - 1];
231
- await this.preloadSsrLazyScripts([view, Layout]);
232
- return await this.renderViewWithDocumentShell({
233
- view,
234
- props,
235
- ctx,
236
- layout: Layout,
237
- transformDocumentHtml: normalizeLitHtml
238
- });
239
- } catch (error) {
240
- throw this.createRenderError("Error rendering view", error);
210
+ async renderToResponse(view, props, ctx) {
211
+ try {
212
+ const layouts = view.config?.layouts;
213
+ const Layout = layouts?.[layouts.length - 1];
214
+ await this.preloadSsrLazyScripts([view, Layout]);
215
+ return await this.renderViewWithDocumentShell({
216
+ view,
217
+ props,
218
+ ctx,
219
+ layout: Layout,
220
+ transformDocumentHtml: normalizeLitHtml,
221
+ });
222
+ }
223
+ catch (error) {
224
+ throw this.createRenderError('Error rendering view', error);
225
+ }
241
226
  }
242
- }
243
227
  }
244
- export {
245
- LitRenderer
246
- };