@builder.io/sdk-solid 2.0.16 → 2.0.21
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/dist/index.d.ts +6 -1
- package/lib/browser/dev.js +109 -84
- package/lib/browser/dev.jsx +167 -169
- package/lib/browser/index.js +109 -84
- package/lib/browser/index.jsx +167 -169
- package/lib/edge/dev.js +180 -118
- package/lib/edge/dev.jsx +238 -203
- package/lib/edge/index.js +180 -118
- package/lib/edge/index.jsx +238 -203
- package/lib/node/dev.js +110 -85
- package/lib/node/dev.jsx +168 -170
- package/lib/node/index.js +110 -85
- package/lib/node/index.jsx +168 -170
- package/package.json +1 -1
package/lib/edge/index.js
CHANGED
|
@@ -261,29 +261,6 @@ var parseCode = (code, {
|
|
|
261
261
|
const useCode = useReturn ? `return (${code});` : code;
|
|
262
262
|
return useCode;
|
|
263
263
|
};
|
|
264
|
-
|
|
265
|
-
// src/functions/evaluate/browser-runtime/browser.ts
|
|
266
|
-
var runInBrowser = ({
|
|
267
|
-
code,
|
|
268
|
-
builder,
|
|
269
|
-
context,
|
|
270
|
-
event,
|
|
271
|
-
localState,
|
|
272
|
-
rootSetState,
|
|
273
|
-
rootState
|
|
274
|
-
}) => {
|
|
275
|
-
const functionArgs = getFunctionArguments({
|
|
276
|
-
builder,
|
|
277
|
-
context,
|
|
278
|
-
event,
|
|
279
|
-
state: flattenState({
|
|
280
|
-
rootState,
|
|
281
|
-
localState,
|
|
282
|
-
rootSetState
|
|
283
|
-
})
|
|
284
|
-
});
|
|
285
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
286
|
-
};
|
|
287
264
|
function flattenState({
|
|
288
265
|
rootState,
|
|
289
266
|
localState,
|
|
@@ -318,14 +295,27 @@ function flattenState({
|
|
|
318
295
|
});
|
|
319
296
|
}
|
|
320
297
|
|
|
321
|
-
// src/functions/
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
298
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
299
|
+
var runInBrowser = ({
|
|
300
|
+
code,
|
|
301
|
+
builder,
|
|
302
|
+
context,
|
|
303
|
+
event,
|
|
304
|
+
localState,
|
|
305
|
+
rootSetState,
|
|
306
|
+
rootState
|
|
307
|
+
}) => {
|
|
308
|
+
const functionArgs = getFunctionArguments({
|
|
309
|
+
builder,
|
|
310
|
+
context,
|
|
311
|
+
event,
|
|
312
|
+
state: flattenState({
|
|
313
|
+
rootState,
|
|
314
|
+
localState,
|
|
315
|
+
rootSetState
|
|
316
|
+
})
|
|
317
|
+
});
|
|
318
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
329
319
|
};
|
|
330
320
|
|
|
331
321
|
// src/functions/evaluate/edge-runtime/acorn-interpreter.ts
|
|
@@ -3397,22 +3387,56 @@ t.VALUE_IN_DESCRIPTOR = Ia;
|
|
|
3397
3387
|
var acorn_interpreter_default = t;
|
|
3398
3388
|
|
|
3399
3389
|
// src/functions/evaluate/edge-runtime/edge-runtime.ts
|
|
3390
|
+
function patchInterpreter() {
|
|
3391
|
+
const originalGetProperty = acorn_interpreter_default.prototype.getProperty;
|
|
3392
|
+
const originalSetProperty = acorn_interpreter_default.prototype.setProperty;
|
|
3393
|
+
function newGetProperty(obj, name) {
|
|
3394
|
+
if (obj == null || !obj._connected) {
|
|
3395
|
+
return originalGetProperty.call(this, obj, name);
|
|
3396
|
+
}
|
|
3397
|
+
const value = obj._connected[name];
|
|
3398
|
+
if (Array.isArray(value)) {
|
|
3399
|
+
return this.nativeToPseudo(value);
|
|
3400
|
+
}
|
|
3401
|
+
if (typeof value === "object") {
|
|
3402
|
+
return this.createConnectedObject(value);
|
|
3403
|
+
}
|
|
3404
|
+
return value;
|
|
3405
|
+
}
|
|
3406
|
+
function newSetProperty(obj, name, value, opt_descriptor) {
|
|
3407
|
+
if (obj == null || !obj._connected) {
|
|
3408
|
+
return originalSetProperty.call(this, obj, name, value, opt_descriptor);
|
|
3409
|
+
}
|
|
3410
|
+
obj._connected[name] = this.pseudoToNative(value);
|
|
3411
|
+
}
|
|
3412
|
+
const getKeys = [];
|
|
3413
|
+
const setKeys = [];
|
|
3414
|
+
for (const key of Object.keys(acorn_interpreter_default.prototype)) {
|
|
3415
|
+
if (acorn_interpreter_default.prototype[key] === originalGetProperty) {
|
|
3416
|
+
getKeys.push(key);
|
|
3417
|
+
}
|
|
3418
|
+
if (acorn_interpreter_default.prototype[key] === originalSetProperty) {
|
|
3419
|
+
setKeys.push(key);
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
for (const key of getKeys) {
|
|
3423
|
+
acorn_interpreter_default.prototype[key] = newGetProperty;
|
|
3424
|
+
}
|
|
3425
|
+
for (const key of setKeys) {
|
|
3426
|
+
acorn_interpreter_default.prototype[key] = newSetProperty;
|
|
3427
|
+
}
|
|
3428
|
+
acorn_interpreter_default.prototype.createConnectedObject = function(obj) {
|
|
3429
|
+
const connectedObject = this.createObject(this.OBJECT);
|
|
3430
|
+
connectedObject._connected = obj;
|
|
3431
|
+
return connectedObject;
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3434
|
+
patchInterpreter();
|
|
3400
3435
|
var processCode = (code) => {
|
|
3401
|
-
return code.
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
const isStateSetter = trimmed.startsWith("state.");
|
|
3406
|
-
if (!isStateSetter)
|
|
3407
|
-
return line;
|
|
3408
|
-
const [lhs, rhs] = trimmed.split("=");
|
|
3409
|
-
const setStr = lhs.replace("state.", "").trim();
|
|
3410
|
-
const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
|
|
3411
|
-
return `
|
|
3412
|
-
${line}
|
|
3413
|
-
${setExpr}
|
|
3414
|
-
`;
|
|
3415
|
-
}).filter(Boolean).join("\n");
|
|
3436
|
+
return code.replace(/^.*?function main\(\)/, `
|
|
3437
|
+
var __awaiter = function (e, t, n, r) {return r()},
|
|
3438
|
+
__generator = function (e, t) { return t() };
|
|
3439
|
+
function main()`).replace(/\?\./g, ".");
|
|
3416
3440
|
};
|
|
3417
3441
|
var getJSONValName = (val) => val + "JSON";
|
|
3418
3442
|
var runInEdge = ({
|
|
@@ -3424,10 +3448,11 @@ var runInEdge = ({
|
|
|
3424
3448
|
rootSetState,
|
|
3425
3449
|
code
|
|
3426
3450
|
}) => {
|
|
3427
|
-
const state = {
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3451
|
+
const state = flattenState({
|
|
3452
|
+
rootState,
|
|
3453
|
+
localState,
|
|
3454
|
+
rootSetState
|
|
3455
|
+
});
|
|
3431
3456
|
const properties = getFunctionArguments({
|
|
3432
3457
|
builder,
|
|
3433
3458
|
context,
|
|
@@ -3436,6 +3461,9 @@ var runInEdge = ({
|
|
|
3436
3461
|
});
|
|
3437
3462
|
const prependedCode = properties.map(([key]) => {
|
|
3438
3463
|
const jsonValName = getJSONValName(key);
|
|
3464
|
+
if (key === "state") {
|
|
3465
|
+
return ``;
|
|
3466
|
+
}
|
|
3439
3467
|
return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
|
|
3440
3468
|
}).join("\n");
|
|
3441
3469
|
const cleanedCode = processCode(code);
|
|
@@ -3451,16 +3479,15 @@ function theFunction() {
|
|
|
3451
3479
|
}
|
|
3452
3480
|
theFunction();
|
|
3453
3481
|
`;
|
|
3454
|
-
const setRootState = (prop, value) => {
|
|
3455
|
-
const newState = set(state, prop, value);
|
|
3456
|
-
rootSetState?.(newState);
|
|
3457
|
-
};
|
|
3458
3482
|
const initFunc = function(interpreter, globalObject) {
|
|
3459
3483
|
properties.forEach(([key, val]) => {
|
|
3460
|
-
|
|
3461
|
-
|
|
3484
|
+
if (key === "state") {
|
|
3485
|
+
interpreter.setProperty(globalObject, key, interpreter.createConnectedObject(val), interpreter.READONLY_DESCRIPTOR);
|
|
3486
|
+
} else {
|
|
3487
|
+
const jsonVal = JSON.stringify(val);
|
|
3488
|
+
interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
|
|
3489
|
+
}
|
|
3462
3490
|
});
|
|
3463
|
-
interpreter.setProperty(globalObject, "setRootState", interpreter.createNativeFunction(setRootState));
|
|
3464
3491
|
};
|
|
3465
3492
|
const myInterpreter = new acorn_interpreter_default(transformed, initFunc);
|
|
3466
3493
|
myInterpreter.run();
|
|
@@ -3577,6 +3604,16 @@ function evaluate({
|
|
|
3577
3604
|
// src/functions/fast-clone.ts
|
|
3578
3605
|
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
3579
3606
|
|
|
3607
|
+
// src/functions/set.ts
|
|
3608
|
+
var set = (obj, _path, value) => {
|
|
3609
|
+
if (Object(obj) !== obj) {
|
|
3610
|
+
return obj;
|
|
3611
|
+
}
|
|
3612
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
3613
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
3614
|
+
return obj;
|
|
3615
|
+
};
|
|
3616
|
+
|
|
3580
3617
|
// src/functions/transform-block.ts
|
|
3581
3618
|
function transformBlock(block) {
|
|
3582
3619
|
return block;
|
|
@@ -4248,6 +4285,14 @@ function BlockWrapper(props) {
|
|
|
4248
4285
|
});
|
|
4249
4286
|
}
|
|
4250
4287
|
var block_wrapper_default = BlockWrapper;
|
|
4288
|
+
function Awaiter(props) {
|
|
4289
|
+
onMount(() => {
|
|
4290
|
+
});
|
|
4291
|
+
return memo(() => props.children);
|
|
4292
|
+
}
|
|
4293
|
+
var awaiter_default = Awaiter;
|
|
4294
|
+
|
|
4295
|
+
// src/components/block/components/interactive-element.tsx
|
|
4251
4296
|
function InteractiveElement(props) {
|
|
4252
4297
|
const attributes = createMemo(() => {
|
|
4253
4298
|
return props.includeBlockProps ? {
|
|
@@ -4264,17 +4309,43 @@ function InteractiveElement(props) {
|
|
|
4264
4309
|
})
|
|
4265
4310
|
} : {};
|
|
4266
4311
|
});
|
|
4267
|
-
return createComponent(
|
|
4268
|
-
get
|
|
4269
|
-
return
|
|
4312
|
+
return createComponent(Show, {
|
|
4313
|
+
get fallback() {
|
|
4314
|
+
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
4315
|
+
get attributes() {
|
|
4316
|
+
return attributes();
|
|
4317
|
+
},
|
|
4318
|
+
get component() {
|
|
4319
|
+
return props.Wrapper;
|
|
4320
|
+
},
|
|
4321
|
+
get children() {
|
|
4322
|
+
return props.children;
|
|
4323
|
+
}
|
|
4324
|
+
}));
|
|
4270
4325
|
},
|
|
4271
|
-
get
|
|
4272
|
-
return props.Wrapper;
|
|
4326
|
+
get when() {
|
|
4327
|
+
return props.Wrapper.load;
|
|
4273
4328
|
},
|
|
4274
4329
|
get children() {
|
|
4275
|
-
return
|
|
4330
|
+
return createComponent(awaiter_default, {
|
|
4331
|
+
get load() {
|
|
4332
|
+
return props.Wrapper.load;
|
|
4333
|
+
},
|
|
4334
|
+
get fallback() {
|
|
4335
|
+
return props.Wrapper.fallback;
|
|
4336
|
+
},
|
|
4337
|
+
get props() {
|
|
4338
|
+
return props.wrapperProps;
|
|
4339
|
+
},
|
|
4340
|
+
get attributes() {
|
|
4341
|
+
return attributes();
|
|
4342
|
+
},
|
|
4343
|
+
get children() {
|
|
4344
|
+
return props.children;
|
|
4345
|
+
}
|
|
4346
|
+
});
|
|
4276
4347
|
}
|
|
4277
|
-
})
|
|
4348
|
+
});
|
|
4278
4349
|
}
|
|
4279
4350
|
var interactive_element_default = InteractiveElement;
|
|
4280
4351
|
|
|
@@ -4649,7 +4720,7 @@ function Block(props) {
|
|
|
4649
4720
|
});
|
|
4650
4721
|
}
|
|
4651
4722
|
var block_default = Block;
|
|
4652
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4723
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
|
|
4653
4724
|
display: flex;
|
|
4654
4725
|
flex-direction: column;
|
|
4655
4726
|
align-items: stretch;
|
|
@@ -4685,7 +4756,7 @@ function BlocksWrapper(props) {
|
|
|
4685
4756
|
});
|
|
4686
4757
|
return [createComponent(Dynamic, mergeProps({
|
|
4687
4758
|
get ["class"]() {
|
|
4688
|
-
return className() + " dynamic-
|
|
4759
|
+
return className() + " dynamic-68b2d7fe";
|
|
4689
4760
|
},
|
|
4690
4761
|
ref(r$) {
|
|
4691
4762
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4781,7 +4852,7 @@ var getColumnsClass = (id2) => {
|
|
|
4781
4852
|
|
|
4782
4853
|
// src/blocks/columns/columns.tsx
|
|
4783
4854
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
4784
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
4855
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
|
|
4785
4856
|
display: flex;
|
|
4786
4857
|
line-height: normal;
|
|
4787
4858
|
}`);
|
|
@@ -4902,7 +4973,7 @@ function Columns(props) {
|
|
|
4902
4973
|
const _el$ = _tmpl$3();
|
|
4903
4974
|
spread(_el$, mergeProps({
|
|
4904
4975
|
get ["class"]() {
|
|
4905
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
4976
|
+
return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
|
|
4906
4977
|
},
|
|
4907
4978
|
get style() {
|
|
4908
4979
|
return columnsCssVars();
|
|
@@ -5027,16 +5098,16 @@ function getSrcSet(url) {
|
|
|
5027
5098
|
// src/blocks/image/image.tsx
|
|
5028
5099
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
5029
5100
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
5030
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
5031
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
5032
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
5101
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
|
|
5102
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
|
|
5103
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
|
|
5033
5104
|
opacity: 1;
|
|
5034
5105
|
transition: opacity 0.2s ease-in-out;
|
|
5035
|
-
}.div-
|
|
5106
|
+
}.div-7e6ffddc {
|
|
5036
5107
|
width: 100%;
|
|
5037
5108
|
pointer-events: none;
|
|
5038
5109
|
font-size: 0;
|
|
5039
|
-
}.div-
|
|
5110
|
+
}.div-7e6ffddc-2 {
|
|
5040
5111
|
display: flex;
|
|
5041
5112
|
flex-direction: column;
|
|
5042
5113
|
align-items: stretch;
|
|
@@ -5100,7 +5171,7 @@ function Image(props) {
|
|
|
5100
5171
|
}
|
|
5101
5172
|
}), _el$3);
|
|
5102
5173
|
effect((_p$) => {
|
|
5103
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
5174
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-7e6ffddc", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.altText ? void 0 : "presentation", _v$6 = {
|
|
5104
5175
|
"object-position": props.backgroundPosition || "center",
|
|
5105
5176
|
"object-fit": props.backgroundSize || "cover",
|
|
5106
5177
|
...aspectRatioCss()
|
|
@@ -8382,7 +8453,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
8382
8453
|
}
|
|
8383
8454
|
|
|
8384
8455
|
// src/constants/sdk-version.ts
|
|
8385
|
-
var SDK_VERSION = "2.0.
|
|
8456
|
+
var SDK_VERSION = "2.0.21";
|
|
8386
8457
|
|
|
8387
8458
|
// src/functions/register.ts
|
|
8388
8459
|
var registry = {};
|
|
@@ -8735,22 +8806,6 @@ function EnableEditor(props) {
|
|
|
8735
8806
|
}
|
|
8736
8807
|
})(event);
|
|
8737
8808
|
}
|
|
8738
|
-
function evaluateJsCode() {
|
|
8739
|
-
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
8740
|
-
if (jsCode) {
|
|
8741
|
-
evaluate({
|
|
8742
|
-
code: jsCode,
|
|
8743
|
-
context: props.context || {},
|
|
8744
|
-
localState: void 0,
|
|
8745
|
-
rootState: props.builderContextSignal.rootState,
|
|
8746
|
-
rootSetState: props.builderContextSignal.rootSetState,
|
|
8747
|
-
/**
|
|
8748
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
8749
|
-
*/
|
|
8750
|
-
enableCache: false
|
|
8751
|
-
});
|
|
8752
|
-
}
|
|
8753
|
-
}
|
|
8754
8809
|
function onClick(event) {
|
|
8755
8810
|
if (props.builderContextSignal.content) {
|
|
8756
8811
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
@@ -8787,7 +8842,7 @@ function EnableEditor(props) {
|
|
|
8787
8842
|
rootSetState: props.builderContextSignal.rootSetState,
|
|
8788
8843
|
enableCache: true
|
|
8789
8844
|
})));
|
|
8790
|
-
|
|
8845
|
+
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
8791
8846
|
mergeNewRootState({
|
|
8792
8847
|
[key]: json
|
|
8793
8848
|
});
|
|
@@ -8811,6 +8866,8 @@ function EnableEditor(props) {
|
|
|
8811
8866
|
}
|
|
8812
8867
|
}
|
|
8813
8868
|
let elementRef;
|
|
8869
|
+
runHttpRequests();
|
|
8870
|
+
emitStateUpdate();
|
|
8814
8871
|
onMount(() => {
|
|
8815
8872
|
if (isBrowser()) {
|
|
8816
8873
|
if (isEditing()) {
|
|
@@ -8865,14 +8922,6 @@ function EnableEditor(props) {
|
|
|
8865
8922
|
}
|
|
8866
8923
|
}
|
|
8867
8924
|
});
|
|
8868
|
-
onMount(() => {
|
|
8869
|
-
if (!props.apiKey) {
|
|
8870
|
-
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
8871
|
-
}
|
|
8872
|
-
evaluateJsCode();
|
|
8873
|
-
runHttpRequests();
|
|
8874
|
-
emitStateUpdate();
|
|
8875
|
-
});
|
|
8876
8925
|
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
8877
8926
|
function onUpdateFn_0() {
|
|
8878
8927
|
if (props.content) {
|
|
@@ -8880,37 +8929,27 @@ function EnableEditor(props) {
|
|
|
8880
8929
|
}
|
|
8881
8930
|
}
|
|
8882
8931
|
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
8883
|
-
const
|
|
8932
|
+
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
8884
8933
|
function onUpdateFn_1() {
|
|
8885
|
-
evaluateJsCode();
|
|
8886
|
-
}
|
|
8887
|
-
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
|
|
8888
|
-
const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
8889
|
-
function onUpdateFn_2() {
|
|
8890
|
-
runHttpRequests();
|
|
8891
|
-
}
|
|
8892
|
-
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
|
|
8893
|
-
const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
8894
|
-
function onUpdateFn_3() {
|
|
8895
8934
|
emitStateUpdate();
|
|
8896
8935
|
}
|
|
8897
|
-
createEffect(on(() => [
|
|
8898
|
-
const
|
|
8899
|
-
function
|
|
8936
|
+
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
|
|
8937
|
+
const onUpdateFn_2_props_data = createMemo(() => props.data);
|
|
8938
|
+
function onUpdateFn_2() {
|
|
8900
8939
|
if (props.data) {
|
|
8901
8940
|
mergeNewRootState(props.data);
|
|
8902
8941
|
}
|
|
8903
8942
|
}
|
|
8904
|
-
createEffect(on(() => [
|
|
8905
|
-
const
|
|
8906
|
-
function
|
|
8943
|
+
createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
8944
|
+
const onUpdateFn_3_props_locale = createMemo(() => props.locale);
|
|
8945
|
+
function onUpdateFn_3() {
|
|
8907
8946
|
if (props.locale) {
|
|
8908
8947
|
mergeNewRootState({
|
|
8909
8948
|
locale: props.locale
|
|
8910
8949
|
});
|
|
8911
8950
|
}
|
|
8912
8951
|
}
|
|
8913
|
-
createEffect(on(() => [
|
|
8952
|
+
createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
8914
8953
|
return createComponent(builder_context_default.Provider, {
|
|
8915
8954
|
get value() {
|
|
8916
8955
|
return props.builderContextSignal;
|
|
@@ -9078,6 +9117,29 @@ function ContentComponent(props) {
|
|
|
9078
9117
|
rootState: newRootState
|
|
9079
9118
|
}));
|
|
9080
9119
|
}
|
|
9120
|
+
if (!props.apiKey) {
|
|
9121
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
9122
|
+
}
|
|
9123
|
+
const jsCode = builderContextSignal().content?.data?.jsCode;
|
|
9124
|
+
if (jsCode) {
|
|
9125
|
+
evaluate({
|
|
9126
|
+
code: jsCode,
|
|
9127
|
+
context: props.context || {},
|
|
9128
|
+
localState: void 0,
|
|
9129
|
+
rootState: builderContextSignal().rootState,
|
|
9130
|
+
rootSetState: (newState) => {
|
|
9131
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
9132
|
+
...PREVIOUS_VALUE,
|
|
9133
|
+
rootState: newState
|
|
9134
|
+
}));
|
|
9135
|
+
},
|
|
9136
|
+
isExpression: false,
|
|
9137
|
+
/**
|
|
9138
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
9139
|
+
*/
|
|
9140
|
+
enableCache: false
|
|
9141
|
+
});
|
|
9142
|
+
}
|
|
9081
9143
|
return createComponent(components_context_default.Provider, {
|
|
9082
9144
|
get value() {
|
|
9083
9145
|
return {
|