@builder.io/sdk-react-nextjs 0.18.8 → 0.18.10

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 (35) hide show
  1. package/lib/browser/blocks/columns/columns.cjs +3 -2
  2. package/lib/browser/blocks/columns/columns.mjs +7 -6
  3. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  4. package/lib/browser/components/content/components/enable-editor.mjs +125 -125
  5. package/lib/browser/constants/sdk-version.cjs +1 -1
  6. package/lib/browser/constants/sdk-version.mjs +1 -1
  7. package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
  8. package/lib/browser/functions/get-content/generate-content-url.mjs +30 -30
  9. package/lib/browser/helpers/preview-lru-cache/set.cjs +1 -1
  10. package/lib/browser/helpers/preview-lru-cache/set.mjs +7 -5
  11. package/lib/edge/blocks/columns/columns.cjs +3 -2
  12. package/lib/edge/blocks/columns/columns.mjs +7 -6
  13. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  14. package/lib/edge/components/content/components/enable-editor.mjs +125 -125
  15. package/lib/edge/constants/sdk-version.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.mjs +1 -1
  17. package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
  18. package/lib/edge/functions/get-content/generate-content-url.mjs +30 -30
  19. package/lib/edge/helpers/preview-lru-cache/set.cjs +1 -1
  20. package/lib/edge/helpers/preview-lru-cache/set.mjs +7 -5
  21. package/lib/node/blocks/columns/columns.cjs +3 -2
  22. package/lib/node/blocks/columns/columns.mjs +7 -6
  23. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  24. package/lib/node/components/content/components/enable-editor.mjs +125 -125
  25. package/lib/node/constants/sdk-version.cjs +1 -1
  26. package/lib/node/constants/sdk-version.mjs +1 -1
  27. package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
  28. package/lib/node/functions/get-content/generate-content-url.mjs +30 -30
  29. package/lib/node/helpers/preview-lru-cache/set.cjs +1 -1
  30. package/lib/node/helpers/preview-lru-cache/set.mjs +7 -5
  31. package/package.json +1 -1
  32. package/types/cjs/constants/sdk-version.d.ts +1 -1
  33. package/types/cjs/helpers/preview-lru-cache/set.d.ts +3 -4
  34. package/types/esm/constants/sdk-version.d.ts +1 -1
  35. package/types/esm/helpers/preview-lru-cache/set.d.ts +3 -4
@@ -1,138 +1,137 @@
1
1
  "use client";
2
2
  import { jsx as k } from "react/jsx-runtime";
3
3
  import { useRef as P, useState as m, useEffect as c } from "react";
4
- import O from "../../../context/builder.context.mjs";
5
- import { evaluate as W } from "../../../functions/evaluate/evaluate.mjs";
6
- import { fastClone as j } from "../../../functions/fast-clone.mjs";
7
- import { fetchOneEntry as A } from "../../../functions/get-content/index.mjs";
4
+ import M from "../../../context/builder.context.mjs";
5
+ import { evaluate as O } from "../../../functions/evaluate/evaluate.mjs";
6
+ import { fastClone as W } from "../../../functions/fast-clone.mjs";
7
+ import { fetchOneEntry as j } from "../../../functions/get-content/index.mjs";
8
8
  import { isBrowser as L } from "../../../functions/is-browser.mjs";
9
9
  import { isEditing as g } from "../../../functions/is-editing.mjs";
10
- import { isPreviewing as B } from "../../../functions/is-previewing.mjs";
11
- import { logFetch as F } from "../../../functions/log-fetch.mjs";
12
- import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
10
+ import { isPreviewing as A } from "../../../functions/is-previewing.mjs";
11
+ import { logFetch as B } from "../../../functions/log-fetch.mjs";
12
+ import { createRegisterComponentMessage as F } from "../../../functions/register-component.mjs";
13
13
  import { _track as H } from "../../../functions/track/index.mjs";
14
- import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
14
+ import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
15
15
  import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
