@chaibuilder/sdk 2.0.0-beta.6 → 2.0.0-beta.61

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 (52) hide show
  1. package/README.md +0 -4
  2. package/dist/ChaiThemeFn-Cort9tch.js +201 -0
  3. package/dist/ChaiThemeFn-DQu-2Eh9.cjs +13 -0
  4. package/dist/CodeEditor-BLTQpTTM.js +67 -0
  5. package/dist/CodeEditor-CJhjQonw.cjs +1 -0
  6. package/dist/Topbar-CEyGOl06.js +16 -0
  7. package/dist/Topbar-pFV2NO8v.cjs +1 -0
  8. package/dist/{context-menu-0lRey9QY.cjs → context-menu-C_ITMOD1.cjs} +1 -1
  9. package/dist/{context-menu-I8woggB3.js → context-menu-FCyNTUkl.js} +66 -66
  10. package/dist/core.cjs +61 -1
  11. package/dist/core.d.ts +116 -54
  12. package/dist/core.js +8836 -123
  13. package/dist/getSplitClasses-DodqA_KW.cjs +1 -0
  14. package/dist/getSplitClasses-DphwgQiE.js +48 -0
  15. package/dist/{iconBase-Ief2hJUZ.js → iconBase-DHfFLkem.js} +6 -12
  16. package/dist/{jsx-runtime-Sp0orL4X.js → jsx-runtime-Drh4NO5G.js} +234 -232
  17. package/dist/jsx-runtime-qcKc-DpB.cjs +30 -0
  18. package/dist/mockServiceWorker.js +39 -24
  19. package/dist/plugin-2xcljWGM.cjs +1 -0
  20. package/dist/plugin-kUMxtQR5.js +24 -0
  21. package/dist/render.cjs +2 -2
  22. package/dist/render.d.ts +35 -16
  23. package/dist/render.js +146 -136
  24. package/dist/runtime.cjs +1 -1
  25. package/dist/runtime.d.ts +0 -1
  26. package/dist/runtime.js +0 -20
  27. package/dist/{style.css → sdk.css} +1 -1
  28. package/dist/tailwind.cjs +1 -1
  29. package/dist/tailwind.d.ts +31 -26
  30. package/dist/tailwind.js +8 -10
  31. package/dist/ui.cjs +1 -1
  32. package/dist/ui.d.ts +6 -51
  33. package/dist/ui.js +199 -356
  34. package/dist/web-blocks.cjs +29 -2
  35. package/dist/web-blocks.js +1742 -822
  36. package/package.json +122 -121
  37. package/dist/CodeEditor-D-BYzobl.js +0 -127
  38. package/dist/CodeEditor-la8rXIF0.cjs +0 -1
  39. package/dist/STRINGS-Xxstm-7I.js +0 -7
  40. package/dist/STRINGS-Yl7cSWDc.cjs +0 -1
  41. package/dist/Topbar-501zWjpi.cjs +0 -1
  42. package/dist/Topbar-Npy8Q-99.js +0 -161
  43. package/dist/controls-lEwMTdPQ.js +0 -234
  44. package/dist/controls-p9IwFnPx.cjs +0 -1
  45. package/dist/index-kcfrsdbY.cjs +0 -61
  46. package/dist/index-pDSQeyx5.js +0 -8544
  47. package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
  48. package/dist/plugin-UiUFs2fK.js +0 -44
  49. package/dist/plugin-f6SDZ_Or.js +0 -108
  50. package/dist/plugin-jum1MjXp.cjs +0 -1
  51. package/dist/plugin-xOpS-UNV.cjs +0 -1
  52. /package/dist/{iconBase-aZzpqff_.cjs → iconBase-Cn2BsTrq.cjs} +0 -0
