@chaibuilder/sdk 2.0.0-beta.55 → 2.0.0-beta.56
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 +2 -2
- package/dist/render.js +91 -82
- package/package.json +3 -2
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./ChaiThemeFn-DQu-2Eh9.cjs"),r=require("lodash-es"),m=require("./STRINGS-n7COZtKr.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./ChaiThemeFn-DQu-2Eh9.cjs"),r=require("lodash-es"),m=require("./STRINGS-n7COZtKr.cjs"),R=require("@mhsdesign/jit-browser-tailwindcss"),B=require("@tailwindcss/aspect-ratio"),P=require("@tailwindcss/container-queries"),q=require("@tailwindcss/forms"),F=require("@tailwindcss/typography"),E=require("./plugin-2xcljWGM.cjs"),a=require("./jsx-runtime-qcKc-DpB.cjs"),Y=require("@chaibuilder/runtime"),d=require("react"),L=require("tailwind-merge"),k=(e,s="")=>{const t=e.replace(m.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const p=l.split(":");return p[p.length-1]=s+r.last(p),p.join(":")}return`${s}${l}`}).join(" "));return r.flattenDeep(t).join(" ")},v=e=>{if(!e)return[];try{return JSON.parse(A(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function A(e){const s=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(s,n=>{const t=decodeURIComponent(n),i=t.indexOf("public");return i!==-1?t.substring(i+6):t})}async function O(e,s,n=[],t="",i){return await R.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[q,F,B,P,E.chaiBuilderPlugin],corePlugins:{preflight:i},...t?{prefix:`${t}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,s)}const $=(e,s,n)=>{const t=JSON.stringify(e).replace(/#styles:([^"]*)/g,(i,o)=>`#styles:${o.replace(/,/g," ")}`.replace(/#styles:/g,""));return O(s,[t],[],"",n)},N=async(e,s=f.defaultThemeOptions,n=!1)=>await $(e,s,n);async function I(e){const s=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return a.jsxRuntimeExports.jsx(
|
|
3
|
+
@tailwind utilities;`,s)}const $=(e,s,n)=>{const t=JSON.stringify(e).replace(/#styles:([^"]*)/g,(i,o)=>`#styles:${o.replace(/,/g," ")}`.replace(/#styles:/g,""));return O(s,[t],[],"",n)},N=async(e,s=f.defaultThemeOptions,n=!1)=>await $(e,s,n);async function I(e){const s=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return a.jsxRuntimeExports.jsx(d.Suspense,{children:d.createElement(e.component,{...e.props,...s})})}const K=r.memoize((e,s)=>{const n=e.replace(m.STYLES_KEY,"").split(","),t=L.twMerge(n[0],n[1]);return s===""?t.replace(m.STYLES_KEY,"").trim():k(t,s).replace(m.STYLES_KEY,"").trim()});function b(e,s){const n=r.get(e,`${s}_attrs`,{}),t=r.keys(n).join(" ");return r.includes(t,"x-show")&&!r.includes(t,"x-transition")&&(n["x-transition"]=""),n}function M(e,s){const n={};return Object.keys(e).forEach(t=>{if(r.isString(e[t])&&e[t].startsWith(m.STYLES_KEY)){const i=K(e[t],s);n[t]={className:i,...b(e,t)}}}),n}function J(e,s){const n=r.get(e,"_bindings",{});return r.isEmpty(n)?{...e}:(r.each(n,(t,i)=>{r.isString(t)&&r.get(s,t,null)&&(e[i]=r.get(s,t,null))}),e)}function U(e,s,n){if(r.isEmpty(s))return e;const t=r.cloneDeep(e),i=r.get(n,"i18nProps",[]);return r.forEach(r.keys(t),o=>{i.includes(o)&&!r.isEmpty(s)&&(t[o]=r.get(t,`${o}-${s}`,t[o]))}),t}const V=()=>a.jsxRuntimeExports.jsx("span",{children:"Loading..."});function j({blocks:e,parent:s,classPrefix:n="",externalData:t={},blockModifierCallback:i=null,lang:o="",metadata:h={}}){const l=e,p=c=>M(c,n),T=s?r.filter(e,{_parent:s}):r.filter(e,c=>r.isEmpty(c._parent));return a.jsxRuntimeExports.jsx(a.jsxRuntimeExports.Fragment,{children:d.Children.toArray(T.map((c,C)=>{const S={},w=r.filter(l,{_parent:c._id});S.children=w.length>0?a.jsxRuntimeExports.jsx(j,{externalData:t,classPrefix:n,parent:c._id,blocks:l,lang:o??"",metadata:h}):null;const u=Y.getRegisteredChaiBlock(c._type);if(u!==null){let g=c;const x=u.component;g={...u.defaults,...c},i&&(g=i(g));const y=r.omit({blockProps:{},inBuilder:!1,...g,index:C,...J(U(c,o,u),t),...p(g),...S,metadata:h,lang:o??""},["_parent"]);if(r.has(u,"dataProvider")){const _=r.get(u,"suspenseFallback",V);return a.jsxRuntimeExports.jsx(d.Suspense,{fallback:d.createElement(_),children:a.jsxRuntimeExports.jsx(I,{lang:o??"",metadata:h,dataProvider:u.dataProvider,block:c,component:x,props:y})})}return a.jsxRuntimeExports.jsx(d.Suspense,{children:d.createElement(x,y)})}return a.jsxRuntimeExports.jsxs("noscript",{children:[c._type," not found"]})}))})}exports.getChaiThemeCssVariables=f.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=f.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=f.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=j;exports.convertToBlocks=v;exports.getStylesForBlocks=N;
|
package/dist/render.js
CHANGED
|
@@ -1,154 +1,163 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { a as
|
|
3
|
-
import { last as
|
|
1
|
+
import { d as $ } from "./ChaiThemeFn-Cort9tch.js";
|
|
2
|
+
import { a as Ct, b as Pt, c as Bt } from "./ChaiThemeFn-Cort9tch.js";
|
|
3
|
+
import { last as F, flattenDeep as O, memoize as v, filter as h, isEmpty as g, omit as N, has as R, get as u, each as I, isString as C, cloneDeep as J, forEach as L, keys as P, includes as j } from "lodash-es";
|
|
4
4
|
import { S as m } from "./STRINGS-DtEft2kY.js";
|
|
5
|
-
import { createTailwindcss as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { g as
|
|
5
|
+
import { createTailwindcss as b } from "@mhsdesign/jit-browser-tailwindcss";
|
|
6
|
+
import k from "@tailwindcss/aspect-ratio";
|
|
7
|
+
import K from "@tailwindcss/container-queries";
|
|
8
|
+
import M from "@tailwindcss/forms";
|
|
9
|
+
import U from "@tailwindcss/typography";
|
|
10
|
+
import { g as W, c as Y } from "./plugin-kUMxtQR5.js";
|
|
11
11
|
import { j as a } from "./jsx-runtime-Drh4NO5G.js";
|
|
12
|
-
import { getRegisteredChaiBlock as
|
|
13
|
-
import y, { Suspense as S } from "react";
|
|
12
|
+
import { getRegisteredChaiBlock as z } from "@chaibuilder/runtime";
|
|
13
|
+
import y, { Suspense as S, createElement as D } from "react";
|
|
14
14
|
import { twMerge as Q } from "tailwind-merge";
|
|
15
15
|
const V = (t, n = "") => {
|
|
16
|
-
const e = t.replace(m, "").split(",").map((
|
|
16
|
+
const e = t.replace(m, "").split(",").map((r) => r.split(" ").map((c) => {
|
|
17
17
|
if (c === "") return "";
|
|
18
18
|
if (c.includes(":")) {
|
|
19
|
-
const
|
|
20
|
-
return
|
|
19
|
+
const p = c.split(":");
|
|
20
|
+
return p[p.length - 1] = n + F(p), p.join(":");
|
|
21
21
|
}
|
|
22
22
|
return `${n}${c}`;
|
|
23
23
|
}).join(" "));
|
|
24
24
|
return O(e).join(" ");
|
|
25
|
-
},
|
|
25
|
+
}, xt = (t) => {
|
|
26
26
|
if (!t) return [];
|
|
27
27
|
try {
|
|
28
|
-
return JSON.parse(q(t)).filter((
|
|
28
|
+
return JSON.parse(q(t)).filter((s) => !s._type.startsWith("@chai"));
|
|
29
29
|
} catch {
|
|
30
30
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
function q(t) {
|
|
34
34
|
const n = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
35
|
-
return t.replace(n, (
|
|
36
|
-
const e = decodeURIComponent(
|
|
37
|
-
return
|
|
35
|
+
return t.replace(n, (s) => {
|
|
36
|
+
const e = decodeURIComponent(s), r = e.indexOf("public");
|
|
37
|
+
return r !== -1 ? e.substring(r + 6) : e;
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
async function G(t, n,
|
|
41
|
-
return await
|
|
40
|
+
async function G(t, n, s = [], e = "", r) {
|
|
41
|
+
return await b({
|
|
42
42
|
tailwindConfig: {
|
|
43
43
|
darkMode: "class",
|
|
44
|
-
safelist:
|
|
45
|
-
theme: { extend:
|
|
46
|
-
plugins: [U,
|
|
47
|
-
corePlugins: { preflight:
|
|
44
|
+
safelist: s,
|
|
45
|
+
theme: { extend: W(t) },
|
|
46
|
+
plugins: [M, U, k, K, Y],
|
|
47
|
+
corePlugins: { preflight: r },
|
|
48
48
|
...e ? { prefix: `${e}` } : {}
|
|
49
49
|
}
|
|
50
50
|
}).generateStylesFromContent(
|
|
51
|
-
` ${
|
|
51
|
+
` ${r ? "@tailwind base;" : ""}
|
|
52
52
|
@tailwind components;
|
|
53
53
|
@tailwind utilities;`,
|
|
54
54
|
n
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
const H = (t, n,
|
|
58
|
-
const e = JSON.stringify(t).replace(/#styles:([^"]*)/g, (
|
|
59
|
-
return G(n, [e], [], "",
|
|
60
|
-
},
|
|
57
|
+
const H = (t, n, s) => {
|
|
58
|
+
const e = JSON.stringify(t).replace(/#styles:([^"]*)/g, (r, i) => `#styles:${i.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
59
|
+
return G(n, [e], [], "", s);
|
|
60
|
+
}, wt = async (t, n = $, s = !1) => await H(t, n, s);
|
|
61
61
|
async function X(t) {
|
|
62
62
|
const n = await (t == null ? void 0 : t.dataProvider(t.block, t.lang, t.metadata));
|
|
63
63
|
return /* @__PURE__ */ a.jsx(S, { children: y.createElement(t.component, { ...t.props, ...n }) });
|
|
64
64
|
}
|
|
65
65
|
const Z = v((t, n) => {
|
|
66
|
-
const
|
|
66
|
+
const s = t.replace(m, "").split(","), e = Q(s[0], s[1]);
|
|
67
67
|
return n === "" ? e.replace(m, "").trim() : V(e, n).replace(m, "").trim();
|
|
68
68
|
});
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
return
|
|
69
|
+
function tt(t, n) {
|
|
70
|
+
const s = u(t, `${n}_attrs`, {}), e = P(s).join(" ");
|
|
71
|
+
return j(e, "x-show") && !j(e, "x-transition") && (s["x-transition"] = ""), s;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
73
|
+
function et(t, n) {
|
|
74
|
+
const s = {};
|
|
75
75
|
return Object.keys(t).forEach((e) => {
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
className:
|
|
80
|
-
...
|
|
76
|
+
if (C(t[e]) && t[e].startsWith(m)) {
|
|
77
|
+
const r = Z(t[e], n);
|
|
78
|
+
s[e] = {
|
|
79
|
+
className: r,
|
|
80
|
+
...tt(t, e)
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
}),
|
|
83
|
+
}), s;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
return g(
|
|
88
|
-
|
|
85
|
+
function nt(t, n) {
|
|
86
|
+
const s = u(t, "_bindings", {});
|
|
87
|
+
return g(s) ? { ...t } : (I(s, (e, r) => {
|
|
88
|
+
C(e) && u(n, e, null) && (t[r] = u(n, e, null));
|
|
89
89
|
}), t);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function st(t, n, s) {
|
|
92
92
|
if (g(n)) return t;
|
|
93
|
-
const e =
|
|
94
|
-
return
|
|
95
|
-
|
|
93
|
+
const e = J(t), r = u(s, "i18nProps", []);
|
|
94
|
+
return L(P(e), (i) => {
|
|
95
|
+
r.includes(i) && !g(n) && (e[i] = u(e, `${i}-${n}`, e[i]));
|
|
96
96
|
}), e;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
const rt = () => /* @__PURE__ */ a.jsx("span", { children: "Loading..." });
|
|
99
|
+
function it({
|
|
99
100
|
blocks: t,
|
|
100
101
|
parent: n,
|
|
101
|
-
classPrefix:
|
|
102
|
+
classPrefix: s = "",
|
|
102
103
|
externalData: e = {},
|
|
103
|
-
blockModifierCallback:
|
|
104
|
+
blockModifierCallback: r = null,
|
|
104
105
|
lang: i = "",
|
|
105
106
|
metadata: f = {}
|
|
106
107
|
}) {
|
|
107
|
-
const c = t,
|
|
108
|
+
const c = t, p = (o) => et(o, s), B = n ? h(t, { _parent: n }) : h(t, (o) => g(o._parent));
|
|
108
109
|
return /* @__PURE__ */ a.jsx(a.Fragment, { children: y.Children.toArray(
|
|
109
110
|
B.map((o, T) => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
const x = {}, E = h(c, { _parent: o._id });
|
|
112
|
+
x.children = E.length > 0 ? /* @__PURE__ */ a.jsx(
|
|
113
|
+
it,
|
|
113
114
|
{
|
|
114
115
|
externalData: e,
|
|
115
|
-
classPrefix:
|
|
116
|
+
classPrefix: s,
|
|
116
117
|
parent: o._id,
|
|
117
118
|
blocks: c,
|
|
118
119
|
lang: i ?? "",
|
|
119
120
|
metadata: f
|
|
120
121
|
}
|
|
121
122
|
) : null;
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
123
|
+
const l = z(o._type);
|
|
124
|
+
if (l !== null) {
|
|
124
125
|
let d = o;
|
|
125
|
-
const
|
|
126
|
-
d = { ...
|
|
126
|
+
const w = l.component;
|
|
127
|
+
d = { ...l.defaults, ...o }, r && (d = r(d));
|
|
127
128
|
const _ = N(
|
|
128
129
|
{
|
|
129
130
|
blockProps: {},
|
|
130
131
|
inBuilder: !1,
|
|
131
132
|
...d,
|
|
132
133
|
index: T,
|
|
133
|
-
...
|
|
134
|
-
...
|
|
135
|
-
...
|
|
134
|
+
...nt(st(o, i, l), e),
|
|
135
|
+
...p(d),
|
|
136
|
+
...x,
|
|
136
137
|
metadata: f,
|
|
137
138
|
lang: i ?? ""
|
|
138
139
|
},
|
|
139
140
|
["_parent"]
|
|
140
141
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
if (R(l, "dataProvider")) {
|
|
143
|
+
const A = u(
|
|
144
|
+
l,
|
|
145
|
+
"suspenseFallback",
|
|
146
|
+
rt
|
|
147
|
+
);
|
|
148
|
+
return /* @__PURE__ */ a.jsx(S, { fallback: D(A), children: /* @__PURE__ */ a.jsx(
|
|
149
|
+
X,
|
|
150
|
+
{
|
|
151
|
+
lang: i ?? "",
|
|
152
|
+
metadata: f,
|
|
153
|
+
dataProvider: l.dataProvider,
|
|
154
|
+
block: o,
|
|
155
|
+
component: w,
|
|
156
|
+
props: _
|
|
157
|
+
}
|
|
158
|
+
) });
|
|
159
|
+
}
|
|
160
|
+
return /* @__PURE__ */ a.jsx(S, { children: y.createElement(w, _) });
|
|
152
161
|
}
|
|
153
162
|
return /* @__PURE__ */ a.jsxs("noscript", { children: [
|
|
154
163
|
o._type,
|
|
@@ -158,10 +167,10 @@ function nt({
|
|
|
158
167
|
) });
|
|
159
168
|
}
|
|
160
169
|
export {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
it as RenderChaiBlocks,
|
|
171
|
+
xt as convertToBlocks,
|
|
172
|
+
Ct as getChaiThemeCssVariables,
|
|
173
|
+
wt as getStylesForBlocks,
|
|
174
|
+
Pt as getThemeFontsCSSImport,
|
|
175
|
+
Bt as getThemeFontsLinkMarkup
|
|
167
176
|
};
|
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.0.0-beta.
|
|
8
|
+
"version": "2.0.0-beta.56",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
+
"@chaibuilder/runtime": "2.0.0-beta.21",
|
|
69
70
|
"@types/react": "*",
|
|
70
71
|
"@types/react-dom": "*",
|
|
71
72
|
"react": "^18.0 || ^19.0",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
}
|
|
81
82
|
},
|
|
82
83
|
"dependencies": {
|
|
83
|
-
"@chaibuilder/runtime": "2.0.0-beta.
|
|
84
|
+
"@chaibuilder/runtime": "2.0.0-beta.21",
|
|
84
85
|
"@floating-ui/dom": "1.6.13",
|
|
85
86
|
"@floating-ui/react-dom": "2.1.2",
|
|
86
87
|
"@mhsdesign/jit-browser-tailwindcss": "0.4.2",
|