@builder.io/sdk-react 2.0.2 → 2.0.5

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-exports.cjs +29 -29
  2. package/lib/browser/blocks-exports.mjs +300 -278
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/init.cjs +1 -1
  6. package/lib/browser/init.mjs +1 -1
  7. package/lib/browser/server-entry-0c6c220c.js +688 -0
  8. package/lib/browser/server-entry-7e145817.cjs +2 -0
  9. package/lib/browser/server-entry.cjs +1 -1
  10. package/lib/browser/server-entry.mjs +1 -1
  11. package/lib/edge/{accordion-4f96554c.cjs → accordion-72dab8ce.cjs} +1 -1
  12. package/lib/edge/{accordion-ca081054.js → accordion-99129d68.js} +1 -1
  13. package/lib/edge/blocks-426e0c44.js +808 -0
  14. package/lib/edge/blocks-53ae1b87.cjs +12 -0
  15. package/lib/edge/blocks-exports.cjs +1 -1
  16. package/lib/edge/blocks-exports.mjs +2 -2
  17. package/lib/edge/{button-41169061.js → button-778062cd.js} +2 -2
  18. package/lib/edge/{button-5d140f8e.cjs → button-967d0268.cjs} +1 -1
  19. package/lib/edge/{columns-f8916a18.js → columns-3a8c4d3f.js} +53 -51
  20. package/lib/edge/columns-3b921658.cjs +28 -0
  21. package/lib/edge/{content-variants-71ee0c76.js → content-variants-15d191de.js} +28 -26
  22. package/lib/edge/content-variants-4b8718f8.cjs +134 -0
  23. package/lib/edge/evaluate-26c0fdb7.js +2615 -0
  24. package/lib/edge/evaluate-c0eeb4f8.cjs +21 -0
  25. package/lib/edge/form-9d9dce5d.cjs +1 -0
  26. package/lib/edge/{form-ac2f2a0e.js → form-ccb0b912.js} +8 -7
  27. package/lib/edge/{get-class-prop-name-a677d7a5.js → get-class-prop-name-0a91c3bd.js} +1 -1
  28. package/lib/edge/{get-class-prop-name-a9b4959e.cjs → get-class-prop-name-eae60eae.cjs} +1 -1
  29. package/lib/edge/{image-e3fcd611.js → image-6a074aab.js} +27 -25
  30. package/lib/edge/image-eebfcbac.cjs +17 -0
  31. package/lib/edge/{img-b91cb4fd.cjs → img-183de27d.cjs} +1 -1
  32. package/lib/edge/{img-8fc26395.js → img-75751c89.js} +1 -1
  33. package/lib/edge/index.cjs +1 -1
  34. package/lib/edge/index.mjs +1 -1
  35. package/lib/edge/init.cjs +1 -1
  36. package/lib/edge/init.mjs +1 -1
  37. package/lib/edge/{input-549f090e.js → input-27972020.js} +1 -1
  38. package/lib/edge/{input-ec7c695a.cjs → input-fd18a67d.cjs} +1 -1
  39. package/lib/edge/{select-6a5a28ac.js → select-60ff549c.js} +1 -1
  40. package/lib/edge/{select-3ffa9294.cjs → select-6ea0d59f.cjs} +1 -1
  41. package/lib/edge/server-entry-4133a544.cjs +2 -0
  42. package/lib/edge/server-entry-feff6177.js +689 -0
  43. package/lib/edge/server-entry.cjs +1 -1
  44. package/lib/edge/server-entry.mjs +1 -1
  45. package/lib/edge/{slot-40de071b.js → slot-2347377e.js} +12 -11
  46. package/lib/edge/slot-a4509cae.cjs +1 -0
  47. package/lib/edge/{symbol-76e76298.cjs → symbol-98650b06.cjs} +1 -1
  48. package/lib/edge/{symbol-e6515a5f.js → symbol-dcef0d8e.js} +2 -2
  49. package/lib/edge/{tabs-b75be82d.js → tabs-0784574b.js} +10 -9
  50. package/lib/edge/tabs-4c131e17.cjs +1 -0
  51. package/lib/edge/text-1c1986aa.cjs +1 -0
  52. package/lib/edge/text-6f7cbc35.js +38 -0
  53. package/lib/node/blocks-exports.cjs +16 -16
  54. package/lib/node/blocks-exports.mjs +255 -233
  55. package/lib/node/index.cjs +1 -1
  56. package/lib/node/index.mjs +2 -2
  57. package/lib/node/init.cjs +1 -1
  58. package/lib/node/init.mjs +2 -2
  59. package/lib/node/{node-runtime-0e37d6f7.cjs → node-runtime-4978bc21.cjs} +2 -2
  60. package/lib/node/{node-runtime-0f3a5df1.js → node-runtime-ce5c71e5.js} +3 -2
  61. package/lib/node/server-entry-0c6c220c.js +688 -0
  62. package/lib/node/server-entry-7e145817.cjs +2 -0
  63. package/lib/node/server-entry.cjs +1 -1
  64. package/lib/node/server-entry.mjs +1 -1
  65. package/package.json +1 -1
  66. package/types/blocks/image/image.types.d.ts +2 -0
  67. package/types/blocks/symbol/symbol.types.d.ts +1 -0
  68. package/types/constants/sdk-version.d.ts +1 -1
  69. package/types/functions/register-component.d.ts +2 -2
  70. package/lib/browser/server-entry-419c051e.cjs +0 -2
  71. package/lib/browser/server-entry-825b4408.js +0 -695
  72. package/lib/edge/blocks-078044bc.cjs +0 -32
  73. package/lib/edge/blocks-f55c7d3e.js +0 -3418
  74. package/lib/edge/columns-354bf349.cjs +0 -28
  75. package/lib/edge/content-variants-89a9389a.cjs +0 -134
  76. package/lib/edge/form-f2d2c2bf.cjs +0 -1
  77. package/lib/edge/image-344ddbb0.cjs +0 -17
  78. package/lib/edge/server-entry-966ac144.cjs +0 -2
  79. package/lib/edge/server-entry-d2020acf.js +0 -695
  80. package/lib/edge/slot-8b27e15e.cjs +0 -1
  81. package/lib/edge/tabs-9c5af0ec.cjs +0 -1
  82. package/lib/edge/text-5915f038.js +0 -17
  83. package/lib/edge/text-e6dbb721.cjs +0 -1
  84. package/lib/node/server-entry-5ebd1c9b.js +0 -695
  85. package/lib/node/server-entry-8002325b.cjs +0 -2
