@carats/csr 0.0.6 → 0.0.7
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.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{renderPage as s}from"@carats/core";import{clearHydrations as c}from"@carats/hooks";import{transpile as u,init as m}from"jjsx";m();function g(o){let{suspense:
|
|
1
|
+
import{renderPage as s}from"@carats/core";import{clearHydrations as c}from"@carats/hooks";import{transpile as u,init as m}from"jjsx";m();function g(o){let{suspense:t,inAppRouting:d=!0}=o;t.loading=t.loading??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Loading...")),t.error=t.error??(r=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Error: ",r.message)),t.notFound=t.notFound??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Not Found"));async function a(){let r=location.pathname+location.search,e=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await c();try{let n=await s.call(o,r,async i=>await fetch(i).then(l=>l.json()));document.getElementById("app").innerHTML=n}catch(n){document.getElementById("app").innerHTML=u(t.error(n))}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",n=>{history.pushState(null,"",e.href),!(new URL(e.href).origin!==location.origin||e.download)&&(n.preventDefault(),a())}),e._isHandled=!0)})}),{clientRender:a}}export{g as default};
|