@carats/render 0.0.5 → 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.d.ts CHANGED
@@ -1,15 +1,12 @@
1
1
  interface CaratsComponent<T = any> extends JSX.FunctionComponent<T> {
2
- ssp?: string;
3
2
  defaultProps?: T;
4
3
  head?: string;
4
+ burnished?: boolean;
5
5
  }
6
6
  interface Facets {
7
7
  inAppRouting?: boolean;
8
8
  routes: {
9
- [key: string]: {
10
- component: CaratsComponent;
11
- hallmark?: string;
12
- };
9
+ [key: string]: CaratsComponent;
13
10
  };
14
11
  suspense: {
15
12
  loading: () => JSX.Element;
@@ -20,9 +17,10 @@ interface Facets {
20
17
  interface PageComponentResult {
21
18
  component: CaratsComponent<any>;
22
19
  params: Record<string, string>;
23
- hallmark?: string;
20
+ route: string;
24
21
  }
25
- declare function getPageComponent(this: Facets, path: string): PageComponentResult;
22
+ declare function getPageComponent(this: Facets, url: string): PageComponentResult;
26
23
  declare function renderPage<T = any>(this: Facets, component: CaratsComponent<T>, props: T): Promise<string>;
24
+ declare function Burnish<T = any>(component: CaratsComponent<T>): CaratsComponent<T>;
27
25
 
28
- export { type CaratsComponent, type Facets, getPageComponent, renderPage };
26
+ export { Burnish, type CaratsComponent, type Facets, type PageComponentResult, getPageComponent, renderPage };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{matchRoute as c}from"@carats/url";import{transpile as p}from"jjsx";function d(n){let{routes:e,suspense:t}=this;for(let o in e){let{component:r,hallmark:i}=e[o],s=c(o,n);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${o}`;return r.then(m=>{document.getElementById(a)?.replaceWith(p(m))}).catch(m=>{document.getElementById(a)?.replaceWith(p(t.error(m)))}),JJSX.jsxFactory("div",{id:a},t.loading())},params:s,hallmark:i}:{component:r,params:s,hallmark:i}}return{component:t.notFound,params:{}}}async function h(n,e){return p(n(e))}export{d as getPageComponent,h as renderPage};
1
+ import{matchRoute as u}from"@carats/url";import{transpile as i}from"jjsx";function l(e){let{routes:t,suspense:o}=this,m=new URL(e,"http://localhost").pathname;for(let n in t){let r=t[n],s=u(n,m);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${n}`;return r.then(p=>{document.getElementById(a)?.replaceWith(i(p))}).catch(p=>{document.getElementById(a)?.replaceWith(i(o.error(p)))}),JJSX.jsxFactory("div",{id:a},o.loading())},params:s,route:n}:{component:r,params:s,route:n}}return{component:o.notFound,params:{},route:"/not-found"}}async function C(e,t){return i(e(t))}function g(e){return e.burnished=!0,e}export{g as Burnish,l as getPageComponent,C as renderPage};
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@carats/render",
3
- "version": "0.0.5",
4
- "description": "Render module for Carats",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": ["dist"],
8
- "type": "module",
9
- "scripts": {
10
- "prepublishOnly": "npm run build",
11
- "build": "tsup src/index.tsx --config ../../tsup.config.ts"
12
- },
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
- "peerDependencies": {
17
- "@carats/url": "^0.0.1",
18
- "jjsx": "^3.3.0"
19
- }
20
- }
1
+ {
2
+ "name": "@carats/render",
3
+ "version": "0.0.7",
4
+ "description": "Render module for Carats",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "type": "module",
9
+ "scripts": {
10
+ "prepublishOnly": "npm run build",
11
+ "build": "tsup src/index.tsx --config ../../tsup.config.ts"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "peerDependencies": {
17
+ "@carats/url": "^0.0.1",
18
+ "jjsx": "^3.3.0"
19
+ }
20
+ }