@carats/csr 0.0.1 → 0.0.2

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
@@ -4,7 +4,7 @@ interface PageComponentResult {
4
4
  component: CaratsComponent<any>;
5
5
  params: Record<string, string>;
6
6
  }
7
- declare function getPageComponent(path: string): Promise<PageComponentResult>;
7
+ declare function getPageComponent(path: string): PageComponentResult;
8
8
  declare function renderPage(url: string, fetcher: (sspUrl: string) => Promise<any>): Promise<string>;
9
9
 
10
10
  export { getPageComponent, renderPage };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{transpile as m}from"jjsx";import{getConfig as u}from"@carats/core";import{matchRoute as l,parseUrl as g,qs as d,replaceParams as f}from"@carats/url";async function P(s){let{routes:p,suspense:o}=await u(),r=Object.fromEntries(Object.entries(p).filter(([e,t])=>t.public));for(let e in r){let{component:t}=r[e],n=l(e,s);if(n)return t instanceof Promise?{component:()=>{let a=`carats-suspense-${e}`;return t.then(c=>{document.getElementById(a)?.replaceWith(m(c))}).catch(c=>{document.getElementById(a)?.replaceWith(m(o.error(c)))}),JJSX.jsxFactory("div",{id:a},o.loading({id:a}))},params:n}:{component:t,params:n}}return{component:o.notFound,params:{}}}async function R(s,p){let{path:o,query:r}=g(s),{component:e,params:t}=await P(o),n=e.ssp?f(e.ssp+d(r),t):null,i=n?await p(n):e.defaultProps||{url:s,params:t};return m(e(i))}export{P as getPageComponent,R as renderPage};
1
+ import{transpile as m}from"jjsx";import{getConfig as u}from"@carats/core";import{matchRoute as l,parseUrl as g,qs as d,replaceParams as f}from"@carats/url";function P(r){let{routes:p,suspense:o}=u(),s=Object.fromEntries(Object.entries(p).filter(([e,n])=>n.public));for(let e in s){let{component:n}=s[e],t=l(e,r);if(t)return n instanceof Promise?{component:()=>{let a=`carats-suspense-${e}`;return n.then(c=>{document.getElementById(a)?.replaceWith(m(c))}).catch(c=>{document.getElementById(a)?.replaceWith(m(o.error(c)))}),JJSX.jsxFactory("div",{id:a},o.loading({id:a}))},params:t}:{component:n,params:t}}return{component:o.notFound,params:{}}}async function R(r,p){let{path:o,query:s}=g(r),{component:e,params:n}=P(o),t=e.ssp?f(e.ssp+d(s),n):null,i=t?await p(t):e.defaultProps||{url:r,params:n};return m(e(i))}export{P as getPageComponent,R as renderPage};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@carats/csr",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "dependencies": {
6
6
  "jjsx": "^3.3.0"
7
7
  },
8
8
  "peerDependencies": {
9
- "@carats/core": "^0.0.2",
9
+ "@carats/core": "^0.0.3",
10
10
  "@carats/url": "^0.0.1"
11
11
  },
12
12
  "description": "CSR module for Carats",