@carats/csr 0.0.5 → 0.0.6
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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 m}from"jjsx";function
|
|
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:e,inAppRouting:d=!0}=o;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"));async function a(){let n=location.pathname+location.search,t=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await c();try{let r=await s.call(o,n,async i=>await fetch(i).then(l=>l.json()));document.getElementById("app").innerHTML=r}catch(r){document.getElementById("app").innerHTML=u(e.error(r))}finally{clearTimeout(t),history.pushState(null,"",n),window.dispatchEvent(new Event("load")),document.getElementById("loading-indicator")?.classList.add("hide")}}return d&&window.addEventListener("load",()=>{document.querySelectorAll("a").forEach(t=>{t._isHandled||(t.addEventListener("click",r=>{new URL(t.href).origin!==location.origin||t.download||(r.preventDefault(),a())}),t._isHandled=!0)})}),{clientRender:a}}export{g as default};
|