@makeswift/runtime 0.10.13 → 0.10.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.
Files changed (63) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +2 -2
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +2 -2
  5. package/dist/Carousel.cjs.js +1 -1
  6. package/dist/Carousel.es.js +2 -2
  7. package/dist/Countdown.es.js +1 -1
  8. package/dist/Divider.cjs.js +1 -1
  9. package/dist/Divider.es.js +2 -2
  10. package/dist/Embed.es.js +1 -1
  11. package/dist/Form.es.js +1 -1
  12. package/dist/Image.es.js +1 -1
  13. package/dist/LiveProvider.cjs.js +1 -1
  14. package/dist/LiveProvider.es.js +2 -2
  15. package/dist/Navigation.cjs.js +1 -1
  16. package/dist/Navigation.es.js +2 -2
  17. package/dist/PreviewProvider.cjs.js +1 -1
  18. package/dist/PreviewProvider.es.js +2 -2
  19. package/dist/ReadOnlyText.es.js +1 -1
  20. package/dist/ReadOnlyTextV2.es.js +1 -1
  21. package/dist/Root.es.js +1 -1
  22. package/dist/SocialLinks.cjs.js +1 -1
  23. package/dist/SocialLinks.es.js +2 -2
  24. package/dist/Video.es.js +1 -1
  25. package/dist/control-serialization.cjs.js +1 -1
  26. package/dist/control-serialization.es.js +2 -2
  27. package/dist/controls.cjs.js +1 -1
  28. package/dist/controls.es.js +1 -1
  29. package/dist/index.cjs.js +18 -12
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.cjs2.js +37 -6
  32. package/dist/index.cjs2.js.map +1 -1
  33. package/dist/index.es.js +19 -13
  34. package/dist/index.es.js.map +1 -1
  35. package/dist/index.es2.js +38 -7
  36. package/dist/index.es2.js.map +1 -1
  37. package/dist/index.es4.js +1 -1
  38. package/dist/index.es5.js +1 -1
  39. package/dist/index.es6.js +1 -1
  40. package/dist/index.es8.js +1 -1
  41. package/dist/index.es9.js +1 -1
  42. package/dist/prop-controllers.cjs.js +1 -0
  43. package/dist/prop-controllers.cjs.js.map +1 -1
  44. package/dist/prop-controllers.es.js +1 -1
  45. package/dist/react-page.cjs.js +55 -42
  46. package/dist/react-page.cjs.js.map +1 -1
  47. package/dist/react-page.es.js +54 -42
  48. package/dist/react-page.es.js.map +1 -1
  49. package/dist/slate.es.js +1 -1
  50. package/dist/toText.es.js +1 -1
  51. package/dist/types/src/components/hooks/useBackgrounds.d.ts.map +1 -1
  52. package/dist/types/src/controls/image.d.ts +16 -1
  53. package/dist/types/src/controls/image.d.ts.map +1 -1
  54. package/dist/types/src/prop-controllers/copy/backgrounds.d.ts +2 -2
  55. package/dist/types/src/prop-controllers/copy/backgrounds.d.ts.map +1 -1
  56. package/dist/types/src/prop-controllers/descriptors.d.ts +22 -5
  57. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  58. package/dist/types/src/prop-controllers/index.d.ts +2 -1
  59. package/dist/types/src/prop-controllers/index.d.ts.map +1 -1
  60. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  61. package/dist/types/src/runtimes/react/controls/image.d.ts.map +1 -1
  62. package/dist/types/types/locale.d.ts +1 -1
  63. package/package.json +1 -1
@@ -566,7 +566,7 @@ const Types = {
566
566
  Style: StyleControlType
567
567
  };
568
568
  function Backgrounds(options = {}) {
569
- return { type: Types.Backgrounds, options };
569
+ return { type: Types.Backgrounds, version: 1, options };
570
570
  }
