@makeswift/runtime 0.26.4-canary.1 → 0.26.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (700) hide show
  1. package/dist/cjs/api/client.js +2 -13
  2. package/dist/cjs/api/client.js.map +1 -1
  3. package/dist/cjs/api/react.js +256 -0
  4. package/dist/cjs/api/react.js.map +1 -0
  5. package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -1
  6. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  7. package/dist/cjs/api-handler/handlers/merge-translated-data.js.map +1 -1
  8. package/dist/cjs/api-handler/handlers/translatable-data.js.map +1 -1
  9. package/dist/cjs/api-handler/handlers/webhook/diff-projection.js +62 -0
  10. package/dist/cjs/api-handler/handlers/webhook/diff-projection.js.map +1 -0
  11. package/dist/cjs/builder/host-to-builder-actions.js +3 -3
  12. package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
  13. package/dist/cjs/builder/index.js +2 -2
  14. package/dist/cjs/builder/index.js.map +1 -1
  15. package/dist/cjs/builder/serialization.js +78 -0
  16. package/dist/cjs/builder/serialization.js.map +1 -0
  17. package/dist/cjs/client/index.js +8 -8
  18. package/dist/cjs/client/index.js.map +1 -1
  19. package/dist/cjs/components/builtin/Box/Box.js +1 -1
  20. package/dist/cjs/components/builtin/Box/Box.js.map +1 -1
  21. package/dist/cjs/components/builtin/Form/Form.js +1 -1
  22. package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
  23. package/dist/cjs/components/hooks/useTableFormFieldRefs.js +1 -1
  24. package/dist/cjs/components/hooks/useTableFormFieldRefs.js.map +1 -1
  25. package/dist/cjs/controls/serialization/base/index.js +78 -0
  26. package/dist/cjs/controls/serialization/base/index.js.map +1 -0
  27. package/dist/cjs/controls/serialization/base/visitor.js +59 -0
  28. package/dist/cjs/controls/serialization/base/visitor.js.map +1 -0
  29. package/dist/cjs/controls/serialization/index.js +55 -0
  30. package/dist/cjs/controls/serialization/index.js.map +1 -0
  31. package/dist/cjs/controls/serialization/message-port/function-serialization.js +79 -0
  32. package/dist/cjs/controls/serialization/message-port/function-serialization.js.map +1 -0
  33. package/dist/cjs/controls/serialization/message-port/index.js +25 -0
  34. package/dist/cjs/controls/serialization/message-port/index.js.map +1 -0
  35. package/dist/cjs/controls/serialization/message-port/visitor.js +48 -0
  36. package/dist/cjs/controls/serialization/message-port/visitor.js.map +1 -0
  37. package/dist/cjs/next/api-handler/config/app-router.js +10 -1
  38. package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
  39. package/dist/cjs/next/api-handler/config/pages-router.js +1 -1
  40. package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -1
  41. package/dist/cjs/next/components/framework-provider/index.js +1 -1
  42. package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
  43. package/dist/cjs/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  44. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  45. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  46. package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  47. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +2 -1
  48. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  49. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  50. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  51. package/dist/cjs/next/fetch.js +30 -0
  52. package/dist/cjs/next/fetch.js.map +1 -0
  53. package/dist/cjs/next/runtime.js +35 -0
  54. package/dist/cjs/next/runtime.js.map +1 -0
  55. package/dist/cjs/next/testing/element-data.js +3 -3
  56. package/dist/cjs/next/testing/element-data.js.map +1 -1
  57. package/dist/cjs/next/testing/index.js +0 -2
  58. package/dist/cjs/next/testing/index.js.map +1 -1
  59. package/dist/cjs/next/testing/page-rendering.js +3 -3
  60. package/dist/cjs/next/testing/page-rendering.js.map +1 -1
  61. package/dist/cjs/prop-controllers/descriptors.js.map +1 -1
  62. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  63. package/dist/cjs/prop-controllers/serialization.js +355 -0
  64. package/dist/cjs/prop-controllers/serialization.js.map +1 -0
  65. package/dist/cjs/runtimes/react/components/Document.js +2 -2
  66. package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
  67. package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
  68. package/dist/cjs/runtimes/react/components/Element.js +2 -2
  69. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  70. package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
  71. package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
  72. package/dist/cjs/runtimes/react/components/ElementRegistration.js +2 -2
  73. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  74. package/dist/cjs/runtimes/react/components/GoogleFontLink.js +55 -0
  75. package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -0
  76. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
  77. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  78. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +33 -0
  79. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  80. package/dist/cjs/runtimes/react/components/RuntimeProvider.js +5 -6
  81. package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
  82. package/dist/cjs/runtimes/react/components/framework-context.js +13 -3
  83. package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
  84. package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
  85. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +3 -2
  86. package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  87. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  88. package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  89. package/dist/cjs/runtimes/react/controls.js +2 -2
  90. package/dist/cjs/runtimes/react/controls.js.map +1 -1
  91. package/dist/cjs/runtimes/react/element-imperative-handle.js +1 -1
  92. package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
  93. package/dist/cjs/runtimes/react/hooks/use-async-effect.js +55 -0
  94. package/dist/cjs/runtimes/react/hooks/use-async-effect.js.map +1 -0
  95. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js +2 -2
  96. package/dist/cjs/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  97. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js +2 -2
  98. package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  99. package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
  100. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  101. package/dist/cjs/runtimes/react/hooks/use-component.js +3 -3
  102. package/dist/cjs/runtimes/react/hooks/use-component.js.map +1 -1
  103. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js +39 -0
  104. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  105. package/dist/cjs/runtimes/react/hooks/use-dispatch.js.map +1 -1
  106. package/dist/cjs/runtimes/react/hooks/use-document.js +2 -2
  107. package/dist/cjs/runtimes/react/hooks/use-document.js.map +1 -1
  108. package/dist/cjs/runtimes/react/hooks/use-element-id.js +2 -2
  109. package/dist/cjs/runtimes/react/hooks/use-element-id.js.map +1 -1
  110. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js +2 -2
  111. package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  112. package/dist/cjs/runtimes/react/hooks/use-is-preview.js +33 -0
  113. package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
  114. package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
  115. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +2 -2
  116. package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  117. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +1 -1
  118. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  119. package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
  120. package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
  121. package/dist/cjs/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  122. package/dist/cjs/runtimes/react/host-api-client.js +3 -4
  123. package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
  124. package/dist/cjs/runtimes/react/index.js +3 -3
  125. package/dist/cjs/runtimes/react/index.js.map +1 -1
  126. package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js +59 -0
  127. package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
  128. package/dist/cjs/runtimes/react/poll-box-model.js +1 -1
  129. package/dist/cjs/runtimes/react/poll-box-model.js.map +1 -1
  130. package/dist/cjs/runtimes/react/react-runtime-core.js +3 -3
  131. package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
  132. package/dist/cjs/runtimes/react/runtime-core.js +2 -4
  133. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  134. package/dist/cjs/runtimes/react/testing/react-runtime.js +3 -2
  135. package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
  136. package/dist/cjs/runtimes/react/utils/can-accept-ref.js.map +1 -1
  137. package/dist/cjs/runtimes/react/utils/google-fonts-url.js +49 -0
  138. package/dist/cjs/runtimes/react/utils/google-fonts-url.js.map +1 -0
  139. package/dist/cjs/state/actions/internal/read-only-actions.js +25 -17
  140. package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
  141. package/dist/cjs/state/actions/internal/read-write-actions.js +7 -1
  142. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  143. package/dist/cjs/state/actions/internal.js +205 -0
  144. package/dist/cjs/state/actions/internal.js.map +1 -0
  145. package/dist/cjs/state/builder-api/actions.js +8 -11
  146. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  147. package/dist/cjs/state/builder-api/api.js +17 -0
  148. package/dist/cjs/state/builder-api/api.js.map +1 -0
  149. package/dist/cjs/state/builder-api/navigation-listener.js +110 -0
  150. package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -0
  151. package/dist/cjs/state/host-api.js.map +1 -1
  152. package/dist/cjs/state/makeswift-api-client.js +20 -34
  153. package/dist/cjs/state/makeswift-api-client.js.map +1 -1
  154. package/dist/cjs/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
  155. package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -0
  156. package/dist/cjs/state/middleware/read-write/builder-api/index.js +11 -2
  157. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
  158. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
  159. package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
  160. package/dist/cjs/state/middleware/read-write/index.js +40 -0
  161. package/dist/cjs/state/middleware/read-write/index.js.map +1 -0
  162. package/dist/cjs/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
  163. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -0
  164. package/dist/cjs/state/mixins/breakpoint-watch.js +72 -0
  165. package/dist/cjs/state/mixins/breakpoint-watch.js.map +1 -0
  166. package/dist/cjs/state/modules/api-resources.js +4 -7
  167. package/dist/cjs/state/modules/api-resources.js.map +1 -1
  168. package/dist/cjs/state/modules/box-models.js +127 -0
  169. package/dist/cjs/state/modules/box-models.js.map +1 -0
  170. package/dist/cjs/state/modules/breakpoints.js +1 -2
  171. package/dist/cjs/state/modules/breakpoints.js.map +1 -1
  172. package/dist/cjs/state/modules/builder-edit-mode.js +1 -2
  173. package/dist/cjs/state/modules/builder-edit-mode.js.map +1 -1
  174. package/dist/cjs/state/modules/components-meta.js +2 -3
  175. package/dist/cjs/state/modules/components-meta.js.map +1 -1
  176. package/dist/cjs/state/modules/element-imperative-handles.js +60 -0
  177. package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
  178. package/dist/cjs/state/modules/element-trees.js +3 -5
  179. package/dist/cjs/state/modules/element-trees.js.map +1 -1
  180. package/dist/cjs/state/modules/is-in-builder.js +1 -2
  181. package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
  182. package/dist/cjs/state/modules/is-preview.js +47 -0
  183. package/dist/cjs/state/modules/is-preview.js.map +1 -0
  184. package/dist/cjs/state/modules/locale.js +1 -4
  185. package/dist/cjs/state/modules/locale.js.map +1 -1
  186. package/dist/cjs/state/modules/localized-resources-map.js +2 -4
  187. package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
  188. package/dist/cjs/state/modules/pointer.js +47 -0
  189. package/dist/cjs/state/modules/pointer.js.map +1 -0
  190. package/dist/cjs/state/modules/prop-controllers.js +2 -3
  191. package/dist/cjs/state/modules/prop-controllers.js.map +1 -1
  192. package/dist/cjs/state/modules/react-components.js +2 -3
  193. package/dist/cjs/state/modules/react-components.js.map +1 -1
  194. package/dist/cjs/state/modules/read-only-documents.js +2 -3
  195. package/dist/cjs/state/modules/read-only-documents.js.map +1 -1
  196. package/dist/cjs/state/modules/read-write/box-models.js +17 -2
  197. package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
  198. package/dist/cjs/state/modules/read-write-documents.js +98 -0
  199. package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
  200. package/dist/cjs/state/modules/site-version.js +0 -3
  201. package/dist/cjs/state/modules/site-version.js.map +1 -1
  202. package/dist/cjs/state/react-builder-preview.js +508 -18
  203. package/dist/cjs/state/react-builder-preview.js.map +1 -1
  204. package/dist/cjs/state/react-page.js +250 -6
  205. package/dist/cjs/state/react-page.js.map +1 -1
  206. package/dist/cjs/state/read-only-state.js +23 -1
  207. package/dist/cjs/state/read-only-state.js.map +1 -1
  208. package/dist/cjs/state/read-write-state.js +9 -2
  209. package/dist/cjs/state/read-write-state.js.map +1 -1
  210. package/dist/cjs/state/shared-api.js.map +1 -1
  211. package/dist/cjs/state/store.js +219 -0
  212. package/dist/cjs/state/store.js.map +1 -0
  213. package/dist/cjs/state/translations/get.js +2 -2
  214. package/dist/cjs/state/translations/get.js.map +1 -1
  215. package/dist/cjs/state/translations/merge.js +2 -2
  216. package/dist/cjs/state/translations/merge.js.map +1 -1
  217. package/dist/cjs/state/unified-state.js +17 -0
  218. package/dist/cjs/state/unified-state.js.map +1 -0
  219. package/dist/cjs/translations/index.js +32 -0
  220. package/dist/cjs/translations/index.js.map +1 -0
  221. package/dist/cjs/unstable-framework-support/index.js +4 -2
  222. package/dist/cjs/unstable-framework-support/index.js.map +1 -1
  223. package/dist/cjs/utils/deferred.js +39 -0
  224. package/dist/cjs/utils/deferred.js.map +1 -0
  225. package/dist/cjs/utils/ref-counted-map.js +120 -0
  226. package/dist/cjs/utils/ref-counted-map.js.map +1 -0
  227. package/dist/esm/api/client.js +2 -13
  228. package/dist/esm/api/client.js.map +1 -1
  229. package/dist/esm/api/react.js +223 -0
  230. package/dist/esm/api/react.js.map +1 -0
  231. package/dist/esm/api-handler/handlers/element-tree.js.map +1 -1
  232. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  233. package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -1
  234. package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -1
  235. package/dist/esm/api-handler/handlers/webhook/diff-projection.js +38 -0
  236. package/dist/esm/api-handler/handlers/webhook/diff-projection.js.map +1 -0
  237. package/dist/esm/builder/host-to-builder-actions.js +4 -4
  238. package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
  239. package/dist/esm/builder/index.js +1 -1
  240. package/dist/esm/builder/index.js.map +1 -1
  241. package/dist/esm/builder/serialization.js +59 -0
  242. package/dist/esm/builder/serialization.js.map +1 -0
  243. package/dist/esm/client/index.js +5 -5
  244. package/dist/esm/client/index.js.map +1 -1
  245. package/dist/esm/components/builtin/Box/Box.js +1 -1
  246. package/dist/esm/components/builtin/Box/Box.js.map +1 -1
  247. package/dist/esm/components/builtin/Form/Form.js +1 -1
  248. package/dist/esm/components/builtin/Form/Form.js.map +1 -1
  249. package/dist/esm/components/hooks/useTableFormFieldRefs.js +1 -1
  250. package/dist/esm/components/hooks/useTableFormFieldRefs.js.map +1 -1
  251. package/dist/esm/controls/serialization/base/index.js +78 -0
  252. package/dist/esm/controls/serialization/base/index.js.map +1 -0
  253. package/dist/esm/controls/serialization/base/visitor.js +39 -0
  254. package/dist/esm/controls/serialization/base/visitor.js.map +1 -0
  255. package/dist/esm/controls/serialization/index.js +30 -0
  256. package/dist/esm/controls/serialization/index.js.map +1 -0
  257. package/dist/esm/controls/serialization/message-port/function-serialization.js +52 -0
  258. package/dist/esm/controls/serialization/message-port/function-serialization.js.map +1 -0
  259. package/dist/esm/controls/serialization/message-port/index.js +3 -0
  260. package/dist/esm/controls/serialization/message-port/index.js.map +1 -0
  261. package/dist/esm/controls/serialization/message-port/visitor.js +24 -0
  262. package/dist/esm/controls/serialization/message-port/visitor.js.map +1 -0
  263. package/dist/esm/next/api-handler/config/app-router.js +10 -1
  264. package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
  265. package/dist/esm/next/api-handler/config/pages-router.js +1 -1
  266. package/dist/esm/next/api-handler/config/pages-router.js.map +1 -1
  267. package/dist/esm/next/components/framework-provider/index.js +5 -2
  268. package/dist/esm/next/components/framework-provider/index.js.map +1 -1
  269. package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  270. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +2 -1
  271. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  272. package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  273. package/dist/esm/next/components/tests/makeswift-component/fixtures.js +2 -1
  274. package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -1
  275. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
  276. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  277. package/dist/esm/next/fetch.js +6 -0
  278. package/dist/esm/next/fetch.js.map +1 -0
  279. package/dist/esm/next/runtime.js +11 -0
  280. package/dist/esm/next/runtime.js.map +1 -0
  281. package/dist/esm/next/testing/element-data.js +1 -1
  282. package/dist/esm/next/testing/element-data.js.map +1 -1
  283. package/dist/esm/next/testing/index.js +0 -1
  284. package/dist/esm/next/testing/index.js.map +1 -1
  285. package/dist/esm/next/testing/page-rendering.js +3 -3
  286. package/dist/esm/next/testing/page-rendering.js.map +1 -1
  287. package/dist/esm/prop-controllers/descriptors.js.map +1 -1
  288. package/dist/esm/prop-controllers/instances.js.map +1 -1
  289. package/dist/esm/prop-controllers/serialization.js +338 -0
  290. package/dist/esm/prop-controllers/serialization.js.map +1 -0
  291. package/dist/esm/runtimes/react/components/Document.js +1 -1
  292. package/dist/esm/runtimes/react/components/Document.js.map +1 -1
  293. package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
  294. package/dist/esm/runtimes/react/components/Element.js +1 -3
  295. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  296. package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
  297. package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
  298. package/dist/esm/runtimes/react/components/ElementRegistration.js +1 -1
  299. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  300. package/dist/esm/runtimes/react/components/GoogleFontLink.js +35 -0
  301. package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -0
  302. package/dist/esm/runtimes/react/components/MakeswiftComponent.js +1 -1
  303. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  304. package/dist/esm/runtimes/react/components/MakeswiftFonts.js +9 -0
  305. package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  306. package/dist/esm/runtimes/react/components/RuntimeProvider.js +4 -5
  307. package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
  308. package/dist/esm/runtimes/react/components/framework-context.js +14 -2
  309. package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
  310. package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
  311. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +3 -2
  312. package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
  313. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
  314. package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  315. package/dist/esm/runtimes/react/controls.js +2 -2
  316. package/dist/esm/runtimes/react/controls.js.map +1 -1
  317. package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
  318. package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
  319. package/dist/esm/runtimes/react/hooks/use-async-effect.js +31 -0
  320. package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +1 -0
  321. package/dist/esm/runtimes/react/hooks/use-breakpoints.js +1 -1
  322. package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -1
  323. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js +1 -1
  324. package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
  325. package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
  326. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  327. package/dist/esm/runtimes/react/hooks/use-component.js +1 -1
  328. package/dist/esm/runtimes/react/hooks/use-component.js.map +1 -1
  329. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js +15 -0
  330. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  331. package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +1 -1
  332. package/dist/esm/runtimes/react/hooks/use-document.js +1 -1
  333. package/dist/esm/runtimes/react/hooks/use-document.js.map +1 -1
  334. package/dist/esm/runtimes/react/hooks/use-element-id.js +1 -1
  335. package/dist/esm/runtimes/react/hooks/use-element-id.js.map +1 -1
  336. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js +1 -1
  337. package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
  338. package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
  339. package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
  340. package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
  341. package/dist/esm/runtimes/react/hooks/use-resolved-props.js +2 -2
  342. package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
  343. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +1 -1
  344. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  345. package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
  346. package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
  347. package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
  348. package/dist/esm/runtimes/react/host-api-client.js +2 -3
  349. package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
  350. package/dist/esm/runtimes/react/index.js +2 -2
  351. package/dist/esm/runtimes/react/index.js.map +1 -1
  352. package/dist/esm/runtimes/react/lib/resolved-style-to-css.js +38 -0
  353. package/dist/esm/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
  354. package/dist/esm/runtimes/react/poll-box-model.js +1 -1
  355. package/dist/esm/runtimes/react/poll-box-model.js.map +1 -1
  356. package/dist/esm/runtimes/react/react-runtime-core.js +1 -4
  357. package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
  358. package/dist/esm/runtimes/react/runtime-core.js +5 -3
  359. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  360. package/dist/esm/runtimes/react/testing/react-runtime.js +3 -2
  361. package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
  362. package/dist/esm/runtimes/react/utils/can-accept-ref.js.map +1 -1
  363. package/dist/esm/runtimes/react/utils/google-fonts-url.js +23 -0
  364. package/dist/esm/runtimes/react/utils/google-fonts-url.js.map +1 -0
  365. package/dist/esm/state/actions/internal/read-only-actions.js +21 -14
  366. package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
  367. package/dist/esm/state/actions/internal/read-write-actions.js +6 -1
  368. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  369. package/dist/esm/state/actions/internal.js +162 -0
  370. package/dist/esm/state/actions/internal.js.map +1 -0
  371. package/dist/esm/state/builder-api/actions.js +7 -8
  372. package/dist/esm/state/builder-api/actions.js.map +1 -1
  373. package/dist/esm/state/builder-api/api.js +1 -0
  374. package/dist/esm/state/builder-api/api.js.map +1 -0
  375. package/dist/esm/state/builder-api/navigation-listener.js +86 -0
  376. package/dist/esm/state/builder-api/navigation-listener.js.map +1 -0
  377. package/dist/esm/state/host-api.js.map +1 -1
  378. package/dist/esm/state/makeswift-api-client.js +19 -33
  379. package/dist/esm/state/makeswift-api-client.js.map +1 -1
  380. package/dist/esm/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
  381. package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -0
  382. package/dist/esm/state/middleware/read-write/builder-api/index.js +11 -2
  383. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
  384. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
  385. package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
  386. package/dist/esm/state/middleware/read-write/index.js +16 -0
  387. package/dist/esm/state/middleware/read-write/index.js.map +1 -0
  388. package/dist/esm/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
  389. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -0
  390. package/dist/esm/state/mixins/breakpoint-watch.js +48 -0
  391. package/dist/esm/state/mixins/breakpoint-watch.js.map +1 -0
  392. package/dist/esm/state/modules/api-resources.js +5 -8
  393. package/dist/esm/state/modules/api-resources.js.map +1 -1
  394. package/dist/esm/state/modules/box-models.js +98 -0
  395. package/dist/esm/state/modules/box-models.js.map +1 -0
  396. package/dist/esm/state/modules/breakpoints.js +2 -3
  397. package/dist/esm/state/modules/breakpoints.js.map +1 -1
  398. package/dist/esm/state/modules/builder-edit-mode.js +2 -3
  399. package/dist/esm/state/modules/builder-edit-mode.js.map +1 -1
  400. package/dist/esm/state/modules/components-meta.js +3 -4
  401. package/dist/esm/state/modules/components-meta.js.map +1 -1
  402. package/dist/esm/state/modules/element-imperative-handles.js +35 -0
  403. package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
  404. package/dist/esm/state/modules/element-trees.js +4 -6
  405. package/dist/esm/state/modules/element-trees.js.map +1 -1
  406. package/dist/esm/state/modules/is-in-builder.js +2 -3
  407. package/dist/esm/state/modules/is-in-builder.js.map +1 -1
  408. package/dist/esm/state/modules/is-preview.js +21 -0
  409. package/dist/esm/state/modules/is-preview.js.map +1 -0
  410. package/dist/esm/state/modules/locale.js +1 -4
  411. package/dist/esm/state/modules/locale.js.map +1 -1
  412. package/dist/esm/state/modules/localized-resources-map.js +3 -5
  413. package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
  414. package/dist/esm/state/modules/pointer.js +22 -0
  415. package/dist/esm/state/modules/pointer.js.map +1 -0
  416. package/dist/esm/state/modules/prop-controllers.js +3 -4
  417. package/dist/esm/state/modules/prop-controllers.js.map +1 -1
  418. package/dist/esm/state/modules/react-components.js +3 -4
  419. package/dist/esm/state/modules/react-components.js.map +1 -1
  420. package/dist/esm/state/modules/read-only-documents.js +6 -4
  421. package/dist/esm/state/modules/read-only-documents.js.map +1 -1
  422. package/dist/esm/state/modules/read-write/box-models.js +16 -2
  423. package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
  424. package/dist/esm/state/modules/read-write-documents.js +60 -0
  425. package/dist/esm/state/modules/read-write-documents.js.map +1 -0
  426. package/dist/esm/state/modules/site-version.js +0 -3
  427. package/dist/esm/state/modules/site-version.js.map +1 -1
  428. package/dist/esm/state/react-builder-preview.js +500 -15
  429. package/dist/esm/state/react-builder-preview.js.map +1 -1
  430. package/dist/esm/state/react-page.js +240 -7
  431. package/dist/esm/state/react-page.js.map +1 -1
  432. package/dist/esm/state/read-only-state.js +20 -1
  433. package/dist/esm/state/read-only-state.js.map +1 -1
  434. package/dist/esm/state/read-write-state.js +7 -1
  435. package/dist/esm/state/read-write-state.js.map +1 -1
  436. package/dist/esm/state/shared-api.js.map +1 -1
  437. package/dist/esm/state/store.js +188 -0
  438. package/dist/esm/state/store.js.map +1 -0
  439. package/dist/esm/state/translations/get.js +1 -1
  440. package/dist/esm/state/translations/get.js.map +1 -1
  441. package/dist/esm/state/translations/merge.js +1 -1
  442. package/dist/esm/state/translations/merge.js.map +1 -1
  443. package/dist/esm/state/unified-state.js +1 -0
  444. package/dist/esm/state/unified-state.js.map +1 -0
  445. package/dist/esm/translations/index.js +7 -0
  446. package/dist/esm/translations/index.js.map +1 -0
  447. package/dist/esm/unstable-framework-support/index.js +4 -2
  448. package/dist/esm/unstable-framework-support/index.js.map +1 -1
  449. package/dist/esm/utils/deferred.js +15 -0
  450. package/dist/esm/utils/deferred.js.map +1 -0
  451. package/dist/esm/utils/ref-counted-map.js +96 -0
  452. package/dist/esm/utils/ref-counted-map.js.map +1 -0
  453. package/dist/types/api/client.d.ts +2 -5
  454. package/dist/types/api/client.d.ts.map +1 -1
  455. package/dist/types/api/react.d.ts +82 -0
  456. package/dist/types/api/react.d.ts.map +1 -0
  457. package/dist/types/api-handler/handlers/element-tree.d.ts +1 -1
  458. package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -1
  459. package/dist/types/api-handler/handlers/merge-translated-data.d.ts +1 -1
  460. package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -1
  461. package/dist/types/api-handler/handlers/translatable-data.d.ts +1 -1
  462. package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -1
  463. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +201 -0
  464. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts.map +1 -0
  465. package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
  466. package/dist/types/builder/host-to-builder-actions.d.ts +2 -2
  467. package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
  468. package/dist/types/builder/index.d.ts +2 -2
  469. package/dist/types/builder/index.d.ts.map +1 -1
  470. package/dist/types/builder/serialization.d.ts +23 -0
  471. package/dist/types/builder/serialization.d.ts.map +1 -0
  472. package/dist/types/builder/serialization.test.d.ts +2 -0
  473. package/dist/types/builder/serialization.test.d.ts.map +1 -0
  474. package/dist/types/client/index.d.ts +2 -2
  475. package/dist/types/client/index.d.ts.map +1 -1
  476. package/dist/types/client/tests/client.get-component-snapshots.test.d.ts +2 -0
  477. package/dist/types/client/tests/client.get-component-snapshots.test.d.ts.map +1 -0
  478. package/dist/types/client/tests/client.get-fonts.test.d.ts +2 -0
  479. package/dist/types/client/tests/client.get-fonts.test.d.ts.map +1 -0
  480. package/dist/types/client/tests/client.introspect-many.test.d.ts +2 -0
  481. package/dist/types/client/tests/client.introspect-many.test.d.ts.map +1 -0
  482. package/dist/types/components/builtin/Box/Box.d.ts +1 -1
  483. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  484. package/dist/types/components/builtin/Form/Form.d.ts +1 -1
  485. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  486. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts +3 -0
  487. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
  488. package/dist/types/controls/serialization/base/index.d.ts +10 -0
  489. package/dist/types/controls/serialization/base/index.d.ts.map +1 -0
  490. package/dist/types/controls/serialization/base/visitor.d.ts +7 -0
  491. package/dist/types/controls/serialization/base/visitor.d.ts.map +1 -0
  492. package/dist/types/controls/serialization/index.d.ts +10 -0
  493. package/dist/types/controls/serialization/index.d.ts.map +1 -0
  494. package/dist/types/controls/serialization/message-port/function-serialization.d.ts +16 -0
  495. package/dist/types/controls/serialization/message-port/function-serialization.d.ts.map +1 -0
  496. package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts +2 -0
  497. package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts.map +1 -0
  498. package/dist/types/controls/serialization/message-port/index.d.ts +3 -0
  499. package/dist/types/controls/serialization/message-port/index.d.ts.map +1 -0
  500. package/dist/types/controls/serialization/message-port/visitor.d.ts +7 -0
  501. package/dist/types/controls/serialization/message-port/visitor.d.ts.map +1 -0
  502. package/dist/types/locale.d.ts +1 -1
  503. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
  504. package/dist/types/next/api-handler/config/pages-router.test.d.ts +2 -0
  505. package/dist/types/next/api-handler/config/pages-router.test.d.ts.map +1 -0
  506. package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
  507. package/dist/types/next/components/tests/controls/code-control.test.d.ts +2 -0
  508. package/dist/types/next/components/tests/controls/code-control.test.d.ts.map +1 -0
  509. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
  510. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  511. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +3 -3
  512. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  513. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
  514. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  515. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +1 -1
  516. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -1
  517. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts +1 -1
  518. package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts.map +1 -1
  519. package/dist/types/next/fetch.d.ts +3 -0
  520. package/dist/types/next/fetch.d.ts.map +1 -0
  521. package/dist/types/next/runtime.d.ts +10 -0
  522. package/dist/types/next/runtime.d.ts.map +1 -0
  523. package/dist/types/next/testing/element-data.d.ts +1 -1
  524. package/dist/types/next/testing/element-data.d.ts.map +1 -1
  525. package/dist/types/next/testing/index.d.ts +0 -1
  526. package/dist/types/next/testing/index.d.ts.map +1 -1
  527. package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
  528. package/dist/types/prop-controllers/descriptors.d.ts +1 -1
  529. package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
  530. package/dist/types/prop-controllers/instances.d.ts +1 -1
  531. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  532. package/dist/types/prop-controllers/serialization.d.ts +228 -0
  533. package/dist/types/prop-controllers/serialization.d.ts.map +1 -0
  534. package/dist/types/runtimes/react/components/Document.d.ts +1 -1
  535. package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
  536. package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
  537. package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
  538. package/dist/types/runtimes/react/components/Element.d.ts +1 -1
  539. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  540. package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
  541. package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
  542. package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
  543. package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
  544. package/dist/types/runtimes/react/components/GoogleFontLink.d.ts +14 -0
  545. package/dist/types/runtimes/react/components/GoogleFontLink.d.ts.map +1 -0
  546. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +7 -0
  547. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +1 -0
  548. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +1 -1
  549. package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
  550. package/dist/types/runtimes/react/components/framework-context.d.ts +4 -2
  551. package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
  552. package/dist/types/runtimes/react/components/page/Page.d.ts +1 -1
  553. package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
  554. package/dist/types/runtimes/react/controls.d.ts +2 -2
  555. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  556. package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
  557. package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  558. package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts +2 -0
  559. package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts.map +1 -0
  560. package/dist/types/runtimes/react/hooks/use-async-effect.d.ts +3 -0
  561. package/dist/types/runtimes/react/hooks/use-async-effect.d.ts.map +1 -0
  562. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
  563. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
  564. package/dist/types/runtimes/react/hooks/use-component.d.ts +1 -1
  565. package/dist/types/runtimes/react/hooks/use-component.d.ts.map +1 -1
  566. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts +3 -0
  567. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts.map +1 -0
  568. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts +3 -3
  569. package/dist/types/runtimes/react/hooks/use-dispatch.d.ts.map +1 -1
  570. package/dist/types/runtimes/react/hooks/use-document.d.ts +1 -1
  571. package/dist/types/runtimes/react/hooks/use-document.d.ts.map +1 -1
  572. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
  573. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
  574. package/dist/types/runtimes/react/hooks/use-register-document.d.ts +1 -1
  575. package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
  576. package/dist/types/runtimes/react/hooks/use-selector.d.ts +3 -3
  577. package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
  578. package/dist/types/runtimes/react/hooks/use-store.d.ts +4 -4
  579. package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
  580. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts +1 -1
  581. package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts.map +1 -1
  582. package/dist/types/runtimes/react/host-api-client.d.ts +1 -1
  583. package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
  584. package/dist/types/runtimes/react/index.d.ts +1 -1
  585. package/dist/types/runtimes/react/index.d.ts.map +1 -1
  586. package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts +4 -0
  587. package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts.map +1 -0
  588. package/dist/types/runtimes/react/poll-box-model.d.ts +1 -1
  589. package/dist/types/runtimes/react/poll-box-model.d.ts.map +1 -1
  590. package/dist/types/runtimes/react/react-runtime-core.d.ts +1 -1
  591. package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
  592. package/dist/types/runtimes/react/runtime-core.d.ts +1 -2
  593. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  594. package/dist/types/runtimes/react/testing/react-runtime.d.ts +4 -1
  595. package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
  596. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts +1 -1
  597. package/dist/types/runtimes/react/utils/can-accept-ref.d.ts.map +1 -1
  598. package/dist/types/runtimes/react/utils/google-fonts-url.d.ts +6 -0
  599. package/dist/types/runtimes/react/utils/google-fonts-url.d.ts.map +1 -0
  600. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts +5 -0
  601. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts.map +1 -0
  602. package/dist/types/state/__tests__/fixtures/translatable-content-sample.d.ts +3 -0
  603. package/dist/types/state/__tests__/fixtures/translatable-content-sample.d.ts.map +1 -0
  604. package/dist/types/state/__tests__/get-translatable-content.test.d.ts +2 -0
  605. package/dist/types/state/__tests__/get-translatable-content.test.d.ts.map +1 -0
  606. package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
  607. package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
  608. package/dist/types/state/__tests__/store.read-write-state.test.d.ts +2 -0
  609. package/dist/types/state/__tests__/store.read-write-state.test.d.ts.map +1 -0
  610. package/dist/types/state/__tests__/test-store.d.ts +31 -0
  611. package/dist/types/state/__tests__/test-store.d.ts.map +1 -0
  612. package/dist/types/state/actions/index.d.ts +5 -8
  613. package/dist/types/state/actions/index.d.ts.map +1 -1
  614. package/dist/types/state/actions/internal/index.d.ts +4 -2
  615. package/dist/types/state/actions/internal/index.d.ts.map +1 -1
  616. package/dist/types/state/actions/internal/read-only-actions.d.ts +25 -13
  617. package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
  618. package/dist/types/state/actions/internal/read-write-actions.d.ts +6 -1
  619. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  620. package/dist/types/state/actions/internal.d.ts +181 -0
  621. package/dist/types/state/actions/internal.d.ts.map +1 -0
  622. package/dist/types/state/builder-api/actions.d.ts +14 -14
  623. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  624. package/dist/types/state/builder-api/api.d.ts +9 -0
  625. package/dist/types/state/builder-api/api.d.ts.map +1 -0
  626. package/dist/types/state/builder-api/navigation-listener.d.ts +3 -0
  627. package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -0
  628. package/dist/types/state/host-api.d.ts +1 -1
  629. package/dist/types/state/host-api.d.ts.map +1 -1
  630. package/dist/types/state/makeswift-api-client.d.ts +2 -11
  631. package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
  632. package/dist/types/state/middleware/makeswift-api-client-sync.d.ts +5 -0
  633. package/dist/types/state/middleware/makeswift-api-client-sync.d.ts.map +1 -0
  634. package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -1
  635. package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +1 -1
  636. package/dist/types/state/middleware/read-write/index.d.ts +5 -0
  637. package/dist/types/state/middleware/read-write/index.d.ts.map +1 -0
  638. package/dist/types/state/middleware/{prop-controller-handles.d.ts → read-write/prop-controller-handles.d.ts} +1 -1
  639. package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -0
  640. package/dist/types/state/mixins/breakpoint-watch.d.ts +11 -0
  641. package/dist/types/state/mixins/breakpoint-watch.d.ts.map +1 -0
  642. package/dist/types/state/modules/api-resources.d.ts.map +1 -1
  643. package/dist/types/state/modules/box-models.d.ts +23 -0
  644. package/dist/types/state/modules/box-models.d.ts.map +1 -0
  645. package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
  646. package/dist/types/state/modules/builder-edit-mode.d.ts.map +1 -1
  647. package/dist/types/state/modules/components-meta.d.ts.map +1 -1
  648. package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
  649. package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
  650. package/dist/types/state/modules/element-trees.d.ts.map +1 -1
  651. package/dist/types/state/modules/is-in-builder.d.ts.map +1 -1
  652. package/dist/types/state/modules/is-preview.d.ts +6 -0
  653. package/dist/types/state/modules/is-preview.d.ts.map +1 -0
  654. package/dist/types/state/modules/locale.d.ts.map +1 -1
  655. package/dist/types/state/modules/localized-resources-map.d.ts.map +1 -1
  656. package/dist/types/state/modules/pointer.d.ts +12 -0
  657. package/dist/types/state/modules/pointer.d.ts.map +1 -0
  658. package/dist/types/state/modules/prop-controllers.d.ts.map +1 -1
  659. package/dist/types/state/modules/react-components.d.ts.map +1 -1
  660. package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
  661. package/dist/types/state/modules/read-write/box-models.d.ts +12 -9
  662. package/dist/types/state/modules/read-write/box-models.d.ts.map +1 -1
  663. package/dist/types/state/modules/read-write-documents.d.ts +14 -0
  664. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
  665. package/dist/types/state/modules/site-version.d.ts.map +1 -1
  666. package/dist/types/state/react-builder-preview.d.ts +93 -26
  667. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  668. package/dist/types/state/react-page.d.ts +136 -20
  669. package/dist/types/state/react-page.d.ts.map +1 -1
  670. package/dist/types/state/read-only-state.d.ts +10 -1
  671. package/dist/types/state/read-only-state.d.ts.map +1 -1
  672. package/dist/types/state/read-write-state.d.ts +12 -6
  673. package/dist/types/state/read-write-state.d.ts.map +1 -1
  674. package/dist/types/state/shared-api.d.ts.map +1 -1
  675. package/dist/types/state/store.d.ts +86 -0
  676. package/dist/types/state/store.d.ts.map +1 -0
  677. package/dist/types/state/translations/get.d.ts +1 -1
  678. package/dist/types/state/translations/get.d.ts.map +1 -1
  679. package/dist/types/state/translations/merge.d.ts +1 -1
  680. package/dist/types/state/translations/merge.d.ts.map +1 -1
  681. package/dist/types/state/unified-state.d.ts +9 -0
  682. package/dist/types/state/unified-state.d.ts.map +1 -0
  683. package/dist/types/translations/index.d.ts +6 -0
  684. package/dist/types/translations/index.d.ts.map +1 -0
  685. package/dist/types/unstable-framework-support/index.d.ts +1 -1
  686. package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
  687. package/dist/types/utils/__tests__/ref-counted-map.test.d.ts +2 -0
  688. package/dist/types/utils/__tests__/ref-counted-map.test.d.ts.map +1 -0
  689. package/dist/types/utils/deferred.d.ts +7 -0
  690. package/dist/types/utils/deferred.d.ts.map +1 -0
  691. package/dist/types/utils/ref-counted-map.d.ts +32 -0
  692. package/dist/types/utils/ref-counted-map.d.ts.map +1 -0
  693. package/package.json +3 -3
  694. package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
  695. package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  696. package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
  697. package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
  698. package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
  699. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
  700. package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts.map +0 -1
