@builder.io/sdk-react-nextjs 0.17.1 → 0.17.3
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 +2 -2
- package/lib/browser/blocks/columns/columns.mjs +2 -2
- package/lib/browser/blocks/image/image.cjs +3 -3
- package/lib/browser/blocks/image/image.mjs +8 -8
- package/lib/browser/blocks/text/text.cjs +1 -1
- package/lib/browser/blocks/text/text.mjs +6 -24
- package/lib/browser/components/awaiter.cjs +1 -1
- package/lib/browser/components/block/block.cjs +1 -1
- package/lib/browser/components/block/block.mjs +27 -28
- package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/browser/components/blocks/blocks-wrapper.mjs +2 -2
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +102 -96
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-block-component-options.cjs +1 -1
- package/lib/browser/functions/get-block-component-options.mjs +21 -5
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/browser/functions/get-processed-block.cjs +1 -1
- package/lib/browser/functions/get-processed-block.mjs +18 -19
- package/lib/browser/helpers/flatten.cjs +1 -1
- package/lib/browser/helpers/flatten.mjs +28 -15
- package/lib/edge/blocks/columns/columns.cjs +2 -2
- package/lib/edge/blocks/columns/columns.mjs +2 -2
- package/lib/edge/blocks/image/image.cjs +3 -3
- package/lib/edge/blocks/image/image.mjs +8 -8
- package/lib/edge/blocks/text/text.cjs +1 -1
- package/lib/edge/blocks/text/text.mjs +6 -24
- package/lib/edge/components/awaiter.cjs +1 -1
- package/lib/edge/components/block/block.cjs +1 -1
- package/lib/edge/components/block/block.mjs +27 -28
- package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/edge/components/blocks/blocks-wrapper.mjs +2 -2
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +102 -96
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +5 -5
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +25 -28
- package/lib/edge/functions/get-block-component-options.cjs +1 -1
- package/lib/edge/functions/get-block-component-options.mjs +21 -5
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/edge/functions/get-processed-block.cjs +1 -1
- package/lib/edge/functions/get-processed-block.mjs +18 -19
- package/lib/edge/helpers/flatten.cjs +1 -1
- package/lib/edge/helpers/flatten.mjs +28 -15
- package/lib/node/blocks/columns/columns.cjs +2 -2
- package/lib/node/blocks/columns/columns.mjs +2 -2
- package/lib/node/blocks/image/image.cjs +3 -3
- package/lib/node/blocks/image/image.mjs +8 -8
- package/lib/node/blocks/text/text.cjs +1 -1
- package/lib/node/blocks/text/text.mjs +6 -24
- package/lib/node/components/awaiter.cjs +1 -1
- package/lib/node/components/block/block.cjs +1 -1
- package/lib/node/components/block/block.mjs +27 -28
- package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/node/components/blocks/blocks-wrapper.mjs +2 -2
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +102 -96
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-block-component-options.cjs +1 -1
- package/lib/node/functions/get-block-component-options.mjs +21 -5
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/node/functions/get-processed-block.cjs +1 -1
- package/lib/node/functions/get-processed-block.mjs +18 -19
- package/lib/node/helpers/flatten.cjs +1 -1
- package/lib/node/helpers/flatten.mjs +28 -15
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/get-block-component-options.d.ts +2 -1
- package/types/cjs/functions/get-processed-block.d.ts +1 -6
- package/types/cjs/helpers/flatten.d.ts +6 -0
- package/types/cjs/server-index.d.ts +1 -1
- package/types/cjs/types/builder-content.d.ts +1 -0
- package/types/cjs/types/input.d.ts +10 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/get-block-component-options.d.ts +2 -1
- package/types/esm/functions/get-processed-block.d.ts +1 -6
- package/types/esm/helpers/flatten.d.ts +6 -0
- package/types/esm/server-index.d.ts +1 -1
- package/types/esm/types/builder-content.d.ts +1 -0
- package/types/esm/types/input.d.ts +10 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import { evaluate as
|
|
6
|
-
import { fastClone as
|
|
7
|
-
import { fetchOneEntry as
|
|
8
|
-
import { isBrowser as
|
|
2
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as P, useState as s, useEffect as l } 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";
|
|
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
|
|
11
|
-
import { logFetch as
|
|
10
|
+
import { isPreviewing as B } from "../../../functions/is-previewing.mjs";
|
|
11
|
+
import { logFetch as F } from "../../../functions/log-fetch.mjs";
|
|
12
12
|
import { createRegisterComponentMessage as z } from "../../../functions/register-component.mjs";
|
|
13
|
-
import { _track as
|
|
13
|
+
import { _track as H } from "../../../functions/track/index.mjs";
|
|
14
14
|
import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
16
|
import { postPreviewContent as G } from "../../../helpers/preview-lru-cache/set.mjs";
|
|
@@ -20,37 +20,37 @@ import { triggerAnimation as Y } from "../../block/animator.mjs";
|
|
|
20
20
|
import { needsElementRefDivForEditing as q } from "./enable-editor.helpers.mjs";
|
|
21
21
|
import { getWrapperClassName as Z } from "./styles.helpers.mjs";
|
|
22
22
|
import { useRouter as p } from "next/navigation";
|
|
23
|
-
function
|
|
24
|
-
var
|
|
25
|
-
const
|
|
23
|
+
function we(e) {
|
|
24
|
+
var R, w, y;
|
|
25
|
+
const c = P(null);
|
|
26
26
|
function g(n) {
|
|
27
|
-
var
|
|
27
|
+
var i, a;
|
|
28
28
|
const t = {
|
|
29
29
|
...e.builderContextSignal.rootState,
|
|
30
30
|
...n
|
|
31
31
|
};
|
|
32
|
-
e.builderContextSignal.rootSetState ? (
|
|
32
|
+
e.builderContextSignal.rootSetState ? (a = (i = e.builderContextSignal).rootSetState) == null || a.call(i, t) : e.builderContextSignal.rootState = t;
|
|
33
33
|
}
|
|
34
34
|
function b(n) {
|
|
35
|
-
var
|
|
35
|
+
var i, a, r, o, d;
|
|
36
36
|
const t = {
|
|
37
37
|
...e.builderContextSignal.content,
|
|
38
38
|
...n,
|
|
39
39
|
data: {
|
|
40
|
-
...(
|
|
40
|
+
...(i = e.builderContextSignal.content) == null ? void 0 : i.data,
|
|
41
41
|
...n == null ? void 0 : n.data
|
|
42
42
|
},
|
|
43
43
|
meta: {
|
|
44
|
-
...(
|
|
44
|
+
...(a = e.builderContextSignal.content) == null ? void 0 : a.meta,
|
|
45
45
|
...n == null ? void 0 : n.meta,
|
|
46
|
-
breakpoints: ((
|
|
46
|
+
breakpoints: ((r = n == null ? void 0 : n.meta) == null ? void 0 : r.breakpoints) || ((d = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : d.breakpoints)
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
G({
|
|
50
50
|
value: t,
|
|
51
51
|
key: t.id
|
|
52
52
|
}).then(() => {
|
|
53
|
-
|
|
53
|
+
M.refresh();
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function T() {
|
|
@@ -59,20 +59,20 @@ function Re(e) {
|
|
|
59
59
|
"aria-hidden": !0
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
const [
|
|
62
|
+
const [D, ee] = s(
|
|
63
63
|
() => e.contentWrapper || "div"
|
|
64
64
|
);
|
|
65
|
-
function
|
|
65
|
+
function v(n) {
|
|
66
66
|
return J({
|
|
67
67
|
model: e.model,
|
|
68
68
|
trustedHosts: e.trustedHosts,
|
|
69
69
|
callbacks: {
|
|
70
70
|
configureSdk: (t) => {
|
|
71
|
-
var
|
|
72
|
-
const { breakpoints:
|
|
73
|
-
!
|
|
71
|
+
var r;
|
|
72
|
+
const { breakpoints: i, contentId: a } = t;
|
|
73
|
+
!a || a !== ((r = e.builderContextSignal.content) == null ? void 0 : r.id) || i && b({
|
|
74
74
|
meta: {
|
|
75
|
-
breakpoints:
|
|
75
|
+
breakpoints: i
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
},
|
|
@@ -85,36 +85,36 @@ function Re(e) {
|
|
|
85
85
|
}
|
|
86
86
|
})(n);
|
|
87
87
|
}
|
|
88
|
-
const [h, te] =
|
|
89
|
-
function
|
|
90
|
-
var t,
|
|
88
|
+
const [h, te] = s(() => ({})), [S, ne] = s(() => ({})), [x, U] = s(() => !1);
|
|
89
|
+
function V(n) {
|
|
90
|
+
var t, i;
|
|
91
91
|
if (e.builderContextSignal.content) {
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const a = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, r = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
|
|
93
|
+
H({
|
|
94
94
|
apiHost: e.apiHost,
|
|
95
95
|
type: "click",
|
|
96
96
|
canTrack: K(e.canTrack),
|
|
97
|
-
contentId:
|
|
97
|
+
contentId: r,
|
|
98
98
|
apiKey: e.apiKey,
|
|
99
|
-
variationId:
|
|
99
|
+
variationId: a !== r ? a : void 0,
|
|
100
100
|
...$(n),
|
|
101
101
|
unique: !x
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
x ||
|
|
104
|
+
x || U(!0);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
var t,
|
|
108
|
-
const n = (
|
|
109
|
-
Object.entries(n).forEach(([
|
|
110
|
-
if (!o ||
|
|
106
|
+
function _() {
|
|
107
|
+
var t, i, a;
|
|
108
|
+
const n = (a = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? a : {};
|
|
109
|
+
Object.entries(n).forEach(([r, o]) => {
|
|
110
|
+
if (!o || S[r] || h[r] && !f())
|
|
111
111
|
return;
|
|
112
|
-
|
|
113
|
-
const
|
|
112
|
+
S[r] = !0;
|
|
113
|
+
const d = o.replace(
|
|
114
114
|
/{{([^}]+)}}/g,
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
code:
|
|
115
|
+
(u, N) => String(
|
|
116
|
+
W({
|
|
117
|
+
code: N,
|
|
118
118
|
context: e.context || {},
|
|
119
119
|
localState: void 0,
|
|
120
120
|
rootState: e.builderContextSignal.rootState,
|
|
@@ -122,24 +122,24 @@ function Re(e) {
|
|
|
122
122
|
})
|
|
123
123
|
)
|
|
124
124
|
);
|
|
125
|
-
|
|
125
|
+
F(d), fetch(d).then((u) => u.json()).then((u) => {
|
|
126
126
|
g({
|
|
127
|
-
[
|
|
128
|
-
}), h[
|
|
129
|
-
}).catch((
|
|
130
|
-
console.error("error fetching dynamic data", o,
|
|
127
|
+
[r]: u
|
|
128
|
+
}), h[r] = !0;
|
|
129
|
+
}).catch((u) => {
|
|
130
|
+
console.error("error fetching dynamic data", o, u);
|
|
131
131
|
}).finally(() => {
|
|
132
|
-
|
|
132
|
+
S[r] = !1;
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function m() {
|
|
137
137
|
f() && window.dispatchEvent(
|
|
138
138
|
new CustomEvent(
|
|
139
139
|
"builder:component:stateChange",
|
|
140
140
|
{
|
|
141
141
|
detail: {
|
|
142
|
-
state:
|
|
142
|
+
state: j(e.builderContextSignal.rootState),
|
|
143
143
|
ref: {
|
|
144
144
|
name: e.model
|
|
145
145
|
}
|
|
@@ -149,7 +149,7 @@ function Re(e) {
|
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
function C(n) {
|
|
152
|
-
window.addEventListener("message",
|
|
152
|
+
window.addEventListener("message", v), Q(), X({
|
|
153
153
|
...e.locale ? {
|
|
154
154
|
locale: e.locale
|
|
155
155
|
} : {},
|
|
@@ -162,92 +162,98 @@ function Re(e) {
|
|
|
162
162
|
}), Object.values(
|
|
163
163
|
e.builderContextSignal.componentInfos
|
|
164
164
|
).forEach((t) => {
|
|
165
|
-
var
|
|
166
|
-
if (!e.model || !((
|
|
167
|
-
const
|
|
168
|
-
(
|
|
165
|
+
var i, a;
|
|
166
|
+
if (!e.model || !((i = t.models) != null && i.length) || t.models.includes(e.model)) {
|
|
167
|
+
const r = z(t);
|
|
168
|
+
(a = window.parent) == null || a.postMessage(r, "*");
|
|
169
169
|
}
|
|
170
170
|
}), window.addEventListener(
|
|
171
171
|
"builder:component:stateChangeListenerActivated",
|
|
172
|
-
|
|
172
|
+
m
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
function E(n) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
r
|
|
180
|
-
|
|
176
|
+
var o;
|
|
177
|
+
const t = new URL(location.href).searchParams, i = t.get("builder.preview"), a = t.get(
|
|
178
|
+
`builder.overrides.${i}`
|
|
179
|
+
), r = t.get("apiKey") || t.get("builder.space");
|
|
180
|
+
(i === "BUILDER_STUDIO" || i === e.model && r === e.apiKey && (!e.content || a === e.content.id)) && A({
|
|
181
|
+
model: e.model || "",
|
|
181
182
|
apiKey: e.apiKey,
|
|
182
|
-
apiVersion: e.builderContextSignal.apiVersion
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
apiVersion: e.builderContextSignal.apiVersion,
|
|
184
|
+
...i === "BUILDER_STUDIO" && ((o = e.context) != null && o.symbolId) ? {
|
|
185
|
+
query: {
|
|
186
|
+
id: e.context.symbolId
|
|
187
|
+
}
|
|
188
|
+
} : {}
|
|
189
|
+
}).then((d) => {
|
|
190
|
+
d && b(d);
|
|
185
191
|
});
|
|
186
192
|
}
|
|
187
|
-
const
|
|
188
|
-
return I.current || (
|
|
193
|
+
const M = p(), I = P(!1);
|
|
194
|
+
return I.current || (_(), m(), I.current = !0), l(() => {
|
|
189
195
|
var n;
|
|
190
|
-
return (n =
|
|
196
|
+
return (n = c.current) == null || n.addEventListener(
|
|
191
197
|
"initeditingbldr",
|
|
192
198
|
C
|
|
193
199
|
), () => {
|
|
194
200
|
var t;
|
|
195
|
-
return (t =
|
|
201
|
+
return (t = c.current) == null ? void 0 : t.removeEventListener(
|
|
196
202
|
"initeditingbldr",
|
|
197
203
|
C
|
|
198
204
|
);
|
|
199
205
|
};
|
|
200
|
-
}, []),
|
|
206
|
+
}, []), l(() => {
|
|
201
207
|
var n;
|
|
202
|
-
return (n =
|
|
208
|
+
return (n = c.current) == null || n.addEventListener(
|
|
203
209
|
"initpreviewingbldr",
|
|
204
210
|
E
|
|
205
211
|
), () => {
|
|
206
212
|
var t;
|
|
207
|
-
return (t =
|
|
213
|
+
return (t = c.current) == null ? void 0 : t.removeEventListener(
|
|
208
214
|
"initpreviewingbldr",
|
|
209
215
|
E
|
|
210
216
|
);
|
|
211
217
|
};
|
|
212
|
-
}, []),
|
|
218
|
+
}, []), l(() => {
|
|
213
219
|
var n, t;
|
|
214
|
-
if (
|
|
215
|
-
if (f() && !e.isNestedRender &&
|
|
216
|
-
const
|
|
217
|
-
|
|
220
|
+
if (L()) {
|
|
221
|
+
if (f() && !e.isNestedRender && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && K(e.canTrack)) {
|
|
222
|
+
const a = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, r = (t = e.builderContextSignal.content) == null ? void 0 : t.id, o = e.apiKey;
|
|
223
|
+
H({
|
|
218
224
|
apiHost: e.apiHost,
|
|
219
225
|
type: "impression",
|
|
220
226
|
canTrack: !0,
|
|
221
|
-
contentId:
|
|
227
|
+
contentId: r,
|
|
222
228
|
apiKey: o,
|
|
223
|
-
variationId:
|
|
229
|
+
variationId: a !== r ? a : void 0
|
|
224
230
|
});
|
|
225
231
|
}
|
|
226
|
-
|
|
232
|
+
B() && f();
|
|
227
233
|
}
|
|
228
|
-
}, []),
|
|
229
|
-
}, [e.content]),
|
|
230
|
-
|
|
231
|
-
}, [e.builderContextSignal.rootState]),
|
|
234
|
+
}, []), l(() => {
|
|
235
|
+
}, [e.content]), l(() => {
|
|
236
|
+
m();
|
|
237
|
+
}, [e.builderContextSignal.rootState]), l(() => {
|
|
232
238
|
e.data && g(e.data);
|
|
233
|
-
}, [e.data]),
|
|
239
|
+
}, [e.data]), l(() => {
|
|
234
240
|
e.locale && g({
|
|
235
241
|
locale: e.locale
|
|
236
242
|
});
|
|
237
|
-
}, [e.locale]),
|
|
238
|
-
|
|
243
|
+
}, [e.locale]), l(() => () => {
|
|
244
|
+
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
239
245
|
"builder:component:stateChangeListenerActivated",
|
|
240
|
-
|
|
246
|
+
m
|
|
241
247
|
));
|
|
242
|
-
}, []), /* @__PURE__ */
|
|
243
|
-
|
|
248
|
+
}, []), /* @__PURE__ */ k(O.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content || q() ? /* @__PURE__ */ k(
|
|
249
|
+
D,
|
|
244
250
|
{
|
|
245
|
-
ref:
|
|
246
|
-
onClick: (n) =>
|
|
247
|
-
"builder-content-id": (
|
|
251
|
+
ref: c,
|
|
252
|
+
onClick: (n) => V(n),
|
|
253
|
+
"builder-content-id": (R = e.builderContextSignal.content) == null ? void 0 : R.id,
|
|
248
254
|
"builder-model": e.model,
|
|
249
255
|
className: Z(
|
|
250
|
-
((
|
|
256
|
+
((w = e.content) == null ? void 0 : w.testVariationId) || ((y = e.content) == null ? void 0 : y.id)
|
|
251
257
|
),
|
|
252
258
|
style: {
|
|
253
259
|
display: !e.builderContextSignal.content && q() ? "none" : void 0
|
|
@@ -259,5 +265,5 @@ function Re(e) {
|
|
|
259
265
|
) : null });
|
|
260
266
|
}
|
|
261
267
|
export {
|
|
262
|
-
|
|
268
|
+
we as default
|
|
263
269
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.3";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./evaluate/evaluate.cjs");function i(t,e){var o;return{...(o=t.component)==null?void 0:o.options,...t.options,...r(t,e)}}const r=(t,e)=>{var o,n;if(((o=t.component)==null?void 0:o.name)==="Text"&&((n=t.component.options)!=null&&n.text)&&typeof t.component.options.text=="string")return{...t.component.options,text:t.component.options.text.replace(/{{([^}]+)}}/g,(s,p)=>a.evaluate({code:p,context:e,localState:e.localState,rootState:e.rootState,rootSetState:e.rootSetState}))}};exports.getBlockComponentOptions=i;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { evaluate as a } from "./evaluate/evaluate.mjs";
|
|
2
|
+
function s(t, o) {
|
|
3
|
+
var e;
|
|
3
4
|
return {
|
|
4
|
-
...(
|
|
5
|
-
...
|
|
5
|
+
...(e = t.component) == null ? void 0 : e.options,
|
|
6
|
+
...t.options,
|
|
7
|
+
...r(t, o)
|
|
6
8
|
};
|
|
7
9
|
}
|
|
10
|
+
const r = (t, o) => {
|
|
11
|
+
var e, n;
|
|
12
|
+
if (((e = t.component) == null ? void 0 : e.name) === "Text" && ((n = t.component.options) != null && n.text) && typeof t.component.options.text == "string")
|
|
13
|
+
return {
|
|
14
|
+
...t.component.options,
|
|
15
|
+
text: t.component.options.text.replace(/{{([^}]+)}}/g, (i, p) => a({
|
|
16
|
+
code: p,
|
|
17
|
+
context: o,
|
|
18
|
+
localState: o.localState,
|
|
19
|
+
rootState: o.rootState,
|
|
20
|
+
rootSetState: o.rootSetState
|
|
21
|
+
}))
|
|
22
|
+
};
|
|
23
|
+
};
|
|
8
24
|
export {
|
|
9
|
-
|
|
25
|
+
s as getBlockComponentOptions
|
|
10
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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,59 +1,79 @@
|
|
|
1
|
-
import { flatten as
|
|
2
|
-
import { normalizeSearchParams as
|
|
3
|
-
import { DEFAULT_API_VERSION as
|
|
4
|
-
import { getBuilderSearchParamsFromWindow as
|
|
5
|
-
|
|
1
|
+
import { flatten as U, flattenMongoQuery as E, unflatten as F } from "../../helpers/flatten.mjs";
|
|
2
|
+
import { normalizeSearchParams as O } from "../../helpers/search/search.mjs";
|
|
3
|
+
import { DEFAULT_API_VERSION as J } from "../../types/api-version.mjs";
|
|
4
|
+
import { getBuilderSearchParamsFromWindow as L } from "../get-builder-search-params/index.mjs";
|
|
5
|
+
import { isBrowser as R } from "../is-browser.mjs";
|
|
6
|
+
const w = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
|
|
6
7
|
const {
|
|
7
|
-
limit:
|
|
8
|
-
userAttributes:
|
|
8
|
+
limit: a = 30,
|
|
9
|
+
userAttributes: r,
|
|
9
10
|
query: h,
|
|
10
|
-
model:
|
|
11
|
-
apiKey:
|
|
12
|
-
enrich:
|
|
13
|
-
locale:
|
|
14
|
-
apiVersion:
|
|
15
|
-
fields:
|
|
16
|
-
omit:
|
|
17
|
-
offset:
|
|
18
|
-
cacheSeconds:
|
|
11
|
+
model: y,
|
|
12
|
+
apiKey: u,
|
|
13
|
+
enrich: d,
|
|
14
|
+
locale: A,
|
|
15
|
+
apiVersion: o = J,
|
|
16
|
+
fields: P,
|
|
17
|
+
omit: N,
|
|
18
|
+
offset: c,
|
|
19
|
+
cacheSeconds: l,
|
|
19
20
|
staleCacheSeconds: f,
|
|
20
21
|
sort: S,
|
|
21
|
-
includeUnpublished:
|
|
22
|
-
apiHost:
|
|
23
|
-
} =
|
|
24
|
-
if (!
|
|
22
|
+
includeUnpublished: p,
|
|
23
|
+
apiHost: v
|
|
24
|
+
} = t;
|
|
25
|
+
if (!u)
|
|
25
26
|
throw new Error("Missing API key");
|
|
26
|
-
if (!["v3"].includes(
|
|
27
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${
|
|
28
|
-
const
|
|
29
|
-
e.searchParams.set("apiKey",
|
|
30
|
-
const
|
|
31
|
-
let i =
|
|
32
|
-
if (
|
|
33
|
-
locale:
|
|
27
|
+
if (!["v3"].includes(o))
|
|
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);
|
|
32
|
+
let i = r || {};
|
|
33
|
+
if (m && (e.searchParams.set("locale", m), i = {
|
|
34
|
+
locale: m,
|
|
34
35
|
...i
|
|
35
|
-
}),
|
|
36
|
-
const s =
|
|
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({
|
|
37
38
|
sort: S
|
|
38
39
|
});
|
|
39
|
-
for (const
|
|
40
|
-
e.searchParams.set(
|
|
40
|
+
for (const n in s)
|
|
41
|
+
e.searchParams.set(n, JSON.stringify(s[n]));
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
-
}
|
|
43
|
+
const b = {
|
|
44
|
+
...L(),
|
|
45
|
+
...O(t.options || {})
|
|
46
|
+
};
|
|
47
|
+
i = {
|
|
48
|
+
...i,
|
|
49
|
+
...$(b)
|
|
50
|
+
};
|
|
51
|
+
const g = U(b);
|
|
46
52
|
for (const s in g)
|
|
47
53
|
e.searchParams.set(s, String(g[s]));
|
|
48
|
-
if (i && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
|
|
54
|
+
if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
|
|
49
55
|
const s = E({
|
|
50
56
|
query: h
|
|
51
57
|
});
|
|
52
|
-
for (const
|
|
53
|
-
e.searchParams.set(
|
|
58
|
+
for (const n in s)
|
|
59
|
+
e.searchParams.set(n, JSON.stringify(s[n]));
|
|
54
60
|
}
|
|
55
61
|
return e;
|
|
62
|
+
}, T = (t) => {
|
|
63
|
+
const a = {};
|
|
64
|
+
for (const r in t)
|
|
65
|
+
r.startsWith("userAttributes.") && (a[r] = t[r], delete t[r]);
|
|
66
|
+
return a;
|
|
67
|
+
}, $ = (t) => {
|
|
68
|
+
if (R() && t.preview === "BUILDER_STUDIO") {
|
|
69
|
+
t["userAttributes.urlPath"] = window.location.pathname, t["userAttributes.host"] = window.location.host;
|
|
70
|
+
const a = T(t), {
|
|
71
|
+
userAttributes: r
|
|
72
|
+
} = F(a);
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
56
76
|
};
|
|
57
77
|
export {
|
|
58
|
-
|
|
78
|
+
_ as generateContentUrl
|
|
59
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../constants/target.cjs"),d=require("../helpers/omit.cjs"),p=require("./evaluate/evaluate.cjs"),f=require("./extract-localized-values.cjs"),g=require("./fast-clone.cjs"),m=require("./set.cjs"),y=require("./transform-block.cjs");function o(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>o(n));if(e["@type"]==="@builder.io/sdk:Element")return e;const t={};for(const n in e)n!=="meta"&&Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=o(e[n]));return t}const C=["svelte","vue","angular","qwik","solid"].includes(u.TARGET),q=e=>{if(C){const t=g.fastClone(e);return{...t,properties:{...t.properties},actions:{...t.actions}}}else{const t=o(d.omit(e,"children","meta"));return{...t,properties:{...t.properties},actions:{...t.actions},children:e.children,meta:e.meta}}},v=({block:e,context:t,localState:n,rootState:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../constants/target.cjs"),d=require("../helpers/omit.cjs"),p=require("./evaluate/evaluate.cjs"),f=require("./extract-localized-values.cjs"),g=require("./fast-clone.cjs"),m=require("./set.cjs"),y=require("./transform-block.cjs");function o(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>o(n));if(e["@type"]==="@builder.io/sdk:Element")return e;const t={};for(const n in e)n!=="meta"&&Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=o(e[n]));return t}const C=["svelte","vue","angular","qwik","solid"].includes(u.TARGET),q=e=>{if(C){const t=g.fastClone(e);return{...t,properties:{...t.properties},actions:{...t.actions}}}else{const t=o(d.omit(e,"children","meta"));return{...t,properties:{...t.properties},actions:{...t.actions},children:e.children,meta:e.meta}}},v=({block:e,context:t,localState:n,rootState:i,rootSetState:s})=>{if(!e.bindings)return e;const r=q(e);for(const c in e.bindings){const a=e.bindings[c],l=p.evaluate({code:a,localState:n,rootState:i,rootSetState:s,context:t});m.set(r,c,l)}return r};function B({block:e,context:t,localState:n,rootState:i,rootSetState:s}){let r=f.resolveLocalizedValues(e,i.locale);return r=y.transformBlock(r),v({block:r,localState:n,rootState:i,rootSetState:s,context:t})}exports.deepCloneWithConditions=o;exports.getProcessedBlock=B;
|
|
@@ -5,16 +5,16 @@ import { resolveLocalizedValues as f } from "./extract-localized-values.mjs";
|
|
|
5
5
|
import { fastClone as u } from "./fast-clone.mjs";
|
|
6
6
|
import { set as y } from "./set.mjs";
|
|
7
7
|
import { transformBlock as g } from "./transform-block.mjs";
|
|
8
|
-
function
|
|
8
|
+
function s(e) {
|
|
9
9
|
if (e === null || typeof e != "object")
|
|
10
10
|
return e;
|
|
11
11
|
if (Array.isArray(e))
|
|
12
|
-
return e.map((t) =>
|
|
12
|
+
return e.map((t) => s(t));
|
|
13
13
|
if (e["@type"] === "@builder.io/sdk:Element")
|
|
14
14
|
return e;
|
|
15
15
|
const r = {};
|
|
16
16
|
for (const t in e)
|
|
17
|
-
t !== "meta" && Object.prototype.hasOwnProperty.call(e, t) && (r[t] =
|
|
17
|
+
t !== "meta" && Object.prototype.hasOwnProperty.call(e, t) && (r[t] = s(e[t]));
|
|
18
18
|
return r;
|
|
19
19
|
}
|
|
20
20
|
const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) => {
|
|
@@ -30,7 +30,7 @@ const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) =>
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
} else {
|
|
33
|
-
const r =
|
|
33
|
+
const r = s(m(e, "children", "meta"));
|
|
34
34
|
return {
|
|
35
35
|
...r,
|
|
36
36
|
properties: {
|
|
@@ -47,42 +47,41 @@ const C = ["svelte", "vue", "angular", "qwik", "solid"].includes(l), v = (e) =>
|
|
|
47
47
|
block: e,
|
|
48
48
|
context: r,
|
|
49
49
|
localState: t,
|
|
50
|
-
rootState:
|
|
51
|
-
rootSetState:
|
|
50
|
+
rootState: i,
|
|
51
|
+
rootSetState: o
|
|
52
52
|
}) => {
|
|
53
53
|
if (!e.bindings)
|
|
54
54
|
return e;
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
const p = e.bindings[
|
|
55
|
+
const n = v(e);
|
|
56
|
+
for (const c in e.bindings) {
|
|
57
|
+
const p = e.bindings[c], a = d({
|
|
58
58
|
code: p,
|
|
59
59
|
localState: t,
|
|
60
|
-
rootState:
|
|
61
|
-
rootSetState:
|
|
60
|
+
rootState: i,
|
|
61
|
+
rootSetState: o,
|
|
62
62
|
context: r
|
|
63
63
|
});
|
|
64
|
-
y(
|
|
64
|
+
y(n, c, a);
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return n;
|
|
67
67
|
};
|
|
68
68
|
function P({
|
|
69
69
|
block: e,
|
|
70
70
|
context: r,
|
|
71
|
-
|
|
72
|
-
localState: s,
|
|
71
|
+
localState: t,
|
|
73
72
|
rootState: i,
|
|
74
73
|
rootSetState: o
|
|
75
74
|
}) {
|
|
76
75
|
let n = f(e, i.locale);
|
|
77
|
-
return n = g(n),
|
|
76
|
+
return n = g(n), O({
|
|
78
77
|
block: n,
|
|
79
|
-
localState:
|
|
78
|
+
localState: t,
|
|
80
79
|
rootState: i,
|
|
81
80
|
rootSetState: o,
|
|
82
81
|
context: r
|
|
83
|
-
})
|
|
82
|
+
});
|
|
84
83
|
}
|
|
85
84
|
export {
|
|
86
|
-
|
|
85
|
+
s as deepCloneWithConditions,
|
|
87
86
|
P as getProcessedBlock
|
|
88
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(l,s=null,o="."){return Object.keys(l).reduce((n,t)=>{const e=l[t],r=[s,t].filter(Boolean).join(o);return[typeof e=="object",e!==null,!(Array.isArray(e)&&e.length===0)].every(Boolean)?{...n,...i(e,r,o)}:{...n,[r]:e}},{})}function u(l,s,o={}){for(const n in l){const t=l[n],e=s?s+"."+n:n;t&&typeof t=="object"&&!Array.isArray(t)&&!Object.keys(t).find(r=>r.startsWith("$"))?u(t,e,o):o[e]=t}return o}function c(l){const s={};for(const o in l){const n=o.split(".");let t=s;for(let e=0;e<n.length;e++){const r=n[e];e===n.length-1?t[r]=l[o]:(t[r]=t[r]||{},t=t[r])}}return s}exports.flatten=i;exports.flattenMongoQuery=u;exports.unflatten=c;
|