@carats/csr 0.0.19 → 0.0.21

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.d.ts CHANGED
@@ -5,9 +5,12 @@ declare global {
5
5
  _isHandled: boolean;
6
6
  }
7
7
  interface Window {
8
- ssp: {
9
- for: string | undefined;
10
- data: any;
8
+ carats: {
9
+ ssp: {
10
+ for: string | undefined;
11
+ data: any;
12
+ };
13
+ crown?: string;
11
14
  };
12
15
  }
13
16
  }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{clearHydrations as c}from"@carats/hooks";import{getPageComponent as p,renderPage as u}from"@carats/render";import{init as f,transpile as g}from"jjsx";var r={};async function a(){let{suspense:t}=r;t.loading=t.loading??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Loading...")),t.error=t.error??(e=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Error: ",e.message)),t.notFound=t.notFound??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Not Found"));let n=location.pathname+location.search,s=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await c();try{let{component:e}=p.call(r,location.href),o=e.defaultProps;if(e.burnished&&(window.ssp.for!==n||e.recast)){let d=`/culet${n}`;o=await fetch(d).then(l=>l.json()),window.ssp.data=o,window.ssp.for=n}else o=window.ssp.data;let i=await u.call(r,e,o);document.getElementById("app").innerHTML=i}catch(e){document.getElementById("app").innerHTML=g(t.error(e))}finally{clearTimeout(s),window.dispatchEvent(new Event("load")),document.getElementById("loading-indicator")?.classList.add("hide")}}function y(t){if(new URL(t,location.origin).origin!==location.origin){window.location.href=t;return}history.pushState(null,"",t),a()}function L(t){f(),window.ssp||(window.ssp={for:void 0,data:null}),r=t;let{inAppRouting:n=!0}=t;n&&(window.addEventListener("load",()=>{document.querySelectorAll("a").forEach(e=>{e._isHandled||new URL(e.href,location.origin).origin!==location.origin||e.download||(e.addEventListener("click",i=>{i.preventDefault(),history.pushState(null,"",e.href),a()}),e._isHandled=!0)})}),window.addEventListener("popstate",a))}export{a as clientRender,y as goTo,L as mount};
1
+ import{clearHydrations as p}from"@carats/hooks";import{defineFacets as f,getPageComponent as u,renderPage as m}from"@carats/render";import{init as g,transpile as d}from"jjsx";var r=f({});async function i(){let{suspense:t}=r,n=location.pathname+location.search,s=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await p();try{let{component:e}=u.call(r,location.href),a=e.defaultProps;if(e.burnished&&(window.carats.ssp.for!==n||e.recast)){let l=`/culet${n}`;a=await fetch(l).then(w=>w.json()),window.carats.ssp.data=a,window.carats.ssp.for=n}else a=window.carats.ssp.data;let o="";e.head&&(o=d(e.head)),window.carats.crown?document.head.innerHTML=document.head.innerHTML.replace(window.carats.crown,o):document.head.innerHTML+=o,window.carats.crown=o;let c=await m.call(r,e,a);document.getElementById("app").innerHTML=c}catch(e){document.getElementById("app").innerHTML=d(t.error(e))}finally{clearTimeout(s),window.dispatchEvent(new Event("load")),document.getElementById("loading-indicator")?.classList.add("hide")}}function H(t){if(new URL(t,location.origin).origin!==location.origin){window.location.href=t;return}history.pushState(null,"",t),i()}function T(t){g(),window.carats||(window.carats={ssp:{for:void 0,data:null}}),r=t;let{inAppRouting:n=!0}=t;n&&(window.addEventListener("load",()=>{document.querySelectorAll("a").forEach(e=>{e._isHandled||new URL(e.href,location.origin).origin!==location.origin||e.download||(e.addEventListener("click",o=>{o.preventDefault(),history.pushState(null,"",e.href),i()}),e._isHandled=!0)})}),window.addEventListener("popstate",i))}export{i as clientRender,H as goTo,T as mount};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@carats/csr",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "main": "dist/index.js",
5
5
  "dependencies": {
6
6
  "jjsx": "^3.3.0"
7
7
  },
8
8
  "peerDependencies": {
9
9
  "@carats/hooks": "^0.0.2",
10
- "@carats/render": "^0.0.8",
10
+ "@carats/render": "^0.0.10",
11
11
  "@carats/url": "^0.0.1"
12
12
  },
13
13
  "description": "CSR module for Carats",