@carats/render 0.0.2 → 0.0.4

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
@@ -1,8 +1,9 @@
1
1
  interface CaratsComponent<T = any> extends JSX.FunctionComponent<T> {
2
2
  ssp?: string;
3
3
  defaultProps?: T;
4
+ head?: string;
4
5
  }
5
- interface CaratsRenderContext {
6
+ interface Facets {
6
7
  inAppRouting?: boolean;
7
8
  routes: Record<string, CaratsComponent>;
8
9
  suspense: {
@@ -15,7 +16,7 @@ interface PageComponentResult {
15
16
  component: CaratsComponent<any>;
16
17
  params: Record<string, string>;
17
18
  }
18
- declare function getPageComponent(this: CaratsRenderContext, path: string): PageComponentResult;
19
- declare function renderPage<T = any>(this: CaratsRenderContext, component: CaratsComponent<T>, props: T): Promise<string>;
19
+ declare function getPageComponent(this: Facets, path: string): PageComponentResult;
20
+ declare function renderPage<T = any>(this: Facets, component: CaratsComponent<T>, props: T): Promise<string>;
20
21
 
21
- export { type CaratsRenderContext, getPageComponent, renderPage };
22
+ export { type CaratsComponent, type Facets, getPageComponent, renderPage };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{matchRoute as i}from"@carats/url";import{transpile as m}from"jjsx";function C(n){let{routes:e,suspense:t}=this;for(let o in e){let r=e[o],s=i(o,n);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${o}`;return r.then(p=>{document.getElementById(a)?.replaceWith(m(p))}).catch(p=>{document.getElementById(a)?.replaceWith(m(t.error(p)))}),JJSX.jsxFactory("div",{id:a},t.loading())},params:s}:{component:r,params:s}}return{component:t.notFound,params:{}}}async function g(n,e){return m(n(e))}export{C as getPageComponent,g as renderPage};
1
+ import{matchRoute as i}from"@carats/url";import{transpile as m}from"jjsx";function g(n){let{routes:e,suspense:t}=this;for(let o in e){let r=e[o],s=i(o,n);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${o}`;return r.then(p=>{document.getElementById(a)?.replaceWith(m(p))}).catch(p=>{document.getElementById(a)?.replaceWith(m(t.error(p)))}),JJSX.jsxFactory("div",{id:a},t.loading())},params:s}:{component:r,params:s}}return{component:t.notFound,params:{}}}async function l(n,e){return m(n(e))}export{g as getPageComponent,l as renderPage};
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@carats/render",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Render module for Carats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": ["dist"],
8
8
  "type": "module",
9
9
  "scripts": {
10
+ "prepublishOnly": "npm run build",
10
11
  "build": "tsup src/index.tsx --config ../../tsup.config.ts"
11
12
  },
12
13
  "publishConfig": {