@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.
package/lib/edge/dev.jsx CHANGED
@@ -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";
@@ -258,29 +258,6 @@ var parseCode = (code, {
258
258
  const useCode = useReturn ? `return (${code});` : code;
259
259
  return useCode;
260
260
  };
261
-
262
- // src/functions/evaluate/browser-runtime/browser.ts
263
- var runInBrowser = ({
264
- code,
265
- builder,
266
- context,
267
- event,
268
- localState,
269
- rootSetState,
270
- rootState
271
- }) => {
272
- const functionArgs = getFunctionArguments({
273
- builder,
274
- context,
275
- event,
276
- state: flattenState({
277
- rootState,
278
- localState,
279
- rootSetState
280
- })
281
- });
282
- return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
283
- };
284
261
  function flattenState({
285
262
  rootState,
286
263
  localState,
@@ -315,14 +292,27 @@ function flattenState({
315
292
  });
316
293
  }
317
294
 
318
- // src/functions/set.ts
319
- var set = (obj, _path, value) => {
320
- if (Object(obj) !== obj) {
321
- return obj;
322
- }
323
- const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
324
- 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;
325
- return obj;
295
+ // src/functions/evaluate/browser-runtime/browser.ts
296
+ var runInBrowser = ({
297
+ code,
298
+ builder,
299
+ context,
300
+ event,
301
+ localState,
302
+ rootSetState,
303
+ rootState
304
+ }) => {
305
+ const functionArgs = getFunctionArguments({
306
+ builder,
307
+ context,
308
+ event,
309
+ state: flattenState({
310
+ rootState,
311
+ localState,
312
+ rootSetState
313
+ })
314
+ });
315
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
326
316
  };
327
317
 
328
318
  // src/functions/evaluate/edge-runtime/acorn-interpreter.ts
@@ -3394,22 +3384,56 @@ t.VALUE_IN_DESCRIPTOR = Ia;
3394
3384
  var acorn_interpreter_default = t;
3395
3385
 
3396
3386
  // src/functions/evaluate/edge-runtime/edge-runtime.ts
3387
+ function patchInterpreter() {
3388
+ const originalGetProperty = acorn_interpreter_default.prototype.getProperty;
3389
+ const originalSetProperty = acorn_interpreter_default.prototype.setProperty;
3390
+ function newGetProperty(obj, name) {
3391
+ if (obj == null || !obj._connected) {
3392
+ return originalGetProperty.call(this, obj, name);
3393
+ }
3394
+ const value = obj._connected[name];
3395
+ if (Array.isArray(value)) {
3396
+ return this.nativeToPseudo(value);
3397
+ }
3398
+ if (typeof value === "object") {
3399
+ return this.createConnectedObject(value);
3400
+ }
3401
+ return value;
3402
+ }
3403
+ function newSetProperty(obj, name, value, opt_descriptor) {
3404
+ if (obj == null || !obj._connected) {
3405
+ return originalSetProperty.call(this, obj, name, value, opt_descriptor);
3406
+ }
3407
+ obj._connected[name] = this.pseudoToNative(value);
3408
+ }
3409
+ const getKeys = [];
3410
+ const setKeys = [];
3411
+ for (const key of Object.keys(acorn_interpreter_default.prototype)) {
3412
+ if (acorn_interpreter_default.prototype[key] === originalGetProperty) {
3413
+ getKeys.push(key);
3414
+ }
3415
+ if (acorn_interpreter_default.prototype[key] === originalSetProperty) {
3416
+ setKeys.push(key);
3417
+ }
3418
+ }
3419
+ for (const key of getKeys) {
3420
+ acorn_interpreter_default.prototype[key] = newGetProperty;
3421
+ }
3422
+ for (const key of setKeys) {
3423
+ acorn_interpreter_default.prototype[key] = newSetProperty;
3424
+ }
3425
+ acorn_interpreter_default.prototype.createConnectedObject = function(obj) {
3426
+ const connectedObject = this.createObject(this.OBJECT);
3427
+ connectedObject._connected = obj;
3428
+ return connectedObject;
3429
+ };
3430
+ }
3431
+ patchInterpreter();
3397
3432
  var processCode = (code) => {
3398
- return code.split("\n").map((line) => {
3399
- const trimmed = line.trim();
3400
- if (line.includes("__awaiter"))
3401
- return void 0;
3402
- const isStateSetter = trimmed.startsWith("state.");
3403
- if (!isStateSetter)
3404
- return line;
3405
- const [lhs, rhs] = trimmed.split("=");
3406
- const setStr = lhs.replace("state.", "").trim();
3407
- const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
3408
- return `
3409
- ${line}
3410
- ${setExpr}
3411
- `;
3412
- }).filter(Boolean).join("\n");
3433
+ return code.replace(/^.*?function main\(\)/, `
3434
+ var __awaiter = function (e, t, n, r) {return r()},
3435
+ __generator = function (e, t) { return t() };
3436
+ function main()`).replace(/\?\./g, ".");
3413
3437
  };
3414
3438
  var getJSONValName = (val) => val + "JSON";
3415
3439
  var runInEdge = ({
@@ -3421,10 +3445,11 @@ var runInEdge = ({
3421
3445
  rootSetState,
3422
3446
  code
3423
3447
  }) => {
3424
- const state = {
3425
- ...rootState,
3426
- ...localState
3427
- };
3448
+ const state = flattenState({
3449
+ rootState,
3450
+ localState,
3451
+ rootSetState
3452
+ });
3428
3453
  const properties = getFunctionArguments({
3429
3454
  builder,
3430
3455
  context,
@@ -3433,6 +3458,9 @@ var runInEdge = ({
3433
3458
  });
3434
3459
  const prependedCode = properties.map(([key]) => {
3435
3460
  const jsonValName = getJSONValName(key);
3461
+ if (key === "state") {
3462
+ return ``;
3463
+ }
3436
3464
  return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
3437
3465
  }).join("\n");
3438
3466
  const cleanedCode = processCode(code);
@@ -3448,16 +3476,15 @@ function theFunction() {
3448
3476
  }
3449
3477
  theFunction();
3450
3478
  `;
3451
- const setRootState = (prop, value) => {
3452
- const newState = set(state, prop, value);
3453
- rootSetState?.(newState);
3454
- };
3455
3479
  const initFunc = function(interpreter, globalObject) {
3456
3480
  properties.forEach(([key, val]) => {
3457
- const jsonVal = JSON.stringify(val);
3458
- interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
3481
+ if (key === "state") {
3482
+ interpreter.setProperty(globalObject, key, interpreter.createConnectedObject(val), interpreter.READONLY_DESCRIPTOR);
3483
+ } else {
3484
+ const jsonVal = JSON.stringify(val);
3485
+ interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
3486
+ }
3459
3487
  });
3460
- interpreter.setProperty(globalObject, "setRootState", interpreter.createNativeFunction(setRootState));
3461
3488
  };
3462
3489
  const myInterpreter = new acorn_interpreter_default(transformed, initFunc);
3463
3490
  myInterpreter.run();
@@ -3474,24 +3501,30 @@ function isNodeRuntime() {
3474
3501
  }
3475
3502
 
3476
3503
  // src/functions/evaluate/should-force-browser-runtime-in-node.ts
3477
- var shouldForceBrowserRuntimeInNode = () => {
3504
+ var shouldForceBrowserRuntimeInNode = ({
3505
+ shouldLogWarning
3506
+ }) => {
3478
3507
  if (!isNodeRuntime())
3479
3508
  return false;
3480
3509
  const isArm64 = process.arch === "arm64";
3481
3510
  const isNode20 = process.version.startsWith("v20");
3482
3511
  const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes("--no-node-snapshot");
3483
3512
  if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
3484
- logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
3513
+ if (shouldLogWarning) {
3514
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
3485
3515
  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.
3486
3516
  See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
3487
3517
  `);
3518
+ }
3488
3519
  return true;
3489
3520
  }
3490
3521
  return false;
3491
3522
  };
3492
3523
 
3493
3524
  // src/functions/evaluate/choose-eval.ts
3494
- var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
3525
+ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode({
3526
+ shouldLogWarning: true
3527
+ }) ? runInBrowser(args) : runInEdge(args);
3495
3528
 
3496
3529
  // src/functions/evaluate/evaluate.ts
3497
3530
  var DISABLE_CACHE = true;
@@ -3568,6 +3601,16 @@ function evaluate({
3568
3601
  // src/functions/fast-clone.ts
3569
3602
  var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
3570
3603
 
3604
+ // src/functions/set.ts
3605
+ var set = (obj, _path, value) => {
3606
+ if (Object(obj) !== obj) {
3607
+ return obj;
3608
+ }
3609
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
3610
+ 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;
3611
+ return obj;
3612
+ };
3613
+
3571
3614
  // src/functions/transform-block.ts
3572
3615
  function transformBlock(block) {
3573
3616
  return block;
@@ -4234,12 +4277,23 @@ function BlockWrapper(props) {
4234
4277
  var Block_wrapper_default = BlockWrapper;
4235
4278
 
4236
4279
  // src/components/block/components/component-ref/component-ref.tsx
4237
- import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
4280
+ import { Show as Show4, For, createSignal as createSignal3 } from "solid-js";
4238
4281
  import { Dynamic as Dynamic3 } from "solid-js/web";
4239
4282
 
4240
4283
  // src/components/block/components/interactive-element.tsx
4241
- import { createMemo as createMemo2 } from "solid-js";
4284
+ import { Show as Show3, createMemo as createMemo2 } from "solid-js";
4242
4285
  import { Dynamic as Dynamic2 } from "solid-js/web";
4286
+
4287
+ // src/components/awaiter.tsx
4288
+ import { onMount } from "solid-js";
4289
+ function Awaiter(props) {
4290
+ onMount(() => {
4291
+ });
4292
+ return <><>{props.children}</></>;
4293
+ }
4294
+ var Awaiter_default = Awaiter;
4295
+
4296
+ // src/components/block/components/interactive-element.tsx
4243
4297
  function InteractiveElement(props) {
4244
4298
  const attributes = createMemo2(() => {
4245
4299
  return props.includeBlockProps ? {
@@ -4256,11 +4310,19 @@ function InteractiveElement(props) {
4256
4310
  })
4257
4311
  } : {};
4258
4312
  });
4259
- return <><Dynamic2
4260
- {...props.wrapperProps}
4313
+ return <><Show3
4314
+ fallback={<Dynamic2
4315
+ {...props.wrapperProps}
4316
+ attributes={attributes()}
4317
+ component={props.Wrapper}
4318
+ >{props.children}</Dynamic2>}
4319
+ when={props.Wrapper.load}
4320
+ ><Awaiter_default
4321
+ load={props.Wrapper.load}
4322
+ fallback={props.Wrapper.fallback}
4323
+ props={props.wrapperProps}
4261
4324
  attributes={attributes()}
4262
- component={props.Wrapper}
4263
- >{props.children}</Dynamic2></>;
4325
+ >{props.children}</Awaiter_default></Show3></>;
4264
4326
  }
4265
4327
  var interactive_element_default = InteractiveElement;
4266
4328
 
@@ -4302,7 +4364,7 @@ function ComponentRef(props) {
4302
4364
  const [Wrapper, setWrapper] = createSignal3(
4303
4365
  props.isInteractive ? interactive_element_default : props.componentRef
4304
4366
  );
4305
- return <><Show3 when={props.componentRef}><Dynamic3
4367
+ return <><Show4 when={props.componentRef}><Dynamic3
4306
4368
  {...getWrapperProps({
4307
4369
  componentOptions: props.componentOptions,
4308
4370
  builderBlock: props.builderBlock,
@@ -4323,7 +4385,7 @@ function ComponentRef(props) {
4323
4385
  registeredComponents={props.registeredComponents}
4324
4386
  linkComponent={props.linkComponent}
4325
4387
  />;
4326
- }}</For></Dynamic3></Show3></>;
4388
+ }}</For></Dynamic3></Show4></>;
4327
4389
  }
4328
4390
  var Component_ref_default = ComponentRef;
4329
4391
 
@@ -4412,7 +4474,7 @@ function Block(props) {
4412
4474
  isInteractive: !(blockComponent()?.isRSC && TARGET === "rsc")
4413
4475
  };
4414
4476
  });
4415
- onMount(() => {
4477
+ onMount2(() => {
4416
4478
  const blockId = processedBlock().id;
4417
4479
  const animations = processedBlock().animations;
4418
4480
  if (animations && blockId) {
@@ -4424,13 +4486,13 @@ function Block(props) {
4424
4486
  );
4425
4487
  }
4426
4488
  });
4427
- return <><Show4 when={canShowBlock()}>
4489
+ return <><Show5 when={canShowBlock()}>
4428
4490
  <Block_styles_default
4429
4491
  block={processedBlock()}
4430
4492
  context={props.context}
4431
4493
  />
4432
- <Show4
4433
- fallback={<Show4
4494
+ <Show5
4495
+ fallback={<Show5
4434
4496
  fallback={<For2 each={repeatItem()}>{(data, _index) => {
4435
4497
  const index = _index();
4436
4498
  return <Repeated_block_default
@@ -4452,9 +4514,9 @@ function Block(props) {
4452
4514
  builderBlock={componentRefProps().builderBlock}
4453
4515
  includeBlockProps={componentRefProps().includeBlockProps}
4454
4516
  isInteractive={componentRefProps().isInteractive}
4455
- /></Show4>}
4517
+ /></Show5>}
4456
4518
  when={!blockComponent()?.noWrap}
4457
- ><Show4
4519
+ ><Show5
4458
4520
  fallback={<For2 each={repeatItem()}>{(data, _index) => {
4459
4521
  const index = _index();
4460
4522
  return <Repeated_block_default
@@ -4492,13 +4554,13 @@ function Block(props) {
4492
4554
  context={props.context}
4493
4555
  />;
4494
4556
  }}</For2>
4495
- </Block_wrapper_default></Show4></Show4>
4496
- </Show4></>;
4557
+ </Block_wrapper_default></Show5></Show5>
4558
+ </Show5></>;
4497
4559
  }
4498
4560
  var Block_default = Block;
4499
4561
 
4500
4562
  // src/components/blocks/blocks-wrapper.tsx
4501
- import { onMount as onMount2, createMemo as createMemo6 } from "solid-js";
4563
+ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
4502
4564
  import { Dynamic as Dynamic4 } from "solid-js/web";
4503
4565
  function BlocksWrapper(props) {
4504
4566
  const className = createMemo6(() => {
@@ -4533,11 +4595,11 @@ function BlocksWrapper(props) {
4533
4595
  }
4534
4596
  }
4535
4597
  let blocksWrapperRef;
4536
- onMount2(() => {
4598
+ onMount3(() => {
4537
4599
  });
4538
4600
  return <>
4539
4601
  <Dynamic4
4540
- class={className() + " dynamic-4da8c6f4"}
4602
+ class={className() + " dynamic-68b2d7fe"}
4541
4603
  ref={blocksWrapperRef}
4542
4604
  builder-path={props.path}
4543
4605
  builder-parent-id={props.parent}
@@ -4549,7 +4611,7 @@ function BlocksWrapper(props) {
4549
4611
  {...props.BlocksWrapperProps}
4550
4612
  component={props.BlocksWrapper}
4551
4613
  >{props.children}</Dynamic4>
4552
- <style>{`.dynamic-4da8c6f4 {
4614
+ <style>{`.dynamic-68b2d7fe {
4553
4615
  display: flex;
4554
4616
  flex-direction: column;
4555
4617
  align-items: stretch;
@@ -4569,7 +4631,7 @@ function Blocks(props) {
4569
4631
  styleProp={props.styleProp}
4570
4632
  BlocksWrapper={props.context?.BlocksWrapper || builderContext.BlocksWrapper}
4571
4633
  BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext.BlocksWrapperProps}
4572
- ><Show5 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
4634
+ ><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
4573
4635
  const index = _index();
4574
4636
  return <Block_default
4575
4637
  key={block.id}
@@ -4578,7 +4640,7 @@ function Blocks(props) {
4578
4640
  context={props.context || builderContext}
4579
4641
  registeredComponents={props.registeredComponents || componentsContext.registeredComponents}
4580
4642
  />;
4581
- }}</For3></Show5></Blocks_wrapper_default></>;
4643
+ }}</For3></Show6></Blocks_wrapper_default></>;
4582
4644
  }
4583
4645
  var Blocks_default = Blocks;
4584
4646
 
@@ -4709,15 +4771,15 @@ function Columns(props) {
4709
4771
  }
4710
4772
  return <>
4711
4773
  <div
4712
- class={getColumnsClass(props.builderBlock?.id) + " div-3ff242de"}
4774
+ class={getColumnsClass(props.builderBlock?.id) + " div-46766f1c"}
4713
4775
  style={columnsCssVars()}
4714
4776
  {...{}}
4715
4777
  >
4716
- <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default
4778
+ <Show7 when={TARGET !== "reactNative"}><Inlined_styles_default
4717
4779
  id="builderio-columns"
4718
4780
  styles={columnsStyles()}
4719
4781
  nonce={props.builderContext.nonce}
4720
- /></Show6>
4782
+ /></Show7>
4721
4783
  <For4 each={props.columns}>{(column, _index) => {
4722
4784
  const index = _index();
4723
4785
  return <Dynamic_renderer_default
@@ -4738,7 +4800,7 @@ function Columns(props) {
4738
4800
  /></Dynamic_renderer_default>;
4739
4801
  }}</For4>
4740
4802
  </div>
4741
- <style>{`.div-3ff242de {
4803
+ <style>{`.div-46766f1c {
4742
4804
  display: flex;
4743
4805
  line-height: normal;
4744
4806
  }`}</style>
@@ -4753,7 +4815,7 @@ function FragmentComponent(props) {
4753
4815
  var fragment_default = FragmentComponent;
4754
4816
 
4755
4817
  // src/blocks/image/image.tsx
4756
- import { Show as Show7, onMount as onMount3, createMemo as createMemo8 } from "solid-js";
4818
+ import { Show as Show8, onMount as onMount4, createMemo as createMemo8 } from "solid-js";
4757
4819
 
4758
4820
  // src/blocks/image/image.helpers.ts
4759
4821
  function removeProtocol(path) {
@@ -4843,14 +4905,14 @@ function Image(props) {
4843
4905
  const out = props.aspectRatio ? aspectRatioStyles : void 0;
4844
4906
  return out;
4845
4907
  });
4846
- onMount3(() => {
4908
+ onMount4(() => {
4847
4909
  });
4848
4910
  return <>
4849
4911
  <>
4850
4912
  <picture>
4851
- <Show7 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show7>
4913
+ <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
4852
4914
  <img
4853
- class={"builder-image" + (props.className ? " " + props.className : "") + " img-4512e110"}
4915
+ class={"builder-image" + (props.className ? " " + props.className : "") + " img-7e6ffddc"}
4854
4916
  loading={props.highPriority ? "eager" : "lazy"}
4855
4917
  fetchpriority={props.highPriority ? "high" : "auto"}
4856
4918
  alt={props.altText}
@@ -4865,25 +4927,25 @@ function Image(props) {
4865
4927
  sizes={props.sizes}
4866
4928
  />
4867
4929
  </picture>
4868
- <Show7
4930
+ <Show8
4869
4931
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
4870
4932
  ><div
4871
- class="builder-image-sizer div-4512e110"
4933
+ class="builder-image-sizer div-7e6ffddc"
4872
4934
  style={{
4873
4935
  "padding-top": props.aspectRatio * 100 + "%"
4874
4936
  }}
4875
- /></Show7>
4876
- <Show7 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show7>
4877
- <Show7 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-4512e110-2">{props.children}</div></Show7>
4937
+ /></Show8>
4938
+ <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
4939
+ <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-7e6ffddc-2">{props.children}</div></Show8>
4878
4940
  </>
4879
- <style>{`.img-4512e110 {
4941
+ <style>{`.img-7e6ffddc {
4880
4942
  opacity: 1;
4881
4943
  transition: opacity 0.2s ease-in-out;
4882
- }.div-4512e110 {
4944
+ }.div-7e6ffddc {
4883
4945
  width: 100%;
4884
4946
  pointer-events: none;
4885
4947
  font-size: 0;
4886
- }.div-4512e110-2 {
4948
+ }.div-7e6ffddc-2 {
4887
4949
  display: flex;
4888
4950
  flex-direction: column;
4889
4951
  align-items: stretch;
@@ -4919,10 +4981,10 @@ function SectionComponent(props) {
4919
4981
  var section_default = SectionComponent;
4920
4982
 
4921
4983
  // src/blocks/symbol/symbol.tsx
4922
- import { onMount as onMount7, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
4984
+ import { onMount as onMount8, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
4923
4985
 
4924
4986
  // src/components/content-variants/content-variants.tsx
4925
- import { Show as Show14, For as For9, onMount as onMount6, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
4987
+ import { Show as Show15, For as For9, onMount as onMount7, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
4926
4988
 
4927
4989
  // src/helpers/url.ts
4928
4990
  var getTopLevelDomain = (host) => {
@@ -5116,7 +5178,7 @@ var handleABTesting = async ({
5116
5178
  var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
5117
5179
 
5118
5180
  // src/components/content/content.tsx
5119
- import { Show as Show13, createSignal as createSignal18 } from "solid-js";
5181
+ import { Show as Show14, createSignal as createSignal18 } from "solid-js";
5120
5182
 
5121
5183
  // src/blocks/accordion/component-info.ts
5122
5184
  var defaultTitle = {
@@ -5250,7 +5312,7 @@ var componentInfo = {
5250
5312
  };
5251
5313
 
5252
5314
  // src/blocks/accordion/accordion.tsx
5253
- import { Show as Show8, For as For5, createSignal as createSignal9, createMemo as createMemo9 } from "solid-js";
5315
+ import { Show as Show9, For as For5, createSignal as createSignal9, createMemo as createMemo9 } from "solid-js";
5254
5316
 
5255
5317
  // src/blocks/accordion/helpers.ts
5256
5318
  var convertOrderNumberToString = (order) => {
@@ -5384,7 +5446,7 @@ function Accordion(props) {
5384
5446
  registeredComponents={props.builderComponents}
5385
5447
  linkComponent={props.builderLinkComponent}
5386
5448
  /></div>
5387
- <Show8 when={open().includes(index)}><div
5449
+ <Show9 when={open().includes(index)}><div
5388
5450
  class={getAccordionDetailClassName(index)}
5389
5451
  style={accordionDetailStyles()}
5390
5452
  ><Blocks_default
@@ -5394,7 +5456,7 @@ function Accordion(props) {
5394
5456
  context={props.builderContext}
5395
5457
  registeredComponents={props.builderComponents}
5396
5458
  linkComponent={props.builderLinkComponent}
5397
- /></div></Show8>
5459
+ /></div></Show9>
5398
5460
  </>;
5399
5461
  }}</For5></div></>;
5400
5462
  }
@@ -6075,7 +6137,7 @@ var componentInfo9 = {
6075
6137
  };
6076
6138
 
6077
6139
  // src/blocks/tabs/tabs.tsx
6078
- import { Show as Show9, For as For6, createSignal as createSignal10 } from "solid-js";
6140
+ import { Show as Show10, For as For6, createSignal as createSignal10 } from "solid-js";
6079
6141
  function Tabs(props) {
6080
6142
  const [activeTab, setActiveTab] = createSignal10(
6081
6143
  props.defaultActiveTab ? props.defaultActiveTab - 1 : 0
@@ -6117,14 +6179,14 @@ function Tabs(props) {
6117
6179
  linkComponent={props.builderLinkComponent}
6118
6180
  /></span>;
6119
6181
  }}</For6></div>
6120
- <Show9 when={activeTabContent(activeTab())}><div><Blocks_default
6182
+ <Show10 when={activeTabContent(activeTab())}><div><Blocks_default
6121
6183
  parent={props.builderBlock.id}
6122
6184
  path={`component.options.tabs.${activeTab()}.content`}
6123
6185
  blocks={activeTabContent(activeTab())}
6124
6186
  context={props.builderContext}
6125
6187
  registeredComponents={props.builderComponents}
6126
6188
  linkComponent={props.builderLinkComponent}
6127
- /></div></Show9>
6189
+ /></div></Show10>
6128
6190
  </div></>;
6129
6191
  }
6130
6192
  var tabs_default = Tabs;
@@ -6213,12 +6275,12 @@ var componentInfo11 = {
6213
6275
  };
6214
6276
 
6215
6277
  // src/blocks/custom-code/custom-code.tsx
6216
- import { onMount as onMount4, createSignal as createSignal12 } from "solid-js";
6278
+ import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
6217
6279
  function CustomCode(props) {
6218
6280
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
6219
6281
  const [scriptsRun, setScriptsRun] = createSignal12([]);
6220
6282
  let elementRef;
6221
- onMount4(() => {
6283
+ onMount5(() => {
6222
6284
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
6223
6285
  return;
6224
6286
  }
@@ -6568,7 +6630,7 @@ var componentInfo13 = {
6568
6630
  };
6569
6631
 
6570
6632
  // src/blocks/form/form/form.tsx
6571
- import { Show as Show10, For as For7, createSignal as createSignal14 } from "solid-js";
6633
+ import { Show as Show11, For as For7, createSignal as createSignal14 } from "solid-js";
6572
6634
 
6573
6635
  // src/functions/get-env.ts
6574
6636
  var validEnvList = ["production", "qa", "test", "development", "dev", "cdn-qa", "cloud", "fast", "cdn2", "cdn-prod"];
@@ -6783,7 +6845,7 @@ function FormComponent(props) {
6783
6845
  {...{}}
6784
6846
  {...props.attributes}
6785
6847
  >
6786
- <Show10 when={props.builderBlock && props.builderBlock.children}><For7 each={props.builderBlock?.children}>{(block, _index) => {
6848
+ <Show11 when={props.builderBlock && props.builderBlock.children}><For7 each={props.builderBlock?.children}>{(block, _index) => {
6787
6849
  const idx = _index();
6788
6850
  return <Block_default
6789
6851
  key={`form-block-${idx}`}
@@ -6792,23 +6854,23 @@ function FormComponent(props) {
6792
6854
  registeredComponents={props.builderComponents}
6793
6855
  linkComponent={props.builderLinkComponent}
6794
6856
  />;
6795
- }}</For7></Show10>
6796
- <Show10 when={submissionState() === "error"}><Blocks_default
6857
+ }}</For7></Show11>
6858
+ <Show11 when={submissionState() === "error"}><Blocks_default
6797
6859
  path="errorMessage"
6798
6860
  blocks={props.errorMessage}
6799
6861
  context={props.builderContext}
6800
- /></Show10>
6801
- <Show10 when={submissionState() === "sending"}><Blocks_default
6862
+ /></Show11>
6863
+ <Show11 when={submissionState() === "sending"}><Blocks_default
6802
6864
  path="sendingMessage"
6803
6865
  blocks={props.sendingMessage}
6804
6866
  context={props.builderContext}
6805
- /></Show10>
6806
- <Show10 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-2e825338">{JSON.stringify(responseData(), null, 2)}</pre></Show10>
6807
- <Show10 when={submissionState() === "success"}><Blocks_default
6867
+ /></Show11>
6868
+ <Show11 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-2e825338">{JSON.stringify(responseData(), null, 2)}</pre></Show11>
6869
+ <Show11 when={submissionState() === "success"}><Blocks_default
6808
6870
  path="successMessage"
6809
6871
  blocks={props.successMessage}
6810
6872
  context={props.builderContext}
6811
- /></Show10>
6873
+ /></Show11>
6812
6874
  </form>
6813
6875
  <style>{`.pre-2e825338 {
6814
6876
  padding: 10px;
@@ -7160,7 +7222,7 @@ var componentInfo19 = {
7160
7222
  };
7161
7223
 
7162
7224
  // src/blocks/video/video.tsx
7163
- import { Show as Show11, createMemo as createMemo15 } from "solid-js";
7225
+ import { Show as Show12, createMemo as createMemo15 } from "solid-js";
7164
7226
  function Video(props) {
7165
7227
  const videoProps = createMemo15(() => {
7166
7228
  return {
@@ -7211,8 +7273,8 @@ function Video(props) {
7211
7273
  }}
7212
7274
  src={props.video || "no-src"}
7213
7275
  poster={props.posterImage}
7214
- ><Show11 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show11></video>
7215
- <Show11
7276
+ ><Show12 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show12></video>
7277
+ <Show12
7216
7278
  when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
7217
7279
  ><div
7218
7280
  style={{
@@ -7221,15 +7283,15 @@ function Video(props) {
7221
7283
  "pointer-events": "none",
7222
7284
  "font-size": "0px"
7223
7285
  }}
7224
- /></Show11>
7225
- <Show11 when={props.builderBlock?.children?.length && props.fitContent}><div
7286
+ /></Show12>
7287
+ <Show12 when={props.builderBlock?.children?.length && props.fitContent}><div
7226
7288
  style={{
7227
7289
  display: "flex",
7228
7290
  "flex-direction": "column",
7229
7291
  "align-items": "stretch"
7230
7292
  }}
7231
- >{props.children}</div></Show11>
7232
- <Show11 when={props.builderBlock?.children?.length && !props.fitContent}><div
7293
+ >{props.children}</div></Show12>
7294
+ <Show12 when={props.builderBlock?.children?.length && !props.fitContent}><div
7233
7295
  style={{
7234
7296
  "pointer-events": "none",
7235
7297
  display: "flex",
@@ -7241,7 +7303,7 @@ function Video(props) {
7241
7303
  width: "100%",
7242
7304
  height: "100%"
7243
7305
  }}
7244
- >{props.children}</div></Show11>
7306
+ >{props.children}</div></Show12>
7245
7307
  </div></>;
7246
7308
  }
7247
7309
  var video_default = Video;
@@ -7386,8 +7448,8 @@ var Inlined_script_default = InlinedScript;
7386
7448
 
7387
7449
  // src/components/content/components/enable-editor.tsx
7388
7450
  import {
7389
- Show as Show12,
7390
- onMount as onMount5,
7451
+ Show as Show13,
7452
+ onMount as onMount6,
7391
7453
  on as on3,
7392
7454
  createEffect as createEffect3,
7393
7455
  createMemo as createMemo16,
@@ -7894,7 +7956,7 @@ function isFromTrustedHost(trustedHosts, e) {
7894
7956
  }
7895
7957
 
7896
7958
  // src/constants/sdk-version.ts
7897
- var SDK_VERSION = "2.0.15";
7959
+ var SDK_VERSION = "2.0.21";
7898
7960
 
7899
7961
  // src/functions/register.ts
7900
7962
  var registry = {};
@@ -8247,22 +8309,6 @@ function EnableEditor(props) {
8247
8309
  }
8248
8310
  })(event);
8249
8311
  }
8250
- function evaluateJsCode() {
8251
- const jsCode = props.builderContextSignal.content?.data?.jsCode;
8252
- if (jsCode) {
8253
- evaluate({
8254
- code: jsCode,
8255
- context: props.context || {},
8256
- localState: void 0,
8257
- rootState: props.builderContextSignal.rootState,
8258
- rootSetState: props.builderContextSignal.rootSetState,
8259
- /**
8260
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8261
- */
8262
- enableCache: false
8263
- });
8264
- }
8265
- }
8266
8312
  function onClick(event) {
8267
8313
  if (props.builderContextSignal.content) {
8268
8314
  const variationId = props.builderContextSignal.content?.testVariationId;
@@ -8304,7 +8350,7 @@ function EnableEditor(props) {
8304
8350
  })
8305
8351
  )
8306
8352
  );
8307
- fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
8353
+ fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
8308
8354
  mergeNewRootState({
8309
8355
  [key]: json
8310
8356
  });
@@ -8334,7 +8380,9 @@ function EnableEditor(props) {
8334
8380
  }
8335
8381
  }
8336
8382
  let elementRef;
8337
- onMount5(() => {
8383
+ runHttpRequests();
8384
+ emitStateUpdate();
8385
+ onMount6(() => {
8338
8386
  if (isBrowser()) {
8339
8387
  if (isEditing()) {
8340
8388
  window.addEventListener("message", processMessage);
@@ -8395,16 +8443,6 @@ function EnableEditor(props) {
8395
8443
  }
8396
8444
  }
8397
8445
  });
8398
- onMount5(() => {
8399
- if (!props.apiKey) {
8400
- logger.error(
8401
- "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
8402
- );
8403
- }
8404
- evaluateJsCode();
8405
- runHttpRequests();
8406
- emitStateUpdate();
8407
- });
8408
8446
  const onUpdateFn_0_props_content = createMemo16(() => props.content);
8409
8447
  function onUpdateFn_0() {
8410
8448
  if (props.content) {
@@ -8412,57 +8450,35 @@ function EnableEditor(props) {
8412
8450
  }
8413
8451
  }
8414
8452
  createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
8415
- const onUpdateFn_1_props_builderContextSignal_content__data__jsCode = createMemo16(() => props.builderContextSignal.content?.data?.jsCode);
8416
- function onUpdateFn_1() {
8417
- evaluateJsCode();
8418
- }
8419
- createEffect3(
8420
- on3(
8421
- () => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()],
8422
- onUpdateFn_1
8423
- )
8424
- );
8425
- const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo16(() => props.builderContextSignal.content?.data?.httpRequests);
8426
- function onUpdateFn_2() {
8427
- runHttpRequests();
8428
- }
8429
- createEffect3(
8430
- on3(
8431
- () => [
8432
- onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()
8433
- ],
8434
- onUpdateFn_2
8435
- )
8436
- );
8437
- const onUpdateFn_3_props_builderContextSignal_rootState = createMemo16(
8453
+ const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
8438
8454
  () => props.builderContextSignal.rootState
8439
8455
  );
8440
- function onUpdateFn_3() {
8456
+ function onUpdateFn_1() {
8441
8457
  emitStateUpdate();
8442
8458
  }
8443
8459
  createEffect3(
8444
8460
  on3(
8445
- () => [onUpdateFn_3_props_builderContextSignal_rootState()],
8446
- onUpdateFn_3
8461
+ () => [onUpdateFn_1_props_builderContextSignal_rootState()],
8462
+ onUpdateFn_1
8447
8463
  )
8448
8464
  );
8449
- const onUpdateFn_4_props_data = createMemo16(() => props.data);
8450
- function onUpdateFn_4() {
8465
+ const onUpdateFn_2_props_data = createMemo16(() => props.data);
8466
+ function onUpdateFn_2() {
8451
8467
  if (props.data) {
8452
8468
  mergeNewRootState(props.data);
8453
8469
  }
8454
8470
  }
8455
- createEffect3(on3(() => [onUpdateFn_4_props_data()], onUpdateFn_4));
8456
- const onUpdateFn_5_props_locale = createMemo16(() => props.locale);
8457
- function onUpdateFn_5() {
8471
+ createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
8472
+ const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
8473
+ function onUpdateFn_3() {
8458
8474
  if (props.locale) {
8459
8475
  mergeNewRootState({
8460
8476
  locale: props.locale
8461
8477
  });
8462
8478
  }
8463
8479
  }
8464
- createEffect3(on3(() => [onUpdateFn_5_props_locale()], onUpdateFn_5));
8465
- return <><builder_context_default.Provider value={props.builderContextSignal}><Show12 when={props.builderContextSignal.content}><Dynamic5
8480
+ createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
8481
+ return <><builder_context_default.Provider value={props.builderContextSignal}><Show13 when={props.builderContextSignal.content}><Dynamic5
8466
8482
  class={getWrapperClassName(
8467
8483
  props.content?.testVariationId || props.content?.id
8468
8484
  )}
@@ -8475,7 +8491,7 @@ function EnableEditor(props) {
8475
8491
  {...showContentProps()}
8476
8492
  {...props.contentWrapperProps}
8477
8493
  component={ContentWrapper()}
8478
- >{props.children}</Dynamic5></Show12></builder_context_default.Provider></>;
8494
+ >{props.children}</Dynamic5></Show13></builder_context_default.Provider></>;
8479
8495
  }
8480
8496
  var Enable_editor_default = EnableEditor;
8481
8497
 
@@ -8612,6 +8628,31 @@ function ContentComponent(props) {
8612
8628
  rootState: newRootState
8613
8629
  }));
8614
8630
  }
8631
+ if (!props.apiKey) {
8632
+ logger.error(
8633
+ "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
8634
+ );
8635
+ }
8636
+ const jsCode = builderContextSignal().content?.data?.jsCode;
8637
+ if (jsCode) {
8638
+ evaluate({
8639
+ code: jsCode,
8640
+ context: props.context || {},
8641
+ localState: void 0,
8642
+ rootState: builderContextSignal().rootState,
8643
+ rootSetState: (newState) => {
8644
+ setBuilderContextSignal((PREVIOUS_VALUE) => ({
8645
+ ...PREVIOUS_VALUE,
8646
+ rootState: newState
8647
+ }));
8648
+ },
8649
+ isExpression: false,
8650
+ /**
8651
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8652
+ */
8653
+ enableCache: false
8654
+ });
8655
+ }
8615
8656
  return <><components_context_default.Provider
8616
8657
  value={{
8617
8658
  registeredComponents: registeredComponents()
@@ -8635,18 +8676,18 @@ function ContentComponent(props) {
8635
8676
  setBuilderContextSignal
8636
8677
  }}
8637
8678
  >
8638
- <Show13 when={props.isSsrAbTest}><Inlined_script_default
8679
+ <Show14 when={props.isSsrAbTest}><Inlined_script_default
8639
8680
  id="builderio-variant-visibility"
8640
8681
  scriptStr={scriptStr()}
8641
8682
  nonce={props.nonce || ""}
8642
- /></Show13>
8643
- <Show13 when={TARGET !== "reactNative"}><Styles_default
8683
+ /></Show14>
8684
+ <Show14 when={TARGET !== "reactNative"}><Styles_default
8644
8685
  nonce={props.nonce || ""}
8645
8686
  isNestedRender={props.isNestedRender}
8646
8687
  contentId={builderContextSignal().content?.id}
8647
8688
  cssCode={builderContextSignal().content?.data?.cssCode}
8648
8689
  customFonts={builderContextSignal().content?.data?.customFonts}
8649
- /></Show13>
8690
+ /></Show14>
8650
8691
  <Blocks_default
8651
8692
  blocks={builderContextSignal().content?.data?.blocks}
8652
8693
  context={builderContextSignal()}
@@ -8686,16 +8727,16 @@ function ContentVariants(props) {
8686
8727
  canTrack: getDefaultCanTrack(props.canTrack)
8687
8728
  });
8688
8729
  });
8689
- onMount6(() => {
8730
+ onMount7(() => {
8690
8731
  setShouldRenderVariants(false);
8691
8732
  });
8692
8733
  return <><>
8693
- <Show14 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
8734
+ <Show15 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
8694
8735
  id="builderio-init-variants-fns"
8695
8736
  scriptStr={getInitVariantsFnsScriptString()}
8696
8737
  nonce={props.nonce || ""}
8697
- /></Show14>
8698
- <Show14 when={shouldRenderVariants()}>
8738
+ /></Show15>
8739
+ <Show15 when={shouldRenderVariants()}>
8699
8740
  <Inlined_styles_default
8700
8741
  id="builderio-variants"
8701
8742
  styles={hideVariantsStyleString()}
@@ -8733,7 +8774,7 @@ function ContentVariants(props) {
8733
8774
  {...{}}
8734
8775
  />;
8735
8776
  }}</For9>
8736
- </Show14>
8777
+ </Show15>
8737
8778
  <Content_default
8738
8779
  nonce={props.nonce}
8739
8780
  isNestedRender={props.isNestedRender}
@@ -8814,7 +8855,7 @@ function Symbol2(props) {
8814
8855
  }
8815
8856
  });
8816
8857
  }
8817
- onMount7(() => {
8858
+ onMount8(() => {
8818
8859
  });
8819
8860
  const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
8820
8861
  function onUpdateFn_0() {