@@ -0,0 +1,30 @@
1
+ "use strict";const Pe=require("react");var V={exports:{}},k={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Te;function fr(){if(Te)return k;Te=1;var M=Pe,C=Symbol.for("react.element"),U=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,F=M.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,A={key:!0,ref:!0,__self:!0,__source:!0};function w(y,f,T){var p,E={},_=null,I=null;T!==void 0&&(_=""+T),f.key!==void 0&&(_=""+f.key),f.ref!==void 0&&(I=f.ref);for(p in f)m.call(f,p)&&!A.hasOwnProperty(p)&&(E[p]=f[p]);if(y&&y.defaultProps)for(p in f=y.defaultProps,f)E[p]===void 0&&(E[p]=f[p]);return{$$typeof:C,type:y,key:_,ref:I,props:E,_owner:F.current}}return k.Fragment=U,k.jsx=w,k.jsxs=w,k}var D={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Oe;function cr(){return Oe||(Oe=1,process.env.NODE_ENV!=="production"&&function(){var M=Pe,C=Symbol.for("react.element"),U=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),w=Symbol.for("react.provider"),y=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),H=Symbol.iterator,Ce="@@iterator";function we(e){if(e===null||typeof e!="object")return null;var r=H&&e[H]||e[Ce];return typeof r=="function"?r:null}var O=M.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];je("error",e,t)}}function je(e,r,t){{var n=O.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var xe=!1,ke=!1,De=!1,Fe=!1,Ae=!1,Z;Z=Symbol.for("react.module.reference");function Ie(e){return!!(typeof e=="string"||typeof e=="function"||e===m||e===A||Ae||e===F||e===T||e===p||Fe||e===I||xe||ke||De||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===E||e.$$typeof===w||e.$$typeof===y||e.$$typeof===f||e.$$typeof===Z||e.getModuleId!==void 0))}function $e(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function Q(e){return e.displayName||"Context"}function R(e){if(e==null)return null;if(typeof e.tag=="number"&&c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case m:return"Fragment";case U:return"Portal";case A:return"Profiler";case F:return"StrictMode";case T:return"Suspense";case p:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var r=e;return Q(r)+".Consumer";case w:var t=e;return Q(t._context)+".Provider";case f:return $e(e,e.render,"ForwardRef");case E:var n=e.displayName||null;return n!==null?n:R(e.type)||"Memo";case _:{var o=e,u=o._payload,i=o._init;try{return R(i(u))}catch{return null}}}return null}var b=Object.assign,j=0,ee,re,te,ne,ae,ie,oe;function ue(){}ue.__reactDisabledLog=!0;function We(){{if(j===0){ee=console.log,re=console.info,te=console.warn,ne=console.error,ae=console.group,ie=console.groupCollapsed,oe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ue,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}j++}}function Ye(){{if(j--,j===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:b({},e,{value:ee}),info:b({},e,{value:re}),warn:b({},e,{value:te}),error:b({},e,{value:ne}),group:b({},e,{value:ae}),groupCollapsed:b({},e,{value:ie}),groupEnd:b({},e,{value:oe})})}j<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var N=O.ReactCurrentDispatcher,J;function $(e,r,t){{if(J===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);J=n&&n[1]||""}return`
18
+ `+J+e}}var q=!1,W;{var Le=typeof WeakMap=="function"?WeakMap:Map;W=new Le}function se(e,r){if(!e||q)return"";{var t=W.get(e);if(t!==void 0)return t}var n;q=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=N.current,N.current=null,We();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(d){n=d}Reflect.construct(e,[],i)}else{try{i.call()}catch(d){n=d}e.call(i.prototype)}}else{try{throw Error()}catch(d){n=d}e()}}catch(d){if(d&&n&&typeof d.stack=="string"){for(var a=d.stack.split(`
19
+ `),v=n.stack.split(`
20
+ `),s=a.length-1,l=v.length-1;s>=1&&l>=0&&a[s]!==v[l];)l--;for(;s>=1&&l>=0;s--,l--)if(a[s]!==v[l]){if(s!==1||l!==1)do if(s--,l--,l<0||a[s]!==v[l]){var g=`
21
+ `+a[s].replace(" at new "," at ");return e.displayName&&g.includes("<anonymous>")&&(g=g.replace("<anonymous>",e.displayName)),typeof e=="function"&&W.set(e,g),g}while(s>=1&&l>=0);break}}}finally{q=!1,N.current=u,Ye(),Error.prepareStackTrace=o}var P=e?e.displayName||e.name:"",h=P?$(P):"";return typeof e=="function"&&W.set(e,h),h}function Ve(e,r,t){return se(e,!1)}function Me(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Y(e,r,t){if(e==null)return"";if(typeof e=="function")return se(e,Me(e));if(typeof e=="string")return $(e);switch(e){case T:return $("Suspense");case p:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return Ve(e.render);case E:return Y(e.type,r,t);case _:{var n=e,o=n._payload,u=n._init;try{return Y(u(o),r,t)}catch{}}}return""}var x=Object.prototype.hasOwnProperty,le={},fe=O.ReactDebugCurrentFrame;function L(e){if(e){var r=e._owner,t=Y(e.type,e._source,r?r.type:null);fe.setExtraStackFrame(t)}else fe.setExtraStackFrame(null)}function Ue(e,r,t,n,o){{var u=Function.call.bind(x);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var v=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(L(o),c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),L(null)),a instanceof Error&&!(a.message in le)&&(le[a.message]=!0,L(o),c("Failed %s type: %s",t,a.message),L(null))}}}var Ne=Array.isArray;function B(e){return Ne(e)}function Je(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function qe(e){try{return ce(e),!1}catch{return!0}}function ce(e){return""+e}function ve(e){if(qe(e))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Je(e)),ce(e)}var de=O.ReactCurrentOwner,Be={key:!0,ref:!0,__self:!0,__source:!0},pe,ge;function Ke(e){if(x.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ge(e){if(x.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ze(e,r){typeof e.ref=="string"&&de.current}function Xe(e,r){{var t=function(){pe||(pe=!0,c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function He(e,r){{var t=function(){ge||(ge=!0,c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Ze=function(e,r,t,n,o,u,i){var a={$$typeof:C,type:e,key:r,ref:t,props:i,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function Qe(e,r,t,n,o){{var u,i={},a=null,v=null;t!==void 0&&(ve(t),a=""+t),Ge(r)&&(ve(r.key),a=""+r.key),Ke(r)&&(v=r.ref,ze(r,o));for(u in r)x.call(r,u)&&!Be.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)i[u]===void 0&&(i[u]=s[u])}if(a||v){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&Xe(i,l),v&&He(i,l)}return Ze(e,a,v,o,n,de.current,i)}}var K=O.ReactCurrentOwner,Ee=O.ReactDebugCurrentFrame;function S(e){if(e){var r=e._owner,t=Y(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}var G;G=!1;function z(e){return typeof e=="object"&&e!==null&&e.$$typeof===C}function Re(){{if(K.current){var e=R(K.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function er(e){return""}var ye={};function rr(e){{var r=Re();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
24
+
25
+ Check the top-level render call using <`+t+">.")}return r}}function _e(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=rr(r);if(ye[t])return;ye[t]=!0;var n="";e&&e._owner&&e._owner!==K.current&&(n=" It was passed a child from "+R(e._owner.type)+"."),S(e),c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),S(null)}}function be(e,r){{if(typeof e!="object")return;if(B(e))for(var t=0;t<e.length;t++){var n=e[t];z(n)&&_e(n,r)}else if(z(e))e._store&&(e._store.validated=!0);else if(e){var o=we(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)z(i.value)&&_e(i.value,r)}}}function tr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===f||r.$$typeof===E))t=r.propTypes;else return;if(t){var n=R(r);Ue(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!G){G=!0;var o=R(r);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function nr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){S(e),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),S(null);break}}e.ref!==null&&(S(e),c("Invalid attribute `ref` supplied to `React.Fragment`."),S(null))}}var he={};function me(e,r,t,n,o,u){{var i=Ie(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=er();v?a+=v:a+=Re();var s;e===null?s="null":B(e)?s="array":e!==void 0&&e.$$typeof===C?(s="<"+(R(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var l=Qe(e,r,t,o,u);if(l==null)return l;if(i){var g=r.children;if(g!==void 0)if(n)if(B(g)){for(var P=0;P<g.length;P++)be(g[P],e);Object.freeze&&Object.freeze(g)}else c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else be(g,e)}if(x.call(r,"key")){var h=R(e),d=Object.keys(r).filter(function(lr){return lr!=="key"}),X=d.length>0?"{key: someKey, "+d.join(": ..., ")+": ...}":"{key: someKey}";if(!he[h+X]){var sr=d.length>0?"{"+d.join(": ..., ")+": ...}":"{}";c(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,X,h,sr,h),he[h+X]=!0}}return e===m?nr(l):tr(l),l}}function ar(e,r,t){return me(e,r,t,!0)}function ir(e,r,t){return me(e,r,t,!1)}var or=ir,ur=ar;D.Fragment=m,D.jsx=or,D.jsxs=ur}()),D}var Se;function vr(){return Se||(Se=1,process.env.NODE_ENV==="production"?V.exports=fr():V.exports=cr()),V.exports}var dr=vr();exports.jsxRuntimeExports=dr;
@@ -2,13 +2,14 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker (2.0.8).
5
+ * Mock Service Worker.
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 INTEGRITY_CHECKSUM = '0877fcdc026242810f5bfde0d7178db4'
11
+ const PACKAGE_VERSION = '2.7.0'
12
+ const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
12
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
14
  const activeClientIds = new Set()
14
15
 
@@ -48,7 +49,10 @@ self.addEventListener('message', async function (event) {
48
49
  case 'INTEGRITY_CHECK_REQUEST': {
49
50
  sendToClient(client, {
50
51
  type: 'INTEGRITY_CHECK_RESPONSE',
51
- payload: INTEGRITY_CHECKSUM,
52
+ payload: {
53
+ packageVersion: PACKAGE_VERSION,
54
+ checksum: INTEGRITY_CHECKSUM,
55
+ },
52
56
  })
53
57
  break
54
58
  }
@@ -58,7 +62,12 @@ self.addEventListener('message', async function (event) {
58
62
 
59
63
  sendToClient(client, {
60
64
  type: 'MOCKING_ENABLED',
61
- payload: true,
65
+ payload: {
66
+ client: {
67
+ id: client.id,
68
+ frameType: client.frameType,
69
+ },
70
+ },
62
71
  })
63
72
  break
64
73
  }
@@ -121,11 +130,6 @@ async function handleRequest(event, requestId) {
121
130
  if (client && activeClientIds.has(client.id)) {
122
131
  ;(async function () {
123
132
  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
129
133
 
130
134
  sendToClient(
131
135
  client,
@@ -137,11 +141,11 @@ async function handleRequest(event, requestId) {
137
141
  type: responseClone.type,
138
142
  status: responseClone.status,
139
143
  statusText: responseClone.statusText,
140
- body: responseBody,
144
+ body: responseClone.body,
141
145
  headers: Object.fromEntries(responseClone.headers.entries()),
142
146
  },
143
147
  },
144
- [responseBody],
148
+ [responseClone.body],
145
149
  )
146
150
  })()
147
151
  }
@@ -156,6 +160,10 @@ async function handleRequest(event, requestId) {
156
160
  async function resolveMainClient(event) {
157
161
  const client = await self.clients.get(event.clientId)
158
162
 
163
+ if (activeClientIds.has(event.clientId)) {
164
+ return client
165
+ }
166
+
159
167
  if (client?.frameType === 'top-level') {
160
168
  return client
161
169
  }
@@ -184,12 +192,26 @@ async function getResponse(event, client, requestId) {
184
192
  const requestClone = request.clone()
185
193
 
186
194
  function passthrough() {
187
- const headers = Object.fromEntries(requestClone.headers.entries())
195
+ // Cast the request headers to a new Headers instance
196
+ // so the headers can be manipulated with.
197
+ const headers = new Headers(requestClone.headers)
198
+
199
+ // Remove the "accept" header value that marked this request as passthrough.
200
+ // This prevents request alteration and also keeps it compliant with the
201
+ // user-defined CORS policies.
202
+ const acceptHeader = headers.get('accept')
203
+ if (acceptHeader) {
204
+ const values = acceptHeader.split(',').map((value) => value.trim())
205
+ const filteredValues = values.filter(
206
+ (value) => value !== 'msw/passthrough',
207
+ )
188
208
 
189
- // Remove internal MSW request header so the passthrough request
190
- // complies with any potential CORS preflight checks on the server.
191
- // Some servers forbid unknown request headers.
192
- delete headers['x-msw-intention']
209
+ if (filteredValues.length > 0) {
210
+ headers.set('accept', filteredValues.join(', '))
211
+ } else {
212
+ headers.delete('accept')
213
+ }
214
+ }
193
215
 
194
216
  return fetch(requestClone, { headers })
195
217
  }
@@ -207,13 +229,6 @@ async function getResponse(event, client, requestId) {
207
229
  return passthrough()
208
230
  }
209
231
 
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
-
217
232
  // Notify the client that a request has been intercepted.
218
233
  const requestBuffer = await request.arrayBuffer()
219
234
  const clientMessage = await sendToClient(
@@ -245,7 +260,7 @@ async function getResponse(event, client, requestId) {
245
260
  return respondWithMock(clientMessage.data)
246
261
  }
247
262
 
248
- case 'MOCK_NOT_FOUND': {
263
+ case 'PASSTHROUGH': {
249
264
  return passthrough()
250
265
  }
251
266
  }
@@ -0,0 +1 @@
1
+ "use strict";const n=require("./ChaiThemeFn-DQu-2Eh9.cjs"),o=(i=n.defaultThemeOptions)=>({container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...n.getChaiThemeOptions(i)}),r=n.plugin(function({addBase:i,theme:e}){i({"h1,h2,h3,h4,h5,h6":{fontFamily:e("fontFamily.heading")},body:{fontFamily:e("fontFamily.body"),color:e("colors.foreground"),backgroundColor:e("colors.background")}})});exports.chaiBuilderPlugin=r;exports.getChaiBuilderTheme=o;
@@ -0,0 +1,24 @@
1
+ import { g as r, d as a, p as i } from "./ChaiThemeFn-Cort9tch.js";
2
+ const t = (n = a) => ({
3
+ container: {
4
+ center: !0,
5
+ padding: "1rem",
6
+ screens: { "2xl": "1400px" }
7
+ },
8
+ ...r(n)
9
+ }), l = i(function({ addBase: n, theme: o }) {
10
+ n({
11
+ "h1,h2,h3,h4,h5,h6": {
12
+ fontFamily: o("fontFamily.heading")
13
+ },
14
+ body: {
15
+ fontFamily: o("fontFamily.body"),
16
+ color: o("colors.foreground"),
17
+ backgroundColor: o("colors.background")
18
+ }
19
+ });
20
+ });
21
+ export {
22
+ l as c,
23
+ t as g
24
+ };
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),a=require("./STRINGS-Yl7cSWDc.cjs"),d=require("./jsx-runtime-JYMCiFoE.cjs"),y=require("react"),x=require("tailwind-merge"),T=require("@chaibuilder/runtime"),B=require("@mhsdesign/jit-browser-tailwindcss"),C=require("@tailwindcss/forms"),q=require("@tailwindcss/typography"),R=require("@tailwindcss/aspect-ratio"),j=require("./plugin-jum1MjXp.cjs");require("./plugin-xOpS-UNV.cjs");const Y=(t,n="")=>{const s=t.replace(a.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=n+r.last(u),u.join(":")}return`${n}${l}`}).join(" "));return r.flattenDeep(s).join(" ")},O=t=>{if(!t)return[];try{return JSON.parse(A(t)).filter(e=>!e._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function A(t){const n=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return t.replace(n,e=>{const s=decodeURIComponent(e),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}const K=t=>{const n={};return Object.keys(t).forEach(e=>{r.isString(t[e])&&t[e].startsWith(a.SLOT_KEY)&&(n[e]=t[e].replace(a.SLOT_KEY,"").split(","))}),n},L=r.memoize((t,n)=>{const e=t.replace(a.STYLES_KEY,"").split(","),s=x.twMerge(e[0],e[1]);return n===""?s.replace(a.STYLES_KEY,"").trim():Y(s,n).replace(a.STYLES_KEY,"").trim()});function N(t,n){const e=r.get(t,`${n}_attrs`,{});r.has(e,"data-ai-key")&&delete e["data-ai-key"];const s=r.keys(e).join(" ");return r.includes(s,"x-show")&&!r.includes(s,"x-transition")&&(e["x-transition"]=""),e}function $(t,n){const e={};return Object.keys(t).forEach(s=>{if(r.isString(t[s])&&t[s].startsWith(a.STYLES_KEY)){const i=L(t[s],n);e[s]={className:i,...N(t,s)}}}),e}function P(t,n){const e=r.get(t,"_bindings",{});return r.isEmpty(e)?{...t}:(r.each(e,(s,i)=>{r.isString(s)&&r.get(n,s,null)&&(t[i]=r.get(n,s,null))}),t)}function v(t,n,e){if(r.isEmpty(n))return t;const s=r.cloneDeep(t);return r.forEach(r.keys(s),i=>{r.get(e,["props",i,"i18n"])&&!r.isEmpty(n)&&(s[i]=r.get(s,`${i}-${n}`,s[i]))}),s}function E({blocks:t,parent:n,classPrefix:e="",externalData:s={},blockModifierCallback:i,lang:p}){const g=t,l=o=>$(o,e),u=n?r.filter(t,{_parent:n}):r.filter(t,o=>r.isEmpty(o._parent));return d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:y.Children.toArray(u.map((o,_)=>{const m=K(o),h={};r.isEmpty(m)||Object.keys(m).forEach(c=>{h[c]=y.Children.toArray(m[c].map(S=>d.jsxRuntimeExports.jsx(E,{externalData:s,classPrefix:e,blocks:g,parent:S,lang:p})))});const w=r.filter(g,{_parent:o._id});h.children=w.length>0?d.jsxRuntimeExports.jsx(E,{externalData:s,classPrefix:e,parent:o._id,blocks:g,lang:p}):null;const f=T.getBlockComponent(o._type);if(f!==null){let c=o;const S=f.component;return c={...f.defaults,...o},i&&(c=i(c)),y.createElement(S,r.omit({blockProps:{},inBuilder:!1,...c,index:_,...P(v(o,p,f),s),...l(c),...h},["_parent"]))}return d.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function I(t,n,e=[],s="",i=!1){return await B.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:e,theme:{extend:j.getChaiBuilderTheme(t)},plugins:[C,q,R,j.chaiBuilderPlugin],corePlugins:{preflight:i},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./ChaiThemeFn-DQu-2Eh9.cjs"),r=require("lodash-es"),h=require("./getSplitClasses-DodqA_KW.cjs"),P=require("@mhsdesign/jit-browser-tailwindcss"),q=require("@tailwindcss/aspect-ratio"),F=require("@tailwindcss/container-queries"),v=require("@tailwindcss/forms"),O=require("@tailwindcss/typography"),C=require("./plugin-2xcljWGM.cjs"),a=require("./jsx-runtime-qcKc-DpB.cjs"),$=require("@chaibuilder/runtime"),p=require("react"),N=require("tailwind-merge"),Y=(e,s="")=>{const{classes:n}=h.getSplitChaiClasses(e),t=n.split(" ").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=s+r.last(u),u.join(":")}return`${s}${l}`}).join(" "));return r.flattenDeep(t).join(" ")},k=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 I(e,s,n=[],t="",i){return await P.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:C.getChaiBuilderTheme(e)},plugins:[v,O,q,F,C.chaiBuilderPlugin],corePlugins:{preflight:i},...t?{prefix:`${t}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,n)}const J=(t,n,e=!1)=>I(n,[r.replace(JSON.stringify(t),/#styles:,?/g,"")],[],"",e),F=async(t,n={},e=!0)=>await J(t,n,e);exports.RenderChaiBlocks=E;exports.convertToBlocks=O;exports.getStylesForBlocks=F;
3
+ @tailwind utilities;`,s)}const M=(e,s,n)=>{const t=JSON.stringify(e).replace(/#styles:([^"]*)/g,(i,o)=>`#styles:${o.replace(/,/g," ")}`.replace(/#styles:/g,""));return I(s,[t],[],"",n)},J=async(e,s=f.defaultThemeOptions,n=!1)=>await M(e,s,n);async function K(e){const s=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return a.jsxRuntimeExports.jsx(p.Suspense,{children:p.createElement(e.component,{...e.props,...s})})}const L=r.memoize((e,s)=>{const{baseClasses:n,classes:t}=h.getSplitChaiClasses(e),i=N.twMerge(n,t);return s===""?i.replace(h.STYLES_KEY,"").trim():Y(i,s).replace(h.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 U(e,s){const n={};return Object.keys(e).forEach(t=>{if(r.isString(e[t])&&e[t].startsWith(h.STYLES_KEY)){const i=L(e[t],s);n[t]={className:i,...b(e,t)}}}),n}function V(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 W(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 z=()=>a.jsxRuntimeExports.jsx("span",{children:"Loading..."});function E({blocks:e,parent:s,classPrefix:n="",externalData:t={},blockModifierCallback:i=null,lang:o="",fallbackLang:g="",metadata:l={}}){const u=e,j=c=>U(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:p.Children.toArray(T.map((c,w)=>{const S={},B=r.filter(u,{_parent:c._id});S.children=B.length>0?a.jsxRuntimeExports.jsx(E,{externalData:t,classPrefix:n,parent:c._id,blocks:u,lang:o||g,metadata:l}):null;const d=$.getRegisteredChaiBlock(c._type);if(d!==null){let m=c;const x=d.component;m={...d.defaults,...c},i&&(m=i(m));const R=o===g?"":o,y=r.omit({blockProps:{},inBuilder:!1,...m,index:w,...V(W(c,R,d),t),...j(m),...S,metadata:l,lang:o||g},["_parent"]);if(r.has(d,"dataProvider")){const _=r.get(d,"suspenseFallback",z);return a.jsxRuntimeExports.jsx(p.Suspense,{fallback:p.createElement(_),children:a.jsxRuntimeExports.jsx(K,{lang:o||g,metadata:l,dataProvider:d.dataProvider,block:c,component:x,props:y})})}return a.jsxRuntimeExports.jsx(p.Suspense,{children:p.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=E;exports.convertToBlocks=k;exports.getStylesForBlocks=J;
package/dist/render.d.ts CHANGED
@@ -1,40 +1,59 @@
1
1
  import { JSX as JSX_2 } from 'react/jsx-runtime';
2
2
 
3
- declare type ChaiBlock = {
3
+ declare type BorderRadiusValue = false | string;
4
+
5
+ declare type ChaiBlock<T = Record<string, any>> = {
4
6
  _id: string;
5
- _type: string;
6
7
  _name?: string;
7
8
  _parent?: string | null | undefined;
8
9
  _bindings?: Record<string, string>;
9
- } & Record<string, any>;
10
-
11
- declare type ChaiBuilderTailwindTheme<T extends Record<string, unknown> = Record<string, unknown>> = {
12
- primaryColor: string;
13
- secondaryColor: string;
14
- headingFont: string;
15
- bodyFont: string;
16
- roundedCorners: string;
17
- bodyBgLightColor: string;
18
- bodyBgDarkColor: string;
19
- bodyTextLightColor: string;
20
- bodyTextDarkColor: string;
10
+ _type: string;
21
11
  } & T;
22
12
 
13
+ declare type ChaiBuilderThemeOptions = {
14
+ fontFamily: false | Record<VariableKey, string>;
15
+ borderRadius: BorderRadiusValue;
16
+ colors: false | {
17
+ group: string;
18
+ items: Record<VariableKey, [HSLColor, HSLColor]>;
19
+ }[];
20
+ };
21
+
22
+ declare type ChaiBuilderThemeValues = {
23
+ fontFamily: Record<string, string>;
24
+ borderRadius: string;
25
+ colors: Record<string, string[]>;
26
+ };
27
+
23
28
  /**
24
29
  * This function converts the chai format content to chai blocks
25
30
  * @param chaiFormatContent
26
31
  */
27
32
  export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
28
33
 
29
- export declare const getStylesForBlocks: (blocks: ChaiBlock[], theme?: ChaiBuilderTailwindTheme | Record<string, string>, includeBaseStyles?: boolean) => Promise<string>;
34
+ export declare const getChaiThemeCssVariables: (chaiTheme: Partial<ChaiBuilderThemeValues>) => string;
30
35
 
31
- export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, blockModifierCallback, lang, }: {
36
+ export declare const getStylesForBlocks: (blocks: ChaiBlock[], themeOptions?: ChaiBuilderThemeOptions, includeBaseStyles?: boolean) => Promise<string>;
37
+
38
+ export declare const getThemeFontsCSSImport: (chaiTheme: {
39
+ fontFamily: Record<string, string>;
40
+ }) => any;
41
+
42
+ export declare const getThemeFontsLinkMarkup: (chaiTheme: Pick<Partial<ChaiBuilderThemeValues>, "fontFamily">) => any;
43
+
44
+ declare type HSLColor = string;
45
+
46
+ export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, blockModifierCallback, lang, fallbackLang, metadata, }: {
32
47
  blocks: ChaiBlock[];
33
48
  parent?: string;
34
49
  classPrefix?: string;
35
50
  externalData?: Record<string, any>;
36
51
  blockModifierCallback?: (block: ChaiBlock) => ChaiBlock;
37
52
  lang?: string;
53
+ fallbackLang?: string;
54
+ metadata?: Record<string, any>;
38
55
  }): JSX_2.Element;
39
56
 
57
+ declare type VariableKey = string;
58
+
40
59
  export { }
package/dist/render.js CHANGED
@@ -1,167 +1,177 @@
1
- import { last as T, flattenDeep as $, memoize as N, filter as _, isEmpty as d, omit as R, isString as j, get as l, each as J, cloneDeep as P, forEach as I, keys as x, has as K, includes as C, replace as L } from "lodash-es";
2
- import { S as f, a as B } from "./STRINGS-Xxstm-7I.js";
3
- import { j as u } from "./jsx-runtime-Sp0orL4X.js";
4
- import w from "react";
5
- import { twMerge as W } from "tailwind-merge";
6
- import { getBlockComponent as Y } from "@chaibuilder/runtime";
7
- import { createTailwindcss as v } from "@mhsdesign/jit-browser-tailwindcss";
8
- import F from "@tailwindcss/forms";
9
- import U from "@tailwindcss/typography";
10
- import z from "@tailwindcss/aspect-ratio";
11
- import { g as M, c as q } from "./plugin-UiUFs2fK.js";
12
- import "./plugin-f6SDZ_Or.js";
13
- const D = (t, r = "") => {
14
- const s = t.replace(f, "").split(",").map((n) => n.split(" ").map((a) => {
15
- if (a === "")
16
- return "";
17
- if (a.includes(":")) {
18
- const c = a.split(":");
19
- return c[c.length - 1] = r + T(c), c.join(":");
1
+ import { d as v } from "./ChaiThemeFn-Cort9tch.js";
2
+ import { a as Bt, b as Et, c as $t } from "./ChaiThemeFn-Cort9tch.js";
3
+ import { last as N, flattenDeep as R, memoize as A, filter as g, isEmpty as f, omit as I, has as J, get as p, each as U, isString as j, cloneDeep as K, forEach as M, keys as P, includes as _ } from "lodash-es";
4
+ import { g as T, S as h } from "./getSplitClasses-DphwgQiE.js";
5
+ import { createTailwindcss as W } from "@mhsdesign/jit-browser-tailwindcss";
6
+ import Y from "@tailwindcss/aspect-ratio";
7
+ import b from "@tailwindcss/container-queries";
8
+ import z from "@tailwindcss/forms";
9
+ import D from "@tailwindcss/typography";
10
+ import { g as L, c as Q } from "./plugin-kUMxtQR5.js";
11
+ import { j as a } from "./jsx-runtime-Drh4NO5G.js";
12
+ import { getRegisteredChaiBlock as V } from "@chaibuilder/runtime";
13
+ import S, { Suspense as y, createElement as q } from "react";
14
+ import { twMerge as G } from "tailwind-merge";
15
+ const H = (t, s = "") => {
16
+ const { classes: n } = T(t), e = n.split(" ").map((r) => r.split(" ").map((c) => {
17
+ if (c === "") return "";
18
+ if (c.includes(":")) {
19
+ const l = c.split(":");
20
+ return l[l.length - 1] = s + N(l), l.join(":");
20
21
  }
21
- return `${r}${a}`;
22
+ return `${s}${c}`;
22
23
  }).join(" "));
23
- return $(s).join(" ");
24
- }, dt = (t) => {
25
- if (!t)
26
- return [];
24
+ return R(e).join(" ");
25
+ }, _t = (t) => {
26
+ if (!t) return [];
27
27
  try {
28
- return JSON.parse(G(t)).filter((e) => !e._type.startsWith("@chai"));
28
+ return JSON.parse(X(t)).filter((n) => !n._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
- function G(t) {
34
- const r = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
35
- return t.replace(r, (e) => {
36
- const s = decodeURIComponent(e), n = s.indexOf("public");
37
- return n !== -1 ? s.substring(n + 6) : s;
33
+ function X(t) {
34
+ const s = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
35
+ return t.replace(s, (n) => {
36
+ const e = decodeURIComponent(n), r = e.indexOf("public");
37
+ return r !== -1 ? e.substring(r + 6) : e;
38
38
  });
39
39
  }
40
- const H = (t) => {
41
- const r = {};
42
- return Object.keys(t).forEach((e) => {
43
- j(t[e]) && t[e].startsWith(B) && (r[e] = t[e].replace(B, "").split(","));
44
- }), r;
45
- }, Q = N((t, r) => {
46
- const e = t.replace(f, "").split(","), s = W(e[0], e[1]);
47
- return r === "" ? s.replace(f, "").trim() : D(s, r).replace(f, "").trim();
40
+ async function Z(t, s, n = [], e = "", r) {
41
+ return await W({
42
+ tailwindConfig: {
43
+ darkMode: "class",
44
+ safelist: n,
45
+ theme: { extend: L(t) },
46
+ plugins: [z, D, Y, b, Q],
47
+ corePlugins: { preflight: r },
48
+ ...e ? { prefix: `${e}` } : {}
49
+ }
50
+ }).generateStylesFromContent(
51
+ ` ${r ? "@tailwind base;" : ""}
52
+ @tailwind components;
53
+ @tailwind utilities;`,
54
+ s
55
+ );
56
+ }
57
+ const k = (t, s, n) => {
58
+ const e = JSON.stringify(t).replace(/#styles:([^"]*)/g, (r, i) => `#styles:${i.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
59
+ return Z(s, [e], [], "", n);
60
+ }, jt = async (t, s = v, n = !1) => await k(t, s, n);
61
+ async function tt(t) {
62
+ const s = await (t == null ? void 0 : t.dataProvider(t.block, t.lang, t.metadata));
63
+ return /* @__PURE__ */ a.jsx(y, { children: S.createElement(t.component, { ...t.props, ...s }) });
64
+ }
65
+ const et = A((t, s) => {
66
+ const { baseClasses: n, classes: e } = T(t), r = G(n, e);
67
+ return s === "" ? r.replace(h, "").trim() : H(r, s).replace(h, "").trim();
48
68
  });
49
- function V(t, r) {
50
- const e = l(t, `${r}_attrs`, {});
51
- K(e, "data-ai-key") && delete e["data-ai-key"];
52
- const s = x(e).join(" ");
53
- return C(s, "x-show") && !C(s, "x-transition") && (e["x-transition"] = ""), e;
69
+ function st(t, s) {
70
+ const n = p(t, `${s}_attrs`, {}), e = P(n).join(" ");
71
+ return _(e, "x-show") && !_(e, "x-transition") && (n["x-transition"] = ""), n;
54
72
  }
55
- function X(t, r) {
56
- const e = {};
57
- return Object.keys(t).forEach((s) => {
58
- if (j(t[s]) && t[s].startsWith(f)) {
59
- const n = Q(t[s], r);
60
- e[s] = {
61
- className: n,
62
- ...V(t, s)
73
+ function nt(t, s) {
74
+ const n = {};
75
+ return Object.keys(t).forEach((e) => {
76
+ if (j(t[e]) && t[e].startsWith(h)) {
77
+ const r = et(t[e], s);
78
+ n[e] = {
79
+ className: r,
80
+ ...st(t, e)
63
81
  };
64
82
  }
65
- }), e;
83
+ }), n;
66
84
  }
67
- function Z(t, r) {
68
- const e = l(t, "_bindings", {});
69
- return d(e) ? { ...t } : (J(e, (s, n) => {
70
- j(s) && l(r, s, null) && (t[n] = l(r, s, null));
85
+ function rt(t, s) {
86
+ const n = p(t, "_bindings", {});
87
+ return f(n) ? { ...t } : (U(n, (e, r) => {
88
+ j(e) && p(s, e, null) && (t[r] = p(s, e, null));
71
89
  }), t);
72
90
  }
73
- function b(t, r, e) {
74
- if (d(r))
75
- return t;
76
- const s = P(t);
77
- return I(x(s), (n) => {
78
- l(e, ["props", n, "i18n"]) && !d(r) && (s[n] = l(s, `${n}-${r}`, s[n]));
79
- }), s;
91
+ function it(t, s, n) {
92
+ if (f(s)) return t;
93
+ const e = K(t), r = p(n, "i18nProps", []);
94
+ return M(P(e), (i) => {
95
+ r.includes(i) && !f(s) && (e[i] = p(e, `${i}-${s}`, e[i]));
96
+ }), e;
80
97
  }
81
- function E({
98
+ const ot = () => /* @__PURE__ */ a.jsx("span", { children: "Loading..." });
99
+ function at({
82
100
  blocks: t,
83
- parent: r,
84
- classPrefix: e = "",
85
- externalData: s = {},
86
- blockModifierCallback: n,
87
- lang: p
101
+ parent: s,
102
+ classPrefix: n = "",
103
+ externalData: e = {},
104
+ blockModifierCallback: r = null,
105
+ lang: i = "",
106
+ fallbackLang: d = "",
107
+ metadata: c = {}
88
108
  }) {
89
- const m = t, a = (i) => X(i, e), c = r ? _(t, { _parent: r }) : _(t, (i) => d(i._parent));
90
- return /* @__PURE__ */ u.jsx(u.Fragment, { children: w.Children.toArray(
91
- c.map((i, O) => {
92
- const h = H(i), y = {};
93
- d(h) || Object.keys(h).forEach((o) => {
94
- y[o] = w.Children.toArray(
95
- h[o].map((S) => /* @__PURE__ */ u.jsx(
96
- E,
97
- {
98
- externalData: s,
99
- classPrefix: e,
100
- blocks: m,
101
- parent: S,
102
- lang: p
103
- }
104
- ))
105
- );
106
- });
107
- const A = _(m, { _parent: i._id });
108
- y.children = A.length > 0 ? /* @__PURE__ */ u.jsx(
109
- E,
109
+ const l = t, B = (o) => nt(o, n), E = s ? g(t, { _parent: s }) : g(t, (o) => f(o._parent));
110
+ return /* @__PURE__ */ a.jsx(a.Fragment, { children: S.Children.toArray(
111
+ E.map((o, $) => {
112
+ const C = {}, F = g(l, { _parent: o._id });
113
+ C.children = F.length > 0 ? /* @__PURE__ */ a.jsx(
114
+ at,
110
115
  {
111
- externalData: s,
112
- classPrefix: e,
113
- parent: i._id,
114
- blocks: m,
115
- lang: p
116
+ externalData: e,
117
+ classPrefix: n,
118
+ parent: o._id,
119
+ blocks: l,
120
+ lang: i || d,
121
+ metadata: c
116
122
  }
117
123
  ) : null;
118
- const g = Y(i._type);
119
- if (g !== null) {
120
- let o = i;
121
- const S = g.component;
122
- return o = { ...g.defaults, ...i }, n && (o = n(o)), w.createElement(
123
- S,
124
- R(
125
- {
126
- blockProps: {},
127
- inBuilder: !1,
128
- ...o,
129
- index: O,
130
- ...Z(b(i, p, g), s),
131
- ...a(o),
132
- ...y
133
- },
134
- ["_parent"]
135
- )
124
+ const u = V(o._type);
125
+ if (u !== null) {
126
+ let m = o;
127
+ const x = u.component;
128
+ m = { ...u.defaults, ...o }, r && (m = r(m));
129
+ const w = I(
130
+ {
131
+ blockProps: {},
132
+ inBuilder: !1,
133
+ ...m,
134
+ index: $,
135
+ ...rt(it(o, i === d ? "" : i, u), e),
136
+ ...B(m),
137
+ ...C,
138
+ metadata: c,
139
+ lang: i || d
140
+ },
141
+ ["_parent"]
136
142
  );
143
+ if (J(u, "dataProvider")) {
144
+ const O = p(
145
+ u,
146
+ "suspenseFallback",
147
+ ot
148
+ );
149
+ return /* @__PURE__ */ a.jsx(y, { fallback: q(O), children: /* @__PURE__ */ a.jsx(
150
+ tt,
151
+ {
152
+ lang: i || d,
153
+ metadata: c,
154
+ dataProvider: u.dataProvider,
155
+ block: o,
156
+ component: x,
157
+ props: w
158
+ }
159
+ ) });
160
+ }
161
+ return /* @__PURE__ */ a.jsx(y, { children: S.createElement(x, w) });
137
162
  }
138
- return /* @__PURE__ */ u.jsxs("noscript", { children: [
139
- i._type,
163
+ return /* @__PURE__ */ a.jsxs("noscript", { children: [
164
+ o._type,
140
165
  " not found"
141
166
  ] });
142
167
  })
143
168
  ) });
144
169
  }
145
- async function k(t, r, e = [], s = "", n = !1) {
146
- return await v({
147
- tailwindConfig: {
148
- darkMode: "class",
149
- safelist: e,
150
- theme: { extend: M(t) },
151
- plugins: [F, U, z, q],
152
- corePlugins: { preflight: n },
153
- ...s ? { prefix: `${s}` } : {}
154
- }
155
- }).generateStylesFromContent(
156
- ` ${n ? "@tailwind base;" : ""}
157
- @tailwind components;
158
- @tailwind utilities;`,
159
- r
160
- );
161
- }
162
- const tt = (t, r, e = !1) => k(r, [L(JSON.stringify(t), /#styles:,?/g, "")], [], "", e), mt = async (t, r = {}, e = !0) => await tt(t, r, e);
163
170
  export {
164
- E as RenderChaiBlocks,
165
- dt as convertToBlocks,
166
- mt as getStylesForBlocks
171
+ at as RenderChaiBlocks,
172
+ _t as convertToBlocks,
173
+ Bt as getChaiThemeCssVariables,
174
+ jt as getStylesForBlocks,
175
+ Et as getThemeFontsCSSImport,
176
+ $t as getThemeFontsLinkMarkup
167
177
  };
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@chaibuilder/runtime"),e=require("./controls-p9IwFnPx.cjs");require("lodash-es");exports.Checkbox=e.c;exports.Code=e.l;exports.Color=e.h;exports.Icon=e.q;exports.Image=e.x;exports.InfoField=e.u;exports.Link=e.w;exports.List=e.S;exports.Model=e.b;exports.MultilineText=e.f;exports.Numeric=e.s;exports.RichText=e.m;exports.SelectOption=e.y;exports.SingleLineText=e.g;exports.Slot=e.r;exports.Styles=e.T;Object.keys(r).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>r[t]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@chaibuilder/runtime");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});