@chaibuilder/sdk 2.2.0 → 2.2.2

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/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./chai-theme-helpers-BjWE6otR.cjs"),n=require("lodash-es"),R=require("@mhsdesign/jit-browser-tailwindcss"),O=require("@tailwindcss/aspect-ratio"),F=require("@tailwindcss/container-queries"),L=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),C=require("./plugin-BiiuylVf.cjs"),u=require("react/jsx-runtime"),P=require("@chaibuilder/runtime"),f=require("react"),N=require("tailwind-merge"),p=require("./getSplitClasses-DodqA_KW.cjs"),A=e=>{if(!e)return[];try{return JSON.parse(I(e)).filter(t=>!t._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function I(e){const i=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(i,t=>{const s=decodeURIComponent(t),a=s.indexOf("public");return a!==-1?s.substring(a+6):s})}async function J(e,i,t=[],s="",a){return await R.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:t,theme:{extend:C.getChaiBuilderTheme(e)},plugins:[L,M,O,F,C.chaiBuilderPlugin],corePlugins:{preflight:a},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${a?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./chai-theme-helpers-BjWE6otR.cjs"),n=require("lodash-es"),$=require("@mhsdesign/jit-browser-tailwindcss"),R=require("@tailwindcss/aspect-ratio"),O=require("@tailwindcss/container-queries"),F=require("@tailwindcss/forms"),L=require("@tailwindcss/typography"),C=require("./plugin-BiiuylVf.cjs"),u=require("react/jsx-runtime"),E=require("@chaibuilder/runtime"),f=require("react"),M=require("tailwind-merge"),m=require("./getSplitClasses-DodqA_KW.cjs"),N=e=>{if(!e)return[];try{return JSON.parse(A(e)).filter(t=>!t._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function A(e){const i=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(i,t=>{const s=decodeURIComponent(t),a=s.indexOf("public");return a!==-1?s.substring(a+6):s})}async function I(e,i,t=[],s="",a){return await $.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:t,theme:{extend:C.getChaiBuilderTheme(e)},plugins:[F,L,R,O,C.chaiBuilderPlugin],corePlugins:{preflight:a},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${a?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,i)}const V=(e,i,t)=>{const s=JSON.stringify(e).replace(/#styles:([^"]*)/g,(a,c)=>`#styles:${c.replace(/,/g," ")}`.replace(/#styles:/g,""));return J(i,[s],[],"",t)},Y=async(e,i=m.defaultThemeOptions,t=!1)=>await V(e,i,t);async function K(e){const i=e.forwardProps?await e.dataProvider({...e.forwardProps,...e.block,lang:e.lang,draft:e.draft,inBuilder:e.inBuilder}):await e.dataProvider(e.block,e.lang,e.metadata??{});return n.has(i,"$metadata")&&e.dataProviderMetadataCallback(e.block,i.$metadata),u.jsx(f.Suspense,{children:f.createElement(e.component,{...n.omit(e.props,["dataProvider","dataProviderMetadataCallback"]),...n.omit(i,"$metadata"),key:`${e.block._id}-async`})})}const z=n.memoize(e=>{const{baseClasses:i,classes:t}=p.getSplitChaiClasses(e);return N.twMerge(i,t).replace(p.STYLES_KEY,"").trim()}),T=(e,i)=>{const t=n.cloneDeep(e);return n.forEach(n.keys(t),s=>{if(n.isString(t[s])){let a=t[s];const c=/\{\{(.*?)\}\}/g,l=a.match(c);l&&l.forEach(o=>{const d=o.slice(2,-2),h=n.get(i,d,o);a=a.replace(o,h)}),t[s]=a}n.isObject(t[s])&&(t[s]=T(t[s],i))}),t};function U(e,i){const t=n.get(e,`${i}_attrs`,{}),s=n.keys(t).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(t["x-transition"]=""),t}function W(e){const i={};return Object.keys(e).forEach(t=>{if(n.isString(e[t])&&e[t].startsWith(p.STYLES_KEY)){const s=z(e[t]);i[t]={className:s,...U(e,t)}}}),i}function D(e,i,t){if(n.isEmpty(i))return e;const s=n.cloneDeep(e),a=n.get(t,"i18nProps",[]);return n.forEach(n.keys(s),c=>{a.includes(c)&&!n.isEmpty(i)&&(s[c]=n.get(s,`${c}-${i}`,s[c]))}),s}const H=n.memoize(e=>{const i=P.getRegisteredChaiBlock(e),t=n.get(i,"schema.properties",{});return Object.fromEntries(Object.entries(t).filter(([,s])=>n.get(s,"runtime",!1)))}),G=(e,i,t)=>n.isEmpty(t)?{}:Object.entries(t).reduce((s,[a,c])=>{const l=[];let o=n.find(e,{_id:i});for(;o;)l.push(o),o=n.find(e,{_id:o._parent});const d=n.find(l,{_type:c.block});return d&&(s[a]=n.get(d,n.get(c,"prop"),null)),s},{}),Q=()=>u.jsx("span",{children:"Loading..."});function X(e){n.has(e,"metadata")&&console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead");const i=e.lang??"en",t=e.fallbackLang??i;return u.jsx(j,{...e,lang:i,fallbackLang:t})}function j({blocks:e,parent:i,externalData:t={},lang:s="en",fallbackLang:a="en",metadata:c={},forwardProps:l={},dataProviderMetadataCallback:o=()=>{},draft:d=!1}){const h=e,x=r=>W(r),E=i?n.filter(e,{_parent:i}):n.filter(e,r=>n.isEmpty(r._parent));return n.uniqBy(E,"_id").map((r,b)=>{const S={},k=n.filter(h,{_parent:r._id});S.children=k.length>0?u.jsx(j,{externalData:t,parent:r._id,blocks:h,lang:s,fallbackLang:a,forwardProps:l,dataProviderMetadataCallback:o,draft:d,metadata:c},`${r._id}-children`):null;const g=P.getRegisteredChaiBlock(r._type);if(g!==null){let y=r;const _=g.component;y={...g.defaults,...r};const v=s===a?"":s,$=G(h,r._id,H(r._type)),w=T(D(r,v,g),t),B=n.omit({...l,...y,...w,...x(w),...S,...$,index:b,lang:s,key:r._id,draft:d,blockProps:{},inBuilder:!1},["_parent"]);if(n.has(g,"dataProvider")){const q=n.get(g,"suspenseFallback",Q);return u.jsx(f.Suspense,{fallback:f.createElement(q),children:u.jsx(K,{inBuilder:!1,dataProviderMetadataCallback:o,lang:s,metadata:c,dataProvider:g.dataProvider,block:r,component:_,props:B,forwardProps:l,draft:d},`${r._id}-async`)},`${r._id}-suspense`)}return u.jsx(f.Suspense,{children:f.createElement(_,B)},`${r._id}-suspense`)}return u.jsxs("noscript",{children:[r._type," not found"]},`${r._id}-noscript`)})}exports.getChaiThemeCssVariables=m.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=m.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=m.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=X;exports.convertToBlocks=A;exports.getStylesForBlocks=Y;
3
+ @tailwind utilities;`,i)}const J=(e,i,t)=>{const s=JSON.stringify(e).replace(/#styles:([^"]*)/g,(a,c)=>`#styles:${c.replace(/,/g," ")}`.replace(/#styles:/g,""));return I(i,[s],[],"",t)},V=async(e,i=p.defaultThemeOptions,t=!1)=>await J(e,i,t);async function Y(e){const i=await e.dataProvider({pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:e.inBuilder});return n.has(i,"$metadata")&&e.dataProviderMetadataCallback(e.block,i.$metadata),u.jsx(f.Suspense,{children:f.createElement(e.component,{...n.omit(e.props,["dataProvider","dataProviderMetadataCallback"]),...n.omit(i,"$metadata"),key:`${e.block._id}-async`})})}const K=n.memoize(e=>{const{baseClasses:i,classes:t}=m.getSplitChaiClasses(e);return M.twMerge(i,t).replace(m.STYLES_KEY,"").trim()}),P=(e,i)=>{const t=n.cloneDeep(e);return n.forEach(n.keys(t),s=>{if(n.isString(t[s])){let a=t[s];const c=/\{\{(.*?)\}\}/g,l=a.match(c);l&&l.forEach(o=>{const d=o.slice(2,-2),h=n.get(i,d,o);a=a.replace(o,h)}),t[s]=a}n.isObject(t[s])&&(t[s]=P(t[s],i))}),t};function z(e,i){const t=n.get(e,`${i}_attrs`,{}),s=n.keys(t).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(t["x-transition"]=""),t}function U(e){const i={};return Object.keys(e).forEach(t=>{if(n.isString(e[t])&&e[t].startsWith(m.STYLES_KEY)){const s=K(e[t]);i[t]={className:s,...z(e,t)}}}),i}function W(e,i,t){if(n.isEmpty(i))return e;const s=n.cloneDeep(e),a=n.get(t,"i18nProps",[]);return n.forEach(n.keys(s),c=>{a.includes(c)&&!n.isEmpty(i)&&(s[c]=n.get(s,`${c}-${i}`,s[c]))}),s}const D=n.memoize(e=>{const i=E.getRegisteredChaiBlock(e),t=n.get(i,"schema.properties",{});return Object.fromEntries(Object.entries(t).filter(([,s])=>n.get(s,"runtime",!1)))}),H=(e,i,t)=>n.isEmpty(t)?{}:Object.entries(t).reduce((s,[a,c])=>{const l=[];let o=n.find(e,{_id:i});for(;o;)l.push(o),o=n.find(e,{_id:o._parent});const d=n.find(l,{_type:c.block});return d&&(s[a]=n.get(d,n.get(c,"prop"),null)),s},{}),G=()=>u.jsx("span",{children:"Loading..."});function Q(e){if(n.has(e,"metadata")&&console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead"),n.isEmpty(e.lang)&&!n.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");const i=e.lang??"en",t=e.fallbackLang??i;return u.jsx(T,{...e,lang:i,fallbackLang:t})}function T({blocks:e,parent:i,externalData:t={},lang:s="en",fallbackLang:a="en",pageProps:c={},dataProviderMetadataCallback:l=()=>{},draft:o=!1}){const d=e,h=r=>U(r),b=i?n.filter(e,{_parent:i}):n.filter(e,r=>n.isEmpty(r._parent));return n.uniqBy(b,"_id").map((r,k)=>{const S={},j=n.filter(d,{_parent:r._id});S.children=j.length>0?u.jsx(T,{externalData:t,parent:r._id,blocks:d,lang:s,fallbackLang:a,pageProps:c,dataProviderMetadataCallback:l,draft:o},`${r._id}-children`):null;const g=E.getRegisteredChaiBlock(r._type);if(g!==null){let y=r;const w=g.component;y={...g.defaults,...r};const x=s===a?"":s,v=H(d,r._id,D(r._type)),_=P(W(r,x,g),t),B=n.omit({...y,..._,...h(_),...S,...v,index:k,lang:s,key:r._id,draft:o,pageProps:c,blockProps:{},inBuilder:!1},["_parent"]);if(n.has(g,"dataProvider")){const q=n.get(g,"suspenseFallback",G);return u.jsx(f.Suspense,{fallback:f.createElement(q),children:u.jsx(Y,{inBuilder:!1,dataProviderMetadataCallback:l,lang:s,pageProps:c,dataProvider:g.dataProvider,block:r,component:w,props:B,draft:o},`${r._id}-async`)},`${r._id}-suspense`)}return u.jsx(f.Suspense,{children:f.createElement(w,B)},`${r._id}-suspense`)}return u.jsxs("noscript",{children:[r._type," not found"]},`${r._id}-noscript`)})}exports.getChaiThemeCssVariables=p.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=p.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=p.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=Q;exports.convertToBlocks=N;exports.getStylesForBlocks=V;
package/dist/render.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ChaiFontViaUrl } from '@chaibuilder/runtime';
2
+ import { ChaiPageProps } from '@chaibuilder/runtime';
2
3
  import { JSX as JSX_2 } from 'react/jsx-runtime';
3
4
 
4
5
  declare type BorderRadiusValue = false | string;
@@ -59,6 +60,7 @@ declare type RenderChaiBlocksProps = {
59
60
  lang?: string;
60
61
  fallbackLang?: string;
61
62
  forwardProps?: Record<string, any>;
63
+ pageProps?: ChaiPageProps;
62
64
  draft?: boolean;
63
65
  dataProviderMetadataCallback?: (block: ChaiBlock, meta: Record<string, any>) => void;
64
66
  metadata?: Record<string, any>;
package/dist/render.js CHANGED
@@ -1,211 +1,205 @@
1
- import { d as U } from "./chai-theme-helpers-FO9vdd-R.js";
2
- import { a as ke, b as Fe, c as Ne } from "./chai-theme-helpers-FO9vdd-R.js";
3
- import { has as S, omit as _, memoize as x, get as l, filter as p, isEmpty as g, uniqBy as W, cloneDeep as O, forEach as T, keys as y, isString as E, isObject as Y, find as h, includes as v } from "lodash-es";
4
- import { createTailwindcss as q } from "@mhsdesign/jit-browser-tailwindcss";
5
- import z from "@tailwindcss/aspect-ratio";
6
- import D from "@tailwindcss/container-queries";
7
- import G from "@tailwindcss/forms";
8
- import H from "@tailwindcss/typography";
9
- import { g as Q, c as X } from "./plugin-B09c0d5S.js";
10
- import { jsx as m, jsxs as Z } from "react/jsx-runtime";
11
- import { getRegisteredChaiBlock as R } from "@chaibuilder/runtime";
12
- import j, { Suspense as w, createElement as ee } from "react";
13
- import { twMerge as te } from "tailwind-merge";
14
- import { g as ne, S as k } from "./getSplitClasses-DphwgQiE.js";
15
- const Oe = (e) => {
1
+ import { d as q } from "./chai-theme-helpers-FO9vdd-R.js";
2
+ import { a as Re, b as je, c as Fe } from "./chai-theme-helpers-FO9vdd-R.js";
3
+ import { has as S, omit as _, memoize as x, get as c, isEmpty as m, filter as g, uniqBy as K, cloneDeep as E, forEach as O, keys as y, isString as T, isObject as U, find as h, includes as v } from "lodash-es";
4
+ import { createTailwindcss as W } from "@mhsdesign/jit-browser-tailwindcss";
5
+ import Y from "@tailwindcss/aspect-ratio";
6
+ import z from "@tailwindcss/container-queries";
7
+ import D from "@tailwindcss/forms";
8
+ import G from "@tailwindcss/typography";
9
+ import { g as H, c as Q } from "./plugin-B09c0d5S.js";
10
+ import { jsx as f, jsxs as X } from "react/jsx-runtime";
11
+ import { getRegisteredChaiBlock as k } from "@chaibuilder/runtime";
12
+ import R, { Suspense as w, createElement as Z } from "react";
13
+ import { twMerge as ee } from "tailwind-merge";
14
+ import { g as te, S as j } from "./getSplitClasses-DphwgQiE.js";
15
+ const xe = (e) => {
16
16
  if (!e) return [];
17
17
  try {
18
- return JSON.parse(se(e)).filter((t) => !t._type.startsWith("@chai"));
18
+ return JSON.parse(ne(e)).filter((t) => !t._type.startsWith("@chai"));
19
19
  } catch {
20
20
  return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
21
21
  }
22
22
  };
23
- function se(e) {
23
+ function ne(e) {
24
24
  const s = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
25
25
  return e.replace(s, (t) => {
26
- const n = decodeURIComponent(t), r = n.indexOf("public");
27
- return r !== -1 ? n.substring(r + 6) : n;
26
+ const n = decodeURIComponent(t), i = n.indexOf("public");
27
+ return i !== -1 ? n.substring(i + 6) : n;
28
28
  });
29
29
  }
30
- async function ie(e, s, t = [], n = "", r) {
31
- return await q({
30
+ async function se(e, s, t = [], n = "", i) {
31
+ return await W({
32
32
  tailwindConfig: {
33
33
  darkMode: "class",
34
34
  safelist: t,
35
- theme: { extend: Q(e) },
36
- plugins: [G, H, z, D, X],
37
- corePlugins: { preflight: r },
35
+ theme: { extend: H(e) },
36
+ plugins: [D, G, Y, z, Q],
37
+ corePlugins: { preflight: i },
38
38
  ...n ? { prefix: `${n}` } : {}
39
39
  }
40
40
  }).generateStylesFromContent(
41
- ` ${r ? "@tailwind base;" : ""}
41
+ ` ${i ? "@tailwind base;" : ""}
42
42
  @tailwind components;
43
43
  @tailwind utilities;`,
44
44
  s
45
45
  );
46
46
  }
47
47
  const re = (e, s, t) => {
48
- const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (r, a) => `#styles:${a.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
49
- return ie(s, [n], [], "", t);
50
- }, Te = async (e, s = U, t = !1) => await re(e, s, t);
51
- async function ae(e) {
52
- const s = e.forwardProps ? await e.dataProvider({
53
- ...e.forwardProps,
54
- ...e.block,
48
+ const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, a) => `#styles:${a.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
49
+ return se(s, [n], [], "", t);
50
+ }, Ee = async (e, s = q, t = !1) => await re(e, s, t);
51
+ async function ie(e) {
52
+ const s = await e.dataProvider({
53
+ pageProps: e.pageProps,
54
+ block: e.block,
55
55
  lang: e.lang,
56
56
  draft: e.draft,
57
57
  inBuilder: e.inBuilder
58
- }) : await e.dataProvider(
59
- e.block,
60
- e.lang,
61
- e.metadata ?? {}
62
- );
63
- return S(s, "$metadata") && e.dataProviderMetadataCallback(e.block, s.$metadata), /* @__PURE__ */ m(w, { children: j.createElement(e.component, {
58
+ });
59
+ return S(s, "$metadata") && e.dataProviderMetadataCallback(e.block, s.$metadata), /* @__PURE__ */ f(w, { children: R.createElement(e.component, {
64
60
  ..._(e.props, ["dataProvider", "dataProviderMetadataCallback"]),
65
61
  ..._(s, "$metadata"),
66
62
  key: `${e.block._id}-async`
67
63
  }) });
68
64
  }
69
- const oe = x((e) => {
70
- const { baseClasses: s, classes: t } = ne(e);
71
- return te(s, t).replace(k, "").trim();
65
+ const ae = x((e) => {
66
+ const { baseClasses: s, classes: t } = te(e);
67
+ return ee(s, t).replace(j, "").trim();
72
68
  }), F = (e, s) => {
73
- const t = O(e);
74
- return T(y(t), (n) => {
75
- if (E(t[n])) {
76
- let r = t[n];
77
- const a = /\{\{(.*?)\}\}/g, c = r.match(a);
78
- c && c.forEach((o) => {
79
- const d = o.slice(2, -2), f = l(s, d, o);
80
- r = r.replace(o, f);
81
- }), t[n] = r;
69
+ const t = E(e);
70
+ return O(y(t), (n) => {
71
+ if (T(t[n])) {
72
+ let i = t[n];
73
+ const a = /\{\{(.*?)\}\}/g, l = i.match(a);
74
+ l && l.forEach((o) => {
75
+ const d = o.slice(2, -2), p = c(s, d, o);
76
+ i = i.replace(o, p);
77
+ }), t[n] = i;
82
78
  }
83
- Y(t[n]) && (t[n] = F(t[n], s));
79
+ U(t[n]) && (t[n] = F(t[n], s));
84
80
  }), t;
85
81
  };
86
- function ce(e, s) {
87
- const t = l(e, `${s}_attrs`, {}), n = y(t).join(" ");
82
+ function oe(e, s) {
83
+ const t = c(e, `${s}_attrs`, {}), n = y(t).join(" ");
88
84
  return v(n, "x-show") && !v(n, "x-transition") && (t["x-transition"] = ""), t;
89
85
  }
90
- function le(e) {
86
+ function ce(e) {
91
87
  const s = {};
92
88
  return Object.keys(e).forEach((t) => {
93
- if (E(e[t]) && e[t].startsWith(k)) {
94
- const n = oe(e[t]);
89
+ if (T(e[t]) && e[t].startsWith(j)) {
90
+ const n = ae(e[t]);
95
91
  s[t] = {
96
92
  className: n,
97
- ...ce(e, t)
93
+ ...oe(e, t)
98
94
  };
99
95
  }
100
96
  }), s;
101
97
  }
102
- function de(e, s, t) {
103
- if (g(s)) return e;
104
- const n = O(e), r = l(t, "i18nProps", []);
105
- return T(y(n), (a) => {
106
- r.includes(a) && !g(s) && (n[a] = l(n, `${a}-${s}`, n[a]));
98
+ function le(e, s, t) {
99
+ if (m(s)) return e;
100
+ const n = E(e), i = c(t, "i18nProps", []);
101
+ return O(y(n), (a) => {
102
+ i.includes(a) && !m(s) && (n[a] = c(n, `${a}-${s}`, n[a]));
107
103
  }), n;
108
104
  }
109
- const ue = x((e) => {
110
- const s = R(e), t = l(s, "schema.properties", {});
111
- return Object.fromEntries(Object.entries(t).filter(([, n]) => l(n, "runtime", !1)));
112
- }), me = (e, s, t) => g(t) ? {} : Object.entries(t).reduce((n, [r, a]) => {
113
- const c = [];
105
+ const de = x((e) => {
106
+ const s = k(e), t = c(s, "schema.properties", {});
107
+ return Object.fromEntries(Object.entries(t).filter(([, n]) => c(n, "runtime", !1)));
108
+ }), ue = (e, s, t) => m(t) ? {} : Object.entries(t).reduce((n, [i, a]) => {
109
+ const l = [];
114
110
  let o = h(e, { _id: s });
115
111
  for (; o; )
116
- c.push(o), o = h(e, { _id: o._parent });
117
- const d = h(c, { _type: a.block });
118
- return d && (n[r] = l(d, l(a, "prop"), null)), n;
119
- }, {}), fe = () => /* @__PURE__ */ m("span", { children: "Loading..." });
120
- function Ee(e) {
121
- S(e, "metadata") && console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead");
112
+ l.push(o), o = h(e, { _id: o._parent });
113
+ const d = h(l, { _type: a.block });
114
+ return d && (n[i] = c(d, c(a, "prop"), null)), n;
115
+ }, {}), fe = () => /* @__PURE__ */ f("span", { children: "Loading..." });
116
+ function Oe(e) {
117
+ if (S(e, "metadata") && console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead"), m(e.lang) && !m(e.fallbackLang))
118
+ throw new Error("lang prop is required when fallbackLang is provided");
122
119
  const s = e.lang ?? "en", t = e.fallbackLang ?? s;
123
- return /* @__PURE__ */ m(N, { ...e, lang: s, fallbackLang: t });
120
+ return /* @__PURE__ */ f(L, { ...e, lang: s, fallbackLang: t });
124
121
  }
125
- function N({
122
+ function L({
126
123
  blocks: e,
127
124
  parent: s,
128
125
  externalData: t = {},
129
126
  lang: n = "en",
130
- fallbackLang: r = "en",
131
- metadata: a = {},
132
- forwardProps: c = {},
133
- dataProviderMetadataCallback: o = () => {
127
+ fallbackLang: i = "en",
128
+ pageProps: a = {},
129
+ dataProviderMetadataCallback: l = () => {
134
130
  },
135
- draft: d = !1
131
+ draft: o = !1
136
132
  }) {
137
- const f = e, A = (i) => le(i), L = s ? p(e, { _parent: s }) : p(e, (i) => g(i._parent));
138
- return W(L, "_id").map((i, I) => {
139
- const B = {}, J = p(f, { _parent: i._id });
140
- B.children = J.length > 0 ? /* @__PURE__ */ m(
141
- N,
133
+ const d = e, p = (r) => ce(r), N = s ? g(e, { _parent: s }) : g(e, (r) => m(r._parent));
134
+ return K(N, "_id").map((r, A) => {
135
+ const B = {}, I = g(d, { _parent: r._id });
136
+ B.children = I.length > 0 ? /* @__PURE__ */ f(
137
+ L,
142
138
  {
143
139
  externalData: t,
144
- parent: i._id,
145
- blocks: f,
140
+ parent: r._id,
141
+ blocks: d,
146
142
  lang: n,
147
- fallbackLang: r,
148
- forwardProps: c,
149
- dataProviderMetadataCallback: o,
150
- draft: d,
151
- metadata: a
143
+ fallbackLang: i,
144
+ pageProps: a,
145
+ dataProviderMetadataCallback: l,
146
+ draft: o
152
147
  },
153
- `${i._id}-children`
148
+ `${r._id}-children`
154
149
  ) : null;
155
- const u = R(i._type);
150
+ const u = k(r._type);
156
151
  if (u !== null) {
157
- let P = i;
152
+ let P = r;
158
153
  const C = u.component;
159
- P = { ...u.defaults, ...i };
160
- const M = n === r ? "" : n, V = me(f, i._id, ue(i._type)), $ = F(de(i, M, u), t), b = _(
154
+ P = { ...u.defaults, ...r };
155
+ const J = n === i ? "" : n, M = ue(d, r._id, de(r._type)), b = F(le(r, J, u), t), $ = _(
161
156
  {
162
- ...c,
163
157
  ...P,
164
- ...$,
165
- ...A($),
158
+ ...b,
159
+ ...p(b),
166
160
  ...B,
167
- ...V,
168
- index: I,
161
+ ...M,
162
+ index: A,
169
163
  lang: n,
170
- key: i._id,
171
- draft: d,
164
+ key: r._id,
165
+ draft: o,
166
+ pageProps: a,
172
167
  blockProps: {},
173
168
  inBuilder: !1
174
169
  },
175
170
  ["_parent"]
176
171
  );
177
172
  if (S(u, "dataProvider")) {
178
- const K = l(u, "suspenseFallback", fe);
179
- return /* @__PURE__ */ m(w, { fallback: ee(K), children: /* @__PURE__ */ m(
180
- ae,
173
+ const V = c(u, "suspenseFallback", fe);
174
+ return /* @__PURE__ */ f(w, { fallback: Z(V), children: /* @__PURE__ */ f(
175
+ ie,
181
176
  {
182
177
  inBuilder: !1,
183
- dataProviderMetadataCallback: o,
178
+ dataProviderMetadataCallback: l,
184
179
  lang: n,
185
- metadata: a,
180
+ pageProps: a,
186
181
  dataProvider: u.dataProvider,
187
- block: i,
182
+ block: r,
188
183
  component: C,
189
- props: b,
190
- forwardProps: c,
191
- draft: d
184
+ props: $,
185
+ draft: o
192
186
  },
193
- `${i._id}-async`
194
- ) }, `${i._id}-suspense`);
187
+ `${r._id}-async`
188
+ ) }, `${r._id}-suspense`);
195
189
  }
196
- return /* @__PURE__ */ m(w, { children: j.createElement(C, b) }, `${i._id}-suspense`);
190
+ return /* @__PURE__ */ f(w, { children: R.createElement(C, $) }, `${r._id}-suspense`);
197
191
  }
198
- return /* @__PURE__ */ Z("noscript", { children: [
199
- i._type,
192
+ return /* @__PURE__ */ X("noscript", { children: [
193
+ r._type,
200
194
  " not found"
201
- ] }, `${i._id}-noscript`);
195
+ ] }, `${r._id}-noscript`);
202
196
  });
203
197
  }
204
198
  export {
205
- Ee as RenderChaiBlocks,
206
- Oe as convertToBlocks,
207
- ke as getChaiThemeCssVariables,
208
- Te as getStylesForBlocks,
209
- Fe as getThemeFontsCSSImport,
210
- Ne as getThemeFontsLinkMarkup
199
+ Oe as RenderChaiBlocks,
200
+ xe as convertToBlocks,
201
+ Re as getChaiThemeCssVariables,
202
+ Ee as getStylesForBlocks,
203
+ je as getThemeFontsCSSImport,
204
+ Fe as getThemeFontsLinkMarkup
211
205
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "2.2.0",
8
+ "version": "2.2.2",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",
@@ -53,7 +53,7 @@
53
53
  }
54
54
  },
55
55
  "peerDependencies": {
56
- "@chaibuilder/runtime": "2.0.8",
56
+ "@chaibuilder/runtime": "2.1.1",
57
57
  "@types/react": "*",
58
58
  "@types/react-dom": "*",
59
59
  "jotai": "2.12.1",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@ai-sdk/react": "^1.2.2",
73
- "@chaibuilder/runtime": "2.0.8",
73
+ "@chaibuilder/runtime": "2.1.1",
74
74
  "@floating-ui/dom": "1.6.13",
75
75
  "@floating-ui/react-dom": "2.1.2",
76
76
  "@mhsdesign/jit-browser-tailwindcss": "0.4.2",