@makeswift/runtime 0.10.16 → 0.11.1

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.es.js +1 -1
  2. package/dist/Button.es.js +1 -1
  3. package/dist/Carousel.es.js +1 -1
  4. package/dist/Countdown.es.js +1 -1
  5. package/dist/Divider.es.js +1 -1
  6. package/dist/Embed.es.js +1 -1
  7. package/dist/Form.es.js +1 -1
  8. package/dist/Image.es.js +1 -1
  9. package/dist/LiveProvider.es.js +1 -1
  10. package/dist/Navigation.es.js +1 -1
  11. package/dist/PreviewProvider.cjs.js +8 -11
  12. package/dist/PreviewProvider.cjs.js.map +1 -1
  13. package/dist/PreviewProvider.es.js +10 -13
  14. package/dist/PreviewProvider.es.js.map +1 -1
  15. package/dist/ReadOnlyText.es.js +1 -1
  16. package/dist/ReadOnlyTextV2.es.js +1 -1
  17. package/dist/Root.es.js +1 -1
  18. package/dist/SocialLinks.es.js +1 -1
  19. package/dist/Video.es.js +1 -1
  20. package/dist/actions.cjs.js +8 -14
  21. package/dist/actions.cjs.js.map +1 -1
  22. package/dist/actions.es.js +8 -12
  23. package/dist/actions.es.js.map +1 -1
  24. package/dist/control-serialization.es.js +1 -1
  25. package/dist/controls.es.js +1 -1
  26. package/dist/index.cjs.js +18 -19
  27. package/dist/index.cjs.js.map +1 -1
  28. package/dist/index.es.js +20 -21
  29. package/dist/index.es.js.map +1 -1
  30. package/dist/index.es2.js +1 -1
  31. package/dist/index.es4.js +1 -1
  32. package/dist/index.es5.js +1 -1
  33. package/dist/index.es6.js +1 -1
  34. package/dist/index.es8.js +1 -1
  35. package/dist/index.es9.js +1 -1
  36. package/dist/main.cjs.js +1 -1
  37. package/dist/main.es.js +1 -1
  38. package/dist/react-page.cjs.js +42 -94
  39. package/dist/react-page.cjs.js.map +1 -1
  40. package/dist/react-page.es.js +35 -83
  41. package/dist/react-page.es.js.map +1 -1
  42. package/dist/slate.es.js +1 -1
  43. package/dist/toText.es.js +1 -1
  44. package/dist/types/src/api/react.d.ts +4 -1
  45. package/dist/types/src/api/react.d.ts.map +1 -1
  46. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  47. package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
  48. package/dist/types/src/index.d.ts +1 -1
  49. package/dist/types/src/index.d.ts.map +1 -1
  50. package/dist/types/src/next/client.d.ts +3 -2
  51. package/dist/types/src/next/client.d.ts.map +1 -1
  52. package/dist/types/src/runtimes/react/index.d.ts +1 -3
  53. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  54. package/dist/types/src/state/actions.d.ts +10 -14
  55. package/dist/types/src/state/actions.d.ts.map +1 -1
  56. package/dist/types/src/state/react-builder-preview.d.ts +1 -3
  57. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  58. package/dist/types/src/state/react-page.d.ts +1 -7
  59. package/dist/types/src/state/react-page.d.ts.map +1 -1
  60. package/dist/types/types/locale.d.ts +1 -1
  61. package/package.json +1 -1
  62. package/dist/types/src/state/modules/locales.d.ts +0 -15
  63. package/dist/types/src/state/modules/locales.d.ts.map +0 -1
package/dist/index.es.js CHANGED
@@ -38,8 +38,8 @@ import * as React from "react";
38
38
  import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
39
39
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
40
40
  import dynamic from "next/dynamic";
