@makeswift/runtime 0.7.18 → 0.8.0

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 (168) 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 +10 -7
  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 +13 -10
  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/index.cjs.js +368 -1506
  74. package/dist/index.cjs.js.map +1 -1
  75. package/dist/index.cjs2.js +22 -20
  76. package/dist/index.cjs2.js.map +1 -1
  77. package/dist/index.cjs3.js +2 -1
  78. package/dist/index.cjs3.js.map +1 -1
  79. package/dist/index.cjs4.js +2 -2
  80. package/dist/index.cjs4.js.map +1 -1
  81. package/dist/index.cjs5.js +3 -3
  82. package/dist/index.cjs5.js.map +1 -1
  83. package/dist/index.cjs6.js +6 -3
  84. package/dist/index.cjs6.js.map +1 -1
  85. package/dist/index.cjs7.js +19 -16
  86. package/dist/index.cjs7.js.map +1 -1
  87. package/dist/index.es.js +334 -1452
  88. package/dist/index.es.js.map +1 -1
  89. package/dist/index.es2.js +4 -2
  90. package/dist/index.es2.js.map +1 -1
  91. package/dist/index.es3.js +2 -1
  92. package/dist/index.es3.js.map +1 -1
  93. package/dist/index.es4.js +1 -1
  94. package/dist/index.es5.js +1 -1
  95. package/dist/index.es6.js +6 -3
  96. package/dist/index.es6.js.map +1 -1
  97. package/dist/index.es7.js +14 -11
  98. package/dist/index.es7.js.map +1 -1
  99. package/dist/introspection.cjs.js +2 -5
  100. package/dist/introspection.cjs.js.map +1 -1
  101. package/dist/introspection.es.js +2 -4
  102. package/dist/introspection.es.js.map +1 -1
  103. package/dist/isNonNullable.cjs.js +6 -0
  104. package/dist/isNonNullable.cjs.js.map +1 -0
  105. package/dist/isNonNullable.es.js +5 -0
  106. package/dist/isNonNullable.es.js.map +1 -0
  107. package/dist/leaf.cjs.js +11 -11
  108. package/dist/leaf.cjs.js.map +1 -1
  109. package/dist/leaf.es.js +2 -2
  110. package/dist/main.cjs.js +1 -0
  111. package/dist/main.cjs.js.map +1 -1
  112. package/dist/main.es.js +1 -0
  113. package/dist/main.es.js.map +1 -1
  114. package/dist/next.cjs.js +8 -6
  115. package/dist/next.cjs.js.map +1 -1
  116. package/dist/next.es.js +9 -6
  117. package/dist/next.es.js.map +1 -1
  118. package/dist/prop-controllers.cjs.js +1 -0
  119. package/dist/prop-controllers.cjs.js.map +1 -1
  120. package/dist/prop-controllers.es.js +1 -0
  121. package/dist/prop-controllers.es.js.map +1 -1
  122. package/dist/react.cjs.js +6 -3
  123. package/dist/react.cjs.js.map +1 -1
  124. package/dist/react.es.js +6 -3
  125. package/dist/react.es.js.map +1 -1
  126. package/dist/responsive-style.cjs.js +917 -0
  127. package/dist/responsive-style.cjs.js.map +1 -0
  128. package/dist/responsive-style.es.js +853 -0
  129. package/dist/responsive-style.es.js.map +1 -0
  130. package/dist/slate.cjs.js +5 -25
  131. package/dist/slate.cjs.js.map +1 -1
  132. package/dist/slate.es.js +5 -25
  133. package/dist/slate.es.js.map +1 -1
  134. package/dist/types/src/api/graphql/documents/queries.d.ts +0 -2
  135. package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
  136. package/dist/types/src/api/graphql/generated/types.d.ts +0 -70
  137. package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
  138. package/dist/types/src/api/react.d.ts +0 -3
  139. package/dist/types/src/api/react.d.ts.map +1 -1
  140. package/dist/types/src/next/api-handler/handlers/element-tree.d.ts +12 -0
  141. package/dist/types/src/next/api-handler/handlers/element-tree.d.ts.map +1 -0
  142. package/dist/types/src/next/api-handler/handlers/fonts.d.ts +18 -0
  143. package/dist/types/src/next/api-handler/handlers/fonts.d.ts.map +1 -0
  144. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +17 -0
  145. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -0
  146. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts +8 -0
  147. package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -0
  148. package/dist/types/src/next/api-handler/handlers/revalidate.d.ts +13 -0
  149. package/dist/types/src/next/api-handler/handlers/revalidate.d.ts.map +1 -0
  150. package/dist/types/src/next/api-handler/index.d.ts +19 -0
  151. package/dist/types/src/next/api-handler/index.d.ts.map +1 -0
  152. package/dist/types/src/next/client.d.ts +11 -35
  153. package/dist/types/src/next/client.d.ts.map +1 -1
  154. package/dist/types/src/next/index.d.ts +1 -6
  155. package/dist/types/src/next/index.d.ts.map +1 -1
  156. package/dist/types/src/state/actions.d.ts +2 -22
  157. package/dist/types/src/state/actions.d.ts.map +1 -1
  158. package/dist/types/src/state/makeswift-api-client.d.ts +4 -9
  159. package/dist/types/src/state/makeswift-api-client.d.ts.map +1 -1
  160. package/dist/types/src/state/modules/api-resources.d.ts +4 -4
  161. package/dist/types/src/state/modules/api-resources.d.ts.map +1 -1
  162. package/package.json +3 -2
  163. package/dist/types/src/api/introspection.d.ts +0 -11
  164. package/dist/types/src/api/introspection.d.ts.map +0 -1
  165. package/dist/types/src/next/api-handler.d.ts +0 -48
  166. package/dist/types/src/next/api-handler.d.ts.map +0 -1
  167. package/dist/types/src/next/snapshots.d.ts +0 -152
  168. 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.18";
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,28 +692,115 @@ class Document$1 extends NextDocument__default["default"] {
1340
692
  });
1341
693
  }
