@carats/csr 0.0.14 → 0.0.15

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +24 -24
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{clearHydrations as f}from"@carats/hooks";import{getPageComponent as w,renderPage as g}from"@carats/render";import{init as h,transpile as E}from"jjsx";window.ssp||(window.ssp={for:void 0,data:null});function y(o,i){let e=o.split("/").pop()?.replace(".cara","").replace(".ts","");return i===e}async function L(o){h();let i=await fetch("/.carats/hallmarks").then(t=>t.json()),{suspense:e,inAppRouting:p=!0}=o;e.loading=e.loading??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Loading...")),e.error=e.error??(t=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Error: ",t.message)),e.notFound=e.notFound??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Not Found"));async function d(){let t=location.pathname+location.search,n=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await f();try{let{component:a,params:c,hallmark:s}=w.call(o,location.pathname),r=window.ssp.data;if(window.ssp.for!==s&&(r=a.defaultProps||{url:t,params:c},i.some(l=>y(l,s)))){let l=`/api${t}`;r=await fetch(l).then(u=>u.json()),window.ssp.data=r,window.ssp.for=s}let m=await g.call(o,a,r);document.getElementById("app").innerHTML=m}catch(a){document.getElementById("app").innerHTML=E(e.error(a))}finally{clearTimeout(n),window.dispatchEvent(new Event("load")),document.getElementById("loading-indicator")?.classList.add("hide")}}return p&&window.addEventListener("load",()=>{document.querySelectorAll("a").forEach(n=>{n._isHandled||(n.addEventListener("click",a=>{history.pushState(null,"",n.href),!(new URL(n.href).origin!==location.origin||n.download)&&(a.preventDefault(),d())}),n._isHandled=!0)})}),{clientRender:d}}export{L as default};
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(a){f();let{suspense:n,inAppRouting:d=!0}=a;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 i(){let o=location.pathname+location.search,e=setTimeout(()=>document.getElementById("loading-indicator")?.classList.remove("hide"),250);await u();try{let{component:t}=p.call(a,location.pathname),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(a,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(),i())}),e._isHandled=!0)})}),{clientRender:i}}export{g as default};
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
- {
2
- "name": "@carats/csr",
3
- "version": "0.0.14",
4
- "main": "dist/index.js",
5
- "dependencies": {
6
- "jjsx": "^3.3.0"
7
- },
8
- "peerDependencies": {
9
- "@carats/hooks": "^0.0.2",
10
- "@carats/render": "^0.0.5",
11
- "@carats/url": "^0.0.1"
12
- },
13
- "description": "CSR module for Carats",
14
- "files": ["dist"],
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "scripts": {
19
- "prepublishOnly": "npm run build",
20
- "build": "tsup src/index.tsx --config ../../tsup.config.ts"
21
- },
22
- "type": "module",
23
- "types": "dist/index.d.ts"
24
- }
1
+ {
2
+ "name": "@carats/csr",
3
+ "version": "0.0.15",
4
+ "main": "dist/index.js",
5
+ "dependencies": {
6
+ "jjsx": "^3.3.0"
7
+ },
8
+ "peerDependencies": {
9
+ "@carats/hooks": "^0.0.2",
10
+ "@carats/render": "^0.0.6",
11
+ "@carats/url": "^0.0.1"
12
+ },
13
+ "description": "CSR module for Carats",
14
+ "files": ["dist"],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "prepublishOnly": "npm run build",
20
+ "build": "tsup src/index.tsx --config ../../tsup.config.ts"
21
+ },
22
+ "type": "module",
23
+ "types": "dist/index.d.ts"
24
+ }