@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/node/dev.js CHANGED
@@ -127,6 +127,15 @@ function getBlockComponentOptions(block) {
127
127
  };
128
128
  }
129
129
 
130
+ // src/helpers/omit.ts
131
+ function omit(obj, ...values) {
132
+ const newObject = Object.assign({}, obj);
133
+ for (const key of values) {
134
+ delete newObject[key];
135
+ }
136
+ return newObject;
137
+ }
138
+
130
139
  // src/helpers/logger.ts
131
140
  var MSG_PREFIX = "[Builder.io]: ";
132
141
  var logger = {
@@ -397,7 +406,7 @@ if (typeof output === 'object' && output !== null) {
397
406
  };
398
407
  var IVM_INSTANCE = null;
399
408
  var IVM_CONTEXT = null;
400
- var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react";
409
+ var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik";
401
410
  var getIvm = () => {
402
411
  try {
403
412
  if (IVM_INSTANCE)
@@ -412,7 +421,7 @@ var getIvm = () => {
412
421
 
413
422
  SOLUTION: In a server-only execution path within your application, do one of the following:
414
423
 
415
- ${SHOULD_MENTION_INITIALIZE_SCRIPT ? '- import and call `initializeNodeRuntime()` from "${SDK_NAME}/node/init".' : ""}
424
+ ${SHOULD_MENTION_INITIALIZE_SCRIPT ? `- import and call \`initializeNodeRuntime()\` from "${SDK_NAME}/node/init".` : ""}
416
425
  - add the following import: \`await import('isolated-vm')\`.
417
426
 
418
427
  For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
@@ -517,6 +526,7 @@ var shouldForceBrowserRuntimeInNode = () => {
517
526
  var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
518
527
 
519
528
  // src/functions/evaluate/evaluate.ts
529
+ var DISABLE_CACHE = true;
520
530
  var EvalCache = class _EvalCache {
521
531
  static cacheLimit = 20;
522
532
  static cache = /* @__PURE__ */ new Map();
@@ -565,7 +575,7 @@ function evaluate({
565
575
  rootState,
566
576
  localState
567
577
  };
568
- if (enableCache) {
578
+ if (enableCache && !DISABLE_CACHE) {
569
579
  const cacheKey = EvalCache.getCacheKey(args);
570
580
  const cachedValue = EvalCache.getCachedValue(cacheKey);
571
581
  if (cachedValue) {
@@ -593,6 +603,53 @@ function transformBlock(block) {
593
603
  }
594
604
 
595
605
  // src/functions/get-processed-block.ts
606
+ function deepCloneWithConditions(obj) {
607
+ if (obj === null || typeof obj !== "object") {
608
+ return obj;
609
+ }
610
+ if (Array.isArray(obj)) {
611
+ return obj.map((item) => deepCloneWithConditions(item));
612
+ }
613
+ if (obj["@type"] === "@builder.io/sdk:Element") {
614
+ return obj;
615
+ }
616
+ const clonedObj = {};
617
+ for (const key in obj) {
618
+ if (key !== "meta" && Object.prototype.hasOwnProperty.call(obj, key)) {
619
+ clonedObj[key] = deepCloneWithConditions(obj[key]);
620
+ }
621
+ }
622
+ return clonedObj;
623
+ }
624
+ var IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK = ["svelte", "vue", "angular", "qwik", "solid"].includes(TARGET);
625
+ var getCopy = (block) => {
626
+ if (IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK) {
627
+ const copy = fastClone(block);
628
+ const copied = {
629
+ ...copy,
630
+ properties: {
631
+ ...copy.properties
632
+ },
633
+ actions: {
634
+ ...copy.actions
635
+ }
636
+ };
637
+ return copied;
638
+ } else {
639
+ const copy = deepCloneWithConditions(omit(block, "children", "meta"));
640
+ return {
641
+ ...copy,
642
+ properties: {
643
+ ...copy.properties
644
+ },
645
+ actions: {
646
+ ...copy.actions
647
+ },
648
+ children: block.children,
649
+ meta: block.meta
650
+ };
651
+ }
652
+ };
596
653
  var evaluateBindings = ({
597
654
  block,
598
655
  context,
@@ -603,16 +660,7 @@ var evaluateBindings = ({
603
660
  if (!block.bindings) {
604
661
  return block;
605
662
  }
606
- const copy = fastClone(block);
607
- const copied = {
608
- ...copy,
609
- properties: {
610
- ...copy.properties
611
- },
612
- actions: {
613
- ...copy.actions
614
- }
615
- };
663
+ const copied = getCopy(block);
616
664
  for (const binding in block.bindings) {
617
665
  const expression = block.bindings[binding];
618
666
  const value = evaluate({
@@ -895,17 +943,9 @@ function mapStyleObjToStrIfNeeded(style) {
895
943
  // src/components/block/block.helpers.ts
896
944
  var getComponent = ({
897
945
  block,
898
- context,
899
946
  registeredComponents
900
947
  }) => {
901
- const componentName = getProcessedBlock({
902
- block,
903
- localState: context.localState,
904
- rootState: context.rootState,
905
- rootSetState: context.rootSetState,
906
- context: context.context,
907
- shouldEvaluateBindings: false
908
- }).component?.name;
948
+ const componentName = block.component?.name;
909
949
  if (!componentName) {
910
950
  return null;
911
951
  }
@@ -1058,14 +1098,7 @@ var inlined_styles_default = InlinedStyles;
1058
1098
  // src/components/block/components/block-styles.tsx
1059
1099
  function BlockStyles(props) {
1060
1100
  const canShowBlock = createMemo(() => {
1061
- const processedBlock = getProcessedBlock({
1062
- block: props.block,
1063
- localState: props.context.localState,
1064
- rootState: props.context.rootState,
1065
- rootSetState: props.context.rootSetState,
1066
- context: props.context.context,
1067
- shouldEvaluateBindings: true
1068
- });
1101
+ const processedBlock = props.block;
1069
1102
  if (checkIsDefined(processedBlock.hide)) {
1070
1103
  return !processedBlock.hide;
1071
1104
  }
@@ -1075,14 +1108,7 @@ function BlockStyles(props) {
1075
1108
  return true;
1076
1109
  });
1077
1110
  const css = createMemo(() => {
1078
- const processedBlock = getProcessedBlock({
1079
- block: props.block,
1080
- localState: props.context.localState,
1081
- rootState: props.context.rootState,
1082
- rootSetState: props.context.rootSetState,
1083
- context: props.context.context,
1084
- shouldEvaluateBindings: true
1085
- });
1111
+ const processedBlock = props.block;
1086
1112
  const styles = processedBlock.responsiveStyles;
1087
1113
  const content = props.context.content;
1088
1114
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
@@ -1388,12 +1414,9 @@ var repeated_block_default = RepeatedBlock;
1388
1414
 
1389
1415
  // src/components/block/block.tsx
1390
1416
  function Block(props) {
1391
- const blockComponent = createMemo(() => {
1392
- return getComponent({
1393
- block: props.block,
1394
- context: props.context,
1395
- registeredComponents: props.registeredComponents
1396
- });
1417
+ createSignal({
1418
+ value: null,
1419
+ update: false
1397
1420
  });
1398
1421
  const repeatItem = createMemo(() => {
1399
1422
  return getRepeatItemData({
@@ -1402,7 +1425,7 @@ function Block(props) {
1402
1425
  });
1403
1426
  });
1404
1427
  const processedBlock = createMemo(() => {
1405
- return props.block.repeat?.collection ? props.block : getProcessedBlock({
1428
+ const blockToUse = props.block.repeat?.collection ? props.block : getProcessedBlock({
1406
1429
  block: props.block,
1407
1430
  localState: props.context.localState,
1408
1431
  rootState: props.context.rootState,
@@ -1410,6 +1433,13 @@ function Block(props) {
1410
1433
  context: props.context.context,
1411
1434
  shouldEvaluateBindings: true
1412
1435
  });
1436
+ return blockToUse;
1437
+ });
1438
+ const blockComponent = createMemo(() => {
1439
+ return getComponent({
1440
+ block: processedBlock(),
1441
+ registeredComponents: props.registeredComponents
1442
+ });
1413
1443
  });
1414
1444
  const Tag = createMemo(() => {
1415
1445
  const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
@@ -1468,40 +1498,72 @@ function Block(props) {
1468
1498
  get children() {
1469
1499
  return [createComponent(block_styles_default, {
1470
1500
  get block() {
1471
- return props.block;
1501
+ return processedBlock();
1472
1502
  },
1473
1503
  get context() {
1474
1504
  return props.context;
1475
1505
  }
1476
1506
  }), createComponent(Show, {
1477
1507
  get fallback() {
1478
- return createComponent(component_ref_default, {
1479
- get componentRef() {
1480
- return componentRefProps().componentRef;
1481
- },
1482
- get componentOptions() {
1483
- return componentRefProps().componentOptions;
1484
- },
1485
- get blockChildren() {
1486
- return componentRefProps().blockChildren;
1487
- },
1488
- get context() {
1489
- return componentRefProps().context;
1490
- },
1491
- get registeredComponents() {
1492
- return componentRefProps().registeredComponents;
1493
- },
1494
- get linkComponent() {
1495
- return componentRefProps().linkComponent;
1496
- },
1497
- get builderBlock() {
1498
- return componentRefProps().builderBlock;
1508
+ return createComponent(Show, {
1509
+ get fallback() {
1510
+ return createComponent(For, {
1511
+ get each() {
1512
+ return repeatItem();
1513
+ },
1514
+ children: (data, _index) => {
1515
+ const index = _index();
1516
+ return createComponent(repeated_block_default, {
1517
+ key: index,
1518
+ get repeatContext() {
1519
+ return data.context;
1520
+ },
1521
+ get block() {
1522
+ return data.block;
1523
+ },
1524
+ get registeredComponents() {
1525
+ return props.registeredComponents;
1526
+ },
1527
+ get linkComponent() {
1528
+ return props.linkComponent;
1529
+ }
1530
+ });
1531
+ }
1532
+ });
1499
1533
  },
1500
- get includeBlockProps() {
1501
- return componentRefProps().includeBlockProps;
1534
+ get when() {
1535
+ return !repeatItem();
1502
1536
  },
1503
- get isInteractive() {
1504
- return componentRefProps().isInteractive;
1537
+ get children() {
1538
+ return createComponent(component_ref_default, {
1539
+ get componentRef() {
1540
+ return componentRefProps().componentRef;
1541
+ },
1542
+ get componentOptions() {
1543
+ return componentRefProps().componentOptions;
1544
+ },
1545
+ get blockChildren() {
1546
+ return componentRefProps().blockChildren;
1547
+ },
1548
+ get context() {
1549
+ return componentRefProps().context;
1550
+ },
1551
+ get registeredComponents() {
1552
+ return componentRefProps().registeredComponents;
1553
+ },
1554
+ get linkComponent() {
1555
+ return componentRefProps().linkComponent;
1556
+ },
1557
+ get builderBlock() {
1558
+ return componentRefProps().builderBlock;
1559
+ },
1560
+ get includeBlockProps() {
1561
+ return componentRefProps().includeBlockProps;
1562
+ },
1563
+ get isInteractive() {
1564
+ return componentRefProps().isInteractive;
1565
+ }
1566
+ });
1505
1567
  }
1506
1568
  });
1507
1569
  },
@@ -1611,7 +1673,7 @@ function Block(props) {
1611
1673
  });
1612
1674
  }
1613
1675
  var block_default = Block;
1614
- var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-1bb6a3a2 {
1676
+ var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-4da8c6f4 {
1615
1677
  display: flex;
1616
1678
  flex-direction: column;
1617
1679
  align-items: stretch;
@@ -1642,9 +1704,16 @@ function BlocksWrapper(props) {
1642
1704
  }, "*");
1643
1705
  }
1644
1706
  }
1707
+ let blocksWrapperRef;
1708
+ onMount(() => {
1709
+ });
1645
1710
  return [createComponent(Dynamic, mergeProps({
1646
1711
  get ["class"]() {
1647
- return className() + " dynamic-1bb6a3a2";
1712
+ return className() + " dynamic-4da8c6f4";
1713
+ },
1714
+ ref(r$) {
1715
+ const _ref$ = blocksWrapperRef;
1716
+ typeof _ref$ === "function" ? _ref$(r$) : blocksWrapperRef = r$;
1648
1717
  },
1649
1718
  get ["builder-path"]() {
1650
1719
  return props.path;
@@ -3108,7 +3177,8 @@ var componentInfo7 = {
3108
3177
  defaultValue: "children"
3109
3178
  }],
3110
3179
  shouldReceiveBuilderProps: {
3111
- builderContext: true
3180
+ builderContext: true,
3181
+ builderComponents: true
3112
3182
  }
3113
3183
  };
3114
3184
  var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
@@ -3129,6 +3199,9 @@ function Slot(props) {
3129
3199
  get context() {
3130
3200
  return props.builderContext;
3131
3201
  },
3202
+ get registeredComponents() {
3203
+ return props.builderComponents;
3204
+ },
3132
3205
  get blocks() {
3133
3206
  return props.builderContext.rootState?.[props.name];
3134
3207
  }
@@ -4946,7 +5019,7 @@ var generateContentUrl = (options) => {
4946
5019
  locale,
4947
5020
  apiVersion = DEFAULT_API_VERSION,
4948
5021
  fields,
4949
- omit,
5022
+ omit: omit2,
4950
5023
  offset,
4951
5024
  cacheSeconds,
4952
5025
  staleCacheSeconds,
@@ -4969,7 +5042,7 @@ var generateContentUrl = (options) => {
4969
5042
  url.searchParams.set("locale", locale);
4970
5043
  if (enrich)
4971
5044
  url.searchParams.set("enrich", String(enrich));
4972
- url.searchParams.set("omit", omit || "meta.componentsUsed");
5045
+ url.searchParams.set("omit", omit2 || "meta.componentsUsed");
4973
5046
  if (fields) {
4974
5047
  url.searchParams.set("fields", fields);
4975
5048
  }
@@ -5342,7 +5415,7 @@ function isFromTrustedHost(trustedHosts, e) {
5342
5415
  }
5343
5416
 
5344
5417
  // src/constants/sdk-version.ts
5345
- var SDK_VERSION = "2.0.9";
5418
+ var SDK_VERSION = "2.0.13";
5346
5419
 
5347
5420
  // src/functions/register.ts
5348
5421
  var registry = {};