41
- import { f as deepEqual, g as createDocumentReference, h as getPropControllerDescriptors, j as isElementReference, k as getDefaultLocale, l as getLocales, m as getSwatchIds, n as getFileIds, o as getTypographyIds, p as getTableIds, q as getPageIds, r as getElementChildren, E as ElementID, B as Backgrounds, W as Width, s as ResponsiveIconRadioGroup, M as Margin, P as Padding, t as Border, u as BorderRadius, S as Shadows, G as GapY, v as GapX, w as ResponsiveSelect, x as ResponsiveNumber, y as Checkbox, z as Grid, A as TextInput, L as Link, D as ResponsiveColor, F as TextStyle, C as ComponentIcon, I as Images, N as Number$1, H as Date$1, J as Font, K as ResponsiveLength, O as TextArea, Q as Table, U as TableFormFields, V as Image, X as ResponsiveOpacity, Y as NavigationLinks, Z as SocialLinks, _ as RichText, $ as Video, a0 as useStyle, a1 as getBorderSwatchIds, a2 as getBoxShadowsSwatchIds, a3 as getResponsiveColorSwatchIds, a4 as StyleControlProperty, a5 as ImageControlValueFormat, a6 as isPropControllersHandle, a7 as isRichTextV1Data, a8 as isNonNullable$1, a9 as TypographyControlType, aa as StyleControlType, ab as RichTextV2ControlType, ac as RichTextControlType, ad as SlotControlType, ae as StyleV2ControlType, af as ListControlType, ag as ShapeControlType, ah as LinkControlType, ai as ImageControlType, aj as IconRadioGroupControlType, ak as ColorControlType, al as SelectControlType, am as TextAreaControlType, an as TextInputControlType, ao as getComponentPropControllerDescriptors, ap as getPropControllers, aq as Types, ar as BorderPropControllerFormat, as as ShadowsPropControllerFormat, at as BorderRadiusPropControllerFormat, au as MarginPropControllerFormat, av as PaddingPropControllerFormat, aw as WidthPropControllerFormat, ax as configureStore$1, ay as copyElementTree, az as getBreakpoints, aA as getElementTreeTranslatableData, aB as parseLocalesInput, aC as getDocument, aD as getElementId, aE as getIsInBuilder, aF as getReactComponent, aG as getBuilderEditMode, aH as getIsPreview } from "./react-page.es.js";
42
- import { A as ActionTypes, o as apiResourceFulfilled, p as registerComponentEffect, q as registerReactComponentEffect, t as registerComponentHandleEffect, v as mountComponentEffect } from "./actions.es.js";
41
+ import { f as deepEqual, g as createDocumentReference, h as getPropControllerDescriptors, j as isElementReference, k as getSwatchIds, l as getFileIds, m as getTypographyIds, n as getTableIds, o as getPageIds, p as getElementChildren, E as ElementID, B as Backgrounds, W as Width, q as ResponsiveIconRadioGroup, M as Margin, P as Padding, r as Border, s as BorderRadius, S as Shadows, G as GapY, t as GapX, u as ResponsiveSelect, v as ResponsiveNumber, w as Checkbox, x as Grid, y as TextInput, L as Link, z as ResponsiveColor, A as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, H as ResponsiveLength, J as TextArea, K as Table, O as TableFormFields, Q as Image, U as ResponsiveOpacity, V as NavigationLinks, X as SocialLinks, Y as RichText, Z as Video, _ as useStyle, $ as getBorderSwatchIds, a0 as getBoxShadowsSwatchIds, a1 as getResponsiveColorSwatchIds, a2 as StyleControlProperty, a3 as ImageControlValueFormat, a4 as isPropControllersHandle, a5 as isRichTextV1Data, a6 as isNonNullable$1, a7 as TypographyControlType, a8 as StyleControlType, a9 as RichTextV2ControlType, aa as RichTextControlType, ab as SlotControlType, ac as StyleV2ControlType, ad as ListControlType, ae as ShapeControlType, af as LinkControlType, ag as ImageControlType, ah as IconRadioGroupControlType, ai as ColorControlType, aj as SelectControlType, ak as TextAreaControlType, al as TextInputControlType, am as getComponentPropControllerDescriptors, an as getPropControllers, ao as Types, ap as BorderPropControllerFormat, aq as ShadowsPropControllerFormat, ar as BorderRadiusPropControllerFormat, as as MarginPropControllerFormat, at as PaddingPropControllerFormat, au as WidthPropControllerFormat, av as configureStore$1, aw as copyElementTree, ax as getBreakpoints, ay as getElementTreeTranslatableData, az as getDocument, aA as getElementId, aB as getIsInBuilder, aC as getReactComponent, aD as getBuilderEditMode, aE as getIsPreview } from "./react-page.es.js";
42
+ import { A as ActionTypes, n as apiResourceFulfilled, o as registerComponentEffect, p as registerReactComponentEffect, q as registerComponentHandleEffect, t as mountComponentEffect } from "./actions.es.js";
43
43
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
44
44
  import { N as NumberControlType, C as CheckboxControlType } from "./number.es.js";
45
45
  import { C as ComboboxControlType } from "./combobox.es.js";
@@ -410,7 +410,10 @@ class MakeswiftClient {
410
410
  if (cacheResult)
411
411
  return cacheResult;
412
412
  const result = await this.makeswiftApiClient.dispatch(fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, locale));
