@builder.io/sdk-solid 2.0.15 → 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.
@@ -83,10 +83,10 @@ function Button(props) {
83
83
  var button_default = Button;
84
84
 
85
85
  // src/blocks/columns/columns.tsx
86
- import { Show as Show6, For as For4, createSignal as createSignal7 } from "solid-js";
86
+ import { Show as Show7, For as For4, createSignal as createSignal7 } from "solid-js";
87
87
 
88
88
  // src/components/blocks/blocks.tsx
89
- import { useContext, Show as Show5, For as For3 } from "solid-js";
89
+ import { useContext, Show as Show6, For as For3 } from "solid-js";
90
90
 
91
91
  // src/context/builder.context.ts
92
92
  import { createContext } from "solid-js";
@@ -112,9 +112,9 @@ var components_context_default = createContext2({ registeredComponents: {} });
112
112
 
113
113
  // src/components/block/block.tsx
114
114
  import {
115
- Show as Show4,
115
+ Show as Show5,
116
116
  For as For2,
117
- onMount,
117
+ onMount as onMount2,
118
118
  createMemo as createMemo5,
119
119
  createSignal as createSignal5
120
120
  } from "solid-js";
@@ -256,29 +256,6 @@ var parseCode = (code, {
256
256
  const useCode = useReturn ? `return (${code});` : code;
257
257
  return useCode;
258
258
  };
259
-
260
- // src/functions/evaluate/browser-runtime/browser.ts
261
- var runInBrowser = ({
262
- code,
263
- builder,
264
- context,
265
- event,
266
- localState,
267
- rootSetState,
268
- rootState
269
- }) => {
270
- const functionArgs = getFunctionArguments({
271
- builder,
272
- context,
273
- event,
274
- state: flattenState({
275
- rootState,
276
- localState,
277
- rootSetState
278
- })
279
- });
280
- return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
281
- };
282
259
  function flattenState({
283
260
  rootState,
284
261
  localState,
@@ -313,14 +290,27 @@ function flattenState({
313
290
  });
314
291
  }
315
292
 
316
- // src/functions/set.ts
317
- var set = (obj, _path, value) => {
318
- if (Object(obj) !== obj) {
319
- return obj;
320
- }
321
- const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
322
- 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;
323
- return obj;
293
+ // src/functions/evaluate/browser-runtime/browser.ts
294
+ var runInBrowser = ({
295
+ code,
296
+ builder,
297
+ context,
298
+ event,
299
+ localState,
300
+ rootSetState,
301
+ rootState
302
+ }) => {
303
+ const functionArgs = getFunctionArguments({
304
+ builder,
305
+ context,
306
+ event,
307
+ state: flattenState({
308
+ rootState,
309
+ localState,
310
+ rootSetState
311
+ })
312
+ });
313
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
324
314
  };
325
315
 
326
316
  // src/functions/evaluate/edge-runtime/acorn-interpreter.ts
@@ -3392,22 +3382,56 @@ t.VALUE_IN_DESCRIPTOR = Ia;
3392
3382
  var acorn_interpreter_default = t;
3393
3383
 
3394
3384
  // src/functions/evaluate/edge-runtime/edge-runtime.ts
3385
+ function patchInterpreter() {
3386
+ const originalGetProperty = acorn_interpreter_default.prototype.getProperty;
3387
+ const originalSetProperty = acorn_interpreter_default.prototype.setProperty;
3388
+ function newGetProperty(obj, name) {
3389
+ if (obj == null || !obj._connected) {
3390
+ return originalGetProperty.call(this, obj, name);
3391
+ }
3392
+ const value = obj._connected[name];
3393
+ if (Array.isArray(value)) {
3394
+ return this.nativeToPseudo(value);
3395
+ }
3396
+ if (typeof value === "object") {
3397
+ return this.createConnectedObject(value);
3398
+ }
3399
+ return value;
3400
+ }
3401
+ function newSetProperty(obj, name, value, opt_descriptor) {
3402
+ if (obj == null || !obj._connected) {
3403
+ return originalSetProperty.call(this, obj, name, value, opt_descriptor);
3404
+ }
3405
+ obj._connected[name] = this.pseudoToNative(value);
3406
+ }
3407
+ const getKeys = [];
3408
+ const setKeys = [];
3409
+ for (const key of Object.keys(acorn_interpreter_default.prototype)) {
3410
+ if (acorn_interpreter_default.prototype[key] === originalGetProperty) {
3411
+ getKeys.push(key);
3412
+ }
3413
+ if (acorn_interpreter_default.prototype[key] === originalSetProperty) {
3414
+ setKeys.push(key);
3415
+ }
3416
+ }
3417
+ for (const key of getKeys) {
3418
+ acorn_interpreter_default.prototype[key] = newGetProperty;
3419
+ }
3420
+ for (const key of setKeys) {
3421
+ acorn_interpreter_default.prototype[key] = newSetProperty;
3422
+ }
3423
+ acorn_interpreter_default.prototype.createConnectedObject = function(obj) {
3424
+ const connectedObject = this.createObject(this.OBJECT);
3425
+ connectedObject._connected = obj;
3426
+ return connectedObject;
3427
+ };
3428
+ }
3429
+ patchInterpreter();
3395
3430
  var processCode = (code) => {
3396
- return code.split("\n").map((line) => {
3397
- const trimmed = line.trim();
3398
- if (line.includes("__awaiter"))
3399
- return void 0;
3400
- const isStateSetter = trimmed.startsWith("state.");
3401
- if (!isStateSetter)
3402
- return line;
3403
- const [lhs, rhs] = trimmed.split("=");
3404
- const setStr = lhs.replace("state.", "").trim();
3405
- const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
3406
- return `
3407
- ${line}
3408
- ${setExpr}
3409
- `;
3410
- }).filter(Boolean).join("\n");
3431
+ return code.replace(/^.*?function main\(\)/, `
3432
+ var __awaiter = function (e, t, n, r) {return r()},
3433
+ __generator = function (e, t) { return t() };
3434
+ function main()`).replace(/\?\./g, ".");
3411
3435
  };
3412
3436
  var getJSONValName = (val) => val + "JSON";
3413
3437
  var runInEdge = ({
@@ -3419,10 +3443,11 @@ var runInEdge = ({
3419
3443
  rootSetState,
3420
3444
  code
3421
3445
  }) => {
3422
- const state = {
3423
- ...rootState,
3424
- ...localState
3425
- };
3446
+ const state = flattenState({
3447
+ rootState,
3448
+ localState,
3449
+ rootSetState
3450
+ });
3426
3451
  const properties = getFunctionArguments({
3427
3452
  builder,
3428
3453
  context,
@@ -3431,6 +3456,9 @@ var runInEdge = ({
3431
3456
  });
3432
3457
  const prependedCode = properties.map(([key]) => {
3433
3458
  const jsonValName = getJSONValName(key);
3459
+ if (key === "state") {
3460
+ return ``;
3461
+ }
3434
3462
  return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
3435
3463
  }).join("\n");
3436
3464
  const cleanedCode = processCode(code);
@@ -3446,16 +3474,15 @@ function theFunction() {
3446
3474
  }
3447
3475
  theFunction();
3448
3476
  `;
3449
- const setRootState = (prop, value) => {
3450
- const newState = set(state, prop, value);
3451
- rootSetState?.(newState);
3452
- };
3453
3477
  const initFunc = function(interpreter, globalObject) {
3454
3478
  properties.forEach(([key, val]) => {
3455
- const jsonVal = JSON.stringify(val);
3456
- interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
3479
+ if (key === "state") {
3480
+ interpreter.setProperty(globalObject, key, interpreter.createConnectedObject(val), interpreter.READONLY_DESCRIPTOR);
3481
+ } else {
3482
+ const jsonVal = JSON.stringify(val);
3483
+ interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
3484
+ }
3457
3485
  });
3458
- interpreter.setProperty(globalObject, "setRootState", interpreter.createNativeFunction(setRootState));
3459
3486
  };
3460
3487
  const myInterpreter = new acorn_interpreter_default(transformed, initFunc);
3461
3488
  myInterpreter.run();
@@ -3472,24 +3499,30 @@ function isNodeRuntime() {
3472
3499
  }
3473
3500
 
3474
3501
  // src/functions/evaluate/should-force-browser-runtime-in-node.ts
3475
- var shouldForceBrowserRuntimeInNode = () => {
3502
+ var shouldForceBrowserRuntimeInNode = ({
3503
+ shouldLogWarning
3504
+ }) => {
3476
3505
  if (!isNodeRuntime())
3477
3506
  return false;
3478
3507
  const isArm64 = process.arch === "arm64";
3479
3508
  const isNode20 = process.version.startsWith("v20");
3480
3509
  const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
3481
3510
  if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
3482
- logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
3511
+ if (shouldLogWarning) {
3512
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
3483
3513
  If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
3484
3514
  See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
3485
3515
  `);
3516
+ }
3486
3517
  return true;
3487
3518
  }
3488
3519
  return false;
3489
3520
  };
3490
3521
 
3491
3522
  // src/functions/evaluate/choose-eval.ts
3492
- var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
3523
+ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode({
3524
+ shouldLogWarning: true
3525
+ }) ? runInBrowser(args) : runInEdge(args);
3493
3526
 
3494
3527
  // src/functions/evaluate/evaluate.ts
3495
3528
  var DISABLE_CACHE = true;
@@ -3566,6 +3599,16 @@ function evaluate({
3566
3599
  // src/functions/fast-clone.ts
3567
3600
  var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
3568
3601
 
3602
+ // src/functions/set.ts
3603
+ var set = (obj, _path, value) => {
3604
+ if (Object(obj) !== obj) {
3605
+ return obj;
3606
+ }
3607
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
3608
+ 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;
3609
+ return obj;
3610
+ };
3611
+
3569
3612
  // src/functions/transform-block.ts
3570
3613
  function transformBlock(block) {
3571
3614
  return block;
@@ -4228,12 +4271,23 @@ function BlockWrapper(props) {
4228
4271
  var Block_wrapper_default = BlockWrapper;
4229
4272
 
4230
4273
  // src/components/block/components/component-ref/component-ref.tsx
4231
- import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
4274
+ import { Show as Show4, For, createSignal as createSignal3 } from "solid-js";
4232
4275
  import { Dynamic as Dynamic3 } from "solid-js/web";
4233
4276
 
4234
4277
  // src/components/block/components/interactive-element.tsx
4235
- import { createMemo as createMemo2 } from "solid-js";
4278
+ import { Show as Show3, createMemo as createMemo2 } from "solid-js";
4236
4279
  import { Dynamic as Dynamic2 } from "solid-js/web";
4280
+
4281
+ // src/components/awaiter.tsx
4282
+ import { onMount } from "solid-js";
4283
+ function Awaiter(props) {
4284
+ onMount(() => {
4285
+ });
4286
+ return <><>{props.children}</></>;
4287
+ }
4288
+ var Awaiter_default = Awaiter;
4289
+
4290
+ // src/components/block/components/interactive-element.tsx
4237
4291
  function InteractiveElement(props) {
4238
4292
  const attributes = createMemo2(() => {
4239
4293
  return props.includeBlockProps ? {
@@ -4250,11 +4304,19 @@ function InteractiveElement(props) {
4250
4304
  })
4251
4305
  } : {};
4252
4306
  });
4253
- return <><Dynamic2
4254
- {...props.wrapperProps}
4307
+ return <><Show3
4308
+ fallback={<Dynamic2
4309
+ {...props.wrapperProps}
4310
+ attributes={attributes()}
4311
+ component={props.Wrapper}
4312
+ >{props.children}</Dynamic2>}
4313
+ when={props.Wrapper.load}
4314
+ ><Awaiter_default
4315
+ load={props.Wrapper.load}
4316
+ fallback={props.Wrapper.fallback}
4317
+ props={props.wrapperProps}
4255
4318
  attributes={attributes()}
4256
- component={props.Wrapper}
4257
- >{props.children}</Dynamic2></>;
4319
+ >{props.children}</Awaiter_default></Show3></>;
4258
4320
  }
4259
4321
  var interactive_element_default = InteractiveElement;
4260
4322
 
@@ -4296,7 +4358,7 @@ function ComponentRef(props) {
4296
4358
  const [Wrapper, setWrapper] = createSignal3(
4297
4359
  props.isInteractive ? interactive_element_default : props.componentRef
4298
4360
  );
4299
- return <><Show3 when={props.componentRef}><Dynamic3
4361
+ return <><Show4 when={props.componentRef}><Dynamic3
4300
4362
  {...getWrapperProps({
4301
4363
  componentOptions: props.componentOptions,
4302
4364
  builderBlock: props.builderBlock,
@@ -4317,7 +4379,7 @@ function ComponentRef(props) {
4317
4379
  registeredComponents={props.registeredComponents}
4318
4380
  linkComponent={props.linkComponent}
4319
4381
  />;
4320
- }}</For></Dynamic3></Show3></>;
4382
+ }}</For></Dynamic3></Show4></>;
4321
4383
  }
4322
4384
  var Component_ref_default = ComponentRef;
4323
4385
 
@@ -4406,7 +4468,7 @@ function Block(props) {
4406
4468
  isInteractive: !(blockComponent()?.isRSC && TARGET === "rsc")
4407
4469
  };
4408
4470
  });
4409
- onMount(() => {
4471
+ onMount2(() => {
4410
4472
  const blockId = processedBlock().id;
4411
4473
  const animations = processedBlock().animations;
4412
4474
  if (animations && blockId) {
@@ -4418,13 +4480,13 @@ function Block(props) {
4418
4480
  );
4419
4481
  }
4420
4482
  });
4421
- return <><Show4 when={canShowBlock()}>
4483
+ return <><Show5 when={canShowBlock()}>
4422
4484
  <Block_styles_default
4423
4485
  block={processedBlock()}
4424
4486
  context={props.context}
4425
4487
  />
4426
- <Show4
4427
- fallback={<Show4
4488
+ <Show5
4489
+ fallback={<Show5
4428
4490
  fallback={<For2 each={repeatItem()}>{(data, _index) => {
4429
4491
  const index = _index();
4430
4492
  return <Repeated_block_default
@@ -4446,9 +4508,9 @@ function Block(props) {
4446
4508
  builderBlock={componentRefProps().builderBlock}
4447
4509
  includeBlockProps={componentRefProps().includeBlockProps}
4448
4510
  isInteractive={componentRefProps().isInteractive}
4449
- /></Show4>}
4511
+ /></Show5>}
4450
4512
  when={!blockComponent()?.noWrap}
4451
- ><Show4
4513
+ ><Show5
4452
4514
  fallback={<For2 each={repeatItem()}>{(data, _index) => {
4453
4515
  const index = _index();
4454
4516
  return <Repeated_block_default
@@ -4486,13 +4548,13 @@ function Block(props) {
4486
4548
  context={props.context}
4487
4549
  />;
4488
4550
  }}</For2>
4489
- </Block_wrapper_default></Show4></Show4>
4490
- </Show4></>;
4551
+ </Block_wrapper_default></Show5></Show5>
4552
+ </Show5></>;
4491
4553
  }
4492
4554
  var Block_default = Block;
4493
4555
 
4494
4556
  // src/components/blocks/blocks-wrapper.tsx
4495
- import { onMount as onMount2, createMemo as createMemo6 } from "solid-js";
4557
+ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
4496
4558
  import { Dynamic as Dynamic4 } from "solid-js/web";
4497
4559
  function BlocksWrapper(props) {
4498
4560
  const className = createMemo6(() => {
@@ -4527,11 +4589,11 @@ function BlocksWrapper(props) {
4527
4589
  }
4528
4590
  }
4529
4591
  let blocksWrapperRef;
4530
- onMount2(() => {
4592
+ onMount3(() => {
4531
4593
  });
4532
4594
  return <>
4533
4595
  <Dynamic4
4534
- class={className() + " dynamic-4da8c6f4"}
4596
+ class={className() + " dynamic-68b2d7fe"}
4535
4597
  ref={blocksWrapperRef}
4536
4598
  builder-path={props.path}
4537
4599
  builder-parent-id={props.parent}
@@ -4543,7 +4605,7 @@ function BlocksWrapper(props) {
4543
4605
  {...props.BlocksWrapperProps}
4544
4606
  component={props.BlocksWrapper}
4545
4607
  >{props.children}</Dynamic4>
4546
- <style>{`.dynamic-4da8c6f4 {
4608
+ <style>{`.dynamic-68b2d7fe {
4547
4609
  display: flex;
4548
4610
  flex-direction: column;
4549
4611
  align-items: stretch;
@@ -4563,7 +4625,7 @@ function Blocks(props) {
4563
4625
  styleProp={props.styleProp}
4564
4626
  BlocksWrapper={props.context?.BlocksWrapper || builderContext.BlocksWrapper}
4565
4627
  BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext.BlocksWrapperProps}
4566
- ><Show5 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
4628
+ ><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
4567
4629
  const index = _index();
4568
4630
  return <Block_default
4569
4631
  key={block.id}
@@ -4572,7 +4634,7 @@ function Blocks(props) {
4572
4634
  context={props.context || builderContext}
4573
4635
  registeredComponents={props.registeredComponents || componentsContext.registeredComponents}
4574
4636
  />;
4575
- }}</For3></Show5></Blocks_wrapper_default></>;
4637
+ }}</For3></Show6></Blocks_wrapper_default></>;
4576
4638
  }
4577
4639
  var Blocks_default = Blocks;
4578
4640
 
@@ -4703,15 +4765,15 @@ function Columns(props) {
4703
4765
  }
4704
4766
  return <>
4705
4767
  <div
4706
- class={getColumnsClass(props.builderBlock?.id) + " div-3ff242de"}
4768
+ class={getColumnsClass(props.builderBlock?.id) + " div-46766f1c"}
4707
4769
  style={columnsCssVars()}
4708
4770
  {...{}}
4709
4771
  >
4710
- <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default
4772
+ <Show7 when={TARGET !== "reactNative"}><Inlined_styles_default
4711
4773
  id="builderio-columns"
4712
4774
  styles={columnsStyles()}
4713
4775
  nonce={props.builderContext.nonce}
4714
- /></Show6>
4776
+ /></Show7>
4715
4777
  <For4 each={props.columns}>{(column, _index) => {
4716
4778
  const index = _index();
4717
4779
  return <Dynamic_renderer_default
@@ -4732,7 +4794,7 @@ function Columns(props) {
4732
4794
  /></Dynamic_renderer_default>;
4733
4795
  }}</For4>
4734
4796
  </div>
4735
- <style>{`.div-3ff242de {
4797
+ <style>{`.div-46766f1c {
4736
4798
  display: flex;
4737
4799
  line-height: normal;
4738
4800
  }`}</style>
@@ -4747,7 +4809,7 @@ function FragmentComponent(props) {
4747
4809
  var fragment_default = FragmentComponent;
4748
4810
 
4749
4811
  // src/blocks/image/image.tsx
4750
- import { Show as Show7, onMount as onMount3, createMemo as createMemo8 } from "solid-js";
4812
+ import { Show as Show8, onMount as onMount4, createMemo as createMemo8 } from "solid-js";
4751
4813
 
4752
4814
  // src/blocks/image/image.helpers.ts
4753
4815
  function removeProtocol(path) {
@@ -4836,14 +4898,14 @@ function Image(props) {
4836
4898
  const out = props.aspectRatio ? aspectRatioStyles : void 0;
4837
4899
  return out;
4838
4900
  });
4839
- onMount3(() => {
4901
+ onMount4(() => {
4840
4902
  });
4841
4903
  return <>
4842
4904
  <>
4843
4905
  <picture>
4844
- <Show7 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show7>
4906
+ <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
4845
4907
  <img
4846
- class={"builder-image" + (props.className ? " " + props.className : "") + " img-4512e110"}
4908
+ class={"builder-image" + (props.className ? " " + props.className : "") + " img-7e6ffddc"}
4847
4909
  loading={props.highPriority ? "eager" : "lazy"}
4848
4910
  fetchpriority={props.highPriority ? "high" : "auto"}
4849
4911
  alt={props.altText}
@@ -4858,25 +4920,25 @@ function Image(props) {
4858
4920
  sizes={props.sizes}
4859
4921
  />
4860
4922
  </picture>
4861
- <Show7
4923
+ <Show8
4862
4924
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
4863
4925
  ><div
4864
- class="builder-image-sizer div-4512e110"
4926
+ class="builder-image-sizer div-7e6ffddc"
4865
4927
  style={{
4866
4928
  "padding-top": props.aspectRatio * 100 + "%"
4867
4929
  }}
4868
- /></Show7>
4869
- <Show7 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show7>
4870
- <Show7 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-4512e110-2">{props.children}</div></Show7>
4930
+ /></Show8>
4931
+ <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
4932
+ <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-7e6ffddc-2">{props.children}</div></Show8>
4871
4933
  </>
4872
- <style>{`.img-4512e110 {
4934
+ <style>{`.img-7e6ffddc {
4873
4935
  opacity: 1;
4874
4936
  transition: opacity 0.2s ease-in-out;
4875
- }.div-4512e110 {
4937
+ }.div-7e6ffddc {
4876
4938
  width: 100%;
4877
4939
  pointer-events: none;
4878
4940
  font-size: 0;
4879
- }.div-4512e110-2 {
4941
+ }.div-7e6ffddc-2 {
4880
4942
  display: flex;
4881
4943
  flex-direction: column;
4882
4944
  align-items: stretch;
@@ -4912,10 +4974,10 @@ function SectionComponent(props) {
4912
4974
  var section_default = SectionComponent;
4913
4975
 
4914
4976
  // src/blocks/symbol/symbol.tsx
4915
- import { onMount as onMount7, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
4977
+ import { onMount as onMount8, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
4916
4978
 
4917
4979
  // src/components/content-variants/content-variants.tsx
4918
- import { Show as Show14, For as For9, onMount as onMount6, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
4980
+ import { Show as Show15, For as For9, onMount as onMount7, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
4919
4981
 
4920
4982
  // src/helpers/url.ts
4921
4983
  var getTopLevelDomain = (host) => {
@@ -5109,7 +5171,7 @@ var handleABTesting = async ({
5109
5171
  var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
5110
5172
 
5111
5173
  // src/components/content/content.tsx
5112
- import { Show as Show13, createSignal as createSignal18 } from "solid-js";
5174
+ import { Show as Show14, createSignal as createSignal18 } from "solid-js";
5113
5175
 
5114
5176
  // src/blocks/accordion/component-info.ts
5115
5177
  var defaultTitle = {
@@ -5243,7 +5305,7 @@ var componentInfo = {
5243
5305
  };
5244
5306
 
5245
5307
  // src/blocks/accordion/accordion.tsx
5246
- import { Show as Show8, For as For5, createSignal as createSignal9, createMemo as createMemo9 } from "solid-js";
5308
+ import { Show as Show9, For as For5, createSignal as createSignal9, createMemo as createMemo9 } from "solid-js";
5247
5309
 
5248
5310
  // src/blocks/accordion/helpers.ts
5249
5311
  var convertOrderNumberToString = (order) => {
@@ -5377,7 +5439,7 @@ function Accordion(props) {
5377
5439
  registeredComponents={props.builderComponents}
5378
5440
  linkComponent={props.builderLinkComponent}
5379
5441
  /></div>
5380
- <Show8 when={open().includes(index)}><div
5442
+ <Show9 when={open().includes(index)}><div
5381
5443
  class={getAccordionDetailClassName(index)}
5382
5444
  style={accordionDetailStyles()}
5383
5445
  ><Blocks_default
@@ -5387,7 +5449,7 @@ function Accordion(props) {
5387
5449
  context={props.builderContext}
5388
5450
  registeredComponents={props.builderComponents}
5389
5451
  linkComponent={props.builderLinkComponent}
5390
- /></div></Show8>
5452
+ /></div></Show9>
5391
5453
  </>;
5392
5454
  }}</For5></div></>;
5393
5455
  }
@@ -6067,7 +6129,7 @@ var componentInfo9 = {
6067
6129
  };
6068
6130
 
6069
6131
  // src/blocks/tabs/tabs.tsx
6070
- import { Show as Show9, For as For6, createSignal as createSignal10 } from "solid-js";
6132
+ import { Show as Show10, For as For6, createSignal as createSignal10 } from "solid-js";
6071
6133
  function Tabs(props) {
6072
6134
  const [activeTab, setActiveTab] = createSignal10(
6073
6135
  props.defaultActiveTab ? props.defaultActiveTab - 1 : 0
@@ -6109,14 +6171,14 @@ function Tabs(props) {
6109
6171
  linkComponent={props.builderLinkComponent}
6110
6172
  /></span>;
6111
6173
  }}</For6></div>
6112
- <Show9 when={activeTabContent(activeTab())}><div><Blocks_default
6174
+ <Show10 when={activeTabContent(activeTab())}><div><Blocks_default
6113
6175
  parent={props.builderBlock.id}
6114
6176
  path={`component.options.tabs.${activeTab()}.content`}
6115
6177
  blocks={activeTabContent(activeTab())}
6116
6178
  context={props.builderContext}
6117
6179
  registeredComponents={props.builderComponents}
6118
6180
  linkComponent={props.builderLinkComponent}
6119
- /></div></Show9>
6181
+ /></div></Show10>
6120
6182
  </div></>;
6121
6183
  }
6122
6184
  var tabs_default = Tabs;
@@ -6205,12 +6267,12 @@ var componentInfo11 = {
6205
6267
  };
6206
6268
 
6207
6269
  // src/blocks/custom-code/custom-code.tsx
6208
- import { onMount as onMount4, createSignal as createSignal12 } from "solid-js";
6270
+ import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
6209
6271
  function CustomCode(props) {
6210
6272
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
6211
6273
  const [scriptsRun, setScriptsRun] = createSignal12([]);
6212
6274
  let elementRef;
6213
- onMount4(() => {
6275
+ onMount5(() => {
6214
6276
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
6215
6277
  return;
6216
6278
  }
@@ -6558,7 +6620,7 @@ var componentInfo13 = {
6558
6620
  };
6559
6621
 
6560
6622
  // src/blocks/form/form/form.tsx
6561
- import { Show as Show10, For as For7, createSignal as createSignal14 } from "solid-js";
6623
+ import { Show as Show11, For as For7, createSignal as createSignal14 } from "solid-js";
6562
6624
 
6563
6625
  // src/functions/get-env.ts
6564
6626
  var validEnvList = ["production", "qa", "test", "development", "dev", "cdn-qa", "cloud", "fast", "cdn2", "cdn-prod"];
@@ -6773,7 +6835,7 @@ function FormComponent(props) {
6773
6835
  {...{}}
6774
6836
  {...props.attributes}
6775
6837
  >
6776
- <Show10 when={props.builderBlock && props.builderBlock.children}><For7 each={props.builderBlock?.children}>{(block, _index) => {
6838
+ <Show11 when={props.builderBlock && props.builderBlock.children}><For7 each={props.builderBlock?.children}>{(block, _index) => {
6777
6839
  const idx = _index();
6778
6840
  return <Block_default
6779
6841
  key={`form-block-${idx}`}
@@ -6782,23 +6844,23 @@ function FormComponent(props) {
6782
6844
  registeredComponents={props.builderComponents}
6783
6845
  linkComponent={props.builderLinkComponent}
6784
6846
  />;
6785
- }}</For7></Show10>
6786
- <Show10 when={submissionState() === "error"}><Blocks_default
6847
+ }}</For7></Show11>
6848
+ <Show11 when={submissionState() === "error"}><Blocks_default
6787
6849
  path="errorMessage"
6788
6850
  blocks={props.errorMessage}
6789
6851
  context={props.builderContext}
6790
- /></Show10>
6791
- <Show10 when={submissionState() === "sending"}><Blocks_default
6852
+ /></Show11>
6853
+ <Show11 when={submissionState() === "sending"}><Blocks_default
6792
6854
  path="sendingMessage"
6793
6855
  blocks={props.sendingMessage}
6794
6856
  context={props.builderContext}
6795
- /></Show10>
6796
- <Show10 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-2e825338">{JSON.stringify(responseData(), null, 2)}</pre></Show10>
6797
- <Show10 when={submissionState() === "success"}><Blocks_default
6857
+ /></Show11>
6858
+ <Show11 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-2e825338">{JSON.stringify(responseData(), null, 2)}</pre></Show11>
6859
+ <Show11 when={submissionState() === "success"}><Blocks_default
6798
6860
  path="successMessage"
6799
6861
  blocks={props.successMessage}
6800
6862
  context={props.builderContext}
6801
- /></Show10>
6863
+ /></Show11>
6802
6864
  </form>
6803
6865
  <style>{`.pre-2e825338 {
6804
6866
  padding: 10px;
@@ -7150,7 +7212,7 @@ var componentInfo19 = {
7150
7212
  };
7151
7213
 
7152
7214
  // src/blocks/video/video.tsx
7153
- import { Show as Show11, createMemo as createMemo15 } from "solid-js";
7215
+ import { Show as Show12, createMemo as createMemo15 } from "solid-js";
7154
7216
  function Video(props) {
7155
7217
  const videoProps = createMemo15(() => {
7156
7218
  return {
@@ -7201,8 +7263,8 @@ function Video(props) {
7201
7263
  }}
7202
7264
  src={props.video || "no-src"}
7203
7265
  poster={props.posterImage}
7204
- ><Show11 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show11></video>
7205
- <Show11
7266
+ ><Show12 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show12></video>
7267
+ <Show12
7206
7268
  when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
7207
7269
  ><div
7208
7270
  style={{
@@ -7211,15 +7273,15 @@ function Video(props) {
7211
7273
  "pointer-events": "none",
7212
7274
  "font-size": "0px"
7213
7275
  }}
7214
- /></Show11>
7215
- <Show11 when={props.builderBlock?.children?.length && props.fitContent}><div
7276
+ /></Show12>
7277
+ <Show12 when={props.builderBlock?.children?.length && props.fitContent}><div
7216
7278
  style={{
7217
7279
  display: "flex",
7218
7280
  "flex-direction": "column",
7219
7281
  "align-items": "stretch"
7220
7282
  }}
7221
- >{props.children}</div></Show11>
7222
- <Show11 when={props.builderBlock?.children?.length && !props.fitContent}><div
7283
+ >{props.children}</div></Show12>
7284
+ <Show12 when={props.builderBlock?.children?.length && !props.fitContent}><div
7223
7285
  style={{
7224
7286
  "pointer-events": "none",
7225
7287
  display: "flex",
@@ -7231,7 +7293,7 @@ function Video(props) {
7231
7293
  width: "100%",
7232
7294
  height: "100%"
7233
7295
  }}
7234
- >{props.children}</div></Show11>
7296
+ >{props.children}</div></Show12>
7235
7297
  </div></>;
7236
7298
  }
7237
7299
  var video_default = Video;
@@ -7376,8 +7438,8 @@ var Inlined_script_default = InlinedScript;
7376
7438
 
7377
7439
  // src/components/content/components/enable-editor.tsx
7378
7440
  import {
7379
- Show as Show12,
7380
- onMount as onMount5,
7441
+ Show as Show13,
7442
+ onMount as onMount6,
7381
7443
  on as on3,
7382
7444
  createEffect as createEffect3,
7383
7445
  createMemo as createMemo16,
@@ -7879,7 +7941,7 @@ function isFromTrustedHost(trustedHosts, e) {
7879
7941
  }
7880
7942
 
7881
7943
  // src/constants/sdk-version.ts
7882
- var SDK_VERSION = "2.0.15";
7944
+ var SDK_VERSION = "2.0.21";
7883
7945
 
7884
7946
  // src/functions/register.ts
7885
7947
  var registry = {};
@@ -8231,22 +8293,6 @@ function EnableEditor(props) {
8231
8293
  }
8232
8294
  })(event);
8233
8295
  }
8234
- function evaluateJsCode() {
8235
- const jsCode = props.builderContextSignal.content?.data?.jsCode;
8236
- if (jsCode) {
8237
- evaluate({
8238
- code: jsCode,
8239
- context: props.context || {},
8240
- localState: void 0,
8241
- rootState: props.builderContextSignal.rootState,
8242
- rootSetState: props.builderContextSignal.rootSetState,
8243
- /**
8244
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8245
- */
8246
- enableCache: false
8247
- });
8248
- }
8249
- }
8250
8296
  function onClick(event) {
8251
8297
  if (props.builderContextSignal.content) {
8252
8298
  const variationId = props.builderContextSignal.content?.testVariationId;
@@ -8288,7 +8334,7 @@ function EnableEditor(props) {
8288
8334
  })
8289
8335
  )
8290
8336
  );
8291
- fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
8337
+ fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
8292
8338
  mergeNewRootState({
8293
8339
  [key]: json
8294
8340
  });
@@ -8317,7 +8363,9 @@ function EnableEditor(props) {
8317
8363
  }
8318
8364
  }
8319
8365
  let elementRef;
8320
- onMount5(() => {
8366
+ runHttpRequests();
8367
+ emitStateUpdate();
8368
+ onMount6(() => {
8321
8369
  if (isBrowser()) {
8322
8370
  if (isEditing()) {
8323
8371
  window.addEventListener("message", processMessage);
@@ -8378,16 +8426,6 @@ function EnableEditor(props) {
8378
8426
  }
8379
8427
  }
8380
8428
  });
8381
- onMount5(() => {
8382
- if (!props.apiKey) {
8383
- logger.error(
8384
- "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
8385
- );
8386
- }
8387
- evaluateJsCode();
8388
- runHttpRequests();
8389
- emitStateUpdate();
8390
- });
8391
8429
  const onUpdateFn_0_props_content = createMemo16(() => props.content);
8392
8430
  function onUpdateFn_0() {
8393
8431
  if (props.content) {
@@ -8395,57 +8433,35 @@ function EnableEditor(props) {
8395
8433
  }
8396
8434
  }
8397
8435
  createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
8398
- const onUpdateFn_1_props_builderContextSignal_content__data__jsCode = createMemo16(() => props.builderContextSignal.content?.data?.jsCode);
8399
- function onUpdateFn_1() {
8400
- evaluateJsCode();
8401
- }
8402
- createEffect3(
8403
- on3(
8404
- () => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()],
8405
- onUpdateFn_1
8406
- )
8407
- );
8408
- const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo16(() => props.builderContextSignal.content?.data?.httpRequests);
8409
- function onUpdateFn_2() {
8410
- runHttpRequests();
8411
- }
8412
- createEffect3(
8413
- on3(
8414
- () => [
8415
- onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()
8416
- ],
8417
- onUpdateFn_2
8418
- )
8419
- );
8420
- const onUpdateFn_3_props_builderContextSignal_rootState = createMemo16(
8436
+ const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
8421
8437
  () => props.builderContextSignal.rootState
8422
8438
  );
8423
- function onUpdateFn_3() {
8439
+ function onUpdateFn_1() {
8424
8440
  emitStateUpdate();
8425
8441
  }
8426
8442
  createEffect3(
8427
8443
  on3(
8428
- () => [onUpdateFn_3_props_builderContextSignal_rootState()],
8429
- onUpdateFn_3
8444
+ () => [onUpdateFn_1_props_builderContextSignal_rootState()],
8445
+ onUpdateFn_1
8430
8446
  )
8431
8447
  );
8432
- const onUpdateFn_4_props_data = createMemo16(() => props.data);
8433
- function onUpdateFn_4() {
8448
+ const onUpdateFn_2_props_data = createMemo16(() => props.data);
8449
+ function onUpdateFn_2() {
8434
8450
  if (props.data) {
8435
8451
  mergeNewRootState(props.data);
8436
8452
  }
8437
8453
  }
8438
- createEffect3(on3(() => [onUpdateFn_4_props_data()], onUpdateFn_4));
8439
- const onUpdateFn_5_props_locale = createMemo16(() => props.locale);
8440
- function onUpdateFn_5() {
8454
+ createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
8455
+ const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
8456
+ function onUpdateFn_3() {
8441
8457
  if (props.locale) {
8442
8458
  mergeNewRootState({
8443
8459
  locale: props.locale
8444
8460
  });
8445
8461
  }
8446
8462
  }
8447
- createEffect3(on3(() => [onUpdateFn_5_props_locale()], onUpdateFn_5));
8448
- return <><builder_context_default.Provider value={props.builderContextSignal}><Show12 when={props.builderContextSignal.content}><Dynamic5
8463
+ createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
8464
+ return <><builder_context_default.Provider value={props.builderContextSignal}><Show13 when={props.builderContextSignal.content}><Dynamic5
8449
8465
  class={getWrapperClassName(
8450
8466
  props.content?.testVariationId || props.content?.id
8451
8467
  )}
@@ -8458,7 +8474,7 @@ function EnableEditor(props) {
8458
8474
  {...showContentProps()}
8459
8475
  {...props.contentWrapperProps}
8460
8476
  component={ContentWrapper()}
8461
- >{props.children}</Dynamic5></Show12></builder_context_default.Provider></>;
8477
+ >{props.children}</Dynamic5></Show13></builder_context_default.Provider></>;
8462
8478
  }
8463
8479
  var Enable_editor_default = EnableEditor;
8464
8480
 
@@ -8595,6 +8611,31 @@ function ContentComponent(props) {
8595
8611
  rootState: newRootState
8596
8612
  }));
8597
8613
  }
8614
+ if (!props.apiKey) {
8615
+ logger.error(
8616
+ "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
8617
+ );
8618
+ }
8619
+ const jsCode = builderContextSignal().content?.data?.jsCode;
8620
+ if (jsCode) {
8621
+ evaluate({
8622
+ code: jsCode,
8623
+ context: props.context || {},
8624
+ localState: void 0,
8625
+ rootState: builderContextSignal().rootState,
8626
+ rootSetState: (newState) => {
8627
+ setBuilderContextSignal((PREVIOUS_VALUE) => ({
8628
+ ...PREVIOUS_VALUE,
8629
+ rootState: newState
8630
+ }));
8631
+ },
8632
+ isExpression: false,
8633
+ /**
8634
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8635
+ */
8636
+ enableCache: false
8637
+ });
8638
+ }
8598
8639
  return <><components_context_default.Provider
8599
8640
  value={{
8600
8641
  registeredComponents: registeredComponents()
@@ -8618,18 +8659,18 @@ function ContentComponent(props) {
8618
8659
  setBuilderContextSignal
8619
8660
  }}
8620
8661
  >
8621
- <Show13 when={props.isSsrAbTest}><Inlined_script_default
8662
+ <Show14 when={props.isSsrAbTest}><Inlined_script_default
8622
8663
  id="builderio-variant-visibility"
8623
8664
  scriptStr={scriptStr()}
8624
8665
  nonce={props.nonce || ""}
8625
- /></Show13>
8626
- <Show13 when={TARGET !== "reactNative"}><Styles_default
8666
+ /></Show14>
8667
+ <Show14 when={TARGET !== "reactNative"}><Styles_default
8627
8668
  nonce={props.nonce || ""}
8628
8669
  isNestedRender={props.isNestedRender}
8629
8670
  contentId={builderContextSignal().content?.id}
8630
8671
  cssCode={builderContextSignal().content?.data?.cssCode}
8631
8672
  customFonts={builderContextSignal().content?.data?.customFonts}
8632
- /></Show13>
8673
+ /></Show14>
8633
8674
  <Blocks_default
8634
8675
  blocks={builderContextSignal().content?.data?.blocks}
8635
8676
  context={builderContextSignal()}
@@ -8669,16 +8710,16 @@ function ContentVariants(props) {
8669
8710
  canTrack: getDefaultCanTrack(props.canTrack)
8670
8711
  });
8671
8712
  });
8672
- onMount6(() => {
8713
+ onMount7(() => {
8673
8714
  setShouldRenderVariants(false);
8674
8715
  });
8675
8716
  return <><>
8676
- <Show14 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
8717
+ <Show15 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
8677
8718
  id="builderio-init-variants-fns"
8678
8719
  scriptStr={getInitVariantsFnsScriptString()}
8679
8720
  nonce={props.nonce || ""}
8680
- /></Show14>
8681
- <Show14 when={shouldRenderVariants()}>
8721
+ /></Show15>
8722
+ <Show15 when={shouldRenderVariants()}>
8682
8723
  <Inlined_styles_default
8683
8724
  id="builderio-variants"
8684
8725
  styles={hideVariantsStyleString()}
@@ -8716,7 +8757,7 @@ function ContentVariants(props) {
8716
8757
  {...{}}
8717
8758
  />;
8718
8759
  }}</For9>
8719
- </Show14>
8760
+ </Show15>
8720
8761
  <Content_default
8721
8762
  nonce={props.nonce}
8722
8763
  isNestedRender={props.isNestedRender}
@@ -8797,7 +8838,7 @@ function Symbol2(props) {
8797
8838
  }
8798
8839
  });
8799
8840
  }
8800
- onMount7(() => {
8841
+ onMount8(() => {
8801
8842
  });
8802
8843
  const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
8803
8844
  function onUpdateFn_0() {