@builder.io/sdk-solid 2.0.16 → 2.0.22
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 +7 -2
- 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/dev.js
CHANGED
|
@@ -263,29 +263,6 @@ var parseCode = (code, {
|
|
|
263
263
|
const useCode = useReturn ? `return (${code});` : code;
|
|
264
264
|
return useCode;
|
|
265
265
|
};
|
|
266
|
-
|
|
267
|
-
// src/functions/evaluate/browser-runtime/browser.ts
|
|
268
|
-
var runInBrowser = ({
|
|
269
|
-
code,
|
|
270
|
-
builder,
|
|
271
|
-
context,
|
|
272
|
-
event,
|
|
273
|
-
localState,
|
|
274
|
-
rootSetState,
|
|
275
|
-
rootState
|
|
276
|
-
}) => {
|
|
277
|
-
const functionArgs = getFunctionArguments({
|
|
278
|
-
builder,
|
|
279
|
-
context,
|
|
280
|
-
event,
|
|
281
|
-
state: flattenState({
|
|
282
|
-
rootState,
|
|
283
|
-
localState,
|
|
284
|
-
rootSetState
|
|
285
|
-
})
|
|
286
|
-
});
|
|
287
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
288
|
-
};
|
|
289
266
|
function flattenState({
|
|
290
267
|
rootState,
|
|
291
268
|
localState,
|
|
@@ -320,14 +297,27 @@ function flattenState({
|
|
|
320
297
|
});
|
|
321
298
|
}
|
|
322
299
|
|
|
323
|
-
// src/functions/
|
|
324
|
-
var
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
300
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
301
|
+
var runInBrowser = ({
|
|
302
|
+
code,
|
|
303
|
+
builder,
|
|
304
|
+
context,
|
|
305
|
+
event,
|
|
306
|
+
localState,
|
|
307
|
+
rootSetState,
|
|
308
|
+
rootState
|
|
309
|
+
}) => {
|
|
310
|
+
const functionArgs = getFunctionArguments({
|
|
311
|
+
builder,
|
|
312
|
+
context,
|
|
313
|
+
event,
|
|
314
|
+
state: flattenState({
|
|
315
|
+
rootState,
|
|
316
|
+
localState,
|
|
317
|
+
rootSetState
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
331
321
|
};
|
|
332
322
|
|
|
333
323
|
// src/functions/evaluate/edge-runtime/acorn-interpreter.ts
|
|
@@ -3399,22 +3389,56 @@ t.VALUE_IN_DESCRIPTOR = Ia;
|
|
|
3399
3389
|
var acorn_interpreter_default = t;
|
|
3400
3390
|
|
|
3401
3391
|
// src/functions/evaluate/edge-runtime/edge-runtime.ts
|
|
3392
|
+
function patchInterpreter() {
|
|
3393
|
+
const originalGetProperty = acorn_interpreter_default.prototype.getProperty;
|
|
3394
|
+
const originalSetProperty = acorn_interpreter_default.prototype.setProperty;
|
|
3395
|
+
function newGetProperty(obj, name) {
|
|
3396
|
+
if (obj == null || !obj._connected) {
|
|
3397
|
+
return originalGetProperty.call(this, obj, name);
|
|
3398
|
+
}
|
|
3399
|
+
const value = obj._connected[name];
|
|
3400
|
+
if (Array.isArray(value)) {
|
|
3401
|
+
return this.nativeToPseudo(value);
|
|
3402
|
+
}
|
|
3403
|
+
if (typeof value === "object") {
|
|
3404
|
+
return this.createConnectedObject(value);
|
|
3405
|
+
}
|
|
3406
|
+
return value;
|
|
3407
|
+
}
|
|
3408
|
+
function newSetProperty(obj, name, value, opt_descriptor) {
|
|
3409
|
+
if (obj == null || !obj._connected) {
|
|
3410
|
+
return originalSetProperty.call(this, obj, name, value, opt_descriptor);
|
|
3411
|
+
}
|
|
3412
|
+
obj._connected[name] = this.pseudoToNative(value);
|
|
3413
|
+
}
|
|
3414
|
+
const getKeys = [];
|
|
3415
|
+
const setKeys = [];
|
|
3416
|
+
for (const key of Object.keys(acorn_interpreter_default.prototype)) {
|
|
3417
|
+
if (acorn_interpreter_default.prototype[key] === originalGetProperty) {
|
|
3418
|
+
getKeys.push(key);
|
|
3419
|
+
}
|
|
3420
|
+
if (acorn_interpreter_default.prototype[key] === originalSetProperty) {
|
|
3421
|
+
setKeys.push(key);
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
for (const key of getKeys) {
|
|
3425
|
+
acorn_interpreter_default.prototype[key] = newGetProperty;
|
|
3426
|
+
}
|
|
3427
|
+
for (const key of setKeys) {
|
|
3428
|
+
acorn_interpreter_default.prototype[key] = newSetProperty;
|
|
3429
|
+
}
|
|
3430
|
+
acorn_interpreter_default.prototype.createConnectedObject = function(obj) {
|
|
3431
|
+
const connectedObject = this.createObject(this.OBJECT);
|
|
3432
|
+
connectedObject._connected = obj;
|
|
3433
|
+
return connectedObject;
|
|
3434
|
+
};
|
|
3435
|
+
}
|
|
3436
|
+
patchInterpreter();
|
|
3402
3437
|
var processCode = (code) => {
|
|
3403
|
-
return code.
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
const isStateSetter = trimmed.startsWith("state.");
|
|
3408
|
-
if (!isStateSetter)
|
|
3409
|
-
return line;
|
|
3410
|
-
const [lhs, rhs] = trimmed.split("=");
|
|
3411
|
-
const setStr = lhs.replace("state.", "").trim();
|
|
3412
|
-
const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
|
|
3413
|
-
return `
|
|
3414
|
-
${line}
|
|
3415
|
-
${setExpr}
|
|
3416
|
-
`;
|
|
3417
|
-
}).filter(Boolean).join("\n");
|
|
3438
|
+
return code.replace(/^.*?function main\(\)/, `
|
|
3439
|
+
var __awaiter = function (e, t, n, r) {return r()},
|
|
3440
|
+
__generator = function (e, t) { return t() };
|
|
3441
|
+
function main()`).replace(/\?\./g, ".");
|
|
3418
3442
|
};
|
|
3419
3443
|
var getJSONValName = (val) => val + "JSON";
|
|
3420
3444
|
var runInEdge = ({
|
|
@@ -3426,10 +3450,11 @@ var runInEdge = ({
|
|
|
3426
3450
|
rootSetState,
|
|
3427
3451
|
code
|
|
3428
3452
|
}) => {
|
|
3429
|
-
const state = {
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3453
|
+
const state = flattenState({
|
|
3454
|
+
rootState,
|
|
3455
|
+
localState,
|
|
3456
|
+
rootSetState
|
|
3457
|
+
});
|
|
3433
3458
|
const properties = getFunctionArguments({
|
|
3434
3459
|
builder,
|
|
3435
3460
|
context,
|
|
@@ -3438,6 +3463,9 @@ var runInEdge = ({
|
|
|
3438
3463
|
});
|
|
3439
3464
|
const prependedCode = properties.map(([key]) => {
|
|
3440
3465
|
const jsonValName = getJSONValName(key);
|
|
3466
|
+
if (key === "state") {
|
|
3467
|
+
return ``;
|
|
3468
|
+
}
|
|
3441
3469
|
return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
|
|
3442
3470
|
}).join("\n");
|
|
3443
3471
|
const cleanedCode = processCode(code);
|
|
@@ -3453,16 +3481,15 @@ function theFunction() {
|
|
|
3453
3481
|
}
|
|
3454
3482
|
theFunction();
|
|
3455
3483
|
`;
|
|
3456
|
-
const setRootState = (prop, value) => {
|
|
3457
|
-
const newState = set(state, prop, value);
|
|
3458
|
-
rootSetState?.(newState);
|
|
3459
|
-
};
|
|
3460
3484
|
const initFunc = function(interpreter, globalObject) {
|
|
3461
3485
|
properties.forEach(([key, val]) => {
|
|
3462
|
-
|
|
3463
|
-
|
|
3486
|
+
if (key === "state") {
|
|
3487
|
+
interpreter.setProperty(globalObject, key, interpreter.createConnectedObject(val), interpreter.READONLY_DESCRIPTOR);
|
|
3488
|
+
} else {
|
|
3489
|
+
const jsonVal = JSON.stringify(val);
|
|
3490
|
+
interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
|
|
3491
|
+
}
|
|
3464
3492
|
});
|
|
3465
|
-
interpreter.setProperty(globalObject, "setRootState", interpreter.createNativeFunction(setRootState));
|
|
3466
3493
|
};
|
|
3467
3494
|
const myInterpreter = new acorn_interpreter_default(transformed, initFunc);
|
|
3468
3495
|
myInterpreter.run();
|
|
@@ -3579,6 +3606,16 @@ function evaluate({
|
|
|
3579
3606
|
// src/functions/fast-clone.ts
|
|
3580
3607
|
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
3581
3608
|
|
|
3609
|
+
// src/functions/set.ts
|
|
3610
|
+
var set = (obj, _path, value) => {
|
|
3611
|
+
if (Object(obj) !== obj) {
|
|
3612
|
+
return obj;
|
|
3613
|
+
}
|
|
3614
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
3615
|
+
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;
|
|
3616
|
+
return obj;
|
|
3617
|
+
};
|
|
3618
|
+
|
|
3582
3619
|
// src/functions/transform-block.ts
|
|
3583
3620
|
function transformBlock(block) {
|
|
3584
3621
|
return block;
|
|
@@ -4254,6 +4291,14 @@ function BlockWrapper(props) {
|
|
|
4254
4291
|
});
|
|
4255
4292
|
}
|
|
4256
4293
|
var block_wrapper_default = BlockWrapper;
|
|
4294
|
+
function Awaiter(props) {
|
|
4295
|
+
onMount(() => {
|
|
4296
|
+
});
|
|
4297
|
+
return memo(() => props.children);
|
|
4298
|
+
}
|
|
4299
|
+
var awaiter_default = Awaiter;
|
|
4300
|
+
|
|
4301
|
+
// src/components/block/components/interactive-element.tsx
|
|
4257
4302
|
function InteractiveElement(props) {
|
|
4258
4303
|
const attributes = createMemo(() => {
|
|
4259
4304
|
return props.includeBlockProps ? {
|
|
@@ -4270,17 +4315,43 @@ function InteractiveElement(props) {
|
|
|
4270
4315
|
})
|
|
4271
4316
|
} : {};
|
|
4272
4317
|
});
|
|
4273
|
-
return createComponent(
|
|
4274
|
-
get
|
|
4275
|
-
return
|
|
4318
|
+
return createComponent(Show, {
|
|
4319
|
+
get fallback() {
|
|
4320
|
+
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
4321
|
+
get attributes() {
|
|
4322
|
+
return attributes();
|
|
4323
|
+
},
|
|
4324
|
+
get component() {
|
|
4325
|
+
return props.Wrapper;
|
|
4326
|
+
},
|
|
4327
|
+
get children() {
|
|
4328
|
+
return props.children;
|
|
4329
|
+
}
|
|
4330
|
+
}));
|
|
4276
4331
|
},
|
|
4277
|
-
get
|
|
4278
|
-
return props.Wrapper;
|
|
4332
|
+
get when() {
|
|
4333
|
+
return props.Wrapper.load;
|
|
4279
4334
|
},
|
|
4280
4335
|
get children() {
|
|
4281
|
-
return
|
|
4336
|
+
return createComponent(awaiter_default, {
|
|
4337
|
+
get load() {
|
|
4338
|
+
return props.Wrapper.load;
|
|
4339
|
+
},
|
|
4340
|
+
get fallback() {
|
|
4341
|
+
return props.Wrapper.fallback;
|
|
4342
|
+
},
|
|
4343
|
+
get props() {
|
|
4344
|
+
return props.wrapperProps;
|
|
4345
|
+
},
|
|
4346
|
+
get attributes() {
|
|
4347
|
+
return attributes();
|
|
4348
|
+
},
|
|
4349
|
+
get children() {
|
|
4350
|
+
return props.children;
|
|
4351
|
+
}
|
|
4352
|
+
});
|
|
4282
4353
|
}
|
|
4283
|
-
})
|
|
4354
|
+
});
|
|
4284
4355
|
}
|
|
4285
4356
|
var interactive_element_default = InteractiveElement;
|
|
4286
4357
|
|
|
@@ -4655,7 +4726,7 @@ function Block(props) {
|
|
|
4655
4726
|
});
|
|
4656
4727
|
}
|
|
4657
4728
|
var block_default = Block;
|
|
4658
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4729
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
|
|
4659
4730
|
display: flex;
|
|
4660
4731
|
flex-direction: column;
|
|
4661
4732
|
align-items: stretch;
|
|
@@ -4691,7 +4762,7 @@ function BlocksWrapper(props) {
|
|
|
4691
4762
|
});
|
|
4692
4763
|
return [createComponent(Dynamic, mergeProps({
|
|
4693
4764
|
get ["class"]() {
|
|
4694
|
-
return className() + " dynamic-
|
|
4765
|
+
return className() + " dynamic-68b2d7fe";
|
|
4695
4766
|
},
|
|
4696
4767
|
ref(r$) {
|
|
4697
4768
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4787,7 +4858,7 @@ var getColumnsClass = (id2) => {
|
|
|
4787
4858
|
|
|
4788
4859
|
// src/blocks/columns/columns.tsx
|
|
4789
4860
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
4790
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
4861
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
|
|
4791
4862
|
display: flex;
|
|
4792
4863
|
line-height: normal;
|
|
4793
4864
|
}`);
|
|
@@ -4908,7 +4979,7 @@ function Columns(props) {
|
|
|
4908
4979
|
const _el$ = _tmpl$3();
|
|
4909
4980
|
spread(_el$, mergeProps({
|
|
4910
4981
|
get ["class"]() {
|
|
4911
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
4982
|
+
return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
|
|
4912
4983
|
},
|
|
4913
4984
|
get style() {
|
|
4914
4985
|
return columnsCssVars();
|
|
@@ -5033,16 +5104,16 @@ function getSrcSet(url) {
|
|
|
5033
5104
|
// src/blocks/image/image.tsx
|
|
5034
5105
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
5035
5106
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
5036
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
5037
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
5038
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
5107
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
|
|
5108
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
|
|
5109
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
|
|
5039
5110
|
opacity: 1;
|
|
5040
5111
|
transition: opacity 0.2s ease-in-out;
|
|
5041
|
-
}.div-
|
|
5112
|
+
}.div-7e6ffddc {
|
|
5042
5113
|
width: 100%;
|
|
5043
5114
|
pointer-events: none;
|
|
5044
5115
|
font-size: 0;
|
|
5045
|
-
}.div-
|
|
5116
|
+
}.div-7e6ffddc-2 {
|
|
5046
5117
|
display: flex;
|
|
5047
5118
|
flex-direction: column;
|
|
5048
5119
|
align-items: stretch;
|
|
@@ -5107,7 +5178,7 @@ function Image(props) {
|
|
|
5107
5178
|
}
|
|
5108
5179
|
}), _el$3);
|
|
5109
5180
|
effect((_p$) => {
|
|
5110
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
5181
|
+
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 = {
|
|
5111
5182
|
"object-position": props.backgroundPosition || "center",
|
|
5112
5183
|
"object-fit": props.backgroundSize || "cover",
|
|
5113
5184
|
...aspectRatioCss()
|
|
@@ -8397,7 +8468,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
8397
8468
|
}
|
|
8398
8469
|
|
|
8399
8470
|
// src/constants/sdk-version.ts
|
|
8400
|
-
var SDK_VERSION = "2.0.
|
|
8471
|
+
var SDK_VERSION = "2.0.22";
|
|
8401
8472
|
|
|
8402
8473
|
// src/functions/register.ts
|
|
8403
8474
|
var registry = {};
|
|
@@ -8751,22 +8822,6 @@ function EnableEditor(props) {
|
|
|
8751
8822
|
}
|
|
8752
8823
|
})(event);
|
|
8753
8824
|
}
|
|
8754
|
-
function evaluateJsCode() {
|
|
8755
|
-
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
8756
|
-
if (jsCode) {
|
|
8757
|
-
evaluate({
|
|
8758
|
-
code: jsCode,
|
|
8759
|
-
context: props.context || {},
|
|
8760
|
-
localState: void 0,
|
|
8761
|
-
rootState: props.builderContextSignal.rootState,
|
|
8762
|
-
rootSetState: props.builderContextSignal.rootSetState,
|
|
8763
|
-
/**
|
|
8764
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
8765
|
-
*/
|
|
8766
|
-
enableCache: false
|
|
8767
|
-
});
|
|
8768
|
-
}
|
|
8769
|
-
}
|
|
8770
8825
|
function onClick(event) {
|
|
8771
8826
|
if (props.builderContextSignal.content) {
|
|
8772
8827
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
@@ -8803,7 +8858,7 @@ function EnableEditor(props) {
|
|
|
8803
8858
|
rootSetState: props.builderContextSignal.rootSetState,
|
|
8804
8859
|
enableCache: true
|
|
8805
8860
|
})));
|
|
8806
|
-
|
|
8861
|
+
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
8807
8862
|
mergeNewRootState({
|
|
8808
8863
|
[key]: json
|
|
8809
8864
|
});
|
|
@@ -8828,6 +8883,8 @@ function EnableEditor(props) {
|
|
|
8828
8883
|
}
|
|
8829
8884
|
}
|
|
8830
8885
|
let elementRef;
|
|
8886
|
+
runHttpRequests();
|
|
8887
|
+
emitStateUpdate();
|
|
8831
8888
|
onMount(() => {
|
|
8832
8889
|
if (isBrowser()) {
|
|
8833
8890
|
if (isEditing()) {
|
|
@@ -8882,14 +8939,6 @@ function EnableEditor(props) {
|
|
|
8882
8939
|
}
|
|
8883
8940
|
}
|
|
8884
8941
|
});
|
|
8885
|
-
onMount(() => {
|
|
8886
|
-
if (!props.apiKey) {
|
|
8887
|
-
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
8888
|
-
}
|
|
8889
|
-
evaluateJsCode();
|
|
8890
|
-
runHttpRequests();
|
|
8891
|
-
emitStateUpdate();
|
|
8892
|
-
});
|
|
8893
8942
|
const onUpdateFn_0_props_content = createMemo(() => props.content);
|
|
8894
8943
|
function onUpdateFn_0() {
|
|
8895
8944
|
if (props.content) {
|
|
@@ -8897,37 +8946,27 @@ function EnableEditor(props) {
|
|
|
8897
8946
|
}
|
|
8898
8947
|
}
|
|
8899
8948
|
createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
8900
|
-
const
|
|
8949
|
+
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
8901
8950
|
function onUpdateFn_1() {
|
|
8902
|
-
evaluateJsCode();
|
|
8903
|
-
}
|
|
8904
|
-
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
|
|
8905
|
-
const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
|
|
8906
|
-
function onUpdateFn_2() {
|
|
8907
|
-
runHttpRequests();
|
|
8908
|
-
}
|
|
8909
|
-
createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
|
|
8910
|
-
const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
|
|
8911
|
-
function onUpdateFn_3() {
|
|
8912
8951
|
emitStateUpdate();
|
|
8913
8952
|
}
|
|
8914
|
-
createEffect(on(() => [
|
|
8915
|
-
const
|
|
8916
|
-
function
|
|
8953
|
+
createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
|
|
8954
|
+
const onUpdateFn_2_props_data = createMemo(() => props.data);
|
|
8955
|
+
function onUpdateFn_2() {
|
|
8917
8956
|
if (props.data) {
|
|
8918
8957
|
mergeNewRootState(props.data);
|
|
8919
8958
|
}
|
|
8920
8959
|
}
|
|
8921
|
-
createEffect(on(() => [
|
|
8922
|
-
const
|
|
8923
|
-
function
|
|
8960
|
+
createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
8961
|
+
const onUpdateFn_3_props_locale = createMemo(() => props.locale);
|
|
8962
|
+
function onUpdateFn_3() {
|
|
8924
8963
|
if (props.locale) {
|
|
8925
8964
|
mergeNewRootState({
|
|
8926
8965
|
locale: props.locale
|
|
8927
8966
|
});
|
|
8928
8967
|
}
|
|
8929
8968
|
}
|
|
8930
|
-
createEffect(on(() => [
|
|
8969
|
+
createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
8931
8970
|
return createComponent(builder_context_default.Provider, {
|
|
8932
8971
|
get value() {
|
|
8933
8972
|
return props.builderContextSignal;
|
|
@@ -9095,6 +9134,29 @@ function ContentComponent(props) {
|
|
|
9095
9134
|
rootState: newRootState
|
|
9096
9135
|
}));
|
|
9097
9136
|
}
|
|
9137
|
+
if (!props.apiKey) {
|
|
9138
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
9139
|
+
}
|
|
9140
|
+
const jsCode = builderContextSignal().content?.data?.jsCode;
|
|
9141
|
+
if (jsCode) {
|
|
9142
|
+
evaluate({
|
|
9143
|
+
code: jsCode,
|
|
9144
|
+
context: props.context || {},
|
|
9145
|
+
localState: void 0,
|
|
9146
|
+
rootState: builderContextSignal().rootState,
|
|
9147
|
+
rootSetState: (newState) => {
|
|
9148
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
9149
|
+
...PREVIOUS_VALUE,
|
|
9150
|
+
rootState: newState
|
|
9151
|
+
}));
|
|
9152
|
+
},
|
|
9153
|
+
isExpression: false,
|
|
9154
|
+
/**
|
|
9155
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
9156
|
+
*/
|
|
9157
|
+
enableCache: false
|
|
9158
|
+
});
|
|
9159
|
+
}
|
|
9098
9160
|
return createComponent(components_context_default.Provider, {
|
|
9099
9161
|
get value() {
|
|
9100
9162
|
return {
|