@makeswift/runtime 0.7.19 → 0.8.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 (222) hide show
  1. package/dist/Box.cjs.js +13 -10
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +8 -5
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +39 -36
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +14 -11
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +36 -33
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +11 -8
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +29 -53
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +4 -28
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +10 -34
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +4 -28
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +5 -29
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +4 -28
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +75 -72
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +13 -10
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +21 -18
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +14 -11
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +11 -8
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +11 -8
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +39 -36
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +13 -10
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +11 -8
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +11 -8
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +18 -15
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +14 -11
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/Root.cjs.js +12 -9
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +10 -7
  52. package/dist/Root.es.js.map +1 -1
  53. package/dist/SocialLinks.cjs.js +15 -12
  54. package/dist/SocialLinks.cjs.js.map +1 -1
  55. package/dist/SocialLinks.es.js +8 -5
  56. package/dist/SocialLinks.es.js.map +1 -1
  57. package/dist/Text.cjs.js +6 -3
  58. package/dist/Text.cjs.js.map +1 -1
  59. package/dist/Text.es.js +7 -4
  60. package/dist/Text.es.js.map +1 -1
  61. package/dist/Video.cjs.js +5 -29
  62. package/dist/Video.cjs.js.map +1 -1
  63. package/dist/Video.es.js +4 -28
  64. package/dist/Video.es.js.map +1 -1
  65. package/dist/actions.cjs.js +0 -13
  66. package/dist/actions.cjs.js.map +1 -1
  67. package/dist/actions.es.js +1 -12
  68. package/dist/actions.es.js.map +1 -1
  69. package/dist/components.cjs.js +11 -8
  70. package/dist/components.cjs.js.map +1 -1
  71. package/dist/components.es.js +11 -8
  72. package/dist/components.es.js.map +1 -1
  73. package/dist/controls.cjs.js +1 -0
  74. package/dist/controls.cjs.js.map +1 -1
  75. package/dist/controls.es.js +1 -1
  76. package/dist/descriptors.cjs.js +13 -0
  77. package/dist/descriptors.cjs.js.map +1 -1
  78. package/dist/descriptors.es.js +13 -1
  79. package/dist/descriptors.es.js.map +1 -1
  80. package/dist/index.cjs.js +368 -1508
  81. package/dist/index.cjs.js.map +1 -1
  82. package/dist/index.cjs2.js +22 -20
  83. package/dist/index.cjs2.js.map +1 -1
  84. package/dist/index.cjs3.js +2 -1
  85. package/dist/index.cjs3.js.map +1 -1
  86. package/dist/index.cjs4.js +2 -2
  87. package/dist/index.cjs4.js.map +1 -1
  88. package/dist/index.cjs5.js +4 -4
  89. package/dist/index.cjs5.js.map +1 -1
  90. package/dist/index.cjs6.js +6 -3
  91. package/dist/index.cjs6.js.map +1 -1
  92. package/dist/index.cjs7.js +19 -16
  93. package/dist/index.cjs7.js.map +1 -1
  94. package/dist/index.es.js +334 -1454
  95. package/dist/index.es.js.map +1 -1
  96. package/dist/index.es2.js +4 -2
  97. package/dist/index.es2.js.map +1 -1
  98. package/dist/index.es3.js +2 -1
  99. package/dist/index.es3.js.map +1 -1
  100. package/dist/index.es4.js +1 -1
  101. package/dist/index.es5.js +3 -3
  102. package/dist/index.es5.js.map +1 -1
  103. package/dist/index.es6.js +6 -3
  104. package/dist/index.es6.js.map +1 -1
  105. package/dist/index.es7.js +15 -12
  106. package/dist/index.es7.js.map +1 -1
  107. package/dist/introspection.cjs.js +2 -5
  108. package/dist/introspection.cjs.js.map +1 -1
  109. package/dist/introspection.es.js +2 -4
  110. package/dist/introspection.es.js.map +1 -1
  111. package/dist/isNonNullable.cjs.js +6 -0
  112. package/dist/isNonNullable.cjs.js.map +1 -0
  113. package/dist/isNonNullable.es.js +5 -0
  114. package/dist/isNonNullable.es.js.map +1 -0
  115. package/dist/leaf.cjs.js +11 -11
  116. package/dist/leaf.cjs.js.map +1 -1
  117. package/dist/leaf.es.js +2 -2
  118. package/dist/main.cjs.js +1 -0
  119. package/dist/main.cjs.js.map +1 -1
  120. package/dist/main.es.js +1 -0
  121. package/dist/main.es.js.map +1 -1
  122. package/dist/next.cjs.js +8 -6
  123. package/dist/next.cjs.js.map +1 -1
  124. package/dist/next.es.js +9 -6
  125. package/dist/next.es.js.map +1 -1
  126. package/dist/prop-controllers.cjs.js +1 -0
  127. package/dist/prop-controllers.cjs.js.map +1 -1
  128. package/dist/prop-controllers.es.js +1 -0
  129. package/dist/prop-controllers.es.js.map +1 -1
  130. package/dist/react.cjs.js +6 -3
  131. package/dist/react.cjs.js.map +1 -1
  132. package/dist/react.es.js +6 -3
  133. package/dist/react.es.js.map +1 -1
  134. package/dist/responsive-style.cjs.js +917 -0
  135. package/dist/responsive-style.cjs.js.map +1 -0
  136. package/dist/responsive-style.es.js +853 -0
  137. package/dist/responsive-style.es.js.map +1 -0
  138. package/dist/slate.cjs.js +5 -25
  139. package/dist/slate.cjs.js.map +1 -1
  140. package/dist/slate.es.js +5 -25
  141. package/dist/slate.es.js.map +1 -1
  142. package/dist/types/src/api/graphql/documents/queries.d.ts +0 -2
  143. package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
  144. package/dist/types/src/api/graphql/generated/types.d.ts +0 -70
  145. package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
  146. package/dist/types/src/api/react.d.ts +0 -3
  147. package/dist/types/src/api/react.d.ts.map +1 -1
  148. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  149. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  150. package/dist/types/src/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +1 -0
  151. package/dist/types/src/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
  152. package/dist/types/src/components/builtin/Form/components/Field/index.d.ts +1 -0
  153. package/dist/types/src/components/builtin/Form/components/Field/index.d.ts.map +1 -1
  154. package/dist/types/src/components/builtin/Form/components/Spinner/index.d.ts +1 -0
  155. package/dist/types/src/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
  156. package/dist/types/src/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts +1 -0
  157. package/dist/types/src/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
  158. package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts +1 -0
  159. package/dist/types/src/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
  160. package/dist/types/src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts +1 -0
  161. package/dist/types/src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts.map +1 -1
  162. package/dist/types/src/components/builtin/SocialLinks/options.d.ts +1 -0
  163. package/dist/types/src/components/builtin/SocialLinks/options.d.ts.map +1 -1
  164. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +1 -0
  165. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
  166. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts +1 -0
  167. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +1 -1
  168. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +1 -0
  169. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -1
  170. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +1 -0
  171. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  172. package/dist/types/src/components/page/Page.d.ts +1 -0
  173. package/dist/types/src/components/page/Page.d.ts.map +1 -1
  174. package/dist/types/src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts +1 -0
  175. package/dist/types/src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
  176. package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts +1 -0
  177. package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  178. package/dist/types/src/controls/rich-text/types.d.ts +20 -6
  179. package/dist/types/src/controls/rich-text/types.d.ts.map +1 -1
  180. package/dist/types/src/next/api-handler/handlers/element-tree.d.ts +12 -0
  181. package/dist/types/src/next/api-handler/handlers/element-tree.d.ts.map +1 -0
  182. package/dist/types/src/next/api-handler/handlers/fonts.d.ts +18 -0
  183. package/dist/types/src/next/api-handler/handlers/fonts.d.ts.map +1 -0
  184. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +17 -0
  185. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -0
  186. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts +8 -0
  187. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -0
  188. package/dist/types/src/next/api-handler/handlers/revalidate.d.ts +13 -0
  189. package/dist/types/src/next/api-handler/handlers/revalidate.d.ts.map +1 -0
  190. package/dist/types/src/next/api-handler/index.d.ts +19 -0
  191. package/dist/types/src/next/api-handler/index.d.ts.map +1 -0
  192. package/dist/types/src/next/client.d.ts +11 -35
  193. package/dist/types/src/next/client.d.ts.map +1 -1
  194. package/dist/types/src/next/document.d.ts +1 -0
  195. package/dist/types/src/next/document.d.ts.map +1 -1
  196. package/dist/types/src/next/index.d.ts +1 -6
  197. package/dist/types/src/next/index.d.ts.map +1 -1
  198. package/dist/types/src/next/preview-mode.d.ts +1 -0
  199. package/dist/types/src/next/preview-mode.d.ts.map +1 -1
  200. package/dist/types/src/runtimes/react/components/render-hook.d.ts +1 -0
  201. package/dist/types/src/runtimes/react/components/render-hook.d.ts.map +1 -1
  202. package/dist/types/src/runtimes/react/controls/control.d.ts +1 -0
  203. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  204. package/dist/types/src/runtimes/react/controls/list.d.ts +1 -0
  205. package/dist/types/src/runtimes/react/controls/list.d.ts.map +1 -1
  206. package/dist/types/src/runtimes/react/controls/shape.d.ts +1 -0
  207. package/dist/types/src/runtimes/react/controls/shape.d.ts.map +1 -1
  208. package/dist/types/src/runtimes/react/controls.d.ts +1 -0
  209. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  210. package/dist/types/src/state/actions.d.ts +2 -22
  211. package/dist/types/src/state/actions.d.ts.map +1 -1
  212. package/dist/types/src/state/makeswift-api-client.d.ts +4 -9
  213. package/dist/types/src/state/makeswift-api-client.d.ts.map +1 -1
  214. package/dist/types/src/state/modules/api-resources.d.ts +4 -4
  215. package/dist/types/src/state/modules/api-resources.d.ts.map +1 -1
  216. package/package.json +3 -2
  217. package/dist/types/src/api/introspection.d.ts +0 -11
  218. package/dist/types/src/api/introspection.d.ts.map +0 -1
  219. package/dist/types/src/next/api-handler.d.ts +0 -48
  220. package/dist/types/src/next/api-handler.d.ts.map +0 -1
  221. package/dist/types/src/next/snapshots.d.ts +0 -152
  222. package/dist/types/src/next/snapshots.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -35,15 +35,12 @@ var __publicField = (obj, key, value) => {
35
35
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
36
  return value;
37
37
  };
38
- var _c;
39
38
  var React = require("react");
40
39
  var withSelector = require("use-sync-external-store/shim/with-selector");
41
40
  var dynamic = require("next/dynamic");
42
41
  var constants = require("./constants.cjs.js");
43
42
  var actions = require("./actions.cjs.js");
44
- var css = require("@emotion/css");
45
- var serialize = require("@emotion/serialize");
46
- var utils = require("@emotion/utils");
43
+ var responsiveStyle = require("./responsive-style.cjs.js");
47
44
  var jsxRuntime = require("react/jsx-runtime");
48
45
  var descriptors = require("./descriptors.cjs.js");
49
46
  require("slate");
@@ -52,19 +49,20 @@ var combobox = require("./combobox.cjs.js");
52
49
  require("slate-react");
53
50
  var shim = require("use-sync-external-store/shim");
54
51
  var introspection = require("./introspection.cjs.js");
55
- var redux = require("redux");
56
- var thunk = require("redux-thunk");
57
- var types = require("./types.cjs.js");
52
+ var isNonNullable = require("./isNonNullable.cjs.js");
58
53
  var boxModels = require("./box-models.cjs.js");
59
54
  var ColorHelper = require("color");
60
55
  var scrollIntoView = require("scroll-into-view-if-needed");
56
+ var css = require("@emotion/css");
61
57
  var reactDom = require("react-dom");
62
58
  var parse = require("html-react-parser");
63
59
  var Head = require("next/head");
60
+ var types = require("./types.cjs.js");
64
61
  var createEmotionServer = require("@emotion/server/create-instance");
65
62
  var NextDocument = require("next/document");
66
- var cookie = require("cookie");
67
63
  var Cors = require("cors");
64
+ var pathToRegexp = require("path-to-regexp");
65
+ var cookie = require("cookie");
68
66
  var httpProxy = require("http-proxy");
69
67
  var setCookieParser = require("set-cookie-parser");
70
68
  var uuid = require("uuid");
@@ -94,7 +92,6 @@ function _interopNamespace(e) {
94
92
  }
95
93
  var React__namespace = /* @__PURE__ */ _interopNamespace(React);
96
94
  var dynamic__default = /* @__PURE__ */ _interopDefaultLegacy(dynamic);
97
- var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
98
95
  var ColorHelper__default = /* @__PURE__ */ _interopDefaultLegacy(ColorHelper);
99
96
  var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
100
97
  var parse__default = /* @__PURE__ */ _interopDefaultLegacy(parse);
@@ -147,661 +144,6 @@ function BodySnippet({
147
144
  }, [code, cleanup]);
148
145
  return null;
149
146
  }
