@carats/ssr 0.0.2 → 0.0.3

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
@@ -2,7 +2,6 @@ import { CaratsRequest, Hallmark } from '@carats/core';
2
2
  import { Facets } from '@carats/render';
3
3
 
4
4
  interface CaratsServerEntry {
5
- getApiData: <T = any>(req: CaratsRequest) => Promise<T>;
6
5
  render: (req: CaratsRequest) => Promise<{
7
6
  html?: string;
8
7
  head?: string;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{getPageComponent as d,renderPage as f}from"@carats/render";import{matchRoute as h,parseUrl as c,qs as g,replaceParams as P}from"@carats/url";import{init as y,transpile as C}from"jjsx";function R(o,p){y();async function u(r){let{path:n}=c(r.url);for(let[i,t]of Object.entries(p)){let a=h(i,n);if(a)return await t({params:a,url:r.url,cookies:r.cookies,headers:r.headers,method:r.method,data:r.data})}return{_status:404,error:"API endpoint not found"}}async function m(r){let{suspense:{error:n}}=o,{query:i}=c(r.url),{component:t,params:a}=d.call(o,r.url),e=t.defaultProps||{url:r.url,params:a},s="";if(t.ssp){let l=P(t.ssp+g(i),a);e=await u(r),s=e.head||"",s+=`
2
- <script>window.ssp=${JSON.stringify({for:l,data:e})}</script>`}try{return{html:await f.call(o,t,e),head:s}}catch(l){return{html:C(n(l)),head:s}}}return{getApiData:u,render:m}}export{R as default};
1
+ import{getPageComponent as u,renderPage as f}from"@carats/render";import{init as g,transpile as y}from"jjsx";function h(a,n){g();async function m(o){let{suspense:{error:p}}=a,{component:e,params:c}=u.call(a,o.url),i={...o,params:c},s=e.defaultProps||i,r="",l=Object.keys(n).find(t=>t.endsWith(`${e.name}.api.ts`));l&&(s=await n[l].default(i),r=e.head||"",r+=`
2
+ <script>window.ssp=${JSON.stringify({for:e.name,data:s})}</script>`,r=r.trim());let d=await f.call(a,e,s);try{return{html:d,head:r}}catch(t){return{html:y(p(t)),head:r}}}return{render:m}}export{h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carats/ssr",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "SSG module for Carats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,9 +14,8 @@
14
14
  "access": "public"
15
15
  },
16
16
  "peerDependencies": {
17
- "@carats/core": "^0.0.10",
18
- "@carats/render": "^0.0.1",
19
- "@carats/url": "^0.0.1",
17
+ "@carats/core": "^0.0.11",
18
+ "@carats/render": "^0.0.4",
20
19
  "jjsx": "^3.3.0",
21
20
  "vite": "^8.0.2"
22
21
  }