@carats/csr 0.0.16 → 0.0.18

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