571
571
  const BorderPropControllerFormat = {
572
572
  ClassName: "makeswift::prop-controllers::border::format::class-name",
@@ -807,14 +807,19 @@ const ImageControlValueFormat = {
807
807
  WithDimensions: "makeswift::controls::image::format::with-dimensions"
808
808
  };
809
809
  function Image(config = {}) {
810
- return { type: ImageControlType, config };
810
+ return { type: ImageControlType, config, version: 1 };
811
811
  }
812
812
  Image.Format = ImageControlValueFormat;
813
813
  function copyImageData(value, context) {
814
- var _a;
815
814
  if (value == null)
816
815
  return value;
817
- return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
816
+ return match(value).with(P.string, (id) => {
817
+ var _a;
818
+ return (_a = context.replacementContext.fileIds.get(id)) != null ? _a : id;
819
+ }).with({ type: "makeswift-file" }, ({ id }) => {
820
+ var _a;
821
+ return (_a = context.replacementContext.fileIds.get(id)) != null ? _a : id;
822
+ }).otherwise((val) => val);
818
823
  }
819
824
  if (import_meta.vitest) {
820
825
  const { describe, test, expect } = import_meta.vitest;
@@ -1221,41 +1226,51 @@ function mergeSlotData(base = { columns: [], elements: [] }, override = { column
1221
1226
  });
1222
1227
  return { columns: mergedColumns, elements: mergedElements };
1223
1228
  }
1224
- function copy$e(value, context) {
1229
+ function copy$e(descriptor, value, context) {
1225
1230
  if (value == null)
1226
1231
  return value;
1227
1232
  return value.map((override) => __spreadProps(__spreadValues({}, override), {
1228
1233
  value: override.value.map((backgroundItem) => {
1229
- var _a, _b;
1230
- switch (backgroundItem.type) {
1231
- case "color":
1232
- return __spreadProps(__spreadValues({}, backgroundItem), {
1233
- payload: backgroundItem.payload === null ? null : __spreadProps(__spreadValues({}, backgroundItem.payload), {
1234
- swatchId: (_a = context.replacementContext.swatchIds.get(backgroundItem.payload.swatchId)) != null ? _a : backgroundItem.payload.swatchId
1235
- })
1236
- });
1237
- case "gradient":
1238
- return __spreadProps(__spreadValues({}, backgroundItem), {
1239
- payload: __spreadProps(__spreadValues({}, backgroundItem.payload), {
1240
- stops: backgroundItem.payload.stops.map((stop) => {
1241
- var _a2;
1242
- return __spreadProps(__spreadValues({}, stop), {
1243
- color: stop.color == null ? null : __spreadProps(__spreadValues({}, stop.color), {
1244
- swatchId: (_a2 = context.replacementContext.swatchIds.get(stop.color.swatchId)) != null ? _a2 : stop.color.swatchId
1245
- })
1246
- });
1247
- })
1234
+ return match([descriptor, backgroundItem]).with([P.any, { type: "color" }], ([, item]) => {
1235
+ var _a;
1236
+ return __spreadProps(__spreadValues({}, item), {
1237
+ payload: item.payload === null ? null : __spreadProps(__spreadValues({}, item.payload), {
1238
+ swatchId: (_a = context.replacementContext.swatchIds.get(item.payload.swatchId)) != null ? _a : item.payload.swatchId
1239
+ })
1240
+ });
1241
+ }).with([P.any, { type: "gradient" }], ([, item]) => {
1242
+ return __spreadProps(__spreadValues({}, item), {
1243
+ payload: __spreadProps(__spreadValues({}, item.payload), {
1244
+ stops: item.payload.stops.map((stop) => {
1245
+ var _a;
1246
+ return __spreadProps(__spreadValues({}, stop), {
1247
+ color: stop.color == null ? null : __spreadProps(__spreadValues({}, stop.color), {
1248
+ swatchId: (_a = context.replacementContext.swatchIds.get(stop.color.swatchId)) != null ? _a : stop.color.swatchId
1249
+ })
1250
+ });
1248
1251
  })
1249
- });
1250
- case "image":
1251
- return __spreadProps(__spreadValues({}, backgroundItem), {
1252
- payload: __spreadProps(__spreadValues({}, backgroundItem.payload), {
1253
- imageId: (_b = context.replacementContext.fileIds.get(backgroundItem.payload.imageId)) != null ? _b : backgroundItem.payload.imageId
1252
+ })
1253
+ });
1254
+ }).with([
1255
+ { version: 1 },
1256
+ { type: "image-v1", version: 1, payload: { image: { type: "makeswift-file" } } }
1257
+ ], ([, item]) => {
1258
+ var _a;
1259
+ return __spreadProps(__spreadValues({}, item), {
1260
+ payload: __spreadProps(__spreadValues({}, item.payload), {
1261
+ image: __spreadProps(__spreadValues({}, item.payload.image), {
1262
+ id: (_a = context.replacementContext.fileIds.get(item.payload.image.id)) != null ? _a : item.payload.image.id
1254
1263
  })
1255
- });
1256
- default:
1257
- return backgroundItem;
1258
- }
1264
+ })
1265
+ });
1266
+ }).with([P.any, { type: "image", payload: { imageId: P.string } }], ([, item]) => {
1267
+ var _a;
1268
+ return __spreadProps(__spreadValues({}, item), {
1269
+ payload: __spreadProps(__spreadValues({}, item.payload), {
1270
+ imageId: (_a = context.replacementContext.fileIds.get(item.payload.imageId)) != null ? _a : item.payload.imageId
1271
+ })
1272
+ });
1273
+ }).otherwise(() => backgroundItem);
1259
1274
  })
1260
1275
  }));
1261
1276
  }
@@ -1947,7 +1962,7 @@ function copy$2(value, context) {
1947
1962
  function copy$1(descriptor, value, context) {
1948
1963
  switch (descriptor.type) {
1949
1964
  case "Backgrounds":
1950
- return copy$e(value, context);
1965
+ return copy$e(descriptor, value, context);
1951
1966
  case "Grid":
1952
1967
  return copy$d(value, context);
1953
1968
  case "NavigationLinks":
@@ -4343,12 +4358,9 @@ function getSwatchIds(descriptor, prop) {
4343
4358
  function getBackgroundsFileIds(value) {
4344
4359
  var _a;
4345
4360
  return (_a = value == null ? void 0 : value.flatMap((override) => override.value).flatMap((backgroundItem) => {
4346
- switch (backgroundItem.type) {
4347
- case "image":
4348
- return [backgroundItem.payload.imageId];
4349
- default:
4350
- return [];
4351
- }
4361
+ return match(backgroundItem).with({ type: "image-v1", payload: { image: { type: "makeswift-file" } } }, (item) => [
4362
+ item.payload.image.id
4363
+ ]).with({ type: "image", payload: { imageId: P.string } }, (item) => [item.payload.imageId]).otherwise(() => []);
4352
4364
  })) != null ? _a : [];
4353
4365
  }
4354
4366
  function getFileIds(descriptor, prop) {
@@ -4367,7 +4379,7 @@ function getFileIds(descriptor, prop) {
4367
4379
  }
4368
4380
  case ImageControlType: {
4369
4381
  const value = prop;
4370
- return value == null ? [] : [value];
4382
+ return match(value).with(P.string, (f) => [f]).with({ type: "makeswift-file" }, (f) => [f.id]).with({ type: "external-file" }, () => []).otherwise(() => []);
4371
4383
  }
4372
4384
  case ShapeControlType: {
4373
4385
  return getShapeFileIds(descriptor, prop);
@@ -4734,5 +4746,5 @@ function configureStore({
4734
4746
  locales: getInitialState(locales != null ? locales : preloadedState == null ? void 0 : preloadedState.locales)
4735
4747
  }), applyMiddleware(thunk));
4736
4748
  }
4737
- export { useStyle as $, ResponsiveColor as A, Backgrounds as B, ComponentIcon as C, TextStyle as D, ElementID as E, Date as F, GapY as G, Font as H, Images as I, ResponsiveLength as J, TextArea$1 as K, Link$1 as L, Margin as M, Number as N, Table as O, Padding as P, TableFormFields as Q, RichTextPropControllerMessageType as R, Shadows as S, TableFormFieldsMessageType as T, Image$1 as U, ResponsiveOpacity as V, Width as W, NavigationLinks as X, SocialLinks as Y, RichText as Z, Video as _, copy$9 as a, getListTypographyIds as a$, getBorderSwatchIds as a0, getBoxShadowsSwatchIds as a1, getResponsiveColorSwatchIds as a2, StyleControlProperty as a3, ImageControlValueFormat as a4, isPropControllersHandle as a5, isRichTextV1Data as a6, isNonNullable as a7, TypographyControlType as a8, StyleControlType as a9, parseLocalesInput as aA, getDocument as aB, getElementId as aC, getIsInBuilder as aD, getReactComponent as aE, getBuilderEditMode as aF, getIsPreview as aG, getBackgroundsFileIds as aH, getBackgroundsSwatchIds as aI, Color as aJ, copyColorData as aK, copy as aL, merge as aM, getTranslatableData as aN, unstable_IconRadioGroupIcon as aO, unstable_IconRadioGroup as aP, Image as aQ, copyImageData as aR, Link as aS, copyLinkData as aT, List as aU, ListControlMessageType as aV, ListControl as aW, copyListData as aX, getListElementChildren as aY, getListSwatchIds as aZ, getListFileIds as a_, RichTextV2ControlType as aa, RichTextControlType as ab, SlotControlType as ac, StyleV2ControlType as ad, ListControlType as ae, ShapeControlType as af, LinkControlType as ag, ImageControlType as ah, IconRadioGroupControlType as ai, ColorControlType as aj, SelectControlType as ak, TextAreaControlType as al, TextInputControlType as am, getComponentPropControllerDescriptors as an, getPropControllers as ao, Types as ap, BorderPropControllerFormat as aq, ShadowsPropControllerFormat as ar, BorderRadiusPropControllerFormat as as, MarginPropControllerFormat as at, PaddingPropControllerFormat as au, WidthPropControllerFormat as av, configureStore as aw, copyElementTree as ax, getBreakpoints as ay, getElementTreeTranslatableData as az, copy$8 as b, InlinePlugin as b$, getListPageIds as b0, getListTranslatableData as b1, Select as b2, Shape as b3, ShapeControlMessageType as b4, ShapeControl as b5, copyShapeData as b6, getShapeElementChildren as b7, getShapeSwatchIds as b8, getShapeTypographyIds as b9, RichTextV2Mode as bA, RichTextV2ControlMessageType as bB, RichTextV2Control as bC, richTextV2DataToDescendents as bD, richTextV2DescendentsToData as bE, createRichTextV2Plugin as bF, unstable_Typography as bG, getTypographySwatchIds as bH, getTypographyTypographyIds as bI, TypographyActions as bJ, TYPOGRAPHY_KEY as bK, withTypography as bL, TypographyPlugin as bM, BlockActions as bN, ListActions as bO, onKeyDown as bP, withBlock as bQ, BlockPlugin as bR, withInlineMode as bS, InlineModePlugin as bT, withTextAlign as bU, TextAlignPlugin as bV, RootBlockType as bW, BlockType as bX, InlineType as bY, BlockTextAlignment as bZ, withInline as b_, getShapePageIds as ba, getShapeFileIds as bb, getShapeTranslatableData as bc, Slot as bd, SlotControlMessageType as be, SlotControl as bf, copySlotData as bg, mergeSlotData as bh, Style as bi, StyleControlMessageType as bj, StyleControl as bk, copyStyleData as bl, unstable_useStyleV2ClassName as bm, unstable_StyleV2 as bn, StyleV2ControlMessageType as bo, StyleV2Control as bp, TextArea as bq, TextInput as br, copyRichTextData as bs, ObjectType as bt, RichTextControlMessageType as bu, RichTextControl as bv, richTextDTOtoSelection as bw, richTextDTOtoDAO as bx, toSelectionDTO as by, richTextDAOToDTO as bz, createDocument as c, ElementUtils as c0, onChange$1 as c1, getValue$3 as c2, isLinkElement as c3, getInitialState$7 as c4, reducer$8 as c5, getDocument$1 as c6, getComponentsMeta as c7, getComponentPropControllerDescriptors$1 as c8, BuilderEditMode as c9, getDocumentKeysSortedByDepth as ca, getPropController as cb, getPropControllersHandle as cc, getElement as cd, getElementPropControllerDescriptors as ce, createPropController as cf, reducer$7 as cg, reducer$9 as ch, reducer$6 as ci, reducer$5 as cj, reducer$4 as ck, reducer$3 as cl, reducer$2 as cm, reducer$1 as cn, getInitialState$2 as co, descriptors as d, deepEqual as e, createDocumentReference as f, getPropControllerDescriptors as g, isElementReference as h, introspection as i, getDefaultLocale as j, getLocales as k, getSwatchIds as l, getFileIds as m, getTypographyIds as n, getTableIds as o, getPageIds as p, getElementChildren as q, ResponsiveIconRadioGroup as r, Border as s, BorderRadius as t, GapX as u, ResponsiveSelect as v, ResponsiveNumber as w, Checkbox as x, Grid as y, TextInput$1 as z };
4749
+ export { Video as $, TextInput$1 as A, Backgrounds as B, ComponentIcon as C, ResponsiveColor as D, ElementID as E, TextStyle as F, GapY as G, Date as H, Images as I, Font as J, ResponsiveLength as K, Link$1 as L, Margin as M, Number as N, TextArea$1 as O, Padding as P, Table as Q, RichTextPropControllerMessageType as R, Shadows as S, TableFormFieldsMessageType as T, TableFormFields as U, Image$1 as V, Width as W, ResponsiveOpacity as X, NavigationLinks as Y, SocialLinks as Z, RichText as _, copy$9 as a, getListFileIds as a$, useStyle as a0, getBorderSwatchIds as a1, getBoxShadowsSwatchIds as a2, getResponsiveColorSwatchIds as a3, StyleControlProperty as a4, ImageControlValueFormat as a5, isPropControllersHandle as a6, isRichTextV1Data as a7, isNonNullable as a8, TypographyControlType as a9, getElementTreeTranslatableData as aA, parseLocalesInput as aB, getDocument as aC, getElementId as aD, getIsInBuilder as aE, getReactComponent as aF, getBuilderEditMode as aG, getIsPreview as aH, getBackgroundsFileIds as aI, getBackgroundsSwatchIds as aJ, Color as aK, copyColorData as aL, copy as aM, merge as aN, getTranslatableData as aO, unstable_IconRadioGroupIcon as aP, unstable_IconRadioGroup as aQ, Image as aR, copyImageData as aS, Link as aT, copyLinkData as aU, List as aV, ListControlMessageType as aW, ListControl as aX, copyListData as aY, getListElementChildren as aZ, getListSwatchIds as a_, StyleControlType as aa, RichTextV2ControlType as ab, RichTextControlType as ac, SlotControlType as ad, StyleV2ControlType as ae, ListControlType as af, ShapeControlType as ag, LinkControlType as ah, ImageControlType as ai, IconRadioGroupControlType as aj, ColorControlType as ak, SelectControlType as al, TextAreaControlType as am, TextInputControlType as an, getComponentPropControllerDescriptors as ao, getPropControllers as ap, Types as aq, BorderPropControllerFormat as ar, ShadowsPropControllerFormat as as, BorderRadiusPropControllerFormat as at, MarginPropControllerFormat as au, PaddingPropControllerFormat as av, WidthPropControllerFormat as aw, configureStore as ax, copyElementTree as ay, getBreakpoints as az, copy$8 as b, withInline as b$, getListTypographyIds as b0, getListPageIds as b1, getListTranslatableData as b2, Select as b3, Shape as b4, ShapeControlMessageType as b5, ShapeControl as b6, copyShapeData as b7, getShapeElementChildren as b8, getShapeSwatchIds as b9, richTextDAOToDTO as bA, RichTextV2Mode as bB, RichTextV2ControlMessageType as bC, RichTextV2Control as bD, richTextV2DataToDescendents as bE, richTextV2DescendentsToData as bF, createRichTextV2Plugin as bG, unstable_Typography as bH, getTypographySwatchIds as bI, getTypographyTypographyIds as bJ, TypographyActions as bK, TYPOGRAPHY_KEY as bL, withTypography as bM, TypographyPlugin as bN, BlockActions as bO, ListActions as bP, onKeyDown as bQ, withBlock as bR, BlockPlugin as bS, withInlineMode as bT, InlineModePlugin as bU, withTextAlign as bV, TextAlignPlugin as bW, RootBlockType as bX, BlockType as bY, InlineType as bZ, BlockTextAlignment as b_, getShapeTypographyIds as ba, getShapePageIds as bb, getShapeFileIds as bc, getShapeTranslatableData as bd, Slot as be, SlotControlMessageType as bf, SlotControl as bg, copySlotData as bh, mergeSlotData as bi, Style as bj, StyleControlMessageType as bk, StyleControl as bl, copyStyleData as bm, unstable_useStyleV2ClassName as bn, unstable_StyleV2 as bo, StyleV2ControlMessageType as bp, StyleV2Control as bq, TextArea as br, TextInput as bs, copyRichTextData as bt, ObjectType as bu, RichTextControlMessageType as bv, RichTextControl as bw, richTextDTOtoSelection as bx, richTextDTOtoDAO as by, toSelectionDTO as bz, createDocument as c, InlinePlugin as c0, ElementUtils as c1, onChange$1 as c2, getValue$3 as c3, isLinkElement as c4, getInitialState$7 as c5, reducer$8 as c6, getDocument$1 as c7, getComponentsMeta as c8, getComponentPropControllerDescriptors$1 as c9, BuilderEditMode as ca, getDocumentKeysSortedByDepth as cb, getPropController as cc, getPropControllersHandle as cd, getElement as ce, getElementPropControllerDescriptors as cf, createPropController as cg, reducer$7 as ch, reducer$9 as ci, reducer$6 as cj, reducer$5 as ck, reducer$4 as cl, reducer$3 as cm, reducer$2 as cn, reducer$1 as co, getInitialState$2 as cp, descriptors as d, copy$e as e, deepEqual as f, createDocumentReference as g, getPropControllerDescriptors as h, introspection as i, isElementReference as j, getDefaultLocale as k, getLocales as l, getSwatchIds as m, getFileIds as n, getTypographyIds as o, getTableIds as p, getPageIds as q, getElementChildren as r, ResponsiveIconRadioGroup as s, Border as t, BorderRadius as u, GapX as v, ResponsiveSelect as w, ResponsiveNumber as x, Checkbox as y, Grid as z };
4738
4750
  //# sourceMappingURL=react-page.es.js.map