150
- async function introspect(element, client, store) {
151
- const descriptors$1 = constants.getPropControllerDescriptors(store.getState());
152
- const swatchIds = /* @__PURE__ */ new Set();
153
- const fileIds = /* @__PURE__ */ new Set();
154
- const typographyIds = /* @__PURE__ */ new Set();
155
- const tableIds = /* @__PURE__ */ new Set();
156
- const pageIds = /* @__PURE__ */ new Set();
157
- const remaining = [element];
158
- const seen = /* @__PURE__ */ new Set();
159
- let current;
160
- while (current = remaining.pop()) {
161
- let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
162
- Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
163
- introspection.getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
164
- swatchIds.add(swatchId);
165
- });
166
- introspection.getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
167
- introspection.getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
168
- introspection.getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
169
- introspection.getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
170
- introspection.getElementChildren(descriptor, props[propName]).forEach((child) => {
171
- if (!seen.has(child.key)) {
172
- seen.add(child.key);
173
- remaining.push(child);
174
- }
175
- });
176
- if (descriptor.type === descriptors.ShapeControlType) {
177
- const prop = props[propName];
178
- if (prop == null)
179
- return;
180
- getResourcesFromElementDescriptors(descriptor.config.type, prop);
181
- }
182
- if (descriptor.type === descriptors.ListControlType) {
183
- const prop = props[propName];
184
- if (prop == null)
185
- return;
186
- prop.forEach((item) => {
187
- getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
188
- });
189
- }
190
- if (descriptor.type === descriptors.Types.Shape) {
191
- const prop = props[propName];
192
- if (prop == null)
193
- return;
194
- getResourcesFromElementDescriptors(descriptor.options.type, prop);
195
- }
196
- if (descriptor.type === descriptors.Types.List) {
197
- const prop = props[propName];
198
- if (prop == null)
199
- return;
200
- prop.forEach((item) => {
201
- getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
202
- });
203
- }
204
- });
205
- };
206
- let element2;
207
- if (constants.isElementReference(current)) {
208
- const globalElement = await client.fetchGlobalElement(current.value);
209
- const elementData = globalElement == null ? void 0 : globalElement.data;
210
- if (elementData == null)
211
- continue;
212
- element2 = elementData;
213
- } else {
214
- element2 = current;
215
- }
216
- const elementDescriptors = descriptors$1.get(element2.type);
217
- if (elementDescriptors == null)
218
- continue;
219
- getResourcesFromElementDescriptors(elementDescriptors, element2.props);
220
- }
221
- const typographies = await client.fetchTypographies([...typographyIds]);
222
- typographies.forEach((typography) => {
223
- typography == null ? void 0 : typography.style.forEach((style) => {
224
- var _a;
225
- const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
226
- if (swatchId != null)
227
- swatchIds.add(swatchId);
228
- });
229
- });
230
- return {
231
- swatchIds: [...swatchIds],
232
- fileIds: [...fileIds],
233
- typographyIds: [...typographyIds],
234
- tableIds: [...tableIds],
235
- pageIds: [...pageIds]
236
- };
237
- }
238
- function normalizeToMakeswiftResources(partialResources) {
239
- const resources = {
240
- swatches: (partialResources == null ? void 0 : partialResources.swatches) || [],
241
- typographies: (partialResources == null ? void 0 : partialResources.typographies) || [],
242
- files: (partialResources == null ? void 0 : partialResources.files) || [],
243
- tables: (partialResources == null ? void 0 : partialResources.tables) || [],
244
- pagePathnameSlices: (partialResources == null ? void 0 : partialResources.pagePathnameSlices) || [],
245
- globalElements: (partialResources == null ? void 0 : partialResources.globalElements) || [],
246
- snippets: (partialResources == null ? void 0 : partialResources.snippets) || [],
247
- fonts: (partialResources == null ? void 0 : partialResources.fonts) || [],
248
- pageMetadata: (partialResources == null ? void 0 : partialResources.pageMetadata) || {},
249
- pageSeo: (partialResources == null ? void 0 : partialResources.pageSeo) || {}
250
- };
251
- return resources;
252
- }
253
- function fileToFileSnapshot(file) {
254
- return file;
255
- }
256
- function is(x, y) {
257
- if (x === y)
258
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
259
- return x !== x && y !== y;
260
- }
261
- const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
262
- const shallowEqual = (a, b) => {
263
- if (is(a, b))
264
- return true;
265
- if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
266
- return false;
267
- const keysA = Object.keys(a);
268
- const keysB = Object.keys(b);
269
- if (keysA.length !== keysB.length)
270
- return false;
271
- for (let i = 0; i < keysA.length; i += 1) {
272
- if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
273
- return false;
274
- }
275
- return true;
276
- };
277
- const { hasOwnProperty } = Object.prototype;
278
- const deepEqual = (a, b) => {
279
- if (shallowEqual(a, b))
280
- return true;
281
- if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
282
- return false;
283
- const keysA = Object.keys(a);
284
- const keysB = Object.keys(b);
285
- if (keysA.length !== keysB.length)
286
- return false;
287
- for (let i = 0; i < keysA.length; i += 1) {
288
- if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
289
- return false;
290
- }
291
- return true;
292
- };
293
- function isNonNullable(value) {
294
- return value != null;
295
- }
296
- function getSnapshotResourcesFromSerializedState(serializedState) {
297
- const resources = {
298
- swatches: serializedState.Swatch.filter((_) => true),
299
- typographies: serializedState.Typography.filter((_) => true),
300
- files: serializedState.File.map(({ id, value }) => value.__typename === types.APIResourceType.File ? { id, value: fileToFileSnapshot(value) } : null).filter(isNonNullable),
301
- tables: serializedState.Table.filter((_) => true),
302
- pagePathnameSlices: serializedState.PagePathnameSlice.filter((_) => true),
303
- globalElements: serializedState.GlobalElement.filter((_) => true)
304
- };
305
- return resources;
306
- }
307
- function getInitialState(serializedState = {
308
- Swatch: [],
309
- File: [],
310
- Typography: [],
311
- PagePathnameSlice: [],
312
- GlobalElement: [],
313
- Table: [],
314
- Snippet: [],
315
- Page: [],
316
- Site: []
317
- }) {
318
- return new Map(Object.entries(serializedState).map(([apiResourceType, resources]) => [
319
- apiResourceType,
320
- new Map(resources.map(({ id, value }) => [id, value]))
321
- ]));
322
- }
323
- function getSerializedState$1(state) {
324
- const resourceMap = {
325
- Swatch: [],
326
- File: [],
327
- Typography: [],
328
- PagePathnameSlice: [],
329
- GlobalElement: [],
330
- Table: [],
331
- Snippet: [],
332
- Page: [],
333
- Site: []
334
- };
335
- Array.from(state.entries()).forEach(([resourceType, resources]) => {
336
- const particularResourceMap = [];
337
- Array.from(resources.entries()).forEach(([id, value]) => {
338
- if (value != null) {
339
- particularResourceMap.push({ id, value });
340
- }
341
- });
342
- resourceMap[resourceType] = particularResourceMap;
343
- });
344
- return resourceMap;
345
- }
346
- function getHasAPIResource$1(state, resourceType, resourceId) {
347
- var _a, _b;
348
- return (_b = (_a = state.get(resourceType)) == null ? void 0 : _a.has(resourceId)) != null ? _b : false;
349
- }
350
- function getAPIResource$1(state, resourceType, resourceId) {
351
- var _a;
352
- const resource = (_a = state.get(resourceType)) == null ? void 0 : _a.get(resourceId);
353
- return (resource == null ? void 0 : resource.__typename) === resourceType ? resource : null;
354
- }
355
- function reducer$1(state = getInitialState(), action) {
356
- switch (action.type) {
357
- case actions.ActionTypes.API_RESOURCE_FULFILLED: {
358
- const { resourceType, resourceId, resource } = action.payload;
359
- return new Map(state).set(resourceType, new Map(state.get(resourceType)).set(resourceId, resource));
360
- }
361
- case actions.ActionTypes.INTROSPECTED_RESOURCES_FULFILLED: {
362
- const { introspectedResourceIds, introspectedResources } = action.payload;
363
- const swatches = new Map(state.get(types.APIResourceType.Swatch));
364
- const files = new Map(state.get(types.APIResourceType.File));
365
- const typographies = new Map(state.get(types.APIResourceType.Typography));
366
- const pagePathnameSlices = new Map(state.get(types.APIResourceType.PagePathnameSlice));
367
- const tables = new Map(state.get(types.APIResourceType.Table));
368
- introspectedResourceIds.swatchIds.forEach((swatchId, idx) => {
369
- swatches.set(swatchId, introspectedResources.swatches[idx]);
370
- });
371
- introspectedResourceIds.fileIds.forEach((fileId, idx) => {
372
- files.set(fileId, introspectedResources.files[idx]);
373
- });
374
- introspectedResourceIds.typographyIds.forEach((typographyId, idx) => {
375
- typographies.set(typographyId, introspectedResources.typographies[idx]);
376
- });
377
- introspectedResourceIds.pageIds.forEach((pageId, idx) => {
378
- const pagePathnameSlice = introspectedResources.pagePathnamesById[idx];
379
- if (pagePathnameSlice == null) {
380
- pagePathnameSlices.set(pageId, pagePathnameSlice);
381
- } else {
382
- const nodeId = Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64");
383
- pagePathnameSlices.set(nodeId, __spreadProps(__spreadValues({}, pagePathnameSlice), { id: nodeId }));
384
- }
385
- });
386
- introspectedResourceIds.tableIds.forEach((tableId, idx) => {
387
- tables.set(tableId, introspectedResources.tables[idx]);
388
- });
389
- return new Map(state).set(types.APIResourceType.Swatch, swatches).set(types.APIResourceType.File, files).set(types.APIResourceType.Typography, typographies).set(types.APIResourceType.PagePathnameSlice, pagePathnameSlices).set(types.APIResourceType.Table, tables);
390
- }
391
- case actions.ActionTypes.TYPOGRAPHIES_FULFILLED: {
392
- const typographies = new Map(state.get(types.APIResourceType.Typography));
393
- action.payload.typographyIds.forEach((typographyId, idx) => {
394
- typographies.set(typographyId, action.payload.typographies[idx]);
395
- });
396
- return new Map(state).set(types.APIResourceType.Typography, typographies);
397
- }
398
- case actions.ActionTypes.CHANGE_API_RESOURCE: {
399
- const existingApiResource = getAPIResource$1(state, action.payload.resource.__typename, action.payload.resource.id);
400
- if (deepEqual(existingApiResource, action.payload.resource))
401
- return state;
402
- return new Map(state).set(action.payload.resource.__typename, new Map(state.get(action.payload.resource.__typename)).set(action.payload.resource.id, action.payload.resource));
403
- }
404
- case actions.ActionTypes.EVICT_API_RESOURCE: {
405
- const [resourceType, resourceId] = action.payload.id.split(":");
406
- if (!(resourceType in types.APIResourceType))
407
- return state;
408
- const resources = new Map(state.get(resourceType));
409
- const deleted = resources.delete(resourceId);
410
- return deleted ? new Map(state).set(resourceType, resources) : state;
411
- }
412
- default:
413
- return state;
414
- }
415
- }
416
- const SwatchFragment = `
417
- fragment Swatch on Swatch {
418
- __typename
419
- id
420
- hue
421
- saturation
422
- lightness
423
- }
424
- `;
425
- const FileFragment = `
426
- fragment File on File {
427
- __typename
428
- id
429
- name
430
- publicUrl: publicUrlV2
431
- extension
432
- dimensions {
433
- width
434
- height
435
- }
436
- }
437
- `;
438
- const TypographyFragment = `
439
- fragment Typography on Typography {
440
- __typename
441
- id
442
- name
443
- style {
444
- deviceId
445
- value {
446
- fontFamily
447
- fontSize {
448
- value
449
- unit
450
- }
451
- color {
452
- swatchId
453
- alpha
454
- }
455
- lineHeight
456
- letterSpacing
457
- fontWeight
458
- textAlign
459
- uppercase
460
- underline
461
- strikethrough
462
- italic
463
- }
464
- }
465
- }
466
- `;
467
- const PagePathnameSliceFragment = `
468
- fragment PagePathnameSlice on PagePathnameSlice {
469
- __typename
470
- id
471
- pathname
472
- }
473
- `;
474
- const GlobalElementFragment = `
475
- fragment GlobalElement on GlobalElement {
476
- __typename
477
- id
478
- data
479
- }
480
- `;
481
- const TableFragment = `
482
- fragment Table on Table {
483
- __typename
484
- id
485
- name
486
- columns {
487
- __typename
488
- id
489
- name
490
-
491
- ... on MultipleSelectTableColumn {
492
- options {
493
- id
494
- name
495
- }
496
- }
497
-
498
- ... on SingleSelectTableColumn {
499
- options {
500
- id
501
- name
502
- }
503
- }
504
- }
505
- }
506
- `;
507
- const IntrospectedResourcesQuery = `
508
- query IntrospectedResources(
509
- $swatchIds: [ID!]!
510
- $fileIds: [ID!]!
511
- $typographyIds: [ID!]!
512
- $pageIds: [ID!]!
513
- $tableIds: [ID!]!
514
- ) {
515
- swatches(ids: $swatchIds) {
516
- ...Swatch
517
- }
518
-
519
- files(ids: $fileIds) {
520
- ...File
521
- }
522
-
523
- typographies(ids: $typographyIds) {
524
- ...Typography
525
- }
526
-
527
- pagePathnamesById(ids: $pageIds) {
528
- ...PagePathnameSlice
529
- }
530
-
531
- tables(ids: $tableIds) {
532
- ...Table
533
- }
534
- }
535
-
536
- ${SwatchFragment}
537
- ${FileFragment}
538
- ${TypographyFragment}
539
- ${PagePathnameSliceFragment}
540
- ${TableFragment}
541
- `;
542
- const SwatchQuery = `
543
- query Swatch($swatchId: ID!) {
544
- swatch(id: $swatchId) {
545
- ...Swatch
546
- }
547
- }
548
-
549
- ${SwatchFragment}
550
- `;
551
- const FileQuery = `
552
- query File($fileId: ID!) {
553
- file(id: $fileId) {
554
- ...File
555
- }
556
- }
557
-
558
- ${FileFragment}
559
- `;
560
- const TypographyQuery = `
561
- query Typography($typographyId: ID!) {
562
- typography(id: $typographyId) {
563
- ...Typography
564
- }
565
- }
566
-
567
- ${TypographyFragment}
568
- `;
569
- const PagePathnamesByIdQuery = `
570
- query PagePathnamesById($pageIds: [ID!]!) {
571
- pagePathnamesById(ids: $pageIds) {
572
- ...PagePathnameSlice
573
- }
574
- }
575
-
576
- ${PagePathnameSliceFragment}
577
- `;
578
- const TableQuery = `
579
- query Table($tableId: ID!) {
580
- table(id: $tableId) {
581
- ...Table
582
- }
583
- }
584
-
585
- ${TableFragment}
586
- `;
587
- const TypographiesQuery = `
588
- query Typographies($typographyIds: [ID!]!) {
589
- typographies(ids: $typographyIds) {
590
- ...Typography
591
- }
592
- }
593
-
594
- ${TypographyFragment}
595
- `;
596
- const GlobalElementQuery = `
597
- query GlobalElement($globalElementId: ID!) {
598
- globalElement(id: $globalElementId) {
599
- ...GlobalElement
600
- }
601
- }
602
-
603
- ${GlobalElementFragment}
604
- `;
605
- const CreateTableRecordMutation = `
606
- mutation CreateTableRecord($input: CreateTableRecordInput!) {
607
- createTableRecord(input: $input) {
608
- tableRecord {
609
- id
610
- }
611
- }
612
- }
613
- `;
614
- const reducer = reducer$1;
615
- function getSerializedState(state) {
616
- return getSerializedState$1(state);
617
- }
618
- function getHasAPIResource(state, resourceType, resourceId) {
619
- return getHasAPIResource$1(state, resourceType, resourceId);
620
- }
621
- function getAPIResource(state, resourceType, resourceId) {
622
- return getAPIResource$1(state, resourceType, resourceId);
623
- }
624
- function fetchAPIResource(resourceType, resourceId) {
625
- return async (dispatch, getState, client) => {
626
- var _a;
627
- const state = getState();
628
- if (getHasAPIResource(state, resourceType, resourceId)) {
629
- return getAPIResource(state, resourceType, resourceId);
630
- }
631
- let resource;
632
- switch (resourceType) {
633
- case types.APIResourceType.Swatch:
634
- resource = (await client.request(SwatchQuery, {
635
- swatchId: resourceId
636
- })).swatch;
637
- break;
638
- case types.APIResourceType.File:
639
- resource = (await client.request(FileQuery, {
640
- fileId: resourceId
641
- })).file;
642
- break;
643
- case types.APIResourceType.Typography:
644
- resource = (await client.request(TypographyQuery, {
645
- typographyId: resourceId
646
- })).typography;
647
- break;
648
- case types.APIResourceType.GlobalElement:
649
- resource = (await client.request(GlobalElementQuery, { globalElementId: resourceId })).globalElement;
650
- break;
651
- case types.APIResourceType.PagePathnameSlice:
652
- resource = (_a = (await client.request(PagePathnamesByIdQuery, { pageIds: [resourceId] })).pagePathnamesById[0]) != null ? _a : null;
653
- break;
654
- case types.APIResourceType.Table:
655
- resource = (await client.request(TableQuery, {
656
- tableId: resourceId
657
- })).table;
658
- break;
659
- default:
660
- resource = null;
661
- }
662
- dispatch(actions.apiResourceFulfilled(resourceType, resourceId, resource));
663
- return resource;
664
- };
665
- }
666
- function fetchIntrospectedResources(introspectedResourceIds) {
667
- return async (dispatch, _getState, client) => {
668
- const introspectedResources = await client.request(IntrospectedResourcesQuery, introspectedResourceIds);
669
- dispatch(actions.introspectedResourcesFulfilled(introspectedResourceIds, introspectedResources));
670
- };
671
- }
672
- function fetchTypographies(typographyIds) {
673
- return async (dispatch, getState, client) => {
674
- const state = getState();
675
- if (typographyIds.every((typographyId) => getHasAPIResource(state, types.APIResourceType.Typography, typographyId))) {
676
- return typographyIds.map((typographyId) => getAPIResource(state, types.APIResourceType.Typography, typographyId));
677
- }
678
- const { typographies } = await client.request(TypographiesQuery, { typographyIds });
679
- dispatch(actions.typographiesFulfilled(typographyIds, typographies));
680
- return typographies;
681
- };
682
- }
683
- function configureStore({
684
- graphqlClient,
685
- serializedState
686
- }) {
687
- return redux.createStore(reducer, getInitialState(serializedState), redux.applyMiddleware(thunk__default["default"].withExtraArgument(graphqlClient)));
688
- }
689
- class GraphQLClient {
690
- constructor(endpoint) {
691
- __publicField(this, "endpoint");
692
- this.endpoint = endpoint;
693
- }
694
- async request(query, variables = {}) {
695
- const response = await fetch(this.endpoint, {
696
- method: "POST",
697
- headers: { "Content-Type": "application/json" },
698
- body: JSON.stringify({ query, variables })
699
- });
700
- if (!response.ok && response.status !== 400) {
701
- throw new Error(`${response.status} ${response.statusText}`);
702
- }
703
- const body = await response.json();
704
- if (body.errors != null) {
705
- console.error(body);
706
- throw new Error("GraphQL response contains errors, check the console.");
707
- }
708
- return body.data;
709
- }
710
- }
711
- class MakeswiftClient {
712
- constructor({
713
- uri,
714
- cacheData
715
- }) {
716
- __publicField(this, "graphqlClient");
717
- __publicField(this, "makeswiftApiClient");
718
- __publicField(this, "subscribe");
719
- this.graphqlClient = new GraphQLClient(uri);
720
- this.makeswiftApiClient = configureStore({
721
- graphqlClient: this.graphqlClient,
722
- serializedState: cacheData
723
- });
724
- this.subscribe = this.makeswiftApiClient.subscribe;
725
- }
726
- async prefetch(element) {
727
- const introspectionData = await introspect(element, this, storeContextDefaultValue);
728
- await this.makeswiftApiClient.dispatch(fetchIntrospectedResources(introspectionData));
729
- return getSerializedState(this.makeswiftApiClient.getState());
730
- }
731
- readSwatch(swatchId) {
732
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Swatch, swatchId);
733
- }
734
- async fetchSwatch(swatchId) {
735
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.Swatch, swatchId));
736
- }
737
- readFile(fileId) {
738
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.File, fileId);
739
- }
740
- async fetchFile(fileId) {
741
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.File, fileId));
742
- }
743
- readTypography(typographyId) {
744
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Typography, typographyId);
745
- }
746
- async fetchTypography(typographyId) {
747
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.Typography, typographyId));
748
- }
749
- async fetchTypographies(typographyIds) {
750
- return await this.makeswiftApiClient.dispatch(fetchTypographies(typographyIds));
751
- }
752
- readGlobalElement(globalElementId) {
753
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.GlobalElement, globalElementId);
754
- }
755
- async fetchGlobalElement(globalElementId) {
756
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.GlobalElement, globalElementId));
757
- }
758
- readPagePathnameSlice(pageId) {
759
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.PagePathnameSlice, pageId);
760
- }
761
- async fetchPagePathnameSlice(pageId) {
762
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.PagePathnameSlice, pageId));
763
- }
764
- readTable(tableId) {
765
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Table, tableId);
766
- }
767
- async fetchTable(tableId) {
768
- return await this.makeswiftApiClient.dispatch(fetchAPIResource(types.APIResourceType.Table, tableId));
769
- }
770
- async createTableRecord(tableId, columns) {
771
- await this.graphqlClient.request(CreateTableRecordMutation, {
772
- input: {
773
- data: {
774
- tableId,
775
- columns
776
- }
777
- }
778
- });
779
- }
780
- readSite(siteId) {
781
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Site, siteId);
782
- }
783
- readPage(pageId) {
784
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Page, pageId);
785
- }
786
- readSnippet(snippetId) {
787
- return getAPIResource(this.makeswiftApiClient.getState(), types.APIResourceType.Snippet, snippetId);
788
- }
789
- }
790
- const Context$1 = React.createContext(new MakeswiftClient({
791
- uri: "https://api.makeswift.com/graphql"
792
- }));
793
- function useMakeswiftClient() {
794
- return React.useContext(Context$1);
795
- }
796
- function MakeswiftProvider({
797
- client,
798
- children
799
- }) {
800
- return /* @__PURE__ */ jsxRuntime.jsx(Context$1.Provider, {
801
- value: client,
802
- children
803
- });
804
- }
805
147
  const SnippetLocation = {
806
148
  Body: "BODY",
807
149
  Head: "HEAD"
@@ -849,7 +191,7 @@ function Page$1({
849
191
  return;
850
192
  const oldSnippets = snippets.map(filterUsedSnippetProperties);
851
193
  const newSnippets = cachedPage.snippets.map(filterUsedSnippetProperties);
852
- if (deepEqual(newSnippets, oldSnippets))
194
+ if (responsiveStyle.deepEqual(newSnippets, oldSnippets))
853
195
  return;
854
196
  setSnippets(cachedPage.snippets);
855
197
  }, [cachedPage]);
@@ -991,22 +333,22 @@ function Page$1({
991
333
  });
992
334
  }
