@carats/render 0.0.11 → 0.0.13

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,6 +4,7 @@ interface CaratsComponent<T = any> extends JSX.FunctionComponent<T> {
4
4
  burnished?: boolean;
5
5
  recast?: boolean;
6
6
  }
7
+ type CaratsComponentWithThis<T = any> = ((this: CaratsComponent<T>, props: T) => JSX.Element) & CaratsComponent<T>;
7
8
  interface Facets {
8
9
  inAppRouting?: boolean;
9
10
  routes: Record<string, CaratsComponent>;
@@ -29,6 +30,7 @@ declare function renderPage<T = any>(this: Facets, component: CaratsComponent<T>
29
30
  interface BurnishOptions {
30
31
  recast?: boolean;
31
32
  }
32
- declare function Burnish<T = any>(this: CaratsComponent<T>, component: CaratsComponent<T>, options?: BurnishOptions): CaratsComponent<T>;
33
+ declare function Burnish<T = any>(component: CaratsComponentWithThis<T>, options?: BurnishOptions): CaratsComponentWithThis<T>;
34
+ declare function Burnish<T = any>(component: CaratsComponent<T>, options?: BurnishOptions): CaratsComponent<T>;
33
35
 
34
- export { Burnish, type CaratsComponent, type Facets, type PageComponentResult, defineFacets, getPageComponent, renderPage };
36
+ export { Burnish, type CaratsComponent, type CaratsComponentWithThis, type Facets, type PageComponentResult, defineFacets, getPageComponent, renderPage };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{matchRoute as c}from"@carats/url";import{transpile as u}from"jjsx";function g(e){return{inAppRouting:e.inAppRouting??!0,routes:e.routes??{},suspense:{loading:e.suspense?.loading??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Loading...")),error:e.suspense?.error??(n=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Error: ",n.message)),notFound:e.suspense?.notFound??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Not Found"))}}}function C(e){let{routes:n,suspense:o}=this,p=new URL(e,"http://localhost").pathname;for(let t in n){let r=n[t],s=c(t,p);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${t}`;return r.then(i=>{document.getElementById(a)?.replaceWith(u(i))}).catch(i=>{document.getElementById(a)?.replaceWith(u(o.error(i)))}),JJSX.jsxFactory("div",{id:a},o.loading())},params:s,route:t}:{component:r,params:s,route:t}}return{component:o.notFound,params:{},route:"/not-found"}}async function h(e,n){return u(e.call(e,n))}function f(e,n){return e.burnished=!0,n?.recast&&(e.recast=!0),e.bind(e)}export{f as Burnish,g as defineFacets,C as getPageComponent,h as renderPage};
1
+ import{matchRoute as m}from"@carats/url";import{transpile as p}from"jjsx";function d(n){return{inAppRouting:n.inAppRouting??!0,routes:n.routes??{},suspense:{loading:n.suspense?.loading??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Loading...")),error:n.suspense?.error??(t=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Error: ",t.message)),notFound:n.suspense?.notFound??(()=>JJSX.jsxFactory(JJSX.fragmentFactory,null,"\u{1F48E} Not Found"))}}}function l(n){let{routes:t,suspense:o}=this,u=new URL(n,"http://localhost").pathname;for(let e in t){let r=t[e],s=m(e,u);if(s)return r instanceof Promise?{component:()=>{let a=`carats-suspense-${e}`;return r.then(i=>{document.getElementById(a)?.replaceWith(p(i))}).catch(i=>{document.getElementById(a)?.replaceWith(p(o.error(i)))}),JJSX.jsxFactory("div",{id:a},o.loading())},params:s,route:e}:{component:r,params:s,route:e}}return{component:o.notFound,params:{},route:"/not-found"}}async function g(n,t){return p(n.call(n,t))}function T(n,t){return n.burnished=!0,t?.recast&&(n.recast=!0),n}export{T as Burnish,d as defineFacets,l as getPageComponent,g as renderPage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carats/render",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Render module for Carats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",