16
- import { getCookieSync as G } from "../../../helpers/cookie.mjs";
17
- import { postPreviewContent as J } from "../../../helpers/preview-lru-cache/set.mjs";
18
- import { createEditorListener as Q } from "../../../helpers/subscribe-to-editor.mjs";
19
- import { registerInsertMenu as X, setupBrowserForEditing as Y } from "../../../scripts/init-editing.mjs";
20
- import { triggerAnimation as Z } from "../../block/animator.mjs";
16
+ import { getCookieSync as z } from "../../../helpers/cookie.mjs";
17
+ import { postPreviewContent as G } from "../../../helpers/preview-lru-cache/set.mjs";
18
+ import { createEditorListener as J } from "../../../helpers/subscribe-to-editor.mjs";
19
+ import { registerInsertMenu as Q, setupBrowserForEditing as X } from "../../../scripts/init-editing.mjs";
20
+ import { triggerAnimation as Y } from "../../block/animator.mjs";
21
21
  import { needsElementRefDivForEditing as q } from "./enable-editor.helpers.mjs";
22
- import { getWrapperClassName as p } from "./styles.helpers.mjs";
23
- import { useRouter as ee } from "next/navigation";
24
- function ke(e) {
25
- var y, R, w;
22
+ import { getWrapperClassName as Z } from "./styles.helpers.mjs";
23
+ import { useRouter as p } from "next/navigation";
24
+ function Rt(t) {
25
+ var w, y, R;
26
26
  const u = P(null);
27
27
  m(() => !1);
28
28
  function s(n) {
29
- var i, r;
30
- const t = {
31
- ...e.builderContextSignal.rootState,
29
+ var i, o;
30
+ const e = {
31
+ ...t.builderContextSignal.rootState,
32
32
  ...n
33
33
  };
34
- e.builderContextSignal.rootSetState ? (r = (i = e.builderContextSignal).rootSetState) == null || r.call(i, t) : e.builderContextSignal.rootState = t;
34
+ t.builderContextSignal.rootSetState ? (o = (i = t.builderContextSignal).rootSetState) == null || o.call(i, e) : t.builderContextSignal.rootState = e;
35
35
  }
36
36
  function b(n) {
37
- var i, r, a, o, d;
38
- const t = {
39
- ...e.builderContextSignal.content,
37
+ var i, o, a, r, d;
38
+ const e = {
39
+ ...t.builderContextSignal.content,
40
40
  ...n,
41
41
  data: {
42
- ...(i = e.builderContextSignal.content) == null ? void 0 : i.data,
42
+ ...(i = t.builderContextSignal.content) == null ? void 0 : i.data,
43
43
  ...n == null ? void 0 : n.data
44
44
  },
45
45
  meta: {
46
- ...(r = e.builderContextSignal.content) == null ? void 0 : r.meta,
46
+ ...(o = t.builderContextSignal.content) == null ? void 0 : o.meta,
47
47
  ...n == null ? void 0 : n.meta,
48
- breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((d = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : d.breakpoints)
48
+ breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((d = (r = t.builderContextSignal.content) == null ? void 0 : r.meta) == null ? void 0 : d.breakpoints)
49
49
  }
50
50
  };
51
- J({
52
- value: t,
53
- key: t.id
54
- }).then(() => {
55
- _.refresh();
51
+ G({
52
+ value: e,
53
+ key: e.id,
54
+ url: window.location.pathname
56
55
  });
57
56
  }
58
57
  function T() {
59
- return e.showContent ? {} : {
58
+ return t.showContent ? {} : {
60
59
  hidden: !0,
61
60
  "aria-hidden": !0
62
61
  };
63
62
  }
64
- const [U, te] = m(
65
- () => e.contentWrapper || "div"
63
+ const [U, tt] = m(
64
+ () => t.contentWrapper || "div"
66
65
  );
67
66
  function v(n) {
68
- return Q({
69
- model: e.model,
70
- trustedHosts: e.trustedHosts,
67
+ return J({
68
+ model: t.model,
69
+ trustedHosts: t.trustedHosts,
71
70
  callbacks: {
72
- configureSdk: (t) => {
71
+ configureSdk: (e) => {
73
72
  var a;
74
- const { breakpoints: i, contentId: r } = t;
75
- !r || r !== ((a = e.builderContextSignal.content) == null ? void 0 : a.id) || i && b({
73
+ const { breakpoints: i, contentId: o } = e;
74
+ !o || o !== ((a = t.builderContextSignal.content) == null ? void 0 : a.id) || i && b({
76
75
  meta: {
77
76
  breakpoints: i
78
77
  }
79
78
  });
80
79
  },
81
- animation: (t) => {
82
- Z(t);
80
+ animation: (e) => {
81
+ Y(e);
83
82
  },
84
- contentUpdate: (t) => {
85
- b(t);
83
+ contentUpdate: (e) => {
84
+ b(e);
86
85
  },
87
- stateUpdate: (t) => {
88
- s(t);
86
+ stateUpdate: (e) => {
87
+ s(e);
89
88
  }
90
89
  }
91
90
  })(n);
92
91
  }
93
- const [h, ne] = m(() => ({})), [S, ie] = m(() => ({})), [x, D] = m(() => !1);
92
+ const [h, et] = m(() => ({})), [S, nt] = m(() => ({})), [x, D] = m(() => !1);
94
93
  function V(n) {
95
- var t, i;
96
- if (e.builderContextSignal.content) {
97
- const r = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, a = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
94
+ var e, i;
95
+ if (t.builderContextSignal.content) {
96
+ const o = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId, a = (i = t.builderContextSignal.content) == null ? void 0 : i.id;
98
97
  H({
99
- apiHost: e.apiHost,
98
+ apiHost: t.apiHost,
100
99
  type: "click",
101
- canTrack: K(e.canTrack),
100
+ canTrack: K(t.canTrack),
102
101
  contentId: a,
103
- apiKey: e.apiKey,
104
- variationId: r !== a ? r : void 0,
105
- ...z(n),
102
+ apiKey: t.apiKey,
103
+ variationId: o !== a ? o : void 0,
104
+ ...$(n),
106
105
  unique: !x
107
106
  });
108
107
  }
109
108
  x || D(!0);
110
109
  }
111
110
  function N() {
112
- var t, i, r;
113
- const n = (r = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? r : {};
114
- Object.entries(n).forEach(([a, o]) => {
115
- if (!o || S[a] || h[a] && !g())
111
+ var e, i, o;
112
+ const n = (o = (i = (e = t.builderContextSignal.content) == null ? void 0 : e.data) == null ? void 0 : i.httpRequests) != null ? o : {};
113
+ Object.entries(n).forEach(([a, r]) => {
114
+ if (!r || S[a] || h[a] && !g())
116
115
  return;
117
116
  S[a] = !0;
118
- const d = o.replace(
117
+ const d = r.replace(
119
118
  /{{([^}]+)}}/g,
120
- (l, M) => String(
121
- W({
122
- code: M,
123
- context: e.context || {},
119
+ (l, _) => String(
120
+ O({
121
+ code: _,
122
+ context: t.context || {},
124
123
  localState: void 0,
125
- rootState: e.builderContextSignal.rootState,
126
- rootSetState: e.builderContextSignal.rootSetState
124
+ rootState: t.builderContextSignal.rootState,
125
+ rootSetState: t.builderContextSignal.rootSetState
127
126
  })
128
127
  )
129
128
  );
130
- F(d), fetch(d).then((l) => l.json()).then((l) => {
129
+ B(d), fetch(d).then((l) => l.json()).then((l) => {
131
130
  s({
132
131
  [a]: l
133
132
  }), h[a] = !0;
134
133
  }).catch((l) => {
135
- console.error("error fetching dynamic data", o, l);
134
+ console.error("error fetching dynamic data", r, l);
136
135
  }).finally(() => {
137
136
  S[a] = !1;
138
137
  });
@@ -144,9 +143,9 @@ function ke(e) {
144
143
  "builder:component:stateChange",
145
144
  {
146
145
  detail: {
147
- state: j(e.builderContextSignal.rootState),
146
+ state: W(t.builderContextSignal.rootState),
148
147
  ref: {
149
- name: e.model
148
+ name: t.model
150
149
  }
151
150
  }
152
151
  }
@@ -154,26 +153,26 @@ function ke(e) {
154
153
  );
155
154
  }
156
155
  function C(n) {
157
- var t;
158
- window.addEventListener("message", v), X(), Y({
159
- ...e.locale ? {
160
- locale: e.locale
156
+ var e;
157
+ window.addEventListener("message", v), Q(), X({
158
+ ...t.locale ? {
159
+ locale: t.locale
161
160
  } : {},
162
- ...e.enrich ? {
163
- enrich: e.enrich
161
+ ...t.enrich ? {
162
+ enrich: t.enrich
164
163
  } : {},
165
- ...e.trustedHosts ? {
166
- trustedHosts: e.trustedHosts
164
+ ...t.trustedHosts ? {
165
+ trustedHosts: t.trustedHosts
167
166
  } : {},
168
- modelName: (t = e.model) != null ? t : "",
169
- apiKey: e.apiKey
167
+ modelName: (e = t.model) != null ? e : "",
168
+ apiKey: t.apiKey
170
169
  }), Object.values(
171
- e.builderContextSignal.componentInfos
170
+ t.builderContextSignal.componentInfos
172
171
  ).forEach((i) => {
173
- var r, a;
174
- if (!((r = i.models) != null && r.length) || i.models.includes(e.model)) {
175
- const o = $(i);
176
- (a = window.parent) == null || a.postMessage(o, "*");
172
+ var o, a;
173
+ if (!((o = i.models) != null && o.length) || i.models.includes(t.model)) {
174
+ const r = F(i);
175
+ (a = window.parent) == null || a.postMessage(r, "*");
177
176
  }
178
177
  }), window.addEventListener(
179
178
  "builder:component:stateChangeListenerActivated",
@@ -181,32 +180,33 @@ function ke(e) {
181
180
  );
182
181
  }
183
182
  function E(n) {
184
- var o;
185
- const t = new URL(location.href).searchParams, i = t.get("builder.preview"), r = t.get(
183
+ var r;
184
+ const e = new URL(location.href).searchParams, i = e.get("builder.preview"), o = e.get(
186
185
  `builder.overrides.${i}`
187
- ), a = t.get("apiKey") || t.get("builder.space");
188
- (i === "BUILDER_STUDIO" || i === e.model && a === e.apiKey && (!e.content || r === e.content.id)) && A({
189
- model: e.model,
190
- apiKey: e.apiKey,
191
- apiVersion: e.builderContextSignal.apiVersion,
192
- ...i === "BUILDER_STUDIO" && ((o = e.context) != null && o.symbolId) ? {
186
+ ), a = e.get("apiKey") || e.get("builder.space");
187
+ (i === "BUILDER_STUDIO" || i === t.model && a === t.apiKey && (!t.content || o === t.content.id)) && j({
188
+ model: t.model,
189
+ apiKey: t.apiKey,
190
+ apiVersion: t.builderContextSignal.apiVersion,
191
+ ...i === "BUILDER_STUDIO" && ((r = t.context) != null && r.symbolId) ? {
193
192
  query: {
194
- id: e.context.symbolId
193
+ id: t.context.symbolId
195
194
  }
196
195
  } : {}
197
196
  }).then((d) => {
198
197
  d && b(d);
199
198
  });
200
199
  }
201
- const _ = ee(), I = P(!1);
200
+ p();
201
+ const I = P(!1);
202
202
  return I.current || (N(), f(), I.current = !0), c(() => {
203
203
  var n;
204
204
  return (n = u.current) == null || n.addEventListener(
205
205
  "initeditingbldr",
206
206
  C
207
207
  ), () => {
208
- var t;
209
- return (t = u.current) == null ? void 0 : t.removeEventListener(
208
+ var e;
209
+ return (e = u.current) == null ? void 0 : e.removeEventListener(
210
210
  "initeditingbldr",
211
211
  C
212
212
  );
@@ -217,24 +217,24 @@ function ke(e) {
217
217
  "initpreviewingbldr",
218
218
  E
219
219
  ), () => {
220
- var t;
221
- return (t = u.current) == null ? void 0 : t.removeEventListener(
220
+ var e;
221
+ return (e = u.current) == null ? void 0 : e.removeEventListener(
222
222
  "initpreviewingbldr",
223
223
  E
224
224
  );
225
225
  };
226
226
  }, []), c(() => {
227
- var n, t, i;
227
+ var n, e, i;
228
228
  if (L()) {
229
- g() && !e.isNestedRender && u.current && u.current.dispatchEvent(new CustomEvent("initeditingbldr"));
230
- const r = e.builderContextSignal.content && K(e.canTrack), a = G({
231
- name: `builder.tests.${(n = e.builderContextSignal.content) == null ? void 0 : n.id}`,
229
+ g() && !t.isNestedRender && u.current && u.current.dispatchEvent(new CustomEvent("initeditingbldr"));
230
+ const o = t.builderContextSignal.content && K(t.canTrack), a = z({
231
+ name: `builder.tests.${(n = t.builderContextSignal.content) == null ? void 0 : n.id}`,
232
232
  canTrack: !0
233
- }), o = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId;
234
- if (r && o === a) {
235
- const d = (i = e.builderContextSignal.content) == null ? void 0 : i.id, l = e.apiKey;
233
+ }), r = (e = t.builderContextSignal.content) == null ? void 0 : e.testVariationId;
234
+ if (o && r === a) {
235
+ const d = (i = t.builderContextSignal.content) == null ? void 0 : i.id, l = t.apiKey;
236
236
  H({
237
- apiHost: e.apiHost,
237
+ apiHost: t.apiHost,
238
238
  type: "impression",
239
239
  canTrack: !0,
240
240
  contentId: d,
@@ -242,41 +242,41 @@ function ke(e) {
242
242
  variationId: a !== d ? a : void 0
243
243
  });
244
244
  }
245
- B() && g();
245
+ A() && g();
246
246
  }
247
247
  }, []), c(() => {
248
- }, [e.content]), c(() => {
248
+ }, [t.content]), c(() => {
249
249
  f();
250
- }, [e.builderContextSignal.rootState]), c(() => {
251
- e.data && s(e.data);
252
- }, [e.data]), c(() => {
253
- e.locale && s({
254
- locale: e.locale
250
+ }, [t.builderContextSignal.rootState]), c(() => {
251
+ t.data && s(t.data);
252
+ }, [t.data]), c(() => {
253
+ t.locale && s({
254
+ locale: t.locale
255
255
  });
256
- }, [e.locale]), c(() => () => {
256
+ }, [t.locale]), c(() => () => {
257
257
  L() && (window.removeEventListener("message", v), window.removeEventListener(
258
258
  "builder:component:stateChangeListenerActivated",
259
259
  f
260
260
  ));
261
- }, []), /* @__PURE__ */ k(O.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content || q() ? /* @__PURE__ */ k(
261
+ }, []), /* @__PURE__ */ k(M.Provider, { value: t.builderContextSignal, children: t.builderContextSignal.content || q() ? /* @__PURE__ */ k(
262
262
  U,
263
263
  {
264
264
  ref: u,
265
265
  onClick: (n) => V(n),
266
- "builder-content-id": (y = e.builderContextSignal.content) == null ? void 0 : y.id,
267
- "builder-model": e.model,
268
- className: p(
269
- ((R = e.content) == null ? void 0 : R.testVariationId) || ((w = e.content) == null ? void 0 : w.id)
266
+ "builder-content-id": (w = t.builderContextSignal.content) == null ? void 0 : w.id,
267
+ "builder-model": t.model,
268
+ className: Z(
269
+ ((y = t.content) == null ? void 0 : y.testVariationId) || ((R = t.content) == null ? void 0 : R.id)
270
270
  ),
271
271
  style: {
272
- display: !e.builderContextSignal.content && q() ? "none" : void 0
272
+ display: !t.builderContextSignal.content && q() ? "none" : void 0
273
273
  },
274
274
  ...T(),
275
- ...e.contentWrapperProps,
276
- children: e.children
275
+ ...t.contentWrapperProps,
276
+ children: t.children
277
277
  }
278
278
  ) : null });
279
279
  }
280
280
  export {
281
- ke as default
281
+ Rt as default
282
282
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.8";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.10";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.18.8";
1
+ const o = "0.18.10";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),E=require("../../types/api-version.cjs"),F=require("../get-builder-search-params/index.cjs"),T=require("../is-browser.cjs"),U=t=>typeof t=="number"&&!isNaN(t)&&t>=0,V=t=>{const{limit:a=30,userAttributes:s,query:m,model:w,apiKey:d,enrich:P,locale:A,apiVersion:c=E.DEFAULT_API_VERSION,fields:S,omit:v,offset:l,cacheSeconds:f,staleCacheSeconds:u,sort:b,includeUnpublished:g,apiHost:N}=t;if(!d)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const k=a!==1,I=N||"https://cdn.builder.io",e=new URL(`${I}/api/${c}/content/${w}`);e.searchParams.set("apiKey",d),e.searchParams.set("limit",String(a)),e.searchParams.set("noTraverse",String(k)),e.searchParams.set("includeRefs",String(!0));const h=A||(s==null?void 0:s.locale);let n=s||{};if(h&&(e.searchParams.set("locale",h),n={locale:h,...n}),P&&e.searchParams.set("enrich",String(P)),e.searchParams.set("omit",v||"meta.componentsUsed"),S&&e.searchParams.set("fields",S),Number.isFinite(l)&&l>-1&&e.searchParams.set("offset",String(Math.floor(l))),typeof g=="boolean"&&e.searchParams.set("includeUnpublished",String(g)),f&&U(f)&&e.searchParams.set("cacheSeconds",String(f)),u&&U(u)&&e.searchParams.set("staleCacheSeconds",String(u)),b){const r=o.flatten({sort:b});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}const p={...F.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(t.options||{})};n={...n,...B(p)};const y=o.flatten(p);for(const r in y)e.searchParams.set(r,String(y[r]));if(Object.keys(n).length>0&&e.searchParams.set("userAttributes",JSON.stringify(n)),m){const r=o.flattenMongoQuery({query:m});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}return e},$=t=>{const a={};for(const s in t)s.startsWith("userAttributes.")&&(a[s]=t[s],delete t[s]);return a},B=t=>{if(T.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const a=$(t),{userAttributes:s}=o.unflatten(a);return s}return{}};exports.generateContentUrl=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),E=require("../../types/api-version.cjs"),F=require("../get-builder-search-params/index.cjs"),T=require("../is-browser.cjs"),w=t=>typeof t=="number"&&!isNaN(t)&&t>=0,V=t=>{const{limit:a=30,userAttributes:s,query:d,model:A,apiKey:P,enrich:S,locale:v,apiVersion:c=E.DEFAULT_API_VERSION,fields:b,omit:l,offset:f,cacheSeconds:u,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:N}=t;if(!P)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const k=a!==1,I=N||"https://cdn.builder.io",e=new URL(`${I}/api/${c}/content/${A}`);e.searchParams.set("apiKey",P),e.searchParams.set("limit",String(a)),e.searchParams.set("noTraverse",String(k)),e.searchParams.set("includeRefs",String(!0));const m=v||(s==null?void 0:s.locale);let n=s||{};if(m&&(e.searchParams.set("locale",m),n={locale:m,...n}),S&&e.searchParams.set("enrich",String(S)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(f)&&f>-1&&e.searchParams.set("offset",String(Math.floor(f))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),u&&w(u)&&e.searchParams.set("cacheSeconds",String(u)),h&&w(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}const y={...F.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(t.options||{})};n={...n,...B(y)};const U=o.flatten(y);for(const r in U)e.searchParams.set(r,String(U[r]));if(Object.keys(n).length>0&&e.searchParams.set("userAttributes",JSON.stringify(n)),d){const r=o.flattenMongoQuery({query:d});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}return e},$=t=>{const a={};for(const s in t)s.startsWith("userAttributes.")&&(a[s]=t[s],delete t[s]);return a},B=t=>{if(T.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const a=$(t),{userAttributes:s}=o.unflatten(a);return s}return{}};exports.generateContentUrl=V;
@@ -1,59 +1,59 @@
1
- import { flatten as U, flattenMongoQuery as E, unflatten as F } from "../../helpers/flatten.mjs";
1
+ import { flatten as w, flattenMongoQuery as E, unflatten as F } from "../../helpers/flatten.mjs";
2
2
  import { normalizeSearchParams as O } from "../../helpers/search/search.mjs";
3
3
  import { DEFAULT_API_VERSION as J } from "../../types/api-version.mjs";
4
4
  import { getBuilderSearchParamsFromWindow as L } from "../get-builder-search-params/index.mjs";
5
5
  import { isBrowser as R } from "../is-browser.mjs";
6
- const w = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
6
+ const y = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
7
7
  const {
8
8
  limit: a = 30,
9
9
  userAttributes: r,
10
- query: h,
11
- model: y,
12
- apiKey: u,
13
- enrich: d,
14
- locale: A,
10
+ query: u,
11
+ model: A,
12
+ apiKey: d,
13
+ enrich: P,
14
+ locale: N,
15
15
  apiVersion: o = J,
16
- fields: P,
17
- omit: N,
18
- offset: c,
19
- cacheSeconds: l,
20
- staleCacheSeconds: f,
21
- sort: S,
22
- includeUnpublished: p,
16
+ fields: S,
17
+ omit: c,
18
+ offset: l,
19
+ cacheSeconds: f,
20
+ staleCacheSeconds: m,
21
+ sort: p,
22
+ includeUnpublished: b,
23
23
  apiHost: v
24
24
  } = t;
25
- if (!u)
25
+ if (!d)
26
26
  throw new Error("Missing API key");
27
27
  if (!["v3"].includes(o))
28
28
  throw new Error(`Invalid apiVersion: expected 'v3', received '${o}'`);
29
- const k = a !== 1, I = v || "https://cdn.builder.io", e = new URL(`${I}/api/${o}/content/${y}`);
30
- e.searchParams.set("apiKey", u), e.searchParams.set("limit", String(a)), e.searchParams.set("noTraverse", String(k)), e.searchParams.set("includeRefs", String(!0));
31
- const m = A || (r == null ? void 0 : r.locale);
29
+ const k = a !== 1, I = v || "https://cdn.builder.io", e = new URL(`${I}/api/${o}/content/${A}`);
30
+ e.searchParams.set("apiKey", d), e.searchParams.set("limit", String(a)), e.searchParams.set("noTraverse", String(k)), e.searchParams.set("includeRefs", String(!0));
31
+ const h = N || (r == null ? void 0 : r.locale);
32
32
  let i = r || {};
33
- if (m && (e.searchParams.set("locale", m), i = {
34
- locale: m,
33
+ if (h && (e.searchParams.set("locale", h), i = {
34
+ locale: h,
35
35
  ...i
36
- }), d && e.searchParams.set("enrich", String(d)), e.searchParams.set("omit", N || "meta.componentsUsed"), P && e.searchParams.set("fields", P), Number.isFinite(c) && c > -1 && e.searchParams.set("offset", String(Math.floor(c))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), l && w(l) && e.searchParams.set("cacheSeconds", String(l)), f && w(f) && e.searchParams.set("staleCacheSeconds", String(f)), S) {
37
- const s = U({
38
- sort: S
36
+ }), P && e.searchParams.set("enrich", String(P)), e.searchParams.set("omit", c != null ? c : "meta.componentsUsed"), S && e.searchParams.set("fields", S), Number.isFinite(l) && l > -1 && e.searchParams.set("offset", String(Math.floor(l))), typeof b == "boolean" && e.searchParams.set("includeUnpublished", String(b)), f && y(f) && e.searchParams.set("cacheSeconds", String(f)), m && y(m) && e.searchParams.set("staleCacheSeconds", String(m)), p) {
37
+ const s = w({
38
+ sort: p
39
39
  });
40
40
  for (const n in s)
41
41
  e.searchParams.set(n, JSON.stringify(s[n]));
42
42
  }
43
- const b = {
43
+ const g = {
44
44
  ...L(),
45
45
  ...O(t.options || {})
46
46
  };
47
47
  i = {
48
48
  ...i,
49
- ...$(b)
49
+ ...$(g)
50
50
  };
51
- const g = U(b);
52
- for (const s in g)
53
- e.searchParams.set(s, String(g[s]));
54
- if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
51
+ const U = w(g);
52
+ for (const s in U)
53
+ e.searchParams.set(s, String(U[s]));
54
+ if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)), u) {
55
55
  const s = E({
56
- query: h
56
+ query: u
57
57
  });
58
58
  for (const n in s)
59
59
  e.searchParams.set(n, JSON.stringify(s[n]));
@@ -1 +1 @@
1
- "use server";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./init.cjs");async function i({key:e,value:t}){return n.init(),globalThis._BUILDER_PREVIEW_LRU_CACHE.set(e,t),{[e]:t}}exports.postPreviewContent=i;
1
+ "use server";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("next/cache"),r=require("./init.cjs");async function o({key:e,value:t,url:i}){r.init(),globalThis._BUILDER_PREVIEW_LRU_CACHE.set(e,t),n.revalidatePath(i)}exports.postPreviewContent=o;
@@ -1,11 +1,13 @@
1
1
  "use server";
2
- import { init as e } from "./init.mjs";
3
- async function o({
2
+ import { revalidatePath as r } from "next/cache";
3
+ import { init as i } from "./init.mjs";
4
+ async function a({
4
5
  key: t,
5
- value: r
6
+ value: e,
7
+ url: o
6
8
  }) {
7
- return e(), globalThis._BUILDER_PREVIEW_LRU_CACHE.set(t, r), { [t]: r };
9
+ i(), globalThis._BUILDER_PREVIEW_LRU_CACHE.set(t, e), r(o);
8
10
  }
9
11
  export {
10
- o as postPreviewContent
12
+ a as postPreviewContent
11
13
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-nextjs",
3
3
  "description": "Builder.io RSC SDK for NextJS App Directory",
4
- "version": "0.18.8",
4
+ "version": "0.18.10",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.18.8";
1
+ export declare const SDK_VERSION = "0.18.10";
@@ -1,7 +1,6 @@
1
1
  import type { BuilderContent } from '../../types/builder-content.js';
2
- export declare function postPreviewContent({ key, value, }: {
2
+ export declare function postPreviewContent({ key, value, url, }: {
3
3
  key: string;
4
4
  value: BuilderContent;
5
- }): Promise<{
6
- [x: string]: BuilderContent;
7
- }>;
5
+ url: string;
6
+ }): Promise<void>;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.18.8";
1
+ export declare const SDK_VERSION = "0.18.10";
@@ -1,7 +1,6 @@
1
1
  import type { BuilderContent } from '../../types/builder-content.js';
2
- export declare function postPreviewContent({ key, value, }: {
2
+ export declare function postPreviewContent({ key, value, url, }: {
3
3
  key: string;
4
4
  value: BuilderContent;
5
- }): Promise<{
6
- [x: string]: BuilderContent;
7
- }>;
5
+ url: string;
6
+ }): Promise<void>;