993
335
  function useCachedPage(pageId) {
994
- const client = useMakeswiftClient();
336
+ const client = responsiveStyle.useMakeswiftClient();
995
337
  const getSnapshot = () => pageId == null ? null : client.readPage(pageId);
996
338
  const page = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
997
339
  return page;
998
340
  }
999
341
  function useCachedSite(siteId) {
1000
- const client = useMakeswiftClient();
342
+ const client = responsiveStyle.useMakeswiftClient();
1001
343
  const getSnapshot = () => siteId == null ? null : client.readSite(siteId);
1002
344
  const site = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
1003
345
  return site;
1004
346
  }
1005
- const version = "0.7.19";
1006
347
  class Makeswift {
1007
348
  constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
1008
349
  __publicField(this, "apiKey");
1009
350
  __publicField(this, "apiOrigin");
351
+ __publicField(this, "graphqlClient");
1010
352
  if (typeof apiKey !== "string") {
1011
353
  throw new Error(`The Makeswift client must be passed a valid Makeswift site API key: \`new Makeswift('<makeswift_site_api_key>')\`
1012
354
  Received "${apiKey}" instead.`);
@@ -1017,6 +359,7 @@ Received "${apiKey}" instead.`);
1017
359
  } catch {
1018
360
  throw new Error(`The Makeswift client received an invalid \`apiOrigin\` parameter: "${apiOrigin}".`);
1019
361
  }
362
+ this.graphqlClient = new responsiveStyle.GraphQLClient(new URL("graphql", apiOrigin).href);
1020
363
  }
