@builder.io/sdk-react-nextjs 0.16.13 → 0.16.14

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 (85) hide show
  1. package/lib/browser/blocks/columns/columns.cjs +2 -2
  2. package/lib/browser/blocks/columns/columns.mjs +2 -2
  3. package/lib/browser/blocks/image/image.cjs +4 -4
  4. package/lib/browser/blocks/image/image.mjs +25 -25
  5. package/lib/browser/components/awaiter.cjs +1 -0
  6. package/lib/browser/components/awaiter.mjs +10 -0
  7. package/lib/browser/components/block/components/interactive-element.cjs +1 -1
  8. package/lib/browser/components/block/components/interactive-element.mjs +19 -9
  9. package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
  10. package/lib/browser/components/blocks/blocks-wrapper.mjs +5 -5
  11. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  12. package/lib/browser/components/content/components/enable-editor.mjs +114 -139
  13. package/lib/browser/components/content/content.cjs +1 -1
  14. package/lib/browser/components/content/content.mjs +62 -43
  15. package/lib/browser/constants/sdk-version.cjs +1 -1
  16. package/lib/browser/constants/sdk-version.mjs +1 -1
  17. package/lib/browser/functions/evaluate/browser-runtime/browser.cjs +1 -1
  18. package/lib/browser/functions/evaluate/browser-runtime/browser.mjs +19 -45
  19. package/lib/browser/functions/evaluate/helpers.cjs +1 -1
  20. package/lib/browser/functions/evaluate/helpers.mjs +50 -24
  21. package/lib/browser/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
  22. package/lib/browser/functions/evaluate/node-runtime/node-runtime.mjs +7 -7
  23. package/lib/edge/blocks/columns/columns.cjs +2 -2
  24. package/lib/edge/blocks/columns/columns.mjs +2 -2
  25. package/lib/edge/blocks/image/image.cjs +4 -4
  26. package/lib/edge/blocks/image/image.mjs +25 -25
  27. package/lib/edge/components/awaiter.cjs +1 -0
  28. package/lib/edge/components/awaiter.mjs +10 -0
  29. package/lib/edge/components/block/components/interactive-element.cjs +1 -1
  30. package/lib/edge/components/block/components/interactive-element.mjs +19 -9
  31. package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
  32. package/lib/edge/components/blocks/blocks-wrapper.mjs +5 -5
  33. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  34. package/lib/edge/components/content/components/enable-editor.mjs +114 -139
  35. package/lib/edge/components/content/content.cjs +1 -1
  36. package/lib/edge/components/content/content.mjs +62 -43
  37. package/lib/edge/constants/builder-registered-components.cjs +1 -1
  38. package/lib/edge/constants/builder-registered-components.mjs +1 -1
  39. package/lib/edge/constants/extra-components.cjs +1 -1
  40. package/lib/edge/constants/extra-components.mjs +1 -1
  41. package/lib/edge/constants/sdk-version.cjs +1 -1
  42. package/lib/edge/constants/sdk-version.mjs +1 -1
  43. package/lib/edge/functions/evaluate/browser-runtime/browser.cjs +1 -1
  44. package/lib/edge/functions/evaluate/browser-runtime/browser.mjs +19 -45
  45. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +8 -10
  46. package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +70 -53
  47. package/lib/edge/functions/evaluate/helpers.cjs +1 -1
  48. package/lib/edge/functions/evaluate/helpers.mjs +50 -24
  49. package/lib/edge/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
  50. package/lib/edge/functions/evaluate/node-runtime/node-runtime.mjs +7 -7
  51. package/lib/node/blocks/columns/columns.cjs +2 -2
  52. package/lib/node/blocks/columns/columns.mjs +2 -2
  53. package/lib/node/blocks/image/image.cjs +4 -4
  54. package/lib/node/blocks/image/image.mjs +25 -25
  55. package/lib/node/components/awaiter.cjs +1 -0
  56. package/lib/node/components/awaiter.mjs +10 -0
  57. package/lib/node/components/block/components/interactive-element.cjs +1 -1
  58. package/lib/node/components/block/components/interactive-element.mjs +19 -9
  59. package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
  60. package/lib/node/components/blocks/blocks-wrapper.mjs +5 -5
  61. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  62. package/lib/node/components/content/components/enable-editor.mjs +114 -139
  63. package/lib/node/components/content/content.cjs +1 -1
  64. package/lib/node/components/content/content.mjs +62 -43
  65. package/lib/node/constants/sdk-version.cjs +1 -1
  66. package/lib/node/constants/sdk-version.mjs +1 -1
  67. package/lib/node/functions/evaluate/browser-runtime/browser.cjs +1 -1
  68. package/lib/node/functions/evaluate/browser-runtime/browser.mjs +19 -45
  69. package/lib/node/functions/evaluate/helpers.cjs +1 -1
  70. package/lib/node/functions/evaluate/helpers.mjs +50 -24
  71. package/lib/node/functions/evaluate/node-runtime/node-runtime.cjs +9 -9
  72. package/lib/node/functions/evaluate/node-runtime/node-runtime.mjs +26 -26
  73. package/package.json +1 -1
  74. package/types/cjs/components/awaiter.d.ts +14 -0
  75. package/types/cjs/constants/sdk-version.d.ts +1 -1
  76. package/types/cjs/context/component-reference-types.d.ts +4 -0
  77. package/types/cjs/context/types.d.ts +2 -1
  78. package/types/cjs/functions/evaluate/browser-runtime/browser.d.ts +0 -6
  79. package/types/cjs/functions/evaluate/helpers.d.ts +5 -0
  80. package/types/esm/components/awaiter.d.ts +14 -0
  81. package/types/esm/constants/sdk-version.d.ts +1 -1
  82. package/types/esm/context/component-reference-types.d.ts +4 -0
  83. package/types/esm/context/types.d.ts +2 -1
  84. package/types/esm/functions/evaluate/browser-runtime/browser.d.ts +0 -6
  85. package/types/esm/functions/evaluate/helpers.d.ts +5 -0
