@makeswift/runtime 0.2.11 → 0.2.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/dist/index.cjs.js CHANGED
@@ -1002,7 +1002,7 @@ class Document$1 extends NextDocument__default["default"] {
1002
1002
  });
1003
1003
  }
1004
1004
  }
1005
- const version = "0.2.11";
1005
+ const version = "0.2.13";
1006
1006
  function isErrorWithMessage(error) {
1007
1007
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1008
1008
  }
package/dist/index.es.js CHANGED
@@ -967,7 +967,7 @@ class Document$1 extends NextDocument {
967
967
  });
968
968
  }
969
969
  }
970
- const version = "0.2.11";
970
+ const version = "0.2.13";
971
971
  function isErrorWithMessage(error) {
972
972
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
973
973
  }
@@ -473,7 +473,7 @@ function getPageIds(descriptor, prop) {
473
473
  return [];
474
474
  }
475
475
  }
476
- function copy$7(value, context) {
476
+ function copy$d(value, context) {
477
477
  if (value == null)
478
478
  return value;
479
479
  return value.map((override) => __spreadProps(__spreadValues({}, override), {
@@ -511,12 +511,12 @@ function copy$7(value, context) {
511
511
  })
512
512
  }));
513
513
  }
514
- function copy$6(value, context) {
514
+ function copy$c(value, context) {
515
515
  return __spreadProps(__spreadValues({}, value), {
516
516
  elements: value.elements.map((element) => context.copyElement(element))
517
517
  });
518
518
  }
519
- function copy$5(value, context) {
519
+ function copy$b(value, context) {
520
520
  var _a, _b;
521
521
  if (value == null)
522
522
  return value;
@@ -547,7 +547,7 @@ function copy$5(value, context) {
547
547
  return value;
548
548
  }
549
549
  }
550
- function copy$4(value, context) {
550
+ function copy$a(value, context) {
551
551
  if (value == null)
552
552
  return value;
553
553
  return value.map(copyNavigationLinksPanelItem);
@@ -558,7 +558,7 @@ function copy$4(value, context) {
558
558
  const { color: color2, link } = item.payload;
559
559
  return __spreadProps(__spreadValues({}, item), {
560
560
  payload: __spreadProps(__spreadValues({}, item.payload), {
561
- link: link != null ? copy$5(link, context) : void 0,
561
+ link: link != null ? copy$b(link, context) : void 0,
562
562
  color: color2 != null ? color2.map((override) => {
563
563
  var _a;
564
564
  return __spreadProps(__spreadValues({}, override), {
@@ -575,7 +575,7 @@ function copy$4(value, context) {
575
575
  }
576
576
  }
577
577
  }
578
- function copy$3(value, context) {
578
+ function copy$9(value, context) {
579
579
  if (value == null)
580
580
  return value;
581
581
  return value.map((override) => __spreadProps(__spreadValues({}, override), { value: override.value.map(copyShadowItem) }));
@@ -593,13 +593,29 @@ function copy$3(value, context) {
593
593
  });
594
594
  }
595
595
  }
596
- function copy$2(value, context) {
596
+ function copy$8(value, context) {
597
597
  var _a;
598
598
  if (value == null)
599
599
  return value;
600
600
  return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
601
601
  }
602
- function copy$1(value, context) {
602
+ function copy$7(value, context) {
603
+ if (value == null)
604
+ return value;
605
+ return value.map(copyImagesPanelItem);
606
+ function copyImagesPanelItem(imagesPanelItem) {
607
+ var _a;
608
+ const { file } = imagesPanelItem.props;
609
+ if (file == null)
610
+ return imagesPanelItem;
611
+ return __spreadProps(__spreadValues({}, imagesPanelItem), {
612
+ props: __spreadProps(__spreadValues({}, imagesPanelItem.props), {
613
+ file: (_a = context.replacementContext.fileIds.get(file)) != null ? _a : file
614
+ })
615
+ });
616
+ }
617
+ }
618
+ function copy$6(value, context) {
603
619
  if (value == null)
604
620
  return value;
605
621
  return value.map((override) => __spreadProps(__spreadValues({}, override), { value: copyColorValue(override.value) }));
@@ -610,26 +626,176 @@ function copy$1(value, context) {
610
626
  });
611
627
  }
612
628
  }
629
+ function copy$5(value, context) {
630
+ if (value == null)
631
+ return value;
632
+ return __spreadProps(__spreadValues({}, value), { fields: value.fields.map(copyFormFieldsPanelItem) });
633
+ function copyFormFieldsPanelItem(item) {
634
+ var _a;
635
+ return __spreadProps(__spreadValues({}, item), {
636
+ tableColumnId: (_a = context.replacementContext.tableColumnIds.get(item.tableColumnId)) != null ? _a : item.tableColumnId
637
+ });
638
+ }
639
+ }
640
+ function copy$4(value, context) {
641
+ var _a;
642
+ if (value == null)
643
+ return value;
644
+ return (_a = context.replacementContext.tableIds.get(value)) != null ? _a : value;
645
+ }
646
+ function copy$3(value, context) {
647
+ if (value == null)
648
+ return value;
649
+ return value.map((override) => __spreadProps(__spreadValues({}, override), { value: copyBorderValue(override.value) }));
650
+ function copyBorderValue({ borderTop, borderRight, borderBottom, borderLeft }) {
651
+ return {
652
+ borderTop: borderTop && copyBorderSide(borderTop),
653
+ borderRight: borderRight && copyBorderSide(borderRight),
654
+ borderBottom: borderBottom && copyBorderSide(borderBottom),
655
+ borderLeft: borderLeft && copyBorderSide(borderLeft)
656
+ };
657
+ }
658
+ function copyBorderSide(borderSide) {
659
+ var _a;
660
+ const { color: color2 } = borderSide;
661
+ if (color2 == null)
662
+ return borderSide;
663
+ return __spreadProps(__spreadValues({}, borderSide), {
664
+ color: __spreadProps(__spreadValues({}, color2), {
665
+ swatchId: (_a = context.replacementContext.swatchIds.get(color2.swatchId)) != null ? _a : color2.swatchId
666
+ })
667
+ });
668
+ }
669
+ }
670
+ function copy$2(value, context) {
671
+ if (value == null)
672
+ return value;
673
+ return __spreadProps(__spreadValues({}, value), { document: value.document ? copyNode(value.document) : value.document });
674
+ function copyNode(node) {
675
+ var _a;
676
+ switch (node.object) {
677
+ case "document":
678
+ case "block":
679
+ case "inline":
680
+ return copyInline(node);
681
+ case "text":
682
+ return __spreadProps(__spreadValues({}, node), { marks: (_a = node.marks) == null ? void 0 : _a.map(copyMark) });
683
+ default:
684
+ return node;
685
+ }
686
+ }
687
+ function copyInline(inline) {
688
+ var _a, _b;
689
+ switch (inline.type) {
690
+ case "link":
691
+ return __spreadProps(__spreadValues({}, inline), {
692
+ nodes: (_a = inline.nodes) == null ? void 0 : _a.map(copyNode),
693
+ data: inline.data ? copyLinkData(inline.data) : inline.data
694
+ });
695
+ default:
696
+ return __spreadProps(__spreadValues({}, inline), { nodes: (_b = inline.nodes) == null ? void 0 : _b.map(copyNode) });
697
+ }
698
+ }
699
+ function copyLinkData(data) {
700
+ var _a, _b;
701
+ switch (data.type) {
702
+ case "OPEN_PAGE": {
703
+ const pageId = data.payload.pageId;
704
+ if (pageId == null)
705
+ return data;
706
+ return __spreadProps(__spreadValues({}, data), {
707
+ payload: __spreadProps(__spreadValues({}, data.payload), {
708
+ pageId: (_a = context.replacementContext.pageIds.get(pageId)) != null ? _a : data.payload.pageId
709
+ })
710
+ });
711
+ }
712
+ case "SCROLL_TO_ELEMENT": {
713
+ const elementIdConfig = data.payload.elementIdConfig;
714
+ if (elementIdConfig == null)
715
+ return data;
716
+ return __spreadProps(__spreadValues({}, data), {
717
+ payload: __spreadProps(__spreadValues({}, data.payload), {
718
+ elementIdConfig: __spreadProps(__spreadValues({}, elementIdConfig), {
719
+ elementKey: (_b = context.replacementContext.elementKeys.get(elementIdConfig.elementKey)) != null ? _b : elementIdConfig.elementKey
720
+ })
721
+ })
722
+ });
723
+ }
724
+ default:
725
+ return data;
726
+ }
727
+ }
728
+ function copyMark(mark) {
729
+ var _a, _b, _c, _d;
730
+ switch (mark.type) {
731
+ case "typography": {
732
+ const typographyId = (_a = mark.data) == null ? void 0 : _a.value.id;
733
+ return __spreadProps(__spreadValues({}, mark), {
734
+ data: __spreadProps(__spreadValues({}, mark.data), {
735
+ value: __spreadProps(__spreadValues({}, (_b = mark.data) == null ? void 0 : _b.value), {
736
+ id: (_c = context.replacementContext.typographyIds.get(typographyId)) != null ? _c : typographyId,
737
+ style: (_d = mark.data) == null ? void 0 : _d.value.style.map((override) => {
738
+ var _a2, _b2, _c2;
739
+ return __spreadProps(__spreadValues({}, override), {
740
+ value: __spreadProps(__spreadValues({}, override.value), {
741
+ color: override.value.color == null ? override.value.color : __spreadProps(__spreadValues({}, override.value.color), {
742
+ swatchId: (_c2 = context.replacementContext.swatchIds.get((_a2 = override.value.color) == null ? void 0 : _a2.swatchId)) != null ? _c2 : (_b2 = override.value.color) == null ? void 0 : _b2.swatchId
743
+ })
744
+ })
745
+ });
746
+ })
747
+ })
748
+ })
749
+ });
750
+ }
751
+ default:
752
+ return mark;
753
+ }
754
+ }
755
+ }
756
+ function copy$1(value, context) {
757
+ if (value == null)
758
+ return value;
759
+ if (context.replacementContext.elementHtmlIds.has(value))
760
+ return void 0;
761
+ context.replacementContext.elementHtmlIds.add(value);
762
+ return value;
763
+ }
613
764
  function copy(descriptor, value, context) {
614
765
  switch (descriptor.type) {
615
766
  case "Backgrounds":
616
- return copy$7(value, context);
767
+ return copy$d(value, context);
617
768
  case "Grid":
618
- return copy$6(value, context);
769
+ return copy$c(value, context);
619
770
  case "NavigationLinks":
620
- return copy$4(value, context);
771
+ return copy$a(value, context);
621
772
  case "Link":
622
- return copy$5(value, context);
773
+ return copy$b(value, context);
623
774
  case "Shadows":
624
- return copy$3(value, context);
775
+ return copy$9(value, context);
625
776
  case "Image":
626
- return copy$2(value, context);
777
+ return copy$8(value, context);
778
+ case "Images":
779
+ return copy$7(value, context);
627
780
  case "ResponsiveColor":
781
+ return copy$6(value, context);
782
+ case "TableFormFields":
783
+ return copy$5(value, context);
784
+ case "Table":
785
+ return copy$4(value, context);
786
+ case "Border":
787
+ return copy$3(value, context);
788
+ case "RichText":
789
+ return copy$2(value, context);
790
+ case "ElementID":
628
791
  return copy$1(value, context);
629
792
  default:
630
793
  return value;
631
794
  }
632
795
  }
796
+ function copyElementReference(value, context) {
797
+ return context.replacementContext.globalElementIds.get(value) || value;
798
+ }
633
799
  const reducer = redux.combineReducers({
634
800
  documents: reducer$6,
635
801
  reactComponents: reducer$5,
@@ -733,18 +899,20 @@ function createReplacementContext(jsonReplacementContext) {
733
899
  function copyElementTree(state, elementTree, replacementContext) {
734
900
  function copyElementTreeNode(state2, replacementContext2) {
735
901
  return function(node) {
902
+ const context = {
903
+ replacementContext: replacementContext2,
904
+ copyElement: copyElementTreeNode(state2, replacementContext2)
905
+ };
736
906
  if ("props" in node) {
737
907
  for (const propKey of Object.keys(node.props)) {
738
908
  const descriptors = getComponentPropControllerDescriptors(state2, node.type);
739
909
  if (descriptors == null)
740
910
  continue;
741
911
  const descriptor = descriptors[propKey];
742
- const context = {
743
- replacementContext: replacementContext2,
744
- copyElement: copyElementTreeNode(state2, replacementContext2)
745
- };
746
912
  node.props[propKey] = copy(descriptor, node.props[propKey], context);
747
913
  }
914
+ } else if (node.type === "reference") {
915
+ return __spreadProps(__spreadValues({}, node), { value: copyElementReference(node.value, context) });
748
916
  }
749
917
  return node;
750
918
  };