@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,12 +1,12 @@
|
|
|
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.cjs"),o=require("./acorn-interpreter.cjs");function C(){const r=o.prototype.getProperty,i=o.prototype.setProperty;function a(t,n){if(t==null||!t._connected)return r.call(this,t,n);const e=t._connected[n];return Array.isArray(e)?this.nativeToPseudo(e):typeof e=="object"?this.createConnectedObject(e):e}function f(t,n,e,d){if(t==null||!t._connected)return i.call(this,t,n,e,d);t._connected[n]=this.pseudoToNative(e)}const u=[],p=[];for(const t of Object.keys(o.prototype))o.prototype[t]===r&&u.push(t),o.prototype[t]===i&&p.push(t);for(const t of u)o.prototype[t]=a;for(const t of p)o.prototype[t]=f;o.prototype.createConnectedObject=function(t){const n=this.createObject(this.OBJECT);return n._connected=t,n}}C();const m=r=>r.replace(/^.*?function main\(\)/,`
|
|
2
2
|
var __awaiter = function (e, t, n, r) {return r()},
|
|
3
3
|
__generator = function (e, t) { return t() };
|
|
4
|
-
function main()`).replace(/\?\./g,"."),P=r=>r+"JSON",
|
|
5
|
-
`),
|
|
4
|
+
function main()`).replace(/\?\./g,"."),P=r=>r+"JSON",v=({builder:r,context:i,event:a,rootState:f,localState:u,rootSetState:p,code:t})=>{const n=O.flattenState({rootState:f,localState:u,rootSetState:p}),e=O.getFunctionArguments({builder:r,context:i,event:a,state:n}),d=e.map(([c])=>{const s=P(c);return c==="state"?"":`var ${c} = ${s} === undefined ? undefined : JSON.parse(${s});`}).join(`
|
|
5
|
+
`),h=m(t);if(h==="")return;const S=`
|
|
6
6
|
function theFunction() {
|
|
7
7
|
${d}
|
|
8
8
|
|
|
9
|
-
${
|
|
9
|
+
${h}
|
|
10
10
|
}
|
|
11
11
|
theFunction();
|
|
12
|
-
`,_=function(c,s){e.forEach(([l,
|
|
12
|
+
`,_=function(c,s){e.forEach(([l,g])=>{if(l==="state")c.setProperty(s,l,c.createConnectedObject(g),c.READONLY_DESCRIPTOR);else{const N=JSON.stringify(g);c.setProperty(s,P(l),N)}})},y=new o(S,_);return y.run(),y.pseudoToNative(y.value)};exports.runInEdge=v;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { flattenState as S, getFunctionArguments as C } from "../helpers.mjs";
|
|
1
|
+
import { flattenState as N, getFunctionArguments as C } from "../helpers.mjs";
|
|
3
2
|
import o from "./acorn-interpreter.mjs";
|
|
4
|
-
function
|
|
3
|
+
function S() {
|
|
5
4
|
const r = o.prototype.getProperty, i = o.prototype.setProperty;
|
|
6
5
|
function a(t, n) {
|
|
7
6
|
if (t == null || !t._connected)
|
|
@@ -14,68 +13,66 @@ function v() {
|
|
|
14
13
|
return i.call(this, t, n, e, d);
|
|
15
14
|
t._connected[n] = this.pseudoToNative(e);
|
|
16
15
|
}
|
|
17
|
-
const
|
|
16
|
+
const u = [], p = [];
|
|
18
17
|
for (const t of Object.keys(o.prototype))
|
|
19
|
-
o.prototype[t] === r &&
|
|
20
|
-
for (const t of p)
|
|
21
|
-
o.prototype[t] = a;
|
|
18
|
+
o.prototype[t] === r && u.push(t), o.prototype[t] === i && p.push(t);
|
|
22
19
|
for (const t of u)
|
|
20
|
+
o.prototype[t] = a;
|
|
21
|
+
for (const t of p)
|
|
23
22
|
o.prototype[t] = f;
|
|
24
23
|
o.prototype.createConnectedObject = function(t) {
|
|
25
24
|
const n = this.createObject(this.OBJECT);
|
|
26
25
|
return n._connected = t, n;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
const
|
|
28
|
+
S();
|
|
29
|
+
const v = (r) => r.replace(/^.*?function main\(\)/, `
|
|
31
30
|
var __awaiter = function (e, t, n, r) {return r()},
|
|
32
31
|
__generator = function (e, t) { return t() };
|
|
33
|
-
function main()`).replace(/\?\./g, "."),
|
|
32
|
+
function main()`).replace(/\?\./g, "."), g = (r) => r + "JSON", $ = ({
|
|
34
33
|
builder: r,
|
|
35
34
|
context: i,
|
|
36
35
|
event: a,
|
|
37
36
|
rootState: f,
|
|
38
|
-
localState:
|
|
39
|
-
rootSetState:
|
|
37
|
+
localState: u,
|
|
38
|
+
rootSetState: p,
|
|
40
39
|
code: t
|
|
41
40
|
}) => {
|
|
42
|
-
const n =
|
|
41
|
+
const n = N({
|
|
43
42
|
rootState: f,
|
|
44
|
-
localState:
|
|
45
|
-
rootSetState:
|
|
43
|
+
localState: u,
|
|
44
|
+
rootSetState: p
|
|
46
45
|
}), e = C({
|
|
47
46
|
builder: r,
|
|
48
47
|
context: i,
|
|
49
48
|
event: a,
|
|
50
49
|
state: n
|
|
51
50
|
}), d = e.map(([c]) => {
|
|
52
|
-
const s =
|
|
51
|
+
const s = g(c);
|
|
53
52
|
return c === "state" ? "" : `var ${c} = ${s} === undefined ? undefined : JSON.parse(${s});`;
|
|
54
53
|
}).join(`
|
|
55
|
-
`),
|
|
56
|
-
if (
|
|
57
|
-
N.warn("Skipping evaluation of empty code block.");
|
|
54
|
+
`), h = v(t);
|
|
55
|
+
if (h === "")
|
|
58
56
|
return;
|
|
59
|
-
|
|
60
|
-
const O = `
|
|
57
|
+
const m = `
|
|
61
58
|
function theFunction() {
|
|
62
59
|
${d}
|
|
63
60
|
|
|
64
|
-
${
|
|
61
|
+
${h}
|
|
65
62
|
}
|
|
66
63
|
theFunction();
|
|
67
64
|
`, P = function(c, s) {
|
|
68
|
-
e.forEach(([l,
|
|
65
|
+
e.forEach(([l, O]) => {
|
|
69
66
|
if (l === "state")
|
|
70
|
-
c.setProperty(s, l, c.createConnectedObject(
|
|
67
|
+
c.setProperty(s, l, c.createConnectedObject(O), c.READONLY_DESCRIPTOR);
|
|
71
68
|
else {
|
|
72
|
-
const _ = JSON.stringify(
|
|
73
|
-
c.setProperty(s,
|
|
69
|
+
const _ = JSON.stringify(O);
|
|
70
|
+
c.setProperty(s, g(l), _);
|
|
74
71
|
}
|
|
75
72
|
});
|
|
76
|
-
}, y = new o(
|
|
73
|
+
}, y = new o(m, P);
|
|
77
74
|
return y.run(), y.pseudoToNative(y.value);
|
|
78
75
|
};
|
|
79
76
|
export {
|
|
80
|
-
|
|
77
|
+
$ as runInEdge
|
|
81
78
|
};
|
|
@@ -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;
|