@wcstack/server 2.1.0 → 2.2.0

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/dist/index.esm.js CHANGED
@@ -357,7 +357,7 @@ async function renderToString(html, options) {
357
357
  }
358
358
  }
359
359
 
360
- var version = "2.1.0";
360
+ var version = "2.2.0";
361
361
  var pkg = {
362
362
  version: version};
363
363
 
@@ -1,2 +1,2 @@
1
- import{Window as t}from"happy-dom";const e=Symbol.for("wcstack.ssr.snapshotBuilder");const n=new class{_queue=[];_locked=!1;async acquire(){return this._locked&&await new Promise(t=>this._queue.push(t)),this._locked=!0,()=>{this._locked=!1,this._queue.shift()?.()}}},r=["document","customElements","HTMLElement","DocumentFragment","Node","NodeFilter","Comment","Text","MutationObserver","ShadowRoot","Element","HTMLTemplateElement","window","location","history","Event","CustomEvent"];function o(t){const e={};for(const n of r)e[n]=globalThis[n],globalThis[n]=t[n];const n=URL.createObjectURL;return URL.createObjectURL=void 0,()=>{URL.createObjectURL=n;for(const t of r)globalThis[t]=e[t]}}function s(t){const e=globalThis.URL,n=t;return globalThis.URL=class extends e{constructor(t,e){"string"==typeof t&&t.startsWith("/")&&void 0===e?super(t,n):super(t,e)}},globalThis.URL.createObjectURL=e.createObjectURL,globalThis.URL.revokeObjectURL=e.revokeObjectURL,()=>{globalThis.URL=e}}async function a(t,e){const n=e?.maxIterations??10,r=new WeakSet,o=new Set;for(let e=0;e<n;e++){const e=[];for(const n of t.querySelectorAll("*-*")){if(r.has(n))continue;const t=n.constructor;t.hasConnectedCallbackPromise&&(r.add(n),e.push(n.connectedCallbackPromise)),"function"==typeof t.getBindingsReady&&o.add(t)}if(0===e.length)break;await Promise.all(e)}await Promise.all(Array.from(o,e=>e.getBindingsReady(t)))}async function i(r,i){const c=await n.acquire(),l=i?.url?new t({url:i.url}):new t,d=o(l),u=l.document;let h=null;try{if(void 0!==i?.url||void 0!==i?.baseHref){const t=u.createElement("base");t.setAttribute("href",i.baseHref??"/"),u.head.appendChild(t)}const t=i?.baseUrl??(i?.url?new URL(i.url).origin:void 0);h=t?s(t):null;const n=i?.bootstraps??await async function(){const{bootstrapState:t}=await import("@wcstack/state");return[t]}();for(const t of n)await t();const o=function(){const t=globalThis[e];return null==t||"wcs-ssr-snapshot"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.build?null:t}();return u.documentElement.setAttribute("data-wcs-server",null!==o?"orchestrated":""),u.body.innerHTML=r,await a(u),o?.build(u),u.body.innerHTML}finally{try{const t=[];for(const e of u.querySelectorAll("*-*")){const n=e.constructor;"function"==typeof n.getBindingsReady&&t.push(n.getBindingsReady(u))}await Promise.allSettled(t)}catch{}const t=globalThis[Symbol.for("wcstack.binder.pending")];Array.isArray(t)&&(t.length=0),h?.(),d(),await l.close(),c()}}const c="2.1.0";class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"html",event:"wcs-render:html-changed",semantics:"state"},{name:"loading",event:"wcs-render:loading-changed",semantics:"state"},{name:"error",event:"wcs-render:error",semantics:"state"}]};_html=null;_loading=!1;_error=null;get html(){return this._html}get loading(){return this._loading}get error(){return this._error}_setLoading(t){this._loading=t,this.dispatchEvent(new CustomEvent("wcs-render:loading-changed",{detail:t}))}_setHtml(t){this._html=t,this.dispatchEvent(new CustomEvent("wcs-render:html-changed",{detail:t}))}_setError(t){this._error=t,this.dispatchEvent(new CustomEvent("wcs-render:error",{detail:t}))}async render(t){this._setLoading(!0),this._setError(null);try{const e=await i(t);return this._setHtml(e),this._setLoading(!1),this._html}catch(t){return this._setError(t instanceof Error?t:new Error(String(t))),this._setLoading(!1),null}}}export{r as GLOBALS_KEYS,l as RenderCore,c as VERSION,s as installBaseUrl,o as installGlobals,i as renderToString,a as waitForReady};
1
+ import{Window as t}from"happy-dom";const e=Symbol.for("wcstack.ssr.snapshotBuilder");const n=new class{_queue=[];_locked=!1;async acquire(){return this._locked&&await new Promise(t=>this._queue.push(t)),this._locked=!0,()=>{this._locked=!1,this._queue.shift()?.()}}},r=["document","customElements","HTMLElement","DocumentFragment","Node","NodeFilter","Comment","Text","MutationObserver","ShadowRoot","Element","HTMLTemplateElement","window","location","history","Event","CustomEvent"];function o(t){const e={};for(const n of r)e[n]=globalThis[n],globalThis[n]=t[n];const n=URL.createObjectURL;return URL.createObjectURL=void 0,()=>{URL.createObjectURL=n;for(const t of r)globalThis[t]=e[t]}}function s(t){const e=globalThis.URL,n=t;return globalThis.URL=class extends e{constructor(t,e){"string"==typeof t&&t.startsWith("/")&&void 0===e?super(t,n):super(t,e)}},globalThis.URL.createObjectURL=e.createObjectURL,globalThis.URL.revokeObjectURL=e.revokeObjectURL,()=>{globalThis.URL=e}}async function a(t,e){const n=e?.maxIterations??10,r=new WeakSet,o=new Set;for(let e=0;e<n;e++){const e=[];for(const n of t.querySelectorAll("*-*")){if(r.has(n))continue;const t=n.constructor;t.hasConnectedCallbackPromise&&(r.add(n),e.push(n.connectedCallbackPromise)),"function"==typeof t.getBindingsReady&&o.add(t)}if(0===e.length)break;await Promise.all(e)}await Promise.all(Array.from(o,e=>e.getBindingsReady(t)))}async function i(r,i){const c=await n.acquire(),l=i?.url?new t({url:i.url}):new t,d=o(l),u=l.document;let h=null;try{if(void 0!==i?.url||void 0!==i?.baseHref){const t=u.createElement("base");t.setAttribute("href",i.baseHref??"/"),u.head.appendChild(t)}const t=i?.baseUrl??(i?.url?new URL(i.url).origin:void 0);h=t?s(t):null;const n=i?.bootstraps??await async function(){const{bootstrapState:t}=await import("@wcstack/state");return[t]}();for(const t of n)await t();const o=function(){const t=globalThis[e];return null==t||"wcs-ssr-snapshot"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.build?null:t}();return u.documentElement.setAttribute("data-wcs-server",null!==o?"orchestrated":""),u.body.innerHTML=r,await a(u),o?.build(u),u.body.innerHTML}finally{try{const t=[];for(const e of u.querySelectorAll("*-*")){const n=e.constructor;"function"==typeof n.getBindingsReady&&t.push(n.getBindingsReady(u))}await Promise.allSettled(t)}catch{}const t=globalThis[Symbol.for("wcstack.binder.pending")];Array.isArray(t)&&(t.length=0),h?.(),d(),await l.close(),c()}}const c="2.2.0";class l extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"html",event:"wcs-render:html-changed",semantics:"state"},{name:"loading",event:"wcs-render:loading-changed",semantics:"state"},{name:"error",event:"wcs-render:error",semantics:"state"}]};_html=null;_loading=!1;_error=null;get html(){return this._html}get loading(){return this._loading}get error(){return this._error}_setLoading(t){this._loading=t,this.dispatchEvent(new CustomEvent("wcs-render:loading-changed",{detail:t}))}_setHtml(t){this._html=t,this.dispatchEvent(new CustomEvent("wcs-render:html-changed",{detail:t}))}_setError(t){this._error=t,this.dispatchEvent(new CustomEvent("wcs-render:error",{detail:t}))}async render(t){this._setLoading(!0),this._setError(null);try{const e=await i(t);return this._setHtml(e),this._setLoading(!1),this._html}catch(t){return this._setError(t instanceof Error?t:new Error(String(t))),this._setLoading(!1),null}}}export{r as GLOBALS_KEYS,l as RenderCore,c as VERSION,s as installBaseUrl,o as installGlobals,i as renderToString,a as waitForReady};
2
2
  //# sourceMappingURL=index.esm.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/server",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Server-side rendering for wcstack Web Components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "license": "MIT",
44
44
  "dependencies": {
45
- "@wcstack/state": "^2.1.0",
45
+ "@wcstack/state": "^2.2.0",
46
46
  "happy-dom": "^20.0.11"
47
47
  },
48
48
  "devDependencies": {