@makeswift/runtime 0.9.3 → 0.9.5

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 +4 -4
  2. package/dist/Box.es.js +5 -5
  3. package/dist/Button.cjs.js +4 -4
  4. package/dist/Button.es.js +5 -5
  5. package/dist/Carousel.cjs.js +4 -4
  6. package/dist/Carousel.es.js +5 -5
  7. package/dist/Countdown.cjs.js +2 -2
  8. package/dist/Countdown.es.js +3 -3
  9. package/dist/Divider.cjs.js +4 -4
  10. package/dist/Divider.es.js +5 -5
  11. package/dist/Embed.cjs.js +1 -0
  12. package/dist/Embed.cjs.js.map +1 -1
  13. package/dist/Embed.es.js +2 -1
  14. package/dist/Embed.es.js.map +1 -1
  15. package/dist/Form.cjs.js +2 -2
  16. package/dist/Form.es.js +3 -3
  17. package/dist/Image.cjs.js +2 -2
  18. package/dist/Image.es.js +3 -3
  19. package/dist/LiveProvider.cjs.js +5 -5
  20. package/dist/LiveProvider.es.js +5 -5
  21. package/dist/Navigation.cjs.js +3 -3
  22. package/dist/Navigation.es.js +4 -4
  23. package/dist/PreviewProvider.cjs.js +9 -8
  24. package/dist/PreviewProvider.cjs.js.map +1 -1
  25. package/dist/PreviewProvider.es.js +11 -10
  26. package/dist/PreviewProvider.es.js.map +1 -1
  27. package/dist/ReadOnlyText.cjs.js +4 -5
  28. package/dist/ReadOnlyText.cjs.js.map +1 -1
  29. package/dist/ReadOnlyText.es.js +4 -5
  30. package/dist/ReadOnlyText.es.js.map +1 -1
  31. package/dist/ReadOnlyTextV2.cjs.js +17 -19
  32. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  33. package/dist/ReadOnlyTextV2.es.js +16 -18
  34. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  35. package/dist/Root.cjs.js +2 -2
  36. package/dist/Root.es.js +3 -3
  37. package/dist/SocialLinks.cjs.js +4 -4
  38. package/dist/SocialLinks.es.js +5 -5
  39. package/dist/Text.cjs.js +2 -2
  40. package/dist/Text.es.js +2 -2
  41. package/dist/Video.cjs.js +1 -0
  42. package/dist/Video.cjs.js.map +1 -1
  43. package/dist/Video.es.js +2 -1
  44. package/dist/Video.es.js.map +1 -1
  45. package/dist/actions.cjs.js +467 -3
  46. package/dist/actions.cjs.js.map +1 -1
  47. package/dist/actions.es.js +467 -4
  48. package/dist/actions.es.js.map +1 -1
  49. package/dist/box-model.cjs.js +1 -0
  50. package/dist/box-model.cjs.js.map +1 -1
  51. package/dist/box-model.es.js +1 -0
  52. package/dist/box-model.es.js.map +1 -1
  53. package/dist/builder.cjs.js +1 -0
  54. package/dist/builder.cjs.js.map +1 -1
  55. package/dist/builder.es.js +1 -0
  56. package/dist/builder.es.js.map +1 -1
  57. package/dist/components.cjs.js +2 -2
  58. package/dist/components.es.js +2 -2
  59. package/dist/control-serialization.cjs.js +1 -0
  60. package/dist/control-serialization.cjs.js.map +1 -1
  61. package/dist/control-serialization.es.js +2 -1
  62. package/dist/control-serialization.es.js.map +1 -1
  63. package/dist/controls.cjs.js +19 -14
  64. package/dist/controls.cjs.js.map +1 -1
  65. package/dist/controls.es.js +3 -2
  66. package/dist/controls.es.js.map +1 -1
  67. package/dist/index.cjs.js +182 -60
  68. package/dist/index.cjs.js.map +1 -1
  69. package/dist/index.cjs10.js +25 -13
  70. package/dist/index.cjs10.js.map +1 -1
  71. package/dist/index.cjs2.js +1 -0
  72. package/dist/index.cjs2.js.map +1 -1
  73. package/dist/index.cjs5.js +96 -5
  74. package/dist/index.cjs5.js.map +1 -1
  75. package/dist/index.cjs8.js +2 -2
  76. package/dist/index.cjs9.js +5 -5
  77. package/dist/index.es.js +170 -49
  78. package/dist/index.es.js.map +1 -1
  79. package/dist/index.es10.js +26 -14
  80. package/dist/index.es10.js.map +1 -1
  81. package/dist/index.es2.js +2 -1
  82. package/dist/index.es2.js.map +1 -1
  83. package/dist/index.es4.js +1 -1
  84. package/dist/index.es5.js +88 -2
  85. package/dist/index.es5.js.map +1 -1
  86. package/dist/index.es6.js +1 -1
  87. package/dist/index.es8.js +2 -2
  88. package/dist/index.es9.js +6 -6
  89. package/dist/main.cjs.js +1 -0
  90. package/dist/main.cjs.js.map +1 -1
  91. package/dist/main.es.js +1 -0
  92. package/dist/main.es.js.map +1 -1
  93. package/dist/next.cjs.js +2 -2
  94. package/dist/next.es.js +3 -3
  95. package/dist/prop-controllers.cjs.js +1 -0
  96. package/dist/prop-controllers.cjs.js.map +1 -1
  97. package/dist/prop-controllers.es.js +1 -0
  98. package/dist/prop-controllers.es.js.map +1 -1
  99. package/dist/react-page.cjs.js +114 -31
  100. package/dist/react-page.cjs.js.map +1 -1
  101. package/dist/react-page.es.js +111 -12
  102. package/dist/react-page.es.js.map +1 -1
  103. package/dist/react.cjs.js +2 -2
  104. package/dist/react.es.js +2 -2
  105. package/dist/slate.cjs.js +22 -75
  106. package/dist/slate.cjs.js.map +1 -1
  107. package/dist/slate.es.js +25 -79
  108. package/dist/slate.es.js.map +1 -1
  109. package/dist/state/breakpoints.cjs.js +1 -0
  110. package/dist/state/breakpoints.cjs.js.map +1 -1
  111. package/dist/state/breakpoints.es.js +1 -0
  112. package/dist/state/breakpoints.es.js.map +1 -1
  113. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  114. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  115. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  116. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +0 -17
  117. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  118. package/dist/types/src/components/page/Page.d.ts.map +1 -1
  119. package/dist/types/src/controls/control.d.ts +3 -2
  120. package/dist/types/src/controls/control.d.ts.map +1 -1
  121. package/dist/types/src/controls/index.d.ts +1 -0
  122. package/dist/types/src/controls/index.d.ts.map +1 -1
  123. package/dist/types/src/controls/list.d.ts +2 -0
  124. package/dist/types/src/controls/list.d.ts.map +1 -1
  125. package/dist/types/src/controls/shape.d.ts +2 -0
  126. package/dist/types/src/controls/shape.d.ts.map +1 -1
  127. package/dist/types/src/controls/typography.d.ts +31 -0
  128. package/dist/types/src/controls/typography.d.ts.map +1 -0
  129. package/dist/types/src/next/client.d.ts +9 -1
  130. package/dist/types/src/next/client.d.ts.map +1 -1
  131. package/dist/types/src/next/index.d.ts.map +1 -1
  132. package/dist/types/src/prop-controllers/descriptors.d.ts +6 -3
  133. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  134. package/dist/types/src/prop-controllers/introspection.d.ts +1 -1
  135. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  136. package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
  137. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  138. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  139. package/dist/types/src/runtimes/react/controls/typography.d.ts +21 -0
  140. package/dist/types/src/runtimes/react/controls/typography.d.ts.map +1 -0
  141. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  142. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  143. package/dist/types/src/slate/TypographyPlugin/index.d.ts +9 -0
  144. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  145. package/dist/types/src/state/actions.d.ts +7 -7
  146. package/dist/types/src/state/actions.d.ts.map +1 -1
  147. package/dist/types/src/state/modules/locales.d.ts +6 -7
  148. package/dist/types/src/state/modules/locales.d.ts.map +1 -1
  149. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  150. package/dist/types/src/state/react-page.d.ts +3 -1
  151. package/dist/types/src/state/react-page.d.ts.map +1 -1
  152. package/dist/types/types/locale.d.ts +9 -0
  153. package/dist/types/types/locale.d.ts.map +1 -0
  154. package/dist/types.cjs2.js +13 -16
  155. package/dist/types.cjs2.js.map +1 -1
  156. package/dist/types.es2.js +10 -13
  157. package/dist/types.es2.js.map +1 -1
  158. package/dist/{text-input.cjs.js → typography.cjs.js} +9 -1
  159. package/dist/typography.cjs.js.map +1 -0
  160. package/dist/{text-input.es.js → typography.es.js} +8 -2
  161. package/dist/typography.es.js.map +1 -0
  162. package/package.json +1 -1
  163. package/dist/leaf.cjs.js +0 -182
  164. package/dist/leaf.cjs.js.map +0 -1
  165. package/dist/leaf.es.js +0 -179
  166. package/dist/leaf.es.js.map +0 -1
  167. package/dist/text-input.cjs.js.map +0 -1
  168. package/dist/text-input.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs5.js","sources":["../src/slate/TypographyPlugin/clearActiveTypographyStyle.ts","../src/slate/TypographyPlugin/clearDeviceActiveTypography.ts","../src/slate/TypographyPlugin/detachActiveTypography.ts","../src/slate/TypographyPlugin/setActiveTypographyId.ts","../src/slate/TypographyPlugin/setActiveTypographyStyle.ts","../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function clearActiveTypographyStyle(\n editor: Editor,\n options?: ClearActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style: [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearDeviceActiveTypographyOptions = {\n at?: Range\n}\n\nexport function clearDeviceActiveTypography(\n editor: Editor,\n currentDeviceId: string,\n options?: ClearDeviceActiveTypographyOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style:\n node?.typography?.style.filter(({ deviceId }) => deviceId !== currentDeviceId) ?? [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function detachActiveTypography(\n editor: Editor,\n value: RichTextTypography['style'],\n options?: SetActiveTypographyIdOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n Transforms.setNodes(\n editor,\n {\n typography: {\n style: value,\n },\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyId(\n editor: Editor,\n id?: string,\n options?: SetActiveTypographyIdOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n Transforms.setNodes(\n editor,\n {\n typography: {\n id,\n style: [],\n },\n },\n {\n at,\n match: node => Text.isText(node),\n split: Range.isExpanded(at),\n },\n )\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { Breakpoints, findBreakpointOverride, BreakpointId } from '../../state/modules/breakpoints'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyStyle(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: string,\n prop: string,\n value?: unknown,\n options?: SetActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const deviceOverrides = node?.typography?.style ?? []\n const deviceStyle = findBreakpointOverride(\n breakpoints,\n deviceOverrides,\n deviceId as BreakpointId,\n v => v,\n ) || {\n value: {},\n }\n const nextDeviceStyle = {\n deviceId,\n value: { ...deviceStyle.value, [prop]: value },\n }\n\n const nextTypography: RichTextTypography = {\n ...node.typography,\n style: [...deviceOverrides.filter(v => v.deviceId !== deviceId), nextDeviceStyle],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography: nextTypography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Text, Transforms } from 'slate'\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n if (\n Text.isText(normalizationNode) &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, 'typography', { at: normalizationPath })\n return\n }\n\n if (Text.isText(normalizationNode) && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n"],"names":["Editor","Transforms","Text","Range","findBreakpointOverride"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOO,oCACL,QACA,SACA;AACOA,eAAA,mBAAmB,QAAQ,MAAM;;AAChC,UAAA,KAAK,yCAAS,OAAT,YAAe,OAAO;AACjC,QAAI,CAAC;AAAI;AACT,UAAM,QAAQA,MAAA,OAAO,SAAS,QAAQ,EAAE;AAExC,QAAI,MAAM,SAAS;AACjBC,YAAA,WAAW,SACT,QACA;AAAA,QACE,OAAO;AAAA,MAAA,GAET;AAAA,QACE,IAAI,MAAM;AAAA,QACV,OAAO,CAAA,SAAQC,WAAK,OAAO,IAAI;AAAA,QAC/B,OAAOC,MAAA,MAAM,WAAW,MAAM,OAAO;AAAA,MAAA,CAEzC;AAAA,IACF;AAEA,QAAI,MAAM,SAAS;AACjB,YAAM,YAAY,MAAM,KACtBH,MAAAA,OAAO,MAAM,QAAQ;AAAA,QACnB,IAAI,MAAM;AAAA,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Aa,QAAQ,GAAG,eAAe;AAAA,UAAA;AAGlFH,gBAAA,WAAW,SACT,QACA;AAAA,YACE,YAAY;AAAA,UAAA,GAEd,EAAE,IAAI,KAAA,CACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM;AAAA,EAAA,CACb;AACH;ACtEO,MAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,wBAAwB,QAAgB;AAC7C,QAAM,EAAE,kBAAkB;AAC1B,SAAO,gBAAgB,CAAS,UAAA;;AACxB,UAAA,CAAC,mBAAmB,qBAAqB;AAC/C,QACEC,MAAK,KAAA,OAAO,iBAAiB,KAC7B,8DAAmB,eAAnB,mBAA+B,OAAM,QACrC,8DAAmB,eAAnB,mBAA+B,MAAM,YAAW,GAChD;AACAD,YAAA,WAAW,WAAW,QAAQ,cAAc,EAAE,IAAI,mBAAmB;AACrE;AAAA,IACF;AAEA,QAAIC,MAAAA,KAAK,OAAO,iBAAiB,KAAK,wDAAmB,UAAS,MAAM;AACtED,YAAA,WAAW,WAAW,QAAQ,SAAS,EAAE,IAAI,mBAAmB;AAChE;AAAA,IACF;AAEA,kBAAc,KAAK;AAAA,EAAA;AAGd,SAAA;AACT;;;"}
1
+ {"version":3,"file":"index.cjs5.js","sources":["../src/slate/TypographyPlugin/clearActiveTypographyStyle.ts","../src/slate/TypographyPlugin/clearDeviceActiveTypography.ts","../src/slate/TypographyPlugin/detachActiveTypography.ts","../src/slate/TypographyPlugin/setActiveTypographyId.ts","../src/slate/TypographyPlugin/setActiveTypographyStyle.ts","../src/slate/utils/responsive.ts","../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function clearActiveTypographyStyle(\n editor: Editor,\n options?: ClearActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style: [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearDeviceActiveTypographyOptions = {\n at?: Range\n}\n\nexport function clearDeviceActiveTypography(\n editor: Editor,\n currentDeviceId: string,\n options?: ClearDeviceActiveTypographyOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style:\n node?.typography?.style.filter(({ deviceId }) => deviceId !== currentDeviceId) ?? [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function detachActiveTypography(\n editor: Editor,\n value: RichTextTypography['style'],\n options?: SetActiveTypographyIdOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n Transforms.setNodes(\n editor,\n {\n typography: {\n style: value,\n },\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyId(\n editor: Editor,\n id?: string,\n options?: SetActiveTypographyIdOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n Transforms.setNodes(\n editor,\n {\n typography: {\n id,\n style: [],\n },\n },\n {\n at,\n match: node => Text.isText(node),\n split: Range.isExpanded(at),\n },\n )\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { Breakpoints, findBreakpointOverride, BreakpointId } from '../../state/modules/breakpoints'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyStyle(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: string,\n prop: string,\n value?: unknown,\n options?: SetActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const deviceOverrides = node?.typography?.style ?? []\n const deviceStyle = findBreakpointOverride(\n breakpoints,\n deviceOverrides,\n deviceId as BreakpointId,\n v => v,\n ) || {\n value: {},\n }\n const nextDeviceStyle = {\n deviceId,\n value: { ...deviceStyle.value, [prop]: value },\n }\n\n const nextTypography: RichTextTypography = {\n ...node.typography,\n style: [...deviceOverrides.filter(v => v.deviceId !== deviceId), nextDeviceStyle],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography: nextTypography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, NodeMatch, Descendant, NodeEntry } from 'slate'\nimport { getSelection } from '../selectors'\nimport deepEqual from '../../utils/deepEqual'\n\ntype SetResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n split: boolean\n}\n\nexport function setResponsiveValue<T extends Descendant, K extends keyof T>(\n editor: Editor,\n key: K,\n value: T[K] | undefined,\n options: SetResponsiveValueOptions<T>,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = getSelection(editor)\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes<Descendant>(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: options.match,\n split: options.split,\n },\n )\n }\n\n if (atRef.current) {\n const nodesToUpdate = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: (node, path) => options.match(node, path) && node.slice === true,\n }),\n )\n\n for (const [, path] of nodesToUpdate) {\n Transforms.setNodes(\n editor,\n {\n [key]: value,\n },\n { at: path },\n )\n }\n }\n\n atRef.unref()\n })\n}\n\ntype GetResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n}\n\nexport function getResponsiveValue<T extends Descendant, K extends keyof T>(\n editor: Editor,\n key: K,\n options: GetResponsiveValueOptions<T>,\n): T[K] | undefined {\n const matchingValues = Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: options?.match,\n }),\n )\n .filter(([node, path]) => options.match(node, path))\n .map(([node]) => node[key]) as (T[K] | undefined)[]\n\n const value =\n matchingValues.length === 0\n ? undefined\n : matchingValues.reduce((a, b) => (deepEqual(a, b) ? b : undefined))\n\n return value\n}\n\ntype NormalizeResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n}\n\nexport function normalizeResponsiveValue<T extends Descendant, K extends keyof T & string>(\n editor: Editor,\n key: K,\n options: NormalizeResponsiveValueOptions<T>,\n) {\n return (entry: NodeEntry) => {\n const [node, path] = entry\n\n if (!options.match(node, path)) {\n return false\n }\n\n const responsiveValue = node?.[key]\n\n if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {\n Transforms.unsetNodes(editor, key, { at: path })\n return true\n }\n\n if (node?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: path })\n return true\n }\n\n return false\n }\n}\n","import { Editor, Text, Transforms } from 'slate'\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\nimport { createRichTextV2Plugin, unstable_Typography } from '../../controls'\nimport { getResponsiveValue, setResponsiveValue } from '../utils/responsive'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport const TYPOGRAPHY_KEY = 'typography'\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n if (\n Text.isText(normalizationNode) &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath })\n return\n }\n\n if (Text.isText(normalizationNode) && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function TypographyPlugin() {\n return createRichTextV2Plugin({\n withPlugin: withTypography,\n control: {\n definition: unstable_Typography(),\n onChange: (editor, value) => {\n setResponsiveValue(editor, TYPOGRAPHY_KEY, value, {\n match: Text.isText,\n split: true,\n })\n },\n getValue: editor => getResponsiveValue(editor, TYPOGRAPHY_KEY, { match: Text.isText }),\n getLeafValue: (text: Text) => {\n return Text.isText(text) ? text.typography : undefined\n },\n },\n renderLeaf: (renderLeaf, className) => props => {\n return renderLeaf({\n ...props,\n leaf: {\n ...props.leaf,\n className: `${props.leaf.className} ${className}`,\n },\n })\n },\n })\n}\n"],"names":["Editor","Transforms","Text","Range","findBreakpointOverride","getSelection","deepEqual","createRichTextV2Plugin","unstable_Typography"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,oCACL,QACA,SACA;AACOA,eAAA,mBAAmB,QAAQ,MAAM;;AAChC,UAAA,KAAK,yCAAS,OAAT,YAAe,OAAO;AACjC,QAAI,CAAC;AAAI;AACT,UAAM,QAAQA,MAAA,OAAO,SAAS,QAAQ,EAAE;AAExC,QAAI,MAAM,SAAS;AACjBC,YAAA,WAAW,SACT,QACA;AAAA,QACE,OAAO;AAAA,MAAA,GAET;AAAA,QACE,IAAI,MAAM;AAAA,QACV,OAAO,CAAA,SAAQC,WAAK,OAAO,IAAI;AAAA,QAC/B,OAAOC,MAAA,MAAM,WAAW,MAAM,OAAO;AAAA,MAAA,CAEzC;AAAA,IACF;AAEA,QAAI,MAAM,SAAS;AACjB,YAAM,YAAY,MAAM,KACtBH,MAAAA,OAAO,MAAM,QAAQ;AAAA,QACnB,IAAI,MAAM;AAAA,QACV,OAAO,CAAQ,SAAAE,WAAK,OAAO,IAAI,KAAK,KAAK,UAAU;A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ACP,YAAYC,WAAAA,oBAAoB;AAAA,MAChC,UAAU,CAAC,QAAQ,UAAU;AACR,2BAAA,QAAQ,gBAAgB,OAAO;AAAA,UAChD,OAAON,MAAK,KAAA;AAAA,UACZ,OAAO;AAAA,QAAA,CACR;AAAA,MACH;AAAA,MACA,UAAU,YAAU,mBAAmB,QAAQ,gBAAgB,EAAE,OAAOA,WAAK,QAAQ;AAAA,MACrF,cAAc,CAAC,SAAe;AAC5B,eAAOA,MAAAA,KAAK,OAAO,IAAI,IAAI,KAAK,aAAa;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,YAAY,CAAC,YAAY,cAAc,CAAS,UAAA;AAC9C,aAAO,WAAW,iCACb,QADa;AAAA,QAEhB,MAAM,iCACD,MAAM,OADL;AAAA,UAEJ,WAAW,GAAG,MAAM,KAAK,aAAa;AAAA,QACxC;AAAA,MAAA,EACD;AAAA,IACH;AAAA,EAAA,CACD;AACH;;;;;;;;"}
@@ -9,13 +9,14 @@ require("./react-page.cjs.js");
9
9
  require("redux");
10
10
  require("redux-thunk");
11
11
  require("./actions.cjs.js");
12
+ require("zod");
12
13
  require("./state/breakpoints.cjs.js");
13
14
  require("@emotion/css");
14
15
  require("@emotion/serialize");
15
16
  require("@emotion/utils");
16
17
  require("slate");
17
18
  require("react/jsx-runtime");
18
- require("./text-input.cjs.js");
19
+ require("./typography.cjs.js");
19
20
  require("./combobox.cjs.js");
20
21
  require("use-sync-external-store/shim");
21
22
  require("./types.cjs.js");
@@ -26,7 +27,6 @@ require("scroll-into-view-if-needed");
26
27
  require("react-dom");
27
28
  require("html-react-parser");
28
29
  require("next/head");
29
- require("zod");
30
30
  require("@emotion/server/create-instance");
31
31
  require("next/document");
32
32
  require("cors");
@@ -37,9 +37,6 @@ var isHotkey = require("is-hotkey");
37
37
  var slateHistory = require("slate-history");
38
38
  var slateReact = require("slate-react");
39
39
  var reactPage = require("./react-page.cjs.js");
40
- var css = require("@emotion/css");
41
- require("@emotion/serialize");
42
- require("@emotion/utils");
43
40
  var next = require("./index.cjs.js");
44
41
  require("./state/breakpoints.cjs.js");
45
42
  require("./types.cjs2.js");
@@ -47,13 +44,16 @@ var index = require("./index.cjs6.js");
47
44
  var index$1 = require("./index.cjs7.js");
48
45
  var jsxRuntime = require("react/jsx-runtime");
49
46
  require("./index.cjs3.js");
47
+ var css = require("@emotion/css");
50
48
  var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
49
+ require("./actions.cjs.js");
51
50
  require("redux");
52
51
  require("redux-thunk");
53
- require("./actions.cjs.js");
52
+ require("@emotion/serialize");
53
+ require("@emotion/utils");
54
54
  require("use-sync-external-store/shim/with-selector");
55
55
  require("next/dynamic");
56
- require("./text-input.cjs.js");
56
+ require("./typography.cjs.js");
57
57
  require("./combobox.cjs.js");
58
58
  require("use-sync-external-store/shim");
59
59
  require("./types.cjs.js");
package/dist/index.es.js CHANGED
@@ -38,23 +38,21 @@ import * as React from "react";
38
38
  import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
39
39
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
40
40
  import dynamic from "next/dynamic";
41
- import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getElementSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, S as ShapeControlType, L as ListControlType, m as Types, E as ElementID, B as Backgrounds, W as Width, n as ResponsiveIconRadioGroup, M as Margin, P as Padding, o as Border, p as BorderRadius, q as Shadows, G as GapY, r as GapX, s as ResponsiveSelect, t as ResponsiveNumber, u as Checkbox, v as Grid, w as TextInput, x as Link, y as ResponsiveColor, z as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, A as ResponsiveLength, H as TextArea, J as Table, K as TableFormFields, O as Image, Q as ResponsiveOpacity, U as NavigationLinks, V as SocialLinks, X as RichText, Y as Video, Z as useStyle, _ as getBorderSwatchIds, $ as isNonNullable, a0 as getBoxShadowsSwatchIds, a1 as getResponsiveColorSwatchIds, a2 as StyleControlProperty, a3 as ImageControlValueFormat, a4 as isPropControllersHandle, a5 as StyleControlType, a6 as RichTextV2ControlType, a7 as RichTextControlType, a8 as SlotControlType, a9 as StyleV2ControlType, aa as LinkControlType, ab as ImageControlType, ac as ColorControlType, ad as getComponentPropControllerDescriptors, ae as getPropControllers, af as BorderPropControllerFormat, ag as ShadowsPropControllerFormat, ah as BorderRadiusPropControllerFormat, ai as MarginPropControllerFormat, aj as PaddingPropControllerFormat, ak as WidthPropControllerFormat, al as configureStore$1, am as copyElementTree, an as getBreakpoints, ao as getDocument, ap as getElementId, aq as getIsPreview, ar as getIsInBuilder, as as getReactComponent, at as getBuilderEditMode } from "./react-page.es.js";
42
- import { A as ActionTypes, n as apiResourceFulfilled, o as registerComponentEffect, p as registerReactComponentEffect, q as registerComponentHandleEffect, t as mountComponentEffect } from "./actions.es.js";
41
+ import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, E as ElementID, B as Backgrounds, W as Width, m as ResponsiveIconRadioGroup, M as Margin, P as Padding, n as Border, o as BorderRadius, S as Shadows, G as GapY, p as GapX, q as ResponsiveSelect, r as ResponsiveNumber, s as Checkbox, t as Grid, u as TextInput, L as Link, v as ResponsiveColor, w as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, x as ResponsiveLength, y as TextArea, z as Table, A as TableFormFields, H as Image, J as ResponsiveOpacity, K as NavigationLinks, O as SocialLinks, Q as RichText, V as Video, U as useStyle, X as getBorderSwatchIds, Y as isNonNullable$1, Z as getBoxShadowsSwatchIds, _ as getResponsiveColorSwatchIds, $ as StyleControlProperty, a0 as ImageControlValueFormat, a1 as isPropControllersHandle, a2 as StyleControlType, a3 as RichTextV2ControlType, a4 as RichTextControlType, a5 as SlotControlType, a6 as StyleV2ControlType, a7 as ListControlType, a8 as ShapeControlType, a9 as LinkControlType, aa as ImageControlType, ab as ColorControlType, ac as getComponentPropControllerDescriptors, ad as getPropControllers, ae as Types, af as BorderPropControllerFormat, ag as ShadowsPropControllerFormat, ah as BorderRadiusPropControllerFormat, ai as MarginPropControllerFormat, aj as PaddingPropControllerFormat, ak as WidthPropControllerFormat, al as configureStore$1, am as copyElementTree, an as getBreakpoints, ao as parseLocalesInput, ap as getDocument, aq as getElementId, ar as getIsPreview, as as getIsInBuilder, at as getReactComponent, au as getBuilderEditMode } from "./react-page.es.js";
42
+ import { A as ActionTypes, o as apiResourceFulfilled, p as registerComponentEffect, q as registerReactComponentEffect, t as registerComponentHandleEffect, v as mountComponentEffect } from "./actions.es.js";
43
43
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
44
- import { I as IconRadioGroupControlType, S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
44
+ import { T as TypographyControlType, I as IconRadioGroupControlType, S as SelectControlType, a as TextAreaControlType, b as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./typography.es.js";
45
45
  import { C as ComboboxControlType } from "./combobox.es.js";
46
46
  import "slate";
47
47
  import { useSyncExternalStore } from "use-sync-external-store/shim";
48
48
  import { createStore, applyMiddleware } from "redux";
49
49
  import thunk from "redux-thunk";
50
50
  import { A as APIResourceType } from "./types.es.js";
51
- import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, getBreakpoint, getBreakpointMediaQuery, parseBreakpointsInput } from "./state/breakpoints.es.js";
51
+ import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, getBreakpoint, getBreakpointMediaQuery, shallowMergeFallbacks, parseBreakpointsInput } from "./state/breakpoints.es.js";
52
52
  import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
53
53
  import ColorHelper from "color";
54
- import { cache, cx } from "@emotion/css";
55
- import "@emotion/serialize";
56
- import "@emotion/utils";
57
54
  import scrollIntoView from "scroll-into-view-if-needed";
55
+ import { cache, cx } from "@emotion/css";
58
56
  import { findDOMNode } from "react-dom";
59
57
  import parse from "html-react-parser";
60
58
  import Head from "next/head";
@@ -565,7 +563,7 @@ const filterUsedSnippetProperties = ({
565
563
  function Page$1({
566
564
  document: page
567
565
  }) {
568
- var _a;
566
+ var _a, _b;
569
567
  const isInBuilder = useIsInBuilder();
570
568
  const [snippets, setSnippets] = useState(page.snippets);
571
569
  const cachedPage = useCachedPage(isInBuilder ? page.id : null);
@@ -627,6 +625,10 @@ function Page$1({
627
625
  });
628
626
  previousHeadSnippets.current = headSnippets;
629
627
  }, [headSnippets]);
628
+ const baseLocalizedPage = page.localizedPages.find(({
629
+ parentId
630
+ }) => parentId == null);
631
+ const documentId = (_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.elementTreeId) != null ? _b : page.id;
630
632
  return /* @__PURE__ */ jsxs(Fragment, {
631
633
  children: [/* @__PURE__ */ jsxs(Head, {
632
634
  children: [/* @__PURE__ */ jsx("style", {
@@ -708,7 +710,7 @@ function Page$1({
708
710
  return null;
709
711
  }))]
710
712
  }), /* @__PURE__ */ jsx(DocumentReference, {
711
- documentReference: createDocumentReference(page.id)
713
+ documentReference: createDocumentReference(documentId)
712
714
  }), filteredSnippets.filter((snippet) => snippet.location === SnippetLocation.Body).map((snippet) => /* @__PURE__ */ jsx(BodySnippet, {
713
715
  code: snippet.code,
714
716
  cleanup: snippet.cleanup
@@ -925,7 +927,7 @@ Received "${apiKey}" instead.`);
925
927
  while (current = remaining.pop()) {
926
928
  let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
927
929
  Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
928
- getElementSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
930
+ getSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
929
931
  swatchIds.add(swatchId);
930
932
  });
931
933
  getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
@@ -938,34 +940,6 @@ Received "${apiKey}" instead.`);
938
940
  remaining.push(child);
939
941
  }
940
942
  });
941
- if (descriptor.type === ShapeControlType) {
942
- const prop = props[propName];
943
- if (prop == null)
944
- return;
945
- getResourcesFromElementDescriptors(descriptor.config.type, prop);
946
- }
947
- if (descriptor.type === ListControlType) {
948
- const prop = props[propName];
949
- if (prop == null)
950
- return;
951
- prop.forEach((item) => {
952
- getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
953
- });
954
- }
955
- if (descriptor.type === Types.Shape) {
956
- const prop = props[propName];
957
- if (prop == null)
958
- return;
959
- getResourcesFromElementDescriptors(descriptor.options.type, prop);
960
- }
961
- if (descriptor.type === Types.List) {
962
- const prop = props[propName];
963
- if (prop == null)
964
- return;
965
- prop.forEach((item) => {
966
- getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
967
- });
968
- }
969
943
  });
970
944
  };
971
945
  let element2;
@@ -1044,10 +1018,16 @@ Received "${apiKey}" instead.`);
1044
1018
  }))
1045
1019
  };
1046
1020
  }
1047
- async getPageSnapshot(pathname, { preview: previewOverride = false } = {}) {
1021
+ async getPageSnapshot(pathname, {
1022
+ preview: previewOverride = false,
1023
+ unstable_locale
1024
+ } = {}) {
1048
1025
  var _a;
1049
1026
  const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
1050
- const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document`, {
1027
+ const searchParams = new URLSearchParams();
1028
+ if (unstable_locale)
1029
+ searchParams.set("locale", unstable_locale);
1030
+ const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document?${searchParams.toString()}`, {
1051
1031
  headers: { "Makeswift-Site-Version": siteVersion }
1052
1032
  });
1053
1033
  if (!response.ok) {
@@ -1148,7 +1128,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1148
1128
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1149
1129
  return res.json(fonts2);
1150
1130
  }
1151
- const version = "0.9.3";
1131
+ const version = "0.9.5";
1152
1132
  async function handler(req, res, { apiKey, unstable_siteVersions }) {
1153
1133
  if (req.query.secret !== apiKey) {
1154
1134
  return res.status(401).json({ message: "Unauthorized" });
@@ -1419,9 +1399,13 @@ const Page = memo(({
1419
1399
  uri: new URL("graphql", snapshot.apiOrigin).href,
1420
1400
  cacheData: snapshot.cacheData
1421
1401
  }), [snapshot]);
1402
+ const rootElements = /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]);
1403
+ snapshot.document.localizedPages.forEach((localizedPage) => {
1404
+ rootElements.set(localizedPage.elementTreeId, localizedPage.data);
1405
+ });
1422
1406
  return /* @__PURE__ */ jsx(RuntimeProvider, {
1423
1407
  client,
1424
- rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
1408
+ rootElements,
1425
1409
  preview: snapshot.preview,
1426
1410
  runtime,
1427
1411
  children: /* @__PURE__ */ jsx(Page$1, {
@@ -2568,7 +2552,7 @@ function mapSideColor(swatches, _e) {
2568
2552
  return __spreadProps(__spreadValues({}, restOfSide), {
2569
2553
  color: color && {
2570
2554
  alpha: color.alpha,
2571
- swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId)
2555
+ swatch: swatches.filter(isNonNullable$1).find((s) => s && s.id === color.swatchId)
2572
2556
  }
2573
2557
  });
2574
2558
  }
@@ -2614,7 +2598,7 @@ function useBoxShadow(value) {
2614
2598
  return __spreadProps(__spreadValues({}, restOfShadow), {
2615
2599
  payload: {
2616
2600
  color: color != null ? {
2617
- swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId),
2601
+ swatch: swatches.filter(isNonNullable$1).find((s) => s && s.id === color.swatchId),
2618
2602
  alpha: color.alpha
2619
2603
  } : null,
2620
2604
  inset: inset != null ? inset : ShadowDefaultValue.inset,
@@ -2638,7 +2622,7 @@ function useResponsiveColor(color) {
2638
2622
  const { swatchId, alpha } = v;
2639
2623
  const swatch = swatches.find((s) => s && s.id === swatchId);
2640
2624
  return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
2641
- }).filter(isNonNullable);
2625
+ }).filter(isNonNullable$1);
2642
2626
  }
2643
2627
  const getIndexes = (spans, index) => {
2644
2628
  const flattened = spans.reduce((a, s) => a.concat(s), []);
@@ -3346,6 +3330,138 @@ function useTextAreaValue(data, definition) {
3346
3330
  function useTextInputValue(data, definition) {
3347
3331
  return data != null ? data : definition.config.defaultValue;
3348
3332
  }
3333
+ function isNonNullable(value) {
3334
+ return value != null;
3335
+ }
3336
+ function typographyFragementToTypographyControlData(typography) {
3337
+ if (typography == null)
3338
+ return void 0;
3339
+ return {
3340
+ id: typography.id,
3341
+ style: typography.style.map(({ deviceId, value }) => {
3342
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3343
+ return {
3344
+ deviceId,
3345
+ value: {
3346
+ fontFamily: (_a = value.fontFamily) != null ? _a : void 0,
3347
+ lineHeight: (_b = value.lineHeight) != null ? _b : void 0,
3348
+ letterSpacing: (_c = value.letterSpacing) != null ? _c : void 0,
3349
+ fontWeight: (_d = value.fontWeight) != null ? _d : void 0,
3350
+ textAlign: (_e = value.textAlign) != null ? _e : void 0,
3351
+ uppercase: (_f = value.uppercase) != null ? _f : void 0,
3352
+ underline: (_g = value.underline) != null ? _g : void 0,
3353
+ strikethrough: (_h = value.strikethrough) != null ? _h : void 0,
3354
+ italic: (_i = value.italic) != null ? _i : void 0,
3355
+ fontSize: (_j = value.fontSize) != null ? _j : void 0,
3356
+ color: (_k = value.color) != null ? _k : void 0
3357
+ }
3358
+ };
3359
+ })
3360
+ };
3361
+ }
3362
+ function getTypographyStyleSwatchIds(style) {
3363
+ var _a;
3364
+ return (_a = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
3365
+ var _a2;
3366
+ return (_a2 = typographyStyle.color) == null ? void 0 : _a2.swatchId;
3367
+ }).filter(isNonNullable)) != null ? _a : [];
3368
+ }
3369
+ const withColor = (swatches) => (deviceRawTypographyValue) => {
3370
+ var _b, _c;
3371
+ const { value, deviceId } = deviceRawTypographyValue;
3372
+ if (value.color == null) {
3373
+ const _a = value, { color } = _a, nextValue = __objRest(_a, ["color"]);
3374
+ return {
3375
+ deviceId,
3376
+ value: nextValue
3377
+ };
3378
+ }
3379
+ return {
3380
+ deviceId,
3381
+ value: __spreadProps(__spreadValues({}, value), {
3382
+ color: {
3383
+ swatch: swatches.find((s) => {
3384
+ var _a2;
3385
+ return s && s.id === ((_a2 = value.color) == null ? void 0 : _a2.swatchId);
3386
+ }),
3387
+ alpha: (_c = (_b = value.color) == null ? void 0 : _b.alpha) != null ? _c : void 0
3388
+ }
3389
+ })
3390
+ };
3391
+ };
3392
+ const getDeviceId = ({ deviceId }) => deviceId;
3393
+ function useEnhancedTypography(value) {
3394
+ var _a, _b, _c;
3395
+ const typography = typographyFragementToTypographyControlData(useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null));
3396
+ const source = (_b = typography == null ? void 0 : typography.style) != null ? _b : [];
3397
+ const override = (_c = value == null ? void 0 : value.style) != null ? _c : [];
3398
+ const breakpoints = useBreakpoints();
3399
+ const swatchIds = [
3400
+ ...getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
3401
+ ...getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
3402
+ ];
3403
+ const swatches = useSwatches(swatchIds).filter(isNonNullable);
3404
+ const enhancedSource = source.map(withColor(swatches));
3405
+ const enhancedOverride = override.map(withColor(swatches));
3406
+ const devices = [
3407
+ ...new Set(enhancedSource.map(getDeviceId).concat(enhancedOverride.map(getDeviceId)))
3408
+ ];
3409
+ return devices.map((deviceId) => {
3410
+ var _a2, _b2;
3411
+ const deviceSource = (_a2 = findBreakpointOverride(breakpoints, enhancedSource, deviceId)) == null ? void 0 : _a2.value;
3412
+ const deviceOverride = (_b2 = findBreakpointOverride(breakpoints, enhancedOverride, deviceId, (v) => v)) == null ? void 0 : _b2.value;
3413
+ if (deviceSource && deviceOverride) {
3414
+ return {
3415
+ deviceId,
3416
+ value: __spreadValues(__spreadValues({}, deviceSource), deviceOverride)
3417
+ };
3418
+ } else if (deviceOverride) {
3419
+ return {
3420
+ deviceId,
3421
+ value: deviceOverride
3422
+ };
3423
+ } else if (deviceSource) {
3424
+ return {
3425
+ deviceId,
3426
+ value: deviceSource
3427
+ };
3428
+ }
3429
+ return null;
3430
+ }).filter(isNonNullable);
3431
+ }
3432
+ function useTypographyClassName(value) {
3433
+ return useStyle(useResponsiveStyle([value], ([value2]) => {
3434
+ if (value2 === void 0)
3435
+ return {};
3436
+ let styles = {};
3437
+ if (value2.color != null)
3438
+ styles.color = colorToString(value2.color);
3439
+ if (value2.fontFamily != null)
3440
+ styles.fontFamily = value2.fontFamily;
3441
+ if (value2.fontSize != null && value2.fontSize.value != null && value2.fontSize.unit != null)
3442
+ styles.fontSize = `${value2.fontSize.value}${value2.fontSize.unit}`;
3443
+ if (value2.fontWeight != null)
3444
+ styles.fontWeight = value2.fontWeight;
3445
+ if (value2.lineHeight != null)
3446
+ styles.lineHeight = value2.lineHeight;
3447
+ if (value2.letterSpacing != null)
3448
+ styles.letterSpacing = `${value2.letterSpacing / 10}em`;
3449
+ if (value2.uppercase != null)
3450
+ styles.textTransform = value2.uppercase === true ? "uppercase" : "initial";
3451
+ if (value2.underline != null || value2.strikethrough != null)
3452
+ styles.textDecoration = [
3453
+ Boolean(value2.underline) && "underline",
3454
+ Boolean(value2.strikethrough) && "line-through"
3455
+ ].filter(Boolean).join(" ");
3456
+ if (value2.italic != null)
3457
+ styles.fontStyle = value2.italic === true ? "italic" : "initial";
3458
+ return styles;
3459
+ }, shallowMergeFallbacks));
3460
+ }
3461
+ function useTypographyValue(data) {
3462
+ const enhancedTypography = useEnhancedTypography(data);
3463
+ return useTypographyClassName(enhancedTypography);
3464
+ }
3349
3465
  function ControlValue({
3350
3466
  data,
3351
3467
  definition,
@@ -3458,6 +3574,12 @@ function ControlValue({
3458
3574
  parameters: [data, definition, control],
3459
3575
  children: (value) => children(value)
3460
3576
  }, definition.type);
3577
+ case TypographyControlType:
3578
+ return /* @__PURE__ */ jsx(RenderHook, {
3579
+ hook: useTypographyValue,
3580
+ parameters: [data],
3581
+ children: (value) => children(value)
3582
+ }, definition.type);
3461
3583
  default:
3462
3584
  return children(data);
3463
3585
  }
@@ -3512,6 +3634,7 @@ function PropsValue({
3512
3634
  case ListControlType:
3513
3635
  case LinkControlType:
3514
3636
  case StyleV2ControlType:
3637
+ case TypographyControlType:
3515
3638
  return /* @__PURE__ */ jsx(ControlValue, {
3516
3639
  definition: descriptor,
3517
3640
  data: props[propName],
@@ -3741,9 +3864,7 @@ class ReactRuntime {
3741
3864
  __publicField(this, "store");
3742
3865
  this.store = configureStore$1({
3743
3866
  breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : void 0,
3744
- locales: unstable_i18n ? __spreadProps(__spreadValues({}, unstable_i18n), {
3745
- locale: null
3746
- }) : void 0
3867
+ locales: unstable_i18n ? parseLocalesInput(unstable_i18n) : void 0
3747
3868
  });
3748
3869
  registerBuiltinComponents(this);
3749
3870
  }
@@ -4005,5 +4126,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
4005
4126
  document: document2
4006
4127
  });
4007
4128
  }));
4008
- export { Document$1 as $, Alignments as A, forwardNextDynamicRef as B, Contrasts as C, DocumentReference as D, Element$1 as E, useIsPreview as F, useFiles as G, useSwatches as H, usePagePathnameSlice as I, useElementId as J, deepEqual as K, ElementImperativeHandle as L, StoreContext as M, MakeswiftProvider as N, ControlValue as O, PageProvider as P, useBuilderEditMode as Q, RuntimeProvider as R, Shapes as S, pollBoxModel as T, useTypography as U, getStaticPaths as V, getStaticProps as W, getServerSideProps as X, Page as Y, Makeswift as Z, PreviewModeScript as _, ReactRuntime as a, MakeswiftApiHandler as a0, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, Page$1 as m, useResponsiveStyle as n, useResponsiveWidth as o, useResponsiveTextStyle as p, colorToString as q, useBreakpoints as r, Sizes as s, useFormContext as t, useIsInBuilder as u, useResponsiveGridItem as v, useTable as w, useMakeswiftClient as x, Provider as y, useFile as z };
4129
+ export { PreviewModeScript as $, Alignments as A, forwardNextDynamicRef as B, Contrasts as C, DocumentReference as D, Element$1 as E, useIsPreview as F, useFiles as G, useSwatches as H, usePagePathnameSlice as I, useElementId as J, deepEqual as K, ElementImperativeHandle as L, StoreContext as M, MakeswiftProvider as N, ControlValue as O, PageProvider as P, useBuilderEditMode as Q, RuntimeProvider as R, Shapes as S, pollBoxModel as T, useEnhancedTypography as U, useTypographyClassName as V, getStaticPaths as W, getStaticProps as X, getServerSideProps as Y, Page as Z, Makeswift as _, ReactRuntime as a, Document$1 as a0, MakeswiftApiHandler as a1, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, Page$1 as m, useResponsiveStyle as n, useResponsiveWidth as o, useResponsiveTextStyle as p, colorToString as q, useBreakpoints as r, Sizes as s, useFormContext as t, useIsInBuilder as u, useResponsiveGridItem as v, useTable as w, useMakeswiftClient as x, Provider as y, useFile as z };
4009
4130
  //# sourceMappingURL=index.es.js.map