@makeswift/runtime 0.28.6-canary.4 → 0.28.6-canary.6

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 (272) hide show
  1. package/dist/cjs/api/client.js.map +0 -1
  2. package/dist/cjs/api/fragments.js.map +0 -1
  3. package/dist/cjs/api/graphql/client.js.map +0 -1
  4. package/dist/cjs/api/graphql/documents/index.js.map +0 -1
  5. package/dist/cjs/api/index.js.map +0 -1
  6. package/dist/cjs/api/site-version/index.js.map +0 -1
  7. package/dist/cjs/api-handler/cookies.js.map +0 -1
  8. package/dist/cjs/api-handler/cors.js.map +0 -1
  9. package/dist/cjs/api-handler/handlers/element-tree.js.map +0 -1
  10. package/dist/cjs/api-handler/handlers/fonts.js.map +0 -1
  11. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  12. package/dist/cjs/api-handler/handlers/webhook/index.js.map +0 -1
  13. package/dist/cjs/api-handler/index.js.map +0 -1
  14. package/dist/cjs/builder/breakpoints/index.js.map +0 -1
  15. package/dist/cjs/builder/core/index.js.map +0 -1
  16. package/dist/cjs/builder/host-api.js.map +0 -1
  17. package/dist/cjs/builder/host-to-builder-actions.js.map +0 -1
  18. package/dist/cjs/builder/index.js.map +0 -1
  19. package/dist/cjs/builder/unstructured-introspection/__fixtures__/index.js.map +0 -1
  20. package/dist/cjs/builder/unstructured-introspection/index.js.map +0 -1
  21. package/dist/cjs/client/index.js +3 -3
  22. package/dist/cjs/client/index.js.map +0 -1
  23. package/dist/cjs/components/builtin/Box/index.js.map +0 -1
  24. package/dist/cjs/components/builtin/Button/index.js.map +0 -1
  25. package/dist/cjs/components/builtin/Carousel/index.js.map +0 -1
  26. package/dist/cjs/components/builtin/Countdown/index.js.map +0 -1
  27. package/dist/cjs/components/builtin/Divider/index.js.map +0 -1
  28. package/dist/cjs/components/builtin/Embed/index.js.map +0 -1
  29. package/dist/cjs/components/builtin/Form/index.js.map +0 -1
  30. package/dist/cjs/components/builtin/Image/Image.js.map +0 -1
  31. package/dist/cjs/components/builtin/Image/index.js.map +0 -1
  32. package/dist/cjs/components/builtin/Navigation/index.js.map +0 -1
  33. package/dist/cjs/components/builtin/Root/index.js.map +0 -1
  34. package/dist/cjs/components/builtin/Slot/index.js.map +0 -1
  35. package/dist/cjs/components/builtin/SocialLinks/index.js.map +0 -1
  36. package/dist/cjs/components/builtin/Text/index.js.map +0 -1
  37. package/dist/cjs/components/builtin/Video/index.js.map +0 -1
  38. package/dist/cjs/components/builtin/constants.js.map +0 -1
  39. package/dist/cjs/components/hooks/index.js.map +0 -1
  40. package/dist/cjs/components/shared/BackgroundsContainer/index.js.map +0 -1
  41. package/dist/cjs/components/shared/ErrorBoundary.js.map +0 -1
  42. package/dist/cjs/components/shared/FallbackComponent/index.js.map +0 -1
  43. package/dist/cjs/components/shared/GutterContainer/index.js.map +0 -1
  44. package/dist/cjs/components/shared/Link/index.js.map +0 -1
  45. package/dist/cjs/components/shared/grid-item.js.map +0 -1
  46. package/dist/cjs/components/utils/drop-first.js.map +0 -1
  47. package/dist/cjs/controls/control.js.map +0 -1
  48. package/dist/cjs/controls/index.js.map +0 -1
  49. package/dist/cjs/controls/rich-text/index.js.map +0 -1
  50. package/dist/cjs/controls/rich-text-v2/index.js.map +0 -1
  51. package/dist/cjs/controls/serialization/base/index.js.map +0 -1
  52. package/dist/cjs/controls/serialization/index.js.map +0 -1
  53. package/dist/cjs/controls/serialization/message-port/index.js.map +0 -1
  54. package/dist/cjs/controls/style-v2/index.js.map +0 -1
  55. package/dist/cjs/global.d.js.map +0 -1
  56. package/dist/cjs/index.js.map +0 -1
  57. package/dist/cjs/next/api-handler/index.js.map +0 -1
  58. package/dist/cjs/next/client.js.map +0 -1
  59. package/dist/cjs/next/components/framework-provider/app-router/index.js.map +0 -1
  60. package/dist/cjs/next/components/framework-provider/index.js.map +0 -1
  61. package/dist/cjs/next/components/framework-provider/pages-router/index.js.map +0 -1
  62. package/dist/cjs/next/document.js.map +0 -1
  63. package/dist/cjs/next/fetch.js.map +0 -1
  64. package/dist/cjs/next/index.js.map +0 -1
  65. package/dist/cjs/next/middleware/index.js.map +0 -1
  66. package/dist/cjs/next/testing/element-data.js.map +0 -1
  67. package/dist/cjs/next/testing/index.js.map +0 -1
  68. package/dist/cjs/prop-controllers/copy.js.map +0 -1
  69. package/dist/cjs/prop-controllers/deleted.js.map +0 -1
  70. package/dist/cjs/prop-controllers/descriptors.js.map +0 -1
  71. package/dist/cjs/react/builtins/countdown.js.map +0 -1
  72. package/dist/cjs/react/builtins/divider.js.map +0 -1
  73. package/dist/cjs/react/builtins/embed.js.map +0 -1
  74. package/dist/cjs/react/builtins/form.js.map +0 -1
  75. package/dist/cjs/react/builtins/image.js.map +0 -1
  76. package/dist/cjs/react/builtins/index.js.map +0 -1
  77. package/dist/cjs/react/core/index.js.map +0 -1
  78. package/dist/cjs/react/index.js.map +0 -1
  79. package/dist/cjs/runtimes/react/components/index.js.map +0 -1
  80. package/dist/cjs/runtimes/react/components/page/index.js.map +0 -1
  81. package/dist/cjs/runtimes/react/controls/rich-text/components/Element/inline.js.map +0 -1
  82. package/dist/cjs/runtimes/react/controls/rich-text/components/Leaf/leaf.js.map +0 -1
  83. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +0 -1
  84. package/dist/cjs/runtimes/react/find-dom-node.js.map +0 -1
  85. package/dist/cjs/runtimes/react/host-api-client.js.map +0 -1
  86. package/dist/cjs/runtimes/react/index.js.map +0 -1
  87. package/dist/cjs/runtimes/react/legacy-controls.js.map +0 -1
  88. package/dist/cjs/runtimes/react/root-style-registry.js +10 -0
  89. package/dist/cjs/runtimes/react/root-style-registry.js.map +1 -1
  90. package/dist/cjs/slate/BlockPlugin/indent.js.map +0 -1
  91. package/dist/cjs/slate/BlockPlugin/index.js.map +0 -1
  92. package/dist/cjs/slate/BuilderPlugin/index.js.map +0 -1
  93. package/dist/cjs/slate/InlineModePlugin/index.js.map +0 -1
  94. package/dist/cjs/slate/InlinePlugin/getValue.js.map +0 -1
  95. package/dist/cjs/slate/InlinePlugin/index.js.map +0 -1
  96. package/dist/cjs/slate/LinkPlugin/getValue.js.map +0 -1
  97. package/dist/cjs/slate/LinkPlugin/index.js.map +0 -1
  98. package/dist/cjs/slate/LocalChangesPlugin/index.js.map +0 -1
  99. package/dist/cjs/slate/TextAlignPlugin/getValue.js.map +0 -1
  100. package/dist/cjs/slate/TextAlignPlugin/index.js.map +0 -1
  101. package/dist/cjs/slate/TypographyPlugin/getValue.js.map +0 -1
  102. package/dist/cjs/slate/TypographyPlugin/index.js.map +0 -1
  103. package/dist/cjs/slate/index.js.map +0 -1
  104. package/dist/cjs/slate/utils/editor.js.map +0 -1
  105. package/dist/cjs/slate/utils/element.js.map +0 -1
  106. package/dist/cjs/slate/utils/filterForSubtreeRoots.js.map +0 -1
  107. package/dist/cjs/slate/utils/index.js.map +0 -1
  108. package/dist/cjs/state/actions/index.js.map +0 -1
  109. package/dist/cjs/state/actions/internal/index.js.map +0 -1
  110. package/dist/cjs/state/host-api.js.map +0 -1
  111. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +0 -1
  112. package/dist/cjs/state/middleware/read-write/index.js.map +0 -1
  113. package/dist/cjs/state/modules/element-trees.js.map +0 -1
  114. package/dist/cjs/state/modules/is-in-builder.js.map +0 -1
  115. package/dist/cjs/state/modules/is-read-only.js.map +0 -1
  116. package/dist/cjs/testing/fixtures.js.map +0 -1
  117. package/dist/cjs/translations/index.js.map +0 -1
  118. package/dist/cjs/unstable-framework-support/index.js +2 -0
  119. package/dist/cjs/unstable-framework-support/index.js.map +0 -1
  120. package/dist/cjs/utils/deepEqual.js.map +0 -1
  121. package/dist/cjs/utils/deferred.js.map +0 -1
  122. package/dist/cjs/utils/deterministic-uuid.js.map +0 -1
  123. package/dist/cjs/utils/esm-compat.js.map +0 -1
  124. package/dist/cjs/utils/is-server.js.map +0 -1
  125. package/dist/cjs/utils/isNonNullable.js.map +0 -1
  126. package/dist/esm/api/graphql/documents/queries.js.map +0 -1
  127. package/dist/esm/api/graphql/generated/types.js.map +0 -1
  128. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  129. package/dist/esm/api-handler/handlers/webhook/site-published.js.map +0 -1
  130. package/dist/esm/api-handler/handlers/webhook/types.js.map +0 -1
  131. package/dist/esm/client/index.js +3 -3
  132. package/dist/esm/components/builtin/Box/register.js.map +0 -1
  133. package/dist/esm/components/builtin/Button/register.js.map +0 -1
  134. package/dist/esm/components/builtin/Carousel/register.js.map +0 -1
  135. package/dist/esm/components/builtin/Countdown/register.js.map +0 -1
  136. package/dist/esm/components/builtin/Divider/register.js.map +0 -1
  137. package/dist/esm/components/builtin/Embed/register.js.map +0 -1
  138. package/dist/esm/components/builtin/Form/components/Field/services/responsiveField.js.map +0 -1
  139. package/dist/esm/components/builtin/Form/register.js.map +0 -1
  140. package/dist/esm/components/builtin/Form/types.js.map +0 -1
  141. package/dist/esm/components/builtin/Image/register.js.map +0 -1
  142. package/dist/esm/components/builtin/Navigation/register.js.map +0 -1
  143. package/dist/esm/components/builtin/Root/Root.js.map +0 -1
  144. package/dist/esm/components/builtin/Root/register.js.map +0 -1
  145. package/dist/esm/components/builtin/Slot/Slot.js.map +0 -1
  146. package/dist/esm/components/builtin/Slot/register.js.map +0 -1
  147. package/dist/esm/components/builtin/SocialLinks/SocialLinks.js.map +0 -1
  148. package/dist/esm/components/builtin/SocialLinks/options.js.map +0 -1
  149. package/dist/esm/components/builtin/SocialLinks/register.js.map +0 -1
  150. package/dist/esm/components/builtin/Text/Text.js.map +0 -1
  151. package/dist/esm/components/builtin/Text/register.js.map +0 -1
  152. package/dist/esm/components/builtin/Video/Video.js +0 -49
  153. package/dist/esm/components/builtin/Video/Video.js.map +0 -1
  154. package/dist/esm/components/builtin/Video/register.js.map +0 -1
  155. package/dist/esm/components/hooks/useTableFormFieldsPropControllerData.js +0 -10
  156. package/dist/esm/components/hooks/useTablePropControllerData.js +0 -12
  157. package/dist/esm/components/hooks/useTextAreaPropControllerData.js +0 -12
  158. package/dist/esm/components/hooks/useTextInputPropControllerData.js +0 -10
  159. package/dist/esm/components/hooks/useTextStylePropControllerData.js +0 -12
  160. package/dist/esm/components/hooks/useVideoPropControllerData.js +0 -12
  161. package/dist/esm/components/icons/Warning20.js +0 -15
  162. package/dist/esm/controls/rich-text-v2/translations/merge-translations.js.map +0 -1
  163. package/dist/esm/controls/rich-text-v2/translations/translations-core.js.map +0 -1
  164. package/dist/esm/controls/serialization/base/visitor.js +0 -39
  165. package/dist/esm/controls/serialization/base/visitor.js.map +0 -1
  166. package/dist/esm/controls/serialization/message-port/visitor.js +0 -24
  167. package/dist/esm/controls/serialization/message-port/visitor.js.map +0 -1
  168. package/dist/esm/next/api-handler/config/pages-router.js.map +0 -1
  169. package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js.map +0 -1
  170. package/dist/esm/next/components/tests/__fixtures__/page-document.js.map +0 -1
  171. package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +0 -1
  172. package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js.map +0 -1
  173. package/dist/esm/next/components/tests/controls/fixtures/rich-text-v2.js.map +0 -1
  174. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +0 -1
  175. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +0 -1
  176. package/dist/esm/next/hooks/use-router-locale-sync.js.map +0 -1
  177. package/dist/esm/next/tests/__fixtures__/resources.js.map +0 -1
  178. package/dist/esm/next/tests/__fixtures__/translated-data.js.map +0 -1
  179. package/dist/esm/react/builtins/video.js +0 -7
  180. package/dist/esm/react/builtins/video.js.map +0 -1
  181. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +0 -1
  182. package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +0 -1
  183. package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +0 -1
  184. package/dist/esm/runtimes/react/components/Slot.js.map +0 -1
  185. package/dist/esm/runtimes/react/components/SlotProvider.js.map +0 -1
  186. package/dist/esm/runtimes/react/components/hooks/use-framework-context.js.map +0 -1
  187. package/dist/esm/runtimes/react/components/hooks/use-page-snippets.js.map +0 -1
  188. package/dist/esm/runtimes/react/components/page/Page.js.map +0 -1
  189. package/dist/esm/runtimes/react/components/page/PageHead.js.map +0 -1
  190. package/dist/esm/runtimes/react/components/page/page-seo-settings.js.map +0 -1
  191. package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js.map +0 -1
  192. package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js.map +0 -1
  193. package/dist/esm/runtimes/react/components/render-hook.js.map +0 -1
  194. package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.js +0 -39
  195. package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.js.map +0 -1
  196. package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +0 -35
  197. package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +0 -1
  198. package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js.map +0 -1
  199. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +0 -1
  200. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +0 -1
  201. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +0 -1
  202. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +0 -1
  203. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.js.map +0 -1
  204. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js +0 -39
  205. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js.map +0 -1
  206. package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +0 -1
  207. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +0 -1
  208. package/dist/esm/runtimes/react/controls/slot.js.map +0 -1
  209. package/dist/esm/runtimes/react/controls/style.js.map +0 -1
  210. package/dist/esm/runtimes/react/controls/typography.js.map +0 -1
  211. package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +0 -1
  212. package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +0 -1
  213. package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +0 -1
  214. package/dist/esm/runtimes/react/hooks/use-builtin-suspense.js.map +0 -1
  215. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +0 -1
  216. package/dist/esm/runtimes/react/hooks/use-component.js.map +0 -1
  217. package/dist/esm/runtimes/react/hooks/use-css-id.js.map +0 -1
  218. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +0 -1
  219. package/dist/esm/runtimes/react/hooks/use-disable-register-element.js.map +0 -1
  220. package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +0 -1
  221. package/dist/esm/runtimes/react/hooks/use-document-context.js.map +0 -1
  222. package/dist/esm/runtimes/react/hooks/use-document-cycles.js.map +0 -1
  223. package/dist/esm/runtimes/react/hooks/use-document.js.map +0 -1
  224. package/dist/esm/runtimes/react/hooks/use-element-id.js.map +0 -1
  225. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +0 -1
  226. package/dist/esm/runtimes/react/hooks/use-is-read-only.js.map +0 -1
  227. package/dist/esm/runtimes/react/hooks/use-react-runtime.js.map +0 -1
  228. package/dist/esm/runtimes/react/hooks/use-register-document.js.map +0 -1
  229. package/dist/esm/runtimes/react/hooks/use-resolvable-record.js.map +0 -1
  230. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +0 -1
  231. package/dist/esm/runtimes/react/hooks/use-resolved-value.js.map +0 -1
  232. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +0 -1
  233. package/dist/esm/runtimes/react/hooks/use-selector.js.map +0 -1
  234. package/dist/esm/runtimes/react/hooks/use-store.js.map +0 -1
  235. package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +0 -1
  236. package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +0 -1
  237. package/dist/esm/runtimes/react/lib/react-dom.js.map +0 -1
  238. package/dist/esm/runtimes/react/root-style-registry.js +10 -1
  239. package/dist/esm/runtimes/react/root-style-registry.js.map +1 -1
  240. package/dist/esm/runtimes/react/testing/react-runtime.js.map +0 -1
  241. package/dist/esm/runtimes/react/use-global-style.js.map +0 -1
  242. package/dist/esm/runtimes/react/use-style.js.map +0 -1
  243. package/dist/esm/runtimes/react/utils/prop-error-handling-proxy.js.map +0 -1
  244. package/dist/esm/runtimes/react/utils/suppress-ref-warning.js.map +0 -1
  245. package/dist/esm/slate/BlockPlugin/utils/location.js.map +0 -1
  246. package/dist/esm/slate/BlockPlugin/wrapInline.js +0 -12
  247. package/dist/esm/slate/BlockPlugin/wrapInline.js.map +0 -1
  248. package/dist/esm/slate/BlockPlugin/wrapList.js +0 -44
  249. package/dist/esm/slate/BlockPlugin/wrapList.js.map +0 -1
  250. package/dist/esm/slate/utils/responsive.js.map +0 -1
  251. package/dist/esm/slate/utils/toText.js.map +0 -1
  252. package/dist/esm/slate/utils/unhangRange.js.map +0 -1
  253. package/dist/esm/state/actions/internal/read-only-actions.js.map +0 -1
  254. package/dist/esm/state/actions/internal/read-write-actions.js.map +0 -1
  255. package/dist/esm/state/builder-api/proxy.js.map +0 -1
  256. package/dist/esm/state/middleware/read-only-element-tree.js.map +0 -1
  257. package/dist/esm/state/middleware/read-write/measure-box-models.js.map +0 -1
  258. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +0 -1
  259. package/dist/esm/state/middleware/read-write/update-element-tree.js.map +0 -1
  260. package/dist/esm/state/modules/prop-controllers.js.map +0 -1
  261. package/dist/esm/state/modules/react-components.js.map +0 -1
  262. package/dist/esm/state/modules/read-only-documents.js.map +0 -1
  263. package/dist/esm/state/modules/read-write/pointer.js.map +0 -1
  264. package/dist/esm/state/modules/read-write/read-write-documents.js.map +0 -1
  265. package/dist/esm/state/modules/site-version.js.map +0 -1
  266. package/dist/esm/unstable-framework-support/index.js +2 -0
  267. package/dist/esm/unstable-framework-support/index.js.map +1 -1
  268. package/dist/types/runtimes/react/root-style-registry.d.ts +1 -0
  269. package/dist/types/runtimes/react/root-style-registry.d.ts.map +1 -1
  270. package/dist/types/unstable-framework-support/index.d.ts +1 -1
  271. package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
  272. package/package.json +3 -3
