@builder.io/sdk-solid 0.7.0 → 0.7.1-0
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/dev.js +102 -58
- package/lib/browser/dev.jsx +104 -59
- package/lib/browser/index.js +101 -57
- package/lib/browser/index.jsx +103 -58
- package/lib/edge/dev.js +158 -74
- package/lib/edge/dev.jsx +160 -75
- package/lib/edge/index.js +157 -73
- package/lib/edge/index.jsx +159 -74
- package/lib/node/dev.js +555 -374
- package/lib/node/dev.jsx +556 -374
- package/lib/node/index.js +553 -373
- package/lib/node/index.jsx +554 -373
- package/package.json +2 -1
package/lib/browser/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, memo, Dynamic, use } from 'solid-js/web';
|
|
2
2
|
import { createContext, Show, useContext, For, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
import { css } from 'solid-styled-components';
|
|
4
4
|
|
|
@@ -185,6 +185,19 @@ var getFunctionArguments = ({
|
|
|
185
185
|
event
|
|
186
186
|
});
|
|
187
187
|
};
|
|
188
|
+
var getBuilderGlobals = () => ({
|
|
189
|
+
isEditing: isEditing(),
|
|
190
|
+
isBrowser: isBrowser(),
|
|
191
|
+
isServer: !isBrowser(),
|
|
192
|
+
getUserAttributes: () => getUserAttributes()
|
|
193
|
+
});
|
|
194
|
+
var parseCode = (code, {
|
|
195
|
+
isExpression = true
|
|
196
|
+
}) => {
|
|
197
|
+
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
198
|
+
const useCode = useReturn ? `return (${code});` : code;
|
|
199
|
+
return useCode;
|
|
200
|
+
};
|
|
188
201
|
|
|
189
202
|
// src/functions/evaluate/browser-runtime/browser.js
|
|
190
203
|
var runInBrowser = ({
|
|
@@ -226,6 +239,9 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
226
239
|
});
|
|
227
240
|
}
|
|
228
241
|
|
|
242
|
+
// src/functions/evaluate/choose-eval.js
|
|
243
|
+
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
|
|
244
|
+
|
|
229
245
|
// src/functions/evaluate/evaluate.js
|
|
230
246
|
function evaluate({
|
|
231
247
|
code,
|
|
@@ -240,17 +256,11 @@ function evaluate({
|
|
|
240
256
|
logger.warn("Skipping evaluation of empty code block.");
|
|
241
257
|
return;
|
|
242
258
|
}
|
|
243
|
-
const builder = {
|
|
244
|
-
isEditing: isEditing(),
|
|
245
|
-
isBrowser: isBrowser(),
|
|
246
|
-
isServer: !isBrowser(),
|
|
247
|
-
getUserAttributes: () => getUserAttributes()
|
|
248
|
-
};
|
|
249
|
-
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
250
|
-
const useCode = useReturn ? `return (${code});` : code;
|
|
251
259
|
const args = {
|
|
252
|
-
code:
|
|
253
|
-
|
|
260
|
+
code: parseCode(code, {
|
|
261
|
+
isExpression
|
|
262
|
+
}),
|
|
263
|
+
builder: getBuilderGlobals(),
|
|
254
264
|
context,
|
|
255
265
|
event,
|
|
256
266
|
rootSetState,
|
|
@@ -258,7 +268,7 @@ function evaluate({
|
|
|
258
268
|
localState
|
|
259
269
|
};
|
|
260
270
|
try {
|
|
261
|
-
return
|
|
271
|
+
return chooseBrowserOrServerEval(args);
|
|
262
272
|
} catch (e) {
|
|
263
273
|
logger.error("Failed code evaluation: " + e.message, {
|
|
264
274
|
code
|
|
@@ -2683,42 +2693,40 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
|
2683
2693
|
function CustomCode(props) {
|
|
2684
2694
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2685
2695
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2696
|
+
let elementRef;
|
|
2697
|
+
onMount(() => {
|
|
2698
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
2702
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2703
|
+
const script = scripts[i];
|
|
2704
|
+
if (script.src) {
|
|
2705
|
+
if (scriptsInserted().includes(script.src)) {
|
|
2706
|
+
continue;
|
|
2707
|
+
}
|
|
2708
|
+
scriptsInserted().push(script.src);
|
|
2709
|
+
const newScript = document.createElement("script");
|
|
2710
|
+
newScript.async = true;
|
|
2711
|
+
newScript.src = script.src;
|
|
2712
|
+
document.head.appendChild(newScript);
|
|
2713
|
+
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
2714
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
try {
|
|
2718
|
+
scriptsRun().push(script.innerText);
|
|
2719
|
+
new Function(script.innerText)();
|
|
2720
|
+
} catch (error) {
|
|
2721
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
2710
2722
|
}
|
|
2711
2723
|
}
|
|
2712
2724
|
}
|
|
2713
|
-
}
|
|
2714
|
-
let elem;
|
|
2715
|
-
onMount(() => {
|
|
2716
|
-
findAndRunScripts();
|
|
2717
2725
|
});
|
|
2718
2726
|
return (() => {
|
|
2719
2727
|
const _el$ = _tmpl$13();
|
|
2720
|
-
const _ref$ =
|
|
2721
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) :
|
|
2728
|
+
const _ref$ = elementRef;
|
|
2729
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
2722
2730
|
effect((_p$) => {
|
|
2723
2731
|
const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
|
|
2724
2732
|
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
@@ -3381,7 +3389,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
|
|
|
3381
3389
|
}));
|
|
3382
3390
|
|
|
3383
3391
|
// src/constants/sdk-version.js
|
|
3384
|
-
var SDK_VERSION = "0.7.0";
|
|
3392
|
+
var SDK_VERSION = "0.7.1-0";
|
|
3385
3393
|
|
|
3386
3394
|
// src/functions/register.js
|
|
3387
3395
|
var registry = {};
|
|
@@ -3835,6 +3843,7 @@ var __spreadValues15 = (a, b) => {
|
|
|
3835
3843
|
}
|
|
3836
3844
|
return a;
|
|
3837
3845
|
};
|
|
3846
|
+
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3838
3847
|
var generateContentUrl = (options) => {
|
|
3839
3848
|
let {
|
|
3840
3849
|
noTraverse = false
|
|
@@ -3848,7 +3857,14 @@ var generateContentUrl = (options) => {
|
|
|
3848
3857
|
includeRefs = true,
|
|
3849
3858
|
enrich,
|
|
3850
3859
|
locale,
|
|
3851
|
-
apiVersion = DEFAULT_API_VERSION
|
|
3860
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
3861
|
+
fields,
|
|
3862
|
+
omit,
|
|
3863
|
+
offset,
|
|
3864
|
+
cacheSeconds,
|
|
3865
|
+
staleCacheSeconds,
|
|
3866
|
+
sort,
|
|
3867
|
+
includeUnpublished
|
|
3852
3868
|
} = options;
|
|
3853
3869
|
if (!apiKey) {
|
|
3854
3870
|
throw new Error("Missing API key");
|
|
@@ -3860,6 +3876,30 @@ var generateContentUrl = (options) => {
|
|
|
3860
3876
|
noTraverse = true;
|
|
3861
3877
|
}
|
|
3862
3878
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
|
|
3879
|
+
url.searchParams.set("omit", omit || "meta.componentsUsed");
|
|
3880
|
+
if (fields) {
|
|
3881
|
+
url.searchParams.set("fields", fields);
|
|
3882
|
+
}
|
|
3883
|
+
if (Number.isFinite(offset) && offset > -1) {
|
|
3884
|
+
url.searchParams.set("offset", String(Math.floor(offset)));
|
|
3885
|
+
}
|
|
3886
|
+
if (typeof includeUnpublished === "boolean") {
|
|
3887
|
+
url.searchParams.set("includeUnpublished", String(includeUnpublished));
|
|
3888
|
+
}
|
|
3889
|
+
if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
|
|
3890
|
+
url.searchParams.set("cacheSeconds", String(cacheSeconds));
|
|
3891
|
+
}
|
|
3892
|
+
if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
|
|
3893
|
+
url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
|
|
3894
|
+
}
|
|
3895
|
+
if (sort) {
|
|
3896
|
+
const flattened2 = flatten({
|
|
3897
|
+
sort
|
|
3898
|
+
});
|
|
3899
|
+
for (const key in flattened2) {
|
|
3900
|
+
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3863
3903
|
const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
|
|
3864
3904
|
const flattened = flatten(queryOptions);
|
|
3865
3905
|
for (const key in flattened) {
|
|
@@ -4150,11 +4190,8 @@ function EnableEditor(props) {
|
|
|
4150
4190
|
}
|
|
4151
4191
|
let elementRef;
|
|
4152
4192
|
onMount(() => {
|
|
4153
|
-
if (!props.apiKey) {
|
|
4154
|
-
logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
4155
|
-
}
|
|
4156
4193
|
if (isBrowser()) {
|
|
4157
|
-
if (isEditing()) {
|
|
4194
|
+
if (isEditing() && true) {
|
|
4158
4195
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
4159
4196
|
window.addEventListener("message", processMessage);
|
|
4160
4197
|
registerInsertMenu();
|
|
@@ -4175,18 +4212,20 @@ function EnableEditor(props) {
|
|
|
4175
4212
|
});
|
|
4176
4213
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
4177
4214
|
}
|
|
4178
|
-
|
|
4215
|
+
const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
|
|
4216
|
+
if (shouldTrackImpression) {
|
|
4179
4217
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
4180
4218
|
const contentId = props.builderContextSignal.content?.id;
|
|
4219
|
+
const apiKeyProp = props.apiKey;
|
|
4181
4220
|
_track({
|
|
4182
4221
|
type: "impression",
|
|
4183
|
-
canTrack:
|
|
4222
|
+
canTrack: true,
|
|
4184
4223
|
contentId,
|
|
4185
|
-
apiKey:
|
|
4224
|
+
apiKey: apiKeyProp,
|
|
4186
4225
|
variationId: variationId !== contentId ? variationId : void 0
|
|
4187
4226
|
});
|
|
4188
4227
|
}
|
|
4189
|
-
if (isPreviewing()) {
|
|
4228
|
+
if (isPreviewing() && true) {
|
|
4190
4229
|
const searchParams = new URL(location.href).searchParams;
|
|
4191
4230
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
4192
4231
|
const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
|
|
@@ -4203,11 +4242,16 @@ function EnableEditor(props) {
|
|
|
4203
4242
|
});
|
|
4204
4243
|
}
|
|
4205
4244
|
}
|
|
4206
|
-
evaluateJsCode();
|
|
4207
|
-
runHttpRequests();
|
|
4208
|
-
emitStateUpdate();
|
|
4209
4245
|
}
|
|
4210
4246
|
});
|
|
4247
|
+
onMount(() => {
|
|
4248
|
+
if (!props.apiKey) {
|
|
4249
|
+
logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
4250
|
+
}
|
|
4251
|
+
evaluateJsCode();
|
|
4252
|
+
runHttpRequests();
|
|
4253
|
+
emitStateUpdate();
|
|
4254
|
+
});
|
|
4211
4255
|
function onUpdateFn_0() {
|
|
4212
4256
|
if (props.content) {
|
|
4213
4257
|
mergeNewContent(props.content);
|
|
@@ -4240,16 +4284,17 @@ function EnableEditor(props) {
|
|
|
4240
4284
|
},
|
|
4241
4285
|
get children() {
|
|
4242
4286
|
const _el$ = _tmpl$14();
|
|
4243
|
-
_el$.$$click = (event) => onClick(event);
|
|
4244
4287
|
const _ref$ = elementRef;
|
|
4245
4288
|
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
4246
4289
|
spread(_el$, mergeProps({
|
|
4247
4290
|
get ["class"]() {
|
|
4248
4291
|
return props.classNameProp;
|
|
4249
|
-
}
|
|
4292
|
+
}
|
|
4293
|
+
}, {}, {
|
|
4250
4294
|
get key() {
|
|
4251
4295
|
return forceReRenderCount();
|
|
4252
4296
|
},
|
|
4297
|
+
"onClick": (event) => onClick(event),
|
|
4253
4298
|
get ["builder-content-id"]() {
|
|
4254
4299
|
return props.builderContextSignal.content?.id;
|
|
4255
4300
|
},
|
|
@@ -4268,7 +4313,6 @@ function EnableEditor(props) {
|
|
|
4268
4313
|
});
|
|
4269
4314
|
}
|
|
4270
4315
|
var enable_editor_default = EnableEditor;
|
|
4271
|
-
delegateEvents(["click"]);
|
|
4272
4316
|
var _tmpl$15 = /* @__PURE__ */ template(`<script>`);
|
|
4273
4317
|
function InlinedScript(props) {
|
|
4274
4318
|
return (() => {
|
package/lib/browser/dev.jsx
CHANGED
|
@@ -172,6 +172,19 @@ var getFunctionArguments = ({
|
|
|
172
172
|
event
|
|
173
173
|
});
|
|
174
174
|
};
|
|
175
|
+
var getBuilderGlobals = () => ({
|
|
176
|
+
isEditing: isEditing(),
|
|
177
|
+
isBrowser: isBrowser(),
|
|
178
|
+
isServer: !isBrowser(),
|
|
179
|
+
getUserAttributes: () => getUserAttributes()
|
|
180
|
+
});
|
|
181
|
+
var parseCode = (code, {
|
|
182
|
+
isExpression = true
|
|
183
|
+
}) => {
|
|
184
|
+
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
185
|
+
const useCode = useReturn ? `return (${code});` : code;
|
|
186
|
+
return useCode;
|
|
187
|
+
};
|
|
175
188
|
|
|
176
189
|
// src/functions/evaluate/browser-runtime/browser.js
|
|
177
190
|
var runInBrowser = ({
|
|
@@ -213,6 +226,9 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
213
226
|
});
|
|
214
227
|
}
|
|
215
228
|
|
|
229
|
+
// src/functions/evaluate/choose-eval.js
|
|
230
|
+
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
|
|
231
|
+
|
|
216
232
|
// src/functions/evaluate/evaluate.js
|
|
217
233
|
function evaluate({
|
|
218
234
|
code,
|
|
@@ -227,17 +243,11 @@ function evaluate({
|
|
|
227
243
|
logger.warn("Skipping evaluation of empty code block.");
|
|
228
244
|
return;
|
|
229
245
|
}
|
|
230
|
-
const builder = {
|
|
231
|
-
isEditing: isEditing(),
|
|
232
|
-
isBrowser: isBrowser(),
|
|
233
|
-
isServer: !isBrowser(),
|
|
234
|
-
getUserAttributes: () => getUserAttributes()
|
|
235
|
-
};
|
|
236
|
-
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
237
|
-
const useCode = useReturn ? `return (${code});` : code;
|
|
238
246
|
const args = {
|
|
239
|
-
code:
|
|
240
|
-
|
|
247
|
+
code: parseCode(code, {
|
|
248
|
+
isExpression
|
|
249
|
+
}),
|
|
250
|
+
builder: getBuilderGlobals(),
|
|
241
251
|
context,
|
|
242
252
|
event,
|
|
243
253
|
rootSetState,
|
|
@@ -245,7 +255,7 @@ function evaluate({
|
|
|
245
255
|
localState
|
|
246
256
|
};
|
|
247
257
|
try {
|
|
248
|
-
return
|
|
258
|
+
return chooseBrowserOrServerEval(args);
|
|
249
259
|
} catch (e) {
|
|
250
260
|
logger.error("Failed code evaluation: " + e.message, {
|
|
251
261
|
code
|
|
@@ -2412,45 +2422,43 @@ import { onMount, createSignal as createSignal10 } from "solid-js";
|
|
|
2412
2422
|
function CustomCode(props) {
|
|
2413
2423
|
const [scriptsInserted, setScriptsInserted] = createSignal10([]);
|
|
2414
2424
|
const [scriptsRun, setScriptsRun] = createSignal10([]);
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2425
|
+
let elementRef;
|
|
2426
|
+
onMount(() => {
|
|
2427
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
2431
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2432
|
+
const script = scripts[i];
|
|
2433
|
+
if (script.src) {
|
|
2434
|
+
if (scriptsInserted().includes(script.src)) {
|
|
2435
|
+
continue;
|
|
2436
|
+
}
|
|
2437
|
+
scriptsInserted().push(script.src);
|
|
2438
|
+
const newScript = document.createElement("script");
|
|
2439
|
+
newScript.async = true;
|
|
2440
|
+
newScript.src = script.src;
|
|
2441
|
+
document.head.appendChild(newScript);
|
|
2442
|
+
} else if (!script.type || [
|
|
2443
|
+
"text/javascript",
|
|
2444
|
+
"application/javascript",
|
|
2445
|
+
"application/ecmascript"
|
|
2446
|
+
].includes(script.type)) {
|
|
2447
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
2448
|
+
continue;
|
|
2449
|
+
}
|
|
2450
|
+
try {
|
|
2451
|
+
scriptsRun().push(script.innerText);
|
|
2452
|
+
new Function(script.innerText)();
|
|
2453
|
+
} catch (error) {
|
|
2454
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
2443
2455
|
}
|
|
2444
2456
|
}
|
|
2445
2457
|
}
|
|
2446
|
-
}
|
|
2447
|
-
let elem;
|
|
2448
|
-
onMount(() => {
|
|
2449
|
-
findAndRunScripts();
|
|
2450
2458
|
});
|
|
2451
2459
|
return <div
|
|
2452
2460
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
2453
|
-
ref={
|
|
2461
|
+
ref={elementRef}
|
|
2454
2462
|
innerHTML={props.code}
|
|
2455
2463
|
/>;
|
|
2456
2464
|
}
|
|
@@ -3108,7 +3116,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
|
|
|
3108
3116
|
}));
|
|
3109
3117
|
|
|
3110
3118
|
// src/constants/sdk-version.js
|
|
3111
|
-
var SDK_VERSION = "0.7.0";
|
|
3119
|
+
var SDK_VERSION = "0.7.1-0";
|
|
3112
3120
|
|
|
3113
3121
|
// src/functions/register.js
|
|
3114
3122
|
var registry = {};
|
|
@@ -3562,6 +3570,7 @@ var __spreadValues15 = (a, b) => {
|
|
|
3562
3570
|
}
|
|
3563
3571
|
return a;
|
|
3564
3572
|
};
|
|
3573
|
+
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3565
3574
|
var generateContentUrl = (options) => {
|
|
3566
3575
|
let {
|
|
3567
3576
|
noTraverse = false
|
|
@@ -3575,7 +3584,14 @@ var generateContentUrl = (options) => {
|
|
|
3575
3584
|
includeRefs = true,
|
|
3576
3585
|
enrich,
|
|
3577
3586
|
locale,
|
|
3578
|
-
apiVersion = DEFAULT_API_VERSION
|
|
3587
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
3588
|
+
fields,
|
|
3589
|
+
omit,
|
|
3590
|
+
offset,
|
|
3591
|
+
cacheSeconds,
|
|
3592
|
+
staleCacheSeconds,
|
|
3593
|
+
sort,
|
|
3594
|
+
includeUnpublished
|
|
3579
3595
|
} = options;
|
|
3580
3596
|
if (!apiKey) {
|
|
3581
3597
|
throw new Error("Missing API key");
|
|
@@ -3587,6 +3603,30 @@ var generateContentUrl = (options) => {
|
|
|
3587
3603
|
noTraverse = true;
|
|
3588
3604
|
}
|
|
3589
3605
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
|
|
3606
|
+
url.searchParams.set("omit", omit || "meta.componentsUsed");
|
|
3607
|
+
if (fields) {
|
|
3608
|
+
url.searchParams.set("fields", fields);
|
|
3609
|
+
}
|
|
3610
|
+
if (Number.isFinite(offset) && offset > -1) {
|
|
3611
|
+
url.searchParams.set("offset", String(Math.floor(offset)));
|
|
3612
|
+
}
|
|
3613
|
+
if (typeof includeUnpublished === "boolean") {
|
|
3614
|
+
url.searchParams.set("includeUnpublished", String(includeUnpublished));
|
|
3615
|
+
}
|
|
3616
|
+
if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
|
|
3617
|
+
url.searchParams.set("cacheSeconds", String(cacheSeconds));
|
|
3618
|
+
}
|
|
3619
|
+
if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
|
|
3620
|
+
url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
|
|
3621
|
+
}
|
|
3622
|
+
if (sort) {
|
|
3623
|
+
const flattened2 = flatten({
|
|
3624
|
+
sort
|
|
3625
|
+
});
|
|
3626
|
+
for (const key in flattened2) {
|
|
3627
|
+
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3590
3630
|
const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
|
|
3591
3631
|
const flattened = flatten(queryOptions);
|
|
3592
3632
|
for (const key in flattened) {
|
|
@@ -3873,13 +3913,8 @@ function EnableEditor(props) {
|
|
|
3873
3913
|
}
|
|
3874
3914
|
let elementRef;
|
|
3875
3915
|
onMount2(() => {
|
|
3876
|
-
if (!props.apiKey) {
|
|
3877
|
-
logger.error(
|
|
3878
|
-
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
3879
|
-
);
|
|
3880
|
-
}
|
|
3881
3916
|
if (isBrowser()) {
|
|
3882
|
-
if (isEditing()) {
|
|
3917
|
+
if (isEditing() && true) {
|
|
3883
3918
|
setForceReRenderCount(forceReRenderCount() + 1);
|
|
3884
3919
|
window.addEventListener("message", processMessage);
|
|
3885
3920
|
registerInsertMenu();
|
|
@@ -3905,18 +3940,20 @@ function EnableEditor(props) {
|
|
|
3905
3940
|
emitStateUpdate
|
|
3906
3941
|
);
|
|
3907
3942
|
}
|
|
3908
|
-
|
|
3943
|
+
const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
|
|
3944
|
+
if (shouldTrackImpression) {
|
|
3909
3945
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
3910
3946
|
const contentId = props.builderContextSignal.content?.id;
|
|
3947
|
+
const apiKeyProp = props.apiKey;
|
|
3911
3948
|
_track({
|
|
3912
3949
|
type: "impression",
|
|
3913
|
-
canTrack:
|
|
3950
|
+
canTrack: true,
|
|
3914
3951
|
contentId,
|
|
3915
|
-
apiKey:
|
|
3952
|
+
apiKey: apiKeyProp,
|
|
3916
3953
|
variationId: variationId !== contentId ? variationId : void 0
|
|
3917
3954
|
});
|
|
3918
3955
|
}
|
|
3919
|
-
if (isPreviewing()) {
|
|
3956
|
+
if (isPreviewing() && true) {
|
|
3920
3957
|
const searchParams = new URL(location.href).searchParams;
|
|
3921
3958
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
3922
3959
|
const searchParamPreviewId = searchParams.get(
|
|
@@ -3935,11 +3972,18 @@ function EnableEditor(props) {
|
|
|
3935
3972
|
});
|
|
3936
3973
|
}
|
|
3937
3974
|
}
|
|
3938
|
-
evaluateJsCode();
|
|
3939
|
-
runHttpRequests();
|
|
3940
|
-
emitStateUpdate();
|
|
3941
3975
|
}
|
|
3942
3976
|
});
|
|
3977
|
+
onMount2(() => {
|
|
3978
|
+
if (!props.apiKey) {
|
|
3979
|
+
logger.error(
|
|
3980
|
+
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
3981
|
+
);
|
|
3982
|
+
}
|
|
3983
|
+
evaluateJsCode();
|
|
3984
|
+
runHttpRequests();
|
|
3985
|
+
emitStateUpdate();
|
|
3986
|
+
});
|
|
3943
3987
|
function onUpdateFn_0() {
|
|
3944
3988
|
if (props.content) {
|
|
3945
3989
|
mergeNewContent(props.content);
|
|
@@ -3976,6 +4020,7 @@ function EnableEditor(props) {
|
|
|
3976
4020
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
3977
4021
|
return <stdin_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
|
|
3978
4022
|
class={props.classNameProp}
|
|
4023
|
+
{...{}}
|
|
3979
4024
|
key={forceReRenderCount()}
|
|
3980
4025
|
ref={elementRef}
|
|
3981
4026
|
onClick={(event) => onClick(event)}
|