@builder.io/sdk-react-nextjs 0.16.20 → 0.16.24

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 (53) hide show
  1. package/lib/browser/blocks/columns/columns.cjs +2 -2
  2. package/lib/browser/blocks/columns/columns.mjs +24 -24
  3. package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
  4. package/lib/browser/components/blocks/blocks-wrapper.mjs +26 -20
  5. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  6. package/lib/browser/components/content/components/enable-editor.mjs +58 -57
  7. package/lib/browser/constants/sdk-version.cjs +1 -1
  8. package/lib/browser/constants/sdk-version.mjs +1 -1
  9. package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
  10. package/lib/browser/functions/get-content/generate-content-url.mjs +43 -37
  11. package/lib/browser/functions/log-fetch.cjs +1 -0
  12. package/lib/browser/functions/log-fetch.mjs +8 -0
  13. package/lib/browser/functions/register-component.cjs +1 -1
  14. package/lib/browser/functions/register-component.mjs +6 -6
  15. package/lib/browser/functions/track/index.cjs +1 -1
  16. package/lib/browser/functions/track/index.mjs +18 -14
  17. package/lib/edge/blocks/columns/columns.cjs +2 -2
  18. package/lib/edge/blocks/columns/columns.mjs +24 -24
  19. package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
  20. package/lib/edge/components/blocks/blocks-wrapper.mjs +26 -20
  21. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  22. package/lib/edge/components/content/components/enable-editor.mjs +58 -57
  23. package/lib/edge/constants/sdk-version.cjs +1 -1
  24. package/lib/edge/constants/sdk-version.mjs +1 -1
  25. package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
  26. package/lib/edge/functions/get-content/generate-content-url.mjs +43 -37
  27. package/lib/edge/functions/log-fetch.cjs +1 -0
  28. package/lib/edge/functions/log-fetch.mjs +8 -0
  29. package/lib/edge/functions/register-component.cjs +1 -1
  30. package/lib/edge/functions/register-component.mjs +6 -6
  31. package/lib/edge/functions/track/index.cjs +1 -1
  32. package/lib/edge/functions/track/index.mjs +18 -14
  33. package/lib/node/blocks/columns/columns.cjs +2 -2
  34. package/lib/node/blocks/columns/columns.mjs +24 -24
  35. package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
  36. package/lib/node/components/blocks/blocks-wrapper.mjs +26 -20
  37. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  38. package/lib/node/components/content/components/enable-editor.mjs +58 -57
  39. package/lib/node/constants/sdk-version.cjs +1 -1
  40. package/lib/node/constants/sdk-version.mjs +1 -1
  41. package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
  42. package/lib/node/functions/get-content/generate-content-url.mjs +43 -37
  43. package/lib/node/functions/log-fetch.cjs +1 -0
  44. package/lib/node/functions/log-fetch.mjs +8 -0
  45. package/lib/node/functions/register-component.cjs +1 -1
  46. package/lib/node/functions/register-component.mjs +6 -6
  47. package/lib/node/functions/track/index.cjs +1 -1
  48. package/lib/node/functions/track/index.mjs +18 -14
  49. package/package.json +1 -1
  50. package/types/cjs/constants/sdk-version.d.ts +1 -1
  51. package/types/cjs/functions/log-fetch.d.ts +1 -0
  52. package/types/esm/constants/sdk-version.d.ts +1 -1
  53. package/types/esm/functions/log-fetch.d.ts +1 -0
@@ -7,44 +7,45 @@ import { fastClone as _ } from "../../../functions/fast-clone.mjs";
7
7
  import { fetchOneEntry as D } from "../../../functions/get-content/index.mjs";
8
8
  import { isBrowser as L } from "../../../functions/is-browser.mjs";
9
9
  import { isEditing as f } from "../../../functions/is-editing.mjs";
10
- import { isPreviewing as O } from "../../../functions/is-previewing.mjs";
10
+ import { isPreviewing as F } from "../../../functions/is-previewing.mjs";
11
+ import { logFetch as O } from "../../../functions/log-fetch.mjs";
11
12
  import { createRegisterComponentMessage as B } from "../../../functions/register-component.mjs";
12
13
  import { _track as y } from "../../../functions/track/index.mjs";
