@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.
- package/lib/browser/blocks/columns/columns.cjs +3 -2
- package/lib/browser/blocks/columns/columns.mjs +7 -6
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +125 -125
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +30 -30
- package/lib/browser/helpers/preview-lru-cache/set.cjs +1 -1
- package/lib/browser/helpers/preview-lru-cache/set.mjs +7 -5
- package/lib/edge/blocks/columns/columns.cjs +3 -2
- package/lib/edge/blocks/columns/columns.mjs +7 -6
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +125 -125
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +30 -30
- package/lib/edge/helpers/preview-lru-cache/set.cjs +1 -1
- package/lib/edge/helpers/preview-lru-cache/set.mjs +7 -5
- package/lib/node/blocks/columns/columns.cjs +3 -2
- package/lib/node/blocks/columns/columns.mjs +7 -6
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +125 -125
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +30 -30
- package/lib/node/helpers/preview-lru-cache/set.cjs +1 -1
- package/lib/node/helpers/preview-lru-cache/set.mjs +7 -5
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/helpers/preview-lru-cache/set.d.ts +3 -4
- package/types/esm/constants/sdk-version.d.ts +1 -1
- 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
|
|
5
|
-
import { evaluate as
|
|
6
|
-
import { fastClone as
|
|
7
|
-
import { fetchOneEntry as
|
|
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
|
|
11
|
-
import { logFetch as
|
|
12
|
-
import { createRegisterComponentMessage as
|
|
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
|
|
14
|
+
import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
|
-
import { getCookieSync as
|
|
17
|
-
import { postPreviewContent as
|
|
18
|
-
import { createEditorListener as
|
|
19
|
-
import { registerInsertMenu as
|
|
20
|
-
import { triggerAnimation as
|
|
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
|
|
23
|
-
import { useRouter as
|
|
24
|
-
function
|
|
25
|
-
var y, R
|
|
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,
|
|
30
|
-
const
|
|
31
|
-
...
|
|
29
|
+
var i, o;
|
|
30
|
+
const e = {
|
|
31
|
+
...t.builderContextSignal.rootState,
|
|
32
32
|
...n
|
|
33
33
|
};
|
|
34
|
-
|
|
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,
|
|
38
|
-
const
|
|
39
|
-
...
|
|
37
|
+
var i, o, a, r, d;
|
|
38
|
+
const e = {
|
|
39
|
+
...t.builderContextSignal.content,
|
|
40
40
|
...n,
|
|
41
41
|
data: {
|
|
42
|
-
...(i =
|
|
42
|
+
...(i = t.builderContextSignal.content) == null ? void 0 : i.data,
|
|
43
43
|
...n == null ? void 0 : n.data
|
|
44
44
|
},
|
|
45
45
|
meta: {
|
|
46
|
-
...(
|
|
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 = (
|
|
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
|
-
|
|
52
|
-
value:
|
|
53
|
-
key:
|
|
54
|
-
|
|
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
|
|
58
|
+
return t.showContent ? {} : {
|
|
60
59
|
hidden: !0,
|
|
61
60
|
"aria-hidden": !0
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
|
-
const [U,
|
|
65
|
-
() =>
|
|
63
|
+
const [U, tt] = m(
|
|
64
|
+
() => t.contentWrapper || "div"
|
|
66
65
|
);
|
|
67
66
|
function v(n) {
|
|
68
|
-
return
|
|
69
|
-
model:
|
|
70
|
-
trustedHosts:
|
|
67
|
+
return J({
|
|
68
|
+
model: t.model,
|
|
69
|
+
trustedHosts: t.trustedHosts,
|
|
71
70
|
callbacks: {
|
|
72
|
-
configureSdk: (
|
|
71
|
+
configureSdk: (e) => {
|
|
73
72
|
var a;
|
|
74
|
-
const { breakpoints: i, contentId:
|
|
75
|
-
!
|
|
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: (
|
|
82
|
-
|
|
80
|
+
animation: (e) => {
|
|
81
|
+
Y(e);
|
|
83
82
|
},
|
|
84
|
-
contentUpdate: (
|
|
85
|
-
b(
|
|
83
|
+
contentUpdate: (e) => {
|
|
84
|
+
b(e);
|
|
86
85
|
},
|
|
87
|
-
stateUpdate: (
|
|
88
|
-
s(
|
|
86
|
+
stateUpdate: (e) => {
|
|
87
|
+
s(e);
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
})(n);
|
|
92
91
|
}
|
|
93
|
-
const [h,
|
|
92
|
+
const [h, et] = m(() => ({})), [S, nt] = m(() => ({})), [x, D] = m(() => !1);
|
|
94
93
|
function V(n) {
|
|
95
|
-
var
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
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:
|
|
98
|
+
apiHost: t.apiHost,
|
|
100
99
|
type: "click",
|
|
101
|
-
canTrack: K(
|
|
100
|
+
canTrack: K(t.canTrack),
|
|
102
101
|
contentId: a,
|
|
103
|
-
apiKey:
|
|
104
|
-
variationId:
|
|
105
|
-
|
|
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
|
|
113
|
-
const n = (
|
|
114
|
-
Object.entries(n).forEach(([a,
|
|
115
|
-
if (!
|
|
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 =
|
|
117
|
+
const d = r.replace(
|
|
119
118
|
/{{([^}]+)}}/g,
|
|
120
|
-
(l,
|
|
121
|
-
|
|
122
|
-
code:
|
|
123
|
-
context:
|
|
119
|
+
(l, _) => String(
|
|
120
|
+
O({
|
|
121
|
+
code: _,
|
|
122
|
+
context: t.context || {},
|
|
124
123
|
localState: void 0,
|
|
125
|
-
rootState:
|
|
126
|
-
rootSetState:
|
|
124
|
+
rootState: t.builderContextSignal.rootState,
|
|
125
|
+
rootSetState: t.builderContextSignal.rootSetState
|
|
127
126
|
})
|
|
128
127
|
)
|
|
129
128
|
);
|
|
130
|
-
|
|
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",
|
|
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:
|
|
146
|
+
state: W(t.builderContextSignal.rootState),
|
|
148
147
|
ref: {
|
|
149
|
-
name:
|
|
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
|
|
158
|
-
window.addEventListener("message", v),
|
|
159
|
-
...
|
|
160
|
-
locale:
|
|
156
|
+
var e;
|
|
157
|
+
window.addEventListener("message", v), Q(), X({
|
|
158
|
+
...t.locale ? {
|
|
159
|
+
locale: t.locale
|
|
161
160
|
} : {},
|
|
162
|
-
...
|
|
163
|
-
enrich:
|
|
161
|
+
...t.enrich ? {
|
|
162
|
+
enrich: t.enrich
|
|
164
163
|
} : {},
|
|
165
|
-
...
|
|
166
|
-
trustedHosts:
|
|
164
|
+
...t.trustedHosts ? {
|
|
165
|
+
trustedHosts: t.trustedHosts
|
|
167
166
|
} : {},
|
|
168
|
-
modelName: (
|
|
169
|
-
apiKey:
|
|
167
|
+
modelName: (e = t.model) != null ? e : "",
|
|
168
|
+
apiKey: t.apiKey
|
|
170
169
|
}), Object.values(
|
|
171
|
-
|
|
170
|
+
t.builderContextSignal.componentInfos
|
|
172
171
|
).forEach((i) => {
|
|
173
|
-
var
|
|
174
|
-
if (!((
|
|
175
|
-
const
|
|
176
|
-
(a = window.parent) == null || a.postMessage(
|
|
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
|
|
185
|
-
const
|
|
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 =
|
|
188
|
-
(i === "BUILDER_STUDIO" || i ===
|
|
189
|
-
model:
|
|
190
|
-
apiKey:
|
|
191
|
-
apiVersion:
|
|
192
|
-
...i === "BUILDER_STUDIO" && ((
|
|
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:
|
|
193
|
+
id: t.context.symbolId
|
|
195
194
|
}
|
|
196
195
|
} : {}
|
|
197
196
|
}).then((d) => {
|
|
198
197
|
d && b(d);
|
|
199
198
|
});
|
|
200
199
|
}
|
|
201
|
-
|
|
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
|
|
209
|
-
return (
|
|
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
|
|
221
|
-
return (
|
|
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,
|
|
227
|
+
var n, e, i;
|
|
228
228
|
if (L()) {
|
|
229
|
-
g() && !
|
|
230
|
-
const
|
|
231
|
-
name: `builder.tests.${(n =
|
|
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
|
-
}),
|
|
234
|
-
if (
|
|
235
|
-
const d = (i =
|
|
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:
|
|
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
|
-
|
|
245
|
+
A() && g();
|
|
246
246
|
}
|
|
247
247
|
}, []), c(() => {
|
|
248
|
-
}, [
|
|
248
|
+
}, [t.content]), c(() => {
|
|
249
249
|
f();
|
|
250
|
-
}, [
|
|
251
|
-
|
|
252
|
-
}, [
|
|
253
|
-
|
|
254
|
-
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
|
-
}, [
|
|
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(
|
|
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": (
|
|
267
|
-
"builder-model":
|
|
268
|
-
className:
|
|
269
|
-
((
|
|
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: !
|
|
272
|
+
display: !t.builderContextSignal.content && q() ? "none" : void 0
|
|
273
273
|
},
|
|
274
274
|
...T(),
|
|
275
|
-
...
|
|
276
|
-
children:
|
|
275
|
+
...t.contentWrapperProps,
|
|
276
|
+
children: t.children
|
|
277
277
|
}
|
|
278
278
|
) : null });
|
|
279
279
|
}
|
|
280
280
|
export {
|
|
281
|
-
|
|
281
|
+
Rt as default
|
|
282
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.10";exports.SDK_VERSION=e;
|
|
@@ -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"),
|
|
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
|
|
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
|
|
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:
|
|
11
|
-
model:
|
|
12
|
-
apiKey:
|
|
13
|
-
enrich:
|
|
14
|
-
locale:
|
|
10
|
+
query: u,
|
|
11
|
+
model: A,
|
|
12
|
+
apiKey: d,
|
|
13
|
+
enrich: P,
|
|
14
|
+
locale: N,
|
|
15
15
|
apiVersion: o = J,
|
|
16
|
-
fields:
|
|
17
|
-
omit:
|
|
18
|
-
offset:
|
|
19
|
-
cacheSeconds:
|
|
20
|
-
staleCacheSeconds:
|
|
21
|
-
sort:
|
|
22
|
-
includeUnpublished:
|
|
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 (!
|
|
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/${
|
|
30
|
-
e.searchParams.set("apiKey",
|
|
31
|
-
const
|
|
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 (
|
|
34
|
-
locale:
|
|
33
|
+
if (h && (e.searchParams.set("locale", h), i = {
|
|
34
|
+
locale: h,
|
|
35
35
|
...i
|
|
36
|
-
}),
|
|
37
|
-
const s =
|
|
38
|
-
sort:
|
|
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
|
|
43
|
+
const g = {
|
|
44
44
|
...L(),
|
|
45
45
|
...O(t.options || {})
|
|
46
46
|
};
|
|
47
47
|
i = {
|
|
48
48
|
...i,
|
|
49
|
-
...$(
|
|
49
|
+
...$(g)
|
|
50
50
|
};
|
|
51
|
-
const
|
|
52
|
-
for (const s in
|
|
53
|
-
e.searchParams.set(s, String(
|
|
54
|
-
if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)),
|
|
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:
|
|
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
|
|
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 {
|
|
3
|
-
|
|
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:
|
|
6
|
+
value: e,
|
|
7
|
+
url: o
|
|
6
8
|
}) {
|
|
7
|
-
|
|
9
|
+
i(), globalThis._BUILDER_PREVIEW_LRU_CACHE.set(t, e), r(o);
|
|
8
10
|
}
|
|
9
11
|
export {
|
|
10
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
}>;
|
|
5
|
+
url: string;
|
|
6
|
+
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
}>;
|
|
5
|
+
url: string;
|
|
6
|
+
}): Promise<void>;
|