@carats/ssr 0.0.9 → 0.0.10

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,4 +1,4 @@
1
- import { CaratsRequest, Culet } from '@carats/core';
1
+ import { CaratsRequest } from '@carats/core';
2
2
  import { Facets } from '@carats/render';
3
3
 
4
4
  interface CaratsServerEntry {
@@ -10,7 +10,14 @@ interface CaratsServerEntry {
10
10
  facets: Facets;
11
11
  culets: Record<string, Culet>;
12
12
  }
13
+ type CuletArgs<B = Object> = CaratsRequest<B> & {
14
+ params: Record<string, string>;
15
+ };
16
+ type Culet<I = any, O = any> = ((request: CuletArgs<I>) => O) & {
17
+ __isCulet__?: true;
18
+ };
19
+ declare function culet(culet: Culet): Culet;
13
20
  declare function culet(route: string, culet: Culet): Culet;
14
21
  declare function defineServerEntry(facets: Facets): CaratsServerEntry;
15
22
 
16
- export { type CaratsServerEntry, culet, defineServerEntry };
23
+ export { type CaratsServerEntry, type Culet, type CuletArgs, culet, defineServerEntry };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{getPageComponent as p,renderPage as C}from"@carats/render";import{parseUrl as d}from"@carats/url";import{init as f,transpile as P}from"jjsx";var a={};function w(r,e){return a[r]=e,e}function E(r){f();async function e(t,c){let{component:o,params:i,route:n}=c||p.call(r,t.url.replace("/culet",""));return a[n]?await a[n]({...t,params:i}):o.defaultProps}async function l(t){let{suspense:{error:c}}=r,o=p.call(r,t.url),{path:i}=d(t.url),n=await e(t,o),{component:u}=o,s=u.head||"";s+=`
2
- <script>window.ssp=${JSON.stringify({for:i,data:n})}</script>`,s=s.trim();let m=await C.call(r,u,n);try{return{html:m,head:s}}catch(g){return{html:P(c(g)),head:s}}}return{render:l,getServerProps:e,facets:r,culets:a}}export{w as culet,E as defineServerEntry};
1
+ import{getPageComponent as l,renderPage as g}from"@carats/render";import{parseUrl as f}from"@carats/url";import{init as d,transpile as y}from"jjsx";var a={};function x(t,r){if(typeof t=="string")return a[t]=r,r.__isCulet__=!0,r;if(!t.__isCulet__)throw new Error("Invalid culet");return t}function q(t){d();async function r(e,u){let{component:o,params:i,route:n}=u||l.call(t,e.url.replace("/culet",""));return a[n]?await a[n]({...e,params:i}):o.defaultProps}async function p(e){let{suspense:{error:u}}=t,o=l.call(t,e.url),{path:i}=f(e.url),n=await r(e,o),{component:c}=o,s=c.head||"";s+=`
2
+ <script>window.ssp=${JSON.stringify({for:i,data:n})}</script>`,s=s.trim();let C=await g.call(t,c,n);try{return{html:C,head:s}}catch(m){return{html:y(u(m)),head:s}}}return{render:p,getServerProps:r,facets:t,culets:a}}export{x as culet,q as defineServerEntry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carats/ssr",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "SSR module for Carats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "peerDependencies": {
17
- "@carats/core": "^0.0.13",
17
+ "@carats/core": "^0.0.14",
18
18
  "@carats/render": "^0.0.7",
19
19
  "jjsx": "^3.3.0",
20
20
  "vite": "^8.0.2"