@@ -1,695 +0,0 @@
1
- const v = "react", Q = (e) => {
2
- const t = {};
3
- return e.forEach((n, r) => {
4
- t[r] = n;
5
- }), t;
6
- }, L = (e) => e instanceof URLSearchParams ? Q(e) : e, V = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- function Y() {
11
- return c() && window.self !== window.top;
12
- }
13
- function Z(e) {
14
- return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
15
- V(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
16
- }
17
- function Ge(e) {
18
- const t = e || (c() ? window.location.search : void 0);
19
- return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
20
- }
21
- const U = (e) => JSON.parse(JSON.stringify(e)), ze = (e) => ({
22
- type: "builder.registerComponent",
23
- data: ne(e)
24
- }), ee = (e) => {
25
- const t = e.toString().trim();
26
- return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
27
- }, te = (e) => typeof e == "function" ? ee(e) : U(e), ne = ({
28
- inputs: e,
29
- ...t
30
- }) => ({
31
- ...U(t),
32
- inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
33
- ...r,
34
- [o]: te(s)
35
- }), {}))
36
- }), x = {};
37
- function re(e, t) {
38
- let n = x[e];
39
- if (n || (n = x[e] = []), n.push(t), c()) {
40
- const r = {
41
- type: "builder.register",
42
- data: {
43
- type: e,
44
- info: t
45
- }
46
- };
47
- try {
48
- parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
49
- } catch (o) {
50
- console.debug("Could not postmessage", o);
51
- }
52
- }
53
- }
54
- const A = {};
55
- function Je(e) {
56
- if (c()) {
57
- Object.assign(A, e);
58
- const t = {
59
- type: "builder.settingsChange",
60
- data: A
61
- };
62
- parent.postMessage(t, "*");
63
- }
64
- }
65
- const T = "builder.", oe = "options.", M = (e) => {
66
- if (!e)
67
- return {};
68
- const t = L(e), n = {};
69
- return Object.keys(t).forEach((r) => {
70
- if (r.startsWith(T)) {
71
- const o = r.replace(T, "").replace(oe, "");
72
- n[o] = t[r];
73
- }
74
- }), n;
75
- }, se = () => {
76
- if (!c())
77
- return {};
78
- const e = new URLSearchParams(window.location.search);
79
- return M(e);
80
- }, b = "[Builder.io]: ", f = {
81
- log: (...e) => console.log(b, ...e),
82
- error: (...e) => console.error(b, ...e),
83
- warn: (...e) => console.warn(b, ...e),
84
- debug: (...e) => console.debug(b, ...e)
85
- }, m = (e) => e != null, ie = (e) => {
86
- if (e === "localhost" || e === "127.0.0.1")
87
- return e;
88
- const t = e.split(".");
89
- return t.length > 2 ? t.slice(1).join(".") : e;
90
- }, N = ({
91
- name: e,
92
- canTrack: t
93
- }) => {
94
- var n;
95
- try {
96
- return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
97
- } catch (r) {
98
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
99
- return;
100
- }
101
- }, F = async (e) => N(e), ae = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ce = [["secure", ""], ["SameSite", "None"]], ue = ({
102
- name: e,
103
- value: t,
104
- expires: n
105
- }) => {
106
- const o = (c() ? location.protocol === "https:" : !0) ? ce : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", ie(window.location.hostname)], ...o];
107
- return ae(a);
108
- }, j = async ({
109
- name: e,
110
- value: t,
111
- expires: n,
112
- canTrack: r
113
- }) => {
114
- try {
115
- if (!r)
116
- return;
117
- const o = ue({
118
- name: e,
119
- value: t,
120
- expires: n
121
- });
122
- document.cookie = o;
123
- } catch (o) {
124
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
125
- }
126
- };
127
- function de() {
128
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
129
- const t = Math.random() * 16 | 0;
130
- return (e == "x" ? t : t & 3 | 8).toString(16);
131
- });
132
- }
133
- function D() {
134
- return de().replace(/-/g, "");
135
- }
136
- const K = "builderSessionId", le = async ({
137
- canTrack: e
138
- }) => {
139
- if (!e)
140
- return;
141
- const t = await F({
142
- name: K,
143
- canTrack: e
144
- });
145
- if (m(t))
146
- return t;
147
- {
148
- const n = fe();
149
- return he({
150
- id: n,
151
- canTrack: e
152
- }), n;
153
- }
154
- }, fe = () => D(), he = ({
155
- id: e,
156
- canTrack: t
157
- }) => j({
158
- name: K,
159
- value: e,
160
- canTrack: t
161
- }), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ge = ({
162
- key: e,
163
- canTrack: t
164
- }) => {
165
- var n;
166
- try {
167
- return t ? (n = W()) == null ? void 0 : n.getItem(e) : void 0;
168
- } catch (r) {
169
- console.debug("[LocalStorage] GET error: ", r);
170
- return;
171
- }
172
- }, pe = ({
173
- key: e,
174
- canTrack: t,
175
- value: n
176
- }) => {
177
- var r;
178
- try {
179
- t && ((r = W()) == null || r.setItem(e, n));
180
- } catch (o) {
181
- console.debug("[LocalStorage] SET error: ", o);
182
- }
183
- }, _ = "builderVisitorId", me = ({
184
- canTrack: e
185
- }) => {
186
- if (!e)
187
- return;
188
- const t = ge({
189
- key: _,
190
- canTrack: e
191
- });
192
- if (m(t))
193
- return t;
194
- {
195
- const n = ye();
196
- return we({
197
- id: n,
198
- canTrack: e
199
- }), n;
200
- }
201
- }, ye = () => D(), we = ({
202
- id: e,
203
- canTrack: t
204
- }) => pe({
205
- key: _,
206
- value: e,
207
- canTrack: t
208
- }), Se = () => {
209
- if (c()) {
210
- const e = new URL(location.href);
211
- return e.pathname === "" && (e.pathname = "/"), e;
212
- } else
213
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
214
- }, be = () => typeof navigator == "object" && navigator.userAgent || "", ve = () => {
215
- const e = be(), t = {
216
- Android() {
217
- return e.match(/Android/i);
218
- },
219
- BlackBerry() {
220
- return e.match(/BlackBerry/i);
221
- },
222
- iOS() {
223
- return e.match(/iPhone|iPod/i);
224
- },
225
- Opera() {
226
- return e.match(/Opera Mini/i);
227
- },
228
- Windows() {
229
- return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
230
- },
231
- any() {
232
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
233
- }
234
- }, n = e.match(/Tablet|iPad/i), r = Se();
235
- return {
236
- urlPath: r == null ? void 0 : r.pathname,
237
- host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
238
- device: n ? "tablet" : t.any() ? "mobile" : "desktop"
239
- };
240
- }, Ie = async ({
241
- canTrack: e
242
- }) => {
243
- if (!e)
244
- return {
245
- visitorId: void 0,
246
- sessionId: void 0
247
- };
248
- const t = await le({
249
- canTrack: e
250
- }), n = me({
251
- canTrack: e
252
- });
253
- return {
254
- sessionId: t,
255
- visitorId: n
256
- };
257
- }, ke = async ({
258
- type: e,
259
- canTrack: t,
260
- apiKey: n,
261
- metadata: r,
262
- ...o
263
- }) => ({
264
- type: e,
265
- data: {
266
- ...o,
267
- metadata: {
268
- url: location.href,
269
- ...r
270
- },
271
- ...await Ie({
272
- canTrack: t
273
- }),
274
- userAttributes: ve(),
275
- ownerId: n
276
- }
277
- });
278
- async function Ee(e) {
279
- if (!e.apiKey) {
280
- f.error("Missing API key for track call. Please provide your API key.");
281
- return;
282
- }
283
- if (e.canTrack && !Z() && (c() || v === "reactNative"))
284
- return fetch("https://cdn.builder.io/api/v1/track", {
285
- method: "POST",
286
- body: JSON.stringify({
287
- events: [await ke(e)]
288
- }),
289
- headers: {
290
- "content-type": "application/json"
291
- },
292
- mode: "cors"
293
- }).catch((t) => {
294
- console.error("Failed to track: ", t);
295
- });
296
- }
297
- const He = (e) => Ee({
298
- ...e,
299
- canTrack: !0
300
- }), Oe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
301
- function $(e, t) {
302
- if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
303
- return !1;
304
- const n = new URL(t.origin), r = n.hostname;
305
- return (e || Oe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
306
- }
307
- const Pe = "2.0.2", Xe = () => {
308
- re("insertMenu", {
309
- name: "_default",
310
- default: !0,
311
- items: [{
312
- name: "Box"
313
- }, {
314
- name: "Text"
315
- }, {
316
- name: "Image"
317
- }, {
318
- name: "Columns"
319
- }, {
320
- name: "Core:Section"
321
- }, {
322
- name: "Core:Button"
323
- }, {
324
- name: "Embed"
325
- }, {
326
- name: "Custom Code"
327
- }]
328
- });
329
- };
330
- let R = !1;
331
- const Ce = (e = {}) => {
332
- var t, n;
333
- R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
334
- type: "builder.sdkInfo",
335
- data: {
336
- target: v,
337
- version: Pe,
338
- supportsPatchUpdates: !1,
339
- // Supports builder-model="..." attribute which is needed to
340
- // scope our '+ add block' button styling
341
- supportsAddBlockScoping: !0,
342
- supportsCustomBreakpoints: !0
343
- }
344
- }, "*"), (n = window.parent) == null || n.postMessage({
345
- type: "builder.updateContent",
346
- data: {
347
- options: e
348
- }
349
- }, "*"), window.addEventListener("message", (r) => {
350
- var s, a;
351
- if (!$(e.trustedHosts, r))
352
- return;
353
- const {
354
- data: o
355
- } = r;
356
- if (o != null && o.type)
357
- switch (o.type) {
358
- case "builder.evaluate": {
359
- const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
360
- let u, h = null;
361
- try {
362
- u = I.apply(null, y);
363
- } catch (g) {
364
- h = g;
365
- }
366
- h ? (s = window.parent) == null || s.postMessage({
367
- type: "builder.evaluateError",
368
- data: {
369
- id: p,
370
- error: h.message
371
- }
372
- }, "*") : u && typeof u.then == "function" ? u.then((g) => {
373
- var w;
374
- (w = window.parent) == null || w.postMessage({
375
- type: "builder.evaluateResult",
376
- data: {
377
- id: p,
378
- result: g
379
- }
380
- }, "*");
381
- }).catch(console.error) : (a = window.parent) == null || a.postMessage({
382
- type: "builder.evaluateResult",
383
- data: {
384
- result: u,
385
- id: p
386
- }
387
- }, "*");
388
- break;
389
- }
390
- }
391
- })));
392
- }, xe = ({
393
- model: e,
394
- trustedHosts: t,
395
- callbacks: n
396
- }) => (r) => {
397
- if (!$(t, r))
398
- return;
399
- const {
400
- data: o
401
- } = r;
402
- if (o)
403
- switch (o.type) {
404
- case "builder.configureSdk": {
405
- n.configureSdk(o.data);
406
- break;
407
- }
408
- case "builder.triggerAnimation": {
409
- n.animation(o.data);
410
- break;
411
- }
412
- case "builder.contentUpdate": {
413
- const s = o.data, a = s.key || s.alias || s.entry || s.modelName, d = s.data;
414
- a === e && n.contentUpdate(d);
415
- break;
416
- }
417
- }
418
- }, qe = (e, t, n) => {
419
- if (!c)
420
- return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
421
- };
422
- Ce();
423
- const r = xe({
424
- callbacks: {
425
- contentUpdate: t,
426
- animation: () => {
427
- },
428
- configureSdk: () => {
429
- }
430
- },
431
- model: e,
432
- trustedHosts: n == null ? void 0 : n.trustedHosts
433
- });
434
- return window.addEventListener("message", r), () => {
435
- window.removeEventListener("message", r);
436
- };
437
- }, Ae = "builder.tests", E = (e) => `${Ae}.${e}`, Te = ({
438
- contentId: e
439
- }) => F({
440
- name: E(e),
441
- canTrack: !0
442
- }), Re = ({
443
- contentId: e
444
- }) => N({
445
- name: E(e),
446
- canTrack: !0
447
- }), Be = ({
448
- contentId: e,
449
- value: t
450
- }) => j({
451
- name: E(e),
452
- value: t,
453
- canTrack: !0
454
- }), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Le = ({
455
- id: e,
456
- variations: t
457
- }) => {
458
- var o;
459
- let n = 0;
460
- const r = Math.random();
461
- for (const s in t) {
462
- const a = (o = t[s]) == null ? void 0 : o.testRatio;
463
- if (n += a, r < n)
464
- return s;
465
- }
466
- return e;
467
- }, z = (e) => {
468
- const t = Le(e);
469
- return Be({
470
- contentId: e.id,
471
- value: t
472
- }).catch((n) => {
473
- f.error("could not store A/B test variation: ", n);
474
- }), t;
475
- }, J = ({
476
- item: e,
477
- testGroupId: t
478
- }) => {
479
- const n = e.variations[t];
480
- return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
481
- !n ? {
482
- testVariationId: e.id,
483
- testVariationName: "Default"
484
- } : {
485
- data: n.data,
486
- testVariationId: n.id,
487
- testVariationName: n.name || (n.id === e.id ? "Default" : "")
488
- };
489
- }, Qe = ({
490
- item: e,
491
- canTrack: t
492
- }) => {
493
- if (!t)
494
- return e;
495
- if (!e)
496
- return;
497
- if (!G(e))
498
- return e;
499
- const n = Re({
500
- contentId: e.id
501
- }) || z({
502
- variations: e.variations,
503
- id: e.id
504
- }), r = J({
505
- item: e,
506
- testGroupId: n
507
- });
508
- return {
509
- ...e,
510
- ...r
511
- };
512
- }, Ve = async ({
513
- item: e,
514
- canTrack: t
515
- }) => {
516
- if (!t || !G(e))
517
- return e;
518
- const r = await Te({
519
- contentId: e.id
520
- }) || z({
521
- variations: e.variations,
522
- id: e.id
523
- }), o = J({
524
- item: e,
525
- testGroupId: r
526
- });
527
- return {
528
- ...e,
529
- ...o
530
- };
531
- }, Ue = (e) => m(e) ? e : !0;
532
- function Me() {
533
- return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
534
- }
535
- function Ne() {
536
- const e = Me().fetch;
537
- if (typeof e == "undefined")
538
- throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
539
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
540
- return e;
541
- }
542
- const Fe = Ne();
543
- function k(e, t = null, n = ".") {
544
- return Object.keys(e).reduce((r, o) => {
545
- const s = e[o], a = [t, o].filter(Boolean).join(n);
546
- return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
547
- ...r,
548
- ...k(s, a, n)
549
- } : {
550
- ...r,
551
- [a]: s
552
- };
553
- }, {});
554
- }
555
- function H(e, t, n = {}) {
556
- for (const r in e) {
557
- const o = e[r], s = t ? t + "." + r : r;
558
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
559
- }
560
- return n;
561
- }
562
- const je = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
563
- const {
564
- limit: t = 30,
565
- userAttributes: n,
566
- query: r,
567
- model: o,
568
- apiKey: s,
569
- enrich: a,
570
- locale: d,
571
- apiVersion: y = je,
572
- fields: p,
573
- omit: I,
574
- offset: u,
575
- cacheSeconds: h,
576
- staleCacheSeconds: g,
577
- sort: w,
578
- includeUnpublished: P
579
- } = e;
580
- if (!s)
581
- throw new Error("Missing API key");
582
- if (!["v3"].includes(y))
583
- throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
584
- const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
585
- if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
586
- const l = k({
587
- sort: w
588
- });
589
- for (const S in l)
590
- i.searchParams.set(S, JSON.stringify(l[S]));
591
- }
592
- const q = {
593
- ...se(),
594
- ...L(e.options || {})
595
- }, C = k(q);
596
- for (const l in C)
597
- i.searchParams.set(l, String(C[l]));
598
- if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
599
- const l = H({
600
- query: r
601
- });
602
- for (const S in l)
603
- i.searchParams.set(S, JSON.stringify(l[S]));
604
- }
605
- return i;
606
- }, De = (e) => "results" in e;
607
- async function Ke(e) {
608
- const t = await $e({
609
- ...e,
610
- limit: 1
611
- });
612
- return t && t[0] || null;
613
- }
614
- const We = async (e) => {
615
- var s;
616
- const t = O(e);
617
- return await (await ((s = e.fetch) != null ? s : Fe)(t.href, e.fetchOptions)).json();
618
- }, _e = async (e, t, n = O(e)) => {
619
- const r = Ue(e.canTrack);
620
- if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
621
- return t.results;
622
- try {
623
- const o = [];
624
- for (const s of t.results)
625
- o.push(await Ve({
626
- item: s,
627
- canTrack: r
628
- }));
629
- t.results = o;
630
- } catch (o) {
631
- f.error("Could not process A/B tests. ", o);
632
- }
633
- return t.results;
634
- };
635
- async function $e(e) {
636
- try {
637
- const t = O(e), n = await We(e);
638
- return De(n) ? _e(e, n) : (f.error("Error fetching data. ", {
639
- url: t,
640
- content: n,
641
- options: e
642
- }), null);
643
- } catch (t) {
644
- return f.error("Error fetching data. ", t), null;
645
- }
646
- }
647
- const Ye = async (e) => {
648
- var r, o, s;
649
- const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
650
- ...e,
651
- apiKey: e.apiKey,
652
- model: e.model || "page",
653
- userAttributes: {
654
- ...e.userAttributes,
655
- ...t ? {
656
- urlPath: t
657
- } : {}
658
- },
659
- options: M(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
660
- };
661
- return {
662
- apiKey: n.apiKey,
663
- model: n.model,
664
- content: await Ke(n)
665
- };
666
- };
667
- export {
668
- b as MSG_PREFIX,
669
- v as TARGET,
670
- _e as _processContentResult,
671
- Ee as _track,
672
- m as checkIsDefined,
673
- xe as createEditorListener,
674
- ze as createRegisterComponentMessage,
675
- U as fastClone,
676
- Fe as fetch,
677
- Ye as fetchBuilderProps,
678
- $e as fetchEntries,
679
- Ke as fetchOneEntry,
680
- M as getBuilderSearchParams,
681
- Ue as getDefaultCanTrack,
682
- ve as getUserAttributes,
683
- Qe as handleABTestingSync,
684
- c as isBrowser,
685
- Z as isEditing,
686
- Ge as isPreviewing,
687
- f as logger,
688
- re as register,
689
- Xe as registerInsertMenu,
690
- ne as serializeComponentInfo,
691
- Je as setEditorSettings,
692
- Ce as setupBrowserForEditing,
693
- qe as subscribeToEditor,
694
- He as track
695
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),o=require("./blocks-078044bc.cjs");require("react");require("./blocks-exports.cjs");require("./server-entry-966ac144.cjs");require("./get-class-prop-name-a9b4959e.cjs");require("./dynamic-renderer-b29b45ca.cjs");function u(e){var t,r,n;return i.jsx("div",{style:{pointerEvents:"auto"},...!((t=e.builderContext.context)!=null&&t.symbolId)&&{"builder-slot":e.name},children:i.jsx(o.Blocks,{parent:(r=e.builderContext.context)==null?void 0:r.symbolId,path:`symbol.data.${e.name}`,context:e.builderContext,blocks:(n=e.builderContext.rootState)==null?void 0:n[e.name]})})}exports.default=u;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("react"),r=require("./blocks-078044bc.cjs");require("./blocks-exports.cjs");require("./server-entry-966ac144.cjs");require("./get-class-prop-name-a9b4959e.cjs");require("./dynamic-renderer-b29b45ca.cjs");function s(e){var c;const[t,a]=u.useState(()=>e.defaultActiveTab?e.defaultActiveTab-1:0);function o(n){return e.tabs&&e.tabs[n].content}function b(n){n===t&&e.collapsible?a(-1):a(n)}return i.jsxs("div",{children:[i.jsx("div",{className:"builder-tabs-wrap",style:{display:"flex",flexDirection:"row",justifyContent:e.tabHeaderLayout||"flex-start",overflow:"auto"},children:(c=e.tabs)==null?void 0:c.map((n,l)=>i.jsx("span",{className:`builder-tab-wrap ${t===l?"builder-tab-active":""}`,style:{...t===l?e.activeTabStyle:{}},onClick:d=>b(l),children:i.jsx(r.Blocks,{parent:e.builderBlock.id,path:`component.options.tabs.${l}.label`,blocks:n.label,context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})},l))}),o(t)?i.jsx("div",{children:i.jsx(r.Blocks,{parent:e.builderBlock.id,path:`component.options.tabs.${t}.content`,blocks:o(t),context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})}):null]})}exports.default=s;
@@ -1,17 +0,0 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- function o(e) {
3
- var t;
4
- return /* @__PURE__ */ n(
5
- "div",
6
- {
7
- className: "builder-text",
8
- dangerouslySetInnerHTML: { __html: ((t = e.text) == null ? void 0 : t.toString()) || "" },
9
- style: {
10
- outline: "none"
11
- }
12
- }
13
- );
14
- }
15
- export {
16
- o as default
17
- };