@lit-labs/ssr-client
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -315,3 +315,7 @@ /** | ||
else { | ||
throw new Error('internal error'); | ||
// TODO(augustjk): This message may need to be updated based on | ||
// hydration strategy. See https://github.com/lit/lit/issues/1434 | ||
throw new 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.`); | ||
} | ||
@@ -318,0 +322,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import{noChange as e}from"lit-html";import{_$LH as t}from"lit-html/private-ssr-support.js";import{PartType as r}from"lit-html/directive.js";import{isPrimitive as o,isTemplateResult as n,isCompiledTemplateResult as a,isSingleExpression as i}from"lit-html/directive-helpers.js"; | ||
import{noChange as e}from"lit-html";import{_$LH as t}from"lit-html/private-ssr-support.js";import{PartType as r}from"lit-html/directive.js";import{isPrimitive as n,isTemplateResult as o,isCompiledTemplateResult as i,isSingleExpression as a}from"lit-html/directive-helpers.js"; | ||
/** | ||
@@ -6,3 +6,3 @@ * @license | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/const{TemplateInstance:l,isIterable:s,resolveDirective:c,ChildPart:d,ElementPart:p}=t,f=(e,t,r={})=>{if(void 0!==t._$litPart$)throw Error("container already contains a live render");let o,n,a;const i=[],l=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);let s;for(;null!==(s=l.nextNode());){const t=s.data;if(t.startsWith("lit-part")){if(0===i.length&&void 0!==o)throw Error(`There must be only one root part per container. Found a part marker (${s}) when we already have a root part marker (${n})`);a=m(e,s,i,r),void 0===o&&(o=a),n??=s}else if(t.startsWith("lit-node"))u(s,i,r);else if(t.startsWith("/lit-part")){if(1===i.length&&a!==o)throw Error("internal error");a=h(s,a,i)}}if(void 0===o){const e=t instanceof ShadowRoot?"{container.host.localName}'s shadow root":t instanceof DocumentFragment?"DocumentFragment":t.localName;console.error(`There should be exactly one root part in a render container, but we didn't find any in ${e}.`)}t._$litPart$=o},m=(t,r,i,p)=>{let f,m;if(0===i.length)m=new d(r,null,void 0,p),f=t;else{const e=i[i.length-1];if("template-instance"===e.type)m=new d(r,null,e.instance,p),e.instance._$AV.push(m),f=e.result.values[e.instancePartIndex++],e.templatePartIndex++;else if("iterable"===e.type){m=new d(r,null,e.part,p);const t=e.iterator.next();if(t.done)throw f=void 0,e.done=!0,Error("Unhandled shorter than expected iterable");f=t.value,e.part._$AH.push(m)}else m=new d(r,null,e.part,p)}if(f=c(m,f),f===e)i.push({part:m,type:"leaf"});else if(o(f))i.push({part:m,type:"leaf"}),m._$AH=f;else if(n(f)){if(a(f))throw Error("compiled templates are not supported");const e="lit-part "+w(f);if(r.data!==e)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const e=d.prototype._$AC(f),t=new l(e,m);i.push({type:"template-instance",instance:t,part:m,templatePartIndex:0,instancePartIndex:0,result:f}),m._$AH=t}}else s(f)?(i.push({part:m,type:"iterable",value:f,iterator:f[Symbol.iterator](),done:!1}),m._$AH=[]):(i.push({part:m,type:"leaf"}),m._$AH=f??"");return m},h=(e,t,r)=>{if(void 0===t)throw Error("unbalanced part marker");t._$AB=e;const o=r.pop();if("iterable"===o.type&&!o.iterator.next().done)throw Error("unexpected longer than expected iterable");if(r.length>0)return r[r.length-1].part},u=(e,t,o)=>{const n=/lit-node (\d+)/.exec(e.data),a=parseInt(n[1]),l=e.nextElementSibling;if(null===l)throw Error("could not find node for attribute parts");l.removeAttribute("defer-hydration");const s=t[t.length-1];if("template-instance"!==s.type)throw Error("internal error");{const e=s.instance;for(;;){const t=e._$AD.parts[s.templatePartIndex];if(void 0===t||t.type!==r.ATTRIBUTE&&t.type!==r.ELEMENT||t.index!==a)break;if(t.type===r.ATTRIBUTE){const n=new t.ctor(l,t.name,t.strings,s.instance,o),a=i(n)?s.result.values[s.instancePartIndex]:s.result.values,c=!(n.type===r.EVENT||n.type===r.PROPERTY);n._$AI(a,n,s.instancePartIndex,c),s.instancePartIndex+=t.strings.length-1,e._$AV.push(n)}else{const t=new p(l,s.instance,o);c(t,s.result.values[s.instancePartIndex++]),e._$AV.push(t)}s.templatePartIndex++}}},w=e=>{const t=new Uint32Array(2).fill(5381);for(const r of e.strings)for(let e=0;e<r.length;e++)t[e%2]=33*t[e%2]^r.charCodeAt(e);const r=String.fromCharCode(...new Uint8Array(t.buffer));return btoa(r)};export{w as digestForTemplateResult,f as hydrate}; | ||
*/const{TemplateInstance:l,isIterable:s,resolveDirective:d,ChildPart:c,ElementPart:p}=t,f=(e,t,r={})=>{if(void 0!==t._$litPart$)throw Error("container already contains a live render");let n,o,i;const a=[],l=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);let s;for(;null!==(s=l.nextNode());){const t=s.data;if(t.startsWith("lit-part")){if(0===a.length&&void 0!==n)throw Error(`There must be only one root part per container. Found a part marker (${s}) when we already have a root part marker (${o})`);i=m(e,s,a,r),void 0===n&&(n=i),o??=s}else if(t.startsWith("lit-node"))u(s,a,r);else if(t.startsWith("/lit-part")){if(1===a.length&&i!==n)throw Error("internal error");i=h(s,i,a)}}if(void 0===n){const e=t instanceof ShadowRoot?"{container.host.localName}'s shadow root":t instanceof DocumentFragment?"DocumentFragment":t.localName;console.error(`There should be exactly one root part in a render container, but we didn't find any in ${e}.`)}t._$litPart$=n},m=(t,r,a,p)=>{let f,m;if(0===a.length)m=new c(r,null,void 0,p),f=t;else{const e=a[a.length-1];if("template-instance"===e.type)m=new c(r,null,e.instance,p),e.instance._$AV.push(m),f=e.result.values[e.instancePartIndex++],e.templatePartIndex++;else if("iterable"===e.type){m=new c(r,null,e.part,p);const t=e.iterator.next();if(t.done)throw f=void 0,e.done=!0,Error("Unhandled shorter than expected iterable");f=t.value,e.part._$AH.push(m)}else m=new c(r,null,e.part,p)}if(f=d(m,f),f===e)a.push({part:m,type:"leaf"});else if(n(f))a.push({part:m,type:"leaf"}),m._$AH=f;else if(o(f)){if(i(f))throw Error("compiled templates are not supported");const e="lit-part "+w(f);if(r.data!==e)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const e=c.prototype._$AC(f),t=new l(e,m);a.push({type:"template-instance",instance:t,part:m,templatePartIndex:0,instancePartIndex:0,result:f}),m._$AH=t}}else s(f)?(a.push({part:m,type:"iterable",value:f,iterator:f[Symbol.iterator](),done:!1}),m._$AH=[]):(a.push({part:m,type:"leaf"}),m._$AH=f??"");return m},h=(e,t,r)=>{if(void 0===t)throw Error("unbalanced part marker");t._$AB=e;const n=r.pop();if("iterable"===n.type&&!n.iterator.next().done)throw Error("unexpected longer than expected iterable");if(r.length>0)return r[r.length-1].part},u=(e,t,n)=>{const o=/lit-node (\d+)/.exec(e.data),i=parseInt(o[1]),l=e.nextElementSibling;if(null===l)throw Error("could not find node for attribute parts");l.removeAttribute("defer-hydration");const s=t[t.length-1];if("template-instance"!==s.type)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 e=s.instance;for(;;){const t=e._$AD.parts[s.templatePartIndex];if(void 0===t||t.type!==r.ATTRIBUTE&&t.type!==r.ELEMENT||t.index!==i)break;if(t.type===r.ATTRIBUTE){const o=new t.ctor(l,t.name,t.strings,s.instance,n),i=a(o)?s.result.values[s.instancePartIndex]:s.result.values,d=!(o.type===r.EVENT||o.type===r.PROPERTY);o._$AI(i,o,s.instancePartIndex,d),s.instancePartIndex+=t.strings.length-1,e._$AV.push(o)}else{const t=new p(l,s.instance,n);d(t,s.result.values[s.instancePartIndex++]),e._$AV.push(t)}s.templatePartIndex++}}},w=e=>{const t=new Uint32Array(2).fill(5381);for(const r of e.strings)for(let e=0;e<r.length;e++)t[e%2]=33*t[e%2]^r.charCodeAt(e);const r=String.fromCharCode(...new Uint8Array(t.buffer));return btoa(r)};export{w as digestForTemplateResult,f as hydrate}; | ||
//# sourceMappingURL=hydrate-lit-html.js.map |
@@ -309,3 +309,7 @@ import { Buffer } from 'buffer'; | ||
else { | ||
throw new Error('internal error'); | ||
// TODO(augustjk): This message may need to be updated based on | ||
// hydration strategy. See https://github.com/lit/lit/issues/1434 | ||
throw new 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.`); | ||
} | ||
@@ -312,0 +316,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import{Buffer as e}from"buffer";import{noChange as t}from"lit-html";import{_$LH as r}from"lit-html/private-ssr-support.js";import{PartType as o}from"lit-html/directive.js";import{isPrimitive as n,isTemplateResult as a,isCompiledTemplateResult as i,isSingleExpression as l}from"lit-html/directive-helpers.js";const{TemplateInstance:s,isIterable:c,resolveDirective:d,ChildPart:p,ElementPart:f}=r,m=(e,t,r={})=>{if(void 0!==t._$litPart$)throw Error("container already contains a live render");let o,n,a;const i=[],l=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);let s;for(;null!==(s=l.nextNode());){const t=s.data;if(t.startsWith("lit-part")){if(0===i.length&&void 0!==o)throw Error(`There must be only one root part per container. Found a part marker (${s}) when we already have a root part marker (${n})`);a=h(e,s,i,r),void 0===o&&(o=a),n??=s}else if(t.startsWith("lit-node"))w(s,i,r);else if(t.startsWith("/lit-part")){if(1===i.length&&a!==o)throw Error("internal error");a=u(s,a,i)}}if(void 0===o){const e=t instanceof ShadowRoot?"{container.host.localName}'s shadow root":t instanceof DocumentFragment?"DocumentFragment":t.localName;console.error(`There should be exactly one root part in a render container, but we didn't find any in ${e}.`)}t._$litPart$=o},h=(e,r,o,l)=>{let f,m;if(0===o.length)m=new p(r,null,void 0,l),f=e;else{const e=o[o.length-1];if("template-instance"===e.type)m=new p(r,null,e.instance,l),e.instance._$AV.push(m),f=e.result.values[e.instancePartIndex++],e.templatePartIndex++;else if("iterable"===e.type){m=new p(r,null,e.part,l);const t=e.iterator.next();if(t.done)throw f=void 0,e.done=!0,Error("Unhandled shorter than expected iterable");f=t.value,e.part._$AH.push(m)}else m=new p(r,null,e.part,l)}if(f=d(m,f),f===t)o.push({part:m,type:"leaf"});else if(n(f))o.push({part:m,type:"leaf"}),m._$AH=f;else if(a(f)){if(i(f))throw Error("compiled templates are not supported");const e="lit-part "+v(f);if(r.data!==e)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const e=p.prototype._$AC(f),t=new s(e,m);o.push({type:"template-instance",instance:t,part:m,templatePartIndex:0,instancePartIndex:0,result:f}),m._$AH=t}}else c(f)?(o.push({part:m,type:"iterable",value:f,iterator:f[Symbol.iterator](),done:!1}),m._$AH=[]):(o.push({part:m,type:"leaf"}),m._$AH=f??"");return m},u=(e,t,r)=>{if(void 0===t)throw Error("unbalanced part marker");t._$AB=e;const o=r.pop();if("iterable"===o.type&&!o.iterator.next().done)throw Error("unexpected longer than expected iterable");if(r.length>0)return r[r.length-1].part},w=(e,t,r)=>{const n=/lit-node (\d+)/.exec(e.data),a=parseInt(n[1]),i=e.nextElementSibling;if(null===i)throw Error("could not find node for attribute parts");i.removeAttribute("defer-hydration");const s=t[t.length-1];if("template-instance"!==s.type)throw Error("internal error");{const e=s.instance;for(;;){const t=e._$AD.parts[s.templatePartIndex];if(void 0===t||t.type!==o.ATTRIBUTE&&t.type!==o.ELEMENT||t.index!==a)break;if(t.type===o.ATTRIBUTE){const n=new t.ctor(i,t.name,t.strings,s.instance,r),a=l(n)?s.result.values[s.instancePartIndex]:s.result.values,c=!(n.type===o.EVENT||n.type===o.PROPERTY);n._$AI(a,n,s.instancePartIndex,c),s.instancePartIndex+=t.strings.length-1,e._$AV.push(n)}else{const t=new f(i,s.instance,r);d(t,s.result.values[s.instancePartIndex++]),e._$AV.push(t)}s.templatePartIndex++}}},v=t=>{const r=new Uint32Array(2).fill(5381);for(const e of t.strings)for(let t=0;t<e.length;t++)r[t%2]=33*r[t%2]^e.charCodeAt(t);const o=String.fromCharCode(...new Uint8Array(r.buffer));return e.from(o,"binary").toString("base64")};export{v as digestForTemplateResult,m as hydrate}; | ||
import{Buffer as e}from"buffer";import{noChange as t}from"lit-html";import{_$LH as r}from"lit-html/private-ssr-support.js";import{PartType as n}from"lit-html/directive.js";import{isPrimitive as o,isTemplateResult as i,isCompiledTemplateResult as a,isSingleExpression as l}from"lit-html/directive-helpers.js";const{TemplateInstance:s,isIterable:d,resolveDirective:c,ChildPart:p,ElementPart:f}=r,m=(e,t,r={})=>{if(void 0!==t._$litPart$)throw Error("container already contains a live render");let n,o,i;const a=[],l=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);let s;for(;null!==(s=l.nextNode());){const t=s.data;if(t.startsWith("lit-part")){if(0===a.length&&void 0!==n)throw Error(`There must be only one root part per container. Found a part marker (${s}) when we already have a root part marker (${o})`);i=u(e,s,a,r),void 0===n&&(n=i),o??=s}else if(t.startsWith("lit-node"))w(s,a,r);else if(t.startsWith("/lit-part")){if(1===a.length&&i!==n)throw Error("internal error");i=h(s,i,a)}}if(void 0===n){const e=t instanceof ShadowRoot?"{container.host.localName}'s shadow root":t instanceof DocumentFragment?"DocumentFragment":t.localName;console.error(`There should be exactly one root part in a render container, but we didn't find any in ${e}.`)}t._$litPart$=n},u=(e,r,n,l)=>{let f,m;if(0===n.length)m=new p(r,null,void 0,l),f=e;else{const e=n[n.length-1];if("template-instance"===e.type)m=new p(r,null,e.instance,l),e.instance._$AV.push(m),f=e.result.values[e.instancePartIndex++],e.templatePartIndex++;else if("iterable"===e.type){m=new p(r,null,e.part,l);const t=e.iterator.next();if(t.done)throw f=void 0,e.done=!0,Error("Unhandled shorter than expected iterable");f=t.value,e.part._$AH.push(m)}else m=new p(r,null,e.part,l)}if(f=c(m,f),f===t)n.push({part:m,type:"leaf"});else if(o(f))n.push({part:m,type:"leaf"}),m._$AH=f;else if(i(f)){if(a(f))throw Error("compiled templates are not supported");const e="lit-part "+v(f);if(r.data!==e)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{const e=p.prototype._$AC(f),t=new s(e,m);n.push({type:"template-instance",instance:t,part:m,templatePartIndex:0,instancePartIndex:0,result:f}),m._$AH=t}}else d(f)?(n.push({part:m,type:"iterable",value:f,iterator:f[Symbol.iterator](),done:!1}),m._$AH=[]):(n.push({part:m,type:"leaf"}),m._$AH=f??"");return m},h=(e,t,r)=>{if(void 0===t)throw Error("unbalanced part marker");t._$AB=e;const n=r.pop();if("iterable"===n.type&&!n.iterator.next().done)throw Error("unexpected longer than expected iterable");if(r.length>0)return r[r.length-1].part},w=(e,t,r)=>{const o=/lit-node (\d+)/.exec(e.data),i=parseInt(o[1]),a=e.nextElementSibling;if(null===a)throw Error("could not find node for attribute parts");a.removeAttribute("defer-hydration");const s=t[t.length-1];if("template-instance"!==s.type)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 e=s.instance;for(;;){const t=e._$AD.parts[s.templatePartIndex];if(void 0===t||t.type!==n.ATTRIBUTE&&t.type!==n.ELEMENT||t.index!==i)break;if(t.type===n.ATTRIBUTE){const o=new t.ctor(a,t.name,t.strings,s.instance,r),i=l(o)?s.result.values[s.instancePartIndex]:s.result.values,d=!(o.type===n.EVENT||o.type===n.PROPERTY);o._$AI(i,o,s.instancePartIndex,d),s.instancePartIndex+=t.strings.length-1,e._$AV.push(o)}else{const t=new f(a,s.instance,r);c(t,s.result.values[s.instancePartIndex++]),e._$AV.push(t)}s.templatePartIndex++}}},v=t=>{const r=new Uint32Array(2).fill(5381);for(const e of t.strings)for(let t=0;t<e.length;t++)r[t%2]=33*r[t%2]^e.charCodeAt(t);const n=String.fromCharCode(...new Uint8Array(r.buffer));return e.from(n,"binary").toString("base64")};export{v as digestForTemplateResult,m as hydrate}; | ||
//# sourceMappingURL=hydrate-lit-html.js.map |
{ | ||
"name": "@lit-labs/ssr-client", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Client package for @lit-labs/ssr.", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
219857
1471