1021
364
  async fetch(path, init) {
1022
365
  const response = await fetch(new URL(path, this.apiOrigin).toString(), __spreadProps(__spreadValues({}, init), {
@@ -1033,9 +376,149 @@ Received "${apiKey}" instead.`);
1033
376
  const json = await response.json();
1034
377
  return json;
1035
378
  }
379
+ async getTypographies(typographyIds) {
380
+ const result = await this.graphqlClient.request(responsiveStyle.TypographiesQuery, { typographyIds });
381
+ return result.typographies;
382
+ }
383
+ async getIntrospectedResources(introspectedResourceIds) {
384
+ const result = await this.graphqlClient.request(responsiveStyle.IntrospectedResourcesQuery, introspectedResourceIds);
385
+ return result;
386
+ }
387
+ async introspect(element) {
388
+ const descriptors$1 = constants.getPropControllerDescriptors(storeContextDefaultValue.getState());
389
+ const swatchIds = /* @__PURE__ */ new Set();
390
+ const fileIds = /* @__PURE__ */ new Set();
391
+ const typographyIds = /* @__PURE__ */ new Set();
392
+ const tableIds = /* @__PURE__ */ new Set();
393
+ const pageIds = /* @__PURE__ */ new Set();
394
+ const globalElements = /* @__PURE__ */ new Map();
395
+ const remaining = [element];
396
+ const seen = /* @__PURE__ */ new Set();
397
+ let current;
398
+ while (current = remaining.pop()) {
399
+ let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
400
+ Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
401
+ introspection.getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
402
+ swatchIds.add(swatchId);
403
+ });
404
+ introspection.getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
405
+ introspection.getTypographyIds(descriptor, props[propName]).forEach((typographyId) => typographyIds.add(typographyId));
406
+ introspection.getTableIds(descriptor, props[propName]).forEach((tableId) => tableIds.add(tableId));
407
+ introspection.getPageIds(descriptor, props[propName]).forEach((pageId) => pageIds.add(pageId));
408
+ introspection.getElementChildren(descriptor, props[propName]).forEach((child) => {
409
+ if (!seen.has(child.key)) {
410
+ seen.add(child.key);
411
+ remaining.push(child);
412
+ }
413
+ });
414
+ if (descriptor.type === descriptors.ShapeControlType) {
415
+ const prop = props[propName];
416
+ if (prop == null)
417
+ return;
418
+ getResourcesFromElementDescriptors(descriptor.config.type, prop);
419
+ }
420
+ if (descriptor.type === descriptors.ListControlType) {
421
+ const prop = props[propName];
422
+ if (prop == null)
423
+ return;
424
+ prop.forEach((item) => {
425
+ getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
426
+ });
427
+ }
428
+ if (descriptor.type === descriptors.Types.Shape) {
429
+ const prop = props[propName];
430
+ if (prop == null)
431
+ return;
432
+ getResourcesFromElementDescriptors(descriptor.options.type, prop);
433
+ }
434
+ if (descriptor.type === descriptors.Types.List) {
435
+ const prop = props[propName];
436
+ if (prop == null)
437
+ return;
438
+ prop.forEach((item) => {
439
+ getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
440
+ });
441
+ }
442
+ });
443
+ };
444
+ let element2;
445
+ if (constants.isElementReference(current)) {
446
+ const globalElement = await this.getGlobalElement(current.value);
447
+ globalElements.set(current.value, globalElement);
448
+ const elementData = globalElement == null ? void 0 : globalElement.data;
449
+ if (elementData == null)
450
+ continue;
451
+ element2 = elementData;
452
+ } else {
453
+ element2 = current;
454
+ }
455
+ const elementDescriptors = descriptors$1.get(element2.type);
456
+ if (elementDescriptors == null)
457
+ continue;
458
+ getResourcesFromElementDescriptors(elementDescriptors, element2.props);
459
+ }
460
+ const typographies = await this.getTypographies([...typographyIds]);
461
+ typographies.forEach((typography) => {
462
+ typography == null ? void 0 : typography.style.forEach((style) => {
463
+ var _a;
464
+ const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
465
+ if (swatchId != null)
466
+ swatchIds.add(swatchId);
467
+ });
468
+ });
469
+ const { swatches, files, tables, pagePathnamesById } = await this.getIntrospectedResources({
470
+ swatchIds: [...swatchIds],
471
+ fileIds: [...fileIds],
472
+ tableIds: [...tableIds],
473
+ pageIds: [...pageIds]
474
+ });
475
+ const pagePathnameSlices = pagePathnamesById.map((pagePathnameSlice) => pagePathnameSlice && __spreadProps(__spreadValues({}, pagePathnameSlice), {
476
+ id: Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64")
477
+ }));
478
+ return {
479
+ [types.APIResourceType.Swatch]: [...swatchIds].map((id) => {
480
+ var _a;
481
+ return {
482
+ id,
483
+ value: (_a = swatches.find((swatch) => (swatch == null ? void 0 : swatch.id) === id)) != null ? _a : null
484
+ };
485
+ }),
486
+ [types.APIResourceType.File]: [...fileIds].map((id) => {
487
+ var _a;
488
+ return {
489
+ id,
490
+ value: (_a = files.find((file) => (file == null ? void 0 : file.id) === id)) != null ? _a : null
491
+ };
492
+ }),
493
+ [types.APIResourceType.Typography]: [...typographyIds].map((id) => {
494
+ var _a;
495
+ return {
496
+ id,
497
+ value: (_a = typographies.find((typography) => (typography == null ? void 0 : typography.id) === id)) != null ? _a : null
498
+ };
499
+ }),
500
+ [types.APIResourceType.Table]: [...tableIds].map((id) => {
501
+ var _a;
502
+ return {
503
+ id,
504
+ value: (_a = tables.find((table) => (table == null ? void 0 : table.id) === id)) != null ? _a : null
505
+ };
506
+ }),
507
+ [types.APIResourceType.PagePathnameSlice]: [...pageIds].map((id) => {
508
+ var _a;
509
+ return {
510
+ id,
511
+ value: (_a = pagePathnameSlices.find((pagePathnameSlice) => (pagePathnameSlice == null ? void 0 : pagePathnameSlice.id) === id)) != null ? _a : null
512
+ };
513
+ }),
514
+ [types.APIResourceType.GlobalElement]: [...globalElements.entries()].map(([id, value]) => ({
515
+ id,
516
+ value
517
+ }))
518
+ };
519
+ }
1036
520
  async createSnapshot(document2, preview) {
1037
- const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
1038
- const cacheData = await client.prefetch(document2.data);
521
+ const cacheData = await this.introspect(document2.data);
1039
522
  return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
1040
523
  }
1041
524
  async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
@@ -1056,161 +539,30 @@ Received "${apiKey}" instead.`);
1056
539
  const snapshot = this.getPageSnapshotByPageId(page.id, { preview });
1057
540
  return snapshot;
1058
541
  }
1059
- async unstable_getPageData(path, { preview } = {}) {
1060
- const [page] = await this.getPages({ path });
1061
- if (page == null)
1062
- return null;
1063
- const document2 = await this.getDocumentForPage(page.id);
1064
- const snapshot = await this.unstable_createSnapshotOnDemand({ document: document2, pageId: page.id });
1065
- return {
1066
- pageId: page.id,
1067
- siteId: document2.site.id,
1068
- snapshot,
1069
- options: { preview: preview || false, apiOrigin: this.apiOrigin.href }
1070
- };
542
+ async getSwatch(swatchId) {
543
+ const result = await this.graphqlClient.request(responsiveStyle.SwatchQuery, { swatchId });
544
+ return result.swatch;
1071
545
  }
1072
- async getDocumentForPage(pageId) {
1073
- const response = await this.fetch(`/v1/pages/${pageId}/document?preview=false`);
1074
- if (!response.ok) {
1075
- if (response.status === 404)
1076
- throw Error("Document not found.");
1077
- throw new Error(`Failed to create snapshot with error: "${response.statusText}"`);
1078
- }
1079
- const document2 = await response.json();
1080
- return document2;
546
+ async getFile(fileId) {
547
+ const result = await this.graphqlClient.request(responsiveStyle.FileQuery, { fileId });
548
+ return result.file;
1081
549
  }
1082
- async unstable_createSnapshotOnDemand({
1083
- document: document2,
1084
- pageId
1085
- }) {
1086
- let fetchedDocument = document2;
1087
- if (fetchedDocument == null) {
1088
- const response = await this.fetch(`/v1/pages/${pageId}/document?preview=false`);
1089
- if (!response.ok) {
1090
- if (response.status === 404) {
1091
- throw new Error("Not found");
1092
- }
1093
- throw new Error(`Failed to create snapshot with error: "${response.statusText}"`);
1094
- }
1095
- fetchedDocument = await response.json();
1096
- }
1097
- if (fetchedDocument == null) {
1098
- throw Error("fetchedDocument should never be null");
1099
- }
1100
- const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
1101
- const prefetchedResources = await client.prefetch(fetchedDocument.data);
1102
- const resources = normalizeToMakeswiftResources(getSnapshotResourcesFromSerializedState(prefetchedResources));
1103
- resources.snippets = fetchedDocument.snippets.map((snippet) => ({
1104
- id: snippet.id,
1105
- value: snippet
1106
- }));
1107
- resources.pageMetadata = fetchedDocument.meta;
1108
- resources.pageSeo = fetchedDocument.seo;
1109
- resources.fonts = fetchedDocument.fonts.map((font) => ({ id: font.family, value: font }));
1110
- return { resources, elementTree: fetchedDocument.data, runtimeVersion: version };
550
+ async getTypography(typographyId) {
551
+ const result = await this.graphqlClient.request(responsiveStyle.TypographyQuery, { typographyId });
552
+ return result.typography;
1111
553
  }
1112
- async unstable_createSnapshot({
1113
- publishedResources,
1114
- deletedResources,
1115
- publishedElementTree,
1116
- currentSnapshot
1117
- }) {
1118
- const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
1119
- function mergeResources({
1120
- resourcesFromPublishedElementTree: resourcesFromPublishedElementTree2,
1121
- resourcesFromCurrentSnapshot: resourcesFromCurrentSnapshot2,
1122
- publishedResources: publishedResources2,
1123
- deletedResources: deletedResources2
1124
- }) {
1125
- function mergeIdSpecifiedResource(resourceSet, deletedResources3) {
1126
- const map = new Map(resourceSet.map(({ id, value }) => [id, value]));
1127
- deletedResources3 == null ? void 0 : deletedResources3.forEach((id) => map.delete(id));
1128
- const finalResourceSet = [];
1129
- Array.from(map.entries()).forEach(([id, value]) => {
1130
- if (value != null) {
1131
- finalResourceSet.push({ id, value });
1132
- }
1133
- });
1134
- return finalResourceSet;
1135
- }
1136
- const resources2 = {
1137
- swatches: mergeIdSpecifiedResource([
1138
- ...resourcesFromPublishedElementTree2.swatches,
1139
- ...resourcesFromCurrentSnapshot2.swatches,
1140
- ...publishedResources2.swatches
1141
- ], deletedResources2 == null ? void 0 : deletedResources2.swatches),
1142
- files: mergeIdSpecifiedResource([
1143
- ...resourcesFromPublishedElementTree2.files,
1144
- ...resourcesFromCurrentSnapshot2.files,
1145
- ...publishedResources2.files
1146
- ], deletedResources2 == null ? void 0 : deletedResources2.files),
1147
- tables: mergeIdSpecifiedResource([
1148
- ...resourcesFromPublishedElementTree2.tables,
1149
- ...resourcesFromCurrentSnapshot2.tables,
1150
- ...publishedResources2.tables
1151
- ], deletedResources2 == null ? void 0 : deletedResources2.tables),
1152
- typographies: mergeIdSpecifiedResource([
1153
- ...resourcesFromPublishedElementTree2.typographies,
1154
- ...resourcesFromCurrentSnapshot2.typographies,
1155
- ...publishedResources2.typographies
1156
- ], deletedResources2 == null ? void 0 : deletedResources2.typographies),
1157
- pagePathnameSlices: mergeIdSpecifiedResource([
1158
- ...resourcesFromPublishedElementTree2.pagePathnameSlices,
1159
- ...resourcesFromCurrentSnapshot2.pagePathnameSlices,
1160
- ...publishedResources2.pagePathnameSlices
1161
- ], deletedResources2 == null ? void 0 : deletedResources2.pagePathnameSlices),
1162
- globalElements: mergeIdSpecifiedResource([
1163
- ...resourcesFromPublishedElementTree2.globalElements,
1164
- ...resourcesFromCurrentSnapshot2.globalElements,
1165
- ...publishedResources2.globalElements
1166
- ], deletedResources2 == null ? void 0 : deletedResources2.globalElements),
1167
- snippets: mergeIdSpecifiedResource([
1168
- ...resourcesFromPublishedElementTree2.snippets,
1169
- ...resourcesFromCurrentSnapshot2.snippets,
1170
- ...publishedResources2.snippets
1171
- ], deletedResources2 == null ? void 0 : deletedResources2.snippets),
1172
- fonts: mergeIdSpecifiedResource([
1173
- ...resourcesFromPublishedElementTree2.fonts,
1174
- ...resourcesFromCurrentSnapshot2.fonts,
1175
- ...publishedResources2.fonts
1176
- ], deletedResources2 == null ? void 0 : deletedResources2.fonts),
1177
- pageMetadata: __spreadValues(__spreadValues({}, resourcesFromCurrentSnapshot2.pageMetadata), publishedResources2.pageMetadata),
1178
- pageSeo: __spreadValues(__spreadValues({}, resourcesFromCurrentSnapshot2.pageSeo), publishedResources2.pageSeo)
1179
- };
1180
- return resources2;
1181
- }
1182
- const resourcesFromPublishedElementTree = publishedElementTree != null ? normalizeToMakeswiftResources(getSnapshotResourcesFromSerializedState(await client.prefetch(publishedElementTree))) : normalizeToMakeswiftResources({});
1183
- const resourcesFromCurrentSnapshot = normalizeToMakeswiftResources((currentSnapshot == null ? void 0 : currentSnapshot.resources) || {});
1184
- const resources = mergeResources({
1185
- resourcesFromPublishedElementTree,
1186
- resourcesFromCurrentSnapshot,
1187
- publishedResources: normalizeToMakeswiftResources(publishedResources),
1188
- deletedResources
1189
- });
1190
- const elementTree = publishedElementTree || (currentSnapshot == null ? void 0 : currentSnapshot.elementTree);
1191
- if (elementTree == null) {
1192
- throw Error("elementTree should not be null; something went wrong.");
1193
- }
1194
- return {
1195
- resources,
1196
- elementTree,
1197
- runtimeVersion: version
1198
- };
554
+ async getGlobalElement(globalElementId) {
555
+ const result = await this.graphqlClient.request(responsiveStyle.GlobalElementQuery, { globalElementId });
556
+ return result.globalElement;
1199
557
  }
1200
- unstable_getSnapshotResourceMapping(snapshot) {
1201
- const resources = snapshot.resources;
1202
- function parseResourceIds({ id }) {
1203
- return id;
1204
- }
1205
- return [
1206
- ...resources.swatches.map(parseResourceIds),
1207
- ...resources.files.map(parseResourceIds),
1208
- ...resources.tables.map(parseResourceIds),
1209
- ...resources.typographies.map(parseResourceIds),
1210
- ...resources.pagePathnameSlices.map(parseResourceIds),
1211
- ...resources.globalElements.map(parseResourceIds),
1212
- ...resources.snippets.map(parseResourceIds)
1213
- ];
558
+ async getPagePathnameSlice(pageId) {
559
+ var _a;
560
+ const result = await this.graphqlClient.request(responsiveStyle.PagePathnamesByIdQuery, { pageIds: [pageId] });
561
+ return (_a = result.pagePathnamesById.at(0)) != null ? _a : null;
562
+ }
563
+ async getTable(tableId) {
564
+ const result = await this.graphqlClient.request(responsiveStyle.TableQuery, { tableId });
565
+ return result.table;
1214
566
  }
1215
567
  }
1216
568
  function PreviewModeScript({
@@ -1340,17 +692,40 @@ class Document$1 extends NextDocument__default["default"] {
1340
692
  });
1341
693
  }
1342
694
  }
1343
- function isErrorWithMessage(error) {
1344
- return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
695
+ async function elementTree(req, res) {
696
+ const elementTree2 = req.body.elementTree;
697
+ const replacementContext = req.body.replacementContext;
698
+ if (elementTree2 == null) {
699
+ return res.status(400).json({ message: "elementTree must be defined" });
700
+ }
701
+ if (replacementContext == null) {
702
+ return res.status(400).json({ message: "replacementContext must be defined" });
703
+ }
704
+ const generatedElementTree = ReactRuntime.copyElementTree(elementTree2, replacementContext);
705
+ const response = { elementTree: generatedElementTree };
706
+ return res.json(response);
1345
707
  }
1346
- function MakeswiftApiHandler(apiKey, {
1347
- appOrigin = "https://app.makeswift.com",
1348
- apiOrigin = "https://api.makeswift.com",
1349
- getFonts
1350
- } = {}) {
1351
- const cors = Cors__default["default"]({ origin: appOrigin });
708
+ async function fonts(_req, res, { getFonts } = {}) {
709
+ var _a;
710
+ const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
711
+ return res.json(fonts2);
712
+ }
713
+ const version = "0.8.1";
714
+ async function handler(req, res, { apiKey }) {
715
+ if (req.query.secret !== apiKey) {
716
+ return res.status(401).json({ message: "Unauthorized" });
717
+ }
718
+ return res.json({
719
+ version,
720
+ previewMode: true,
721
+ interactionMode: true,
722
+ clientSideNavigation: true,
723
+ elementFromPoint: false
724
+ });
725
+ }
726
+ async function proxyPreviewMode(req, res, { apiKey }) {
1352
727
  const previewModeProxy = httpProxy.createProxyServer();
1353
- previewModeProxy.on("proxyReq", (proxyReq) => {
728
+ previewModeProxy.once("proxyReq", (proxyReq) => {
1354
729
  proxyReq.removeHeader("X-Makeswift-Preview-Mode");
1355
730
  proxyReq.removeHeader("X-Invoke-Path");
1356
731
  proxyReq.removeHeader("X-Invoke-Query");
@@ -1358,12 +733,74 @@ function MakeswiftApiHandler(apiKey, {
1358
733
  url.searchParams.delete("x-makeswift-preview-mode");
1359
734
  proxyReq.path = url.pathname + url.search;
1360
735
  });
736
+ if (req.query.secret !== apiKey)
737
+ return res.status(401).send("Unauthorized");
738
+ const host = req.headers.host;
739
+ if (host == null)
740
+ return res.status(400).send("Bad Request");
741
+ const forwardedProtoHeader = req.headers["x-forwarded-proto"];
742
+ let forwardedProto = [];
743
+ if (Array.isArray(forwardedProtoHeader)) {
744
+ forwardedProto = forwardedProtoHeader;
745
+ } else if (typeof forwardedProtoHeader === "string") {
746
+ forwardedProto = forwardedProtoHeader.split(",");
747
+ }
748
+ const isForwardedProtoHttps = forwardedProto.includes("https");
749
+ const forwardedSSL = req.headers["x-forwarded-ssl"];
750
+ const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
751
+ const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
752
+ let target = `${proto}://${host}`;
753
+ const secure = process.env["NODE_ENV"] === "production";
754
+ const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
755
+ res.removeHeader("Set-Cookie");
756
+ if (!Array.isArray(setCookie))
757
+ return res.status(500).send("Internal Server Error");
758
+ const cookie$1 = setCookieParser.parse(setCookie).map((cookie2) => cookie.serialize(cookie2.name, cookie2.value, cookie2)).join(";");
759
+ return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie: cookie$1 }, secure }, (err) => {
760
+ if (err)
761
+ reject(err);
762
+ else
763
+ resolve2();
764
+ }));
765
+ }
766
+ function isErrorWithMessage(error) {
767
+ return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
768
+ }
769
+ async function revalidate(req, res, { apiKey }) {
770
+ if (req.query.secret !== apiKey) {
771
+ return res.status(401).json({ message: "Unauthorized" });
772
+ }
773
+ if (typeof req.query.path !== "string") {
774
+ return res.status(400).json({ message: "Bad Request" });
775
+ }
776
+ const revalidate2 = res.revalidate;
777
+ if (typeof revalidate2 !== "function") {
778
+ const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
779
+ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
780
+ console.warn(message);
781
+ return res.json({ revalidated: false });
782
+ }
783
+ try {
784
+ await revalidate2(req.query.path);
785
+ return res.json({ revalidated: true });
786
+ } catch (error) {
787
+ if (isErrorWithMessage(error)) {
788
+ return res.status(500).json({ message: error.message });
789
+ }
790
+ return res.status(500).json({ message: "Error Revalidating" });
791
+ }
792
+ }
793
+ function MakeswiftApiHandler(apiKey, {
794
+ appOrigin = "https://app.makeswift.com",
795
+ apiOrigin = "https://api.makeswift.com",
796
+ getFonts
797
+ } = {}) {
798
+ const cors = Cors__default["default"]({ origin: appOrigin });
1361
799
  if (typeof apiKey !== "string") {
1362
800
  throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
1363
801
  Received "${apiKey}" instead.`);
1364
802
  }
1365
803
  return async function makeswiftApiHandler(req, res) {
1366
- var _a;
1367
804
  await new Promise((resolve2, reject) => {
1368
805
  cors(req, res, (err) => {
1369
806
  if (err instanceof Error)
@@ -1378,224 +815,40 @@ Received "${apiKey}" instead.`);
1378
815
  Received "${makeswift}" for the \`makeswift\` param instead.
1379
816
  Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
1380
817
  }
1381
- const action = makeswift.join("/");
1382
- switch (action) {
1383
- case "manifest": {
1384
- if (req.query.secret !== apiKey)
1385
- return res.status(401).json({ message: "Unauthorized" });
1386
- return res.json({
1387
- version,
1388
- previewMode: true,
1389
- interactionMode: true,
1390
- clientSideNavigation: true,
1391
- elementFromPoint: false
1392
- });
1393
- }
1394
- case "revalidate": {
1395
- if (req.query.secret !== apiKey) {
1396
- return res.status(401).json({ message: "Unauthorized" });
1397
- }
1398
- if (typeof req.query.path !== "string") {
1399
- return res.status(400).json({ message: "Bad Request" });
1400
- }
1401
- const revalidate = res.revalidate;
1402
- if (typeof revalidate !== "function") {
1403
- const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
1404
- Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
1405
- console.warn(message);
1406
- return res.json({ revalidated: false });
1407
- }
1408
- try {
1409
- await revalidate(req.query.path);
1410
- return res.json({ revalidated: true });
1411
- } catch (error) {
1412
- if (isErrorWithMessage(error)) {
1413
- return res.status(500).json({ message: error.message });
1414
- }
1415
- return res.status(500).json({ message: "Error Revalidating" });
1416
- }
1417
- }
1418
- case "proxy-preview-mode": {
1419
- if (req.query.secret !== apiKey)
1420
- return res.status(401).send("Unauthorized");
1421
- const host = req.headers.host;
1422
- if (host == null)
1423
- return res.status(400).send("Bad Request");
1424
- const forwardedProto = req.headers["x-forwarded-proto"];
1425
- const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
1426
- const forwardedSSL = req.headers["x-forwarded-ssl"];
1427
- const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
1428
- const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
1429
- let target = `${proto}://${host}`;
1430
- if (process.env["NODE_ENV"] !== "production") {
1431
- const port = req.socket.localPort;
1432
- if (port != null)
1433
- target = `http://localhost:${port}`;
1434
- }
1435
- const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
1436
- res.removeHeader("Set-Cookie");
1437
- if (!Array.isArray(setCookie))
1438
- return res.status(500).send("Internal Server Error");
1439
- const cookie$1 = setCookieParser.parse(setCookie).map((cookie2) => cookie.serialize(cookie2.name, cookie2.value, cookie2)).join(";");
1440
- return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie: cookie$1 } }, (err) => {
1441
- if (err)
1442
- reject(err);
1443
- else
1444
- resolve2();
1445
- }));
1446
- }
1447
- case "fonts": {
1448
- const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1449
- return res.json(fonts);
1450
- }
1451
- case "element-tree": {
1452
- const elementTree = req.body.elementTree;
1453
- const replacementContext = req.body.replacementContext;
1454
- if (elementTree == null) {
1455
- return res.status(400).json({ message: "elementTree must be defined" });
1456
- }
1457
- if (replacementContext == null) {
1458
- return res.status(400).json({ message: "replacementContext must be defined" });
1459
- }
1460
- const generatedElementTree = ReactRuntime.copyElementTree(elementTree, replacementContext);
1461
- const response = { elementTree: generatedElementTree };
1462
- return res.json(response);
1463
- }
1464
- case "snapshot": {
1465
- let validateBody = function(body2) {
1466
- if (body2.pageId == null) {
1467
- return res.status(400).json({ message: "Must define pageId." });
1468
- }
1469
- if (body2.currentSnapshot == null && body2.publishedElementTree == null) {
1470
- return res.status(400).json({ message: "Either currentSnapshot or publishedElementTree must be defined." });
1471
- }
1472
- };
1473
- const body = req.body;
1474
- validateBody(body);
1475
- const client = new Makeswift(apiKey, {
1476
- apiOrigin
1477
- });
1478
- const makeswiftApiClient = new MakeswiftClient({ uri: new URL("graphql", apiOrigin).href });
1479
- async function formMakeswiftResources(publishedResources) {
1480
- var _a2, _b, _c2, _d, _e, _f, _g, _h;
1481
- const publishedResourcesInMakeswiftSnapshotFormat = {
1482
- swatches: [],
1483
- typographies: [],
1484
- files: [],
1485
- tables: [],
1486
- pagePathnameSlices: [],
1487
- globalElements: [],
1488
- snippets: [],
1489
- fonts: [],
1490
- pageMetadata: publishedResources == null ? void 0 : publishedResources.pageMetadata,
1491
- pageSeo: publishedResources == null ? void 0 : publishedResources.pageSeo
1492
- };
1493
- if (publishedResources == null) {
1494
- return publishedResourcesInMakeswiftSnapshotFormat;
1495
- }
1496
- for await (const swatchId of publishedResources.swatches || []) {
1497
- const swatch = await makeswiftApiClient.fetchSwatch(swatchId);
1498
- if (swatch != null) {
1499
- (_a2 = publishedResourcesInMakeswiftSnapshotFormat.swatches) == null ? void 0 : _a2.push({
1500
- id: swatchId,
1501
- value: swatch
1502
- });
1503
- }
1504
- }
1505
- for await (const typographyId of publishedResources.typographies || []) {
1506
- const typography = await makeswiftApiClient.fetchTypography(typographyId);
1507
- if (typography != null) {
1508
- (_b = publishedResourcesInMakeswiftSnapshotFormat.typographies) == null ? void 0 : _b.push({
1509
- id: typographyId,
1510
- value: typography
1511
- });
1512
- }
1513
- }
1514
- for await (const fileId of publishedResources.files || []) {
1515
- const file = await makeswiftApiClient.fetchFile(fileId);
1516
- if (file != null) {
1517
- (_c2 = publishedResourcesInMakeswiftSnapshotFormat.files) == null ? void 0 : _c2.push({
1518
- id: fileId,
1519
- value: fileToFileSnapshot(file)
1520
- });
1521
- }
1522
- }
1523
- for await (const tableId of publishedResources.tables || []) {
1524
- const table = await makeswiftApiClient.fetchTable(tableId);
1525
- if (table != null) {
1526
- (_d = publishedResourcesInMakeswiftSnapshotFormat.tables) == null ? void 0 : _d.push({
1527
- id: tableId,
1528
- value: table
1529
- });
1530
- }
1531
- }
1532
- for await (const pageId of publishedResources.pagePathnameSlices || []) {
1533
- const pagePathnameSlice = await makeswiftApiClient.fetchPagePathnameSlice(pageId);
1534
- if (pagePathnameSlice != null) {
1535
- (_e = publishedResourcesInMakeswiftSnapshotFormat.pagePathnameSlices) == null ? void 0 : _e.push({
1536
- id: pageId,
1537
- value: pagePathnameSlice
1538
- });
1539
- }
1540
- }
1541
- for await (const globalElementId of publishedResources.globalElements || []) {
1542
- const globalElement = await makeswiftApiClient.fetchGlobalElement(globalElementId);
1543
- if (globalElement != null) {
1544
- (_f = publishedResourcesInMakeswiftSnapshotFormat.globalElements) == null ? void 0 : _f.push({
1545
- id: globalElementId,
1546
- value: globalElement
1547
- });
1548
- }
1549
- }
1550
- if (publishedResources.snippets != null || publishedResources.fonts != null) {
1551
- const response2 = await fetch(new URL(`/v1/pages/${body.pageId}/document?preview=false`, apiOrigin).toString(), {
1552
- headers: { ["X-API-Key"]: apiKey }
1553
- });
1554
- if (!response2.ok) {
1555
- throw new Error(`Failed to hit live page endpoint: "${response2.statusText}"`);
1556
- }
1557
- const document2 = await response2.json();
1558
- const availableSnippets = document2.snippets;
1559
- const availableFonts = document2.fonts;
1560
- for await (const snippetId of publishedResources.snippets || []) {
1561
- const snippet = availableSnippets.find((availableSnippet) => availableSnippet.id === snippetId);
1562
- if (snippet != null) {
1563
- (_g = publishedResourcesInMakeswiftSnapshotFormat.snippets) == null ? void 0 : _g.push({
1564
- id: snippetId,
1565
- value: snippet
1566
- });
1567
- }
1568
- }
1569
- for await (const family of publishedResources.fonts || []) {
1570
- const font = availableFonts.find((availableFont) => availableFont.family === family);
1571
- if (font != null) {
1572
- (_h = publishedResourcesInMakeswiftSnapshotFormat.fonts) == null ? void 0 : _h.push({
1573
- id: family,
1574
- value: font
1575
- });
1576
- }
1577
- }
1578
- }
1579
- return publishedResourcesInMakeswiftSnapshotFormat;
1580
- }
1581
- const snapshot = await client.unstable_createSnapshot({
1582
- publishedResources: await formMakeswiftResources(body.publishedResources),
1583
- deletedResources: body.deletedResources,
1584
- publishedElementTree: body.publishedElementTree,
1585
- currentSnapshot: body.currentSnapshot
1586
- });
1587
- const usedResources = client.unstable_getSnapshotResourceMapping(snapshot);
1588
- const response = {
1589
- pageId: body.pageId,
1590
- snapshot,
1591
- livePageChanges: body.livePageChanges,
1592
- usedResources
1593
- };
1594
- return res.json(response);
1595
- }
1596
- default:
1597
- return res.status(404).json({ message: "Not Found" });
1598
- }
818
+ const client = new Makeswift(apiKey, { apiOrigin });
819
+ const action = "/" + makeswift.join("/");
820
+ const matches = (pattern) => pathToRegexp.match(pattern, { decode: decodeURIComponent })(action);
821
+ let m;
822
+ if (matches("/manifest"))
823
+ return handler(req, res, { apiKey });
824
+ if (matches("/revalidate"))
825
+ return revalidate(req, res, { apiKey });
826
+ if (matches("/proxy-preview-mode"))
827
+ return proxyPreviewMode(req, res, { apiKey });
828
+ if (matches("/fonts"))
829
+ return fonts(req, res, { getFonts });
830
+ if (matches("/element-tree"))
831
+ return elementTree(req, res);
832
+ const handleResource = (resource) => resource === null ? res.status(404).json({ message: "Not Found" }) : res.json(resource);
833
+ if (m = matches("/swatches/:id")) {
834
+ return client.getSwatch(m.params.id).then(handleResource);
835
+ }
836
+ if (m = matches("/files/:id")) {
837
+ return client.getFile(m.params.id).then(handleResource);
838
+ }
839
+ if (m = matches("/typographies/:id")) {
840
+ return client.getTypography(m.params.id).then(handleResource);
841
+ }
842
+ if (m = matches("/global-elements/:id")) {
843
+ return client.getGlobalElement(m.params.id).then(handleResource);
844
+ }
845
+ if (m = matches("/page-pathname-slices/:id")) {
846
+ return client.getPagePathnameSlice(m.params.id).then(handleResource);
847
+ }
848
+ if (m = matches("/tables/:id")) {
849
+ return client.getTable(m.params.id).then(handleResource);
850
+ }
851
+ return res.status(404).json({ message: "Not Found" });
1599
852
  };
1600
853
  }