@@ -1,35 +0,0 @@
1
- import { useState, useEffect, useCallback } from "react";
2
- import { richTextDTOtoDAO, richTextDTOtoSelection } from "@makeswift/controls";
3
- import { useIsInBuilder } from "../../../hooks/use-is-in-builder";
4
- import deepEqual from "../../../../../utils/deepEqual";
5
- const COMMIT_DEBOUNCE_DELAY = 500;
6
- function useSyncWithBuilder(editor, text) {
7
- const [shouldCommit, setShouldCommit] = useState(true);
8
- const isInBuilder = useIsInBuilder();
9
- useEffect(() => {
10
- if (shouldCommit && text && isInBuilder) {
11
- const nextValue = richTextDTOtoDAO(text);
12
- const nextSelection = richTextDTOtoSelection(text);
13
- if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {
14
- editor.children = nextValue;
15
- editor.selection = nextSelection;
16
- editor.onChange();
17
- }
18
- }
19
- }, [editor, shouldCommit, text]);
20
- useEffect(() => {
21
- if (shouldCommit)
22
- return;
23
- const timeoutId = window.setTimeout(() => {
24
- setShouldCommit(true);
25
- }, COMMIT_DEBOUNCE_DELAY);
26
- return () => {
27
- window.clearTimeout(timeoutId);
28
- };
29
- }, [shouldCommit]);
30
- return useCallback(() => setShouldCommit(false), []);
31
- }
32
- export {
33
- useSyncWithBuilder
34
- };
35
- //# sourceMappingURL=useSyncWithBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { type RichTextDTO, richTextDTOtoDAO, richTextDTOtoSelection } from '@makeswift/controls'\n\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextDTO) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n"],"mappings":"AAAA,SAAS,UAAU,WAAW,mBAAmB;AAEjD,SAA2B,kBAAkB,8BAA8B;AAE3E,SAAS,sBAAsB;AAC/B,OAAO,eAAe;AAEtB,MAAM,wBAAwB;AAMvB,SAAS,mBAAmB,QAAgB,MAAoB;AACrE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,IAAI;AACrD,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QAAI,gBAAgB,QAAQ,aAAa;AACvC,YAAM,YAAY,iBAAiB,IAAI;AACvC,YAAM,gBAAgB,uBAAuB,IAAI;AACjD,UAAI,CAAC,UAAU,OAAO,UAAU,SAAS,KAAK,CAAC,UAAU,OAAO,WAAW,aAAa,GAAG;AACzF,eAAO,WAAW;AAClB,eAAO,YAAY;AACnB,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,cAAc,IAAI,CAAC;AAE/B,YAAU,MAAM;AACd,QAAI;AAAc;AAElB,UAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAgB,IAAI;AAAA,IACtB,GAAG,qBAAqB;AAExB,WAAO,MAAM;AACX,aAAO,aAAa,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO,YAAY,MAAM,gBAAgB,KAAK,GAAG,CAAC,CAAC;AACrD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate/types'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"mappings":"AA0CoC,SA8KhC,UA9KgC;AA1CpC,SAAS,UAAU;AACnB,SAAuB,kBAAkB;AAGzC,SAAS,OAAsB,wBAAwB;AAEvD,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB;AACtC,SAAS,gBAAgB;AACzB,OAAO,yBAAyB,8BAA8B;AAC9D,SAAS,YAAY;AASrB,MAAM,eAAe,WAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM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,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","descendant"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/rich-text.tsx"],"sourcesContent":["import { ReactNode, lazy, useCallback } from 'react'\n\nimport { type DataType } from '@makeswift/controls'\nimport { RichTextV1Control, RichTextV1Definition } from '../../../../controls/rich-text'\n\nimport {\n isPropControllersHandle,\n PropControllersHandle,\n} from '../../../../state/modules/prop-controller-handles'\n\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nconst EditableText = lazy(() => import('./EditableText'))\nconst ReadOnlyText = lazy(() => import('./ReadOnlyText'))\n\nexport type RichTextControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV1Definition }\n\nexport function renderRichText(\n data: DataType<RichTextV1Definition> | undefined,\n control: RichTextV1Control | null,\n) {\n return <RichText data={data} control={control} />\n}\n\nfunction RichText({\n data,\n control,\n}: {\n data: DataType<RichTextV1Definition> | undefined\n control: RichTextV1Control | null\n}) {\n const textCallbackRef = useCallback(\n (handle: PropControllersHandle<Descriptors> | HTMLDivElement | null) => {\n if (isPropControllersHandle(handle))\n handle?.setPropControllers?.(control == null ? null : { text: control })\n },\n [control],\n )\n\n return useIsReadOnly() ? (\n <ReadOnlyText text={data} ref={textCallbackRef} />\n ) : (\n <EditableText text={data} ref={textCallbackRef} />\n )\n}\n"],"mappings":"AAuBS;AAvBT,SAAoB,MAAM,mBAAmB;AAK7C;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,qBAAqB;AAE9B,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AACxD,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AAMjD,SAAS,eACd,MACA,SACA;AACA,SAAO,oBAAC,YAAS,MAAY,SAAkB;AACjD;AAEA,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AACF,GAGG;AACD,QAAM,kBAAkB;AAAA,IACtB,CAAC,WAAuE;AACtE,UAAI,wBAAwB,MAAM;AAChC,gBAAQ,qBAAqB,WAAW,OAAO,OAAO,EAAE,MAAM,QAAQ,CAAC;AAAA,IAC3E;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,cAAc,IACnB,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB,IAEhD,oBAAC,gBAAa,MAAM,MAAM,KAAK,iBAAiB;AAEpD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx"],"sourcesContent":["import { RenderElementProps } from 'slate-react'\n\nimport { RichTextV2Definition } from '../../../../../controls/rich-text-v2'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2Definition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return props.children\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n"],"mappings":"AA2BQ;AAtBR,SAAS,oBAAoB;AAOtB,SAAS,kBAAkB,EAAE,YAAY,SAAS,GAAG,MAAM,GAA2B;AAC3F,WAAS,qBAAqBA,QAA2B;AACvD,WAAOA,OAAM;AAAA,EACf;AAEA,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,UAAU,WAAW,CAACA,WAA8B;AACnD,YAAM,EAAE,SAAS,eAAAC,eAAc,IAAI;AAEnC,UAAIA,kBAAiB;AAAM,eAAO,SAASD,MAAK;AAEhD,UAAI,WAAW,QAAQ,QAAQ,mBAAmB;AAChD,eAAOC,eAAc,UAAU,MAAS,EAAED,MAAK;AAEjD,aACE,oBAAC,gBAAa,YAAY,QAAQ,YAAY,MAAM,QAAQ,gBAAgBA,OAAM,OAAO,GACtF,qBAASC,eAAc,UAAU,KAAK,EAAED,MAAK,GAChD;AAAA,IAEJ;AAAA,IACA;AAAA,EACF;AAEA,SAAO,cAAc,KAAK;AAC5B;","names":["props","renderElement"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { RenderLeafProps } from 'slate-react'\nimport { RichTextV2Definition } from '../../../../../controls/rich-text-v2'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2Definition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps): ReactNode {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n"],"mappings":"AAcM;AAVN,SAAS,oBAAoB;AAOtB,SAAS,eAAe,EAAE,YAAY,SAAS,GAAG,MAAM,GAAwB;AACrF,WAAS,kBAAkB,EAAE,YAAY,UAAU,KAAK,GAA+B;AACrF,WACE,oBAAC,UAAK,WAAW,KAAK,WAAY,GAAG,YAClC,UACH;AAAA,EAEJ;AAEA,QAAM,aAAa,QAAQ;AAAA,IACzB,CAAC,UAAU,WAAW,CAACA,WAA2B;AAChD,YAAM,EAAE,SAAS,YAAAC,YAAW,IAAI;AAEhC,UAAI,SAAS,cAAc,QAAQA,eAAc;AAAM,eAAO,SAASD,MAAK;AAE5E,UAAI,QAAQ,gBAAgB;AAAM,eAAOC,YAAW,UAAU,MAAS,EAAED,MAAK;AAE9E,aACE,oBAAC,gBAAa,YAAY,QAAQ,YAAY,MAAM,QAAQ,aAAaA,OAAM,IAAI,GAChF,qBAASC,YAAW,UAAU,KAAK,EAAED,MAAK,GAC7C;AAAA,IAEJ;AAAA,IACA;AAAA,EACF;AAEA,SAAO,WAAW,KAAK;AACzB;","names":["props","renderLeaf"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { Descendant } from 'slate'\nimport { Slate, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../../hooks/use-breakpoints'\nimport { RichTextV2Definition, RichText } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2Definition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichText.Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\n]\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,SAAS,OAAO,yBAAyB;AAEzC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA+B,gBAAgB;AAExC,SAAS,eAAe,YAAgD;AAC7E,QAAM,cAAc,eAAe;AACnC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM,MAAM,UAAU;AAAA,QACtB,UAAU;AAAA,UACR;AAAA,YACE,MAAM,WAAW,OAAO,gBAAgB;AAAA,YACxC,GAAI,WAAW,OAAO,SAAS,SAAS,KAAK,SACzC,CAAC,IACD;AAAA,cACE,YAAY;AAAA,gBACV,OAAO;AAAA,kBACL;AAAA,oBACE,UAAU,kBAAkB,WAAW,EAAE;AAAA,oBACzC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,sBAClC,YAAY;AAAA,oBACd;AAAA,kBACF;AAAA,kBACA,GAAI,YAAY,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,oBAAoB,MAAM,IAC9D;AAAA,oBACE;AAAA,sBACE,UAAU,oBAAoB;AAAA,sBAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK,EAAE;AAAA,oBAC/C;AAAA,kBACF,IACA,CAAC;AAAA,gBACP;AAAA,cACF;AAAA,YACF;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,OAAO,MAAM,WAAW,OAAO,cAAc,WAAW;AAAA,EACtE;AACF;AAEO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM,MAAM,UAAU;AAAA,IACtB,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { Editor } from 'slate'\n\nimport { RichText, RichTextDataV2 } from '../../../../../controls/rich-text-v2'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextDataV2) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = RichText.dataToNodes(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgC;AAEzC,SAAS,sBAAsB;AAI/B,SAAS,0BAA0B,QAAsB;AACvD,SAAO,YAAY,IAAI,KAAK,QAAQ,QAAQ,KAAK;AACnD;AAEO,SAAS,qBAAqB,QAAgB,MAAuB;AAC1E,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QACE,CAAC,0BAA0B,OAAO,aAAa,IAAI,MAAM,OAAO,EAAE,CAAC,KACnE,QACA,aACA;AACA,aAAO,WAAW,SAAS,YAAY,IAAI;AAC3C,aAAO,YAAY,QAAQ,aAAa,IAAI,KAAK,GAAG,GAAG,aAAa;AACpE,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,QAAQ,IAAI,CAAC;AACnB;","names":[]}
@@ -1,39 +0,0 @@
1
- import { Range as SlateRange } from "slate";
2
- import { useIsomorphicLayoutEffect } from "../../../../../components/hooks/useIsomorphicLayoutEffect";
3
- import { ReactEditor } from "slate-react";
4
- function useSyncDOMSelection(editor, isEnabled) {
5
- useIsomorphicLayoutEffect(() => {
6
- if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor))
7
- return;
8
- try {
9
- const root = ReactEditor.findDocumentOrShadowRoot(editor);
10
- const domSelection = root.getSelection();
11
- const newDomRange = ReactEditor.toDOMRange(editor, editor.selection);
12
- if (newDomRange) {
13
- if (SlateRange.isBackward(editor.selection)) {
14
- domSelection?.setBaseAndExtent(
15
- newDomRange.endContainer,
16
- newDomRange.endOffset,
17
- newDomRange.startContainer,
18
- newDomRange.startOffset
19
- );
20
- } else {
21
- domSelection?.setBaseAndExtent(
22
- newDomRange.startContainer,
23
- newDomRange.startOffset,
24
- newDomRange.endContainer,
25
- newDomRange.endOffset
26
- );
27
- }
28
- } else {
29
- domSelection?.removeAllRanges();
30
- }
31
- } catch (e) {
32
- console.error(e);
33
- }
34
- });
35
- }
36
- export {
37
- useSyncDOMSelection
38
- };
39
- //# sourceMappingURL=useSyncDOMSelection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n"],"mappings":"AAAA,SAAiB,SAAS,kBAAkB;AAC5C,SAAS,iCAAiC;AAE1C,SAAS,mBAAmB;AAOrB,SAAS,oBAAoB,QAAgB,WAAsC;AACxF,4BAA0B,MAAM;AAC9B,QAAI,CAAC,UAAU,WAAW,OAAO,aAAa,QAAQ,YAAY,UAAU,MAAM;AAAG;AACrF,QAAI;AACF,YAAM,OAAO,YAAY,yBAAyB,MAAM;AACxD,YAAM,eAAe,KAAK,aAAa;AACvC,YAAM,cAA4B,YAAY,WAAW,QAAQ,OAAO,SAAS;AAEjF,UAAI,aAAa;AACf,YAAI,WAAW,WAAW,OAAO,SAAU,GAAG;AAC5C,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF,OAAO;AACL,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF,OAAO;AACL,sBAAc,gBAAgB;AAAA,MAChC;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport { Descendant, Element, Text } from 'slate'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { toText } from '../../../../slate/utils'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\nimport { ControlValue } from '../control'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps): ReactNode {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps): ReactNode {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf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Y;AAAA,EACnB;AAAA,EACA;AACF,GAGG;AACD,SACE,gCACG,sBAAY,IAAI,CAAC,YAAY,UAAU;AACtC,QAAI,OAAO,UAAU,GAAG;AACtB,aAAO,oBAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,oBAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["props","renderLeaf","renderElement"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/rich-text-v2.tsx"],"sourcesContent":["import { ReactNode, lazy } from 'react'\n\nimport { type DataType } from '@makeswift/controls'\nimport {\n RichTextV2Control,\n RichTextV2Definition,\n RichTextDataV2,\n} from '../../../../controls/rich-text-v2'\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2Definition }\n\nconst EditableText = lazy(() => import('./EditableTextV2'))\nconst ReadOnlyText = lazy(() => import('./ReadOnlyTextV2'))\n\nconst ReadOnlyTextV1 = lazy(() => import('../rich-text/ReadOnlyText'))\n\nexport function renderRichTextV2(\n data: DataType<RichTextV2Definition> | undefined,\n definition: RichTextV2Definition,\n control: RichTextV2Control | null,\n): ReactNode {\n return RichTextV2Definition.isV1Data(data) ? (\n <ReadOnlyTextV1 text={data} />\n ) : (\n <RichTextV2 data={data} definition={definition} control={control} />\n )\n}\n\nfunction RichTextV2({\n data,\n definition,\n control,\n}: {\n data: RichTextDataV2 | undefined\n definition: RichTextV2Definition\n control: RichTextV2Control | null\n}) {\n return useIsReadOnly() ? (\n <ReadOnlyText text={data} definition={definition} />\n ) : (\n <EditableText text={data} definition={definition} control={control} />\n )\n}\n"],"mappings":"AAyBI;AAzBJ,SAAoB,YAAY;AAGhC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,qBAAqB;AAM9B,MAAM,eAAe,KAAK,MAAM,OAAO,kBAAkB,CAAC;AAC1D,MAAM,eAAe,KAAK,MAAM,OAAO,kBAAkB,CAAC;AAE1D,MAAM,iBAAiB,KAAK,MAAM,OAAO,2BAA2B,CAAC;AAE9D,SAAS,iBACd,MACA,YACA,SACW;AACX,SAAO,qBAAqB,SAAS,IAAI,IACvC,oBAAC,kBAAe,MAAM,MAAM,IAE5B,oBAAC,cAAW,MAAY,YAAwB,SAAkB;AAEtE;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SAAO,cAAc,IACnB,oBAAC,gBAAa,MAAM,MAAM,YAAwB,IAElD,oBAAC,gBAAa,MAAM,MAAM,YAAwB,SAAkB;AAExE;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/controls/slot.tsx"],"sourcesContent":["'use client'\n\nimport { ComponentPropsWithoutRef, ElementType, ReactNode, useEffect, useState, memo } from 'react'\nimport { cx } from '@emotion/css'\n\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../controls/slot'\nimport { Element } from '../components/Element'\nimport { useIsInBuilder } from '../hooks/use-is-in-builder'\nimport { getIndexes } from '../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../components/utils/responsive-style'\nimport { useStyle } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport function renderSlot(props: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n return <SlotValue {...props} />\n}\n\nconst SlotValue = memo(\n ({\n data,\n control,\n config,\n }: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n }): ReactNode => {\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n },\n)\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)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{"version":3,"sources":["../../../../../src/runtimes/react/controls/style.ts"],"sourcesContent":["import { type CSSObject } from '@emotion/serialize'\nimport {\n Style,\n type StyleProperty,\n type ResolvedBorderSideData,\n type FontSizePropertyData,\n type WidthPropertyData,\n type ResolvedStyleData,\n} from '@makeswift/controls'\n\nimport { colorToString } from '../../../components/utils/colorToString'\nimport { responsiveStyle } from '../../../components/utils/responsive-style'\n\nimport { BorderRadiusLonghandPropertyData } from '../../../css/border-radius'\nimport { lengthPercentageDataToString } from '../../../css/length-percentage'\nimport { marginPropertyDataToStyle } from '../../../css/margin'\nimport { paddingPropertyDataToStyle } from '../../../css/padding'\nimport { Breakpoints } from '../../../state/modules/breakpoints'\n\nconst defaultMargin = {\n marginTop: 0,\n marginRight: 'auto',\n marginBottom: 0,\n marginLeft: 'auto',\n}\n\nconst defaultPadding = {\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n}\n\nexport function styleV1Css(\n breakpoints: Breakpoints,\n style: ResolvedStyleData | undefined,\n properties: StyleProperty[],\n): CSSObject {\n return {\n ...(properties.includes(Style.Width) && {\n maxWidth: '100%',\n }),\n ...responsiveStyle(\n breakpoints,\n [\n style?.width,\n style?.margin,\n style?.padding,\n style?.border,\n style?.borderRadius,\n style?.textStyle,\n ] as const,\n ([width, margin, padding, border, borderRadius, textStyle]) => ({\n ...(properties.includes(Style.Width) && {\n width: widthToString(width) ?? '100%',\n }),\n ...(properties.includes(Style.Margin) &&\n marginPropertyDataToStyle(margin ?? defaultMargin, defaultMargin)),\n ...(properties.includes(Style.Padding) &&\n paddingPropertyDataToStyle(padding ?? defaultPadding, defaultPadding)),\n ...(properties.includes(Style.Border) && {\n borderTop: borderSideToString(border?.borderTop) ?? '0 solid black',\n borderRight: borderSideToString(border?.borderRight) ?? '0 solid black',\n borderBottom: borderSideToString(border?.borderBottom) ?? '0 solid black',\n borderLeft: borderSideToString(border?.borderLeft) ?? '0 solid black',\n }),\n ...(properties.includes(Style.BorderRadius) && {\n borderTopLeftRadius: borderRadiusToString(borderRadius?.borderTopLeftRadius) ?? 0,\n borderTopRightRadius: borderRadiusToString(borderRadius?.borderTopRightRadius) ?? 0,\n borderBottomRightRadius: borderRadiusToString(borderRadius?.borderBottomRightRadius) ?? 0,\n borderBottomLeftRadius: borderRadiusToString(borderRadius?.borderBottomLeftRadius) ?? 0,\n }),\n ...(properties.includes(Style.TextStyle) && {\n ...(textStyle?.fontFamily && { \n fontFamily: textStyle.fontFamily.toLowerCase().startsWith('var(') \n ? textStyle.fontFamily \n : `\"${textStyle.fontFamily}\"` \n }),\n ...(textStyle?.letterSpacing && { letterSpacing: textStyle.letterSpacing }),\n ...(textStyle?.fontSize && { fontSize: fontSizeToString(textStyle.fontSize) }),\n ...(textStyle?.fontWeight && { fontWeight: textStyle.fontWeight }),\n textTransform: textStyle?.textTransform ?? [],\n fontStyle: textStyle?.fontStyle ?? [],\n }),\n }),\n ),\n }\n\n function widthToString(widthProperty: WidthPropertyData | undefined): string | null {\n if (widthProperty == null) return null\n\n return lengthPercentageDataToString(widthProperty)\n }\n\n function borderSideToString(\n borderSide: ResolvedBorderSideData | null | undefined,\n ): string | null {\n if (borderSide == null) return null\n\n const { width, color, style } = borderSide\n return `${width != null ? width : 0}px ${style} ${\n color != null ? colorToString(color) : 'black'\n }`\n }\n\n function borderRadiusToString(\n borderRadius: BorderRadiusLonghandPropertyData | null | undefined,\n ): string | null {\n if (borderRadius == null) return null\n\n return lengthPercentageDataToString(borderRadius)\n }\n\n function fontSizeToString(fontSize: NonNullable<FontSizePropertyData>) {\n return `${fontSize.value}${fontSize.unit}`\n }\n}\n"],"mappings":"AACA;AAAA,EACE;AAAA,OAMK;AAEP,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAGhC,SAAS,oCAAoC;AAC7C,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAG3C,MAAM,gBAAgB;AAAA,EACpB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AA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AM,SAAS,KAAK;AAAA,UAC1C,GAAI,WAAW,cAAc;AAAA,YAC3B,YAAY,UAAU,WAAW,YAAY,EAAE,WAAW,MAAM,IAC5D,UAAU,aACV,IAAI,UAAU,UAAU;AAAA,UAC9B;AAAA,UACA,GAAI,WAAW,iBAAiB,EAAE,eAAe,UAAU,cAAc;AAAA,UACzE,GAAI,WAAW,YAAY,EAAE,UAAU,iBAAiB,UAAU,QAAQ,EAAE;AAAA,UAC5E,GAAI,WAAW,cAAc,EAAE,YAAY,UAAU,WAAW;AAAA,UAChE,eAAe,WAAW,iBAAiB,CAAC;AAAA,UAC5C,WAAW,WAAW,aAAa,CAAC;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,WAAS,cAAc,eAA6D;AAClF,QAAI,iBAAiB;AAAM,aAAO;AAElC,WAAO,6BAA6B,aAAa;AAAA,EACnD;AAEA,WAAS,mBACP,YACe;AACf,QAAI,cAAc;AAAM,aAAO;AAE/B,UAAM,EAAE,OAAO,OAAO,OAAAA,OAAM,IAAI;AAChC,WAAO,GAAG,SAAS,OAAO,QAAQ,CAAC,MAAMA,MAAK,IAC5C,SAAS,OAAO,cAAc,KAAK,IAAI,OACzC;AAAA,EACF;AAEA,WAAS,qBACP,cACe;AACf,QAAI,gBAAgB;AAAM,aAAO;AAEjC,WAAO,6BAA6B,YAAY;AAAA,EAClD;AAEA,WAAS,iBAAiB,UAA6C;AACrE,WAAO,GAAG,SAAS,KAAK,GAAG,SAAS,IAAI;AAAA,EAC1C;AACF;","names":["style"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/controls/typography.ts"],"sourcesContent":["import { CSSObject } from '@emotion/serialize'\nimport {\n unstable_TypographyDefinition,\n findBreakpointOverride,\n shallowMergeFallbacks,\n type DataType,\n type Breakpoints,\n type DeviceOverride,\n type ResponsiveValue,\n} from '@makeswift/controls'\n\nimport { useSwatches, useTypography } from '../hooks/makeswift-api'\nimport { Typography, Swatch } from '../../../api'\nimport { colorToString } from '../../../components/utils/colorToString'\nimport { responsiveStyle } from '../../../components/utils/responsive-style'\nimport { ColorValue } from '../../../components/utils/types'\nimport { isNonNullable } from '../../../utils/isNonNullable'\nimport { useStyle } from '../use-style'\nimport { useBreakpoints } from '../hooks/use-breakpoints'\n\nexport function typographyFragementToTypographyControlData(\n fragment: Typography | null,\n): DataType<unstable_TypographyDefinition> | undefined {\n if (fragment == null) return undefined\n return {\n id: fragment.id,\n style: fragment.style.map(({ deviceId, value }) => ({\n deviceId,\n value: {\n fontFamily: value.fontFamily ?? undefined,\n lineHeight: value.lineHeight ?? undefined,\n letterSpacing: value.letterSpacing ?? undefined,\n fontWeight: value.fontWeight ?? undefined,\n textAlign: value.textAlign ?? undefined,\n uppercase: value.uppercase ?? undefined,\n underline: value.underline ?? undefined,\n strikethrough: value.strikethrough ?? undefined,\n italic: value.italic ?? undefined,\n fontSize: value.fontSize ?? undefined,\n color: value.color ?? undefined,\n },\n })),\n }\n}\n\ntype EnhancedColor = {\n color?: ColorValue\n}\n\nexport type TypographyControlDataValue = Exclude<\n DataType<unstable_TypographyDefinition>,\n undefined\n>['style'][number]['value']\n\ntype EnhancedTypographyValue = Omit<TypographyControlDataValue, keyof EnhancedColor> & EnhancedColor\n\nexport type EnhancedTypography = Array<DeviceOverride<EnhancedTypographyValue>>\n\nexport function getTypographyStyleSwatchIds(\n style:\n | Exclude<DataType<unstable_TypographyDefinition>, undefined>['style']\n | Typography['style']\n | null\n | undefined,\n): string[] {\n return (\n style\n ?.map(override => override.value)\n .flatMap(typographyStyle => typographyStyle.color?.swatchId)\n .filter(isNonNullable) ?? []\n )\n}\n\nconst withColor =\n (swatches: Swatch[]) =>\n (\n deviceRawTypographyValue: DeviceOverride<TypographyControlDataValue>,\n ): DeviceOverride<EnhancedTypographyValue> => {\n const { value, deviceId } = deviceRawTypographyValue\n\n if (value.color == null) {\n const { color, ...nextValue } = value\n return {\n deviceId,\n value: nextValue,\n }\n }\n return {\n deviceId,\n value: {\n ...value,\n color: {\n swatch: swatches.find(s => s && s.id === value.color?.swatchId),\n alpha: value.color?.alpha ?? undefined,\n },\n },\n }\n }\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\n/**\n * `enhanced` here just means typography ids have been replaced with the related entity.\n */\nexport default function useEnhancedTypography(\n data?: DataType<unstable_TypographyDefinition> | null,\n): EnhancedTypography {\n const typography = typographyFragementToTypographyControlData(useTypography(data?.id ?? null))\n const source = typography?.style ?? []\n const override = data?.style ?? []\n const breakpoints = useBreakpoints()\n\n const swatchIds = [\n ...getTypographyStyleSwatchIds(data?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds).filter(isNonNullable)\n\n const enhancedSource = source.map(withColor(swatches))\n const enhancedOverride = override.map(withColor(swatches))\n\n const devices = [\n ...new Set(enhancedSource.map(getDeviceId).concat(enhancedOverride.map(getDeviceId))),\n ]\n\n return devices\n .map(deviceId => {\n const deviceSource = findBreakpointOverride(breakpoints, enhancedSource, deviceId)?.value\n const deviceOverride = findBreakpointOverride(\n breakpoints,\n enhancedOverride,\n deviceId,\n v => v,\n )?.value\n\n if (deviceSource && deviceOverride) {\n return {\n deviceId,\n value: { ...deviceSource, ...deviceOverride },\n }\n } else if (deviceOverride) {\n return {\n deviceId,\n value: deviceOverride,\n }\n } else if (deviceSource) {\n return {\n deviceId,\n value: deviceSource,\n }\n }\n return null\n })\n .filter(isNonNullable)\n}\n\nfunction typographyToCssObject(value: EnhancedTypographyValue): CSSObject {\n let styles: CSSObject = {}\n if (value.color != null) styles.color = colorToString(value.color)\n if (value.fontFamily != null) styles.fontFamily = value.fontFamily\n if (value.fontSize != null && value.fontSize.value != null && value.fontSize.unit != null)\n styles.fontSize = `${value.fontSize.value}${value.fontSize.unit}`\n if (value.fontWeight != null) styles.fontWeight = value.fontWeight\n if (value.lineHeight != null) styles.lineHeight = value.lineHeight\n if (value.letterSpacing != null) styles.letterSpacing = `${value.letterSpacing / 10}em`\n if (value.uppercase != null)\n styles.textTransform = value.uppercase === true ? 'uppercase' : 'initial'\n if (value.underline != null || value.strikethrough != null)\n styles.textDecoration = [\n Boolean(value.underline) && 'underline',\n Boolean(value.strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' ')\n if (value.italic != null) styles.fontStyle = value.italic === true ? 'italic' : 'initial'\n\n return styles\n}\n\nexport function typographyCss(breakpoints: Breakpoints, style: EnhancedTypography): CSSObject {\n return responsiveStyle<\n EnhancedTypographyValue,\n [ResponsiveValue<EnhancedTypographyValue> | null | undefined]\n >(\n breakpoints,\n [style],\n ([value]) => (value !== undefined ? typographyToCssObject(value) : {}),\n shallowMergeFallbacks,\n )\n}\n\nexport function useTypographyClassName(value: EnhancedTypography): string {\n const breakpoints = useBreakpoints()\n return useStyle(typographyCss(breakpoints, value))\n}\n"],"mappings":"AACA;AAAA,EAEE;AAAA,EACA;AAAA,OAKK;AAEP,SAAS,aAAa,qBAAqB;AAE3C,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAExB,SAAS,2CACd,UACqD;AACrD,MAAI,YAAY;AAAM,WAAO;AAC7B,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,OAAO,SAAS,MAAM,IAAI,CAAC,EAAE,UAAU,MAAM,OAAO;AAAA,MAClD;AAAA,MACA,OAAO;AAAA,QACL,YAAY,MAAM,cAAc;AAAA,QAChC,YAAY,MAAM,cAAc;AAAA,QAChC,eAAe,MAAM,iBAAiB;AAAA,QACtC,YAAY,MAAM,cAAc;AAAA,QAChC,WAAW,MAAM,aAAa;AAAA,QAC9B,WAAW,MAAM,aAAa;AAAA,QAC9B,WAAW,MAAM,aAAa;AAAA,QAC9B,eAAe,MAAM,iBAAiB;AAAA,QACtC,QAAQ,MAAM,UAAU;AAAA,QACxB,UAAU,MAAM,YAAY;AAAA,QAC5B,OAAO,MA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AG;AACb,MAAI,MAAM,UAAU;AAAM,WAAO,YAAY,MAAM,WAAW,OAAO,WAAW;AAEhF,SAAO;AACT;AAEO,SAAS,cAAc,aAA0B,OAAsC;AAC5F,SAAO;AAAA,IAIL;AAAA,IACA,CAAC,KAAK;AAAA,IACN,CAAC,CAAC,KAAK,MAAO,UAAU,SAAY,sBAAsB,KAAK,IAAI,CAAC;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,OAAmC;AACxE,QAAM,cAAc,eAAe;AACnC,SAAO,SAAS,cAAc,aAAa,KAAK,CAAC;AACnD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/makeswift-api.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\nimport {\n File,\n GlobalElement,\n LocalizedGlobalElement,\n PagePathnameSlice,\n Swatch,\n Table,\n Typography,\n} from '../../../api'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useDocumentLocale } from './use-document-context'\n\nexport function useSwatch(swatchId: string | null): Swatch | null {\n const client = useMakeswiftHostApiClient()\n const readSwatch = () => (swatchId == null ? null : client.readSwatch(swatchId))\n const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch)\n\n useEffect(() => {\n if (swatchId != null) client.fetchSwatch(swatchId).catch(console.error)\n }, [client, swatchId])\n\n return swatch\n}\n\nexport function useSwatches(swatchIds: string[]): (Swatch | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(Swatch | null)[] | null>(null)\n\n function getSnapshot() {\n const swatches = swatchIds.map(swatchId => client.readSwatch(swatchId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === swatches.length &&\n lastSnapshot.current.every((swatch, idx) => swatches[idx] === swatch)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = swatches)\n }\n\n const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(swatchIds.map(swatchId => client.fetchSwatch(swatchId))).catch(console.error)\n }, [client, swatchIds])\n\n return swatches\n}\n\nexport function useFile(fileId: string | null): File | null {\n const client = useMakeswiftHostApiClient()\n const readFile = () => (fileId == null ? null : client.readFile(fileId))\n const file = useSyncExternalStore(client.subscribe, readFile, readFile)\n\n useEffect(() => {\n if (fileId != null) client.fetchFile(fileId)\n }, [client, fileId])\n\n return file\n}\n\nexport function useFiles(fileIds: string[]): (File | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(File | null)[] | null>(null)\n\n function getSnapshot() {\n const files = fileIds.map(fileId => client.readFile(fileId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === files.length &&\n lastSnapshot.current.every((file, idx) => files[idx] === file)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = files)\n }\n\n const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(fileIds.map(fileId => client.fetchFile(fileId))).catch(console.error)\n }, [client, fileIds])\n\n return files\n}\n\nexport function useTypography(typographyId: string | null): Typography | null {\n const client = useMakeswiftHostApiClient()\n const readTypography = () => (typographyId == null ? null : client.readTypography(typographyId))\n const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography)\n\n useEffect(() => {\n if (typographyId != null) client.fetchTypography(typographyId).catch(console.error)\n }, [client, typographyId])\n\n return typography\n}\n\nexport function useGlobalElement(globalElementId: string | null): GlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readGlobalElement = () =>\n globalElementId == null ? null : client.readGlobalElement(globalElementId)\n const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement)\n\n useEffect(() => {\n if (globalElementId != null) client.fetchGlobalElement(globalElementId).catch(console.error)\n }, [client, globalElementId])\n\n return globalElement\n}\n\nexport function useLocalizedGlobalElement(\n locale: string | null,\n globalElementId: string | null,\n): LocalizedGlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readLocalizedGlobalElement = () =>\n locale == null || globalElementId == null\n ? null\n : client.readLocalizedGlobalElement({ globalElementId, locale })\n\n const localizedGlobalElement = useSyncExternalStore(\n client.subscribe,\n readLocalizedGlobalElement,\n readLocalizedGlobalElement,\n )\n\n useEffect(() => {\n if (locale != null && globalElementId != null) {\n client.fetchLocalizedGlobalElement({ globalElementId, locale }).catch(console.error)\n }\n }, [client, locale, globalElementId])\n\n return localizedGlobalElement\n}\n\nexport function usePagePathnameSlice(pageId: string | null): PagePathnameSlice | null {\n const client = useMakeswiftHostApiClient()\n const locale = useDocumentLocale()\n\n const readPagePathnameSlice = () =>\n pageId == null ? null : client.readPagePathnameSlice({ pageId, locale })\n\n const pagePathnameSlice = useSyncExternalStore(\n client.subscribe,\n readPagePathnameSlice,\n readPagePathnameSlice,\n )\n\n useEffect(() => {\n if (pageId != null) client.fetchPagePathnameSlice({ pageId, locale }).catch(console.error)\n }, [client, pageId, locale])\n\n return pagePathnameSlice\n}\n\nexport function useTable(tableId: string | null): Table | null {\n const client = useMakeswiftHostApiClient()\n const readTable = () => (tableId == null ? null : client.readTable(tableId))\n const table = useSyncExternalStore(client.subscribe, readTable, readTable)\n\n useEffect(() => {\n if (tableId != null) client.fetchTable(tableId).catch(console.error)\n }, [client, tableId])\n\n return table\n}\n"],"mappings":";AAEA,SAAS,WAAW,QAAQ,4BAA4B;AAWxD,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAE3B,SAAS,UAAU,UAAwC;AAChE,QAAM,SAAS,0BAA0B;AACzC,QAAM,aAAa,MAAO,YAAY,OAAO,OAAO,OAAO,WAAW,QAAQ;AAC9E,QAAM,SAAS,qBAAqB,OAAO,WAAW,YAAY,UAAU;AAE5E,YAAU,MAAM;AACd,QAAI,YAAY;AAAM,aAAO,YAAY,QAAQ,EAAE,MAAM,QAAQ,KAAK;AAAA,EACxE,GAAG,CAAC,QAAQ,QAAQ,CAAC;AAErB,SAAO;AACT;AAEO,SAAS,YAAY,WAAw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;AAAA,IACrF;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,eAAe,CAAC;AAEpC,SAAO;AACT;AAEO,SAAS,qBAAqB,QAAiD;AACpF,QAAM,SAAS,0BAA0B;AACzC,QAAM,SAAS,kBAAkB;AAEjC,QAAM,wBAAwB,MAC5B,UAAU,OAAO,OAAO,OAAO,sBAAsB,EAAE,QAAQ,OAAO,CAAC;AAEzE,QAAM,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd,QAAI,UAAU;AAAM,aAAO,uBAAuB,EAAE,QAAQ,OAAO,CAAC,EAAE,MAAM,QAAQ,KAAK;AAAA,EAC3F,GAAG,CAAC,QAAQ,QAAQ,MAAM,CAAC;AAE3B,SAAO;AACT;AAEO,SAAS,SAAS,SAAsC;AAC7D,QAAM,SAAS,0BAA0B;AACzC,QAAM,YAAY,MAAO,WAAW,OAAO,OAAO,OAAO,UAAU,OAAO;AAC1E,QAAM,QAAQ,qBAAqB,OAAO,WAAW,WAAW,SAAS;AAEzE,YAAU,MAAM;AACd,QAAI,WAAW;AAAM,aAAO,WAAW,OAAO,EAAE,MAAM,QAAQ,KAAK;AAAA,EACrE,GAAG,CAAC,QAAQ,OAAO,CAAC;AAEpB,SAAO;AACT;","names":["swatches","files"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-async-effect.ts"],"sourcesContent":["import { type DependencyList, useEffect } from 'react'\n\nexport function useAsyncEffect(effect: () => Promise<void | (() => void)>, deps: DependencyList) {\n useEffect(() => {\n let cancelled = false\n let cleanup: void | (() => void) | null = null\n\n const runAsyncEffect = async () => {\n try {\n cleanup = await effect()\n\n if (cancelled) {\n cleanup?.()\n cleanup = null\n }\n } catch (error) {\n console.error('Async effect error:', { error, deps })\n }\n }\n\n runAsyncEffect()\n\n return () => {\n cancelled = true\n try {\n cleanup?.()\n } catch (error) {\n console.error('Async effect cleanup error:', { error, deps })\n }\n }\n }, deps)\n}\n"],"mappings":"AAAA,SAA8B,iBAAiB;AAExC,SAAS,eAAe,QAA4C,MAAsB;AAC/F,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,QAAI,UAAsC;AAE1C,UAAM,iBAAiB,YAAY;AACjC,UAAI;AACF,kBAAU,MAAM,OAAO;AAEvB,YAAI,WAAW;AACb,oBAAU;AACV,oBAAU;AAAA,QACZ;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAM,uBAAuB,EAAE,OAAO,KAAK,CAAC;AAAA,MACtD;AAAA,IACF;AAEA,mBAAe;AAEf,WAAO,MAAM;AACX,kBAAY;AACZ,UAAI;AACF,kBAAU;AAAA,MACZ,SAAS,OAAO;AACd,gBAAQ,MAAM,+BAA+B,EAAE,OAAO,KAAK,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,IAAI;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-breakpoints.ts"],"sourcesContent":["import { type Breakpoints } from '../../../state/modules/breakpoints'\nimport { getBreakpoints } from '../../../state/read-only-state'\n\nimport { useSelector } from './use-selector'\n\nexport function useBreakpoints(): Breakpoints {\n return useSelector(state => getBreakpoints(state))\n}\n"],"mappings":"AACA,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAErB,SAAS,iBAA8B;AAC5C,SAAO,YAAY,WAAS,eAAe,KAAK,CAAC;AACnD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-builtin-suspense.ts"],"sourcesContent":["import { useComponentMeta } from './use-component'\n\nexport function useBuiltinSuspense(type: string): boolean {\n const { builtinSuspense } = useComponentMeta(type) ?? {}\n return builtinSuspense ?? true\n}\n"],"mappings":"AAAA,SAAS,wBAAwB;AAE1B,SAAS,mBAAmB,MAAuB;AACxD,QAAM,EAAE,gBAAgB,IAAI,iBAAiB,IAAI,KAAK,CAAC;AACvD,SAAO,mBAAmB;AAC5B;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-cache-data.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type CacheData } from '../../../api/client'\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\n\nexport function useCacheData(cacheData: CacheData) {\n const { makeswiftApiClient: apiStore } = useMakeswiftHostApiClient()\n\n // We perform cache hydration immediately on render - this is safe to do per\n // render because updating the API cache is idempotent. For precedence, see:\n //\n // https://github.com/TanStack/query/blob/8f9f183f11df3709a1a38c4efce1452788041f88/packages/react-query/src/HydrationBoundary.tsx#L41\n useMemo(() => apiStore.dispatch(updateAPIClientCache(cacheData)), [cacheData])\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,SAAS,4BAA4B;AAErC,SAAS,iCAAiC;AAEnC,SAAS,aAAa,WAAsB;AACjD,QAAM,EAAE,oBAAoB,SAAS,IAAI,0BAA0B;AAMnE,UAAQ,MAAM,SAAS,SAAS,qBAAqB,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/E;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-component.ts"],"sourcesContent":["import {\n type ComponentType,\n type ComponentMeta,\n getReactComponent,\n getComponentMeta,\n} from '../../../state/read-only-state'\nimport { useSelector } from './use-selector'\n\nexport function useComponent(type: string): ComponentType | null {\n return useSelector(state => getReactComponent(state, type))\n}\n\nexport function useComponentMeta(type: string): ComponentMeta | null {\n return useSelector(state => getComponentMeta(state, type))\n}\n"],"mappings":"AAAA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAErB,SAAS,aAAa,MAAoC;AAC/D,SAAO,YAAY,WAAS,kBAAkB,OAAO,IAAI,CAAC;AAC5D;AAEO,SAAS,iBAAiB,MAAoC;AACnE,SAAO,YAAY,WAAS,iBAAiB,OAAO,IAAI,CAAC;AAC3D;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-css-id.ts"],"sourcesContent":["import { useId } from 'react'\n\nexport function useCssId(): string {\n return useId().replaceAll(':', '') // CSS class names prohibit colons\n}\n"],"mappings":"AAAA,SAAS,aAAa;AAEf,SAAS,WAAmB;AACjC,SAAO,MAAM,EAAE,WAAW,KAAK,EAAE;AACnC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-current-breakpoint.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport { type BreakpointId } from '../../../state/modules/breakpoints'\nimport { getBaseBreakpoint, getClientBreakpoint } from '../../../state/read-only-state'\n\nimport { useStore } from './use-store'\n\nexport function useCurrentBreakpoint(): BreakpointId {\n const store = useStore()\n\n return useSyncExternalStore(\n store.subscribe,\n () => getClientBreakpoint(store.getState()),\n () => getBaseBreakpoint(store.getState()),\n )\n}\n"],"mappings":"AAAA,SAAS,4BAA4B;AAGrC,SAAS,mBAAmB,2BAA2B;AAEvD,SAAS,gBAAgB;AAElB,SAAS,uBAAqC;AACnD,QAAM,QAAQ,SAAS;AAEvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,oBAAoB,MAAM,SAAS,CAAC;AAAA,IAC1C,MAAM,kBAAkB,MAAM,SAAS,CAAC;AAAA,EAC1C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-disable-register-element.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DisableRegisterElement = createContext(false)\n\nexport function useDisableRegisterElement() {\n return useContext(DisableRegisterElement)\n}\n"],"mappings":"AAAA,SAAS,eAAe,kBAAkB;AAEnC,MAAM,yBAAyB,cAAc,KAAK;AAElD,SAAS,4BAA4B;AAC1C,SAAO,WAAW,sBAAsB;AAC1C;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-dispatch.ts"],"sourcesContent":["import { useStore } from './use-store'\nimport { type Dispatch as ReadOnlyDispatch } from '../../../state/read-only-state'\nimport { type Dispatch as ReadWriteDispatch } from '../../../state/read-write-state'\n\ntype Dispatch = ReadOnlyDispatch & ReadWriteDispatch\n\nexport function useDispatch(): Dispatch {\n const store = useStore()\n\n return store.dispatch\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAMlB,SAAS,cAAwB;AACtC,QAAM,QAAQ,SAAS;AAEvB,SAAO,MAAM;AACf;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-document-context.ts"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\n\nexport const DocumentKeyContext = createContext<string | null>(null)\nexport const DocumentLocaleContext = createContext<string | null>(null)\n\nexport function useDocumentKey(): string | null {\n return useContext(DocumentKeyContext)\n}\n\nexport function useDocumentLocale(): string | null {\n return useContext(DocumentLocaleContext)\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAEnC,MAAM,qBAAqB,cAA6B,IAAI;AAC5D,MAAM,wBAAwB,cAA6B,IAAI;AAE/D,SAAS,iBAAgC;AAC9C,SAAO,WAAW,kBAAkB;AACtC;AAEO,SAAS,oBAAmC;AACjD,SAAO,WAAW,qBAAqB;AACzC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-document-cycles.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DocumentCyclesContext = createContext<string[]>([])\n\nexport function useDocumentCycles() {\n return useContext(DocumentCyclesContext)\n}\n"],"mappings":"AAAA,SAAS,eAAe,kBAAkB;AAEnC,MAAM,wBAAwB,cAAwB,CAAC,CAAC;AAExD,SAAS,oBAAoB;AAClC,SAAO,WAAW,qBAAqB;AACzC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-document.ts"],"sourcesContent":["import { Document, getDocument } from '../../../state/read-only-state'\nimport { useSelector } from './use-selector'\n\nexport function useDocument(documentKey: string): Document | null {\n return useSelector(state => getDocument(state, documentKey))\n}\n"],"mappings":"AAAA,SAAmB,mBAAmB;AACtC,SAAS,mBAAmB;AAErB,SAAS,YAAY,aAAsC;AAChE,SAAO,YAAY,WAAS,YAAY,OAAO,WAAW,CAAC;AAC7D;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-element-id.ts"],"sourcesContent":["import { getElementId } from '../../../state/read-only-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useElementId(elementKey: string | null | undefined): string | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state =>\n documentKey == null || elementKey == null ? null : getElementId(state, documentKey, elementKey),\n )\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAErB,SAAS,aAAa,YAAsD;AACjF,QAAM,cAAc,eAAe;AAEnC,SAAO;AAAA,IAAY,WACjB,eAAe,QAAQ,cAAc,OAAO,OAAO,aAAa,OAAO,aAAa,UAAU;AAAA,EAChG;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"sourcesContent":["import { useStore } from './use-store'\nimport { getIsInBuilder } from '../../../state/read-only-state'\nimport { useSyncExternalStore } from 'react'\n\n/**\n * When multiple React roots share a single store, `isInBuilder` can become\n * `true` before all roots have hydrated. React uses `getServerSnapshot` during\n * client hydration — not just on the server — so if it reads from the live\n * store, it may see `true` while the server HTML was rendered with `false`,\n * causing a hydration mismatch that React may fail to recover from inside\n * nested Suspense boundaries. This can manifest as cases where the correct\n * value of `isInBuilder` is read in the component, but the DOM remains stale.\n *\n * https://react.dev/reference/react/useSyncExternalStore#parameters\n *\n * TODO: For now, we're fixing this by returning a fixed `false` from\n * `getServerSnapshot` to match what the server actually rendered. After\n * hydration, the subscription picks up changes to this value which can only be\n * initiated client-side. We'll need to revisit this problem to reconsider how\n * we holistically handle store state changes across the server/client.\n */\nfunction getServerSnapshot(): boolean {\n return false\n}\n\nexport function useIsInBuilder(): boolean {\n const store = useStore()\n\n return useSyncExternalStore(\n store.subscribe,\n () => getIsInBuilder(store.getState()),\n getServerSnapshot,\n )\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAmBrC,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,iBAA0B;AACxC,QAAM,QAAQ,SAAS;AAEvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,eAAe,MAAM,SAAS,CAAC;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-read-only.ts"],"sourcesContent":["import { getIsReadOnly } from '../../../state/read-only-state'\nimport { useSelector } from './use-selector'\n\nexport function useIsReadOnly(): boolean {\n return useSelector(state => getIsReadOnly(state))\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAErB,SAAS,gBAAyB;AACvC,SAAO,YAAY,WAAS,cAAc,KAAK,CAAC;AAClD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-react-runtime.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\nimport { type ReactRuntimeCore } from '../react-runtime-core'\n\nexport const ReactRuntimeContext = createContext<ReactRuntimeCore | null>(null)\n\nexport function useReactRuntime(): ReactRuntimeCore {\n const runtime = useContext(ReactRuntimeContext)\n if (runtime === null) {\n throw new Error('`useReactRuntime` must be used within a `ReactRuntimeProvider`')\n }\n\n return runtime\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAGnC,MAAM,sBAAsB,cAAuC,IAAI;AAEvE,SAAS,kBAAoC;AAClD,QAAM,UAAU,WAAW,mBAAmB;AAC9C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AAEA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-register-document.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { type Document } from '../../../state/read-only-state'\nimport { useDispatch } from './use-dispatch'\nimport { useIsInBuilder } from './use-is-in-builder'\nimport { registerDocument, registerDocumentsEffect } from '../../../state/shared-api'\nimport { registerBuilderDocumentsEffect } from '../../../state/builder-api/actions'\n\nimport { isServer } from '../../../utils/is-server'\nimport { useIsomorphicLayoutEffect } from '../../../components/hooks/useIsomorphicLayoutEffect'\n\n/**\n * @param document Document to register\n */\nexport function useRegisterDocument(document: Document): void {\n const isInBuilder = useIsInBuilder()\n const dispatch = useDispatch()\n\n if (isServer()) {\n dispatch(registerDocument(document))\n }\n\n /*\n Layout effect is to ensure that the document registration happens prior to the\n attempted creation/registration of prop controllers in child components.\n */\n useIsomorphicLayoutEffect(() => {\n return dispatch(registerDocumentsEffect([document]))\n }, [dispatch, document])\n\n // TODO: Decide whether to do this via middleware or via explicit action (like\n // what we're doing below)\n useEffect(() => {\n if (!isInBuilder) return\n return dispatch(registerBuilderDocumentsEffect([document]))\n }, [isInBuilder, document])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB,+BAA+B;AAC1D,SAAS,sCAAsC;AAE/C,SAAS,gBAAgB;AACzB,SAAS,iCAAiC;AAKnC,SAAS,oBAAoB,UAA0B;AAC5D,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,YAAY;AAE7B,MAAI,SAAS,GAAG;AACd,aAAS,iBAAiB,QAAQ,CAAC;AAAA,EACrC;AAMA,4BAA0B,MAAM;AAC9B,WAAO,SAAS,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AAAA,EACrD,GAAG,CAAC,UAAU,QAAQ,CAAC;AAIvB,YAAU,MAAM;AACd,QAAI,CAAC;AAAa;AAClB,WAAO,SAAS,+BAA+B,CAAC,QAAQ,CAAC,CAAC;AAAA,EAC5D,GAAG,CAAC,aAAa,QAAQ,CAAC;AAC5B;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolvable-record.tsx"],"sourcesContent":["import { type Resolvable } from '@makeswift/controls'\nimport { useMemo, useRef } from 'react'\n\ntype Snapshot = {\n resolvedValues: Record<string, unknown>\n dirtyProps: Set<string>\n}\n\nexport function useResolvableRecord(\n resolvables: Record<string, Resolvable<unknown>>,\n): Resolvable<Record<string, unknown>> {\n const snapshot = useRef<Snapshot>({ resolvedValues: {}, dirtyProps: new Set() })\n\n return useMemo<Resolvable<Record<string, unknown>>>(() => {\n return {\n name: 'resolvable-record',\n subscribe: (onUpdate: () => void): (() => void) => {\n const unsubscribes = Object.values(resolvables).map(s => s.subscribe(onUpdate))\n return () => {\n unsubscribes.forEach(u => u())\n }\n },\n\n readStable: () => {\n const nextSnapshot = Object.entries(resolvables).reduce<Snapshot>(\n ({ dirtyProps, resolvedValues }, [propName, subscription]) => {\n const lastPropValue = snapshot.current.resolvedValues[propName]\n const propValue = subscription.readStable()\n const isDirty = propValue !== lastPropValue\n\n return {\n dirtyProps: isDirty ? dirtyProps.add(propName) : dirtyProps,\n resolvedValues: { ...resolvedValues, [propName]: propValue },\n }\n },\n { resolvedValues: {}, dirtyProps: new Set() },\n )\n\n if (nextSnapshot.dirtyProps.size > 0) {\n snapshot.current = nextSnapshot\n }\n\n return snapshot.current.resolvedValues\n },\n\n triggerResolve: async () => {\n // While we _could_ only trigger resolution on the dirty props, this is\n // not an airtight solution. Some controls will resolve to nullish\n // values even when the underlying data changes, so they won't be dirty\n // (ex: an Image control where the data changes from `undefined` to a\n // file that has not yet been fetched). Even if you add a nullish check\n // on the resolved value, some controls can resolve to non-nullish value\n // when the resolution does not occur (ex: swatches can resolve to\n // black). The true solution is to trigger resolve on underlying data\n // change, and moving these dirtiness optimizations for resolution\n // triggering at the control level.\n return await Promise.all(\n Object.entries(resolvables).map(([propName, sub]) =>\n sub.triggerResolve(snapshot.current.resolvedValues[propName]),\n ),\n )\n },\n }\n }, [resolvables])\n}\n"],"mappings":"AACA,SAAS,SAAS,cAAc;AAOzB,SAAS,oBACd,aACqC;AACrC,QAAM,WAAW,OAAiB,EAAE,gBAAgB,CAAC,GAAG,YAAY,oBAAI,IAAI,EAAE,CAAC;AAE/E,SAAO,QAA6C,MAAM;AACxD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW,CAAC,aAAuC;AACjD,cAAM,eAAe,OAAO,OAAO,WAAW,EAAE,IAAI,OAAK,EAAE,UAAU,QAAQ,CAAC;AAC9E,eAAO,MAAM;AACX,uBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,QAC/B;AAAA,MACF;AAAA,MAEA,YAAY,MAAM;AAChB,cAAM,eAAe,OAAO,QAAQ,WAAW,EAAE;AAAA,UAC/C,CAAC,EAAE,YAAY,eAAe,GAAG,CAAC,UAAU,YAAY,MAAM;AAC5D,kBAAM,gBAAgB,SAAS,QAAQ,eAAe,QAAQ;AAC9D,kBAAM,YAAY,aAAa,WAAW;AAC1C,kBAAM,UAAU,cAAc;AAE9B,mBAAO;AAAA,cACL,YAAY,UAAU,WAAW,IAAI,QAAQ,IAAI;AAAA,cACjD,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,QAAQ,GAAG,UAAU;AAAA,YAC7D;AAAA,UACF;AAAA,UACA,EAAE,gBAAgB,CAAC,GAAG,YAAY,oBAAI,IAAI,EAAE;AAAA,QAC9C;AAEA,YAAI,aAAa,WAAW,OAAO,GAAG;AACpC,mBAAS,UAAU;AAAA,QACrB;AAEA,eAAO,SAAS,QAAQ;AAAA,MAC1B;AAAA,MAEA,gBAAgB,YAAY;AAW1B,eAAO,MAAM,QAAQ;AAAA,UACnB,OAAO,QAAQ,WAAW,EAAE;AAAA,YAAI,CAAC,CAAC,UAAU,GAAG,MAC7C,IAAI,eAAe,SAAS,QAAQ,eAAe,QAAQ,CAAC;AAAA,UAC9D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAClB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport * as ReactPage from '../../../state/read-only-state'\nimport { useResourceResolver } from './use-resource-resolver'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nimport { useStylesheetFactory } from './use-stylesheet-factory'\n\nimport { useResolvableRecord } from './use-resolvable-record'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nfunction useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return ReactPage.getPropControllers(state, { documentKey, elementKey })\n })\n}\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps(\n propDefs: Record<string, ControlDefinition>,\n elementData: Record<string, Data>,\n elementKey: string,\n): Record<string, unknown> {\n const stylesheetFactory = useStylesheetFactory()\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = elementData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, elementData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,YAAY,eAAe;AAC3B,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAE5B,SAAS,4BAA4B;AAErC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AAEvC,SAAS,oBAAoB,YAA4D;AACvF,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,WAAO,UAAU,mBAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EACxE,CAAC;AACH;AAQO,SAAS,iBACd,UACA,aACA,YACyB;AACzB,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,WAAW,oBAAoB,UAAU;AAE/C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,YAAY,QAAQ;AACjC,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,aAAa,kBAAkB,iBAAiB;AAAA,EAC7D;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-value.ts"],"sourcesContent":["import { useMemo, useEffect, useSyncExternalStore } from 'react'\nimport { Resolvable, ResourceResolver } from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nexport function useResolvedValue<D, T>(\n data: D,\n resolver: (data: D, resourceResolver: ResourceResolver) => Resolvable<T>,\n defaultValue?: T,\n): T | undefined {\n const resourceResolver = useResourceResolver()\n const resolvable = useMemo(() => {\n return propErrorHandlingProxy(resolver(data, resourceResolver), defaultValue, error => {\n console.warn(`Error resolving data, falling back to \\`${defaultValue}\\`.`, { error, data })\n })\n }, [data, resourceResolver, defaultValue])\n\n useEffect(() => {\n resolvable.triggerResolve()\n }, [resolvable])\n\n return useSyncExternalStore(resolvable.subscribe, resolvable.readStable, resolvable.readStable)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,4BAA4B;AAGzD,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AAEhC,SAAS,iBACd,MACA,UACA,cACe;AACf,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,aAAa,QAAQ,MAAM;AAC/B,WAAO,uBAAuB,SAAS,MAAM,gBAAgB,GAAG,cAAc,WAAS;AACrF,cAAQ,KAAK,2CAA2C,YAAY,OAAO,EAAE,OAAO,KAAK,CAAC;AAAA,IAC5F,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,kBAAkB,YAAY,CAAC;AAEzC,YAAU,MAAM;AACd,eAAW,eAAe;AAAA,EAC5B,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,qBAAqB,WAAW,WAAW,WAAW,YAAY,WAAW,UAAU;AAChG;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resource-resolver.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type ResourceResolver } from '@makeswift/controls'\n\nimport * as ReactPage from '../../../state/read-only-state'\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useStore } from './use-store'\nimport { useDocumentKey, useDocumentLocale } from './use-document-context'\n\nexport function useResourceResolver(): ResourceResolver {\n const store = useStore()\n const client = useMakeswiftHostApiClient()\n\n const documentKey = useDocumentKey()\n const locale = useDocumentLocale()\n\n return useMemo<ResourceResolver>(() => {\n return {\n resolveSwatch: swatchId => client.resolveSwatch(swatchId),\n resolveFile: fileId => client.resolveFile(fileId),\n resolveTypography: typographyId => client.resolveTypography(typographyId),\n resolvePagePathnameSlice: pageId => client.resolvePagePathnameSlice({ pageId, locale }),\n resolveElementId: elementKey => {\n const read = () =>\n documentKey == null\n ? null\n : ReactPage.getElementId(store.getState(), documentKey, elementKey)\n\n let lastValue: string | null = null\n return {\n name: `element-id:${documentKey}:${elementKey}`,\n readStable: () => (lastValue = read()),\n subscribe: (onUpdate: () => void) =>\n store.subscribe(() => {\n if (read() !== lastValue) onUpdate()\n }),\n }\n },\n }\n }, [client, store, documentKey, locale])\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAGxB,YAAY,eAAe;AAC3B,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,yBAAyB;AAE3C,SAAS,sBAAwC;AACtD,QAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,0BAA0B;AAEzC,QAAM,cAAc,eAAe;AACnC,QAAM,SAAS,kBAAkB;AAEjC,SAAO,QAA0B,MAAM;AACrC,WAAO;AAAA,MACL,eAAe,cAAY,OAAO,cAAc,QAAQ;AAAA,MACxD,aAAa,YAAU,OAAO,YAAY,MAAM;AAAA,MAChD,mBAAmB,kBAAgB,OAAO,kBAAkB,YAAY;AAAA,MACxE,0BAA0B,YAAU,OAAO,yBAAyB,EAAE,QAAQ,OAAO,CAAC;AAAA,MACtF,kBAAkB,gBAAc;AAC9B,cAAM,OAAO,MACX,eAAe,OACX,OACA,UAAU,aAAa,MAAM,SAAS,GAAG,aAAa,UAAU;AAEtE,YAAI,YAA2B;AAC/B,eAAO;AAAA,UACL,MAAM,cAAc,WAAW,IAAI,UAAU;AAAA,UAC7C,YAAY,MAAO,YAAY,KAAK;AAAA,UACpC,WAAW,CAAC,aACV,MAAM,UAAU,MAAM;AACpB,gBAAI,KAAK,MAAM;AAAW,uBAAS;AAAA,UACrC,CAAC;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,aAAa,MAAM,CAAC;AACzC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'\n\nimport { useStore } from './use-store'\nimport { type State as ReadOnlyState } from '../../../state/read-only-state'\nimport { type State as ReadWriteState } from '../../../state/read-write-state'\n\ntype State = ReadOnlyState | ReadWriteState\n\nexport function useSelector<R>(selector: (state: State) => R): R {\n const store = useStore()\n\n return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector)\n}\n"],"mappings":"AAAA,SAAS,wCAAwC;AAEjD,SAAS,gBAAgB;AAMlB,SAAS,YAAe,UAAkC;AAC/D,QAAM,QAAQ,SAAS;AAEvB,SAAO,iCAAiC,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,QAAQ;AACnG;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-store.ts"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\nimport { type Store } from '../../../state/store'\n\nexport const StoreContext = createContext<Store | null>(null)\n\nexport function useStore(): Store {\n const store = useContext(StoreContext)\n if (store == null) {\n throw new Error('`useStore` must be used within a `StoreProvider`')\n }\n\n return store\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAGnC,MAAM,eAAe,cAA4B,IAAI;AAErD,SAAS,WAAkB;AAChC,QAAM,QAAQ,WAAW,YAAY;AACrC,MAAI,SAAS,MAAM;AACjB,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAEA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { type CSSObject, serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n type ResolvedStyleV2,\n type ResolvedTypographyStyle,\n isNotNil,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { useCache } from '../root-style-registry'\nimport { styleV1Css } from '../controls/style'\nimport { typographyCss } from '../controls/typography'\n\nimport { useBreakpoints } from './use-breakpoints'\nimport { useCssId } from './use-css-id'\nimport { useStyles, serializedStyleClassName } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport type StylesheetFactory = {\n get(propName: string): Stylesheet\n useDefinedStyles(): void\n}\n\nexport function useStylesheetFactory(): StylesheetFactory {\n const breakpoints = useBreakpoints()\n const cache = useCache()\n const componentUid = useCssId()\n\n const computedStyles = useRef<Record<string, SerializedStyles>>({}).current\n const boxModelCallbacks = useRef<Record<string, (boxModel: BoxDisplayModel | null) => void>>({}).current\n\n return useMemo(() => {\n const getStylesheet = (styleSheetId: string): Stylesheet => ({\n breakpoints(): Breakpoints {\n return breakpoints\n },\n\n defineStyle(\n style: ResolvedStyle,\n onBoxModelChange?: (boxModel: BoxDisplayModel | null) => void,\n ): string {\n const serialized = serializeStyle(breakpoints, style, cache)\n const uid = `u-${componentUid}-${styleSheetId}`\n computedStyles[uid] = serialized\n\n const className = serializedStyleClassName(cache, serialized)\n if (!onBoxModelChange) return className\n\n boxModelCallbacks[uid] = onBoxModelChange\n return `${className} ${uid}`\n },\n\n child(id: string): Stylesheet {\n return getStylesheet(`${styleSheetId}-${id}`)\n },\n })\n\n return {\n get(propName: string): Stylesheet {\n return getStylesheet(propName)\n },\n\n useDefinedStyles() {\n useStyles(cache, Object.values(computedStyles))\n\n useEffect(() => {\n const unsubscribes = Object.entries(boxModelCallbacks)\n .map(([uid, callback]) =>\n callback != null\n ? pollBoxModel({\n element: document.querySelector(`.${uid}`),\n onBoxModelChange: callback,\n })\n : undefined,\n )\n .filter(isNotNil)\n\n return () => unsubscribes.forEach(fn => fn())\n }, [Object.keys(boxModelCallbacks).join(' ')])\n },\n }\n }, [breakpoints, cache, componentUid])\n}\n\nfunction isTypographyStyle(style: ResolvedStyle): style is ResolvedTypographyStyle {\n return Array.isArray(style)\n}\n\nfunction isStyleV2(style: ResolvedStyle): style is ResolvedStyleV2 {\n return typeof style === 'object' && 'getStyle' in style && typeof style.getStyle === 'function'\n}\n\nfunction styleV2Css(breakpoints: Breakpoints, style: ResolvedStyleV2<CSSObject>): CSSObject {\n return {\n ...style.getStyle(getBaseBreakpoint(breakpoints)),\n ...breakpoints.reduce(\n (styles, breakpoint) => ({\n ...styles,\n [getBreakpointMediaQuery(breakpoint)]: style.getStyle(breakpoint),\n }),\n {},\n ),\n }\n}\n\nfunction resolvedStyleToCss(breakpoints: Breakpoints, style: ResolvedStyle) {\n if (isTypographyStyle(style)) {\n return typographyCss(breakpoints, style)\n }\n\n if (isStyleV2(style)) {\n return styleV2Css(breakpoints, style as ResolvedStyleV2<CSSObject>)\n }\n\n const { properties, styleData } = style\n return styleV1Css(breakpoints, styleData, properties)\n}\n\nfunction serializeStyle(\n breakpoints: Breakpoints,\n style: ResolvedStyle,\n cache: EmotionCache,\n): SerializedStyles {\n const css = resolvedStyleToCss(breakpoints, style)\n return serializeStyles([css], cache.registered)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,cAAc;AAC3C,SAAyB,uBAAuB;AAIhD;AAAA,EAOE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,WAAW,gCAAgC;AACpD,SAAS,oBAAoB;AAOtB,SAAS,uBAA0C;AACxD,QAAM,cAAc,eAAe;AACnC,QAAM,QAAQ,S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jF,SAAO,MAAM,QAAQ,KAAK;AAC5B;AAEA,SAAS,UAAU,OAAgD;AACjE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,OAAO,MAAM,aAAa;AACvF;AAEA,SAAS,WAAW,aAA0B,OAA8C;AAC1F,SAAO;AAAA,IACL,GAAG,MAAM,SAAS,kBAAkB,WAAW,CAAC;AAAA,IAChD,GAAG,YAAY;AAAA,MACb,CAAC,QAAQ,gBAAgB;AAAA,QACvB,GAAG;AAAA,QACH,CAAC,wBAAwB,UAAU,CAAC,GAAG,MAAM,SAAS,UAAU;AAAA,MAClE;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,mBAAmB,aAA0B,OAAsB;AAC1E,MAAI,kBAAkB,KAAK,GAAG;AAC5B,WAAO,cAAc,aAAa,KAAK;AAAA,EACzC;AAEA,MAAI,UAAU,KAAK,GAAG;AACpB,WAAO,WAAW,aAAa,KAAmC;AAAA,EACpE;AAEA,QAAM,EAAE,YAAY,UAAU,IAAI;AAClC,SAAO,WAAW,aAAa,WAAW,UAAU;AACtD;AAEA,SAAS,eACP,aACA,OACA,OACkB;AAClB,QAAM,MAAM,mBAAmB,aAAa,KAAK;AACjD,SAAO,gBAAgB,CAAC,GAAG,GAAG,MAAM,UAAU;AAChD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-universal-dispatch.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport type { ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Dispatch } from '../../../state/read-only-state'\nimport { type Action } from '../../../state/actions'\n\nimport { isServer } from '../../../utils/is-server'\n\n// overloaded signatures\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => A,\n args: Args,\n): void\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => ThunkAction<() => void, any, any, A>,\n args: Args,\n): void\n// implementation\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => ThunkAction<() => void, any, any, A>,\n args: Args,\n) {\n if (isServer()) {\n dispatch(action(...args))\n }\n\n useEffect(() => {\n dispatch(action(...args))\n }, [dispatch, action, ...args])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAM1B,SAAS,gBAAgB;AAclB,SAAS,qBACd,UACA,QACA,MACA;AACA,MAAI,SAAS,GAAG;AACd,aAAS,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1B;AAEA,YAAU,MAAM;AACd,aAAS,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1B,GAAG,CAAC,UAAU,QAAQ,GAAG,IAAI,CAAC;AAChC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/lib/react-dom.ts"],"sourcesContent":["import { type Component } from 'react'\nimport ReactDOM from 'react-dom'\n\ntype FindDOMNodeFn = (instance: Component | null | undefined) => Element | Text | null\n\ntype ReactDOMWithLegacyFindDOMNode = typeof ReactDOM & { findDOMNode?: FindDOMNodeFn }\n\n// For React 18 and below\nconst ReactDOMCompat = ReactDOM as ReactDOMWithLegacyFindDOMNode\n\n// For React 19\n// https://github.com/facebook/react/blob/main/packages/shared/ReactDOMSharedInternals.js\nconst reactDOMInternals = (ReactDOM as any)\n .__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE as {\n findDOMNode: FindDOMNodeFn\n}\n\nexport function findDOMNode(instance: Component | null | undefined): Element | Text | null {\n return ReactDOMCompat.findDOMNode\n ? ReactDOMCompat.findDOMNode(instance)\n : reactDOMInternals.findDOMNode(instance)\n}\n"],"mappings":"AACA,OAAO,cAAc;AAOrB,MAAM,iBAAiB;AAIvB,MAAM,oBAAqB,SACxB;AAII,SAAS,YAAY,UAA+D;AACzF,SAAO,eAAe,cAClB,eAAe,YAAY,QAAQ,IACnC,kBAAkB,YAAY,QAAQ;AAC5C;","names":[]}
@@ -2,7 +2,7 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import createCache from "@emotion/cache";
4
4
  import { cache } from "@emotion/css";
