@wcstack/server 0.2.4 → 0.2.5

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
@@ -198,7 +198,7 @@ async function renderToString(html, options) {
198
198
  }
199
199
  }
200
200
 
201
- var version = "0.2.4";
201
+ var version = "0.2.5";
202
202
  var pkg = {
203
203
  version: version};
204
204
 
@@ -1,2 +1,2 @@
1
- import{Window as t}from"happy-dom";const e=["document","customElements","HTMLElement","DocumentFragment","Node","NodeFilter","Comment","Text","MutationObserver","ShadowRoot","Element","HTMLTemplateElement"];function n(t){const n={};for(const r of e)n[r]=globalThis[r],globalThis[r]=t[r];const r=URL.createObjectURL;return URL.createObjectURL=void 0,()=>{URL.createObjectURL=r;for(const t of e)globalThis[t]=n[t]}}function r(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}}function o(t){const e=t.__state;if(!e||"object"!=typeof e)return{};const n={};for(const[t,r]of Object.entries(e))t.startsWith("$")||"function"==typeof r||(n[t]=r);return n}async function s(e,o){const s=new t,a=n(s),i=s.document,c=o?.baseUrl?r(o.baseUrl):null,l=o?.bootstraps??await async function(){const{bootstrapState:t}=await import("@wcstack/state");return[t]}();for(const t of l)t();try{i.documentElement.setAttribute("data-wcs-server",""),i.body.innerHTML=e;const t=[],n=[],r=new Set;for(const e of i.querySelectorAll("*-*")){const o=e.constructor;o.hasConnectedCallbackPromise&&t.push(e.connectedCallbackPromise),r.has(o)||"function"!=typeof o.getBindingsReady||(r.add(o),n.push(o.getBindingsReady(i)))}return await Promise.all(t),await Promise.all(n),i.body.innerHTML}finally{c?.(),a(),await s.close()}}const a="0.2.4";class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"html",event:"wcs-render:html-changed"},{name:"loading",event:"wcs-render:loading-changed"},{name:"error",event:"wcs-render:error"}]};_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._error=null;try{const e=await s(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{e as GLOBALS_KEYS,i as RenderCore,a as VERSION,o as extractStateData,r as installBaseUrl,n as installGlobals,s as renderToString};
1
+ import{Window as t}from"happy-dom";const e=["document","customElements","HTMLElement","DocumentFragment","Node","NodeFilter","Comment","Text","MutationObserver","ShadowRoot","Element","HTMLTemplateElement"];function n(t){const n={};for(const r of e)n[r]=globalThis[r],globalThis[r]=t[r];const r=URL.createObjectURL;return URL.createObjectURL=void 0,()=>{URL.createObjectURL=r;for(const t of e)globalThis[t]=n[t]}}function r(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}}function o(t){const e=t.__state;if(!e||"object"!=typeof e)return{};const n={};for(const[t,r]of Object.entries(e))t.startsWith("$")||"function"==typeof r||(n[t]=r);return n}async function s(e,o){const s=new t,a=n(s),i=s.document,c=o?.baseUrl?r(o.baseUrl):null,l=o?.bootstraps??await async function(){const{bootstrapState:t}=await import("@wcstack/state");return[t]}();for(const t of l)t();try{i.documentElement.setAttribute("data-wcs-server",""),i.body.innerHTML=e;const t=[],n=[],r=new Set;for(const e of i.querySelectorAll("*-*")){const o=e.constructor;o.hasConnectedCallbackPromise&&t.push(e.connectedCallbackPromise),r.has(o)||"function"!=typeof o.getBindingsReady||(r.add(o),n.push(o.getBindingsReady(i)))}return await Promise.all(t),await Promise.all(n),i.body.innerHTML}finally{c?.(),a(),await s.close()}}const a="0.2.5";class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"html",event:"wcs-render:html-changed"},{name:"loading",event:"wcs-render:loading-changed"},{name:"error",event:"wcs-render:error"}]};_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._error=null;try{const e=await s(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{e as GLOBALS_KEYS,i as RenderCore,a as VERSION,o as extractStateData,r as installBaseUrl,n as installGlobals,s as renderToString};
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": "0.2.4",
3
+ "version": "0.2.5",
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": "file:../state",
45
+ "@wcstack/state": "^1.6.0",
46
46
  "happy-dom": "^20.0.11"
47
47
  },
48
48
  "devDependencies": {