1601
854
  const FORWARDED_NEXT_DYNAMIC_REF_KEY = "__forwarded_next_dynamic_ref__";
@@ -1670,14 +923,14 @@ async function getStaticPaths() {
1670
923
  }
1671
924
  const REVALIDATE_SECONDS = 1;
1672
925
  async function getStaticProps(ctx) {
1673
- var _a, _b, _c2;
926
+ var _a, _b, _c;
1674
927
  deprecationWarning("getStaticProps");
1675
928
  const makeswift = new Makeswift(getApiKey(), {
1676
929
  apiOrigin: getApiOrigin()
1677
930
  });
1678
931
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1679
932
  const snapshot = await makeswift.getPageSnapshot(path, {
1680
- preview: ((_c2 = ctx.previewData) == null ? void 0 : _c2.makeswift) === true
933
+ preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
1681
934
  });
1682
935
  if (snapshot == null)
1683
936
  return {
@@ -1714,7 +967,7 @@ async function getServerSideProps(ctx) {
1714
967
  const Page = React.memo(({
1715
968
  snapshot
1716
969
  }) => {
1717
- const client = React.useMemo(() => new MakeswiftClient({
970
+ const client = React.useMemo(() => new responsiveStyle.MakeswiftClient({
1718
971
  uri: new URL("graphql", snapshot.apiOrigin).href,
1719
972
  cacheData: snapshot.cacheData
1720
973
  }), [snapshot]);
@@ -1727,69 +980,6 @@ const Page = React.memo(({
1727
980
  }, snapshot.document.data.key)
1728
981
  });
1729
982
  });
1730
- const keys = (o) => Object.keys(o);
1731
- const coalesce = (...args) => {
1732
- let i;
1733
- for (i = 0; i < args.length - 1; i += 1) {
1734
- if (args[i] != null)
1735
- return args[i];
1736
- }
1737
- return args[i];
1738
- };
1739
- function shallowMerge(a, b) {
1740
- const bKeys = keys(b);
1741
- const merged = __spreadValues({}, a);
1742
- bKeys.forEach((key) => {
1743
- merged[key] = coalesce(merged[key], b[key]);
1744
- });
1745
- return merged;
1746
- }
1747
- const DEVICES = [
1748
- { id: "desktop", minWidth: 769 },
1749
- { id: "tablet", minWidth: 576, maxWidth: 768 },
1750
- { id: "mobile", maxWidth: 575 }
1751
- ];
1752
- const getDevice = (deviceId) => {
1753
- const device = DEVICES.find(({ id }) => id === deviceId);
1754
- if (device == null)
1755
- throw new Error(`Unrecognized device ID: "${deviceId}".`);
1756
- return device;
1757
- };
1758
- function defaultStrategy(value, fallbacks) {
1759
- return value || fallbacks[0];
1760
- }
1761
- function shallowMergeFallbacks(value, fallbacks) {
1762
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
1763
- deviceId: a.deviceId || b.deviceId,
1764
- value: shallowMerge(a.value, b.value)
1765
- }));
1766
- }
1767
- function findDeviceOverride(values = [], deviceId, strategy = defaultStrategy) {
1768
- const value = values.find(({ deviceId: d }) => d === deviceId);
1769
- const fallbacks = DEVICES.slice(0, DEVICES.findIndex((d) => d.id === deviceId) + 1).reverse().map((d) => values.find((v) => v.deviceId === d.id)).filter((override) => Boolean(override));
1770
- return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
1771
- }
1772
- function join(responsiveValues, joinFn, strategy) {
1773
- return DEVICES.map(({ id }) => id).map((deviceId) => {
1774
- const value = joinFn(responsiveValues.map((responsiveValue) => {
1775
- const deviceValue = responsiveValue && findDeviceOverride(responsiveValue, deviceId, strategy);
1776
- return deviceValue == null ? void 0 : deviceValue.value;
1777
- }));
1778
- if (value == null)
1779
- return null;
1780
- return { deviceId, value };
1781
- }).filter((override) => Boolean(override));
1782
- }
1783
- const getDeviceMediaQuery = (device) => {
1784
- const parts = ["@media only screen"];
1785
- if (device.minWidth != null) {
1786
- parts.push(`(min-width: ${device.minWidth}px)`);
1787
- }
1788
- if (device.maxWidth != null) {
1789
- parts.push(`(max-width: ${device.maxWidth}px)`);
1790
- }
1791
- return parts.join(" and ");
1792
- };
1793
983
  const DEFAULT_BOX_ANIMATE_TYPE = "none";
1794
984
  const DEFAULT_BOX_ANIMATE_DELAY = 0;
1795
985
  const DEFAULT_BOX_ANIMATE_DURATION = 0.75;
@@ -1801,7 +991,7 @@ function registerComponent$c(runtime) {
1801
991
  function isHiddenBasedOnAnimationType(props, deviceId, property) {
1802
992
  var _a, _b;
1803
993
  const animateIn = props[property];
1804
- return ((_b = (_a = findDeviceOverride(animateIn, deviceId)) == null ? void 0 : _a.value) != null ? _b : "none") === "none";
994
+ return ((_b = (_a = responsiveStyle.findDeviceOverride(animateIn, deviceId)) == null ? void 0 : _a.value) != null ? _b : "none") === "none";
1805
995
  }
1806
996
  const isHiddenBasedOnBoxAnimation = (props, deviceId) => isHiddenBasedOnAnimationType(props, deviceId, "boxAnimateType");
1807
997
  const isHiddenBasedOnItemAnimation = (props, deviceId) => isHiddenBasedOnAnimationType(props, deviceId, "itemAnimateType");
@@ -1996,7 +1186,7 @@ function registerComponent$b(runtime) {
1996
1186
  color: descriptors.ResponsiveColor((props, device) => {
1997
1187
  var _a;
1998
1188
  const variant = props.variant;
1999
- const hidden = ((_a = findDeviceOverride(variant, device)) == null ? void 0 : _a.value) === "clear";
1189
+ const hidden = ((_a = responsiveStyle.findDeviceOverride(variant, device)) == null ? void 0 : _a.value) === "clear";
2000
1190
  return { placeholder: "black", hidden };
2001
1191
  }),
2002
1192
  textColor: descriptors.ResponsiveColor({
@@ -2045,7 +1235,7 @@ function registerComponent$a(runtime) {
2045
1235
  step: descriptors.ResponsiveNumber((props, device) => {
2046
1236
  var _a, _b;
2047
1237
  const pageSize = props.pageSize;
2048
- const pageSizeValue = (_b = (_a = findDeviceOverride(pageSize, device)) == null ? void 0 : _a.value) != null ? _b : 1;
1238
+ const pageSizeValue = (_b = (_a = responsiveStyle.findDeviceOverride(pageSize, device)) == null ? void 0 : _a.value) != null ? _b : 1;
2049
1239
  return {
2050
1240
  label: "Step",
2051
1241
  defaultValue: 1,
@@ -2329,7 +1519,7 @@ function registerComponent$6(runtime) {
2329
1519
  labelTextColor: descriptors.ResponsiveColor((props, device) => {
2330
1520
  const hidden = props.tableId == null;
2331
1521
  const responsiveContrast = props.contrast;
2332
- const contrast = findDeviceOverride(responsiveContrast, device);
1522
+ const contrast = responsiveStyle.findDeviceOverride(responsiveContrast, device);
2333
1523
  return {
2334
1524
  hidden,
2335
1525
  label: "Label text color",
@@ -2474,7 +1664,7 @@ function registerComponent$4(runtime) {
2474
1664
  }),
2475
1665
  mobileMenuOpenIconColor: descriptors.ResponsiveColor((props, device) => {
2476
1666
  const mobileMenuAnimation = props.mobileMenuAnimation;
2477
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1667
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2478
1668
  return {
2479
1669
  label: "Open icon color",
2480
1670
  placeholder: "rgba(161, 168, 194, 0.5)",
@@ -2483,7 +1673,7 @@ function registerComponent$4(runtime) {
2483
1673
  }),
2484
1674
  mobileMenuCloseIconColor: descriptors.ResponsiveColor((props, device) => {
2485
1675
  const mobileMenuAnimation = props.mobileMenuAnimation;
2486
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1676
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2487
1677
  return {
2488
1678
  label: "Close icon color",
2489
1679
  placeholder: "rgba(161, 168, 194, 0.5)",
@@ -2492,7 +1682,7 @@ function registerComponent$4(runtime) {
2492
1682
  }),
2493
1683
  mobileMenuBackgroundColor: descriptors.ResponsiveColor((props, device) => {
2494
1684
  const mobileMenuAnimation = props.mobileMenuAnimation;
2495
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1685
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2496
1686
  return {
2497
1687
  label: "Menu BG color",
2498
1688
  placeholder: "black",
@@ -2770,19 +1960,6 @@ function registerBuiltinComponents(runtime) {
2770
1960
  unregisterVideoComponent();
2771
1961
  };
2772
1962
  }
2773
- const isServer = typeof window === "undefined";
2774
- const useInsertionEffectSpecifier = "useInsertionEffect";
2775
- const useInsertionEffect = (_c = React__namespace[useInsertionEffectSpecifier]) != null ? _c : React__namespace.useLayoutEffect;
2776
- function useStyle(style) {
2777
- const serialized = serialize.serializeStyles([style], css.cache.registered);
2778
- utils.registerStyles(css.cache, serialized, false);
2779
- useInsertionEffect(() => {
2780
- utils.insertStyles(css.cache, serialized, false);
2781
- });
2782
- if (isServer)
2783
- utils.insertStyles(css.cache, serialized, false);
2784
- return `${css.cache.key}-${serialized.name}`;
2785
- }
2786
1963
  var _path;
2787
1964
  function _extends() {
2788
1965
  _extends = Object.assign || function(target) {
@@ -2815,7 +1992,7 @@ const FallbackComponent = React.forwardRef(function FallbackComponent2({
2815
1992
  }, ref) {
2816
1993
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
2817
1994
  ref,
2818
- className: useStyle({
1995
+ className: responsiveStyle.useStyle({
2819
1996
  width: "100%",
2820
1997
  height: 54,
2821
1998
  backgroundColor: "#fcedf2",
@@ -2834,110 +2011,18 @@ const FallbackComponent = React.forwardRef(function FallbackComponent2({
2834
2011
  })]
2835
2012
  });
2836
2013
  });
2837
- function useSwatch(swatchId) {
2838
- const client = useMakeswiftClient();
2839
- const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
2840
- const swatch = shim.useSyncExternalStore(client.subscribe, readSwatch, readSwatch);
2841
- React.useEffect(() => {
2842
- if (swatchId != null)
2843
- client.fetchSwatch(swatchId).catch(console.error);
2844
- }, [client, swatchId]);
2845
- return swatch;
2846
- }
2847
- function useSwatches(swatchIds) {
2848
- const client = useMakeswiftClient();
2849
- const lastSnapshot = React.useRef();
2850
- function getSnapshot() {
2851
- const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
2852
- if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
2853
- return lastSnapshot.current;
2854
- }
2855
- return lastSnapshot.current = swatches2;
2856
- }
2857
- const swatches = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
2858
- React.useEffect(() => {
2859
- Promise.all(swatchIds.map((swatchId) => client.fetchSwatch(swatchId))).catch(console.error);
2860
- }, [client, swatchIds]);
2861
- return swatches;
2862
- }
2863
- function useFile(fileId) {
2864
- const client = useMakeswiftClient();
2865
- const readFile = () => fileId == null ? null : client.readFile(fileId);
2866
- const file = shim.useSyncExternalStore(client.subscribe, readFile, readFile);
2867
- React.useEffect(() => {
2868
- if (fileId != null)
2869
- client.fetchFile(fileId);
2870
- }, [client, fileId]);
2871
- return file;
2872
- }
2873
- function useFiles(fileIds) {
2874
- const client = useMakeswiftClient();
2875
- const lastSnapshot = React.useRef();
2876
- function getSnapshot() {
2877
- const files2 = fileIds.map((fileId) => client.readFile(fileId));
2878
- if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
2879
- return lastSnapshot.current;
2880
- }
2881
- return lastSnapshot.current = files2;
2882
- }
2883
- const files = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
2884
- React.useEffect(() => {
2885
- Promise.all(fileIds.map((fileId) => client.fetchFile(fileId))).catch(console.error);
2886
- }, [client, fileIds]);
2887
- return files;
2888
- }
2889
- function useTypography(typographyId) {
2890
- const client = useMakeswiftClient();
2891
- const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
2892
- const typography = shim.useSyncExternalStore(client.subscribe, readTypography, readTypography);
2893
- React.useEffect(() => {
2894
- if (typographyId != null)
2895
- client.fetchTypography(typographyId).catch(console.error);
2896
- }, [client, typographyId]);
2897
- return typography;
2898
- }
2899
- function useGlobalElement(globalElementId) {
2900
- const client = useMakeswiftClient();
2901
- const readGlobalElement = () => globalElementId == null ? null : client.readGlobalElement(globalElementId);
2902
- const globalElement = shim.useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement);
2903
- React.useEffect(() => {
2904
- if (globalElementId != null)
2905
- client.fetchGlobalElement(globalElementId).catch(console.error);
2906
- }, [client, globalElementId]);
2907
- return globalElement;
2908
- }
2909
- function usePagePathnameSlice(pageId) {
2910
- const client = useMakeswiftClient();
2911
- const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice(pageId);
2912
- const pagePathnameSlice = shim.useSyncExternalStore(client.subscribe, readPagePathnameSlice, readPagePathnameSlice);
2913
- React.useEffect(() => {
2914
- if (pageId != null)
2915
- client.fetchPagePathnameSlice(pageId).catch(console.error);
2916
- }, [client, pageId]);
2917
- return pagePathnameSlice;
2918
- }
2919
- function useTable(tableId) {
2920
- const client = useMakeswiftClient();
2921
- const readTable = () => tableId == null ? null : client.readTable(tableId);
2922
- const table = shim.useSyncExternalStore(client.subscribe, readTable, readTable);
2923
- React.useEffect(() => {
2924
- if (tableId != null)
2925
- client.fetchTable(tableId).catch(console.error);
2926
- }, [client, tableId]);
2927
- return table;
2928
- }
2929
- function mapSideColor(swatches, _d) {
2930
- var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
2014
+ function mapSideColor(swatches, _c) {
2015
+ var _d = _c, { color } = _d, restOfSide = __objRest(_d, ["color"]);
2931
2016
  return __spreadProps(__spreadValues({}, restOfSide), {
2932
2017
  color: color && {
2933
2018
  alpha: color.alpha,
2934
- swatch: swatches.filter(introspection.isNonNullable).find((s) => s && s.id === color.swatchId)
2019
+ swatch: swatches.filter(isNonNullable.isNonNullable).find((s) => s && s.id === color.swatchId)
2935
2020
  }
2936
2021
  });
2937
2022
  }
2938
2023
  function useBorder(value) {
2939
2024
  const swatchIds = introspection.getBorderSwatchIds(value);
2940
- const swatches = useSwatches(swatchIds);
2025
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2941
2026
  if (value == null)
2942
2027
  return null;
2943
2028
  return value.map((_a) => {
@@ -2962,7 +2047,7 @@ const ShadowDefaultValue = {
2962
2047
  };
2963
2048
  function useBoxShadow(value) {
2964
2049
  const swatchIds = introspection.getBoxShadowsSwatchIds(value);
2965
- const swatches = useSwatches(swatchIds);
2050
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2966
2051
  if (value == null)
2967
2052
  return null;
2968
2053
  return value.map((_a) => {
@@ -2977,7 +2062,7 @@ function useBoxShadow(value) {
2977
2062
  return __spreadProps(__spreadValues({}, restOfShadow), {
2978
2063
  payload: {
2979
2064
  color: color != null ? {
2980
- swatch: swatches.filter(introspection.isNonNullable).find((s) => s && s.id === color.swatchId),
2065
+ swatch: swatches.filter(isNonNullable.isNonNullable).find((s) => s && s.id === color.swatchId),
2981
2066
  alpha: color.alpha
2982
2067
  } : null,
2983
2068
  inset: inset != null ? inset : ShadowDefaultValue.inset,
@@ -2993,7 +2078,7 @@ function useBoxShadow(value) {
2993
2078
  }
2994
2079
  function useResponsiveColor(color) {
2995
2080
  const swatchIds = introspection.getResponsiveColorSwatchIds(color);
2996
- const swatches = useSwatches(swatchIds);
2081
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2997
2082
  if (color == null)
2998
2083
  return null;
2999
2084
  return color.map((_a) => {
@@ -3001,11 +2086,11 @@ function useResponsiveColor(color) {
3001
2086
  const { swatchId, alpha } = v;
3002
2087
  const swatch = swatches.find((s) => s && s.id === swatchId);
3003
2088
  return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
3004
- }).filter(introspection.isNonNullable);
2089
+ }).filter(isNonNullable.isNonNullable);
3005
2090
  }
3006
- const DEVICE_QUERIES = DEVICES.map((device) => ({
2091
+ const DEVICE_QUERIES = responsiveStyle.DEVICES.map((device) => ({
3007
2092
  id: device.id,
3008
- query: getDeviceMediaQuery(device).replace("@media", "")
2093
+ query: responsiveStyle.getDeviceMediaQuery(device).replace("@media", "")
3009
2094
  }));
3010
2095
  function subscribe(notify) {
3011
2096
  const cleanUpFns = DEVICE_QUERIES.map((q) => {
@@ -3018,7 +2103,7 @@ function subscribe(notify) {
3018
2103
  function useMediaQuery(responsiveValue) {
3019
2104
  const getServerSnapshot = () => {
3020
2105
  var _a;
3021
- return (_a = findDeviceOverride(responsiveValue, DEVICES[0].id)) == null ? void 0 : _a.value;
2106
+ return (_a = responsiveStyle.findDeviceOverride(responsiveValue, responsiveStyle.DEVICES[0].id)) == null ? void 0 : _a.value;
3022
2107
  };
3023
2108
  function getSnapshot() {
3024
2109
  var _a;
@@ -3028,216 +2113,10 @@ function useMediaQuery(responsiveValue) {
3028
2113
  }
3029
2114
  return matchedDevice;
3030
2115
  }, DEVICE_QUERIES[0].id);
3031
- return (_a = findDeviceOverride(responsiveValue, deviceId)) == null ? void 0 : _a.value;
2116
+ return (_a = responsiveStyle.findDeviceOverride(responsiveValue, deviceId)) == null ? void 0 : _a.value;
3032
2117
  }
3033
2118
  return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
3034
2119
  }
3035
- const getIndexes = (spans, index) => {
3036
- const flattened = spans.reduce((a, s) => a.concat(s), []);
3037
- if (index < 0 || index > flattened.length)
3038
- throw new RangeError();
3039
- let remainder = index;
3040
- let rowIndex = 0;
3041
- while (rowIndex < spans.length - 1 && remainder >= spans[rowIndex].length) {
3042
- remainder -= spans[rowIndex].length;
3043
- rowIndex += 1;
3044
- }
3045
- return [rowIndex, remainder];
3046
- };
3047
- function lengthDataToString(data) {
3048
- if (typeof data === "object")
3049
- return `${data.value}${data.unit}`;
3050
- if (typeof data === "number")
3051
- return `${data}px`;
3052
- return data;
3053
- }
3054
- function paddingPropertyDataToStyle(data, defaultValue = {}) {
3055
- var _a, _b, _c2, _d;
3056
- const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
3057
- const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
3058
- const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
3059
- const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
3060
- const style = {};
3061
- if (paddingTop != null)
3062
- style.paddingTop = lengthDataToString(paddingTop);
3063
- if (paddingRight != null)
3064
- style.paddingRight = lengthDataToString(paddingRight);
3065
- if (paddingBottom != null)
3066
- style.paddingBottom = lengthDataToString(paddingBottom);
3067
- if (paddingLeft != null)
3068
- style.paddingLeft = lengthDataToString(paddingLeft);
3069
- return style;
3070
- }
3071
- function marginPropertyDataToStyle(data, defaultValue = {}) {
3072
- var _a, _b, _c2, _d;
3073
- const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
3074
- const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
3075
- const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
3076
- const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
3077
- const style = {};
3078
- if (marginTop != null)
3079
- style.marginTop = lengthDataToString(marginTop);
3080
- if (marginRight != null)
3081
- style.marginRight = lengthDataToString(marginRight);
3082
- if (marginBottom != null)
3083
- style.marginBottom = lengthDataToString(marginBottom);
3084
- if (marginLeft != null)
3085
- style.marginLeft = lengthDataToString(marginLeft);
3086
- return style;
3087
- }
3088
- function lengthPercentageDataToString(data) {
3089
- if (typeof data === "object")
3090
- return `${data.value}${data.unit}`;
3091
- if (typeof data === "number")
3092
- return `${data}px`;
3093
- return data;
3094
- }
3095
- function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
3096
- var _a, _b, _c2, _d;
3097
- const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
3098
- const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
3099
- const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
3100
- const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
3101
- const style = {};
3102
- if (borderTopLeftRadius != null) {
3103
- style.borderTopLeftRadius = lengthPercentageDataToString(borderTopLeftRadius);
3104
- }
3105
- if (borderTopRightRadius != null) {
3106
- style.borderTopRightRadius = lengthPercentageDataToString(borderTopRightRadius);
3107
- }
3108
- if (borderBottomRightRadius != null) {
3109
- style.borderBottomRightRadius = lengthPercentageDataToString(borderBottomRightRadius);
3110
- }
3111
- if (borderBottomLeftRadius != null) {
3112
- style.borderBottomLeftRadius = lengthPercentageDataToString(borderBottomLeftRadius);
3113
- }
3114
- return style;
3115
- }
3116
- function colorToString(color) {
3117
- return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
3118
- }
3119
- function borderPropertyDataToStyle(data, defaultValue = {}) {
3120
- var _a, _b, _c2, _d;
3121
- const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
3122
- const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
3123
- const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
3124
- const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
3125
- const style = {};
3126
- if (borderTop != null)
3127
- style.borderTop = borderSideToString(borderTop);
3128
- if (borderRight != null)
3129
- style.borderRight = borderSideToString(borderRight);
3130
- if (borderBottom != null)
3131
- style.borderBottom = borderSideToString(borderBottom);
3132
- if (borderLeft != null)
3133
- style.borderLeft = borderSideToString(borderLeft);
3134
- return style;
3135
- }
3136
- function borderSideToString(borderSide) {
3137
- if (typeof borderSide === "string")
3138
- return borderSide;
3139
- if (typeof borderSide === "number")
3140
- return `${borderSide}px`;
3141
- const { width, color, style } = borderSide;
3142
- return `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : "black"}`;
3143
- }
3144
- function responsiveStyle(responsiveValues, join$1, strategy) {
3145
- return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
3146
- const device = getDevice(deviceId);
3147
- const mediaQuery = getDeviceMediaQuery(device);
3148
- return __spreadProps(__spreadValues({}, acc), {
3149
- [mediaQuery]: __spreadValues(__spreadValues({}, acc[mediaQuery]), value)
3150
- });
3151
- }, {});
3152
- }
3153
- function responsiveWidth(widthData, defaultValue = "100%") {
3154
- return __spreadValues({
3155
- maxWidth: "100%"
3156
- }, responsiveStyle([widthData], ([width = defaultValue]) => ({
3157
- width: typeof width === "object" ? `${width.value}${width.unit}` : width
3158
- })));
3159
- }
3160
- function responsivePadding(paddingData, defaultValue = {}) {
3161
- return responsiveStyle([paddingData], ([padding = {}]) => paddingPropertyDataToStyle(padding, Object.assign({ paddingTop: 0, paddingRight: 0, paddingBottom: 0, paddingLeft: 0 }, defaultValue)));
3162
- }
3163
- function responsiveMargin(marginData, defaultValue = {}) {
3164
- return responsiveStyle([marginData], ([margin = {}]) => marginPropertyDataToStyle(margin, Object.assign({ marginTop: 0, marginRight: "auto", marginBottom: 0, marginLeft: "auto" }, defaultValue)));
3165
- }
3166
- function responsiveBorderRadius(borderRadiusData, defaultValue = {}) {
3167
- return responsiveStyle([borderRadiusData], ([borderRadius = {}]) => borderRadiusPropertyDataToStyle(borderRadius, Object.assign({
3168
- borderTopLeftRadius: 0,
3169
- borderTopRightRadius: 0,
3170
- borderBottomRightRadius: 0,
3171
- borderBottomLeftRadius: 0
3172
- }, defaultValue)));
3173
- }
3174
- function responsiveBorder(borderData, defaultValue = {}) {
3175
- return responsiveStyle([borderData], ([border = {}]) => borderPropertyDataToStyle(border, Object.assign({
3176
- borderTop: "0px solid black",
3177
- borderRight: "0px solid black",
3178
- borderBottom: "0px solid black",
3179
- borderLeft: "0px solid black"
3180
- }, defaultValue)));
3181
- }
3182
- const floor = (d) => (v) => Math.floor(10 ** d * v) / 10 ** d;
3183
- function responsiveGridItem(props) {
3184
- return __spreadValues({
3185
- display: "flex"
3186
- }, responsiveStyle([props.grid, props.columnGap, props.rowGap], ([
3187
- { spans, count } = { spans: [[12]], count: 12 },
3188
- columnGap = { value: 0, unit: "px" },
3189
- rowGap = { value: 0, unit: "px" }
3190
- ]) => {
3191
- const [rowIndex, columnIndex] = getIndexes(spans, props.index);
3192
- const firstCol = columnIndex === 0;
3193
- const lastCol = columnIndex === spans[rowIndex].length - 1;
3194
- const span = spans[rowIndex][columnIndex];
3195
- const fraction = floor(5)(span / count);
3196
- const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`;
3197
- const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${columnGap.unit} / 2`;
3198
- const iePrecisionError = "0.01px";
3199
- const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`;
3200
- const firstRow = rowIndex === 0;
3201
- const lastRow = rowIndex === spans.length - 1;
3202
- return span === 0 ? { display: "none" } : {
3203
- flexBasis,
3204
- minWidth: flexBasis,
3205
- maxWidth: flexBasis,
3206
- paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
3207
- paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
3208
- paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,
3209
- paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`
3210
- };
3211
- }));
3212
- }
3213
- const getBoxShadow = (shadows) => shadows.map(({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) => `${inset ? "inset " : ""}${offsetX.toFixed(1)}px ${offsetY.toFixed(1)}px ${blurRadius}px ${spreadRadius}px ${color != null ? colorToString(color) : "rgba(0,0,0,0.2)"}`).filter(Boolean).join();
3214
- function responsiveShadow(value) {
3215
- return responsiveStyle([value], ([shadow = []]) => ({
3216
- boxShadow: getBoxShadow(shadow)
3217
- }));
3218
- }
3219
- function responsiveTextStyle(value) {
3220
- return responsiveStyle([value], ([
3221
- textStyle = {
3222
- fontFamily: null,
3223
- letterSpacing: null,
3224
- fontSize: null,
3225
- fontWeight: null,
3226
- textTransform: [],
3227
- fontStyle: []
3228
- }
3229
- ]) => {
3230
- const {
3231
- fontSize,
3232
- fontWeight,
3233
- fontStyle = [],
3234
- textTransform = [],
3235
- letterSpacing,
3236
- fontFamily
3237
- } = textStyle;
3238
- return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, fontFamily == null ? {} : { fontFamily: `"${fontFamily}"` }), fontWeight == null ? {} : { fontWeight }), letterSpacing == null ? {} : { letterSpacing }), fontSize == null ? {} : { fontSize: `${fontSize.value}${fontSize.unit}` }), textTransform.includes("uppercase") ? { textTransform: "uppercase" } : {}), fontStyle.includes("italic") ? { fontStyle: "italic" } : {});
3239
- });
3240
- }
3241
2120
  const defaultMargin = {
3242
2121
  marginTop: 0,
3243
2122
  marginRight: "auto",
@@ -3254,7 +2133,7 @@ function useStyleControlCssObject(style, controlDefinition) {
3254
2133
  const { properties } = controlDefinition.config;
3255
2134
  return __spreadValues(__spreadValues({}, properties.includes(descriptors.StyleControlProperty.Width) && {
3256
2135
  maxWidth: "100%"
3257
- }), responsiveStyle([
2136
+ }), responsiveStyle.responsiveStyle([
3258
2137
  style == null ? void 0 : style.width,
3259
2138
  style == null ? void 0 : style.margin,
3260
2139
  style == null ? void 0 : style.padding,
@@ -3262,14 +2141,14 @@ function useStyleControlCssObject(style, controlDefinition) {
3262
2141
  style == null ? void 0 : style.borderRadius,
3263
2142
  style == null ? void 0 : style.textStyle
3264
2143
  ], ([width, margin, padding, border, borderRadius, textStyle]) => {
3265
- var _a, _b, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
2144
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3266
2145
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(descriptors.StyleControlProperty.Width) && {
3267
2146
  width: (_a = widthToString(width)) != null ? _a : "100%"
3268
- }), properties.includes(descriptors.StyleControlProperty.Margin) && marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(descriptors.StyleControlProperty.Padding) && paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(descriptors.StyleControlProperty.Border) && {
3269
- borderTop: (_b = borderSideToString2(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
3270
- borderRight: (_c2 = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c2 : "0 solid black",
3271
- borderBottom: (_d = borderSideToString2(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
3272
- borderLeft: (_e = borderSideToString2(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
2147
+ }), properties.includes(descriptors.StyleControlProperty.Margin) && responsiveStyle.marginPropertyDataToStyle(margin != null ? margin : defaultMargin, defaultMargin)), properties.includes(descriptors.StyleControlProperty.Padding) && responsiveStyle.paddingPropertyDataToStyle(padding != null ? padding : defaultPadding, defaultPadding)), properties.includes(descriptors.StyleControlProperty.Border) && {
2148
+ borderTop: (_b = borderSideToString(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
2149
+ borderRight: (_c = borderSideToString(border == null ? void 0 : border.borderRight)) != null ? _c : "0 solid black",
2150
+ borderBottom: (_d = borderSideToString(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
2151
+ borderLeft: (_e = borderSideToString(border == null ? void 0 : border.borderLeft)) != null ? _e : "0 solid black"
3273
2152
  }), properties.includes(descriptors.StyleControlProperty.BorderRadius) && {
3274
2153
  borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
3275
2154
  borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
@@ -3283,18 +2162,18 @@ function useStyleControlCssObject(style, controlDefinition) {
3283
2162
  function widthToString(widthProperty) {
3284
2163
  if (widthProperty == null)
3285
2164
  return null;
3286
- return lengthPercentageDataToString(widthProperty);
2165
+ return responsiveStyle.lengthPercentageDataToString(widthProperty);
3287
2166
  }
3288
- function borderSideToString2(borderSide) {
2167
+ function borderSideToString(borderSide) {
3289
2168
  if (borderSide == null)
3290
2169
  return null;
3291
2170
  const { width, color, style: style2 } = borderSide;
3292
- return `${width != null ? width : 0}px ${style2} ${color != null ? colorToString(color) : "black"}`;
2171
+ return `${width != null ? width : 0}px ${style2} ${color != null ? responsiveStyle.colorToString(color) : "black"}`;
3293
2172
  }
3294
2173
  function borderRadiusToString(borderRadius) {
3295
2174
  if (borderRadius == null)
3296
2175
  return null;
3297
- return lengthPercentageDataToString(borderRadius);
2176
+ return responsiveStyle.lengthPercentageDataToString(borderRadius);
3298
2177
  }
3299
2178
  function fontSizeToString(fontSize) {
3300
2179
  return `${fontSize.value}${fontSize.unit}`;
@@ -3303,7 +2182,7 @@ function useStyleControlCssObject(style, controlDefinition) {
3303
2182
  function useFormattedStyle(styleControlData, controlDefinition, control) {
3304
2183
  const style = useStyleControlCssObject(styleControlData, controlDefinition);
3305
2184
  const guid = React.useId().replaceAll(":", "");
3306
- const styleClassName = useStyle(style);
2185
+ const styleClassName = responsiveStyle.useStyle(style);
3307
2186
  const classNames = `${styleClassName} ${guid}`;
3308
2187
  React.useEffect(() => {
3309
2188
  let currentBoxModel = null;
@@ -3312,7 +2191,7 @@ function useFormattedStyle(styleControlData, controlDefinition, control) {
3312
2191
  return;
3313
2192
  const element = document.querySelector(`.${guid}`);
3314
2193
  const measuredBoxModel = element == null ? null : boxModels.getBox(element);
3315
- if (!deepEqual(currentBoxModel, measuredBoxModel)) {
2194
+ if (!responsiveStyle.deepEqual(currentBoxModel, measuredBoxModel)) {
3316
2195
  currentBoxModel = measuredBoxModel;
3317
2196
  control.changeBoxModel(currentBoxModel);
3318
2197
  }
@@ -3339,7 +2218,7 @@ function useCheckboxControlValue(data, definition) {
3339
2218
  function useColorValue(data, definition) {
3340
2219
  var _a, _b;
3341
2220
  const swatchId = (_a = data == null ? void 0 : data.swatchId) != null ? _a : null;
3342
- const swatch = useSwatch(swatchId);
2221
+ const swatch = responsiveStyle.useSwatch(swatchId);
3343
2222
  const alpha = (_b = data == null ? void 0 : data.alpha) != null ? _b : 1;
3344
2223
  if (swatch == null) {
3345
2224
  const { defaultValue } = definition.config;
@@ -3362,7 +2241,7 @@ function useImageControlValue(data, definition) {
3362
2241
  var _a;
3363
2242
  const format = (_a = definition.config.format) != null ? _a : descriptors.ImageControlValueFormat.URL;
3364
2243
  const fileId = data != null ? data : null;
3365
- const file = useFile(fileId);
2244
+ const file = responsiveStyle.useFile(fileId);
3366
2245
  if (format === descriptors.ImageControlValueFormat.URL) {
3367
2246
  return file == null ? void 0 : file.publicUrl;
3368
2247
  }
@@ -3376,7 +2255,7 @@ function useImageControlValue(data, definition) {
3376
2255
  function useLinkControlValue(link, _definition) {
3377
2256
  var _a;
3378
2257
  const pageId = link && link.type === "OPEN_PAGE" ? link.payload.pageId : null;
3379
- const page = usePagePathnameSlice(pageId != null ? pageId : null);
2258
+ const page = responsiveStyle.usePagePathnameSlice(pageId != null ? pageId : null);
3380
2259
  const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a = link.payload.elementIdConfig) == null ? void 0 : _a.elementKey : null;
3381
2260
  const elementId = useElementId(elementKey);
3382
2261
  let href = "#";
@@ -3502,7 +2381,7 @@ function pollBoxModel({
3502
2381
  let currentBoxModel = null;
3503
2382
  const handleAnimationFrameRequest = () => {
3504
2383
  const measuredBoxModel = boxModels.getBox(element);
3505
- if (!deepEqual(currentBoxModel, measuredBoxModel)) {
2384
+ if (!responsiveStyle.deepEqual(currentBoxModel, measuredBoxModel)) {
3506
2385
  currentBoxModel = measuredBoxModel;
3507
2386
  onBoxModelChange(currentBoxModel);
3508
2387
  }
@@ -3532,13 +2411,13 @@ function useSlot(data, control) {
3532
2411
  }, element.key))
3533
2412
  });
3534
2413
  }
3535
- function Slot(_f) {
3536
- var _g = _f, {
2414
+ function Slot(_e) {
2415
+ var _f = _e, {
3537
2416
  as,
3538
2417
  control,
3539
2418
  children,
3540
2419
  className
3541
- } = _g, restOfProps = __objRest(_g, [
2420
+ } = _f, restOfProps = __objRest(_f, [
3542
2421
  "as",
3543
2422
  "control",
3544
2423
  "children",
@@ -3546,7 +2425,7 @@ function Slot(_f) {
3546
2425
  ]);
3547
2426
  const As = as != null ? as : "div";
3548
2427
  const [element, setElement] = React.useState(null);
3549
- const baseClassName = useStyle({
2428
+ const baseClassName = responsiveStyle.useStyle({
3550
2429
  display: "flex",
3551
2430
  flexWrap: "wrap",
3552
2431
  width: "100%"
@@ -3567,15 +2446,15 @@ function Slot(_f) {
3567
2446
  }
3568
2447
  Slot.Placeholder = SlotPlaceholder;
3569
2448
  Slot.Item = SlotItem;
3570
- function SlotItem(_h) {
3571
- var _i = _h, {
2449
+ function SlotItem(_g) {
2450
+ var _h = _g, {
3572
2451
  as,
3573
2452
  control,
3574
2453
  grid,
3575
2454
  index,
3576
2455
  children,
3577
2456
  className
3578
- } = _i, restOfProps = __objRest(_i, [
2457
+ } = _h, restOfProps = __objRest(_h, [
3579
2458
  "as",
3580
2459
  "control",
3581
2460
  "grid",
@@ -3585,13 +2464,13 @@ function SlotItem(_h) {
3585
2464
  ]);
3586
2465
  const As = as != null ? as : "div";
3587
2466
  const [element, setElement] = React.useState(null);
3588
- const baseClassName = useStyle(__spreadValues({
2467
+ const baseClassName = responsiveStyle.useStyle(__spreadValues({
3589
2468
  display: "flex"
3590
- }, responsiveStyle([grid], ([{
2469
+ }, responsiveStyle.responsiveStyle([grid], ([{
3591
2470
  count = 12,
3592
2471
  spans = [[12]]
3593
2472
  } = {}]) => {
3594
- const [rowIndex, columnIndex] = getIndexes(spans, index);
2473
+ const [rowIndex, columnIndex] = responsiveStyle.getIndexes(spans, index);
3595
2474
  const span = spans[rowIndex][columnIndex];
3596
2475
  const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`;
3597
2476
  return span === 0 ? {
@@ -3629,7 +2508,7 @@ function SlotPlaceholder({
3629
2508
  }, [element, control]);
3630
2509
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
3631
2510
  ref: setElement,
3632
- className: useStyle({
2511
+ className: responsiveStyle.useStyle({
3633
2512
  width: "100%",
3634
2513
  background: "rgba(161, 168, 194, 0.18)",
3635
2514
  height: "80px"
@@ -3638,7 +2517,7 @@ function SlotPlaceholder({
3638
2517
  xmlns: "http://www.w3.org/2000/svg",
3639
2518
  width: "100%",
3640
2519
  height: "100%",
3641
- className: useStyle({
2520
+ className: responsiveStyle.useStyle({
3642
2521
  overflow: "visible",
3643
2522
  padding: 8
3644
2523
  }),
@@ -3761,24 +2640,24 @@ function ControlValue({
3761
2640
  }
3762
2641
  }
3763
2642
  function useWidthStyle(value, descriptor) {
3764
- return useStyle(responsiveWidth(value, descriptor.options.defaultValue));
2643
+ return responsiveStyle.useStyle(responsiveStyle.responsiveWidth(value, descriptor.options.defaultValue));
3765
2644
  }
3766
2645
  function usePaddingStyle(value) {
3767
- return useStyle(responsivePadding(value));
2646
+ return responsiveStyle.useStyle(responsiveStyle.responsivePadding(value));
3768
2647
  }
3769
2648
  function useMarginStyle(value) {
3770
- return useStyle(responsiveMargin(value));
2649
+ return responsiveStyle.useStyle(responsiveStyle.responsiveMargin(value));
3771
2650
  }
3772
2651
  function useBorderRadiusStyle(value) {
3773
- return useStyle(responsiveBorderRadius(value));
2652
+ return responsiveStyle.useStyle(responsiveStyle.responsiveBorderRadius(value));
3774
2653
  }
3775
2654
  function useShadowsStyle(value) {
3776
2655
  const shadowValue = useBoxShadow(value);
3777
- return useStyle(responsiveShadow(shadowValue != null ? shadowValue : void 0));
2656
+ return responsiveStyle.useStyle(responsiveStyle.responsiveShadow(shadowValue != null ? shadowValue : void 0));
3778
2657
  }
3779
2658
  function useBorderStyle(value) {
3780
2659
  const borderData = useBorder(value);
3781
- return useStyle(responsiveBorder(borderData != null ? borderData : void 0));
2660
+ return responsiveStyle.useStyle(responsiveStyle.responsiveBorder(borderData != null ? borderData : void 0));
3782
2661
  }
3783
2662
  function PropsValue({
3784
2663
  element,
@@ -3795,7 +2674,7 @@ function PropsValue({
3795
2674
  return constants.getPropControllers(state, documentKey, element.key);
3796
2675
  });
3797
2676
  return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
3798
- var _a2, _b, _c2;
2677
+ var _a2, _b, _c;
3799
2678
  switch (descriptor.type) {
3800
2679
  case textInput.CheckboxControlType:
3801
2680
  case textInput.NumberControlType:
@@ -3837,7 +2716,7 @@ function PropsValue({
3837
2716
  }, descriptor.type);
3838
2717
  }
3839
2718
  case descriptors.SlotControlType: {
3840
- const control = (_c2 = propControllers == null ? void 0 : propControllers[propName]) != null ? _c2 : null;
2719
+ const control = (_c = propControllers == null ? void 0 : propControllers[propName]) != null ? _c : null;
3841
2720
  return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
3842
2721
  hook: useSlot,
3843
2722
  parameters: [props[propName], control],
@@ -4040,8 +2919,8 @@ function createReactRuntime(store) {
4040
2919
  unregisterReactComponent();
4041
2920
  };
4042
2921
  },
4043
- copyElementTree(elementTree, replacementContext) {
4044
- return constants.copyElementTree(store.getState(), elementTree, replacementContext);
2922
+ copyElementTree(elementTree2, replacementContext) {
2923
+ return constants.copyElementTree(store.getState(), elementTree2, replacementContext);
4045
2924
  }
4046
2925
  };
4047
2926
  }
@@ -4054,10 +2933,10 @@ const PreviewProvider = dynamic__default["default"](() => Promise.resolve().then
4054
2933
  const LiveProvider = dynamic__default["default"](() => Promise.resolve().then(function() {
4055
2934
  return require("./LiveProvider.cjs.js");
4056
2935
  }));
4057
- function RuntimeProvider(_j) {
4058
- var _k = _j, {
2936
+ function RuntimeProvider(_i) {
2937
+ var _j = _i, {
4059
2938
  preview
4060
- } = _k, props = __objRest(_k, [
2939
+ } = _j, props = __objRest(_j, [
4061
2940
  "preview"
4062
2941
  ]);
4063
2942
  return preview ? /* @__PURE__ */ jsxRuntime.jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsxRuntime.jsx(LiveProvider, __spreadValues({}, props));
@@ -4154,7 +3033,7 @@ const DisableRegisterElement = React.createContext(false);
4154
3033
  const ElementReference = React.memo(React.forwardRef(function ElementReference2({
4155
3034
  elementReference
4156
3035
  }, ref) {
4157
- const globalElement = useGlobalElement(elementReference.value);
3036
+ const globalElement = responsiveStyle.useGlobalElement(elementReference.value);
4158
3037
  const globalElementData = globalElement == null ? void 0 : globalElement.data;
4159
3038
  const elementReferenceDocument = useDocument(elementReference.key);
4160
3039
  const documentKey = elementReference.key;
@@ -4264,15 +3143,12 @@ exports.DEFAULT_ITEM_ANIMATE_DELAY = DEFAULT_ITEM_ANIMATE_DELAY;
4264
3143
  exports.DEFAULT_ITEM_ANIMATE_DURATION = DEFAULT_ITEM_ANIMATE_DURATION;
4265
3144
  exports.DEFAULT_ITEM_ANIMATE_TYPE = DEFAULT_ITEM_ANIMATE_TYPE;
4266
3145
  exports.DEFAULT_ITEM_STAGGER_DURATION = DEFAULT_ITEM_STAGGER_DURATION;
4267
- exports.DEVICES = DEVICES;
4268
3146
  exports.Document = Document$1;
4269
3147
  exports.DocumentReference = DocumentReference;
4270
3148
  exports.Element = Element$1;
4271
3149
  exports.ElementImperativeHandle = ElementImperativeHandle;
4272
3150
  exports.Makeswift = Makeswift;
4273
3151
  exports.MakeswiftApiHandler = MakeswiftApiHandler;
4274
- exports.MakeswiftClient = MakeswiftClient;
4275
- exports.MakeswiftProvider = MakeswiftProvider;
4276
3152
  exports.Page = Page$1;
4277
3153
  exports.Page$1 = Page;
4278
3154
  exports.PageProvider = PageProvider;
@@ -4283,36 +3159,20 @@ exports.RuntimeProvider = RuntimeProvider;
4283
3159
  exports.Shapes = Shapes;
4284
3160
  exports.Sizes = Sizes;
4285
3161
  exports.StoreContext = StoreContext;
4286
- exports.colorToString = colorToString;
4287
- exports.deepEqual = deepEqual;
4288
- exports.findDeviceOverride = findDeviceOverride;
4289
3162
  exports.forwardNextDynamicRef = forwardNextDynamicRef;
4290
3163
  exports.getServerSideProps = getServerSideProps;
4291
3164
  exports.getStaticPaths = getStaticPaths;
4292
3165
  exports.getStaticProps = getStaticProps;
4293
3166
  exports.pollBoxModel = pollBoxModel;
4294
- exports.responsiveGridItem = responsiveGridItem;
4295
- exports.responsiveStyle = responsiveStyle;
4296
- exports.responsiveTextStyle = responsiveTextStyle;
4297
- exports.responsiveWidth = responsiveWidth;
4298
- exports.shallowMergeFallbacks = shallowMergeFallbacks;
4299
3167
  exports.storeContextDefaultValue = storeContextDefaultValue;
4300
3168
  exports.useBorder = useBorder;
4301
3169
  exports.useBoxShadow = useBoxShadow;
4302
3170
  exports.useBuilderEditMode = useBuilderEditMode;
4303
3171
  exports.useElementId = useElementId;
4304
- exports.useFile = useFile;
4305
- exports.useFiles = useFiles;
4306
3172
  exports.useFormContext = useFormContext;
4307
3173
  exports.useIsInBuilder = useIsInBuilder;
4308
3174
  exports.useIsPreview = useIsPreview;
4309
- exports.useMakeswiftClient = useMakeswiftClient;
4310
3175
  exports.useMediaQuery = useMediaQuery;
4311
3176
  exports.usePageId = usePageId;
4312
- exports.usePagePathnameSlice = usePagePathnameSlice;
4313
3177
  exports.useResponsiveColor = useResponsiveColor;
4314
- exports.useStyle = useStyle;
4315
- exports.useSwatches = useSwatches;
4316
- exports.useTable = useTable;
4317
- exports.useTypography = useTypography;
4318
3178
  //# sourceMappingURL=index.cjs.js.map