5
- import { createContext, useContext } from "react";
5
+ import { createContext, useContext, useState } from "react";
6
6
  const CacheContext = createContext(cache);
7
7
  const DEFAULT_CSS_RESET_ENABLED = true;
8
8
  const CSSResetEnabledContext = createContext(DEFAULT_CSS_RESET_ENABLED);
@@ -49,6 +49,14 @@ function RootStyleRegistry({
49
49
  }) {
50
50
  return /* @__PURE__ */ jsx(CacheContext.Provider, { value: cache2, children: /* @__PURE__ */ jsx(CSSResetEnabledContext.Provider, { value: enableCssReset ?? DEFAULT_CSS_RESET_ENABLED, children }) });
51
51
  }
52
+ function DefaultRootStyleRegistry({
53
+ children,
54
+ cacheKey,
55
+ enableCssReset
56
+ }) {
57
+ const [cache2] = useState(() => createRootStyleCache({ key: cacheKey }));
58
+ return /* @__PURE__ */ jsx(RootStyleRegistry, { cache: cache2, enableCssReset, children });
59
+ }
52
60
  function useCache() {
53
61
  return useContext(CacheContext);
54
62
  }
@@ -56,6 +64,7 @@ function useCSSResetEnabled() {
56
64
  return useContext(CSSResetEnabledContext);
57
65
  }
