@builder.io/sdk-solid 2.0.9 → 2.0.13

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.js CHANGED
@@ -132,6 +132,15 @@ function getBlockComponentOptions(block) {
132
132
  };
133
133
  }
134
134
 
135
+ // src/helpers/omit.ts
136
+ function omit(obj, ...values) {
137
+ const newObject = Object.assign({}, obj);
138
+ for (const key of values) {
139
+ delete newObject[key];
140
+ }
141
+ return newObject;
142
+ }
143
+
135
144
  // src/helpers/logger.ts
136
145
  var MSG_PREFIX = "[Builder.io]: ";
137
146
  var logger = {
@@ -3490,6 +3499,7 @@ var shouldForceBrowserRuntimeInNode = () => {
3490
3499
  var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
3491
3500
 
3492
3501
  // src/functions/evaluate/evaluate.ts
3502
+ var DISABLE_CACHE = true;
3493
3503
  var EvalCache = class _EvalCache {
3494
3504
  static cacheLimit = 20;
3495
3505
  static cache = /* @__PURE__ */ new Map();
@@ -3538,7 +3548,7 @@ function evaluate({
3538
3548
  rootState,
3539
3549
  localState
3540
3550
  };
3541
- if (enableCache) {
3551
+ if (enableCache && !DISABLE_CACHE) {
3542
3552
  const cacheKey = EvalCache.getCacheKey(args);
3543
3553
  const cachedValue = EvalCache.getCachedValue(cacheKey);
3544
3554
  if (cachedValue) {
@@ -3569,6 +3579,53 @@ function transformBlock(block) {
3569
3579
  }
3570
3580
 
3571
3581
  // src/functions/get-processed-block.ts
3582
+ function deepCloneWithConditions(obj) {
3583
+ if (obj === null || typeof obj !== "object") {
3584
+ return obj;
3585
+ }
3586
+ if (Array.isArray(obj)) {
3587
+ return obj.map((item) => deepCloneWithConditions(item));
3588
+ }
3589
+ if (obj["@type"] === "@builder.io/sdk:Element") {
3590
+ return obj;
3591
+ }
3592
+ const clonedObj = {};
3593
+ for (const key in obj) {
3594
+ if (key !== "meta" && Object.prototype.hasOwnProperty.call(obj, key)) {
3595
+ clonedObj[key] = deepCloneWithConditions(obj[key]);
3596
+ }
3597
+ }
3598
+ return clonedObj;
3599
+ }
3600
+ var IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK = ["svelte", "vue", "angular", "qwik", "solid"].includes(TARGET);
3601
+ var getCopy = (block) => {
3602
+ if (IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK) {
3603
+ const copy = fastClone(block);
3604
+ const copied = {
3605
+ ...copy,
3606
+ properties: {
3607
+ ...copy.properties
3608
+ },
3609
+ actions: {
3610
+ ...copy.actions
3611
+ }
3612
+ };
3613
+ return copied;
3614
+ } else {
3615
+ const copy = deepCloneWithConditions(omit(block, "children", "meta"));
3616
+ return {
3617
+ ...copy,
3618
+ properties: {
3619
+ ...copy.properties
3620
+ },
3621
+ actions: {
3622
+ ...copy.actions
3623
+ },
3624
+ children: block.children,
3625
+ meta: block.meta
3626
+ };
3627
+ }
3628
+ };
3572
3629
  var evaluateBindings = ({
3573
3630
  block,
3574
3631
  context,
@@ -3579,16 +3636,7 @@ var evaluateBindings = ({
3579
3636
  if (!block.bindings) {
3580
3637
  return block;
3581
3638
  }
3582
- const copy = fastClone(block);
3583
- const copied = {
3584
- ...copy,
3585
- properties: {
3586
- ...copy.properties
3587
- },
3588
- actions: {
3589
- ...copy.actions
3590
- }
3591
- };
3639
+ const copied = getCopy(block);
3592
3640
  for (const binding in block.bindings) {
3593
3641
  const expression = block.bindings[binding];
3594
3642
  const value = evaluate({
@@ -3871,17 +3919,9 @@ function mapStyleObjToStrIfNeeded(style) {
3871
3919
  // src/components/block/block.helpers.ts
3872
3920
  var getComponent = ({
3873
3921
  block,
3874
- context,
3875
3922
  registeredComponents
3876
3923
  }) => {
3877
- const componentName = getProcessedBlock({
3878
- block,
3879
- localState: context.localState,
3880
- rootState: context.rootState,
3881
- rootSetState: context.rootSetState,
3882
- context: context.context,
3883
- shouldEvaluateBindings: false
3884
- }).component?.name;
3924
+ const componentName = block.component?.name;
3885
3925
  if (!componentName) {
3886
3926
  return null;
3887
3927
  }
@@ -4034,14 +4074,7 @@ var inlined_styles_default = InlinedStyles;
4034
4074
  // src/components/block/components/block-styles.tsx
4035
4075
  function BlockStyles(props) {
4036
4076
  const canShowBlock = createMemo(() => {
4037
- const processedBlock = getProcessedBlock({
4038
- block: props.block,
4039
- localState: props.context.localState,
4040
- rootState: props.context.rootState,
4041
- rootSetState: props.context.rootSetState,
4042
- context: props.context.context,
4043
- shouldEvaluateBindings: true
4044
- });
4077
+ const processedBlock = props.block;
4045
4078
  if (checkIsDefined(processedBlock.hide)) {
4046
4079
  return !processedBlock.hide;
4047
4080
  }
@@ -4051,14 +4084,7 @@ function BlockStyles(props) {
4051
4084
  return true;
4052
4085
  });
4053
4086
  const css = createMemo(() => {
4054
- const processedBlock = getProcessedBlock({
4055
- block: props.block,
4056
- localState: props.context.localState,
4057
- rootState: props.context.rootState,
4058
- rootSetState: props.context.rootSetState,
4059
- context: props.context.context,
4060
- shouldEvaluateBindings: true
4061
- });
4087
+ const processedBlock = props.block;
4062
4088
  const styles = processedBlock.responsiveStyles;
4063
4089
  const content = props.context.content;
4064
4090
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
@@ -4364,12 +4390,9 @@ var repeated_block_default = RepeatedBlock;
4364
4390
 
4365
4391
  // src/components/block/block.tsx
4366
4392
  function Block(props) {
4367
- const blockComponent = createMemo(() => {
4368
- return getComponent({
4369
- block: props.block,
4370
- context: props.context,
4371
- registeredComponents: props.registeredComponents
4372
- });
4393
+ createSignal({
4394
+ value: null,
4395
+ update: false
4373
4396
  });
4374
4397
  const repeatItem = createMemo(() => {
4375
4398
  return getRepeatItemData({
@@ -4378,7 +4401,7 @@ function Block(props) {
4378
4401
  });
4379
4402
  });
4380
4403
  const processedBlock = createMemo(() => {
4381
- return props.block.repeat?.collection ? props.block : getProcessedBlock({
4404
+ const blockToUse = props.block.repeat?.collection ? props.block : getProcessedBlock({
4382
4405
  block: props.block,
4383
4406
  localState: props.context.localState,
4384
4407
  rootState: props.context.rootState,
@@ -4386,6 +4409,13 @@ function Block(props) {
4386
4409
  context: props.context.context,
4387
4410
  shouldEvaluateBindings: true
4388
4411
  });
4412
+ return blockToUse;
4413
+ });
4414
+ const blockComponent = createMemo(() => {
4415
+ return getComponent({
4416
+ block: processedBlock(),
4417
+ registeredComponents: props.registeredComponents
4418
+ });
4389
4419
  });
4390
4420
  const Tag = createMemo(() => {
4391
4421
  const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
@@ -4444,40 +4474,72 @@ function Block(props) {
4444
4474
  get children() {
4445
4475
  return [createComponent(block_styles_default, {
4446
4476
  get block() {
4447
- return props.block;
4477
+ return processedBlock();
4448
4478
  },
4449
4479
  get context() {
4450
4480
  return props.context;
4451
4481
  }
4452
4482
  }), createComponent(Show, {
4453
4483
  get fallback() {
4454
- return createComponent(component_ref_default, {
4455
- get componentRef() {
4456
- return componentRefProps().componentRef;
4457
- },
4458
- get componentOptions() {
4459
- return componentRefProps().componentOptions;
4460
- },
4461
- get blockChildren() {
4462
- return componentRefProps().blockChildren;
4463
- },
4464
- get context() {
4465
- return componentRefProps().context;
4466
- },
4467
- get registeredComponents() {
4468
- return componentRefProps().registeredComponents;
4469
- },
4470
- get linkComponent() {
4471
- return componentRefProps().linkComponent;
4472
- },
4473
- get builderBlock() {
4474
- return componentRefProps().builderBlock;
4484
+ return createComponent(Show, {
4485
+ get fallback() {
4486
+ return createComponent(For, {
4487
+ get each() {
4488
+ return repeatItem();
4489
+ },
4490
+ children: (data, _index) => {
4491
+ const index = _index();
4492
+ return createComponent(repeated_block_default, {
4493
+ key: index,
4494
+ get repeatContext() {
4495
+ return data.context;
4496
+ },
4497
+ get block() {
4498
+ return data.block;
4499
+ },
4500
+ get registeredComponents() {
4501
+ return props.registeredComponents;
4502
+ },
4503
+ get linkComponent() {
4504
+ return props.linkComponent;
4505
+ }
4506
+ });
4507
+ }
4508
+ });
4475
4509
  },
4476
- get includeBlockProps() {
4477
- return componentRefProps().includeBlockProps;
4510
+ get when() {
4511
+ return !repeatItem();
4478
4512
  },
4479
- get isInteractive() {
4480
- return componentRefProps().isInteractive;
4513
+ get children() {
4514
+ return createComponent(component_ref_default, {
4515
+ get componentRef() {
4516
+ return componentRefProps().componentRef;
4517
+ },
4518
+ get componentOptions() {
4519
+ return componentRefProps().componentOptions;
4520
+ },
4521
+ get blockChildren() {
4522
+ return componentRefProps().blockChildren;
4523
+ },
4524
+ get context() {
4525
+ return componentRefProps().context;
4526
+ },
4527
+ get registeredComponents() {
4528
+ return componentRefProps().registeredComponents;
4529
+ },
4530
+ get linkComponent() {
4531
+ return componentRefProps().linkComponent;
4532
+ },
4533
+ get builderBlock() {
4534
+ return componentRefProps().builderBlock;
4535
+ },
4536
+ get includeBlockProps() {
4537
+ return componentRefProps().includeBlockProps;
4538
+ },
4539
+ get isInteractive() {
4540
+ return componentRefProps().isInteractive;
4541
+ }
4542
+ });
4481
4543
  }
4482
4544
  });
4483
4545
  },
@@ -4587,7 +4649,7 @@ function Block(props) {
4587
4649
  });
4588
4650
  }
4589
4651
  var block_default = Block;
4590
- var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-1bb6a3a2 {
4652
+ var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-4da8c6f4 {
4591
4653
  display: flex;
4592
4654
  flex-direction: column;
4593
4655
  align-items: stretch;
@@ -4618,9 +4680,16 @@ function BlocksWrapper(props) {
4618
4680
  }, "*");
4619
4681
  }
4620
4682
  }
4683
+ let blocksWrapperRef;
4684
+ onMount(() => {
4685
+ });
4621
4686
  return [createComponent(Dynamic, mergeProps({
4622
4687
  get ["class"]() {
4623
- return className() + " dynamic-1bb6a3a2";
4688
+ return className() + " dynamic-4da8c6f4";
4689
+ },
4690
+ ref(r$) {
4691
+ const _ref$ = blocksWrapperRef;
4692
+ typeof _ref$ === "function" ? _ref$(r$) : blocksWrapperRef = r$;
4624
4693
  },
4625
4694
  get ["builder-path"]() {
4626
4695
  return props.path;
@@ -6084,7 +6153,8 @@ var componentInfo7 = {
6084
6153
  defaultValue: "children"
6085
6154
  }],
6086
6155
  shouldReceiveBuilderProps: {
6087
- builderContext: true
6156
+ builderContext: true,
6157
+ builderComponents: true
6088
6158
  }
6089
6159
  };
6090
6160
  var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
@@ -6105,6 +6175,9 @@ function Slot(props) {
6105
6175
  get context() {
6106
6176
  return props.builderContext;
6107
6177
  },
6178
+ get registeredComponents() {
6179
+ return props.builderComponents;
6180
+ },
6108
6181
  get blocks() {
6109
6182
  return props.builderContext.rootState?.[props.name];
6110
6183
  }
@@ -7922,7 +7995,7 @@ var generateContentUrl = (options) => {
7922
7995
  locale,
7923
7996
  apiVersion = DEFAULT_API_VERSION,
7924
7997
  fields,
7925
- omit,
7998
+ omit: omit2,
7926
7999
  offset,
7927
8000
  cacheSeconds,
7928
8001
  staleCacheSeconds,
@@ -7945,7 +8018,7 @@ var generateContentUrl = (options) => {
7945
8018
  url.searchParams.set("locale", locale);
7946
8019
  if (enrich)
7947
8020
  url.searchParams.set("enrich", String(enrich));
7948
- url.searchParams.set("omit", omit || "meta.componentsUsed");
8021
+ url.searchParams.set("omit", omit2 || "meta.componentsUsed");
7949
8022
  if (fields) {
7950
8023
  url.searchParams.set("fields", fields);
7951
8024
  }
@@ -8318,7 +8391,7 @@ function isFromTrustedHost(trustedHosts, e) {
8318
8391
  }
8319
8392
 
8320
8393
  // src/constants/sdk-version.ts
8321
- var SDK_VERSION = "2.0.9";
8394
+ var SDK_VERSION = "2.0.13";
8322
8395
 
8323
8396
  // src/functions/register.ts
8324
8397
  var registry = {};