@chaibuilder/sdk 1.2.9 → 1.2.10-7.beta.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.
Files changed (124) hide show
  1. package/README.md +26 -21
  2. package/dist/CodeEditor-2fowVPcS.cjs +143 -0
  3. package/dist/CodeEditor-b6uePnTe.js +143 -0
  4. package/dist/STRINGS-RCf9qnaS.cjs +9 -0
  5. package/dist/STRINGS-t8UhMYZ6.js +10 -0
  6. package/dist/Topbar-O21Nrw2O.cjs +137 -0
  7. package/dist/Topbar-xFfdTq1m.js +137 -0
  8. package/dist/UnsplashImages-awQiGFMX.cjs +280 -0
  9. package/dist/UnsplashImages-qQmFIWEy.js +280 -0
  10. package/dist/UploadImages-a8Hl0tyg.cjs +170 -0
  11. package/dist/UploadImages-cudxJepv.js +170 -0
  12. package/dist/context-menu-VMB9i0d8.cjs +1074 -0
  13. package/dist/context-menu-mp3Gu2KA.js +1043 -0
  14. package/dist/controls-4t-C_rP2.cjs +233 -0
  15. package/dist/controls-fQIu127i.js +234 -0
  16. package/dist/core.cjs +135 -1
  17. package/dist/core.d.ts +344 -119
  18. package/dist/core.js +111 -88
  19. package/dist/iconBase-OGxLGBQ1.cjs +156 -0
  20. package/dist/iconBase-Ofd16yeE.js +157 -0
  21. package/dist/index-R7v8ZYnu.js +12110 -0
  22. package/dist/index-WHVUpVPa.cjs +12125 -0
  23. package/dist/jsx-runtime-_yxTjXEh.js +931 -0
  24. package/dist/jsx-runtime-vPqyLgmD.cjs +930 -0
  25. package/dist/mockServiceWorker.js +18 -10
  26. package/dist/plugin-RAiM74uD.cjs +116 -0
  27. package/dist/plugin-T1qbgBUO.js +55 -0
  28. package/dist/plugin-YcxlCmRm.js +117 -0
  29. package/dist/plugin-cYi6q9KC.cjs +54 -0
  30. package/dist/render.cjs +215 -1
  31. package/dist/render.d.ts +21 -40
  32. package/dist/render.js +190 -98
  33. package/dist/runtime.cjs +28 -0
  34. package/dist/runtime.d.ts +5 -0
  35. package/dist/runtime.js +21 -0
  36. package/dist/style.css +1524 -1
  37. package/dist/tailwind.cjs +80 -1
  38. package/dist/tailwind.d.ts +49 -8
  39. package/dist/tailwind.js +23 -25
  40. package/dist/ui.cjs +410 -1
  41. package/dist/ui.d.ts +3 -13
  42. package/dist/ui.js +374 -163
  43. package/dist/web-blocks.cjs +1246 -9
  44. package/dist/web-blocks.d.ts +1 -1
  45. package/dist/web-blocks.js +961 -789
  46. package/package.json +66 -83
  47. package/dist/AddBlocks-tMxKPoen.js +0 -225
  48. package/dist/AddBlocks-x2LkOHSj.cjs +0 -1
  49. package/dist/BrandingOptions-EzT9UYd6.cjs +0 -1
  50. package/dist/BrandingOptions-QJJ1y5ez.js +0 -194
  51. package/dist/CanvasArea-mlNKmCOh.js +0 -1425
  52. package/dist/CanvasArea-xs4wM64L.cjs +0 -60
  53. package/dist/CurrentPage-aaU4F7wi.cjs +0 -1
  54. package/dist/CurrentPage-lBy25sZn.js +0 -111
  55. package/dist/Functions-7jnEwJyw.js +0 -15
  56. package/dist/Functions-N3yhPYKY.cjs +0 -1
  57. package/dist/Layers-3Xs4A5i8.js +0 -404
  58. package/dist/Layers-eaHy5PK9.cjs +0 -1
  59. package/dist/MODIFIERS-2FeVfZQ9.cjs +0 -1
  60. package/dist/MODIFIERS-RiXS5Mn1.js +0 -67
  61. package/dist/MarkAsGlobalBlock-BjP-Rqlf.js +0 -88
  62. package/dist/MarkAsGlobalBlock-X5dNmZcb.cjs +0 -1
  63. package/dist/PagesPanel--BZhafnt.js +0 -69
  64. package/dist/PagesPanel-gGKCV394.cjs +0 -1
  65. package/dist/ProjectPanel-YcLkM-DW.js +0 -90
  66. package/dist/ProjectPanel-yFJRy0_E.cjs +0 -1
  67. package/dist/Settings-7wlLcvoh.cjs +0 -1
  68. package/dist/Settings-TAgX4hov.js +0 -2186
  69. package/dist/SidePanels-5H4j0mIs.cjs +0 -1
  70. package/dist/SidePanels-btVQQkVK.js +0 -349
  71. package/dist/Topbar-V8xCetWF.cjs +0 -1
  72. package/dist/Topbar-j4t4AgCq.js +0 -116
  73. package/dist/UnsplashImages-41Y3q5_Q.js +0 -200
  74. package/dist/UnsplashImages-DbHky6cj.cjs +0 -1
  75. package/dist/UploadImages-DnQ95_NW.cjs +0 -1
  76. package/dist/UploadImages-xBg-kbKv.js +0 -138
  77. package/dist/_commonjsHelpers-UyOWmZb0.js +0 -8
  78. package/dist/_commonjsHelpers-wDK0ZLPo.cjs +0 -1
  79. package/dist/add-page-modal-MwS7iXn_.cjs +0 -1
  80. package/dist/add-page-modal-cm8damU2.js +0 -108
  81. package/dist/confirm-alert-U7-NcG7G.cjs +0 -1
  82. package/dist/confirm-alert-i4pM3mOt.js +0 -62
  83. package/dist/controls-Dy1qa8Dc.cjs +0 -1
  84. package/dist/controls-XPXGHKht.js +0 -182
  85. package/dist/delete-page-modal-5o4jXu-z.cjs +0 -1
  86. package/dist/delete-page-modal-YrIBvfFA.js +0 -88
  87. package/dist/email-blocks.cjs +0 -1
  88. package/dist/email-blocks.d.ts +0 -3
  89. package/dist/email-blocks.js +0 -274
  90. package/dist/form-OVmsLOrc.js +0 -125
  91. package/dist/form-VbouZlAW.cjs +0 -1
  92. package/dist/functions-Ox_svtKm.cjs +0 -1
  93. package/dist/functions-xIebp8Aw.js +0 -23
  94. package/dist/html-to-json-2PeOCVey.cjs +0 -1
  95. package/dist/html-to-json-57841sEK.js +0 -183
  96. package/dist/index-H6vIwGfD.cjs +0 -1
  97. package/dist/index-N50dZnlC.cjs +0 -206
  98. package/dist/index-e0c8PmRQ.js +0 -205
  99. package/dist/index-gi1LIOCw.cjs +0 -1
  100. package/dist/index-niHREMmR.js +0 -2938
  101. package/dist/index-pZhGT8uT.js +0 -41620
  102. package/dist/jsx-runtime-WbnYoNE9.js +0 -634
  103. package/dist/jsx-runtime-Z_BpKhVy.cjs +0 -27
  104. package/dist/lib.cjs +0 -4
  105. package/dist/lib.d.ts +0 -78
  106. package/dist/lib.js +0 -1322
  107. package/dist/page-viewer-SLt8XgYv.cjs +0 -1
  108. package/dist/page-viewer-feqJr1QI.js +0 -115
  109. package/dist/project-general-setting-SgagORzW.js +0 -83
  110. package/dist/project-general-setting-ym0yCdOq.cjs +0 -1
  111. package/dist/project-seo-setting-Snn2nZgS.cjs +0 -1
  112. package/dist/project-seo-setting-wxAGEkd_.js +0 -85
  113. package/dist/server.cjs +0 -1
  114. package/dist/server.d.ts +0 -299
  115. package/dist/server.js +0 -216
  116. package/dist/single-page-detail-IPod1o5P.cjs +0 -1
  117. package/dist/single-page-detail-dnWMyg6P.js +0 -222
  118. package/dist/studio.cjs +0 -1
  119. package/dist/studio.d.ts +0 -13
  120. package/dist/studio.js +0 -58
  121. package/dist/useAddBlockByDrop-_nwI4W3q.js +0 -20
  122. package/dist/useAddBlockByDrop-inkD7Lck.cjs +0 -1
  123. package/dist/utils-AvyFzbPC.js +0 -1075
  124. package/dist/utils-PTxFk6qT.cjs +0 -1