@@ -1,134 +1,117 @@
1
1
  "use client";
2
- import { jsx as H } from "react/jsx-runtime";
3
- import { useRef as O, useState as m, useEffect as d } from "react";
4
- import B from "../../../context/builder.context.mjs";
5
- import { evaluate as T } from "../../../functions/evaluate/evaluate.mjs";
6
- import { fastClone as F } from "../../../functions/fast-clone.mjs";
7
- import { fetchOneEntry as J } from "../../../functions/get-content/index.mjs";
8
- import { fetch as $ } from "../../../functions/get-fetch.mjs";
9
- import { isBrowser as j } from "../../../functions/is-browser.mjs";
2
+ import { jsx as R } from "react/jsx-runtime";
3
+ import { useRef as L, useState as m, useEffect as c } from "react";
4
+ import N from "../../../context/builder.context.mjs";
5
+ import { evaluate as U } from "../../../functions/evaluate/evaluate.mjs";
6
+ import { fastClone as _ } from "../../../functions/fast-clone.mjs";
7
+ import { fetchOneEntry as D } from "../../../functions/get-content/index.mjs";
8
+ import { isBrowser as y } from "../../../functions/is-browser.mjs";
10
9
  import { isEditing as f } from "../../../functions/is-editing.mjs";
11
- import { isPreviewing as z } from "../../../functions/is-previewing.mjs";
12
- import { createRegisterComponentMessage as G } from "../../../functions/register-component.mjs";
13
- import { _track as A } from "../../../functions/track/index.mjs";
14
- import { getInteractionPropertiesForEvent as Q } from "../../../functions/track/interaction.mjs";
15
- import { getDefaultCanTrack as V } from "../../../helpers/canTrack.mjs";
16
- import { logger as X } from "../../../helpers/logger.mjs";
17
- import { postPreviewContent as Y } from "../../../helpers/preview-lru-cache/set.mjs";
18
- import { createEditorListener as Z } from "../../../helpers/subscribe-to-editor.mjs";
19
- import { registerInsertMenu as p, setupBrowserForEditing as ee } from "../../../scripts/init-editing.mjs";
20
- import { triggerAnimation as te } from "../../block/animator.mjs";
21
- import { getWrapperClassName as ne } from "./styles.helpers.mjs";
22
- import { useRouter as ie } from "next/navigation";
23
- function Ke(e) {
24
- var k, w, y, R, K, L, q;
25
- const c = O(null);
10
+ import { isPreviewing as O } from "../../../functions/is-previewing.mjs";
11
+ import { createRegisterComponentMessage as B } from "../../../functions/register-component.mjs";
12
+ import { _track as K } from "../../../functions/track/index.mjs";
13
+ import { getInteractionPropertiesForEvent as F } from "../../../functions/track/interaction.mjs";
14
+ import { getDefaultCanTrack as q } from "../../../helpers/canTrack.mjs";
15
+ import { postPreviewContent as z } from "../../../helpers/preview-lru-cache/set.mjs";
16
+ import { createEditorListener as $ } from "../../../helpers/subscribe-to-editor.mjs";
17
+ import { registerInsertMenu as G, setupBrowserForEditing as J } from "../../../scripts/init-editing.mjs";
18
+ import { triggerAnimation as Q } from "../../block/animator.mjs";
19
+ import { getWrapperClassName as X } from "./styles.helpers.mjs";
20
+ import { useRouter as Y } from "next/navigation";
21
+ function xe(e) {
22
+ var w, k, P;
23
+ const d = L(null);
26
24
  function g(n) {
27
- var i, a;
25
+ var r, i;
28
26
  const t = {
29
27
  ...e.builderContextSignal.rootState,
30
28
  ...n
31
29
  };
32
- e.builderContextSignal.rootSetState ? (a = (i = e.builderContextSignal).rootSetState) == null || a.call(i, t) : e.builderContextSignal.rootState = t;
30
+ e.builderContextSignal.rootSetState ? (i = (r = e.builderContextSignal).rootSetState) == null || i.call(r, t) : e.builderContextSignal.rootState = t;
33
31
  }
34
- function S(n) {
35
- var i, a, o, r, s;
32
+ function b(n) {
33
+ var r, i, a, o, s;
36
34
  const t = {
37
35
  ...e.builderContextSignal.content,
38
36
  ...n,
39
37
  data: {
40
- ...(i = e.builderContextSignal.content) == null ? void 0 : i.data,
38
+ ...(r = e.builderContextSignal.content) == null ? void 0 : r.data,
41
39
  ...n == null ? void 0 : n.data
42
40
  },
43
41
  meta: {
44
- ...(a = e.builderContextSignal.content) == null ? void 0 : a.meta,
42
+ ...(i = e.builderContextSignal.content) == null ? void 0 : i.meta,
45
43
  ...n == null ? void 0 : n.meta,
46
- breakpoints: ((o = n == null ? void 0 : n.meta) == null ? void 0 : o.breakpoints) || ((s = (r = e.builderContextSignal.content) == null ? void 0 : r.meta) == null ? void 0 : s.breakpoints)
44
+ breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((s = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : s.breakpoints)
47
45
  }
48
46
  };
49
- Y({
47
+ z({
50
48
  value: t,
51
49
  key: t.id
52
50
  }).then(() => {
53
- _.refresh();
51
+ j.refresh();
54
52
  });
55
53
  }
56
- function M() {
54
+ function H() {
57
55
  return e.showContent ? {} : {
58
56
  hidden: !0,
59
57
  "aria-hidden": !0
60
58
  };
61
59
  }
62
- const [N, ae] = m(
60
+ const [T, Z] = m(
63
61
  () => e.contentWrapper || "div"
64
62
  );
65
63
  function v(n) {
66
- return Z({
64
+ return $({
67
65
  model: e.model,
68
66
  trustedHosts: e.trustedHosts,
69
67
  callbacks: {
70
68
  configureSdk: (t) => {
71
- var o;
72
- const { breakpoints: i, contentId: a } = t;
73
- !a || a !== ((o = e.builderContextSignal.content) == null ? void 0 : o.id) || i && S({
69
+ var a;
70
+ const { breakpoints: r, contentId: i } = t;
71
+ !i || i !== ((a = e.builderContextSignal.content) == null ? void 0 : a.id) || r && b({
74
72
  meta: {
75
- breakpoints: i
73
+ breakpoints: r
76
74
  }
77
75
  });
78
76
  },
79
77
  animation: (t) => {
80
- te(t);
78
+ Q(t);
81
79
  },
82
80
  contentUpdate: (t) => {
83
- S(t);
81
+ b(t);
84
82
  }
85
83
  }
86
84
  })(n);
87
85
  }
88
- function h() {
89
- var t, i;
90
- const n = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.jsCode;
91
- n && T({
92
- code: n,
93
- context: e.context || {},
94
- localState: void 0,
95
- rootState: e.builderContextSignal.rootState,
96
- rootSetState: e.builderContextSignal.rootSetState,
97
- /**
98
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
99
- */
100
- enableCache: !1
101
- });
102
- }
103
- const [C, oe] = m(() => ({})), [b, re] = m(() => ({})), [x, W] = m(() => !1);
104
- function U(n) {
105
- var t, i;
86
+ const [h, p] = m(() => ({})), [S, ee] = m(() => ({})), [C, V] = m(() => !1);
87
+ function M(n) {
88
+ var t, r;
106
89
  if (e.builderContextSignal.content) {
107
- const a = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, o = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
108
- A({
90
+ const i = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, a = (r = e.builderContextSignal.content) == null ? void 0 : r.id;
91
+ K({
109
92
  type: "click",
110
- canTrack: V(e.canTrack),
111
- contentId: o,
93
+ canTrack: q(e.canTrack),
94
+ contentId: a,
112
95
  apiKey: e.apiKey,
113
- variationId: a !== o ? a : void 0,
114
- ...Q(n),
115
- unique: !x
96
+ variationId: i !== a ? i : void 0,
97
+ ...F(n),
98
+ unique: !C
116
99
  });
117
100
  }
118
- x || W(!0);
101
+ C || V(!0);
119
102
  }
120
- function E() {
121
- var t, i, a;
122
- const n = (a = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? a : {};
123
- Object.entries(n).forEach(([o, r]) => {
124
- if (!r || b[o] || C[o] && !f())
103
+ function W() {
104
+ var t, r, i;
105
+ const n = (i = (r = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : r.httpRequests) != null ? i : {};
106
+ Object.entries(n).forEach(([a, o]) => {
107
+ if (!o || S[a] || h[a] && !f())
125
108
  return;
126
- b[o] = !0;
127
- const s = r.replace(
109
+ S[a] = !0;
110
+ const s = o.replace(
128
111
  /{{([^}]+)}}/g,
129
- (l, D) => String(
130
- T({
131
- code: D,
112
+ (l, A) => String(
113
+ U({
114
+ code: A,
132
115
  context: e.context || {},
133
116
  localState: void 0,
134
117
  rootState: e.builderContextSignal.rootState,
@@ -137,14 +120,14 @@ function Ke(e) {
137
120
  })
138
121
  )
139
122
  );
140
- $(s).then((l) => l.json()).then((l) => {
123
+ fetch(s).then((l) => l.json()).then((l) => {
141
124
  g({
142
- [o]: l
143
- }), C[o] = !0;
125
+ [a]: l
126
+ }), h[a] = !0;
144
127
  }).catch((l) => {
145
- console.error("error fetching dynamic data", r, l);
128
+ console.error("error fetching dynamic data", o, l);
146
129
  }).finally(() => {
147
- b[o] = !1;
130
+ S[a] = !1;
148
131
  });
149
132
  });
150
133
  }
@@ -154,7 +137,7 @@ function Ke(e) {
154
137
  "builder:component:stateChange",
155
138
  {
156
139
  detail: {
157
- state: F(e.builderContextSignal.rootState),
140
+ state: _(e.builderContextSignal.rootState),
158
141
  ref: {
159
142
  name: e.model
160
143
  }
@@ -163,8 +146,8 @@ function Ke(e) {
163
146
  )
164
147
  );
165
148
  }
166
- function I(n) {
167
- window.addEventListener("message", v), p(), ee({
149
+ function x(n) {
150
+ window.addEventListener("message", v), G(), J({
168
151
  ...e.locale ? {
169
152
  locale: e.locale
170
153
  } : {},
@@ -177,104 +160,96 @@ function Ke(e) {
177
160
  }), Object.values(
178
161
  e.builderContextSignal.componentInfos
179
162
  ).forEach((t) => {
180
- var a;
181
- const i = G(t);
182
- (a = window.parent) == null || a.postMessage(i, "*");
163
+ var i;
164
+ const r = B(t);
165
+ (i = window.parent) == null || i.postMessage(r, "*");
183
166
  }), window.addEventListener(
184
167
  "builder:component:stateChangeListenerActivated",
185
168
  u
186
169
  );
187
170
  }
188
- function P(n) {
189
- const t = new URL(location.href).searchParams, i = t.get("builder.preview"), a = t.get(
190
- `builder.overrides.${i}`
191
- ), o = t.get("apiKey") || t.get("builder.space");
192
- i === e.model && o === e.apiKey && (!e.content || a === e.content.id) && J({
171
+ function E(n) {
172
+ const t = new URL(location.href).searchParams, r = t.get("builder.preview"), i = t.get(
173
+ `builder.overrides.${r}`
174
+ ), a = t.get("apiKey") || t.get("builder.space");
175
+ r === e.model && a === e.apiKey && (!e.content || i === e.content.id) && D({
193
176
  model: e.model,
194
177
  apiKey: e.apiKey,
195
178
  apiVersion: e.builderContextSignal.apiVersion
196
- }).then((r) => {
197
- r && S(r);
179
+ }).then((o) => {
180
+ o && b(o);
198
181
  });
199
182
  }
200
- const _ = ie();
201
- return d(() => {
183
+ const j = Y(), I = L(!1);
184
+ return I.current || (W(), u(), I.current = !0), c(() => {
202
185
  var n;
203
- return (n = c.current) == null || n.addEventListener(
186
+ return (n = d.current) == null || n.addEventListener(
204
187
  "initeditingbldr",
205
- I
188
+ x
206
189
  ), () => {
207
190
  var t;
208
- return (t = c.current) == null ? void 0 : t.removeEventListener(
191
+ return (t = d.current) == null ? void 0 : t.removeEventListener(
209
192
  "initeditingbldr",
210
- I
193
+ x
211
194
  );
212
195
  };
213
- }, []), d(() => {
196
+ }, []), c(() => {
214
197
  var n;
215
- return (n = c.current) == null || n.addEventListener(
198
+ return (n = d.current) == null || n.addEventListener(
216
199
  "initpreviewingbldr",
217
- P
200
+ E
218
201
  ), () => {
219
202
  var t;
220
- return (t = c.current) == null ? void 0 : t.removeEventListener(
203
+ return (t = d.current) == null ? void 0 : t.removeEventListener(
221
204
  "initpreviewingbldr",
222
- P
205
+ E
223
206
  );
224
207
  };
225
- }, []), d(() => {
208
+ }, []), c(() => {
226
209
  var n, t;
227
- if (j()) {
228
- if (f() && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && V(e.canTrack)) {
229
- const a = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, o = (t = e.builderContextSignal.content) == null ? void 0 : t.id, r = e.apiKey;
230
- A({
210
+ if (y()) {
211
+ if (f() && d.current && d.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && q(e.canTrack)) {
212
+ const i = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, a = (t = e.builderContextSignal.content) == null ? void 0 : t.id, o = e.apiKey;
213
+ K({
231
214
  type: "impression",
232
215
  canTrack: !0,
233
- contentId: o,
234
- apiKey: r,
235
- variationId: a !== o ? a : void 0
216
+ contentId: a,
217
+ apiKey: o,
218
+ variationId: i !== a ? i : void 0
236
219
  });
237
220
  }
238
- z() && f();
221
+ O() && f();
239
222
  }
240
- }, []), d(() => {
241
- e.apiKey || X.error(
242
- "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
243
- ), h(), E(), u();
244
- }, []), d(() => {
245
- }, [e.content]), d(() => {
246
- h();
247
- }, [(w = (k = e.builderContextSignal.content) == null ? void 0 : k.data) == null ? void 0 : w.jsCode]), d(() => {
248
- E();
249
- }, [(R = (y = e.builderContextSignal.content) == null ? void 0 : y.data) == null ? void 0 : R.httpRequests]), d(() => {
223
+ }, []), c(() => {
224
+ }, [e.content]), c(() => {
250
225
  u();
251
- }, [e.builderContextSignal.rootState]), d(() => {
226
+ }, [e.builderContextSignal.rootState]), c(() => {
252
227
  e.data && g(e.data);
253
- }, [e.data]), d(() => {
228
+ }, [e.data]), c(() => {
254
229
  e.locale && g({
255
230
  locale: e.locale
256
231
  });
257
- }, [e.locale]), d(() => () => {
258
- j() && (window.removeEventListener("message", v), window.removeEventListener(
232
+ }, [e.locale]), c(() => () => {
233
+ y() && (window.removeEventListener("message", v), window.removeEventListener(
259
234
  "builder:component:stateChangeListenerActivated",
260
235
  u
261
236
  ));
262
- }, []), /* @__PURE__ */ H(B.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ H(
263
- N,
237
+ }, []), /* @__PURE__ */ R(N.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ R(
238
+ T,
264
239
  {
265
- ref: c,
266
- onClick: (n) => U(n),
267
- "builder-content-id": (K = e.builderContextSignal.content) == null ? void 0 : K.id,
240
+ ref: d,
241
+ onClick: (n) => M(n),
242
+ "builder-content-id": (w = e.builderContextSignal.content) == null ? void 0 : w.id,
268
243
  "builder-model": e.model,
269
- ...M(),
270
- ...e.contentWrapperProps,
271
- className: ne(
272
- ((L = e.content) == null ? void 0 : L.testVariationId) || ((q = e.content) == null ? void 0 : q.id)
244
+ className: X(
245
+ ((k = e.content) == null ? void 0 : k.testVariationId) || ((P = e.content) == null ? void 0 : P.id)
273
246
  ),
247
+ ...H(),
248
+ ...e.contentWrapperProps,
274
249
  children: e.children
275
250
  }
276
251
  ) : null });
277
252
  }
278
253
  export {
279
- Ke as default
254
+ xe as default
280
255
  };
@@ -1 +1 @@
1
- "use strict";const i=require("react/jsx-runtime"),x=require("../../constants/builder-registered-components.cjs"),S=require("../../functions/register-component.cjs"),f=require("../blocks/blocks.cjs"),y=require("../content-variants/helpers.cjs"),W=require("../inlined-script.cjs"),R=require("./components/enable-editor.cjs"),V=require("./components/styles.cjs"),h=require("./content.helpers.cjs");function v(t){var o,a,r,l,u,d,s,C,g,m,k;const q=y.getUpdateVariantVisibilityScript({variationId:(o=t.content)==null?void 0:o.testVariationId,contentId:(a=t.content)==null?void 0:a.id}),I=[...x.getDefaultRegisteredComponents(),...((r=t.customComponents)==null?void 0:r.filter(({models:e})=>!(e!=null&&e.length)||!t.model?!0:e.includes(t.model)))||[]].reduce((e,{component:b,...c})=>({...e,[c.name]:{component:b,...S.serializeIncludingFunctions(c)}}),{}),n={content:h.getContentInitialValue({content:t.content,data:t.data}),localState:void 0,rootState:h.getRootStateInitialValue({content:t.content,data:t.data,locale:t.locale}),rootSetState:void 0,context:t.context||{},canTrack:t.canTrack,apiKey:t.apiKey,apiVersion:t.apiVersion,componentInfos:[...x.getDefaultRegisteredComponents(),...((l=t.customComponents)==null?void 0:l.filter(({models:e})=>!(e!=null&&e.length)||!t.model?!0:e.includes(t.model)))||[]].reduce((e,{component:b,...c})=>({...e,[c.name]:S.serializeIncludingFunctions(c)}),{}),inheritedStyles:{},BlocksWrapper:t.blocksWrapper||"div",BlocksWrapperProps:t.blocksWrapperProps||{},nonce:t.nonce||""};return i.jsxs(R,{nonce:t.nonce,content:t.content,data:t.data,model:t.model,context:t.context,apiKey:t.apiKey,canTrack:t.canTrack,locale:t.locale,enrich:t.enrich,showContent:t.showContent,builderContextSignal:n,contentWrapper:t.contentWrapper,contentWrapperProps:t.contentWrapperProps,trustedHosts:t.trustedHosts,children:[t.isSsrAbTest?i.jsx(W,{id:"builderio-variant-visibility",scriptStr:q,nonce:t.nonce||""}):null,i.jsx(V,{nonce:t.nonce||"",isNestedRender:t.isNestedRender,contentId:(u=n.content)==null?void 0:u.id,cssCode:(s=(d=n.content)==null?void 0:d.data)==null?void 0:s.cssCode,customFonts:(g=(C=n.content)==null?void 0:C.data)==null?void 0:g.customFonts}),i.jsx(f,{blocks:(k=(m=n.content)==null?void 0:m.data)==null?void 0:k.blocks,context:n,registeredComponents:I,linkComponent:t.linkComponent})]})}module.exports=v;
1
+ "use strict";const c=require("react/jsx-runtime"),f=require("../../constants/builder-registered-components.cjs"),W=require("../../functions/evaluate/evaluate.cjs"),y=require("../../functions/register-component.cjs"),j=require("../../helpers/logger.cjs"),P=require("../blocks/blocks.cjs"),R=require("../content-variants/helpers.cjs"),V=require("../inlined-script.cjs"),K=require("./components/enable-editor.cjs"),T=require("./components/styles.cjs"),q=require("./content.helpers.cjs");function F(e){var a,r,l,s,u,d,C,g,S,m,k,x,b;const v=R.getUpdateVariantVisibilityScript({variationId:(a=e.content)==null?void 0:a.testVariationId,contentId:(r=e.content)==null?void 0:r.id}),I=[...f.getDefaultRegisteredComponents(),...((l=e.customComponents)==null?void 0:l.filter(({models:t})=>!(t!=null&&t.length)||!e.model?!0:t.includes(e.model)))||[]].reduce((t,{component:h,...o})=>({...t,[o.name]:{component:h,...y.serializeIncludingFunctions(o)}}),{}),n={content:q.getContentInitialValue({content:e.content,data:e.data}),localState:void 0,rootState:q.getRootStateInitialValue({content:e.content,data:e.data,locale:e.locale}),rootSetState:void 0,context:e.context||{},canTrack:e.canTrack,apiKey:e.apiKey,apiVersion:e.apiVersion,componentInfos:[...f.getDefaultRegisteredComponents(),...((s=e.customComponents)==null?void 0:s.filter(({models:t})=>!(t!=null&&t.length)||!e.model?!0:t.includes(e.model)))||[]].reduce((t,{component:h,...o})=>({...t,[o.name]:y.serializeIncludingFunctions(o)}),{}),inheritedStyles:{},BlocksWrapper:e.blocksWrapper||"div",BlocksWrapperProps:e.blocksWrapperProps||{},nonce:e.nonce||""};e.apiKey||j.logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");const i=(d=(u=n.content)==null?void 0:u.data)==null?void 0:d.jsCode;return i&&W.evaluate({code:i,context:e.context||{},localState:void 0,rootState:n.rootState,rootSetState:t=>{n.rootState=t},isExpression:!1,enableCache:!1}),c.jsxs(K,{nonce:e.nonce,content:e.content,data:e.data,model:e.model,context:e.context,apiKey:e.apiKey,canTrack:e.canTrack,locale:e.locale,enrich:e.enrich,showContent:e.showContent,builderContextSignal:n,contentWrapper:e.contentWrapper,contentWrapperProps:e.contentWrapperProps,trustedHosts:e.trustedHosts,children:[e.isSsrAbTest?c.jsx(V,{id:"builderio-variant-visibility",scriptStr:v,nonce:e.nonce||""}):null,c.jsx(T,{nonce:e.nonce||"",isNestedRender:e.isNestedRender,contentId:(C=n.content)==null?void 0:C.id,cssCode:(S=(g=n.content)==null?void 0:g.data)==null?void 0:S.cssCode,customFonts:(k=(m=n.content)==null?void 0:m.data)==null?void 0:k.customFonts}),c.jsx(P,{blocks:(b=(x=n.content)==null?void 0:x.data)==null?void 0:b.blocks,context:n,registeredComponents:I,linkComponent:e.linkComponent})]})}module.exports=F;
@@ -1,38 +1,40 @@
1
- import { jsxs as h, jsx as c } from "react/jsx-runtime";
1
+ import { jsxs as W, jsx as a } from "react/jsx-runtime";
2
2
  import { getDefaultRegisteredComponents as b } from "../../constants/builder-registered-components.mjs";
3
- import { serializeIncludingFunctions as g } from "../../functions/register-component.mjs";
4
- import y from "../blocks/blocks.mjs";
5
- import { getUpdateVariantVisibilityScript as W } from "../content-variants/helpers.mjs";
6
- import V from "../inlined-script.mjs";
7
- import v from "./components/enable-editor.mjs";
8
- import T from "./components/styles.mjs";
9
- import { getContentInitialValue as K, getRootStateInitialValue as P } from "./content.helpers.mjs";
10
- function A(t) {
11
- var i, a, r, l, d, u, m, f, s, C, k;
12
- const x = W({
3
+ import { evaluate as P } from "../../functions/evaluate/evaluate.mjs";
4
+ import { serializeIncludingFunctions as h } from "../../functions/register-component.mjs";
5
+ import { logger as V } from "../../helpers/logger.mjs";
6
+ import K from "../blocks/blocks.mjs";
7
+ import { getUpdateVariantVisibilityScript as T } from "../content-variants/helpers.mjs";
8
+ import j from "../inlined-script.mjs";
9
+ import R from "./components/enable-editor.mjs";
10
+ import A from "./components/styles.mjs";
11
+ import { getContentInitialValue as B, getRootStateInitialValue as E } from "./content.helpers.mjs";
12
+ function L(t) {
13
+ var c, r, l, d, u, m, s, f, C, S, k, g, x;
14
+ const I = T({
13
15
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
14
- variationId: (i = t.content) == null ? void 0 : i.testVariationId,
16
+ variationId: (c = t.content) == null ? void 0 : c.testVariationId,
15
17
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
16
- contentId: (a = t.content) == null ? void 0 : a.id
17
- }), I = [
18
+ contentId: (r = t.content) == null ? void 0 : r.id
19
+ }), v = [
18
20
  ...b(),
19
- ...((r = t.customComponents) == null ? void 0 : r.filter(({ models: n }) => !(n != null && n.length) || !t.model ? !0 : n.includes(t.model))) || []
21
+ ...((l = t.customComponents) == null ? void 0 : l.filter(({ models: e }) => !(e != null && e.length) || !t.model ? !0 : e.includes(t.model))) || []
20
22
  ].reduce(
21
- (n, { component: S, ...o }) => ({
22
- ...n,
23
+ (e, { component: y, ...o }) => ({
24
+ ...e,
23
25
  [o.name]: {
24
- component: S,
25
- ...g(o)
26
+ component: y,
27
+ ...h(o)
26
28
  }
27
29
  }),
28
30
  {}
29
- ), e = {
30
- content: K({
31
+ ), n = {
32
+ content: B({
31
33
  content: t.content,
32
34
  data: t.data
33
35
  }),
34
36
  localState: void 0,
35
- rootState: P({
37
+ rootState: E({
36
38
  content: t.content,
37
39
  data: t.data,
38
40
  locale: t.locale
@@ -44,11 +46,11 @@ function A(t) {
44
46
  apiVersion: t.apiVersion,
45
47
  componentInfos: [
46
48
  ...b(),
47
- ...((l = t.customComponents) == null ? void 0 : l.filter(({ models: n }) => !(n != null && n.length) || !t.model ? !0 : n.includes(t.model))) || []
49
+ ...((d = t.customComponents) == null ? void 0 : d.filter(({ models: e }) => !(e != null && e.length) || !t.model ? !0 : e.includes(t.model))) || []
48
50
  ].reduce(
49
- (n, { component: S, ...o }) => ({
50
- ...n,
51
- [o.name]: g(o)
51
+ (e, { component: y, ...o }) => ({
52
+ ...e,
53
+ [o.name]: h(o)
52
54
  }),
53
55
  {}
54
56
  ),
@@ -57,8 +59,25 @@ function A(t) {
57
59
  BlocksWrapperProps: t.blocksWrapperProps || {},
58
60
  nonce: t.nonce || ""
59
61
  };
60
- return /* @__PURE__ */ h(
61
- v,
62
+ t.apiKey || V.error(
63
+ "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
64
+ );
65
+ const i = (m = (u = n.content) == null ? void 0 : u.data) == null ? void 0 : m.jsCode;
66
+ return i && P({
67
+ code: i,
68
+ context: t.context || {},
69
+ localState: void 0,
70
+ rootState: n.rootState,
71
+ rootSetState: (e) => {
72
+ n.rootState = e;
73
+ },
74
+ isExpression: !1,
75
+ /**
76
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
77
+ */
78
+ enableCache: !1
79
+ }), /* @__PURE__ */ W(
80
+ R,
62
81
  {
63
82
  nonce: t.nonce,
64
83
  content: t.content,
@@ -70,35 +89,35 @@ function A(t) {
70
89
  locale: t.locale,
71
90
  enrich: t.enrich,
72
91
  showContent: t.showContent,
73
- builderContextSignal: e,
92
+ builderContextSignal: n,
74
93
  contentWrapper: t.contentWrapper,
75
94
  contentWrapperProps: t.contentWrapperProps,
76
95
  trustedHosts: t.trustedHosts,
77
96
  children: [
78
- t.isSsrAbTest ? /* @__PURE__ */ c(
79
- V,
97
+ t.isSsrAbTest ? /* @__PURE__ */ a(
98
+ j,
80
99
  {
81
100
  id: "builderio-variant-visibility",
82
- scriptStr: x,
101
+ scriptStr: I,
83
102
  nonce: t.nonce || ""
84
103
  }
85
104
  ) : null,
86
- /* @__PURE__ */ c(
87
- T,
105
+ /* @__PURE__ */ a(
106
+ A,
88
107
  {
89
108
  nonce: t.nonce || "",
90
109
  isNestedRender: t.isNestedRender,
91
- contentId: (d = e.content) == null ? void 0 : d.id,
92
- cssCode: (m = (u = e.content) == null ? void 0 : u.data) == null ? void 0 : m.cssCode,
93
- customFonts: (s = (f = e.content) == null ? void 0 : f.data) == null ? void 0 : s.customFonts
110
+ contentId: (s = n.content) == null ? void 0 : s.id,
111
+ cssCode: (C = (f = n.content) == null ? void 0 : f.data) == null ? void 0 : C.cssCode,
112
+ customFonts: (k = (S = n.content) == null ? void 0 : S.data) == null ? void 0 : k.customFonts
94
113
  }
95
114
  ),
96
- /* @__PURE__ */ c(
97
- y,
115
+ /* @__PURE__ */ a(
116
+ K,
98
117
  {
99
- blocks: (k = (C = e.content) == null ? void 0 : C.data) == null ? void 0 : k.blocks,
100
- context: e,
101
- registeredComponents: I,
118
+ blocks: (x = (g = n.content) == null ? void 0 : g.data) == null ? void 0 : x.blocks,
119
+ context: n,
120
+ registeredComponents: v,
102
121
  linkComponent: t.linkComponent
103
122
  }
104
123
  )
@@ -107,5 +126,5 @@ function A(t) {
107
126
  );
108
127
  }
109
128
  export {
110
- A as default
129
+ L as default
111
130
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.13";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.14";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.16.13";
1
+ const o = "0.16.14";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../helpers.cjs"),w=({code:s,builder:i,context:u,event:r,localState:n,rootSetState:e,rootState:t})=>{const f=l.getFunctionArguments({builder:i,context:u,event:r,state:c({rootState:t,localState:n,rootSetState:e})});return new Function(...f.map(([o])=>o),s)(...f.map(([,o])=>o))};function c({rootState:s,localState:i,rootSetState:u}){return new Proxy(s,{get:(r,n)=>{if(i&&n in i)return i[n];const e=r[n];return typeof e=="object"&&e!==null?c({rootState:e,localState:void 0,rootSetState:u?t=>{r[n]=t,u(r)}:void 0}):e},set:(r,n,e)=>{if(i&&n in i)throw new Error("Writing to local state is not allowed as it is read-only.");return r[n]=e,u==null||u(r),!0}})}exports.flattenState=c;exports.runInBrowser=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../helpers.cjs"),g=({code:r,builder:o,context:s,event:u,localState:c,rootSetState:a,rootState:i})=>{const e=n.getFunctionArguments({builder:o,context:s,event:u,state:n.flattenState({rootState:i,localState:c,rootSetState:a})});return new Function(...e.map(([t])=>t),r)(...e.map(([,t])=>t))};exports.runInBrowser=g;