413
- this.setLocalizedResourceId(globalElementId, (_a = result == null ? void 0 : result.id) != null ? _a : null);
413
+ this.setLocalizedResourceId({
414
+ resourceId: globalElementId,
415
+ localizedResourceId: (_a = result == null ? void 0 : result.id) != null ? _a : null
416
+ });
414
417
  return result;
415
418
  }
416
419
  readPagePathnameSlice(pageId) {
@@ -448,7 +451,10 @@ class MakeswiftClient {
448
451
  var _a;
449
452
  return (_a = this.localizedResourcesMap) == null ? void 0 : _a.get(resourceId);
450
453
  }
451
- setLocalizedResourceId(resourceId, localizedResourceId) {
454
+ setLocalizedResourceId({
455
+ resourceId,
456
+ localizedResourceId
457
+ }) {
452
458
  this.localizedResourcesMap.set(resourceId, localizedResourceId);
453
459
  }
454
460
  }
@@ -993,19 +999,13 @@ Received "${apiKey}" instead.`);
993
999
  }
994
1000
  async getPageSnapshot(pathname, {
995
1001
  preview: previewOverride = false,
996
- unstable_locale
1002
+ locale: localeInput
997
1003
  } = {}) {
998
- var _a, _b, _c;
1004
+ var _a, _b;
999
1005
  const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
1000
- const defaultLocale = (_b = getDefaultLocale(this.runtime.store.getState())) == null ? void 0 : _b.toString();
1001
- const locale = unstable_locale === defaultLocale ? null : unstable_locale;
1002
1006
  const searchParams = new URLSearchParams();
1003
- if (locale) {
1004
- const locales = getLocales(this.runtime.store.getState()).map((locale2) => locale2.toString());
1005
- if (!locales.includes(locale)) {
1006
- throw new Error(`Locale "${locale}" is not included in the locales: ${locales}. Please add the locale to the locales on the ReactRuntime.`);
1007
- }
1008
- searchParams.set("locale", locale);
1007
+ if (localeInput) {
1008
+ searchParams.set("locale", localeInput);
1009
1009
  }
1010
1010
  const response = await this.fetch(`/${this.siteVersion == null ? "v2" : "v3"}/pages/${encodeURIComponent(pathname)}/document?${searchParams.toString()}`, {
1011
1011
  headers: { "Makeswift-Site-Version": siteVersion }
@@ -1018,7 +1018,8 @@ Received "${apiKey}" instead.`);
1018
1018
  }
1019
1019
  const document2 = await response.json();
1020
1020
  const baseLocalizedPage = document2.localizedPages.find(({ parentId }) => parentId == null);
1021
- const { cacheData, localizedResourcesMap } = await this.introspect((_c = baseLocalizedPage == null ? void 0 : baseLocalizedPage.data) != null ? _c : document2.data, previewOverride, locale != null ? locale : void 0);
1021
+ const locale = document2.locale;
1022
+ const { cacheData, localizedResourcesMap } = await this.introspect((_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.data) != null ? _b : document2.data, previewOverride, locale != null ? locale : void 0);
1022
1023
  const apiOrigin = this.apiOrigin.href;
1023
1024
  const preview = siteVersion === MakeswiftSiteVersion.Working;
1024
1025
  return {
@@ -1027,7 +1028,7 @@ Received "${apiKey}" instead.`);
1027
1028
  apiOrigin,
1028
1029
  preview,
1029
1030
  localizedResourcesMap,
1030
- locale: locale != null ? locale : null
1031
+ locale
1031
1032
  };
1032
1033
  }
1033
1034
  async getSwatch(swatchId) {
@@ -1160,7 +1161,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1160
1161
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1161
1162
  return res.json(fonts2);
1162
1163
  }
1163
- const version = "0.10.16";
1164
+ const version = "0.11.1";
1164
1165
  async function handler(req, res, { apiKey, siteVersions }) {
1165
1166
  if (req.query.secret !== apiKey) {
1166
1167
  return res.status(401).json({ message: "Unauthorized" });
@@ -3902,13 +3903,11 @@ function isDomNodeHandle(value) {
3902
3903
  }
3903
3904
  class ReactRuntime {
3904
3905
  constructor({
3905
- breakpoints,
3906
- unstable_i18n
3906
+ breakpoints
3907
3907
  } = {}) {
3908
3908
  __publicField(this, "store");
3909
3909
  this.store = configureStore$1({
3910
- breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0,
3911
- locales: unstable_i18n ? parseLocalesInput(unstable_i18n) : void 0
3910
+ breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0
3912
3911
  });
3913
3912
  registerBuiltinComponents(this);
3914
3913
  }