@@ -33,9 +33,6 @@ __export(client_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(client_exports);
35
35
  var MakeswiftApiClient = __toESM(require("../state/makeswift-api-client"));
36
- var import_shared_api = require("../state/shared-api");
37
- var import_read_only_actions = require("../state/actions/internal/read-only-actions");
38
- var import_read_only_actions2 = require("../state/actions/internal/read-only-actions");
39
36
  var import_types = require("./types");
40
37
  var import_client = require("./graphql/client");
41
38
  var import_documents = require("./graphql/documents");
@@ -55,20 +52,12 @@ class MakeswiftHostApiClient {
55
52
  constructor({
56
53
  uri,
57
54
  fetch,
58
- cacheData,
59
- locale,
60
- siteVersion
55
+ preloadedState
61
56
  }) {
62
57
  this.graphqlClient = new import_client.GraphQLClient(uri);
63
- this.makeswiftApiClient = MakeswiftApiClient.configureStore({
64
- serializedState: cacheData
65
- });
58
+ this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState });
66
59
  this.fetch = fetch;
67
60
  this.subscribe = this.makeswiftApiClient.subscribe;
68
- this.makeswiftApiClient.dispatch(
69
- locale != null ? (0, import_shared_api.setLocale)(new Intl.Locale(locale)) : (0, import_read_only_actions.resetLocaleState)()
70
- );
71
- this.makeswiftApiClient.dispatch((0, import_read_only_actions2.setSiteVersion)(siteVersion));
72
61
  }