1342
694
  }
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);
707
+ }
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.0";
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 }) {
727
+ const previewModeProxy = httpProxy.createProxyServer();
728
+ previewModeProxy.once("proxyReq", (proxyReq) => {
729
+ proxyReq.removeHeader("X-Makeswift-Preview-Mode");
730
+ proxyReq.removeHeader("X-Invoke-Path");
731
+ proxyReq.removeHeader("X-Invoke-Query");
732
+ const url = new URL(proxyReq.path, "http://n");
733
+ url.searchParams.delete("x-makeswift-preview-mode");
734
+ proxyReq.path = url.pathname + url.search;
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
+ }
1343
766
  function isErrorWithMessage(error) {
1344
767
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1345
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
+ }
1346
793
  function MakeswiftApiHandler(apiKey, {
1347
794
  appOrigin = "https://app.makeswift.com",
1348
795
  apiOrigin = "https://api.makeswift.com",
1349
796
  getFonts
1350
797
  } = {}) {
1351
798
  const cors = Cors__default["default"]({ origin: appOrigin });
1352
- const previewModeProxy = httpProxy.createProxyServer();
1353
- previewModeProxy.on("proxyReq", (proxyReq) => {
1354
- proxyReq.removeHeader("X-Makeswift-Preview-Mode");
1355
- const url = new URL(proxyReq.path, "http://n");
1356
- url.searchParams.delete("x-makeswift-preview-mode");
1357
- proxyReq.path = url.pathname + url.search;
1358
- });
1359
799
  if (typeof apiKey !== "string") {
1360
800
  throw new Error(`The Makeswift Next.js API handler must be passed a valid Makeswift site API key: \`MakeswiftApiHandler('<makeswift_site_api_key>')\`
1361
801
  Received "${apiKey}" instead.`);
1362
802
  }
1363
803
  return async function makeswiftApiHandler(req, res) {
1364
- var _a;
1365
804
  await new Promise((resolve2, reject) => {
1366
805
  cors(req, res, (err) => {
1367
806
  if (err instanceof Error)
@@ -1376,224 +815,40 @@ Received "${apiKey}" instead.`);
1376
815
  Received "${makeswift}" for the \`makeswift\` param instead.
1377
816
  Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`);
1378
817
  }
1379
- const action = makeswift.join("/");
1380
- switch (action) {
1381
- case "manifest": {
1382
- if (req.query.secret !== apiKey)
1383
- return res.status(401).json({ message: "Unauthorized" });
1384
- return res.json({
1385
- version,
1386
- previewMode: true,
1387
- interactionMode: true,
1388
- clientSideNavigation: true,
1389
- elementFromPoint: false
1390
- });
1391
- }
1392
- case "revalidate": {
1393
- if (req.query.secret !== apiKey) {
1394
- return res.status(401).json({ message: "Unauthorized" });
1395
- }
1396
- if (typeof req.query.path !== "string") {
1397
- return res.status(400).json({ message: "Bad Request" });
1398
- }
1399
- const revalidate = res.revalidate;
1400
- if (typeof revalidate !== "function") {
1401
- 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.
1402
- Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
1403
- console.warn(message);
1404
- return res.json({ revalidated: false });
1405
- }
1406
- try {
1407
- await revalidate(req.query.path);
1408
- return res.json({ revalidated: true });
1409
- } catch (error) {
1410
- if (isErrorWithMessage(error)) {
1411
- return res.status(500).json({ message: error.message });
1412
- }
1413
- return res.status(500).json({ message: "Error Revalidating" });
1414
- }
1415
- }
1416
- case "proxy-preview-mode": {
1417
- if (req.query.secret !== apiKey)
1418
- return res.status(401).send("Unauthorized");
1419
- const host = req.headers.host;
1420
- if (host == null)
1421
- return res.status(400).send("Bad Request");
1422
- const forwardedProto = req.headers["x-forwarded-proto"];
1423
- const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
1424
- const forwardedSSL = req.headers["x-forwarded-ssl"];
1425
- const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
1426
- const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
1427
- let target = `${proto}://${host}`;
1428
- if (process.env["NODE_ENV"] !== "production") {
1429
- const port = req.socket.localPort;
1430
- if (port != null)
1431
- target = `http://localhost:${port}`;
1432
- }
1433
- const setCookie = res.setPreviewData({ makeswift: true }).getHeader("Set-Cookie");
1434
- res.removeHeader("Set-Cookie");
1435
- if (!Array.isArray(setCookie))
1436
- return res.status(500).send("Internal Server Error");
1437
- const cookie$1 = setCookieParser.parse(setCookie).map((cookie2) => cookie.serialize(cookie2.name, cookie2.value, cookie2)).join(";");
1438
- return await new Promise((resolve2, reject) => previewModeProxy.web(req, res, { target, headers: { cookie: cookie$1 } }, (err) => {
1439
- if (err)
1440
- reject(err);
1441
- else
1442
- resolve2();
1443
- }));
1444
- }
1445
- case "fonts": {
1446
- const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1447
- return res.json(fonts);
1448
- }
1449
- case "element-tree": {
1450
- const elementTree = req.body.elementTree;
1451
- const replacementContext = req.body.replacementContext;
1452
- if (elementTree == null) {
1453
- return res.status(400).json({ message: "elementTree must be defined" });
1454
- }
1455
- if (replacementContext == null) {
1456
- return res.status(400).json({ message: "replacementContext must be defined" });
1457
- }
1458
- const generatedElementTree = ReactRuntime.copyElementTree(elementTree, replacementContext);
1459
- const response = { elementTree: generatedElementTree };
1460
- return res.json(response);
1461
- }
1462
- case "snapshot": {
1463
- let validateBody = function(body2) {
1464
- if (body2.pageId == null) {
1465
- return res.status(400).json({ message: "Must define pageId." });
1466
- }
1467
- if (body2.currentSnapshot == null && body2.publishedElementTree == null) {
1468
- return res.status(400).json({ message: "Either currentSnapshot or publishedElementTree must be defined." });
1469
- }
1470
- };
1471
- const body = req.body;
1472
- validateBody(body);
1473
- const client = new Makeswift(apiKey, {
1474
- apiOrigin
1475
- });
1476
- const makeswiftApiClient = new MakeswiftClient({ uri: new URL("graphql", apiOrigin).href });
1477
- async function formMakeswiftResources(publishedResources) {
1478
- var _a2, _b, _c2, _d, _e, _f, _g, _h;
1479
- const publishedResourcesInMakeswiftSnapshotFormat = {
1480
- swatches: [],
1481
- typographies: [],
1482
- files: [],
1483
- tables: [],
1484
- pagePathnameSlices: [],
1485
- globalElements: [],
1486
- snippets: [],
1487
- fonts: [],
1488
- pageMetadata: publishedResources == null ? void 0 : publishedResources.pageMetadata,
1489
- pageSeo: publishedResources == null ? void 0 : publishedResources.pageSeo
1490
- };
1491
- if (publishedResources == null) {
1492
- return publishedResourcesInMakeswiftSnapshotFormat;
1493
- }
1494
- for await (const swatchId of publishedResources.swatches || []) {
1495
- const swatch = await makeswiftApiClient.fetchSwatch(swatchId);
1496
- if (swatch != null) {
1497
- (_a2 = publishedResourcesInMakeswiftSnapshotFormat.swatches) == null ? void 0 : _a2.push({
1498
- id: swatchId,
1499
- value: swatch
1500
- });
1501
- }
1502
- }
1503
- for await (const typographyId of publishedResources.typographies || []) {
1504
- const typography = await makeswiftApiClient.fetchTypography(typographyId);
1505
- if (typography != null) {
1506
- (_b = publishedResourcesInMakeswiftSnapshotFormat.typographies) == null ? void 0 : _b.push({
1507
- id: typographyId,
1508
- value: typography
1509
- });
1510
- }
1511
- }
1512
- for await (const fileId of publishedResources.files || []) {
1513
- const file = await makeswiftApiClient.fetchFile(fileId);
1514
- if (file != null) {
1515
- (_c2 = publishedResourcesInMakeswiftSnapshotFormat.files) == null ? void 0 : _c2.push({
1516
- id: fileId,
1517
- value: fileToFileSnapshot(file)
1518
- });
1519
- }
1520
- }
1521
- for await (const tableId of publishedResources.tables || []) {
1522
- const table = await makeswiftApiClient.fetchTable(tableId);
1523
- if (table != null) {
1524
- (_d = publishedResourcesInMakeswiftSnapshotFormat.tables) == null ? void 0 : _d.push({
1525
- id: tableId,
1526
- value: table
1527
- });
1528
- }
1529
- }
1530
- for await (const pageId of publishedResources.pagePathnameSlices || []) {
1531
- const pagePathnameSlice = await makeswiftApiClient.fetchPagePathnameSlice(pageId);
1532
- if (pagePathnameSlice != null) {
1533
- (_e = publishedResourcesInMakeswiftSnapshotFormat.pagePathnameSlices) == null ? void 0 : _e.push({
1534
- id: pageId,
1535
- value: pagePathnameSlice
1536
- });
1537
- }
1538
- }
1539
- for await (const globalElementId of publishedResources.globalElements || []) {
1540
- const globalElement = await makeswiftApiClient.fetchGlobalElement(globalElementId);
1541
- if (globalElement != null) {
1542
- (_f = publishedResourcesInMakeswiftSnapshotFormat.globalElements) == null ? void 0 : _f.push({
1543
- id: globalElementId,
1544
- value: globalElement
1545
- });
1546
- }
1547
- }
1548
- if (publishedResources.snippets != null || publishedResources.fonts != null) {
1549
- const response2 = await fetch(new URL(`/v1/pages/${body.pageId}/document?preview=false`, apiOrigin).toString(), {
1550
- headers: { ["X-API-Key"]: apiKey }
1551
- });
1552
- if (!response2.ok) {
1553
- throw new Error(`Failed to hit live page endpoint: "${response2.statusText}"`);
1554
- }
1555
- const document2 = await response2.json();
1556
- const availableSnippets = document2.snippets;
1557
- const availableFonts = document2.fonts;
1558
- for await (const snippetId of publishedResources.snippets || []) {
1559
- const snippet = availableSnippets.find((availableSnippet) => availableSnippet.id === snippetId);
1560
- if (snippet != null) {
1561
- (_g = publishedResourcesInMakeswiftSnapshotFormat.snippets) == null ? void 0 : _g.push({
1562
- id: snippetId,
1563
- value: snippet
1564
- });
1565
- }
1566
- }
1567
- for await (const family of publishedResources.fonts || []) {
1568
- const font = availableFonts.find((availableFont) => availableFont.family === family);
1569
- if (font != null) {
1570
- (_h = publishedResourcesInMakeswiftSnapshotFormat.fonts) == null ? void 0 : _h.push({
1571
- id: family,
1572
- value: font
1573
- });
1574
- }
1575
- }
1576
- }
1577
- return publishedResourcesInMakeswiftSnapshotFormat;
1578
- }
1579
- const snapshot = await client.unstable_createSnapshot({
1580
- publishedResources: await formMakeswiftResources(body.publishedResources),
1581
- deletedResources: body.deletedResources,
1582
- publishedElementTree: body.publishedElementTree,
1583
- currentSnapshot: body.currentSnapshot
1584
- });
1585
- const usedResources = client.unstable_getSnapshotResourceMapping(snapshot);
1586
- const response = {
1587
- pageId: body.pageId,
1588
- snapshot,
1589
- livePageChanges: body.livePageChanges,
1590
- usedResources
1591
- };
1592
- return res.json(response);
1593
- }
1594
- default:
1595
- return res.status(404).json({ message: "Not Found" });
1596
- }
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" });
1597
852
  };
1598
853
  }
1599
854
  const FORWARDED_NEXT_DYNAMIC_REF_KEY = "__forwarded_next_dynamic_ref__";
@@ -1668,14 +923,14 @@ async function getStaticPaths() {
1668
923
  }
1669
924
  const REVALIDATE_SECONDS = 1;
1670
925
  async function getStaticProps(ctx) {
1671
- var _a, _b, _c2;
926
+ var _a, _b, _c;
1672
927
  deprecationWarning("getStaticProps");
1673
928
  const makeswift = new Makeswift(getApiKey(), {
1674
929
  apiOrigin: getApiOrigin()
1675
930
  });
1676
931
  const path = "/" + ((_b = (_a = ctx.params) == null ? void 0 : _a.path) != null ? _b : []).join("/");
1677
932
  const snapshot = await makeswift.getPageSnapshot(path, {
1678
- preview: ((_c2 = ctx.previewData) == null ? void 0 : _c2.makeswift) === true
933
+ preview: ((_c = ctx.previewData) == null ? void 0 : _c.makeswift) === true
1679
934
  });
1680
935
  if (snapshot == null)
1681
936
  return {
@@ -1712,7 +967,7 @@ async function getServerSideProps(ctx) {
1712
967
  const Page = React.memo(({
1713
968
  snapshot
1714
969
  }) => {
1715
- const client = React.useMemo(() => new MakeswiftClient({
970
+ const client = React.useMemo(() => new responsiveStyle.MakeswiftClient({
1716
971
  uri: new URL("graphql", snapshot.apiOrigin).href,
1717
972
  cacheData: snapshot.cacheData
1718
973
  }), [snapshot]);
@@ -1725,69 +980,6 @@ const Page = React.memo(({
1725
980
  }, snapshot.document.data.key)
1726
981
  });
1727
982
  });
1728
- const keys = (o) => Object.keys(o);
1729
- const coalesce = (...args) => {
1730
- let i;
1731
- for (i = 0; i < args.length - 1; i += 1) {
1732
- if (args[i] != null)
1733
- return args[i];
1734
- }
1735
- return args[i];
1736
- };
1737
- function shallowMerge(a, b) {
1738
- const bKeys = keys(b);
1739
- const merged = __spreadValues({}, a);
1740
- bKeys.forEach((key) => {
1741
- merged[key] = coalesce(merged[key], b[key]);
1742
- });
1743
- return merged;
1744
- }
1745
- const DEVICES = [
1746
- { id: "desktop", minWidth: 769 },
1747
- { id: "tablet", minWidth: 576, maxWidth: 768 },
1748
- { id: "mobile", maxWidth: 575 }
1749
- ];
1750
- const getDevice = (deviceId) => {
1751
- const device = DEVICES.find(({ id }) => id === deviceId);
1752
- if (device == null)
1753
- throw new Error(`Unrecognized device ID: "${deviceId}".`);
1754
- return device;
1755
- };
1756
- function defaultStrategy(value, fallbacks) {
1757
- return value || fallbacks[0];
1758
- }
1759
- function shallowMergeFallbacks(value, fallbacks) {
1760
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
1761
- deviceId: a.deviceId || b.deviceId,
1762
- value: shallowMerge(a.value, b.value)
1763
- }));
1764
- }
1765
- function findDeviceOverride(values = [], deviceId, strategy = defaultStrategy) {
1766
- const value = values.find(({ deviceId: d }) => d === deviceId);
1767
- 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));
1768
- return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
1769
- }
1770
- function join(responsiveValues, joinFn, strategy) {
1771
- return DEVICES.map(({ id }) => id).map((deviceId) => {
1772
- const value = joinFn(responsiveValues.map((responsiveValue) => {
1773
- const deviceValue = responsiveValue && findDeviceOverride(responsiveValue, deviceId, strategy);
1774
- return deviceValue == null ? void 0 : deviceValue.value;
1775
- }));
1776
- if (value == null)
1777
- return null;
1778
- return { deviceId, value };
1779
- }).filter((override) => Boolean(override));
1780
- }
1781
- const getDeviceMediaQuery = (device) => {
1782
- const parts = ["@media only screen"];
1783
- if (device.minWidth != null) {
1784
- parts.push(`(min-width: ${device.minWidth}px)`);
1785
- }
1786
- if (device.maxWidth != null) {
1787
- parts.push(`(max-width: ${device.maxWidth}px)`);
1788
- }
1789
- return parts.join(" and ");
1790
- };
1791
983
  const DEFAULT_BOX_ANIMATE_TYPE = "none";
1792
984
  const DEFAULT_BOX_ANIMATE_DELAY = 0;
1793
985
  const DEFAULT_BOX_ANIMATE_DURATION = 0.75;
@@ -1799,7 +991,7 @@ function registerComponent$c(runtime) {
1799
991
  function isHiddenBasedOnAnimationType(props, deviceId, property) {
1800
992
  var _a, _b;
1801
993
  const animateIn = props[property];
1802
- 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";
1803
995
  }
1804
996
  const isHiddenBasedOnBoxAnimation = (props, deviceId) => isHiddenBasedOnAnimationType(props, deviceId, "boxAnimateType");
1805
997
  const isHiddenBasedOnItemAnimation = (props, deviceId) => isHiddenBasedOnAnimationType(props, deviceId, "itemAnimateType");
@@ -1994,7 +1186,7 @@ function registerComponent$b(runtime) {
1994
1186
  color: descriptors.ResponsiveColor((props, device) => {
1995
1187
  var _a;
1996
1188
  const variant = props.variant;
1997
- 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";
1998
1190
  return { placeholder: "black", hidden };
1999
1191
  }),
2000
1192
  textColor: descriptors.ResponsiveColor({
@@ -2043,7 +1235,7 @@ function registerComponent$a(runtime) {
2043
1235
  step: descriptors.ResponsiveNumber((props, device) => {
2044
1236
  var _a, _b;
2045
1237
  const pageSize = props.pageSize;
2046
- 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;
2047
1239
  return {
2048
1240
  label: "Step",
2049
1241
  defaultValue: 1,
@@ -2327,7 +1519,7 @@ function registerComponent$6(runtime) {
2327
1519
  labelTextColor: descriptors.ResponsiveColor((props, device) => {
2328
1520
  const hidden = props.tableId == null;
2329
1521
  const responsiveContrast = props.contrast;
2330
- const contrast = findDeviceOverride(responsiveContrast, device);
1522
+ const contrast = responsiveStyle.findDeviceOverride(responsiveContrast, device);
2331
1523
  return {
2332
1524
  hidden,
2333
1525
  label: "Label text color",
@@ -2472,7 +1664,7 @@ function registerComponent$4(runtime) {
2472
1664
  }),
2473
1665
  mobileMenuOpenIconColor: descriptors.ResponsiveColor((props, device) => {
2474
1666
  const mobileMenuAnimation = props.mobileMenuAnimation;
2475
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1667
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2476
1668
  return {
2477
1669
  label: "Open icon color",
2478
1670
  placeholder: "rgba(161, 168, 194, 0.5)",
@@ -2481,7 +1673,7 @@ function registerComponent$4(runtime) {
2481
1673
  }),
2482
1674
  mobileMenuCloseIconColor: descriptors.ResponsiveColor((props, device) => {
2483
1675
  const mobileMenuAnimation = props.mobileMenuAnimation;
2484
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1676
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2485
1677
  return {
2486
1678
  label: "Close icon color",
2487
1679
  placeholder: "rgba(161, 168, 194, 0.5)",
@@ -2490,7 +1682,7 @@ function registerComponent$4(runtime) {
2490
1682
  }),
2491
1683
  mobileMenuBackgroundColor: descriptors.ResponsiveColor((props, device) => {
2492
1684
  const mobileMenuAnimation = props.mobileMenuAnimation;
2493
- const hidden = !findDeviceOverride(mobileMenuAnimation, device);
1685
+ const hidden = !responsiveStyle.findDeviceOverride(mobileMenuAnimation, device);
2494
1686
  return {
2495
1687
  label: "Menu BG color",
2496
1688
  placeholder: "black",
@@ -2768,19 +1960,6 @@ function registerBuiltinComponents(runtime) {
2768
1960
  unregisterVideoComponent();
2769
1961
  };
2770
1962
  }
2771
- const isServer = typeof window === "undefined";
2772
- const useInsertionEffectSpecifier = "useInsertionEffect";
2773
- const useInsertionEffect = (_c = React__namespace[useInsertionEffectSpecifier]) != null ? _c : React__namespace.useLayoutEffect;
2774
- function useStyle(style) {
2775
- const serialized = serialize.serializeStyles([style], css.cache.registered);
2776
- utils.registerStyles(css.cache, serialized, false);
2777
- useInsertionEffect(() => {
2778
- utils.insertStyles(css.cache, serialized, false);
2779
- });
2780
- if (isServer)
2781
- utils.insertStyles(css.cache, serialized, false);
2782
- return `${css.cache.key}-${serialized.name}`;
2783
- }
2784
1963
  var _path;
2785
1964
  function _extends() {
2786
1965
  _extends = Object.assign || function(target) {
@@ -2813,7 +1992,7 @@ const FallbackComponent = React.forwardRef(function FallbackComponent2({
2813
1992
  }, ref) {
2814
1993
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
2815
1994
  ref,
2816
- className: useStyle({
1995
+ className: responsiveStyle.useStyle({
2817
1996
  width: "100%",
2818
1997
  height: 54,
2819
1998
  backgroundColor: "#fcedf2",
@@ -2832,110 +2011,18 @@ const FallbackComponent = React.forwardRef(function FallbackComponent2({
2832
2011
  })]
2833
2012
  });
2834
2013
  });
2835
- function useSwatch(swatchId) {
2836
- const client = useMakeswiftClient();
2837
- const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
2838
- const swatch = shim.useSyncExternalStore(client.subscribe, readSwatch, readSwatch);
2839
- React.useEffect(() => {
2840
- if (swatchId != null)
2841
- client.fetchSwatch(swatchId).catch(console.error);
2842
- }, [client, swatchId]);
2843
- return swatch;
2844
- }
2845
- function useSwatches(swatchIds) {
2846
- const client = useMakeswiftClient();
2847
- const lastSnapshot = React.useRef();
2848
- function getSnapshot() {
2849
- const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
2850
- if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
2851
- return lastSnapshot.current;
2852
- }
2853
- return lastSnapshot.current = swatches2;
2854
- }
2855
- const swatches = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
2856
- React.useEffect(() => {
2857
- Promise.all(swatchIds.map((swatchId) => client.fetchSwatch(swatchId))).catch(console.error);
2858
- }, [client, swatchIds]);
2859
- return swatches;
2860
- }
2861
- function useFile(fileId) {
2862
- const client = useMakeswiftClient();
2863
- const readFile = () => fileId == null ? null : client.readFile(fileId);
2864
- const file = shim.useSyncExternalStore(client.subscribe, readFile, readFile);
2865
- React.useEffect(() => {
2866
- if (fileId != null)
2867
- client.fetchFile(fileId);
2868
- }, [client, fileId]);
2869
- return file;
2870
- }
2871
- function useFiles(fileIds) {
2872
- const client = useMakeswiftClient();
2873
- const lastSnapshot = React.useRef();
2874
- function getSnapshot() {
2875
- const files2 = fileIds.map((fileId) => client.readFile(fileId));
2876
- if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
2877
- return lastSnapshot.current;
2878
- }
2879
- return lastSnapshot.current = files2;
2880
- }
2881
- const files = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
2882
- React.useEffect(() => {
2883
- Promise.all(fileIds.map((fileId) => client.fetchFile(fileId))).catch(console.error);
2884
- }, [client, fileIds]);
2885
- return files;
2886
- }
2887
- function useTypography(typographyId) {
2888
- const client = useMakeswiftClient();
2889
- const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
2890
- const typography = shim.useSyncExternalStore(client.subscribe, readTypography, readTypography);
2891
- React.useEffect(() => {
2892
- if (typographyId != null)
2893
- client.fetchTypography(typographyId).catch(console.error);
2894
- }, [client, typographyId]);
2895
- return typography;
2896
- }
2897
- function useGlobalElement(globalElementId) {
2898
- const client = useMakeswiftClient();
2899
- const readGlobalElement = () => globalElementId == null ? null : client.readGlobalElement(globalElementId);
2900
- const globalElement = shim.useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement);
2901
- React.useEffect(() => {
2902
- if (globalElementId != null)
2903
- client.fetchGlobalElement(globalElementId).catch(console.error);
2904
- }, [client, globalElementId]);
2905
- return globalElement;
2906
- }
2907
- function usePagePathnameSlice(pageId) {
2908
- const client = useMakeswiftClient();
2909
- const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice(pageId);
2910
- const pagePathnameSlice = shim.useSyncExternalStore(client.subscribe, readPagePathnameSlice, readPagePathnameSlice);
2911
- React.useEffect(() => {
2912
- if (pageId != null)
2913
- client.fetchPagePathnameSlice(pageId).catch(console.error);
2914
- }, [client, pageId]);
2915
- return pagePathnameSlice;
2916
- }
2917
- function useTable(tableId) {
2918
- const client = useMakeswiftClient();
2919
- const readTable = () => tableId == null ? null : client.readTable(tableId);
2920
- const table = shim.useSyncExternalStore(client.subscribe, readTable, readTable);
2921
- React.useEffect(() => {
2922
- if (tableId != null)
2923
- client.fetchTable(tableId).catch(console.error);
2924
- }, [client, tableId]);
2925
- return table;
2926
- }
2927
- function mapSideColor(swatches, _d) {
2928
- var _e = _d, { color } = _e, restOfSide = __objRest(_e, ["color"]);
2014
+ function mapSideColor(swatches, _c) {
2015
+ var _d = _c, { color } = _d, restOfSide = __objRest(_d, ["color"]);
2929
2016
  return __spreadProps(__spreadValues({}, restOfSide), {
2930
2017
  color: color && {
2931
2018
  alpha: color.alpha,
2932
- 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)
2933
2020
  }
2934
2021
  });
2935
2022
  }
2936
2023
  function useBorder(value) {
2937
2024
  const swatchIds = introspection.getBorderSwatchIds(value);
2938
- const swatches = useSwatches(swatchIds);
2025
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2939
2026
  if (value == null)
2940
2027
  return null;
2941
2028
  return value.map((_a) => {
@@ -2960,7 +2047,7 @@ const ShadowDefaultValue = {
2960
2047
  };
2961
2048
  function useBoxShadow(value) {
2962
2049
  const swatchIds = introspection.getBoxShadowsSwatchIds(value);
2963
- const swatches = useSwatches(swatchIds);
2050
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2964
2051
  if (value == null)
2965
2052
  return null;
2966
2053
  return value.map((_a) => {
@@ -2975,7 +2062,7 @@ function useBoxShadow(value) {
2975
2062
  return __spreadProps(__spreadValues({}, restOfShadow), {
2976
2063
  payload: {
2977
2064
  color: color != null ? {
2978
- 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),
2979
2066
  alpha: color.alpha
2980
2067
  } : null,
2981
2068
  inset: inset != null ? inset : ShadowDefaultValue.inset,
@@ -2991,7 +2078,7 @@ function useBoxShadow(value) {
2991
2078
  }
2992
2079
  function useResponsiveColor(color) {
2993
2080
  const swatchIds = introspection.getResponsiveColorSwatchIds(color);
2994
- const swatches = useSwatches(swatchIds);
2081
+ const swatches = responsiveStyle.useSwatches(swatchIds);
2995
2082
  if (color == null)
2996
2083
  return null;
2997
2084
  return color.map((_a) => {
@@ -2999,11 +2086,11 @@ function useResponsiveColor(color) {
2999
2086
  const { swatchId, alpha } = v;
3000
2087
  const swatch = swatches.find((s) => s && s.id === swatchId);
3001
2088
  return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
3002
- }).filter(introspection.isNonNullable);
2089
+ }).filter(isNonNullable.isNonNullable);
3003
2090
  }
3004
- const DEVICE_QUERIES = DEVICES.map((device) => ({
2091
+ const DEVICE_QUERIES = responsiveStyle.DEVICES.map((device) => ({
3005
2092
  id: device.id,
3006
- query: getDeviceMediaQuery(device).replace("@media", "")
2093
+ query: responsiveStyle.getDeviceMediaQuery(device).replace("@media", "")
3007
2094
  }));
3008
2095
  function subscribe(notify) {
3009
2096
  const cleanUpFns = DEVICE_QUERIES.map((q) => {
@@ -3016,7 +2103,7 @@ function subscribe(notify) {
3016
2103
  function useMediaQuery(responsiveValue) {
3017
2104
  const getServerSnapshot = () => {
3018
2105
  var _a;
3019
- 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;
3020
2107
  };
3021
2108
  function getSnapshot() {
3022
2109
  var _a;
@@ -3026,216 +2113,10 @@ function useMediaQuery(responsiveValue) {
3026
2113
  }
3027
2114
  return matchedDevice;
3028
2115
  }, DEVICE_QUERIES[0].id);
3029
- return (_a = findDeviceOverride(responsiveValue, deviceId)) == null ? void 0 : _a.value;
2116
+ return (_a = responsiveStyle.findDeviceOverride(responsiveValue, deviceId)) == null ? void 0 : _a.value;
3030
2117
  }
3031
2118
  return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
3032
2119
  }
3033
- const getIndexes = (spans, index) => {
3034
- const flattened = spans.reduce((a, s) => a.concat(s), []);
3035
- if (index < 0 || index > flattened.length)
3036
- throw new RangeError();
3037
- let remainder = index;
3038
- let rowIndex = 0;
3039
- while (rowIndex < spans.length - 1 && remainder >= spans[rowIndex].length) {
3040
- remainder -= spans[rowIndex].length;
3041
- rowIndex += 1;
3042
- }
3043
- return [rowIndex, remainder];
3044
- };
3045
- function lengthDataToString(data) {
3046
- if (typeof data === "object")
3047
- return `${data.value}${data.unit}`;
3048
- if (typeof data === "number")
3049
- return `${data}px`;
3050
- return data;
3051
- }
3052
- function paddingPropertyDataToStyle(data, defaultValue = {}) {
3053
- var _a, _b, _c2, _d;
3054
- const paddingTop = (_a = data.paddingTop) != null ? _a : defaultValue.paddingTop;
3055
- const paddingRight = (_b = data.paddingRight) != null ? _b : defaultValue.paddingRight;
3056
- const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
3057
- const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
3058
- const style = {};
3059
- if (paddingTop != null)
3060
- style.paddingTop = lengthDataToString(paddingTop);
3061
- if (paddingRight != null)
3062
- style.paddingRight = lengthDataToString(paddingRight);
3063
- if (paddingBottom != null)
3064
- style.paddingBottom = lengthDataToString(paddingBottom);
3065
- if (paddingLeft != null)
3066
- style.paddingLeft = lengthDataToString(paddingLeft);
3067
- return style;
3068
- }
3069
- function marginPropertyDataToStyle(data, defaultValue = {}) {
3070
- var _a, _b, _c2, _d;
3071
- const marginTop = (_a = data.marginTop) != null ? _a : defaultValue.marginTop;
3072
- const marginRight = (_b = data.marginRight) != null ? _b : defaultValue.marginRight;
3073
- const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
3074
- const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
3075
- const style = {};
3076
- if (marginTop != null)
3077
- style.marginTop = lengthDataToString(marginTop);
3078
- if (marginRight != null)
3079
- style.marginRight = lengthDataToString(marginRight);
3080
- if (marginBottom != null)
3081
- style.marginBottom = lengthDataToString(marginBottom);
3082
- if (marginLeft != null)
3083
- style.marginLeft = lengthDataToString(marginLeft);
3084
- return style;
3085
- }
3086
- function lengthPercentageDataToString(data) {
3087
- if (typeof data === "object")
3088
- return `${data.value}${data.unit}`;
3089
- if (typeof data === "number")
3090
- return `${data}px`;
3091
- return data;
3092
- }
3093
- function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
3094
- var _a, _b, _c2, _d;
3095
- const borderTopLeftRadius = (_a = data.borderTopLeftRadius) != null ? _a : defaultValue.borderTopLeftRadius;
3096
- const borderTopRightRadius = (_b = data.borderTopRightRadius) != null ? _b : defaultValue.borderTopRightRadius;
3097
- const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
3098
- const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
3099
- const style = {};
3100
- if (borderTopLeftRadius != null) {
3101
- style.borderTopLeftRadius = lengthPercentageDataToString(borderTopLeftRadius);
3102
- }
3103
- if (borderTopRightRadius != null) {
3104
- style.borderTopRightRadius = lengthPercentageDataToString(borderTopRightRadius);
3105
- }
3106
- if (borderBottomRightRadius != null) {
3107
- style.borderBottomRightRadius = lengthPercentageDataToString(borderBottomRightRadius);
3108
- }
3109
- if (borderBottomLeftRadius != null) {
3110
- style.borderBottomLeftRadius = lengthPercentageDataToString(borderBottomLeftRadius);
3111
- }
3112
- return style;
3113
- }
3114
- function colorToString(color) {
3115
- return color && color.swatch ? `hsla(${color.swatch.hue},${color.swatch.saturation}%,${color.swatch.lightness}%,${color.alpha})` : "";
3116
- }
3117
- function borderPropertyDataToStyle(data, defaultValue = {}) {
3118
- var _a, _b, _c2, _d;
3119
- const borderTop = (_a = data.borderTop) != null ? _a : defaultValue.borderTop;
3120
- const borderRight = (_b = data.borderRight) != null ? _b : defaultValue.borderRight;
3121
- const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
3122
- const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
3123
- const style = {};
3124
- if (borderTop != null)
3125
- style.borderTop = borderSideToString(borderTop);
3126
- if (borderRight != null)
3127
- style.borderRight = borderSideToString(borderRight);
3128
- if (borderBottom != null)
3129
- style.borderBottom = borderSideToString(borderBottom);
3130
- if (borderLeft != null)
3131
- style.borderLeft = borderSideToString(borderLeft);
3132
- return style;
3133
- }
3134
- function borderSideToString(borderSide) {
3135
- if (typeof borderSide === "string")
3136
- return borderSide;
3137
- if (typeof borderSide === "number")
3138
- return `${borderSide}px`;
3139
- const { width, color, style } = borderSide;
3140
- return `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : "black"}`;
3141
- }
3142
- function responsiveStyle(responsiveValues, join$1, strategy) {
3143
- return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
3144
- const device = getDevice(deviceId);
3145
- const mediaQuery = getDeviceMediaQuery(device);
3146
- return __spreadProps(__spreadValues({}, acc), {
3147
- [mediaQuery]: __spreadValues(__spreadValues({}, acc[mediaQuery]), value)
3148
- });
3149
- }, {});
3150
- }
3151
- function responsiveWidth(widthData, defaultValue = "100%") {
3152
- return __spreadValues({
3153
- maxWidth: "100%"
3154
- }, responsiveStyle([widthData], ([width = defaultValue]) => ({
3155
- width: typeof width === "object" ? `${width.value}${width.unit}` : width
3156
- })));
3157
- }
3158
- function responsivePadding(paddingData, defaultValue = {}) {
3159
- return responsiveStyle([paddingData], ([padding = {}]) => paddingPropertyDataToStyle(padding, Object.assign({ paddingTop: 0, paddingRight: 0, paddingBottom: 0, paddingLeft: 0 }, defaultValue)));
3160
- }
3161
- function responsiveMargin(marginData, defaultValue = {}) {
3162
- return responsiveStyle([marginData], ([margin = {}]) => marginPropertyDataToStyle(margin, Object.assign({ marginTop: 0, marginRight: "auto", marginBottom: 0, marginLeft: "auto" }, defaultValue)));
3163
- }
3164
- function responsiveBorderRadius(borderRadiusData, defaultValue = {}) {
3165
- return responsiveStyle([borderRadiusData], ([borderRadius = {}]) => borderRadiusPropertyDataToStyle(borderRadius, Object.assign({
3166
- borderTopLeftRadius: 0,
3167
- borderTopRightRadius: 0,
3168
- borderBottomRightRadius: 0,
3169
- borderBottomLeftRadius: 0
3170
- }, defaultValue)));
3171
- }
3172
- function responsiveBorder(borderData, defaultValue = {}) {
3173
- return responsiveStyle([borderData], ([border = {}]) => borderPropertyDataToStyle(border, Object.assign({
3174
- borderTop: "0px solid black",
3175
- borderRight: "0px solid black",
3176
- borderBottom: "0px solid black",
3177
- borderLeft: "0px solid black"
3178
- }, defaultValue)));
3179
- }
3180
- const floor = (d) => (v) => Math.floor(10 ** d * v) / 10 ** d;
3181
- function responsiveGridItem(props) {
3182
- return __spreadValues({
3183
- display: "flex"
3184
- }, responsiveStyle([props.grid, props.columnGap, props.rowGap], ([
3185
- { spans, count } = { spans: [[12]], count: 12 },
3186
- columnGap = { value: 0, unit: "px" },
3187
- rowGap = { value: 0, unit: "px" }
3188
- ]) => {
3189
- const [rowIndex, columnIndex] = getIndexes(spans, props.index);
3190
- const firstCol = columnIndex === 0;
3191
- const lastCol = columnIndex === spans[rowIndex].length - 1;
3192
- const span = spans[rowIndex][columnIndex];
3193
- const fraction = floor(5)(span / count);
3194
- const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`;
3195
- const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${columnGap.unit} / 2`;
3196
- const iePrecisionError = "0.01px";
3197
- const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`;
3198
- const firstRow = rowIndex === 0;
3199
- const lastRow = rowIndex === spans.length - 1;
3200
- return span === 0 ? { display: "none" } : {
3201
- flexBasis,
3202
- minWidth: flexBasis,
3203
- maxWidth: flexBasis,
3204
- paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
3205
- paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,
3206
- paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,
3207
- paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`
3208
- };
3209
- }));
3210
- }
3211
- 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();
3212
- function responsiveShadow(value) {
3213
- return responsiveStyle([value], ([shadow = []]) => ({
3214
- boxShadow: getBoxShadow(shadow)
3215
- }));
3216
- }
3217
- function responsiveTextStyle(value) {
3218
- return responsiveStyle([value], ([
3219
- textStyle = {
3220
- fontFamily: null,
3221
- letterSpacing: null,
3222
- fontSize: null,
3223
- fontWeight: null,
3224
- textTransform: [],
3225
- fontStyle: []
3226
- }
3227
- ]) => {
3228
- const {
3229
- fontSize,
3230
- fontWeight,
3231
- fontStyle = [],
3232
- textTransform = [],
3233
- letterSpacing,
3234
- fontFamily
3235
- } = textStyle;
3236
- 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" } : {});
3237
- });
3238
- }
3239
2120
  const defaultMargin = {
3240
2121
  marginTop: 0,
3241
2122
  marginRight: "auto",
@@ -3252,7 +2133,7 @@ function useStyleControlCssObject(style, controlDefinition) {
3252
2133
  const { properties } = controlDefinition.config;
3253
2134
  return __spreadValues(__spreadValues({}, properties.includes(descriptors.StyleControlProperty.Width) && {
3254
2135
  maxWidth: "100%"
3255
- }), responsiveStyle([
2136
+ }), responsiveStyle.responsiveStyle([
3256
2137
  style == null ? void 0 : style.width,
3257
2138
  style == null ? void 0 : style.margin,
3258
2139
  style == null ? void 0 : style.padding,
@@ -3260,14 +2141,14 @@ function useStyleControlCssObject(style, controlDefinition) {
3260
2141
  style == null ? void 0 : style.borderRadius,
3261
2142
  style == null ? void 0 : style.textStyle
3262
2143
  ], ([width, margin, padding, border, borderRadius, textStyle]) => {
3263
- 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;
3264
2145
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(descriptors.StyleControlProperty.Width) && {
3265
2146
  width: (_a = widthToString(width)) != null ? _a : "100%"
3266
- }), 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) && {
3267
- borderTop: (_b = borderSideToString2(border == null ? void 0 : border.borderTop)) != null ? _b : "0 solid black",
3268
- borderRight: (_c2 = borderSideToString2(border == null ? void 0 : border.borderRight)) != null ? _c2 : "0 solid black",
3269
- borderBottom: (_d = borderSideToString2(border == null ? void 0 : border.borderBottom)) != null ? _d : "0 solid black",
3270
- 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"
3271
2152
  }), properties.includes(descriptors.StyleControlProperty.BorderRadius) && {
3272
2153
  borderTopLeftRadius: (_f = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopLeftRadius)) != null ? _f : 0,
3273
2154
  borderTopRightRadius: (_g = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _g : 0,
@@ -3281,18 +2162,18 @@ function useStyleControlCssObject(style, controlDefinition) {
3281
2162
  function widthToString(widthProperty) {
3282
2163
  if (widthProperty == null)
3283
2164
  return null;
3284
- return lengthPercentageDataToString(widthProperty);
2165
+ return responsiveStyle.lengthPercentageDataToString(widthProperty);
3285
2166
  }
3286
- function borderSideToString2(borderSide) {
2167
+ function borderSideToString(borderSide) {
3287
2168
  if (borderSide == null)
3288
2169
  return null;
3289
2170
  const { width, color, style: style2 } = borderSide;
3290
- 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"}`;
3291
2172
  }
3292
2173
  function borderRadiusToString(borderRadius) {
3293
2174
  if (borderRadius == null)
3294
2175
  return null;
3295
- return lengthPercentageDataToString(borderRadius);
2176
+ return responsiveStyle.lengthPercentageDataToString(borderRadius);
3296
2177
  }
3297
2178
  function fontSizeToString(fontSize) {
3298
2179
  return `${fontSize.value}${fontSize.unit}`;
@@ -3301,7 +2182,7 @@ function useStyleControlCssObject(style, controlDefinition) {
3301
2182
  function useFormattedStyle(styleControlData, controlDefinition, control) {
3302
2183
  const style = useStyleControlCssObject(styleControlData, controlDefinition);
3303
2184
  const guid = React.useId().replaceAll(":", "");
3304
- const styleClassName = useStyle(style);
2185
+ const styleClassName = responsiveStyle.useStyle(style);
3305
2186
  const classNames = `${styleClassName} ${guid}`;
3306
2187
  React.useEffect(() => {
3307
2188
  let currentBoxModel = null;
@@ -3310,7 +2191,7 @@ function useFormattedStyle(styleControlData, controlDefinition, control) {
3310
2191
  return;
3311
2192
  const element = document.querySelector(`.${guid}`);
3312
2193
  const measuredBoxModel = element == null ? null : boxModels.getBox(element);
3313
- if (!deepEqual(currentBoxModel, measuredBoxModel)) {
2194
+ if (!responsiveStyle.deepEqual(currentBoxModel, measuredBoxModel)) {
3314
2195
  currentBoxModel = measuredBoxModel;
3315
2196
  control.changeBoxModel(currentBoxModel);
3316
2197
  }
@@ -3337,7 +2218,7 @@ function useCheckboxControlValue(data, definition) {
3337
2218
  function useColorValue(data, definition) {
3338
2219
  var _a, _b;
3339
2220
  const swatchId = (_a = data == null ? void 0 : data.swatchId) != null ? _a : null;
3340
- const swatch = useSwatch(swatchId);
2221
+ const swatch = responsiveStyle.useSwatch(swatchId);
3341
2222
  const alpha = (_b = data == null ? void 0 : data.alpha) != null ? _b : 1;
3342
2223
  if (swatch == null) {
3343
2224
  const { defaultValue } = definition.config;
@@ -3360,7 +2241,7 @@ function useImageControlValue(data, definition) {
3360
2241
  var _a;
3361
2242
  const format = (_a = definition.config.format) != null ? _a : descriptors.ImageControlValueFormat.URL;
3362
2243
  const fileId = data != null ? data : null;
3363
- const file = useFile(fileId);
2244
+ const file = responsiveStyle.useFile(fileId);
3364
2245
  if (format === descriptors.ImageControlValueFormat.URL) {
3365
2246
  return file == null ? void 0 : file.publicUrl;
3366
2247
  }
@@ -3374,7 +2255,7 @@ function useImageControlValue(data, definition) {
3374
2255
  function useLinkControlValue(link, _definition) {
3375
2256
  var _a;
3376
2257
  const pageId = link && link.type === "OPEN_PAGE" ? link.payload.pageId : null;
3377
- const page = usePagePathnameSlice(pageId != null ? pageId : null);
2258
+ const page = responsiveStyle.usePagePathnameSlice(pageId != null ? pageId : null);
3378
2259
  const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a = link.payload.elementIdConfig) == null ? void 0 : _a.elementKey : null;
3379
2260
  const elementId = useElementId(elementKey);
3380
2261
  let href = "#";
@@ -3500,7 +2381,7 @@ function pollBoxModel({
3500
2381
  let currentBoxModel = null;
3501
2382
  const handleAnimationFrameRequest = () => {
3502
2383
  const measuredBoxModel = boxModels.getBox(element);
3503
- if (!deepEqual(currentBoxModel, measuredBoxModel)) {
2384
+ if (!responsiveStyle.deepEqual(currentBoxModel, measuredBoxModel)) {
3504
2385
  currentBoxModel = measuredBoxModel;
3505
2386
  onBoxModelChange(currentBoxModel);
3506
2387
  }
@@ -3530,13 +2411,13 @@ function useSlot(data, control) {
3530
2411
  }, element.key))
3531
2412
  });
3532
2413
  }
3533
- function Slot(_f) {
3534
- var _g = _f, {
2414
+ function Slot(_e) {
2415
+ var _f = _e, {
3535
2416
  as,
3536
2417
  control,
3537
2418
  children,
3538
2419
  className
3539
- } = _g, restOfProps = __objRest(_g, [
2420
+ } = _f, restOfProps = __objRest(_f, [
3540
2421
  "as",
3541
2422
  "control",
3542
2423
  "children",
@@ -3544,7 +2425,7 @@ function Slot(_f) {
3544
2425
  ]);
3545
2426
  const As = as != null ? as : "div";
3546
2427
  const [element, setElement] = React.useState(null);
3547
- const baseClassName = useStyle({
2428
+ const baseClassName = responsiveStyle.useStyle({
3548
2429
  display: "flex",
3549
2430
  flexWrap: "wrap",
3550
2431
  width: "100%"
@@ -3565,15 +2446,15 @@ function Slot(_f) {
3565
2446
  }
3566
2447
  Slot.Placeholder = SlotPlaceholder;
3567
2448
  Slot.Item = SlotItem;
3568
- function SlotItem(_h) {
3569
- var _i = _h, {
2449
+ function SlotItem(_g) {
2450
+ var _h = _g, {
3570
2451
  as,
3571
2452
  control,
3572
2453
  grid,
3573
2454
  index,
3574
2455
  children,
3575
2456
  className
3576
- } = _i, restOfProps = __objRest(_i, [
2457
+ } = _h, restOfProps = __objRest(_h, [
3577
2458
  "as",
3578
2459
  "control",
3579
2460
  "grid",
@@ -3583,13 +2464,13 @@ function SlotItem(_h) {
3583
2464
  ]);
3584
2465
  const As = as != null ? as : "div";
3585
2466
  const [element, setElement] = React.useState(null);
3586
- const baseClassName = useStyle(__spreadValues({
2467
+ const baseClassName = responsiveStyle.useStyle(__spreadValues({
3587
2468
  display: "flex"
3588
- }, responsiveStyle([grid], ([{
2469
+ }, responsiveStyle.responsiveStyle([grid], ([{
3589
2470
  count = 12,
3590
2471
  spans = [[12]]
3591
2472
  } = {}]) => {
3592
- const [rowIndex, columnIndex] = getIndexes(spans, index);
2473
+ const [rowIndex, columnIndex] = responsiveStyle.getIndexes(spans, index);
3593
2474
  const span = spans[rowIndex][columnIndex];
3594
2475
  const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`;
3595
2476
  return span === 0 ? {
@@ -3627,7 +2508,7 @@ function SlotPlaceholder({
3627
2508
  }, [element, control]);
3628
2509
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
3629
2510
  ref: setElement,
3630
- className: useStyle({
2511
+ className: responsiveStyle.useStyle({
3631
2512
  width: "100%",
3632
2513
  background: "rgba(161, 168, 194, 0.18)",
3633
2514
  height: "80px"
@@ -3636,7 +2517,7 @@ function SlotPlaceholder({
3636
2517
  xmlns: "http://www.w3.org/2000/svg",
3637
2518
  width: "100%",
3638
2519
  height: "100%",
3639
- className: useStyle({
2520
+ className: responsiveStyle.useStyle({
3640
2521
  overflow: "visible",
3641
2522
  padding: 8
3642
2523
  }),
@@ -3759,24 +2640,24 @@ function ControlValue({
3759
2640
  }
3760
2641
  }
3761
2642
  function useWidthStyle(value, descriptor) {
3762
- return useStyle(responsiveWidth(value, descriptor.options.defaultValue));
2643
+ return responsiveStyle.useStyle(responsiveStyle.responsiveWidth(value, descriptor.options.defaultValue));
3763
2644
  }
3764
2645
  function usePaddingStyle(value) {
3765
- return useStyle(responsivePadding(value));
2646
+ return responsiveStyle.useStyle(responsiveStyle.responsivePadding(value));
3766
2647
  }
3767
2648
  function useMarginStyle(value) {
3768
- return useStyle(responsiveMargin(value));
2649
+ return responsiveStyle.useStyle(responsiveStyle.responsiveMargin(value));
3769
2650
  }
3770
2651
  function useBorderRadiusStyle(value) {
3771
- return useStyle(responsiveBorderRadius(value));
2652
+ return responsiveStyle.useStyle(responsiveStyle.responsiveBorderRadius(value));
3772
2653
  }
3773
2654
  function useShadowsStyle(value) {
3774
2655
  const shadowValue = useBoxShadow(value);
3775
- return useStyle(responsiveShadow(shadowValue != null ? shadowValue : void 0));
2656
+ return responsiveStyle.useStyle(responsiveStyle.responsiveShadow(shadowValue != null ? shadowValue : void 0));
3776
2657
  }
3777
2658
  function useBorderStyle(value) {
3778
2659
  const borderData = useBorder(value);
3779
- return useStyle(responsiveBorder(borderData != null ? borderData : void 0));
2660
+ return responsiveStyle.useStyle(responsiveStyle.responsiveBorder(borderData != null ? borderData : void 0));
3780
2661
  }
3781
2662
  function PropsValue({
3782
2663
  element,
@@ -3793,7 +2674,7 @@ function PropsValue({
3793
2674
  return constants.getPropControllers(state, documentKey, element.key);
3794
2675
  });
3795
2676
  return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
3796
- var _a2, _b, _c2;
2677
+ var _a2, _b, _c;
3797
2678
  switch (descriptor.type) {
3798
2679
  case textInput.CheckboxControlType:
3799
2680
  case textInput.NumberControlType:
@@ -3835,7 +2716,7 @@ function PropsValue({
3835
2716
  }, descriptor.type);
3836
2717
  }
3837
2718
  case descriptors.SlotControlType: {
3838
- 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;
3839
2720
  return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
3840
2721
  hook: useSlot,
3841
2722
  parameters: [props[propName], control],
@@ -4038,8 +2919,8 @@ function createReactRuntime(store) {
4038
2919
  unregisterReactComponent();
4039
2920
  };
4040
2921
  },
4041
- copyElementTree(elementTree, replacementContext) {
4042
- return constants.copyElementTree(store.getState(), elementTree, replacementContext);
2922
+ copyElementTree(elementTree2, replacementContext) {
2923
+ return constants.copyElementTree(store.getState(), elementTree2, replacementContext);
4043
2924
  }
4044
2925
  };
4045
2926
  }
@@ -4052,10 +2933,10 @@ const PreviewProvider = dynamic__default["default"](() => Promise.resolve().then
4052
2933
  const LiveProvider = dynamic__default["default"](() => Promise.resolve().then(function() {
4053
2934
  return require("./LiveProvider.cjs.js");
4054
2935
  }));
4055
- function RuntimeProvider(_j) {
4056
- var _k = _j, {
2936
+ function RuntimeProvider(_i) {
2937
+ var _j = _i, {
4057
2938
  preview
4058
- } = _k, props = __objRest(_k, [
2939
+ } = _j, props = __objRest(_j, [
4059
2940
  "preview"
4060
2941
  ]);
4061
2942
  return preview ? /* @__PURE__ */ jsxRuntime.jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsxRuntime.jsx(LiveProvider, __spreadValues({}, props));
@@ -4152,7 +3033,7 @@ const DisableRegisterElement = React.createContext(false);
4152
3033
  const ElementReference = React.memo(React.forwardRef(function ElementReference2({
4153
3034
  elementReference
4154
3035
  }, ref) {
4155
- const globalElement = useGlobalElement(elementReference.value);
3036
+ const globalElement = responsiveStyle.useGlobalElement(elementReference.value);
4156
3037
  const globalElementData = globalElement == null ? void 0 : globalElement.data;
4157
3038
  const elementReferenceDocument = useDocument(elementReference.key);
4158
3039
  const documentKey = elementReference.key;
@@ -4262,15 +3143,12 @@ exports.DEFAULT_ITEM_ANIMATE_DELAY = DEFAULT_ITEM_ANIMATE_DELAY;
4262
3143
  exports.DEFAULT_ITEM_ANIMATE_DURATION = DEFAULT_ITEM_ANIMATE_DURATION;
4263
3144
  exports.DEFAULT_ITEM_ANIMATE_TYPE = DEFAULT_ITEM_ANIMATE_TYPE;
4264
3145
  exports.DEFAULT_ITEM_STAGGER_DURATION = DEFAULT_ITEM_STAGGER_DURATION;
4265
- exports.DEVICES = DEVICES;
4266
3146
  exports.Document = Document$1;
4267
3147
  exports.DocumentReference = DocumentReference;
4268
3148
  exports.Element = Element$1;
4269
3149
  exports.ElementImperativeHandle = ElementImperativeHandle;
4270
3150
  exports.Makeswift = Makeswift;
4271
3151
  exports.MakeswiftApiHandler = MakeswiftApiHandler;
4272
- exports.MakeswiftClient = MakeswiftClient;
4273
- exports.MakeswiftProvider = MakeswiftProvider;
4274
3152
  exports.Page = Page$1;
4275
3153
  exports.Page$1 = Page;
4276
3154
  exports.PageProvider = PageProvider;
@@ -4281,36 +3159,20 @@ exports.RuntimeProvider = RuntimeProvider;
4281
3159
  exports.Shapes = Shapes;
4282
3160
  exports.Sizes = Sizes;
4283
3161
  exports.StoreContext = StoreContext;
4284
- exports.colorToString = colorToString;
4285
- exports.deepEqual = deepEqual;
4286
- exports.findDeviceOverride = findDeviceOverride;
4287
3162
  exports.forwardNextDynamicRef = forwardNextDynamicRef;
4288
3163
  exports.getServerSideProps = getServerSideProps;
4289
3164
  exports.getStaticPaths = getStaticPaths;
4290
3165
  exports.getStaticProps = getStaticProps;
4291
3166
  exports.pollBoxModel = pollBoxModel;
4292
- exports.responsiveGridItem = responsiveGridItem;
4293
- exports.responsiveStyle = responsiveStyle;
4294
- exports.responsiveTextStyle = responsiveTextStyle;
4295
- exports.responsiveWidth = responsiveWidth;
4296
- exports.shallowMergeFallbacks = shallowMergeFallbacks;
4297
3167
  exports.storeContextDefaultValue = storeContextDefaultValue;
4298
3168
  exports.useBorder = useBorder;
4299
3169
  exports.useBoxShadow = useBoxShadow;
4300
3170
  exports.useBuilderEditMode = useBuilderEditMode;
4301
3171
  exports.useElementId = useElementId;
4302
- exports.useFile = useFile;
4303
- exports.useFiles = useFiles;
4304
3172
  exports.useFormContext = useFormContext;
4305
3173
  exports.useIsInBuilder = useIsInBuilder;
4306
3174
  exports.useIsPreview = useIsPreview;
4307
- exports.useMakeswiftClient = useMakeswiftClient;
4308
3175
  exports.useMediaQuery = useMediaQuery;
4309
3176
  exports.usePageId = usePageId;
4310
- exports.usePagePathnameSlice = usePagePathnameSlice;
4311
3177
  exports.useResponsiveColor = useResponsiveColor;
4312
- exports.useStyle = useStyle;
4313
- exports.useSwatches = useSwatches;
4314
- exports.useTable = useTable;
4315
- exports.useTypography = useTypography;
4316
3178
  //# sourceMappingURL=index.cjs.js.map