@builder.io/sdk-solid 2.0.9 → 2.0.15

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.
@@ -103,7 +103,13 @@ import { createContext as createContext2 } from "solid-js";
103
103
  var components_context_default = createContext2({ registeredComponents: {} });
104
104
 
105
105
  // src/components/block/block.tsx
106
- import { Show as Show4, For as For2, onMount, createMemo as createMemo5 } from "solid-js";
106
+ import {
107
+ Show as Show4,
108
+ For as For2,
109
+ onMount,
110
+ createMemo as createMemo5,
111
+ createSignal as createSignal5
112
+ } from "solid-js";
107
113
 
108
114
  // src/functions/get-block-component-options.ts
109
115
  function getBlockComponentOptions(block) {
@@ -113,6 +119,15 @@ function getBlockComponentOptions(block) {
113
119
  };
114
120
  }
115
121
 
122
+ // src/helpers/omit.ts
123
+ function omit(obj, ...values) {
124
+ const newObject = Object.assign({}, obj);
125
+ for (const key of values) {
126
+ delete newObject[key];
127
+ }
128
+ return newObject;
129
+ }
130
+
116
131
  // src/helpers/logger.ts
117
132
  var logger = {
118
133
  log: (...message) => void 0,
@@ -319,6 +334,7 @@ var shouldForceBrowserRuntimeInNode = () => {
319
334
  var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
320
335
 
321
336
  // src/functions/evaluate/evaluate.ts
337
+ var DISABLE_CACHE = true;
322
338
  var EvalCache = class _EvalCache {
323
339
  static cacheLimit = 20;
324
340
  static cache = /* @__PURE__ */ new Map();
@@ -367,7 +383,7 @@ function evaluate({
367
383
  rootState,
368
384
  localState
369
385
  };
370
- if (enableCache) {
386
+ if (enableCache && !DISABLE_CACHE) {
371
387
  const cacheKey = EvalCache.getCacheKey(args);
372
388
  const cachedValue = EvalCache.getCachedValue(cacheKey);
373
389
  if (cachedValue) {
@@ -408,6 +424,53 @@ function transformBlock(block) {
408
424
  }
409
425
 
410
426
  // src/functions/get-processed-block.ts
427
+ function deepCloneWithConditions(obj) {
428
+ if (obj === null || typeof obj !== "object") {
429
+ return obj;
430
+ }
431
+ if (Array.isArray(obj)) {
432
+ return obj.map((item) => deepCloneWithConditions(item));
433
+ }
434
+ if (obj["@type"] === "@builder.io/sdk:Element") {
435
+ return obj;
436
+ }
437
+ const clonedObj = {};
438
+ for (const key in obj) {
439
+ if (key !== "meta" && Object.prototype.hasOwnProperty.call(obj, key)) {
440
+ clonedObj[key] = deepCloneWithConditions(obj[key]);
441
+ }
442
+ }
443
+ return clonedObj;
444
+ }
445
+ var IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK = ["svelte", "vue", "angular", "qwik", "solid"].includes(TARGET);
446
+ var getCopy = (block) => {
447
+ if (IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK) {
448
+ const copy = fastClone(block);
449
+ const copied = {
450
+ ...copy,
451
+ properties: {
452
+ ...copy.properties
453
+ },
454
+ actions: {
455
+ ...copy.actions
456
+ }
457
+ };
458
+ return copied;
459
+ } else {
460
+ const copy = deepCloneWithConditions(omit(block, "children", "meta"));
461
+ return {
462
+ ...copy,
463
+ properties: {
464
+ ...copy.properties
465
+ },
466
+ actions: {
467
+ ...copy.actions
468
+ },
469
+ children: block.children,
470
+ meta: block.meta
471
+ };
472
+ }
473
+ };
411
474
  var evaluateBindings = ({
412
475
  block,
413
476
  context,
@@ -418,16 +481,7 @@ var evaluateBindings = ({
418
481
  if (!block.bindings) {
419
482
  return block;
420
483
  }
421
- const copy = fastClone(block);
422
- const copied = {
423
- ...copy,
424
- properties: {
425
- ...copy.properties
426
- },
427
- actions: {
428
- ...copy.actions
429
- }
430
- };
484
+ const copied = getCopy(block);
431
485
  for (const binding in block.bindings) {
432
486
  const expression = block.bindings[binding];
433
487
  const value = evaluate({
@@ -709,17 +763,9 @@ function mapStyleObjToStrIfNeeded(style) {
709
763
  // src/components/block/block.helpers.ts
710
764
  var getComponent = ({
711
765
  block,
712
- context,
713
766
  registeredComponents
714
767
  }) => {
715
- const componentName = getProcessedBlock({
716
- block,
717
- localState: context.localState,
718
- rootState: context.rootState,
719
- rootSetState: context.rootSetState,
720
- context: context.context,
721
- shouldEvaluateBindings: false
722
- }).component?.name;
768
+ const componentName = block.component?.name;
723
769
  if (!componentName) {
724
770
  return null;
725
771
  }
@@ -863,14 +909,7 @@ var Inlined_styles_default = InlinedStyles;
863
909
  // src/components/block/components/block-styles.tsx
864
910
  function BlockStyles(props) {
865
911
  const canShowBlock = createMemo(() => {
866
- const processedBlock = getProcessedBlock({
867
- block: props.block,
868
- localState: props.context.localState,
869
- rootState: props.context.rootState,
870
- rootSetState: props.context.rootSetState,
871
- context: props.context.context,
872
- shouldEvaluateBindings: true
873
- });
912
+ const processedBlock = props.block;
874
913
  if (checkIsDefined(processedBlock.hide)) {
875
914
  return !processedBlock.hide;
876
915
  }
@@ -880,14 +919,7 @@ function BlockStyles(props) {
880
919
  return true;
881
920
  });
882
921
  const css = createMemo(() => {
883
- const processedBlock = getProcessedBlock({
884
- block: props.block,
885
- localState: props.context.localState,
886
- rootState: props.context.rootState,
887
- rootSetState: props.context.rootSetState,
888
- context: props.context.context,
889
- shouldEvaluateBindings: true
890
- });
922
+ const processedBlock = props.block;
891
923
  const styles = processedBlock.responsiveStyles;
892
924
  const content = props.context.content;
893
925
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
@@ -1156,12 +1188,9 @@ var Repeated_block_default = RepeatedBlock;
1156
1188
 
1157
1189
  // src/components/block/block.tsx
1158
1190
  function Block(props) {
1159
- const blockComponent = createMemo5(() => {
1160
- return getComponent({
1161
- block: props.block,
1162
- context: props.context,
1163
- registeredComponents: props.registeredComponents
1164
- });
1191
+ const [_processedBlock, set_processedBlock] = createSignal5({
1192
+ value: null,
1193
+ update: false
1165
1194
  });
1166
1195
  const repeatItem = createMemo5(() => {
1167
1196
  return getRepeatItemData({
@@ -1170,7 +1199,7 @@ function Block(props) {
1170
1199
  });
1171
1200
  });
1172
1201
  const processedBlock = createMemo5(() => {
1173
- return props.block.repeat?.collection ? props.block : getProcessedBlock({
1202
+ const blockToUse = props.block.repeat?.collection ? props.block : getProcessedBlock({
1174
1203
  block: props.block,
1175
1204
  localState: props.context.localState,
1176
1205
  rootState: props.context.rootState,
@@ -1178,6 +1207,13 @@ function Block(props) {
1178
1207
  context: props.context.context,
1179
1208
  shouldEvaluateBindings: true
1180
1209
  });
1210
+ return blockToUse;
1211
+ });
1212
+ const blockComponent = createMemo5(() => {
1213
+ return getComponent({
1214
+ block: processedBlock(),
1215
+ registeredComponents: props.registeredComponents
1216
+ });
1181
1217
  });
1182
1218
  const Tag = createMemo5(() => {
1183
1219
  const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
@@ -1235,9 +1271,24 @@ function Block(props) {
1235
1271
  }
1236
1272
  });
1237
1273
  return <><Show4 when={canShowBlock()}>
1238
- <Block_styles_default block={props.block} context={props.context} />
1274
+ <Block_styles_default
1275
+ block={processedBlock()}
1276
+ context={props.context}
1277
+ />
1239
1278
  <Show4
1240
- fallback={<Component_ref_default
1279
+ fallback={<Show4
1280
+ fallback={<For2 each={repeatItem()}>{(data, _index) => {
1281
+ const index = _index();
1282
+ return <Repeated_block_default
1283
+ key={index}
1284
+ repeatContext={data.context}
1285
+ block={data.block}
1286
+ registeredComponents={props.registeredComponents}
1287
+ linkComponent={props.linkComponent}
1288
+ />;
1289
+ }}</For2>}
1290
+ when={!repeatItem()}
1291
+ ><Component_ref_default
1241
1292
  componentRef={componentRefProps().componentRef}
1242
1293
  componentOptions={componentRefProps().componentOptions}
1243
1294
  blockChildren={componentRefProps().blockChildren}
@@ -1247,7 +1298,7 @@ function Block(props) {
1247
1298
  builderBlock={componentRefProps().builderBlock}
1248
1299
  includeBlockProps={componentRefProps().includeBlockProps}
1249
1300
  isInteractive={componentRefProps().isInteractive}
1250
- />}
1301
+ /></Show4>}
1251
1302
  when={!blockComponent()?.noWrap}
1252
1303
  ><Show4
1253
1304
  fallback={<For2 each={repeatItem()}>{(data, _index) => {
@@ -1293,7 +1344,7 @@ function Block(props) {
1293
1344
  var Block_default = Block;
1294
1345
 
1295
1346
  // src/components/blocks/blocks-wrapper.tsx
1296
- import { createMemo as createMemo6 } from "solid-js";
1347
+ import { onMount as onMount2, createMemo as createMemo6 } from "solid-js";
1297
1348
  import { Dynamic as Dynamic4 } from "solid-js/web";
1298
1349
  function BlocksWrapper(props) {
1299
1350
  const className = createMemo6(() => {
@@ -1327,9 +1378,13 @@ function BlocksWrapper(props) {
1327
1378
  );
1328
1379
  }
1329
1380
  }
1381
+ let blocksWrapperRef;
1382
+ onMount2(() => {
1383
+ });
1330
1384
  return <>
1331
1385
  <Dynamic4
1332
- class={className() + " dynamic-1bb6a3a2"}
1386
+ class={className() + " dynamic-4da8c6f4"}
1387
+ ref={blocksWrapperRef}
1333
1388
  builder-path={props.path}
1334
1389
  builder-parent-id={props.parent}
1335
1390
  {...{}}
@@ -1340,7 +1395,7 @@ function BlocksWrapper(props) {
1340
1395
  {...props.BlocksWrapperProps}
1341
1396
  component={props.BlocksWrapper}
1342
1397
  >{props.children}</Dynamic4>
1343
- <style>{`.dynamic-1bb6a3a2 {
1398
+ <style>{`.dynamic-4da8c6f4 {
1344
1399
  display: flex;
1345
1400
  flex-direction: column;
1346
1401
  align-items: stretch;
@@ -1544,7 +1599,7 @@ function FragmentComponent(props) {
1544
1599
  var fragment_default = FragmentComponent;
1545
1600
 
1546
1601
  // src/blocks/image/image.tsx
1547
- import { Show as Show7, onMount as onMount2, createMemo as createMemo8 } from "solid-js";
1602
+ import { Show as Show7, onMount as onMount3, createMemo as createMemo8 } from "solid-js";
1548
1603
 
1549
1604
  // src/blocks/image/image.helpers.ts
1550
1605
  function removeProtocol(path) {
@@ -1633,7 +1688,7 @@ function Image(props) {
1633
1688
  const out = props.aspectRatio ? aspectRatioStyles : void 0;
1634
1689
  return out;
1635
1690
  });
1636
- onMount2(() => {
1691
+ onMount3(() => {
1637
1692
  });
1638
1693
  return <>
1639
1694
  <>
@@ -1709,10 +1764,10 @@ function SectionComponent(props) {
1709
1764
  var section_default = SectionComponent;
1710
1765
 
1711
1766
  // src/blocks/symbol/symbol.tsx
1712
- import { onMount as onMount6, on as on3, createEffect as createEffect3, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1767
+ import { onMount as onMount7, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1713
1768
 
1714
1769
  // src/components/content-variants/content-variants.tsx
1715
- import { Show as Show14, For as For9, onMount as onMount5, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
1770
+ import { Show as Show14, For as For9, onMount as onMount6, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
1716
1771
 
1717
1772
  // src/helpers/url.ts
1718
1773
  var getTopLevelDomain = (host) => {
@@ -2651,7 +2706,8 @@ var componentInfo7 = {
2651
2706
  defaultValue: "children"
2652
2707
  }],
2653
2708
  shouldReceiveBuilderProps: {
2654
- builderContext: true
2709
+ builderContext: true,
2710
+ builderComponents: true
2655
2711
  }
2656
2712
  };
2657
2713
 
@@ -2668,6 +2724,7 @@ function Slot(props) {
2668
2724
  parent={props.builderContext.context?.symbolId}
2669
2725
  path={`symbol.data.${props.name}`}
2670
2726
  context={props.builderContext}
2727
+ registeredComponents={props.builderComponents}
2671
2728
  blocks={props.builderContext.rootState?.[props.name]}
2672
2729
  /></div></>;
2673
2730
  }
@@ -3000,12 +3057,12 @@ var componentInfo11 = {
3000
3057
  };
3001
3058
 
3002
3059
  // src/blocks/custom-code/custom-code.tsx
3003
- import { onMount as onMount3, createSignal as createSignal12 } from "solid-js";
3060
+ import { onMount as onMount4, createSignal as createSignal12 } from "solid-js";
3004
3061
  function CustomCode(props) {
3005
3062
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3006
3063
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3007
3064
  let elementRef;
3008
- onMount3(() => {
3065
+ onMount4(() => {
3009
3066
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3010
3067
  return;
3011
3068
  }
@@ -3064,7 +3121,7 @@ var componentInfo12 = {
3064
3121
  };
3065
3122
 
3066
3123
  // src/blocks/embed/embed.tsx
3067
- import { on, createEffect, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3124
+ import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3068
3125
 
3069
3126
  // src/blocks/embed/helpers.ts
3070
3127
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3105,8 +3162,8 @@ function Embed(props) {
3105
3162
  findAndRunScripts();
3106
3163
  }
3107
3164
  }
3108
- createEffect(
3109
- on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3165
+ createEffect2(
3166
+ on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3110
3167
  );
3111
3168
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3112
3169
  }
@@ -4172,9 +4229,9 @@ var Inlined_script_default = InlinedScript;
4172
4229
  // src/components/content/components/enable-editor.tsx
4173
4230
  import {
4174
4231
  Show as Show12,
4175
- onMount as onMount4,
4176
- on as on2,
4177
- createEffect as createEffect2,
4232
+ onMount as onMount5,
4233
+ on as on3,
4234
+ createEffect as createEffect3,
4178
4235
  createMemo as createMemo16,
4179
4236
  createSignal as createSignal16
4180
4237
  } from "solid-js";
@@ -4281,7 +4338,7 @@ var generateContentUrl = (options) => {
4281
4338
  locale,
4282
4339
  apiVersion = DEFAULT_API_VERSION,
4283
4340
  fields,
4284
- omit,
4341
+ omit: omit2,
4285
4342
  offset,
4286
4343
  cacheSeconds,
4287
4344
  staleCacheSeconds,
@@ -4304,7 +4361,7 @@ var generateContentUrl = (options) => {
4304
4361
  url.searchParams.set("locale", locale);
4305
4362
  if (enrich)
4306
4363
  url.searchParams.set("enrich", String(enrich));
4307
- url.searchParams.set("omit", omit || "meta.componentsUsed");
4364
+ url.searchParams.set("omit", omit2 || "meta.componentsUsed");
4308
4365
  if (fields) {
4309
4366
  url.searchParams.set("fields", fields);
4310
4367
  }
@@ -4674,7 +4731,7 @@ function isFromTrustedHost(trustedHosts, e) {
4674
4731
  }
4675
4732
 
4676
4733
  // src/constants/sdk-version.ts
4677
- var SDK_VERSION = "2.0.9";
4734
+ var SDK_VERSION = "2.0.15";
4678
4735
 
4679
4736
  // src/functions/register.ts
4680
4737
  var registry = {};
@@ -5112,7 +5169,7 @@ function EnableEditor(props) {
5112
5169
  }
5113
5170
  }
5114
5171
  let elementRef;
5115
- onMount4(() => {
5172
+ onMount5(() => {
5116
5173
  if (isBrowser()) {
5117
5174
  if (isEditing()) {
5118
5175
  window.addEventListener("message", processMessage);
@@ -5173,7 +5230,7 @@ function EnableEditor(props) {
5173
5230
  }
5174
5231
  }
5175
5232
  });
5176
- onMount4(() => {
5233
+ onMount5(() => {
5177
5234
  if (!props.apiKey) {
5178
5235
  logger.error(
5179
5236
  "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
@@ -5189,13 +5246,13 @@ function EnableEditor(props) {
5189
5246
  mergeNewContent(props.content);
5190
5247
  }
5191
5248
  }
5192
- createEffect2(on2(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5249
+ createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5193
5250
  const onUpdateFn_1_props_builderContextSignal_content__data__jsCode = createMemo16(() => props.builderContextSignal.content?.data?.jsCode);
5194
5251
  function onUpdateFn_1() {
5195
5252
  evaluateJsCode();
5196
5253
  }
5197
- createEffect2(
5198
- on2(
5254
+ createEffect3(
5255
+ on3(
5199
5256
  () => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()],
5200
5257
  onUpdateFn_1
5201
5258
  )
@@ -5204,8 +5261,8 @@ function EnableEditor(props) {
5204
5261
  function onUpdateFn_2() {
5205
5262
  runHttpRequests();
5206
5263
  }
5207
- createEffect2(
5208
- on2(
5264
+ createEffect3(
5265
+ on3(
5209
5266
  () => [
5210
5267
  onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()
5211
5268
  ],
@@ -5218,8 +5275,8 @@ function EnableEditor(props) {
5218
5275
  function onUpdateFn_3() {
5219
5276
  emitStateUpdate();
5220
5277
  }
5221
- createEffect2(
5222
- on2(
5278
+ createEffect3(
5279
+ on3(
5223
5280
  () => [onUpdateFn_3_props_builderContextSignal_rootState()],
5224
5281
  onUpdateFn_3
5225
5282
  )
@@ -5230,7 +5287,7 @@ function EnableEditor(props) {
5230
5287
  mergeNewRootState(props.data);
5231
5288
  }
5232
5289
  }
5233
- createEffect2(on2(() => [onUpdateFn_4_props_data()], onUpdateFn_4));
5290
+ createEffect3(on3(() => [onUpdateFn_4_props_data()], onUpdateFn_4));
5234
5291
  const onUpdateFn_5_props_locale = createMemo16(() => props.locale);
5235
5292
  function onUpdateFn_5() {
5236
5293
  if (props.locale) {
@@ -5239,7 +5296,7 @@ function EnableEditor(props) {
5239
5296
  });
5240
5297
  }
5241
5298
  }
5242
- createEffect2(on2(() => [onUpdateFn_5_props_locale()], onUpdateFn_5));
5299
+ createEffect3(on3(() => [onUpdateFn_5_props_locale()], onUpdateFn_5));
5243
5300
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show12 when={props.builderContextSignal.content}><Dynamic5
5244
5301
  class={getWrapperClassName(
5245
5302
  props.content?.testVariationId || props.content?.id
@@ -5464,7 +5521,7 @@ function ContentVariants(props) {
5464
5521
  canTrack: getDefaultCanTrack(props.canTrack)
5465
5522
  });
5466
5523
  });
5467
- onMount5(() => {
5524
+ onMount6(() => {
5468
5525
  setShouldRenderVariants(false);
5469
5526
  });
5470
5527
  return <><>
@@ -5592,13 +5649,13 @@ function Symbol(props) {
5592
5649
  }
5593
5650
  });
5594
5651
  }
5595
- onMount6(() => {
5652
+ onMount7(() => {
5596
5653
  });
5597
5654
  const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
5598
5655
  function onUpdateFn_0() {
5599
5656
  setContent();
5600
5657
  }
5601
- createEffect3(on3(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
5658
+ createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
5602
5659
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
5603
5660
  nonce={props.builderContext.nonce}
5604
5661
  isNestedRender={true}