@@ -2,14 +2,13 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker.
5
+ * Mock Service Worker (2.0.8).
6
6
  * @see https://github.com/mswjs/msw
7
7
  * - Please do NOT modify this file.
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.3.1'
12
- const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
11
+ const INTEGRITY_CHECKSUM = '0877fcdc026242810f5bfde0d7178db4'
13
12
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
13
  const activeClientIds = new Set()
15
14
 
@@ -49,10 +48,7 @@ self.addEventListener('message', async function (event) {
49
48
  case 'INTEGRITY_CHECK_REQUEST': {
50
49
  sendToClient(client, {
51
50
  type: 'INTEGRITY_CHECK_RESPONSE',
52
- payload: {
53
- packageVersion: PACKAGE_VERSION,
54
- checksum: INTEGRITY_CHECKSUM,
55
- },
51
+ payload: INTEGRITY_CHECKSUM,
56
52
  })
57
53
  break
58
54
  }
@@ -125,6 +121,11 @@ async function handleRequest(event, requestId) {
125
121
  if (client && activeClientIds.has(client.id)) {
126
122
  ;(async function () {
127
123
  const responseClone = response.clone()
124
+ // When performing original requests, response body will
125
+ // always be a ReadableStream, even for 204 responses.
126
+ // But when creating a new Response instance on the client,
127
+ // the body for a 204 response must be null.
128
+ const responseBody = response.status === 204 ? null : responseClone.body
128
129
 
129
130
  sendToClient(
130
131
  client,
@@ -136,11 +137,11 @@ async function handleRequest(event, requestId) {
136
137
  type: responseClone.type,
137
138
  status: responseClone.status,
138
139
  statusText: responseClone.statusText,
139
- body: responseClone.body,
140
+ body: responseBody,
140
141
  headers: Object.fromEntries(responseClone.headers.entries()),
141
142
  },
142
143
  },
143
- [responseClone.body],
144
+ [responseBody],
144
145
  )
145
146
  })()
146
147
  }
@@ -206,6 +207,13 @@ async function getResponse(event, client, requestId) {
206
207
  return passthrough()
207
208
  }
208
209
 
210
+ // Bypass requests with the explicit bypass header.
211
+ // Such requests can be issued by "ctx.fetch()".
212
+ const mswIntention = request.headers.get('x-msw-intention')
213
+ if (['bypass', 'passthrough'].includes(mswIntention)) {
214
+ return passthrough()
215
+ }
216
+
209
217
  // Notify the client that a request has been intercepted.
210
218
  const requestBuffer = await request.arrayBuffer()
211
219
  const clientMessage = await sendToClient(
@@ -237,7 +245,7 @@ async function getResponse(event, client, requestId) {
237
245
  return respondWithMock(clientMessage.data)
238
246
  }
239
247
 
240
- case 'PASSTHROUGH': {
248
+ case 'MOCK_NOT_FOUND': {
241
249
  return passthrough()
242
250
  }
243
251
  }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ function getDefaultExportFromCjs(x) {
3
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
+ }
5
+ var e = ({ hex: e2, preserve: s2, shades: n }) => {
6
+ const t = ((e3) => {
7
+ const s3 = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e3) || [];
8
+ try {
9
+ let e4 = parseInt(s3[1], 16), n2 = parseInt(s3[2], 16), t2 = parseInt(s3[3], 16);
10
+ e4 /= 255, n2 /= 255, t2 /= 255;
11
+ const r2 = Math.max(e4, n2, t2), a2 = Math.min(e4, n2, t2);
12
+ let o, h = 0, i = (r2 + a2) / 2;
13
+ if (r2 == a2)
14
+ h = o = 0;
15
+ else {
16
+ const s4 = r2 - a2;
17
+ switch (o = i > 0.5 ? s4 / (2 - r2 - a2) : s4 / (r2 + a2), r2) {
18
+ case e4:
19
+ h = (n2 - t2) / s4 + (n2 < t2 ? 6 : 0);
20
+ break;
21
+ case n2:
22
+ h = (t2 - e4) / s4 + 2;
23
+ break;
24
+ case t2:
25
+ h = (e4 - n2) / s4 + 4;
26
+ }
27
+ h /= 6;
28
+ }
29
+ const c = { h: 0, s: 0, l: 0 };
30
+ return c.h = Math.round(360 * h), c.s = Math.round(100 * o), c.l = Math.round(100 * i), c;
31
+ } catch (s4) {
32
+ return console.log(e3), { h: 0, s: 0, l: 0 };
33
+ }
34
+ })(e2), r = {}, a = n.reduce((e3, { name: n2, lightness: a2 }) => {
35
+ const { h: o, s: h, l: i } = t, c = (({ h: e4, s: s3, l: n3 }) => {
36
+ n3 /= 100;
37
+ const t2 = s3 * Math.min(n3, 1 - n3) / 100, r2 = (s4) => {
38
+ const r3 = (s4 + e4 / 30) % 12, a3 = n3 - t2 * Math.max(Math.min(r3 - 3, 9 - r3, 1), -1);
39
+ return Math.round(255 * a3).toString(16).padStart(2, "0");
40
+ };
41
+ return `#${r2(0)}${r2(8)}${r2(4)}`;
42
+ })({ h: o, s: h, l: a2 });
43
+ return e3[n2] = c, s2 && (r[n2] = Math.abs(i - a2)), e3;
44
+ }, {});
45
+ if (s2) {
46
+ const [s3] = Object.keys(r).sort((e3, s4) => r[e3] - r[s4]);
47
+ a[s3] = e2;
48
+ }
49
+ return a;
50
+ }, s = (s2) => {
51
+ "string" == typeof s2 && (s2 = { colors: [s2] }), "object" == typeof s2 && Array.isArray(s2) && (s2 = { colors: s2 }), s2 = Object.assign({ colors: [], names: ["primary", "secondary", "tertiary", "quaternary", "quinary", "senary", "septenary", "octonary", "nonary", "denary"], preserve: true, shades: [{ name: "50", lightness: 98 }, { name: "100", lightness: 95 }, { name: "200", lightness: 90 }, { name: "300", lightness: 82 }, { name: "400", lightness: 64 }, { name: "500", lightness: 46 }, { name: "600", lightness: 33 }, { name: "700", lightness: 24 }, { name: "800", lightness: 14 }, { name: "900", lightness: 7 }, { name: "950", lightness: 4 }] }, s2);
52
+ const { colors: n, names: t, preserve: r, shades: a } = s2;
53
+ if (void 0 === n || void 0 === t || void 0 === r || void 0 === a)
54
+ return {};
55
+ return n.reduce((s3, n2, o) => {
56
+ const h = t[o], i = e({ hex: n2, preserve: r, shades: a });
57
+ return s3[h] = i, s3;
58
+ }, {});
59
+ };
60
+ var createPlugin$2 = {};
61
+ var createPlugin$1 = {};
62
+ (function(exports2) {
63
+ Object.defineProperty(exports2, "__esModule", {
64
+ value: true
65
+ });
66
+ Object.defineProperty(exports2, "default", {
67
+ enumerable: true,
68
+ get: function() {
69
+ return _default;
70
+ }
71
+ });
72
+ function createPlugin2(plugin2, config) {
73
+ return {
74
+ handler: plugin2,
75
+ config
76
+ };
77
+ }
78
+ createPlugin2.withOptions = function(pluginFunction, configFunction = () => ({})) {
79
+ const optionsFunction = function(options) {
80
+ return {
81
+ __options: options,
82
+ handler: pluginFunction(options),
83
+ config: configFunction(options)
84
+ };
85
+ };
86
+ optionsFunction.__isOptionsFunction = true;
87
+ optionsFunction.__pluginFunction = pluginFunction;
88
+ optionsFunction.__configFunction = configFunction;
89
+ return optionsFunction;
90
+ };
91
+ const _default = createPlugin2;
92
+ })(createPlugin$1);
93
+ (function(exports2) {
94
+ Object.defineProperty(exports2, "__esModule", {
95
+ value: true
96
+ });
97
+ Object.defineProperty(exports2, "default", {
98
+ enumerable: true,
99
+ get: function() {
100
+ return _default;
101
+ }
102
+ });
103
+ const _createPlugin = /* @__PURE__ */ _interop_require_default(createPlugin$1);
104
+ function _interop_require_default(obj) {
105
+ return obj && obj.__esModule ? obj : {
106
+ default: obj
107
+ };
108
+ }
109
+ const _default = _createPlugin.default;
110
+ })(createPlugin$2);
111
+ let createPlugin = createPlugin$2;
112
+ var plugin = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default;
113
+ const plugin$1 = /* @__PURE__ */ getDefaultExportFromCjs(plugin);
114
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
115
+ exports.plugin = plugin$1;
116
+ exports.s = s;
@@ -0,0 +1,55 @@
1
+ import { get, set } from "lodash-es";
2
+ import { s, p as plugin } from "./plugin-YcxlCmRm.js";
3
+ const getChaiBuilderTheme = (theme) => {
4
+ const primary = get(theme, "primaryColor", "#000");
5
+ const secondary = get(theme, "secondaryColor", "#ccc");
6
+ const headingFont = get(theme, "headingFont", "Inter");
7
+ const bodyFont = get(theme, "bodyFont", "Inter");
8
+ const borderRadius = get(theme, "roundedCorners", "0");
9
+ const BG_LIGHT_MODE = get(theme, "bodyBgLightColor", "#fff");
10
+ const BG_DARK_MODE = get(theme, "bodyBgDarkColor", "#000");
11
+ const TEXT_LIGHT_MODE = get(theme, "bodyTextLightColor", "#000");
12
+ const TEXT_DARK_MODE = get(theme, "bodyTextDarkColor", "#fff");
13
+ const palette = s({
14
+ colors: [primary, secondary],
15
+ names: ["primary", "secondary"]
16
+ });
17
+ set(palette, "primary.DEFAULT", primary);
18
+ set(palette, "secondary.DEFAULT", secondary);
19
+ const colors = {
20
+ "bg-light": BG_LIGHT_MODE,
21
+ "bg-dark": BG_DARK_MODE,
22
+ "text-dark": TEXT_DARK_MODE,
23
+ "text-light": TEXT_LIGHT_MODE
24
+ };
25
+ return {
26
+ container: {
27
+ center: true,
28
+ padding: "1rem",
29
+ screens: { "2xl": "1400px" }
30
+ },
31
+ fontFamily: { heading: [headingFont], body: [bodyFont] },
32
+ borderRadius: { DEFAULT: `${!borderRadius ? "0px" : borderRadius}px` },
33
+ colors: { ...palette, ...colors }
34
+ };
35
+ };
36
+ const chaiBuilderPlugin = plugin(function({ addBase, theme }) {
37
+ addBase({
38
+ "h1,h2,h3,h4,h5,h6": {
39
+ fontFamily: theme("fontFamily.heading")
40
+ },
41
+ body: {
42
+ fontFamily: theme("fontFamily.body"),
43
+ color: theme("colors.text-light"),
44
+ backgroundColor: theme("colors.bg-light")
45
+ },
46
+ ".dark body": {
47
+ color: theme("colors.text-dark"),
48
+ backgroundColor: theme("colors.bg-dark")
49
+ }
50
+ });
51
+ });
52
+ export {
53
+ chaiBuilderPlugin as c,
54
+ getChaiBuilderTheme as g
55
+ };
@@ -0,0 +1,117 @@
1
+ function getDefaultExportFromCjs(x) {
2
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
3
+ }
4
+ var e = ({ hex: e2, preserve: s2, shades: n }) => {
5
+ const t = ((e3) => {
6
+ const s3 = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e3) || [];
7
+ try {
8
+ let e4 = parseInt(s3[1], 16), n2 = parseInt(s3[2], 16), t2 = parseInt(s3[3], 16);
9
+ e4 /= 255, n2 /= 255, t2 /= 255;
10
+ const r2 = Math.max(e4, n2, t2), a2 = Math.min(e4, n2, t2);
11
+ let o, h = 0, i = (r2 + a2) / 2;
12
+ if (r2 == a2)
13
+ h = o = 0;
14
+ else {
15
+ const s4 = r2 - a2;
16
+ switch (o = i > 0.5 ? s4 / (2 - r2 - a2) : s4 / (r2 + a2), r2) {
17
+ case e4:
18
+ h = (n2 - t2) / s4 + (n2 < t2 ? 6 : 0);
19
+ break;
20
+ case n2:
21
+ h = (t2 - e4) / s4 + 2;
22
+ break;
23
+ case t2:
24
+ h = (e4 - n2) / s4 + 4;
25
+ }
26
+ h /= 6;
27
+ }
28
+ const c = { h: 0, s: 0, l: 0 };
29
+ return c.h = Math.round(360 * h), c.s = Math.round(100 * o), c.l = Math.round(100 * i), c;
30
+ } catch (s4) {
31
+ return console.log(e3), { h: 0, s: 0, l: 0 };
32
+ }
33
+ })(e2), r = {}, a = n.reduce((e3, { name: n2, lightness: a2 }) => {
34
+ const { h: o, s: h, l: i } = t, c = (({ h: e4, s: s3, l: n3 }) => {
35
+ n3 /= 100;
36
+ const t2 = s3 * Math.min(n3, 1 - n3) / 100, r2 = (s4) => {
37
+ const r3 = (s4 + e4 / 30) % 12, a3 = n3 - t2 * Math.max(Math.min(r3 - 3, 9 - r3, 1), -1);
38
+ return Math.round(255 * a3).toString(16).padStart(2, "0");
39
+ };
40
+ return `#${r2(0)}${r2(8)}${r2(4)}`;
41
+ })({ h: o, s: h, l: a2 });
42
+ return e3[n2] = c, s2 && (r[n2] = Math.abs(i - a2)), e3;
43
+ }, {});
44
+ if (s2) {
45
+ const [s3] = Object.keys(r).sort((e3, s4) => r[e3] - r[s4]);
46
+ a[s3] = e2;
47
+ }
48
+ return a;
49
+ }, s = (s2) => {
50
+ "string" == typeof s2 && (s2 = { colors: [s2] }), "object" == typeof s2 && Array.isArray(s2) && (s2 = { colors: s2 }), s2 = Object.assign({ colors: [], names: ["primary", "secondary", "tertiary", "quaternary", "quinary", "senary", "septenary", "octonary", "nonary", "denary"], preserve: true, shades: [{ name: "50", lightness: 98 }, { name: "100", lightness: 95 }, { name: "200", lightness: 90 }, { name: "300", lightness: 82 }, { name: "400", lightness: 64 }, { name: "500", lightness: 46 }, { name: "600", lightness: 33 }, { name: "700", lightness: 24 }, { name: "800", lightness: 14 }, { name: "900", lightness: 7 }, { name: "950", lightness: 4 }] }, s2);
51
+ const { colors: n, names: t, preserve: r, shades: a } = s2;
52
+ if (void 0 === n || void 0 === t || void 0 === r || void 0 === a)
53
+ return {};
54
+ return n.reduce((s3, n2, o) => {
55
+ const h = t[o], i = e({ hex: n2, preserve: r, shades: a });
56
+ return s3[h] = i, s3;
57
+ }, {});
58
+ };
59
+ var createPlugin$2 = {};
60
+ var createPlugin$1 = {};
61
+ (function(exports) {
62
+ Object.defineProperty(exports, "__esModule", {
63
+ value: true
64
+ });
65
+ Object.defineProperty(exports, "default", {
66
+ enumerable: true,
67
+ get: function() {
68
+ return _default;
69
+ }
70
+ });
71
+ function createPlugin2(plugin2, config) {
72
+ return {
73
+ handler: plugin2,
74
+ config
75
+ };
76
+ }
77
+ createPlugin2.withOptions = function(pluginFunction, configFunction = () => ({})) {
78
+ const optionsFunction = function(options) {
79
+ return {
80
+ __options: options,
81
+ handler: pluginFunction(options),
82
+ config: configFunction(options)
83
+ };
84
+ };
85
+ optionsFunction.__isOptionsFunction = true;
86
+ optionsFunction.__pluginFunction = pluginFunction;
87
+ optionsFunction.__configFunction = configFunction;
88
+ return optionsFunction;
89
+ };
90
+ const _default = createPlugin2;
91
+ })(createPlugin$1);
92
+ (function(exports) {
93
+ Object.defineProperty(exports, "__esModule", {
94
+ value: true
95
+ });
96
+ Object.defineProperty(exports, "default", {
97
+ enumerable: true,
98
+ get: function() {
99
+ return _default;
100
+ }
101
+ });
102
+ const _createPlugin = /* @__PURE__ */ _interop_require_default(createPlugin$1);
103
+ function _interop_require_default(obj) {
104
+ return obj && obj.__esModule ? obj : {
105
+ default: obj
106
+ };
107
+ }
108
+ const _default = _createPlugin.default;
109
+ })(createPlugin$2);
110
+ let createPlugin = createPlugin$2;
111
+ var plugin = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default;
112
+ const plugin$1 = /* @__PURE__ */ getDefaultExportFromCjs(plugin);
113
+ export {
114
+ getDefaultExportFromCjs as g,
115
+ plugin$1 as p,
116
+ s
117
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ const lodashEs = require("lodash-es");
3
+ const plugin = require("./plugin-RAiM74uD.cjs");
4
+ const getChaiBuilderTheme = (theme) => {
5
+ const primary = lodashEs.get(theme, "primaryColor", "#000");
6
+ const secondary = lodashEs.get(theme, "secondaryColor", "#ccc");
7
+ const headingFont = lodashEs.get(theme, "headingFont", "Inter");
8
+ const bodyFont = lodashEs.get(theme, "bodyFont", "Inter");
9
+ const borderRadius = lodashEs.get(theme, "roundedCorners", "0");
10
+ const BG_LIGHT_MODE = lodashEs.get(theme, "bodyBgLightColor", "#fff");
11
+ const BG_DARK_MODE = lodashEs.get(theme, "bodyBgDarkColor", "#000");
12
+ const TEXT_LIGHT_MODE = lodashEs.get(theme, "bodyTextLightColor", "#000");
13
+ const TEXT_DARK_MODE = lodashEs.get(theme, "bodyTextDarkColor", "#fff");
14
+ const palette = plugin.s({
15
+ colors: [primary, secondary],
16
+ names: ["primary", "secondary"]
17
+ });
18
+ lodashEs.set(palette, "primary.DEFAULT", primary);
19
+ lodashEs.set(palette, "secondary.DEFAULT", secondary);
20
+ const colors = {
21
+ "bg-light": BG_LIGHT_MODE,
22
+ "bg-dark": BG_DARK_MODE,
23
+ "text-dark": TEXT_DARK_MODE,
24
+ "text-light": TEXT_LIGHT_MODE
25
+ };
26
+ return {
27
+ container: {
28
+ center: true,
29
+ padding: "1rem",
30
+ screens: { "2xl": "1400px" }
31
+ },
32
+ fontFamily: { heading: [headingFont], body: [bodyFont] },
33
+ borderRadius: { DEFAULT: `${!borderRadius ? "0px" : borderRadius}px` },
34
+ colors: { ...palette, ...colors }
35
+ };
36
+ };
37
+ const chaiBuilderPlugin = plugin.plugin(function({ addBase, theme }) {
38
+ addBase({
39
+ "h1,h2,h3,h4,h5,h6": {
40
+ fontFamily: theme("fontFamily.heading")
41
+ },
42
+ body: {
43
+ fontFamily: theme("fontFamily.body"),
44
+ color: theme("colors.text-light"),
45
+ backgroundColor: theme("colors.bg-light")
46
+ },
47
+ ".dark body": {
48
+ color: theme("colors.text-dark"),
49
+ backgroundColor: theme("colors.bg-dark")
50
+ }
51
+ });
52
+ });
53
+ exports.chaiBuilderPlugin = chaiBuilderPlugin;
54
+ exports.getChaiBuilderTheme = getChaiBuilderTheme;
package/dist/render.cjs CHANGED
@@ -1 +1,215 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./jsx-runtime-Z_BpKhVy.cjs"),j=require("react"),s=require("lodash-es"),R=require("tailwind-merge"),u=require("./MODIFIERS-2FeVfZQ9.cjs"),_=require("@chaibuilder/runtime"),x=require("./functions-Ox_svtKm.cjs"),y=require("react-wrap-balancer");require("./_commonjsHelpers-wDK0ZLPo.cjs");const B=t=>{const r={};return Object.keys(t).forEach(e=>{s.isString(t[e])&&t[e].startsWith(u.SLOT_KEY)&&(r[e]=t[e].replace(u.SLOT_KEY,"").split(","))}),r},C=s.memoize((t,r)=>{const e=t.replace(u.STYLES_KEY,"").split(","),n=R.twMerge(e[0],e[1]);return x.addPrefixToClasses(n,r).replace(u.STYLES_KEY,"").trim()});function O(t,r){return s.get(t,`${r}_attrs`,{})}function q(t,r){const e={};return Object.keys(t).forEach(n=>{if(s.isString(t[n])&&t[n].startsWith(u.STYLES_KEY)){const o=C(t[n],r);e[n]={className:o,...O(t,n)}}}),e}function T(t,r){const e=s.get(t,"_bindings",{});return s.isEmpty(e)?{...t}:(s.each(e,(n,o)=>{s.isString(n)&&s.get(r,n,null)&&(t[o]=s.get(r,n,null))}),t)}function a({blocks:t,parent:r,classPrefix:e="c-",externalData:n={}}){const o=t,p=i=>q(i,e),f=r?s.filter(t,{_parent:r}):s.filter(t,i=>s.isEmpty(i._parent));return c.jsxRuntimeExports.jsx(c.jsxRuntimeExports.Fragment,{children:j.Children.toArray(f.map((i,h)=>{const d=B(i),m={};s.isEmpty(d)||Object.keys(d).forEach(l=>{m[l]=j.Children.toArray(d[l].map(E=>c.jsxRuntimeExports.jsx(a,{externalData:n,classPrefix:e,blocks:o,parent:E})))});const S=s.filter(o,{_parent:i._id});m.children=S.length>0?c.jsxRuntimeExports.jsx(a,{externalData:n,classPrefix:e,parent:i._id,blocks:o}):null;const g=_.getBlockComponent(i._type);if(g!==null){let l=i;const E=g.component;return l={...g.defaults,...i},j.createElement(E,s.omit({blockProps:{},inBuilder:!1,...l,index:h,...T(i,n),...p(l),...m},["_parent"]))}return c.jsxRuntimeExports.jsxs("noscript",{children:[i._type," not found"]})}))})}const Y=({pageData:t,externalData:r={},before:e=null,after:n=null,classPrefix:o="c-"})=>{const p=s.get(t.project,"brandingOptions",u.BRANDING_OPTIONS_DEFAULTS);return c.jsxRuntimeExports.jsxs(c.jsxRuntimeExports.Fragment,{children:[e,c.jsxRuntimeExports.jsx("div",{className:o.replace("-","")+" "+x.getBrandingClasses(p,o)+" min-h-screen",children:c.jsxRuntimeExports.jsx(y.Provider,{children:c.jsxRuntimeExports.jsx(a,{externalData:r,blocks:t.page.blocks||[],classPrefix:o})})}),n]})};exports.RenderChaiBlocks=a;exports.RenderChaiPage=Y;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const lodashEs = require("lodash-es");
4
+ const STRINGS = require("./STRINGS-RCf9qnaS.cjs");
5
+ const jsxRuntime = require("./jsx-runtime-vPqyLgmD.cjs");
6
+ const React = require("react");
7
+ const tailwindMerge = require("tailwind-merge");
8
+ const runtime = require("@chaibuilder/runtime");
9
+ const jitBrowserTailwindcss = require("@mhsdesign/jit-browser-tailwindcss");
10
+ const forms = require("@tailwindcss/forms");
11
+ const typography = require("@tailwindcss/typography");
12
+ const aspectRatio = require("@tailwindcss/aspect-ratio");
13
+ const plugin = require("./plugin-cYi6q9KC.cjs");
14
+ require("./plugin-RAiM74uD.cjs");
15
+ const addPrefixToClasses = (classes, prefix = "") => {
16
+ const classesArray = classes.replace(STRINGS.STYLES_KEY, "").split(",");
17
+ const array = classesArray.map((item) => {
18
+ const classes2 = item.split(" ");
19
+ const newClasses = classes2.map((item2) => {
20
+ if (item2 === "")
21
+ return "";
22
+ if (item2.includes(":")) {
23
+ const values = item2.split(":");
24
+ values[values.length - 1] = prefix + lodashEs.last(values);
25
+ return values.join(":");
26
+ }
27
+ return `${prefix}${item2}`;
28
+ });
29
+ return newClasses.join(" ");
30
+ });
31
+ return lodashEs.flattenDeep(array).join(" ");
32
+ };
33
+ const convertToBlocks = (chaiFormatContent) => {
34
+ if (!chaiFormatContent)
35
+ return [];
36
+ try {
37
+ const blocks = JSON.parse(removeAssetPrefix(chaiFormatContent));
38
+ return blocks.filter((block) => !block._type.startsWith("@chai"));
39
+ } catch (error) {
40
+ return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
41
+ }
42
+ };
43
+ function removeAssetPrefix(input) {
44
+ const regex = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
45
+ return input.replace(regex, (match) => {
46
+ const decodedUrl = decodeURIComponent(match);
47
+ const publicIndex = decodedUrl.indexOf("public");
48
+ if (publicIndex !== -1) {
49
+ return decodedUrl.substring(publicIndex + 6);
50
+ }
51
+ return decodedUrl;
52
+ });
53
+ }
54
+ const getSlots = (block) => {
55
+ const slots = {};
56
+ Object.keys(block).forEach((key) => {
57
+ if (lodashEs.isString(block[key]) && block[key].startsWith(STRINGS.SLOT_KEY)) {
58
+ slots[key] = block[key].replace(STRINGS.SLOT_KEY, "").split(",");
59
+ }
60
+ });
61
+ return slots;
62
+ };
63
+ const generateClassNames = lodashEs.memoize((styles, classPrefix) => {
64
+ const stylesArray = styles.replace(STRINGS.STYLES_KEY, "").split(",");
65
+ const classes = tailwindMerge.twMerge(stylesArray[0], stylesArray[1]);
66
+ if (classPrefix === "")
67
+ return classes.replace(STRINGS.STYLES_KEY, "").trim();
68
+ return addPrefixToClasses(classes, classPrefix).replace(STRINGS.STYLES_KEY, "").trim();
69
+ });
70
+ function getElementAttrs(block, key) {
71
+ const attrs = lodashEs.get(block, `${key}_attrs`, {});
72
+ if (lodashEs.has(attrs, "data-ai-key")) {
73
+ delete attrs["data-ai-key"];
74
+ }
75
+ const attrsKeys = lodashEs.keys(attrs).join(" ");
76
+ if (lodashEs.includes(attrsKeys, "x-show") && !lodashEs.includes(attrsKeys, "x-transition")) {
77
+ attrs["x-transition"] = "";
78
+ }
79
+ return attrs;
80
+ }
81
+ function getStyleAttrs(block, classPrefix) {
82
+ const styles = {};
83
+ Object.keys(block).forEach((key) => {
84
+ if (lodashEs.isString(block[key]) && block[key].startsWith(STRINGS.STYLES_KEY)) {
85
+ const classes = generateClassNames(block[key], classPrefix);
86
+ styles[key] = {
87
+ className: classes,
88
+ ...getElementAttrs(block, key)
89
+ };
90
+ }
91
+ });
92
+ return styles;
93
+ }
94
+ function applyBindings(block, chaiData) {
95
+ const bindings = lodashEs.get(block, "_bindings", {});
96
+ if (lodashEs.isEmpty(bindings))
97
+ return { ...block };
98
+ lodashEs.each(bindings, (value, key) => {
99
+ if (lodashEs.isString(value) && lodashEs.get(chaiData, value, null)) {
100
+ block[key] = lodashEs.get(chaiData, value, null);
101
+ }
102
+ });
103
+ return block;
104
+ }
105
+ function applyLanguage(_block, lang, blockDefinition) {
106
+ if (lodashEs.isEmpty(lang))
107
+ return _block;
108
+ const block = lodashEs.cloneDeep(_block);
109
+ lodashEs.forEach(lodashEs.keys(block), (key) => {
110
+ if (lodashEs.get(blockDefinition, ["props", key, "i18n"]) && !lodashEs.isEmpty(lang)) {
111
+ block[key] = lodashEs.get(block, `${key}-${lang}`, block[key]);
112
+ }
113
+ });
114
+ return block;
115
+ }
116
+ function RenderChaiBlocks({
117
+ blocks,
118
+ parent,
119
+ classPrefix = "",
120
+ externalData = {},
121
+ blockModifierCallback,
122
+ lang
123
+ }) {
124
+ const allBlocks = blocks;
125
+ const getStyles = (block) => getStyleAttrs(block, classPrefix);
126
+ const filteredBlocks = parent ? lodashEs.filter(blocks, { _parent: parent }) : lodashEs.filter(blocks, (block) => lodashEs.isEmpty(block._parent));
127
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment, { children: React.Children.toArray(
128
+ filteredBlocks.map((block, index) => {
129
+ const slots = getSlots(block);
130
+ const attrs = {};
131
+ if (!lodashEs.isEmpty(slots)) {
132
+ Object.keys(slots).forEach((key) => {
133
+ attrs[key] = React.Children.toArray(
134
+ slots[key].map((slotId) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
135
+ RenderChaiBlocks,
136
+ {
137
+ externalData,
138
+ classPrefix,
139
+ blocks: allBlocks,
140
+ parent: slotId,
141
+ lang
142
+ }
143
+ ))
144
+ );
145
+ });
146
+ }
147
+ const blocks2 = lodashEs.filter(allBlocks, { _parent: block._id });
148
+ attrs.children = blocks2.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
149
+ RenderChaiBlocks,
150
+ {
151
+ externalData,
152
+ classPrefix,
153
+ parent: block._id,
154
+ blocks: allBlocks,
155
+ lang
156
+ }
157
+ ) : null;
158
+ const blockDefinition = runtime.getBlockComponent(block._type);
159
+ if (blockDefinition !== null) {
160
+ let syncedBlock = block;
161
+ const Component = blockDefinition.component;
162
+ syncedBlock = { ...blockDefinition.defaults, ...block };
163
+ if (blockModifierCallback) {
164
+ syncedBlock = blockModifierCallback(syncedBlock);
165
+ }
166
+ return React.createElement(
167
+ Component,
168
+ lodashEs.omit(
169
+ {
170
+ blockProps: {},
171
+ inBuilder: false,
172
+ ...syncedBlock,
173
+ index,
174
+ ...applyBindings(applyLanguage(block, lang, blockDefinition), externalData),
175
+ ...getStyles(syncedBlock),
176
+ ...attrs
177
+ },
178
+ ["_parent"]
179
+ )
180
+ );
181
+ }
182
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("noscript", { children: [
183
+ block._type,
184
+ " not found"
185
+ ] });
186
+ })
187
+ ) });
188
+ }
189
+ async function getTailwindCSS(theme, markupString, safelist = [], prefix = "", includeBaseStyles = false) {
190
+ const tailwind = jitBrowserTailwindcss.createTailwindcss({
191
+ tailwindConfig: {
192
+ darkMode: "class",
193
+ safelist,
194
+ theme: { extend: plugin.getChaiBuilderTheme(theme) },
195
+ plugins: [forms, typography, aspectRatio, plugin.chaiBuilderPlugin],
196
+ corePlugins: { preflight: includeBaseStyles },
197
+ ...prefix ? { prefix: `${prefix}` } : {}
198
+ }
199
+ });
200
+ return await tailwind.generateStylesFromContent(
201
+ ` ${includeBaseStyles ? "@tailwind base;" : ""}
202
+ @tailwind components;
203
+ @tailwind utilities;`,
204
+ markupString
205
+ );
206
+ }
207
+ const getBlocksTailwindCSS = (blocks, theme, includeBaseStyles = false) => {
208
+ return getTailwindCSS(theme, [lodashEs.replace(JSON.stringify(blocks), /#styles:,?/g, "")], [], "", includeBaseStyles);
209
+ };
210
+ const getStylesForBlocks = async (blocks, theme = {}, includeBaseStyles = true) => {
211
+ return await getBlocksTailwindCSS(blocks, theme, includeBaseStyles);
212
+ };
213
+ exports.RenderChaiBlocks = RenderChaiBlocks;
214
+ exports.convertToBlocks = convertToBlocks;
215
+ exports.getStylesForBlocks = getStylesForBlocks;