73
62
  readSwatch(swatchId) {
74
63
  return MakeswiftApiClient.getAPIResource(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport { setLocale } from '../state/shared-api'\nimport { resetLocaleState } from '../state/actions/internal/read-only-actions'\nimport { setSiteVersion } from '../state/actions/internal/read-only-actions'\n\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\nimport { SiteVersion } from './site-version'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n siteVersion,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n siteVersion: SiteVersion | null\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n\n this.makeswiftApiClient.dispatch(\n locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState(),\n )\n\n this.makeswiftApiClient.dispatch(setSiteVersion(siteVersion))\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoC;AACpC,wBAA0B;AAC1B,+BAAiC;AACjC,IAAAA,4BAA+B;AAE/B,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AASnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAA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AAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,6BAAgB,OAAO,SAAS,KAAK,KAAK;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_read_only_actions"]}
1
+ {"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\n\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n preloadedState,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n preloadedState: Partial<MakeswiftApiClient.State>\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoC;AAEpC,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AAQnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe,EAAE,eAAe,CAAC;AAC9E,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAAA,EAC3C;AAAA,EAEA,WAAW,UAAiC;AAC1C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MA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A,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var react_exports = {};
30
+ __export(react_exports, {
31
+ CacheData: () => CacheData,
32
+ MakeswiftHostApiClient: () => MakeswiftHostApiClient
33
+ });
34
+ module.exports = __toCommonJS(react_exports);
35
+ var MakeswiftApiClient = __toESM(require("../state/makeswift-api-client"));
36
+ var import_types = require("./types");
37
+ var import_client = require("./graphql/client");
38
+ var import_documents = require("./graphql/documents");
39
+ const CacheData = {
40
+ empty() {
41
+ return {
42
+ apiResources: {},
43
+ localizedResourcesMap: {}
44
+ };
45
+ }
46
+ };
47
+ class MakeswiftHostApiClient {
48
+ graphqlClient;
49
+ makeswiftApiClient;
50
+ subscribe;
51
+ fetch;
52
+ constructor({
53
+ uri,
54
+ fetch,
55
+ cacheData,
56
+ locale
57
+ }) {
58
+ this.graphqlClient = new import_client.GraphQLClient(uri);
59
+ this.makeswiftApiClient = MakeswiftApiClient.configureStore({
60
+ serializedState: cacheData,
61
+ defaultLocale: locale
62
+ });
63
+ this.fetch = fetch;
64
+ this.subscribe = this.makeswiftApiClient.subscribe;
65
+ }
66
+ readSwatch(swatchId) {
67
+ return MakeswiftApiClient.getAPIResource(
68
+ this.makeswiftApiClient.getState(),
69
+ import_types.APIResourceType.Swatch,
70
+ swatchId
71
+ );
72
+ }
73
+ async fetchSwatch(swatchId) {
74
+ return await this.makeswiftApiClient.dispatch(
75
+ MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Swatch, swatchId, this.fetch)
76
+ );
77
+ }
78
+ resolveSwatch(swatchId) {
79
+ return this.resolveResource(import_types.APIResourceType.Swatch, {
80
+ id: swatchId,
81
+ read: (id) => this.readSwatch(id),
82
+ fetch: (id) => this.fetchSwatch(id)
83
+ });
84
+ }
85
+ readFile(fileId) {
86
+ return MakeswiftApiClient.getAPIResource(
87
+ this.makeswiftApiClient.getState(),
88
+ import_types.APIResourceType.File,
89
+ fileId
90
+ );
91
+ }
92
+ async fetchFile(fileId) {
93
+ return await this.makeswiftApiClient.dispatch(
94
+ MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.File, fileId, this.fetch)
95
+ );
96
+ }
97
+ resolveFile(fileId) {
98
+ return this.resolveResource(import_types.APIResourceType.File, {
99
+ id: fileId,
100
+ read: (id) => this.readFile(id),
101
+ fetch: (id) => this.fetchFile(id)
102
+ });
103
+ }
104
+ readTypography(typographyId) {
105
+ return MakeswiftApiClient.getAPIResource(
106
+ this.makeswiftApiClient.getState(),
107
+ import_types.APIResourceType.Typography,
108
+ typographyId
109
+ );
110
+ }
111
+ async fetchTypography(typographyId) {
112
+ return await this.makeswiftApiClient.dispatch(
113
+ MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Typography, typographyId, this.fetch)
114
+ );
115
+ }
116
+ resolveTypography(typographyId) {
117
+ return this.resolveResource(import_types.APIResourceType.Typography, {
118
+ id: typographyId,
119
+ read: (id) => this.readTypography(id),
120
+ fetch: (id) => this.fetchTypography(id)
121
+ });
122
+ }
123
+ readGlobalElement(globalElementId) {
124
+ return MakeswiftApiClient.getAPIResource(
125
+ this.makeswiftApiClient.getState(),
126
+ import_types.APIResourceType.GlobalElement,
127
+ globalElementId
128
+ );
129
+ }
130
+ async fetchGlobalElement(globalElementId) {
131
+ return await this.makeswiftApiClient.dispatch(
132
+ MakeswiftApiClient.fetchAPIResource(
133
+ import_types.APIResourceType.GlobalElement,
134
+ globalElementId,
135
+ this.fetch
136
+ )
137
+ );
138
+ }
139
+ readLocalizedGlobalElement({
140
+ globalElementId,
141
+ locale
142
+ }) {
143
+ return MakeswiftApiClient.getAPIResource(
144
+ this.makeswiftApiClient.getState(),
145
+ import_types.APIResourceType.LocalizedGlobalElement,
146
+ globalElementId,
147
+ locale
148
+ );
149
+ }
150
+ async fetchLocalizedGlobalElement({
151
+ globalElementId,
152
+ locale
153
+ }) {
154
+ return await this.makeswiftApiClient.dispatch(
155
+ MakeswiftApiClient.fetchAPIResource(
156
+ import_types.APIResourceType.LocalizedGlobalElement,
157
+ globalElementId,
158
+ this.fetch,
159
+ locale
160
+ )
161
+ );
162
+ }
163
+ readPagePathnameSlice({
164
+ pageId,
165
+ locale
166
+ }) {
167
+ return MakeswiftApiClient.getAPIResource(
168
+ this.makeswiftApiClient.getState(),
169
+ import_types.APIResourceType.PagePathnameSlice,
170
+ pageId,
171
+ locale
172
+ );
173
+ }
174
+ async fetchPagePathnameSlice({
175
+ pageId,
176
+ locale
177
+ }) {
178
+ return await this.makeswiftApiClient.dispatch(
179
+ MakeswiftApiClient.fetchAPIResource(
180
+ import_types.APIResourceType.PagePathnameSlice,
181
+ pageId,
182
+ this.fetch,
183
+ locale
184
+ )
185
+ );
186
+ }
187
+ resolvePagePathnameSlice({
188
+ pageId,
189
+ locale
190
+ }) {
191
+ return this.resolveResource(import_types.APIResourceType.PagePathnameSlice, {
192
+ id: pageId,
193
+ read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
194
+ fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
195
+ });
196
+ }
197
+ resolveResource(type, {
198
+ id,
199
+ read,
200
+ fetch
201
+ }) {
202
+ const _read = () => id != null ? read(id) : null;
203
+ let lastValue = null;
204
+ return {
205
+ name: `${type}:${id}`,
206
+ readStable: () => lastValue = _read(),
207
+ subscribe: (onUpdate) => this.subscribe(() => {
208
+ if (_read() !== lastValue)
209
+ onUpdate();
210
+ }),
211
+ fetch: async () => id != null ? fetch(id) : null
212
+ };
213
+ }
214
+ readTable(tableId) {
215
+ return MakeswiftApiClient.getAPIResource(
216
+ this.makeswiftApiClient.getState(),
217
+ import_types.APIResourceType.Table,
218
+ tableId
219
+ );
220
+ }
221
+ async fetchTable(tableId) {
222
+ return await this.makeswiftApiClient.dispatch(
223
+ MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Table, tableId, this.fetch)
224
+ );
225
+ }
226
+ async createTableRecord(tableId, columns) {
227
+ await this.graphqlClient.request(import_documents.CreateTableRecordMutation, { input: { data: { tableId, columns } } });
228
+ }
229
+ readSite(siteId) {
230
+ return MakeswiftApiClient.getAPIResource(
231
+ this.makeswiftApiClient.getState(),
232
+ import_types.APIResourceType.Site,
233
+ siteId
234
+ );
235
+ }
236
+ readPage(pageId) {
237
+ return MakeswiftApiClient.getAPIResource(
238
+ this.makeswiftApiClient.getState(),
239
+ import_types.APIResourceType.Page,
240
+ pageId
241
+ );
242
+ }
243
+ readSnippet(snippetId) {
244
+ return MakeswiftApiClient.getAPIResource(
245
+ this.makeswiftApiClient.getState(),
246
+ import_types.APIResourceType.Snippet,
247
+ snippetId
248
+ );
249
+ }
250
+ }
251
+ // Annotate the CommonJS export names for ESM import in node:
252
+ 0 && (module.exports = {
253
+ CacheData,
254
+ MakeswiftHostApiClient
255
+ });
256
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/react.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n defaultLocale: locale,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\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AA,MACrC,WAAW,CAAC,aACV,KAAK,UAAU,MAAM;AACnB,YAAI,MAAM,MAAM;AAAW,mBAAS;AAAA,MACtC,CAAC;AAAA,MACH,OAAO,YAAa,MAAM,OAAO,MAAM,EAAE,IAAI;AAAA,IAC/C;AAAA,EACF;AAAA,EAEA,UAAU,SAA+B;AACvC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,6BAAgB,OAAO,SAAS,KAAK,KAAK;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { ReactRuntimeCore } from '../../runtimes/react/react-runtime-core'\nimport { type Element } from '../../state/read-only-state'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\n\nexport async function elementTreeHandler(\n req: ApiRequest,\n { runtime }: { runtime: ReactRuntimeCore },\n): Promise<ApiResponse<{ elementTree: Element } | ErrorResponseBody>> {\n const body = await req.json()\n const { elementTree, replacementContext } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n if (replacementContext == null) {\n return ApiResponse.json({ message: 'replacementContext must be defined' }, { status: 400 })\n }\n\n const generatedElementTree = runtime.copyElementTree(elementTree, replacementContext)\n return ApiResponse.json({ elementTree: generatedElementTree })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AAErE,eAAsB,mBACpB,KACA,EAAE,QAAQ,GAC0D;AACpE,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAE5C,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI,sBAAsB,MAAM;AAC9B,WAAO,oCAAY,KAAK,EAAE,SAAS,qCAAqC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC5F;AAEA,QAAM,uBAAuB,QAAQ,gBAAgB,aAAa,kBAAkB;AACpF,SAAO,oCAAY,KAAK,EAAE,aAAa,qBAAqB,CAAC;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { ReactRuntimeCore } from '../../runtimes/react/react-runtime-core'\nimport { type Element } from '../../state/react-page'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\n\nexport async function elementTreeHandler(\n req: ApiRequest,\n { runtime }: { runtime: ReactRuntimeCore },\n): Promise<ApiResponse<{ elementTree: Element } | ErrorResponseBody>> {\n const body = await req.json()\n const { elementTree, replacementContext } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n if (replacementContext == null) {\n return ApiResponse.json({ message: 'replacementContext must be defined' }, { status: 400 })\n }\n\n const generatedElementTree = runtime.copyElementTree(elementTree, replacementContext)\n return ApiResponse.json({ elementTree: generatedElementTree })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AAErE,eAAsB,mBACpB,KACA,EAAE,QAAQ,GAC0D;AACpE,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAE5C,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI,sBAAsB,MAAM;AAC9B,WAAO,oCAAY,KAAK,EAAE,SAAS,qCAAqC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC5F;AAEA,QAAM,uBAAuB,QAAQ,gBAAgB,aAAa,kBAAkB;AACpF,SAAO,oCAAY,KAAK,EAAE,aAAa,qBAAqB,CAAC;AAC/D;","names":[]}
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.26.4-canary.1",
31
+ version: "0.26.5",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { type Element } from '../../state/read-only-state'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\nimport isErrorWithMessage from '../../utils/isErrorWithMessage'\n\ntype TranslatedData = { elementTree: Element }\n\nexport async function mergeTranslatedDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse<TranslatedData | ErrorResponseBody>> {\n const body = await req.json()\n const { translatedData, elementTree } = body\n\n if (translatedData == null) {\n return ApiResponse.json({ message: 'translatedData must be defined' }, { status: 400 })\n }\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n try {\n const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData)\n return ApiResponse.json({ elementTree: translatedElementTree })\n } catch (error) {\n if (isErrorWithMessage(error)) {\n return ApiResponse.json({ message: error.message }, { status: 500 })\n }\n return ApiResponse.json({ message: 'Error merging translated data' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AACrE,gCAA+B;AAI/B,eAAsB,2BACpB,KACA,EAAE,OAAO,GACiD;AAC1D,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,gBAAgB,YAAY,IAAI;AAExC,MAAI,kBAAkB,MAAM;AAC1B,WAAO,oCAAY,KAAK,EAAE,SAAS,iCAAiC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACxF;AAEA,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI;AACF,UAAM,wBAAwB,OAAO,oBAAoB,aAAa,cAAc;AACpF,WAAO,oCAAY,KAAK,EAAE,aAAa,sBAAsB,CAAC;AAAA,EAChE,SAAS,OAAO;AACd,YAAI,0BAAAA,SAAmB,KAAK,GAAG;AAC7B,aAAO,oCAAY,KAAK,EAAE,SAAS,MAAM,QAAQ,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACrE;AACA,WAAO,oCAAY,KAAK,EAAE,SAAS,gCAAgC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACvF;AACF;","names":["isErrorWithMessage"]}
1
+ {"version":3,"sources":["../../../../src/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { type Element } from '../../state/react-page'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\nimport isErrorWithMessage from '../../utils/isErrorWithMessage'\n\ntype TranslatedData = { elementTree: Element }\n\nexport async function mergeTranslatedDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse<TranslatedData | ErrorResponseBody>> {\n const body = await req.json()\n const { translatedData, elementTree } = body\n\n if (translatedData == null) {\n return ApiResponse.json({ message: 'translatedData must be defined' }, { status: 400 })\n }\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n try {\n const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData)\n return ApiResponse.json({ elementTree: translatedElementTree })\n } catch (error) {\n if (isErrorWithMessage(error)) {\n return ApiResponse.json({ message: error.message }, { status: 500 })\n }\n return ApiResponse.json({ message: 'Error merging translated data' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AACrE,gCAA+B;AAI/B,eAAsB,2BACpB,KACA,EAAE,OAAO,GACiD;AAC1D,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,gBAAgB,YAAY,IAAI;AAExC,MAAI,kBAAkB,MAAM;AAC1B,WAAO,oCAAY,KAAK,EAAE,SAAS,iCAAiC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACxF;AAEA,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI;AACF,UAAM,wBAAwB,OAAO,oBAAoB,aAAa,cAAc;AACpF,WAAO,oCAAY,KAAK,EAAE,aAAa,sBAAsB,CAAC;AAAA,EAChE,SAAS,OAAO;AACd,YAAI,0BAAAA,SAAmB,KAAK,GAAG;AAC7B,aAAO,oCAAY,KAAK,EAAE,SAAS,MAAM,QAAQ,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACrE;AACA,WAAO,oCAAY,KAAK,EAAE,SAAS,gCAAgC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACvF;AACF;","names":["isErrorWithMessage"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { type Data } from '../../state/read-only-state'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse } from '../request-response'\n\ntype TranslatableDataResult = { translatableData: Record<string, Data> }\ntype TranslatableDataError = { message: string }\n\nexport type TranslatableDataResponse = TranslatableDataResult | TranslatableDataError\n\nexport async function translatableDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse> {\n const body = await req.json()\n\n const { elementTree } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined.' }, { status: 400 })\n }\n\n try {\n let translatableData = client.getTranslatableData(elementTree)\n return ApiResponse.json({ translatableData })\n } catch (error) {\n return ApiResponse.json({ message: 'Failed to get translatable data.' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAA6C;AAO7C,eAAsB,wBACpB,KACA,EAAE,OAAO,GACa;AACtB,QAAM,OAAO,MAAM,IAAI,KAAK;AAE5B,QAAM,EAAE,YAAY,IAAI;AAExB,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,+BAA+B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACtF;AAEA,MAAI;AACF,QAAI,mBAAmB,OAAO,oBAAoB,WAAW;AAC7D,WAAO,oCAAY,KAAK,EAAE,iBAAiB,CAAC;AAAA,EAC9C,SAAS,OAAO;AACd,WAAO,oCAAY,KAAK,EAAE,SAAS,mCAAmC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC1F;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { type Data } from '../../state/react-page'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse } from '../request-response'\n\ntype TranslatableDataResult = { translatableData: Record<string, Data> }\ntype TranslatableDataError = { message: string }\n\nexport type TranslatableDataResponse = TranslatableDataResult | TranslatableDataError\n\nexport async function translatableDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse> {\n const body = await req.json()\n\n const { elementTree } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined.' }, { status: 400 })\n }\n\n try {\n let translatableData = client.getTranslatableData(elementTree)\n return ApiResponse.json({ translatableData })\n } catch (error) {\n return ApiResponse.json({ message: 'Failed to get translatable data.' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAA6C;AAO7C,eAAsB,wBACpB,KACA,EAAE,OAAO,GACa;AACtB,QAAM,OAAO,MAAM,IAAI,KAAK;AAE5B,QAAM,EAAE,YAAY,IAAI;AAExB,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,+BAA+B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACtF;AAEA,MAAI;AACF,QAAI,mBAAmB,OAAO,oBAAoB,WAAW;AAC7D,WAAO,oCAAY,KAAK,EAAE,iBAAiB,CAAC;AAAA,EAC9C,SAAS,OAAO;AACd,WAAO,oCAAY,KAAK,EAAE,SAAS,mCAAmC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC1F;AACF;","names":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var diff_projection_exports = {};
20
+ __export(diff_projection_exports, {
21
+ diffProjectionSchema: () => diffProjectionSchema
22
+ });
23
+ module.exports = __toCommonJS(diff_projection_exports);
24
+ var import_zod = require("zod");
25
+ const changeTypeSchema = import_zod.z.enum(["created", "updated", "deleted"]);
26
+ const componentChangeSchema = import_zod.z.object({
27
+ id: import_zod.z.string(),
28
+ locale: import_zod.z.string().nullable(),
29
+ changeType: changeTypeSchema
30
+ });
31
+ const pageChangeSchema = import_zod.z.object({
32
+ pageId: import_zod.z.string().uuid(),
33
+ locale: import_zod.z.string().nullable(),
34
+ changeType: changeTypeSchema,
35
+ pathname: import_zod.z.string(),
36
+ previousPathname: import_zod.z.string().optional()
37
+ });
38
+ const globalElementChangeSchema = import_zod.z.object({
39
+ id: import_zod.z.string().uuid(),
40
+ locale: import_zod.z.string().nullable(),
41
+ changeType: changeTypeSchema
42
+ });
43
+ const swatchChangeSchema = import_zod.z.object({
44
+ id: import_zod.z.string().uuid(),
45
+ changeType: changeTypeSchema
46
+ });
47
+ const typographyChangeSchema = import_zod.z.object({
48
+ id: import_zod.z.string().uuid(),
49
+ changeType: changeTypeSchema
50
+ });
51
+ const diffProjectionSchema = import_zod.z.object({
52
+ components: import_zod.z.array(componentChangeSchema),
53
+ pages: import_zod.z.array(pageChangeSchema),
54
+ globalElements: import_zod.z.array(globalElementChangeSchema),
55
+ swatches: import_zod.z.array(swatchChangeSchema),
56
+ typographies: import_zod.z.array(typographyChangeSchema)
57
+ }).passthrough();
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ diffProjectionSchema
61
+ });
62
+ //# sourceMappingURL=diff-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/diff-projection.ts"],"sourcesContent":["import { z } from 'zod'\n\nconst changeTypeSchema = z.enum(['created', 'updated', 'deleted'])\n\n// `locale` is null for the default locale. We'd prefer explicit locale strings\n// (e.g. \"en-US\"), but both server and runtime treat the default locale as null\n// today — changing that requires a broader localization rework.\nconst componentChangeSchema = z.object({\n id: z.string(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst pageChangeSchema = z.object({\n pageId: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n pathname: z.string(),\n previousPathname: z.string().optional(),\n})\n\nconst globalElementChangeSchema = z.object({\n id: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst swatchChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nconst typographyChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nexport const diffProjectionSchema = z\n .object({\n components: z.array(componentChangeSchema),\n pages: z.array(pageChangeSchema),\n globalElements: z.array(globalElementChangeSchema),\n swatches: z.array(swatchChangeSchema),\n typographies: z.array(typographyChangeSchema),\n })\n // passthrough() preserves unknown resource types the server may add in the\n // future (e.g. `fonts`), so onPublish consumers can access them without a\n // runtime upgrade.\n .passthrough()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,MAAM,mBAAmB,aAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,aAAE,OAAO;AAAA,EACrC,IAAI,aAAE,OAAO;AAAA,EACb,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,aAAE,OAAO;AAAA,EAChC,QAAQ,aAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,aAAE,OAAO;AAAA,EACnB,kBAAkB,aAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,aAAE,OAAO;AAAA,EACzC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,aAAE,OAAO;AAAA,EAClC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,aACjC,OAAO;AAAA,EACN,YAAY,aAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,aAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,aAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,aAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,aAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
@@ -23,12 +23,12 @@ __export(host_to_builder_actions_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(host_to_builder_actions_exports);
25
25
  var import_toolkit = require("@reduxjs/toolkit");
26
- var import_read_only_actions = require("../state/actions/internal/read-only-actions");
26
+ var import_internal = require("../state/actions/internal");
27
27
  var import_actions = require("../state/builder-api/actions");
28
28
  const HostToBuilderActionTypes = {
29
29
  ...import_actions.BuilderActionTypes,
30
- REGISTER_COMPONENT: import_read_only_actions.ReadOnlyActionTypes.REGISTER_COMPONENT,
31
- UNREGISTER_COMPONENT: import_read_only_actions.ReadOnlyActionTypes.UNREGISTER_COMPONENT
30
+ REGISTER_COMPONENT: import_internal.InternalActionTypes.REGISTER_COMPONENT,
31
+ UNREGISTER_COMPONENT: import_internal.InternalActionTypes.UNREGISTER_COMPONENT
32
32
  };
33
33
  function isHostToBuilderAction(action) {
34
34
  return (0, import_toolkit.isAction)(action) && Object.hasOwn(HostToBuilderActionTypes, action.type);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/builder/host-to-builder-actions.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\n// in the past, we reused the same action type for registering components both internally\n// and in the builder; they have been since split into two separate action types,\n// REGISTER_COMPONENT and REGISTER_BUILDER_COMPONENT, but we still have to expose what\n// are now internal actions to the builder for backward compatibility with the older runtimes\nimport {\n type RegisterComponentAction,\n type UnregisterComponentAction,\n ReadOnlyActionTypes,\n} from '../state/actions/internal/read-only-actions'\n\nimport { type BuilderAction, BuilderActionTypes } from '../state/builder-api/actions'\n\nexport const HostToBuilderActionTypes = {\n ...BuilderActionTypes,\n REGISTER_COMPONENT: ReadOnlyActionTypes.REGISTER_COMPONENT,\n UNREGISTER_COMPONENT: ReadOnlyActionTypes.UNREGISTER_COMPONENT,\n} as const\n\nexport type HostToBuilderAction =\n | BuilderAction\n | RegisterComponentAction\n | UnregisterComponentAction\n\nexport function isHostToBuilderAction(action: unknown): action is HostToBuilderAction {\n return isAction(action) && Object.hasOwn(HostToBuilderActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAMzB,+BAIO;AAEP,qBAAuD;AAEhD,MAAM,2BAA2B;AAAA,EACtC,GAAG;AAAA,EACH,oBAAoB,6CAAoB;AAAA,EACxC,sBAAsB,6CAAoB;AAC5C;AAOO,SAAS,sBAAsB,QAAgD;AACpF,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,0BAA0B,OAAO,IAAI;AAChF;","names":[]}
1
+ {"version":3,"sources":["../../../src/builder/host-to-builder-actions.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\n// in the past, we reused the same action type for registering components both internally\n// and in the builder; they have been since split into two separate action types,\n// REGISTER_COMPONENT and REGISTER_BUILDER_COMPONENT, but we still have to expose what\n// are now internal actions to the builder for backward compatibility with the older runtimes\nimport {\n type RegisterComponentAction,\n type UnregisterComponentAction,\n InternalActionTypes,\n} from '../state/actions/internal'\n\nimport { type BuilderAction, BuilderActionTypes } from '../state/builder-api/actions'\n\nexport const HostToBuilderActionTypes = {\n ...BuilderActionTypes,\n REGISTER_COMPONENT: InternalActionTypes.REGISTER_COMPONENT,\n UNREGISTER_COMPONENT: InternalActionTypes.UNREGISTER_COMPONENT,\n} as const\n\nexport type HostToBuilderAction =\n | BuilderAction\n | RegisterComponentAction\n | UnregisterComponentAction\n\nexport function isHostToBuilderAction(action: unknown): action is HostToBuilderAction {\n return isAction(action) && Object.hasOwn(HostToBuilderActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAMzB,sBAIO;AAEP,qBAAuD;AAEhD,MAAM,2BAA2B;AAAA,EACtC,GAAG;AAAA,EACH,oBAAoB,oCAAoB;AAAA,EACxC,sBAAsB,oCAAoB;AAC5C;AAOO,SAAS,sBAAsB,QAAgD;AACpF,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,0BAA0B,OAAO,IAAI;AAChF;","names":[]}
@@ -33,14 +33,14 @@ __export(builder_exports, {
33
33
  Introspection: () => Introspection,
34
34
  Props: () => Props,
35
35
  TableFormFieldsMessageType: () => import_instances.TableFormFieldsMessageType,
36
- createBaseDocument: () => import_read_only_state.createBaseDocument
36
+ createBaseDocument: () => import_react_page.createBaseDocument
37
37
  });
38
38
  module.exports = __toCommonJS(builder_exports);
39
39
  __reExport(builder_exports, require("./serialization"), module.exports);
40
40
  __reExport(builder_exports, require("./unstructured-introspection"), module.exports);
41
41
  __reExport(builder_exports, require("./host-to-builder-actions"), module.exports);
42
42
  __reExport(builder_exports, require("./host-api"), module.exports);
43
- var import_read_only_state = require("../state/read-only-state");
43
+ var import_react_page = require("../state/react-page");
44
44
  var Props = __toESM(require("../prop-controllers/descriptors"));
45
45
  var import_instances = require("../prop-controllers/instances");
46
46
  var Introspection = __toESM(require("../prop-controllers/introspection"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\nexport * from './host-to-builder-actions'\nexport * from './host-api'\n\nexport { type Operation } from '../state/modules/read-write/read-write-documents'\n\nexport { createBaseDocument } from '../state/read-only-state'\n\nexport type {\n Descriptor as PropControllerDescriptor,\n DescriptorValueType as PropControllerDescriptorValueType,\n PanelDescriptor,\n PanelDescriptorType,\n PanelDescriptorValueType,\n} from '../prop-controllers/descriptors'\n\nexport * as Props from '../prop-controllers/descriptors'\nexport type { PropControllerMessage, TableFormFieldsMessage } from '../prop-controllers/instances'\nexport { TableFormFieldsMessageType } from '../prop-controllers/instances'\nexport * as Introspection from '../prop-controllers/introspection'\nexport { DELETED_PROP_CONTROLLER_TYPES } from '../prop-controllers/deleted'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAc,4BAAd;AACA,4BAAc,yCADd;AAEA,4BAAc,sCAFd;AAGA,4BAAc,uBAHd;AAOA,6BAAmC;AAUnC,YAAuB;AAEvB,uBAA2C;AAC3C,oBAA+B;AAC/B,qBAA8C;","names":[]}
1
+ {"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\nexport * from './host-to-builder-actions'\nexport * from './host-api'\n\nexport { type Operation } from '../state/modules/read-write-documents'\n\nexport { createBaseDocument } from '../state/react-page'\n\nexport type {\n Descriptor as PropControllerDescriptor,\n DescriptorValueType as PropControllerDescriptorValueType,\n PanelDescriptor,\n PanelDescriptorType,\n PanelDescriptorValueType,\n} from '../prop-controllers/descriptors'\n\nexport * as Props from '../prop-controllers/descriptors'\nexport type { PropControllerMessage, TableFormFieldsMessage } from '../prop-controllers/instances'\nexport { TableFormFieldsMessageType } from '../prop-controllers/instances'\nexport * as Introspection from '../prop-controllers/introspection'\nexport { DELETED_PROP_CONTROLLER_TYPES } from '../prop-controllers/deleted'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAc,4BAAd;AACA,4BAAc,yCADd;AAEA,4BAAc,sCAFd;AAGA,4BAAc,uBAHd;AAOA,wBAAmC;AAUnC,YAAuB;AAEvB,uBAA2C;AAC3C,oBAA+B;AAC/B,qBAA8C;","names":[]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var serialization_exports = {};
21
+ __export(serialization_exports, {
22
+ deserializeControl: () => deserializeControl,
23
+ deserializeControls: () => deserializeControls,
24
+ serializeControl: () => serializeControl,
25
+ serializeControls: () => serializeControls
26
+ });
27
+ module.exports = __toCommonJS(serialization_exports);
28
+ var import_controls = require("@makeswift/controls");
29
+ var import_serialization = require("../prop-controllers/serialization");
30
+ var import_descriptors = require("../prop-controllers/descriptors");
31
+ var import_base = require("../controls/serialization/base");
32
+ var import_message_port = require("../controls/serialization/message-port");
33
+ var import_serialization2 = require("../controls/serialization");
34
+ __reExport(serialization_exports, require("../prop-controllers/serialization"), module.exports);
35
+ function serializeControl(control) {
36
+ if ((0, import_descriptors.isLegacyDescriptor)(control)) {
37
+ return (0, import_serialization.serializeLegacyControl)(control);
38
+ }
39
+ const messagePortVisitor = new import_message_port.ClientMessagePortSerializationVisitor();
40
+ const serializedControl = control.accept(messagePortVisitor);
41
+ return [serializedControl, messagePortVisitor.getTransferables()];
42
+ }
43
+ function isSerializedLegacyControl(control) {
44
+ return "options" in control;
45
+ }
46
+ function deserializeControl(serializedControl, options) {
47
+ if (isSerializedLegacyControl(serializedControl)) {
48
+ const record = options?.plugins ? (0, import_controls.deserializeObject)(serializedControl, options?.plugins) : serializedControl;
49
+ return (0, import_serialization.deserializeLegacyControl)(record);
50
+ }
51
+ const plugins = [import_message_port.functionDeserializationPlugin, ...options?.plugins ?? []];
52
+ return (0, import_base.deserializeControl)(serializedControl, { plugins });
53
+ }
54
+ function serializeControls(controls) {
55
+ return Object.entries(controls).reduce(
56
+ ([accControls, accTransferables], [key, control]) => {
57
+ const [serializedControl, transferables] = serializeControl(control);
58
+ return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]];
59
+ },
60
+ [{}, []]
61
+ );
62
+ }
63
+ function deserializeControls(serializedControls, { onError, plugins } = {}) {
64
+ return (0, import_serialization2.deserializeControlRecords)(
65
+ serializedControls,
66
+ (serializedControl, options) => deserializeControl(serializedControl, options),
67
+ { onError, plugins }
68
+ );
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ deserializeControl,
73
+ deserializeControls,
74
+ serializeControl,
75
+ serializeControls,
76
+ ...require("../prop-controllers/serialization")
77
+ });
78
+ //# sourceMappingURL=serialization.js.map