58
66
  export {
67
+ DefaultRootStyleRegistry,
59
68
  RootStyleRegistry,
60
69
  StyleTagSSR,
61
70
  createRootStyleCache,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/root-style-registry.tsx"],"sourcesContent":["'use client'\n\nimport createCache, { type EmotionCache } from '@emotion/cache'\nimport { cache } from '@emotion/css'\nimport { type PropsWithChildren, createContext, useContext } from 'react'\n\nconst CacheContext = createContext(cache)\n\nconst DEFAULT_CSS_RESET_ENABLED = true\nconst CSSResetEnabledContext = createContext(DEFAULT_CSS_RESET_ENABLED)\n\nexport type StyleCache = EmotionCache & {\n /**\n * Flush the inserted styles.\n * @returns A list of class names and the corresponding CSS rules that were flushed.\n */\n flush: () => { classNames: string[]; css: string }\n}\n\nexport const createRootStyleCache = ({ key }: { key?: string } = {}): StyleCache => {\n const cache = createCache({ key: key ?? 'mswft' })\n cache.compat = true\n\n // additional state to track inserted style names\n let inserted: string[] = []\n\n return {\n ...cache,\n\n // override the `insert` method to track inserted names\n insert(...args) {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) {\n inserted.push(serialized.name)\n }\n return cache.insert(...args)\n },\n\n flush() {\n const classNames = inserted\n // reset our own state, leave `cache.inserted` intact\n inserted = []\n\n return {\n classNames,\n css: classNames.reduce((css, name) => {\n return css + cache.inserted[name]\n }, ''),\n }\n },\n }\n}\n\ntype StyleTagProps = {\n cacheKey: string\n classNames: string[]\n css: string\n}\n\nexport const StyleTagSSR = ({ cacheKey, classNames, css }: StyleTagProps) => (\n <style\n data-emotion={`${cacheKey} ${classNames.join(' ')}`}\n dangerouslySetInnerHTML={{\n __html: css,\n }}\n />\n)\n\nexport const styleTagHtml = ({ cacheKey, classNames, css }: StyleTagProps): string =>\n `<style data-emotion=\"${cacheKey} ${classNames.join(' ')}\">${css}</style>`\n\nexport type RootStyleProps = {\n /**\n * The key used to prefix generated class names.\n * If not provided, a default key will be used.\n */\n cacheKey?: string\n /**\n * Toggle the built-in CSS reset.\n * Set to `false` when using `@layer`-based CSS frameworks like Tailwind.\n */\n enableCssReset?: boolean\n}\n\nexport function RootStyleRegistry({\n children,\n cache,\n enableCssReset,\n}: PropsWithChildren<{\n cache: StyleCache\n enableCssReset?: boolean\n}>) {\n return (\n <CacheContext.Provider value={cache}>\n <CSSResetEnabledContext.Provider value={enableCssReset ?? DEFAULT_CSS_RESET_ENABLED}>\n {children}\n </CSSResetEnabledContext.Provider>\n </CacheContext.Provider>\n )\n}\n\nexport function useCache(): EmotionCache {\n return useContext(CacheContext)\n}\n\nexport function useCSSResetEnabled(): boolean {\n return useContext(CSSResetEnabledContext)\n}\n"],"mappings":";AA4DE;AA1DF,OAAO,iBAAwC;AAC/C,SAAS,aAAa;AACtB,SAAiC,eAAe,kBAAkB;AAElE,MAAM,eAAe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W,YAAY;AAChC;AAEO,SAAS,qBAA8B;AAC5C,SAAO,WAAW,sBAAsB;AAC1C;","names":["cache"]}
1
+ {"version":3,"sources":["../../../../src/runtimes/react/root-style-registry.tsx"],"sourcesContent":["'use client'\n\nimport createCache, { type EmotionCache } from '@emotion/cache'\nimport { cache } from '@emotion/css'\nimport { type PropsWithChildren, createContext, useContext, useState } from 'react'\n\nconst CacheContext = createContext(cache)\n\nconst DEFAULT_CSS_RESET_ENABLED = true\nconst CSSResetEnabledContext = createContext(DEFAULT_CSS_RESET_ENABLED)\n\nexport type StyleCache = EmotionCache & {\n /**\n * Flush the inserted styles.\n * @returns A list of class names and the corresponding CSS rules that were flushed.\n */\n flush: () => { classNames: string[]; css: string }\n}\n\nexport const createRootStyleCache = ({ key }: { key?: string } = {}): StyleCache => {\n const cache = createCache({ key: key ?? 'mswft' })\n cache.compat = true\n\n // additional state to track inserted style names\n let inserted: string[] = []\n\n return {\n ...cache,\n\n // override the `insert` method to track inserted names\n insert(...args) {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) {\n inserted.push(serialized.name)\n }\n return cache.insert(...args)\n },\n\n flush() {\n const classNames = inserted\n // reset our own state, leave `cache.inserted` intact\n inserted = []\n\n return {\n classNames,\n css: classNames.reduce((css, name) => {\n return css + cache.inserted[name]\n }, ''),\n }\n },\n }\n}\n\ntype StyleTagProps = {\n cacheKey: string\n classNames: string[]\n css: string\n}\n\nexport const StyleTagSSR = ({ cacheKey, classNames, css }: StyleTagProps) => (\n <style\n data-emotion={`${cacheKey} ${classNames.join(' ')}`}\n dangerouslySetInnerHTML={{\n __html: css,\n }}\n />\n)\n\nexport const styleTagHtml = ({ cacheKey, classNames, css }: StyleTagProps): string =>\n `<style data-emotion=\"${cacheKey} ${classNames.join(' ')}\">${css}</style>`\n\nexport type RootStyleProps = {\n /**\n * The key used to prefix generated class names.\n * If not provided, a default key will be used.\n */\n cacheKey?: string\n /**\n * Toggle the built-in CSS reset.\n * Set to `false` when using `@layer`-based CSS frameworks like Tailwind.\n */\n enableCssReset?: boolean\n}\n\nexport function RootStyleRegistry({\n children,\n cache,\n enableCssReset,\n}: PropsWithChildren<{\n cache: StyleCache\n enableCssReset?: boolean\n}>) {\n return (\n <CacheContext.Provider value={cache}>\n <CSSResetEnabledContext.Provider value={enableCssReset ?? DEFAULT_CSS_RESET_ENABLED}>\n {children}\n </CSSResetEnabledContext.Provider>\n </CacheContext.Provider>\n )\n}\n\nexport function DefaultRootStyleRegistry({\n children,\n cacheKey,\n enableCssReset,\n}: PropsWithChildren<RootStyleProps>) {\n const [cache] = useState(() => createRootStyleCache({ key: cacheKey }))\n\n return (\n <RootStyleRegistry cache={cache} enableCssReset={enableCssReset}>\n {children}\n </RootStyleRegistry>\n )\n}\n\nexport function useCache(): EmotionCache {\n return useContext(CacheContext)\n}\n\nexport function useCSSResetEnabled(): boolean {\n return useContext(CSSResetEnabledContext)\n}\n"],"mappings":";AA4DE;AA1DF,OAAO,iBAAwC;AAC/C,SAAS,aAAa;AACtB,SAAiC,eAAe,YAAY,gBAAgB;AAE5E,MAAM,eAAe,cAAc,KAAK;AAExC,MAAM,4BAA4B;AAClC,MAAM,yBAAyB,cAAc,yBAAyB;AAU/D,MAAM,uBAAuB,CAAC,EAAE,IAAI,IAAsB,CAAC,MAAkB;AAClF,QAAMA,SAAQ,YAAY,EAAE,KAAK,OAAO,QAAQ,CAAC;AACjD,EAAAA,OAAM,SAAS;AAGf,MAAI,WAAqB,CAAC;AAE1B,SAAO;AAAA,IACL,GAAGA;AAAA;AAAA,IAGH,UAAU,MAAM;AACd,YAAM,aAAa,KAAK,CAAC;AACzB,UAAIA,OAAM,SAAS,WAAW,IAAI,MAAM,QAAW;AACjD,iBAAS,KAAK,WAAW,IAAI;AAAA,MAC/B;AACA,aAAOA,OAAM,OAAO,GAAG,IAAI;AAAA,IAC7B;AAAA,IAEA,QAAQ;AACN,YAAM,aAAa;AAEnB,iBAAW,CAAC;AAEZ,aAAO;AAAA,QACL;AAAA,QACA,KAAK,WAAW,OAAO,CAAC,KAAK,SAAS;AACpC,iBAAO,MAAMA,OAAM,SAAS,IAAI;AAAA,QAClC,GAAG,EAAE;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;AAQO,MAAM,cAAc,CAAC,EAAE,UAAU,YAAY,IAAI,MACtD;AAAA,EAAC;AAAA;AAAA,IACC,gBAAc,GAAG,QAAQ,IAAI,WAAW,KAAK,GAAG,CAAC;AAAA,IACjD,yBAAyB;AAAA,MACvB,QAAQ;AAAA,IACV;AAAA;AACF;AAGK,MAAM,eAAe,CAAC,EAAE,UAAU,YAAY,IAAI,MACvD,wBAAwB,QAAQ,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,GAAG;AAe3D,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,OAAAA;AAAA,EACA;AACF,GAGI;AACF,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAOA,QAC5B,8BAAC,uBAAuB,UAAvB,EAAgC,OAAO,kBAAkB,2BACvD,UACH,GACF;AAEJ;AAEO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,GAAsC;AACpC,QAAM,CAACA,MAAK,IAAI,SAAS,MAAM,qBAAqB,EAAE,KAAK,SAAS,CAAC,CAAC;AAEtE,SACE,oBAAC,qBAAkB,OAAOA,QAAO,gBAC9B,UACH;AAEJ;AAEO,SAAS,WAAyB;AACvC,SAAO,WAAW,YAAY;AAChC;AAEO,SAAS,qBAA8B;AAC5C,SAAO,WAAW,sBAAsB;AAC1C;","names":["cache"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { type BreakpointsInput } from '../../../state/modules/breakpoints'\nimport { TestOrigins } from '../../../testing/fixtures'\nimport { ReactRuntime } from '../react-runtime'\n\nexport function createReactRuntime({ breakpoints }: { breakpoints?: BreakpointsInput } = {}) {\n return new ReactRuntime({ fetch, breakpoints, ...TestOrigins })\n}\n"],"mappings":"AACA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAEtB,SAAS,mBAAmB,EAAE,YAAY,IAAwC,CAAC,GAAG;AAC3F,SAAO,IAAI,aAAa,EAAE,OAAO,aAAa,GAAG,YAAY,CAAC;AAChE;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/use-global-style.ts"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useRef } from 'react'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nimport { useCache } from './root-style-registry'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n const cache = useCache()\n const serialized = serializeStyles(args, cache.registered)\n\n if (isServer) {\n if (cache.inserted[serialized.name] === undefined) {\n cache.insert('', serialized, cache.sheet, true)\n }\n }\n\n const sheetRef = useRef<[StyleSheet, boolean] | null>(null)\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAA2B,uBAAuB;AAElD,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAEzB,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,8BAA8B;AACpC,MAAM,qBAAqB,MAAM,2BAA2B,KAAK,MAAM;AAEhE,SAAS,kBAAkB,MAAgC;AAChE,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,gBAAgB,MAAM,MAAM,UAAU;AAEzD,MAAI,UAAU;AACZ,QAAI,MAAM,SAAS,WAAW,IAAI,MAAM,QAAW;AACjD,YAAM,OAAO,IAAI,YAAY,MAAM,OAAO,IAAI;AAAA,IAChD;AAAA,EACF;AAEA,QAAM,WAAW,OAAqC,IAAI;AAG1D,qBAAmB,MAAM;AACvB,UAAM,MAAM,GAAG,MAAM,GAAG;AAExB,UAAM,aAAa,MAAM;AACzB,UAAM,QAAQ,IAAK,WAAW,YAAkC;AAAA,MAC9D;AAAA,MACA,OAAO,WAAW;AAAA,MAClB,WAAW,WAAW;AAAA,MACtB,QAAQ,WAAW;AAAA,IACrB,CAAC;AAED,UAAM,OAAO,SAAS;AAAA,MACpB,uBAAuB,GAAG,IAAI,WAAW,IAAI;AAAA,IAC/C;AAEA,QAAI,MAAM,MAAM,KAAK,SAAS,GAAG;AAC/B,YAAM,SAAS,MAAM,MAAM,KAAK,CAAC;AAAA,IACnC;AAEA,QAAI,cAAc;AAElB,QAAI,QAAQ,MAAM;AAChB,oBAAc;AACd,WAAK,aAAa,gBAAgB,GAAG;AACrC,YAAM,QAAQ,CAAC,IAAI,CAAC;AAAA,IACtB;AAEA,aAAS,UAAU,CAAC,OAAO,WAAW;AAEtC,WAAO,MAAM;AACX,YAAM,MAAM;AAAA,IACd;AAAA,EACF,CAAC;AAGD,qBAAmB,MAAM;AACvB,UAAM,CAAC,OAAO,WAAW,IAAI,SAAS,WAAW,CAAC;AAElD,QAAI,SAAS,QAAQ,eAAe;AAAM;AAE1C,QAAI,aAAa;AACf,eAAS,UAAU,CAAC,OAAO,KAAK;AAEhC;AAAA,IACF;AAEA,QAAI,WAAW,QAAQ,MAAM;AAC3B,mBAAa,OAAO,WAAW,MAAM,IAAI;AAAA,IAC3C;AAEA,QAAI,MAAM,KAAK,SAAS,GAAG;AACzB,YAAM,UAAU,MAAM,KAAK,MAAM,KAAK,SAAS,CAAC,EAAE;AAElD,YAAM,SAAS;AAEf,YAAM,MAAM;AAAA,IACd;AAEA,UAAM,OAAO,IAAI,YAAY,OAAO,KAAK;AAAA,EAC3C,CAAC;AACH;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/use-style.ts"],"sourcesContent":["import React from 'react'\nimport { type CSSObject } from '@emotion/serialize'\nimport { EmotionCache } from '@emotion/cache'\nimport { serializeStyles } from '@emotion/serialize'\nimport { registerStyles, insertStyles, type SerializedStyles } from '@emotion/utils'\n\nimport { isServer } from '../../utils/is-server'\n\nimport { useCache } from './root-style-registry'\n\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useStyle(style: CSSObject): string {\n const cache = useCache()\n const serialized = serializeStyles([style], cache.registered)\n\n registerStyles(cache, serialized, false)\n\n useUniversalInsertionEffect(() => {\n insertStyles(cache, serialized, false)\n })\n\n return serializedStyleClassName(cache, serialized)\n}\n\nexport function useStyles(cache: EmotionCache, styles: SerializedStyles[]) {\n styles.forEach(s => registerStyles(cache, s, false))\n\n useUniversalInsertionEffect(() => {\n styles.forEach(s => insertStyles(cache, s, false))\n })\n}\n\nfunction useUniversalInsertionEffect(effect: () => void) {\n useInsertionEffect(effect)\n if (isServer()) effect()\n}\n\nexport function serializedStyleClassName(\n cache: EmotionCache,\n serialized: SerializedStyles,\n): string {\n // see https://github.com/emotion-js/emotion/blob/main/packages/utils/src/index.ts#L26\n return `${cache.key}-${serialized.name}`\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAGlB,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,oBAA2C;AAEpE,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AAEzB,MAAM,8BAA8B;AACpC,MAAM,qBAAqB,MAAM,2BAA2B,KAAK,MAAM;AAEhE,SAAS,SAAS,OAA0B;AACjD,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,gBAAgB,CAAC,KAAK,GAAG,MAAM,UAAU;AAE5D,iBAAe,OAAO,YAAY,KAAK;AAEvC,8BAA4B,MAAM;AAChC,iBAAa,OAAO,YAAY,KAAK;AAAA,EACvC,CAAC;AAED,SAAO,yBAAyB,OAAO,UAAU;AACnD;AAEO,SAAS,UAAU,OAAqB,QAA4B;AACzE,SAAO,QAAQ,OAAK,eAAe,OAAO,GAAG,KAAK,CAAC;AAEnD,8BAA4B,MAAM;AAChC,WAAO,QAAQ,OAAK,aAAa,OAAO,GAAG,KAAK,CAAC;AAAA,EACnD,CAAC;AACH;AAEA,SAAS,4BAA4B,QAAoB;AACvD,qBAAmB,MAAM;AACzB,MAAI,SAAS;AAAG,WAAO;AACzB;AAEO,SAAS,yBACd,OACA,YACQ;AAER,SAAO,GAAG,MAAM,GAAG,IAAI,WAAW,IAAI;AACxC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/utils/prop-error-handling-proxy.ts"],"sourcesContent":["import { type Resolvable } from '@makeswift/controls'\n\nexport function propErrorHandlingProxy<T>(\n resolvable: Resolvable<T>,\n fallback: T,\n onError?: (error: unknown) => void,\n): Resolvable<T> {\n return {\n ...resolvable,\n readStable: () => {\n try {\n return resolvable.readStable()\n } catch (err: unknown) {\n onError?.(err)\n return fallback\n }\n },\n }\n}\n"],"mappings":"AAEO,SAAS,uBACd,YACA,UACA,SACe;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY,MAAM;AAChB,UAAI;AACF,eAAO,WAAW,WAAW;AAAA,MAC/B,SAAS,KAAc;AACrB,kBAAU,GAAG;AACb,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/utils/suppress-ref-warning.ts"],"sourcesContent":["const originalError = console.error\nlet patched = false\n\n/**\n * @see https://github.com/facebook/react/blob/a2505792ed17fd4d7ddc69561053c3ac90899491/packages/react-reconciler/src/ReactFiberBeginWork.new.js#L1814-L1890\n */\nexport function suppressRefWarning(ownerName: string): void {\n if (patched === false) {\n console.error = (...args) => {\n if (\n typeof args[0] === 'string' &&\n args[0].includes('Function components cannot be given refs.') &&\n args[0].includes(`Check the render method of \\`${ownerName}\\`.`)\n ) {\n return\n }\n\n return originalError(...args)\n }\n\n patched = true\n }\n}\n"],"mappings":"AAAA,MAAM,gBAAgB,QAAQ;AAC9B,IAAI,UAAU;AAKP,SAAS,mBAAmB,WAAyB;AAC1D,MAAI,YAAY,OAAO;AACrB,YAAQ,QAAQ,IAAI,SAAS;AAC3B,UACE,OAAO,KAAK,CAAC,MAAM,YACnB,KAAK,CAAC,EAAE,SAAS,2CAA2C,KAC5D,KAAK,CAAC,EAAE,SAAS,gCAAgC,SAAS,KAAK,GAC/D;AACA;AAAA,MACF;AAEA,aAAO,cAAc,GAAG,IAAI;AAAA,IAC9B;AAEA,cAAU;AAAA,EACZ;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/slate/BlockPlugin/utils/location.ts"],"sourcesContent":["import { Range, Point, Path, Location } from 'slate'\n\nexport const LocationUtils = {\n getStartPath(location: Location): Path {\n if (Range.isRange(location)) return Range.start(location).path\n if (Point.isPoint(location)) return location.path\n return location\n },\n}\n"],"mappings":"AAAA,SAAS,OAAO,aAA6B;AAEtC,MAAM,gBAAgB;AAAA,EAC3B,aAAa,UAA0B;AACrC,QAAI,MAAM,QAAQ,QAAQ;AAAG,aAAO,MAAM,MAAM,QAAQ,EAAE;AAC1D,QAAI,MAAM,QAAQ,QAAQ;AAAG,aAAO,SAAS;AAC7C,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,12 +0,0 @@
1
- import { Transforms } from "slate";
2
- import { getSelection } from "../selectors";
3
- function wrapInline(editor, inline) {
4
- Transforms.wrapNodes(editor, inline, {
5
- at: getSelection(editor),
6
- split: true
7
- });
8
- }
9
- export {
10
- wrapInline
11
- };
12
- //# sourceMappingURL=wrapInline.js.map