13
- import { getInteractionPropertiesForEvent as F } from "../../../functions/track/interaction.mjs";
14
+ import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
14
15
  import { getDefaultCanTrack as K } 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 Ct(t) {
16
+ import { postPreviewContent as $ } from "../../../helpers/preview-lru-cache/set.mjs";
17
+ import { createEditorListener as G } from "../../../helpers/subscribe-to-editor.mjs";
18
+ import { registerInsertMenu as J, setupBrowserForEditing as Q } from "../../../scripts/init-editing.mjs";
19
+ import { triggerAnimation as X } from "../../block/animator.mjs";
20
+ import { getWrapperClassName as Y } from "./styles.helpers.mjs";
21
+ import { useRouter as Z } from "next/navigation";
22
+ function It(t) {
22
23
  var w, k, P;
23
24
  const d = H(null);
24
25
  function g(n) {
25
- var a, i;
26
+ var r, i;
26
27
  const e = {
27
28
  ...t.builderContextSignal.rootState,
28
29
  ...n
29
30
  };
30
- t.builderContextSignal.rootSetState ? (i = (a = t.builderContextSignal).rootSetState) == null || i.call(a, e) : t.builderContextSignal.rootState = e;
31
+ t.builderContextSignal.rootSetState ? (i = (r = t.builderContextSignal).rootSetState) == null || i.call(r, e) : t.builderContextSignal.rootState = e;
31
32
  }
32
33
  function b(n) {
33
- var a, i, r, o, s;
34
+ var r, i, a, o, u;
34
35
  const e = {
35
36
  ...t.builderContextSignal.content,
36
37
  ...n,
37
38
  data: {
38
- ...(a = t.builderContextSignal.content) == null ? void 0 : a.data,
39
+ ...(r = t.builderContextSignal.content) == null ? void 0 : r.data,
39
40
  ...n == null ? void 0 : n.data
40
41
  },
41
42
  meta: {
42
43
  ...(i = t.builderContextSignal.content) == null ? void 0 : i.meta,
43
44
  ...n == null ? void 0 : n.meta,
44
- breakpoints: ((r = n == null ? void 0 : n.meta) == null ? void 0 : r.breakpoints) || ((s = (o = t.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : s.breakpoints)
45
+ breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((u = (o = t.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : u.breakpoints)
45
46
  }
46
47
  };
47
- z({
48
+ $({
48
49
  value: e,
49
50
  key: e.id
50
51
  }).then(() => {
@@ -57,25 +58,25 @@ function Ct(t) {
57
58
  "aria-hidden": !0
58
59
  };
59
60
  }
60
- const [T, Z] = m(
61
+ const [T, p] = m(
61
62
  () => t.contentWrapper || "div"
62
63
  );
63
64
  function v(n) {
64
- return $({
65
+ return G({
65
66
  model: t.model,
66
67
  trustedHosts: t.trustedHosts,
67
68
  callbacks: {
68
69
  configureSdk: (e) => {
69
- var r;
70
- const { breakpoints: a, contentId: i } = e;
71
- !i || i !== ((r = t.builderContextSignal.content) == null ? void 0 : r.id) || a && b({
70
+ var a;
71
+ const { breakpoints: r, contentId: i } = e;
72
+ !i || i !== ((a = t.builderContextSignal.content) == null ? void 0 : a.id) || r && b({
72
73
  meta: {
73
- breakpoints: a
74
+ breakpoints: r
74
75
  }
75
76
  });
76
77
  },
77
78
  animation: (e) => {
78
- Q(e);
79
+ X(e);
79
80
  },
80
81
  contentUpdate: (e) => {
81
82
  b(e);
@@ -83,32 +84,32 @@ function Ct(t) {
83
84
  }
84
85
  })(n);
85
86
  }
86
- const [h, p] = m(() => ({})), [S, tt] = m(() => ({})), [x, V] = m(() => !1);
87
+ const [h, tt] = m(() => ({})), [S, et] = m(() => ({})), [x, V] = m(() => !1);
87
88
  function M(n) {
88
- var e, a;
89
+ var e, r;
89
90
  if (t.builderContextSignal.content) {
90
- const i = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId, r = (a = t.builderContextSignal.content) == null ? void 0 : a.id;
91
+ const i = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId, a = (r = t.builderContextSignal.content) == null ? void 0 : r.id;
91
92
  y({
92
93
  apiHost: t.apiHost,
93
94
  type: "click",
94
95
  canTrack: K(t.canTrack),
95
- contentId: r,
96
+ contentId: a,
96
97
  apiKey: t.apiKey,
97
- variationId: i !== r ? i : void 0,
98
- ...F(n),
98
+ variationId: i !== a ? i : void 0,
99
+ ...z(n),
99
100
  unique: !x
100
101
  });
101
102
  }
102
103
  x || V(!0);
103
104
  }
104
105
  function N() {
105
- var e, a, i;
106
- const n = (i = (a = (e = t.builderContextSignal.content) == null ? void 0 : e.data) == null ? void 0 : a.httpRequests) != null ? i : {};
107
- Object.entries(n).forEach(([r, o]) => {
108
- if (!o || S[r] || h[r] && !f())
106
+ var e, r, i;
107
+ const n = (i = (r = (e = t.builderContextSignal.content) == null ? void 0 : e.data) == null ? void 0 : r.httpRequests) != null ? i : {};
108
+ Object.entries(n).forEach(([a, o]) => {
109
+ if (!o || S[a] || h[a] && !f())
109
110
  return;
110
- S[r] = !0;
111
- const s = o.replace(
111
+ S[a] = !0;
112
+ const u = o.replace(
112
113
  /{{([^}]+)}}/g,
113
114
  (l, j) => String(
114
115
  U({
@@ -120,18 +121,18 @@ function Ct(t) {
120
121
  })
121
122
  )
122
123
  );
123
- fetch(s).then((l) => l.json()).then((l) => {
124
+ O(u), fetch(u).then((l) => l.json()).then((l) => {
124
125
  g({
125
- [r]: l
126
- }), h[r] = !0;
126
+ [a]: l
127
+ }), h[a] = !0;
127
128
  }).catch((l) => {
128
129
  console.error("error fetching dynamic data", o, l);
129
130
  }).finally(() => {
130
- S[r] = !1;
131
+ S[a] = !1;
131
132
  });
132
133
  });
133
134
  }
134
- function u() {
135
+ function s() {
135
136
  f() && window.dispatchEvent(
136
137
  new CustomEvent(
137
138
  "builder:component:stateChange",
@@ -147,7 +148,7 @@ function Ct(t) {
147
148
  );
148
149
  }
149
150
  function C(n) {
150
- window.addEventListener("message", v), G(), J({
151
+ window.addEventListener("message", v), J(), Q({
151
152
  ...t.locale ? {
152
153
  locale: t.locale
153
154
  } : {},
@@ -161,18 +162,18 @@ function Ct(t) {
161
162
  t.builderContextSignal.componentInfos
162
163
  ).forEach((e) => {
163
164
  var i;
164
- const a = B(e);
165
- (i = window.parent) == null || i.postMessage(a, "*");
165
+ const r = B(e);
166
+ (i = window.parent) == null || i.postMessage(r, "*");
166
167
  }), window.addEventListener(
167
168
  "builder:component:stateChangeListenerActivated",
168
- u
169
+ s
169
170
  );
170
171
  }
171
172
  function E(n) {
172
- const e = new URL(location.href).searchParams, a = e.get("builder.preview"), i = e.get(
173
- `builder.overrides.${a}`
174
- ), r = e.get("apiKey") || e.get("builder.space");
175
- a === t.model && r === t.apiKey && (!t.content || i === t.content.id) && D({
173
+ const e = new URL(location.href).searchParams, r = e.get("builder.preview"), i = e.get(
174
+ `builder.overrides.${r}`
175
+ ), a = e.get("apiKey") || e.get("builder.space");
176
+ r === t.model && a === t.apiKey && (!t.content || i === t.content.id) && D({
176
177
  model: t.model,
177
178
  apiKey: t.apiKey,
178
179
  apiVersion: t.builderContextSignal.apiVersion
@@ -180,8 +181,8 @@ function Ct(t) {
180
181
  o && b(o);
181
182
  });
182
183
  }
183
- const W = Y(), I = H(!1);
184
- return I.current || (N(), u(), I.current = !0), c(() => {
184
+ const W = Z(), I = H(!1);
185
+ return I.current || (N(), s(), I.current = !0), c(() => {
185
186
  var n;
186
187
  return (n = d.current) == null || n.addEventListener(
187
188
  "initeditingbldr",
@@ -209,21 +210,21 @@ function Ct(t) {
209
210
  var n, e;
210
211
  if (L()) {
211
212
  if (f() && !t.isNestedRender && d.current && d.current.dispatchEvent(new CustomEvent("initeditingbldr")), t.builderContextSignal.content && K(t.canTrack)) {
212
- const i = (n = t.builderContextSignal.content) == null ? void 0 : n.testVariationId, r = (e = t.builderContextSignal.content) == null ? void 0 : e.id, o = t.apiKey;
213
+ const i = (n = t.builderContextSignal.content) == null ? void 0 : n.testVariationId, a = (e = t.builderContextSignal.content) == null ? void 0 : e.id, o = t.apiKey;
213
214
  y({
214
215
  apiHost: t.apiHost,
215
216
  type: "impression",
216
217
  canTrack: !0,
217
- contentId: r,
218
+ contentId: a,
218
219
  apiKey: o,
219
- variationId: i !== r ? i : void 0
220
+ variationId: i !== a ? i : void 0
220
221
  });
221
222
  }
222
- O() && f();
223
+ F() && f();
223
224
  }
224
225
  }, []), c(() => {
225
226
  }, [t.content]), c(() => {
226
- u();
227
+ s();
227
228
  }, [t.builderContextSignal.rootState]), c(() => {
228
229
  t.data && g(t.data);
229
230
  }, [t.data]), c(() => {
@@ -233,7 +234,7 @@ function Ct(t) {
233
234
  }, [t.locale]), c(() => () => {
234
235
  L() && (window.removeEventListener("message", v), window.removeEventListener(
235
236
  "builder:component:stateChangeListenerActivated",
236
- u
237
+ s
237
238
  ));
238
239
  }, []), /* @__PURE__ */ R(A.Provider, { value: t.builderContextSignal, children: t.builderContextSignal.content ? /* @__PURE__ */ R(
239
240
  T,
@@ -242,7 +243,7 @@ function Ct(t) {
242
243
  onClick: (n) => M(n),
243
244
  "builder-content-id": (w = t.builderContextSignal.content) == null ? void 0 : w.id,
244
245
  "builder-model": t.model,
245
- className: X(
246
+ className: Y(
246
247
  ((k = t.content) == null ? void 0 : k.testVariationId) || ((P = t.content) == null ? void 0 : P.id)
247
248
  ),
248
249
  ...q(),
@@ -252,5 +253,5 @@ function Ct(t) {
252
253
  ) : null });
253
254
  }
254
255
  export {
255
- Ct as default
256
+ It as default
256
257
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.20";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.16.24";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.16.20";
1
+ const o = "0.16.24";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),A=require("../../types/api-version.cjs"),V=require("../get-builder-search-params/index.cjs"),y=r=>typeof r=="number"&&!isNaN(r)&&r>=0,$=r=>{const{limit:l=30,userAttributes:f,query:m,model:b,apiKey:h,enrich:u,locale:d,apiVersion:a=A.DEFAULT_API_VERSION,fields:P,omit:v,offset:i,cacheSeconds:n,staleCacheSeconds:o,sort:S,includeUnpublished:g,apiHost:N}=r;if(!h)throw new Error("Missing API key");if(!["v3"].includes(a))throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`);const U=l!==1,q=N||"https://cdn.builder.io",e=new URL(`${q}/api/${a}/content/${b}`);if(e.searchParams.set("apiKey",h),e.searchParams.set("limit",String(l)),e.searchParams.set("noTraverse",String(U)),e.searchParams.set("includeRefs",String(!0)),d&&e.searchParams.set("locale",d),u&&e.searchParams.set("enrich",String(u)),e.searchParams.set("omit",v||"meta.componentsUsed"),P&&e.searchParams.set("fields",P),Number.isFinite(i)&&i>-1&&e.searchParams.set("offset",String(Math.floor(i))),typeof g=="boolean"&&e.searchParams.set("includeUnpublished",String(g)),n&&y(n)&&e.searchParams.set("cacheSeconds",String(n)),o&&y(o)&&e.searchParams.set("staleCacheSeconds",String(o)),S){const s=c.flatten({sort:S});for(const t in s)e.searchParams.set(t,JSON.stringify(s[t]))}const w={...V.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(r.options||{})},p=c.flatten(w);for(const s in p)e.searchParams.set(s,String(p[s]));if(f&&e.searchParams.set("userAttributes",JSON.stringify(f)),m){const s=c.flattenMongoQuery({query:m});for(const t in s)e.searchParams.set(t,JSON.stringify(s[t]))}return e};exports.generateContentUrl=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../helpers/flatten.cjs"),$=require("../../helpers/search/search.cjs"),k=require("../../types/api-version.cjs"),A=require("../get-builder-search-params/index.cjs"),b=r=>typeof r=="number"&&!isNaN(r)&&r>=0,C=r=>{const{limit:h=30,userAttributes:a,query:d,model:U,apiKey:u,enrich:P,locale:v,apiVersion:i=k.DEFAULT_API_VERSION,fields:S,omit:N,offset:o,cacheSeconds:c,staleCacheSeconds:l,sort:g,includeUnpublished:p,apiHost:q}=r;if(!u)throw new Error("Missing API key");if(!["v3"].includes(i))throw new Error(`Invalid apiVersion: expected 'v3', received '${i}'`);const w=h!==1,O=q||"https://cdn.builder.io",e=new URL(`${O}/api/${i}/content/${U}`);e.searchParams.set("apiKey",u),e.searchParams.set("limit",String(h)),e.searchParams.set("noTraverse",String(w)),e.searchParams.set("includeRefs",String(!0));const f=v||(a==null?void 0:a.locale);let n=a;if(f&&(e.searchParams.set("locale",f),n={locale:f,...n}),P&&e.searchParams.set("enrich",String(P)),e.searchParams.set("omit",N||"meta.componentsUsed"),S&&e.searchParams.set("fields",S),Number.isFinite(o)&&o>-1&&e.searchParams.set("offset",String(Math.floor(o))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),c&&b(c)&&e.searchParams.set("cacheSeconds",String(c)),l&&b(l)&&e.searchParams.set("staleCacheSeconds",String(l)),g){const s=m.flatten({sort:g});for(const t in s)e.searchParams.set(t,JSON.stringify(s[t]))}const V={...A.getBuilderSearchParamsFromWindow(),...$.normalizeSearchParams(r.options||{})},y=m.flatten(V);for(const s in y)e.searchParams.set(s,String(y[s]));if(n&&e.searchParams.set("userAttributes",JSON.stringify(n)),d){const s=m.flattenMongoQuery({query:d});for(const t in s)e.searchParams.set(t,JSON.stringify(s[t]))}return e};exports.generateContentUrl=C;
@@ -1,47 +1,53 @@
1
- import { flatten as g, flattenMongoQuery as O } from "../../helpers/flatten.mjs";
2
- import { normalizeSearchParams as k } from "../../helpers/search/search.mjs";
3
- import { DEFAULT_API_VERSION as E } from "../../types/api-version.mjs";
4
- import { getBuilderSearchParamsFromWindow as I } from "../get-builder-search-params/index.mjs";
5
- const y = (r) => typeof r == "number" && !isNaN(r) && r >= 0, M = (r) => {
1
+ import { flatten as y, flattenMongoQuery as E } from "../../helpers/flatten.mjs";
2
+ import { normalizeSearchParams as I } from "../../helpers/search/search.mjs";
3
+ import { DEFAULT_API_VERSION as $ } from "../../types/api-version.mjs";
4
+ import { getBuilderSearchParamsFromWindow as C } from "../get-builder-search-params/index.mjs";
5
+ const b = (r) => typeof r == "number" && !isNaN(r) && r >= 0, R = (r) => {
6
6
  const {
7
- limit: c = 30,
8
- userAttributes: m,
9
- query: f,
10
- model: b,
11
- apiKey: l,
12
- enrich: h,
13
- locale: d,
14
- apiVersion: a = E,
15
- fields: u,
16
- omit: N,
17
- offset: i,
18
- cacheSeconds: n,
19
- staleCacheSeconds: o,
20
- sort: P,
21
- includeUnpublished: p,
22
- apiHost: v
7
+ limit: m = 30,
8
+ userAttributes: a,
9
+ query: h,
10
+ model: N,
11
+ apiKey: d,
12
+ enrich: P,
13
+ locale: U,
14
+ apiVersion: n = $,
15
+ fields: p,
16
+ omit: v,
17
+ offset: o,
18
+ cacheSeconds: c,
19
+ staleCacheSeconds: f,
20
+ sort: S,
21
+ includeUnpublished: u,
22
+ apiHost: w
23
23
  } = r;
24
- if (!l)
24
+ if (!d)
25
25
  throw new Error("Missing API key");
26
- if (!["v3"].includes(a))
27
- throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`);
28
- const U = c !== 1, w = v || "https://cdn.builder.io", e = new URL(`${w}/api/${a}/content/${b}`);
29
- if (e.searchParams.set("apiKey", l), e.searchParams.set("limit", String(c)), e.searchParams.set("noTraverse", String(U)), e.searchParams.set("includeRefs", String(!0)), d && e.searchParams.set("locale", d), h && e.searchParams.set("enrich", String(h)), e.searchParams.set("omit", N || "meta.componentsUsed"), u && e.searchParams.set("fields", u), Number.isFinite(i) && i > -1 && e.searchParams.set("offset", String(Math.floor(i))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), n && y(n) && e.searchParams.set("cacheSeconds", String(n)), o && y(o) && e.searchParams.set("staleCacheSeconds", String(o)), P) {
30
- const s = g({
31
- sort: P
26
+ if (!["v3"].includes(n))
27
+ throw new Error(`Invalid apiVersion: expected 'v3', received '${n}'`);
28
+ const O = m !== 1, k = w || "https://cdn.builder.io", e = new URL(`${k}/api/${n}/content/${N}`);
29
+ e.searchParams.set("apiKey", d), e.searchParams.set("limit", String(m)), e.searchParams.set("noTraverse", String(O)), e.searchParams.set("includeRefs", String(!0));
30
+ const l = U || (a == null ? void 0 : a.locale);
31
+ let i = a;
32
+ if (l && (e.searchParams.set("locale", l), i = {
33
+ locale: l,
34
+ ...i
35
+ }), P && e.searchParams.set("enrich", String(P)), e.searchParams.set("omit", v || "meta.componentsUsed"), p && e.searchParams.set("fields", p), Number.isFinite(o) && o > -1 && e.searchParams.set("offset", String(Math.floor(o))), typeof u == "boolean" && e.searchParams.set("includeUnpublished", String(u)), c && b(c) && e.searchParams.set("cacheSeconds", String(c)), f && b(f) && e.searchParams.set("staleCacheSeconds", String(f)), S) {
36
+ const s = y({
37
+ sort: S
32
38
  });
33
39
  for (const t in s)
34
40
  e.searchParams.set(t, JSON.stringify(s[t]));
35
41
  }
36
42
  const A = {
37
- ...I(),
38
- ...k(r.options || {})
39
- }, S = g(A);
40
- for (const s in S)
41
- e.searchParams.set(s, String(S[s]));
42
- if (m && e.searchParams.set("userAttributes", JSON.stringify(m)), f) {
43
- const s = O({
44
- query: f
43
+ ...C(),
44
+ ...I(r.options || {})
45
+ }, g = y(A);
46
+ for (const s in g)
47
+ e.searchParams.set(s, String(g[s]));
48
+ if (i && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
49
+ const s = E({
50
+ query: h
45
51
  });
46
52
  for (const t in s)
47
53
  e.searchParams.set(t, JSON.stringify(s[t]));
@@ -49,5 +55,5 @@ const y = (r) => typeof r == "number" && !isNaN(r) && r >= 0, M = (r) => {
49
55
  return e;
50
56
  };
51
57
  export {
52
- M as generateContentUrl
58
+ R as generateContentUrl
53
59
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../helpers/logger.cjs");function t(o){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&r.logger.log(o)}exports.logFetch=t;
@@ -0,0 +1,8 @@
1
+ import { logger as r } from "../helpers/logger.mjs";
2
+ function t(o) {
3
+ var e;
4
+ typeof process != "undefined" && ((e = process.env) != null && e.DEBUG) && String(process.env.DEBUG) == "true" && r.log(o);
5
+ }
6
+ export {
7
+ t as logFetch
8
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>({type:"builder.registerComponent",data:r(t)}),s=t=>{const n=t.toString().trim();return`return (${!n.startsWith("function")&&!n.startsWith("(")?"function ":""}${n}).apply(this, arguments)`};function r(t){return JSON.parse(JSON.stringify(t,(n,e)=>typeof e=="function"?s(e):e))}exports.createRegisterComponentMessage=i;exports.serializeIncludingFunctions=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>({type:"builder.registerComponent",data:r(t)}),s=t=>{const n=t.toString().trim(),e=/^[a-zA-Z0-9_]+\s*=>/i.test(n);return`return (${!n.startsWith("function")&&!n.startsWith("(")&&!e?"function ":""}${n}).apply(this, arguments)`};function r(t){return JSON.parse(JSON.stringify(t,(n,e)=>typeof e=="function"?s(e):e))}exports.createRegisterComponentMessage=i;exports.serializeIncludingFunctions=r;
@@ -1,14 +1,14 @@
1
- const s = (t) => ({
1
+ const o = (t) => ({
2
2
  type: "builder.registerComponent",
3
3
  data: i(t)
4
- }), r = (t) => {
5
- const n = t.toString().trim();
6
- return `return (${!n.startsWith("function") && !n.startsWith("(") ? "function " : ""}${n}).apply(this, arguments)`;
4
+ }), e = (t) => {
5
+ const n = t.toString().trim(), r = /^[a-zA-Z0-9_]+\s*=>/i.test(n);
6
+ return `return (${!n.startsWith("function") && !n.startsWith("(") && !r ? "function " : ""}${n}).apply(this, arguments)`;
7
7
  };
8
8
  function i(t) {
9
- return JSON.parse(JSON.stringify(t, (n, e) => typeof e == "function" ? r(e) : e));
9
+ return JSON.parse(JSON.stringify(t, (n, r) => typeof r == "function" ? e(r) : r));
10
10
  }
11
11
  export {
12
- s as createRegisterComponentMessage,
12
+ o as createRegisterComponentMessage,
13
13
  i as serializeIncludingFunctions
14
14
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),g=require("../is-browser.cjs"),l=require("../is-editing.cjs"),y=require("./helpers.cjs"),I=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await d.getSessionId({canTrack:e}),r=u.getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},k=async({type:e,canTrack:t,apiKey:r,metadata:i,...o})=>({type:e,data:{...o,metadata:{url:location.href,...i},...await I({canTrack:t}),userAttributes:y.getUserAttributes(),ownerId:r}});async function s({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||l.isEditing()||!(g.isBrowser()||n.TARGET==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await k(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const f=e=>s({...e,canTrack:!0});exports._track=s;exports.track=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),l=require("../is-browser.cjs"),g=require("../is-editing.cjs"),y=require("../log-fetch.cjs"),I=require("./helpers.cjs"),k=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await d.getSessionId({canTrack:e}),r=u.getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},f=async({type:e,canTrack:t,apiKey:r,metadata:s,...i})=>({type:e,data:{...i,metadata:{url:location.href,...s},...await k({canTrack:t}),userAttributes:I.getUserAttributes(),ownerId:r}});async function o({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||g.isEditing()||!(l.isBrowser()||n.TARGET==="reactNative"))return;const s=`${e||"https://cdn.builder.io"}/api/v1/track`;return y.logFetch(s),fetch(s,{method:"POST",body:JSON.stringify({events:[await f(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const v=e=>o({...e,canTrack:!0});exports._track=o;exports.track=v;
@@ -1,12 +1,13 @@
1
- import { TARGET as a } from "../../constants/target.mjs";
2
- import { logger as s } from "../../helpers/logger.mjs";
1
+ import { TARGET as s } from "../../constants/target.mjs";
2
+ import { logger as a } from "../../helpers/logger.mjs";
3
3
  import { getSdkHeaders as n } from "../../helpers/sdk-headers.mjs";
4
4
  import { getSessionId as c } from "../../helpers/sessionId.mjs";
5
5
  import { getVisitorId as d } from "../../helpers/visitorId.mjs";
6
6
  import { isBrowser as m } from "../is-browser.mjs";
7
7
  import { isEditing as f } from "../is-editing.mjs";
8
- import { getUserAttributes as p } from "./helpers.mjs";
9
- const u = async ({
8
+ import { logFetch as p } from "../log-fetch.mjs";
9
+ import { getUserAttributes as u } from "./helpers.mjs";
10
+ const l = async ({
10
11
  canTrack: t
11
12
  }) => {
12
13
  if (!t)
@@ -23,7 +24,7 @@ const u = async ({
23
24
  sessionId: r,
24
25
  visitorId: e
25
26
  };
26
- }, l = async ({
27
+ }, g = async ({
27
28
  type: t,
28
29
  canTrack: r,
29
30
  apiKey: e,
@@ -37,10 +38,10 @@ const u = async ({
37
38
  url: location.href,
38
39
  ...o
39
40
  },
40
- ...await u({
41
+ ...await l({
41
42
  canTrack: r
42
43
  }),
43
- userAttributes: p(),
44
+ userAttributes: u(),
44
45
  ownerId: e
45
46
  }
46
47
  });
@@ -49,28 +50,31 @@ async function y({
49
50
  ...r
50
51
  }) {
51
52
  if (!r.apiKey) {
52
- s.error("Missing API key for track call. Please provide your API key.");
53
+ a.error("Missing API key for track call. Please provide your API key.");
53
54
  return;
54
55
  }
55
- return !r.canTrack || f() || !(m() || a === "reactNative") ? void 0 : fetch(`${t || "https://cdn.builder.io"}/api/v1/track`, {
56
+ if (!r.canTrack || f() || !(m() || s === "reactNative"))
57
+ return;
58
+ const o = `${t || "https://cdn.builder.io"}/api/v1/track`;
59
+ return p(o), fetch(o, {
56
60
  method: "POST",
57
61
  body: JSON.stringify({
58
- events: [await l(r)]
62
+ events: [await g(r)]
59
63
  }),
60
64
  headers: {
61
65
  "content-type": "application/json",
62
66
  ...n()
63
67
  },
64
68
  mode: "cors"
65
- }).catch((o) => {
66
- console.error("Failed to track: ", o);
69
+ }).catch((i) => {
70
+ console.error("Failed to track: ", i);
67
71
  });
68
72
  }
69
- const E = (t) => y({
73
+ const T = (t) => y({
70
74
  ...t,
71
75
  canTrack: !0
72
76
  });
73
77
  export {
74
78
  y as _track,
75
- E as track
79
+ T as track
76
80
  };
@@ -1,4 +1,4 @@
1
- "use strict";const o=require("react/jsx-runtime"),p=require("../../components/blocks/blocks.cjs"),W=require("../../components/dynamic-renderer/dynamic-renderer.cjs"),j=require("../../components/inlined-styles.cjs"),q=require("../../constants/device-sizes.cjs"),z=require("../../functions/get-class-prop-name.cjs"),B=require("../../functions/get-style.cjs"),A=require("./helpers.cjs");function N(e){var g,f;const a=function(){return typeof e.space=="number"?e.space||0:20},s=function(){return e.columns||[]},u=function(){return e.stackColumnsAt||"tablet"},y=function(t){return t.link?e.builderLinkComponent||"a":"div"},S=function(t){var i;return((i=s()[t])==null?void 0:i.width)||100/s().length},x=function(t){const i=S(t),l=a()*(s().length-1)*(i/100);return`calc(${i}% - ${l}px)`},c=function({stackedStyle:t,desktopStyle:i}){return u()==="tablet"?t:i},m=function({stackedStyle:t,desktopStyle:i}){return u()==="never"?i:t},d=function(){return e.stackColumnsAt==="never"?"row":e.reverseColumnsWhenStacked?"column-reverse":"column"},C=function(){return{"--flex-dir":d(),"--flex-dir-tablet":c({stackedStyle:d(),desktopStyle:"row"})}},v=function(t){const i=t===0?0:a(),l=x(t),r=`${i}px`,k="100%",h=0;return{...{display:"flex",flexDirection:"column",alignItems:"stretch"},width:l,["marginLeft"]:r,"--column-width-mobile":m({stackedStyle:k,desktopStyle:l}),"--column-margin-left-mobile":m({stackedStyle:h,desktopStyle:r}),"--column-width-tablet":c({stackedStyle:k,desktopStyle:l}),"--column-margin-left-tablet":c({stackedStyle:h,desktopStyle:r})}},b=function(t){var l,r;return q.getSizesForBreakpoints(((r=(l=e.builderContext.content)==null?void 0:l.meta)==null?void 0:r.breakpoints)||{})[t].max},w=function(){const t=`.${e.builderBlock.id}-breakpoints > .builder-column`;return`
1
+ "use strict";const o=require("react/jsx-runtime"),W=require("../../components/blocks/blocks.cjs"),j=require("../../components/dynamic-renderer/dynamic-renderer.cjs"),q=require("../../components/inlined-styles.cjs"),z=require("../../constants/device-sizes.cjs"),B=require("../../functions/get-class-prop-name.cjs"),p=require("../../functions/get-style.cjs"),A=require("./helpers.cjs");function N(e){var g,f;const a=function(){return typeof e.space=="number"?e.space||0:20},s=function(){return e.columns||[]},u=function(){return e.stackColumnsAt||"tablet"},y=function(t){return t.link?e.builderLinkComponent||"a":"div"},S=function(t){var i;return((i=s()[t])==null?void 0:i.width)||100/s().length},x=function(t){const i=S(t),l=a()*(s().length-1)*(i/100);return`calc(${i}% - ${l}px)`},c=function({stackedStyle:t,desktopStyle:i}){return u()==="tablet"?t:i},m=function({stackedStyle:t,desktopStyle:i}){return u()==="never"?i:t},d=function(){return e.stackColumnsAt==="never"?"row":e.reverseColumnsWhenStacked?"column-reverse":"column"},C=function(){return{"--flex-dir":d(),"--flex-dir-tablet":c({stackedStyle:d(),desktopStyle:"row"})}},v=function(t){const i=t===0?0:a(),l=x(t),r=`${i}px`,k="100%",h=0;return{...{display:"flex",flexDirection:"column",alignItems:"stretch"},width:l,["marginLeft"]:r,"--column-width-mobile":m({stackedStyle:k,desktopStyle:l}),"--column-margin-left-mobile":m({stackedStyle:h,desktopStyle:r}),"--column-width-tablet":c({stackedStyle:k,desktopStyle:l}),"--column-margin-left-tablet":c({stackedStyle:h,desktopStyle:r})}},b=function(t){var l,r;return z.getSizesForBreakpoints(((r=(l=e.builderContext.content)==null?void 0:l.meta)==null?void 0:r.breakpoints)||{})[t].max},w=function(){const t=`.${e.builderBlock.id}-breakpoints > .builder-column`;return`
2
2
  @media (max-width: ${b("medium")}px) {
3
3
  .${e.builderBlock.id}-breakpoints {
4
4
  flex-direction: var(--flex-dir-tablet);
@@ -22,7 +22,7 @@
22
22
  margin-left: var(--column-margin-left-mobile) !important;
23
23
  }
24
24
  },
25
- `},$=function(t,i){return{...t.link?{href:t.link}:{},[z.getClassPropName()]:"builder-column",style:B.mapStyleObjToStrIfNeeded(v(i))}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:A.getColumnsClass((g=e.builderBlock)==null?void 0:g.id)+" div-0e218b6c",style:C(),children:[o.jsx(j,{id:"builderio-columns",styles:w(),nonce:e.builderContext.nonce}),(f=e.columns)==null?void 0:f.map((n,t)=>o.jsx(W,{TagName:y(n),actionAttributes:{},attributes:$(n,t),children:o.jsx(p,{path:`component.options.columns.${t}.blocks`,parent:e.builderBlock.id,styleProp:{flexGrow:"1"},context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent,blocks:n.blocks})},t))]}),o.jsx("style",{children:`.div-0e218b6c {
25
+ `},$=function(t,i){return{...t.link?{href:t.link}:{},[B.getClassPropName()]:"builder-column",style:p.mapStyleObjToStrIfNeeded(v(i))}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:A.getColumnsClass((g=e.builderBlock)==null?void 0:g.id)+" div-6e395700",style:C(),children:[o.jsx(q,{id:"builderio-columns",styles:w(),nonce:e.builderContext.nonce}),(f=e.columns)==null?void 0:f.map((n,t)=>o.jsx(j,{TagName:y(n),actionAttributes:{},attributes:$(n,t),children:o.jsx(W,{path:`columns.${t}.blocks`,parent:e.builderBlock.id,styleProp:{flexGrow:"1"},context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent,blocks:n.blocks})},t))]}),o.jsx("style",{children:`.div-6e395700 {
26
26
  display: flex;
27
27
  line-height: normal;
28
28
  }`})]})}module.exports=N;