@makeswift/runtime 0.27.1 → 0.27.3

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 (304) hide show
  1. package/dist/cjs/api/api-resources-client.js +160 -0
  2. package/dist/cjs/api/api-resources-client.js.map +1 -0
  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/manifest.js +1 -1
  6. package/dist/cjs/api-handler/handlers/webhook/diff-projection.js +62 -0
  7. package/dist/cjs/api-handler/handlers/webhook/diff-projection.js.map +1 -0
  8. package/dist/cjs/box-model.js +33 -0
  9. package/dist/cjs/box-model.js.map +1 -0
  10. package/dist/cjs/builder/serialization.js +78 -0
  11. package/dist/cjs/builder/serialization.js.map +1 -0
  12. package/dist/cjs/client/index.js +3 -3
  13. package/dist/cjs/components/builtin/index.js +84 -0
  14. package/dist/cjs/components/builtin/index.js.map +1 -0
  15. package/dist/cjs/components/index.js +25 -0
  16. package/dist/cjs/components/index.js.map +1 -0
  17. package/dist/cjs/controls/rich-text-v2/translation.js +187 -0
  18. package/dist/cjs/controls/rich-text-v2/translation.js.map +1 -0
  19. package/dist/cjs/controls/serialization/base/index.js +78 -0
  20. package/dist/cjs/controls/serialization/base/index.js.map +1 -0
  21. package/dist/cjs/controls/serialization/base/visitor.js +59 -0
  22. package/dist/cjs/controls/serialization/base/visitor.js.map +1 -0
  23. package/dist/cjs/controls/serialization/index.js +55 -0
  24. package/dist/cjs/controls/serialization/index.js.map +1 -0
  25. package/dist/cjs/controls/serialization/message-port/function-serialization.js +79 -0
  26. package/dist/cjs/controls/serialization/message-port/function-serialization.js.map +1 -0
  27. package/dist/cjs/controls/serialization/message-port/index.js +25 -0
  28. package/dist/cjs/controls/serialization/message-port/index.js.map +1 -0
  29. package/dist/cjs/controls/serialization/message-port/visitor.js +48 -0
  30. package/dist/cjs/controls/serialization/message-port/visitor.js.map +1 -0
  31. package/dist/cjs/core/index.js +57 -0
  32. package/dist/cjs/core/index.js.map +1 -0
  33. package/dist/cjs/next/api-handler/config/app-router.js +10 -1
  34. package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
  35. package/dist/cjs/next/api-handler/config/pages-router.js +1 -1
  36. package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -1
  37. package/dist/cjs/next/fetch.js +30 -0
  38. package/dist/cjs/next/fetch.js.map +1 -0
  39. package/dist/cjs/prop-controllers/index.js +48 -0
  40. package/dist/cjs/prop-controllers/index.js.map +1 -0
  41. package/dist/cjs/prop-controllers/serialization.js +355 -0
  42. package/dist/cjs/prop-controllers/serialization.js.map +1 -0
  43. package/dist/cjs/react.js +40 -0
  44. package/dist/cjs/react.js.map +1 -0
  45. package/dist/cjs/runtimes/react/components/LiveProvider.js +50 -0
  46. package/dist/cjs/runtimes/react/components/LiveProvider.js.map +1 -0
  47. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +33 -0
  48. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  49. package/dist/cjs/runtimes/react/components/PreviewProvider.js +57 -0
  50. package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +1 -0
  51. package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js +67 -0
  52. package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -0
  53. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js +39 -0
  54. package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  55. package/dist/cjs/runtimes/react/hooks/use-is-preview.js +33 -0
  56. package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
  57. package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js +59 -0
  58. package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
  59. package/dist/cjs/runtimes/react/resource-resolver.js +52 -0
  60. package/dist/cjs/runtimes/react/resource-resolver.js.map +1 -0
  61. package/dist/cjs/state/actions/internal.js +205 -0
  62. package/dist/cjs/state/actions/internal.js.map +1 -0
  63. package/dist/cjs/state/actions.js +423 -0
  64. package/dist/cjs/state/actions.js.map +1 -0
  65. package/dist/cjs/state/api-client/client-store.js +81 -0
  66. package/dist/cjs/state/api-client/client-store.js.map +1 -0
  67. package/dist/cjs/state/api-client/fetch-api-resource.js +125 -0
  68. package/dist/cjs/state/api-client/fetch-api-resource.js.map +1 -0
  69. package/dist/cjs/state/api-client/state.js +89 -0
  70. package/dist/cjs/state/api-client/state.js.map +1 -0
  71. package/dist/cjs/state/api-client/store.js +36 -0
  72. package/dist/cjs/state/api-client/store.js.map +1 -0
  73. package/dist/cjs/state/builder-api/api.js +17 -0
  74. package/dist/cjs/state/builder-api/api.js.map +1 -0
  75. package/dist/cjs/state/builder-api/navigation-listener.js +110 -0
  76. package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -0
  77. package/dist/cjs/state/mixins/breakpoint-watch.js +72 -0
  78. package/dist/cjs/state/mixins/breakpoint-watch.js.map +1 -0
  79. package/dist/cjs/state/mixins/setup-teardown.js +35 -0
  80. package/dist/cjs/state/mixins/setup-teardown.js.map +1 -0
  81. package/dist/cjs/state/modules/box-models.js +127 -0
  82. package/dist/cjs/state/modules/box-models.js.map +1 -0
  83. package/dist/cjs/state/modules/element-imperative-handles.js +60 -0
  84. package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
  85. package/dist/cjs/state/modules/is-preview.js +47 -0
  86. package/dist/cjs/state/modules/is-preview.js.map +1 -0
  87. package/dist/cjs/state/modules/pointer.js +47 -0
  88. package/dist/cjs/state/modules/pointer.js.map +1 -0
  89. package/dist/cjs/state/modules/read-write-documents.js +98 -0
  90. package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
  91. package/dist/cjs/state/react-builder-preview.js +610 -0
  92. package/dist/cjs/state/react-builder-preview.js.map +1 -0
  93. package/dist/cjs/state/react-page.js +355 -0
  94. package/dist/cjs/state/react-page.js.map +1 -0
  95. package/dist/cjs/utils/ref-counted-map.js +120 -0
  96. package/dist/cjs/utils/ref-counted-map.js.map +1 -0
  97. package/dist/esm/api/api-resources-client.js +127 -0
  98. package/dist/esm/api/api-resources-client.js.map +1 -0
  99. package/dist/esm/api/react.js +223 -0
  100. package/dist/esm/api/react.js.map +1 -0
  101. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  102. package/dist/esm/api-handler/handlers/webhook/diff-projection.js +38 -0
  103. package/dist/esm/api-handler/handlers/webhook/diff-projection.js.map +1 -0
  104. package/dist/esm/box-model.js +7 -0
  105. package/dist/esm/box-model.js.map +1 -0
  106. package/dist/esm/builder/serialization.js +59 -0
  107. package/dist/esm/builder/serialization.js.map +1 -0
  108. package/dist/esm/client/index.js +3 -3
  109. package/dist/esm/components/builtin/index.js +34 -0
  110. package/dist/esm/components/builtin/index.js.map +1 -0
  111. package/dist/esm/components/index.js +3 -0
  112. package/dist/esm/components/index.js.map +1 -0
  113. package/dist/esm/controls/rich-text-v2/translation.js +152 -0
  114. package/dist/esm/controls/rich-text-v2/translation.js.map +1 -0
  115. package/dist/esm/controls/serialization/base/index.js +78 -0
  116. package/dist/esm/controls/serialization/base/index.js.map +1 -0
  117. package/dist/esm/controls/serialization/base/visitor.js +39 -0
  118. package/dist/esm/controls/serialization/base/visitor.js.map +1 -0
  119. package/dist/esm/controls/serialization/index.js +30 -0
  120. package/dist/esm/controls/serialization/index.js.map +1 -0
  121. package/dist/esm/controls/serialization/message-port/function-serialization.js +52 -0
  122. package/dist/esm/controls/serialization/message-port/function-serialization.js.map +1 -0
  123. package/dist/esm/controls/serialization/message-port/index.js +3 -0
  124. package/dist/esm/controls/serialization/message-port/index.js.map +1 -0
  125. package/dist/esm/controls/serialization/message-port/visitor.js +24 -0
  126. package/dist/esm/controls/serialization/message-port/visitor.js.map +1 -0
  127. package/dist/esm/core/index.js +35 -0
  128. package/dist/esm/core/index.js.map +1 -0
  129. package/dist/esm/next/api-handler/config/app-router.js +10 -1
  130. package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
  131. package/dist/esm/next/api-handler/config/pages-router.js +1 -1
  132. package/dist/esm/next/api-handler/config/pages-router.js.map +1 -1
  133. package/dist/esm/next/fetch.js +6 -0
  134. package/dist/esm/next/fetch.js.map +1 -0
  135. package/dist/esm/prop-controllers/index.js +11 -0
  136. package/dist/esm/prop-controllers/index.js.map +1 -0
  137. package/dist/esm/prop-controllers/serialization.js +338 -0
  138. package/dist/esm/prop-controllers/serialization.js.map +1 -0
  139. package/dist/esm/react.js +11 -0
  140. package/dist/esm/react.js.map +1 -0
  141. package/dist/esm/runtimes/react/components/LiveProvider.js +20 -0
  142. package/dist/esm/runtimes/react/components/LiveProvider.js.map +1 -0
  143. package/dist/esm/runtimes/react/components/MakeswiftFonts.js +9 -0
  144. package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  145. package/dist/esm/runtimes/react/components/PreviewProvider.js +27 -0
  146. package/dist/esm/runtimes/react/components/PreviewProvider.js.map +1 -0
  147. package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js +43 -0
  148. package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -0
  149. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js +15 -0
  150. package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
  151. package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
  152. package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
  153. package/dist/esm/runtimes/react/lib/resolved-style-to-css.js +38 -0
  154. package/dist/esm/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
  155. package/dist/esm/runtimes/react/resource-resolver.js +28 -0
  156. package/dist/esm/runtimes/react/resource-resolver.js.map +1 -0
  157. package/dist/esm/state/actions/internal.js +162 -0
  158. package/dist/esm/state/actions/internal.js.map +1 -0
  159. package/dist/esm/state/actions.js +349 -0
  160. package/dist/esm/state/actions.js.map +1 -0
  161. package/dist/esm/state/api-client/client-store.js +49 -0
  162. package/dist/esm/state/api-client/client-store.js.map +1 -0
  163. package/dist/esm/state/api-client/fetch-api-resource.js +93 -0
  164. package/dist/esm/state/api-client/fetch-api-resource.js.map +1 -0
  165. package/dist/esm/state/api-client/state.js +52 -0
  166. package/dist/esm/state/api-client/state.js.map +1 -0
  167. package/dist/esm/state/api-client/store.js +12 -0
  168. package/dist/esm/state/api-client/store.js.map +1 -0
  169. package/dist/esm/state/builder-api/api.js +1 -0
  170. package/dist/esm/state/builder-api/api.js.map +1 -0
  171. package/dist/esm/state/builder-api/navigation-listener.js +86 -0
  172. package/dist/esm/state/builder-api/navigation-listener.js.map +1 -0
  173. package/dist/esm/state/mixins/breakpoint-watch.js +48 -0
  174. package/dist/esm/state/mixins/breakpoint-watch.js.map +1 -0
  175. package/dist/esm/state/mixins/setup-teardown.js +11 -0
  176. package/dist/esm/state/mixins/setup-teardown.js.map +1 -0
  177. package/dist/esm/state/modules/box-models.js +98 -0
  178. package/dist/esm/state/modules/box-models.js.map +1 -0
  179. package/dist/esm/state/modules/element-imperative-handles.js +35 -0
  180. package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
  181. package/dist/esm/state/modules/is-preview.js +21 -0
  182. package/dist/esm/state/modules/is-preview.js.map +1 -0
  183. package/dist/esm/state/modules/pointer.js +22 -0
  184. package/dist/esm/state/modules/pointer.js.map +1 -0
  185. package/dist/esm/state/modules/read-write-documents.js +60 -0
  186. package/dist/esm/state/modules/read-write-documents.js.map +1 -0
  187. package/dist/esm/state/react-builder-preview.js +590 -0
  188. package/dist/esm/state/react-builder-preview.js.map +1 -0
  189. package/dist/esm/state/react-page.js +319 -0
  190. package/dist/esm/state/react-page.js.map +1 -0
  191. package/dist/esm/utils/ref-counted-map.js +96 -0
  192. package/dist/esm/utils/ref-counted-map.js.map +1 -0
  193. package/dist/types/api/api-resources-client.d.ts +57 -0
  194. package/dist/types/api/api-resources-client.d.ts.map +1 -0
  195. package/dist/types/api/react.d.ts +82 -0
  196. package/dist/types/api/react.d.ts.map +1 -0
  197. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +201 -0
  198. package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts.map +1 -0
  199. package/dist/types/box-model.d.ts +3 -0
  200. package/dist/types/box-model.d.ts.map +1 -0
  201. package/dist/types/builder/serialization.d.ts +23 -0
  202. package/dist/types/builder/serialization.d.ts.map +1 -0
  203. package/dist/types/builder/serialization.test.d.ts +2 -0
  204. package/dist/types/builder/serialization.test.d.ts.map +1 -0
  205. package/dist/types/client/tests/client.get-component-snapshots.test.d.ts +2 -0
  206. package/dist/types/client/tests/client.get-component-snapshots.test.d.ts.map +1 -0
  207. package/dist/types/client/tests/client.introspect-many.test.d.ts +2 -0
  208. package/dist/types/client/tests/client.introspect-many.test.d.ts.map +1 -0
  209. package/dist/types/components/builtin/index.d.ts +17 -0
  210. package/dist/types/components/builtin/index.d.ts.map +1 -0
  211. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts +3 -0
  212. package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
  213. package/dist/types/components/index.d.ts +3 -0
  214. package/dist/types/components/index.d.ts.map +1 -0
  215. package/dist/types/controls/rich-text-v2/translation.d.ts +6 -0
  216. package/dist/types/controls/rich-text-v2/translation.d.ts.map +1 -0
  217. package/dist/types/controls/serialization/base/index.d.ts +10 -0
  218. package/dist/types/controls/serialization/base/index.d.ts.map +1 -0
  219. package/dist/types/controls/serialization/base/visitor.d.ts +7 -0
  220. package/dist/types/controls/serialization/base/visitor.d.ts.map +1 -0
  221. package/dist/types/controls/serialization/index.d.ts +10 -0
  222. package/dist/types/controls/serialization/index.d.ts.map +1 -0
  223. package/dist/types/controls/serialization/message-port/function-serialization.d.ts +16 -0
  224. package/dist/types/controls/serialization/message-port/function-serialization.d.ts.map +1 -0
  225. package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts +2 -0
  226. package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts.map +1 -0
  227. package/dist/types/controls/serialization/message-port/index.d.ts +3 -0
  228. package/dist/types/controls/serialization/message-port/index.d.ts.map +1 -0
  229. package/dist/types/controls/serialization/message-port/visitor.d.ts +7 -0
  230. package/dist/types/controls/serialization/message-port/visitor.d.ts.map +1 -0
  231. package/dist/types/core/index.d.ts +2 -0
  232. package/dist/types/core/index.d.ts.map +1 -0
  233. package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
  234. package/dist/types/next/api-handler/config/pages-router.test.d.ts +2 -0
  235. package/dist/types/next/api-handler/config/pages-router.test.d.ts.map +1 -0
  236. package/dist/types/next/components/tests/controls/code-control.test.d.ts +2 -0
  237. package/dist/types/next/components/tests/controls/code-control.test.d.ts.map +1 -0
  238. package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts +3 -0
  239. package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts.map +1 -0
  240. package/dist/types/next/fetch.d.ts +3 -0
  241. package/dist/types/next/fetch.d.ts.map +1 -0
  242. package/dist/types/prop-controllers/index.d.ts +8 -0
  243. package/dist/types/prop-controllers/index.d.ts.map +1 -0
  244. package/dist/types/prop-controllers/serialization.d.ts +228 -0
  245. package/dist/types/prop-controllers/serialization.d.ts.map +1 -0
  246. package/dist/types/react.d.ts +4 -0
  247. package/dist/types/react.d.ts.map +1 -0
  248. package/dist/types/runtimes/react/components/LiveProvider.d.ts +3 -0
  249. package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +1 -0
  250. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +7 -0
  251. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +1 -0
  252. package/dist/types/runtimes/react/components/PreviewProvider.d.ts +3 -0
  253. package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +1 -0
  254. package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts +4 -0
  255. package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts.map +1 -0
  256. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts +3 -0
  257. package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts.map +1 -0
  258. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
  259. package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
  260. package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts +4 -0
  261. package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts.map +1 -0
  262. package/dist/types/runtimes/react/resource-resolver.d.ts +10 -0
  263. package/dist/types/runtimes/react/resource-resolver.d.ts.map +1 -0
  264. package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
  265. package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
  266. package/dist/types/state/actions/internal.d.ts +181 -0
  267. package/dist/types/state/actions/internal.d.ts.map +1 -0
  268. package/dist/types/state/actions.d.ts +461 -0
  269. package/dist/types/state/actions.d.ts.map +1 -0
  270. package/dist/types/state/api-client/client-store.d.ts +6 -0
  271. package/dist/types/state/api-client/client-store.d.ts.map +1 -0
  272. package/dist/types/state/api-client/fetch-api-resource.d.ts +11 -0
  273. package/dist/types/state/api-client/fetch-api-resource.d.ts.map +1 -0
  274. package/dist/types/state/api-client/state.d.ts +30 -0
  275. package/dist/types/state/api-client/state.d.ts.map +1 -0
  276. package/dist/types/state/api-client/store.d.ts +18 -0
  277. package/dist/types/state/api-client/store.d.ts.map +1 -0
  278. package/dist/types/state/builder-api/api.d.ts +9 -0
  279. package/dist/types/state/builder-api/api.d.ts.map +1 -0
  280. package/dist/types/state/builder-api/navigation-listener.d.ts +3 -0
  281. package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -0
  282. package/dist/types/state/mixins/breakpoint-watch.d.ts +11 -0
  283. package/dist/types/state/mixins/breakpoint-watch.d.ts.map +1 -0
  284. package/dist/types/state/mixins/setup-teardown.d.ts +7 -0
  285. package/dist/types/state/mixins/setup-teardown.d.ts.map +1 -0
  286. package/dist/types/state/modules/box-models.d.ts +23 -0
  287. package/dist/types/state/modules/box-models.d.ts.map +1 -0
  288. package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
  289. package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
  290. package/dist/types/state/modules/is-preview.d.ts +6 -0
  291. package/dist/types/state/modules/is-preview.d.ts.map +1 -0
  292. package/dist/types/state/modules/pointer.d.ts +12 -0
  293. package/dist/types/state/modules/pointer.d.ts.map +1 -0
  294. package/dist/types/state/modules/read-write-documents.d.ts +14 -0
  295. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
  296. package/dist/types/state/react-builder-preview.d.ts +110 -0
  297. package/dist/types/state/react-builder-preview.d.ts.map +1 -0
  298. package/dist/types/state/react-page.d.ts +149 -0
  299. package/dist/types/state/react-page.d.ts.map +1 -0
  300. package/dist/types/utils/__tests__/ref-counted-map.test.d.ts +2 -0
  301. package/dist/types/utils/__tests__/ref-counted-map.test.d.ts.map +1 -0
  302. package/dist/types/utils/ref-counted-map.d.ts +32 -0
  303. package/dist/types/utils/ref-counted-map.d.ts.map +1 -0
  304. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ import {
2
+ configureStore as configureReduxStore
3
+ } from "@reduxjs/toolkit";
4
+ import * as LocaleState from "../modules/locale";
5
+ import { ActionTypes } from "../actions";
6
+ import { actionMiddleware, middlewareOptions, devToolsConfig } from "../toolkit";
7
+ import { reducer } from "./state";
8
+ function defaultLocaleMiddleware() {
9
+ return actionMiddleware(({ getState }) => (next) => {
10
+ return (action) => {
11
+ switch (action.type) {
12
+ case ActionTypes.CHANGE_API_RESOURCE:
13
+ case ActionTypes.EVICT_API_RESOURCE:
14
+ case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {
15
+ const { locale } = action.payload;
16
+ return next({
17
+ ...action,
18
+ payload: {
19
+ ...action.payload,
20
+ locale: locale ?? LocaleState.getLocale(getState().locale)
21
+ }
22
+ });
23
+ }
24
+ }
25
+ return next(action);
26
+ };
27
+ });
28
+ }
29
+ function configureClientStore({
30
+ preloadedState
31
+ }) {
32
+ return configureReduxStore({
33
+ reducer,
34
+ preloadedState,
35
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware()),
36
+ devTools: devToolsConfig({
37
+ name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
38
+ actionsDenylist: [
39
+ ActionTypes.BUILDER_POINTER_MOVE,
40
+ ActionTypes.HANDLE_POINTER_MOVE,
41
+ ActionTypes.ELEMENT_FROM_POINT_CHANGE
42
+ ]
43
+ })
44
+ });
45
+ }
46
+ export {
47
+ configureClientStore
48
+ };
49
+ //# sourceMappingURL=client-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/client-store.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n type ThunkMiddleware,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as LocaleState from '../modules/locale'\n\nimport { type Action, ActionTypes } from '../actions'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from '../toolkit'\n\nimport { type State, reducer } from './state'\nimport { type Store } from './store'\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(({ getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: {\n ...action.payload,\n locale: locale ?? LocaleState.getLocale(getState().locale),\n },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureClientStore({\n preloadedState,\n}: {\n preloadedState: Partial<State>\n}): Store {\n return configureReduxStore({\n reducer,\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware()),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n"],"mappings":"AAAA;AAAA,EACE,kBAAkB;AAAA,OAGb;AAEP,YAAY,iBAAiB;AAE7B,SAAsB,mBAAmB;AACzC,SAAS,kBAAkB,mBAAmB,sBAAsB;AAEpE,SAAqB,eAAe;AAKpC,SAAS,0BAAiE;AACxE,SAAO,iBAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS;AAAA,cACP,GAAG,OAAO;AAAA,cACV,QAAQ,UAAU,YAAY,UAAU,SAAS,EAAE,MAAM;AAAA,YAC3D;AAAA,UACF,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,qBAAqB;AAAA,EACnC;AACF,GAEU;AACR,SAAO,oBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBAAiB,EAAE,OAAO,wBAAwB,CAAC;AAAA,IAE1E,UAAU,eAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -0,0 +1,93 @@
1
+ import { ApiHandlerHeaders, serializeSiteVersion } from "../../api/site-version";
2
+ import * as SiteVersionState from "../modules/site-version";
3
+ import { apiResourceFulfilled } from "../actions/internal/read-only-actions";
4
+ import { setLocalizedResourceId } from "../host-api";
5
+ import {
6
+ APIResourceType
7
+ } from "../../api";
8
+ import { getHasAPIResource, getAPIResource, getLocalizedResourceId } from "./state";
9
+ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
10
+ const fetchVersioned = async (url, version) => {
11
+ const response = await fetch(url, {
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ ...version != null ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) } : {}
15
+ }
16
+ });
17
+ if (response.status === 404)
18
+ return null;
19
+ if (!response.ok)
20
+ throw new Error(response.statusText);
21
+ if (response.headers.get("content-type")?.includes("application/json") !== true) {
22
+ throw new Error(
23
+ `Expected JSON response from "${url}" but got "${response.headers.get("content-type")}"`
24
+ );
25
+ }
26
+ return response.json();
27
+ };
28
+ return async (dispatch, getState) => {
29
+ const state = getState();
30
+ const version = SiteVersionState.getSiteVersion(state.siteVersion);
31
+ if (getHasAPIResource(state, resourceType, resourceId, locale)) {
32
+ return getAPIResource(state, resourceType, resourceId, locale);
33
+ }
34
+ let resource;
35
+ switch (resourceType) {
36
+ case APIResourceType.Swatch:
37
+ resource = await fetchVersioned(`/api/makeswift/swatches/${resourceId}`, version);
38
+ break;
39
+ case APIResourceType.File:
40
+ resource = await fetchVersioned(`/api/makeswift/files/${resourceId}`, version);
41
+ break;
42
+ case APIResourceType.Typography:
43
+ resource = await fetchVersioned(
44
+ `/api/makeswift/typographies/${resourceId}`,
45
+ version
46
+ );
47
+ break;
48
+ case APIResourceType.GlobalElement:
49
+ resource = await fetchVersioned(
50
+ `/api/makeswift/global-elements/${resourceId}`,
51
+ version
52
+ );
53
+ break;
54
+ case APIResourceType.LocalizedGlobalElement: {
55
+ if (locale == null)
56
+ throw new Error("Locale is required to fetch LocalizedGlobalElement");
57
+ if (getLocalizedResourceId(state, locale, resourceId) === null) {
58
+ return null;
59
+ }
60
+ resource = await fetchVersioned(
61
+ `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,
62
+ version
63
+ );
64
+ dispatch(
65
+ setLocalizedResourceId({
66
+ locale,
67
+ resourceId,
68
+ localizedResourceId: resource?.id ?? null
69
+ })
70
+ );
71
+ break;
72
+ }
73
+ case APIResourceType.PagePathnameSlice: {
74
+ const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, "http://n");
75
+ if (locale != null)
76
+ url.searchParams.set("locale", locale);
77
+ resource = await fetchVersioned(url.pathname + url.search, version);
78
+ break;
79
+ }
80
+ case APIResourceType.Table:
81
+ resource = await fetchVersioned(`/api/makeswift/tables/${resourceId}`, version);
82
+ break;
83
+ default:
84
+ resource = null;
85
+ }
86
+ dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale));
87
+ return resource;
88
+ };
89
+ }
90
+ export {
91
+ fetchAPIResource
92
+ };
93
+ //# sourceMappingURL=fetch-api-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/fetch-api-resource.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SiteVersion, ApiHandlerHeaders, serializeSiteVersion } from '../../api/site-version'\n\nimport * as SiteVersionState from '../modules/site-version'\n\nimport { type Action } from '../actions'\nimport { apiResourceFulfilled } from '../actions/internal/read-only-actions'\nimport { setLocalizedResourceId } from '../host-api'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../../api'\n\nimport { type State, getHasAPIResource, getAPIResource, getLocalizedResourceId } from './state'\n\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchVersioned = async <T>(url: string, version: SiteVersion | null): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n ...(version != null\n ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) }\n : {}),\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n const version = SiteVersionState.getSiteVersion(state.siteVersion)\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchVersioned<Swatch>(`/api/makeswift/swatches/${resourceId}`, version)\n break\n\n case APIResourceType.File:\n resource = await fetchVersioned<File>(`/api/makeswift/files/${resourceId}`, version)\n break\n\n case APIResourceType.Typography:\n resource = await fetchVersioned<Typography>(\n `/api/makeswift/typographies/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchVersioned<GlobalElement>(\n `/api/makeswift/global-elements/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchVersioned<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n version,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchVersioned<PagePathnameSlice>(url.pathname + url.search, version)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchVersioned<Table>(`/api/makeswift/tables/${resourceId}`, version)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n"],"mappings":"AAEA,SAA2B,mBAAmB,4BAA4B;AAE1E,YAAY,sBAAsB;AAGlC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AAEvC;AAAA,EACE;AAAA,OAUK;AAEP,SAAqB,mBAAmB,gBAAgB,8BAA8B;AAM/E,SAAS,iBACd,cACA,YACA,OACA,QACgE;AAChE,QAAM,iBAAiB,OAAU,KAAa,YAAmD;AAC/F,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAI,WAAW,OACX,EAAE,CAAC,kBAAkB,WAAW,GAAG,qBAAqB,OAAO,EAAE,IACjE,CAAC;AAAA,MACP;AAAA,IACF,CAAC;AAED,QAAI,SAAS,WAAW;AAAK,aAAO;AACpC,QAAI,CAAC,SAAS;AAAI,YAAM,IAAI,MAAM,SAAS,UAAU;AAErD,QAAI,SAAS,QAAQ,IAAI,cAAc,GAAG,SAAS,kBAAkB,MAAM,MAAM;AAC/E,YAAM,IAAI;AAAA,QACR,gCAAgC,GAAG,cAAc,SAAS,QAAQ,IAAI,cAAc,CAAC;AAAA,MACvF;AAAA,IACF;AAEA,WAAO,SAAS,KAAK;AAAA,EACvB;AAEA,SAAO,OAAO,UAAU,aAAa;AACnC,UAAM,QAAQ,SAAS;AACvB,UAAM,UAAU,iBAAiB,eAAe,MAAM,WAAW;AAEjE,QAAI,kBAAkB,OAAO,cAAc,YAAY,MAAM,GAAG;AAC9D,aAAO,eAAe,OAAO,cAAc,YAAY,MAAM;AAAA,IAC/D;AAEA,QAAI;AAEJ,YAAQ,cAAc;AAAA,MACpB,KAAK,gBAAgB;AACnB,mBAAW,MAAM,eAAuB,2BAA2B,UAAU,IAAI,OAAO;AACxF;AAAA,MAEF,KAAK,gBAAgB;AACnB,mBAAW,MAAM,eAAqB,wBAAwB,UAAU,IAAI,OAAO;AACnF;AAAA,MAEF,KAAK,gBAAgB;AACnB,mBAAW,MAAM;AAAA,UACf,+BAA+B,UAAU;AAAA,UACzC;AAAA,QACF;AACA;AAAA,MAEF,KAAK,gBAAgB;AACnB,mBAAW,MAAM;AAAA,UACf,kCAAkC,UAAU;AAAA,UAC5C;AAAA,QACF;AACA;AAAA,MAEF,KAAK,gBAAgB,wBAAwB;AAC3C,YAAI,UAAU;AAAM,gBAAM,IAAI,MAAM,oDAAoD;AAIxF,YAAI,uBAAuB,OAAO,QAAQ,UAAU,MAAM,MAAM;AAC9D,iBAAO;AAAA,QACT;AAEA,mBAAW,MAAM;AAAA,UACf,4CAA4C,UAAU,IAAI,MAAM;AAAA,UAChE;AAAA,QACF;AAEA;AAAA,UACE,uBAAuB;AAAA,YACrB;AAAA,YACA;AAAA,YACA,qBAAqB,UAAU,MAAM;AAAA,UACvC,CAAC;AAAA,QACH;AAEA;AAAA,MACF;AAAA,MAEA,KAAK,gBAAgB,mBAAmB;AACtC,cAAM,MAAM,IAAI,IAAI,uCAAuC,UAAU,IAAI,UAAU;AAEnF,YAAI,UAAU;AAAM,cAAI,aAAa,IAAI,UAAU,MAAM;AAEzD,mBAAW,MAAM,eAAkC,IAAI,WAAW,IAAI,QAAQ,OAAO;AACrF;AAAA,MACF;AAAA,MAEA,KAAK,gBAAgB;AACnB,mBAAW,MAAM,eAAsB,yBAAyB,UAAU,IAAI,OAAO;AACrF;AAAA,MAEF;AACE,mBAAW;AAAA,IACf;AAEA,aAAS,qBAAqB,cAAc,YAAY,UAAU,MAAM,CAAC;AAEzE,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,52 @@
1
+ import { combineReducers } from "@reduxjs/toolkit";
2
+ import * as SiteVersionState from "../modules/site-version";
3
+ import * as LocaleState from "../modules/locale";
4
+ import * as APIResources from "../modules/api-resources";
5
+ import * as LocalizedResourcesMap from "../modules/localized-resources-map";
6
+ import { APIResourceType } from "../../api";
7
+ const reducer = combineReducers({
8
+ siteVersion: SiteVersionState.reducer,
9
+ locale: LocaleState.reducer,
10
+ apiResources: APIResources.reducer,
11
+ localizedResourcesMap: LocalizedResourcesMap.reducer
12
+ });
13
+ function getLocalizedResourceId(state, locale, resourceId) {
14
+ return LocalizedResourcesMap.getLocalizedResourceId(
15
+ state.localizedResourcesMap,
16
+ locale,
17
+ resourceId
18
+ );
19
+ }
20
+ function getHasAPIResource(state, resourceType, resourceId, locale) {
21
+ switch (resourceType) {
22
+ case APIResourceType.LocalizedGlobalElement:
23
+ if (locale == null) {
24
+ console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
25
+ return false;
26
+ }
27
+ const localizedId = getLocalizedResourceId(state, locale, resourceId);
28
+ return localizedId != null && APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale);
29
+ default:
30
+ return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale);
31
+ }
32
+ }
33
+ function getAPIResource(state, resourceType, resourceId, locale) {
34
+ switch (resourceType) {
35
+ case APIResourceType.LocalizedGlobalElement:
36
+ if (locale == null) {
37
+ console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
38
+ return null;
39
+ }
40
+ const localizedId = getLocalizedResourceId(state, locale, resourceId);
41
+ return localizedId != null ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale) : null;
42
+ default:
43
+ return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale);
44
+ }
45
+ }
46
+ export {
47
+ getAPIResource,
48
+ getHasAPIResource,
49
+ getLocalizedResourceId,
50
+ reducer
51
+ };
52
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/state.ts"],"sourcesContent":["import { combineReducers, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as SiteVersionState from '../modules/site-version'\nimport * as LocaleState from '../modules/locale'\nimport * as APIResources from '../modules/api-resources'\nimport * as LocalizedResourcesMap from '../modules/localized-resources-map'\n\nimport { type Action } from '../actions'\n\nimport { APIResourceType, type APIResource, type APIResourceLocale } from '../../api'\n\nexport const reducer = combineReducers({\n siteVersion: SiteVersionState.reducer,\n locale: LocaleState.reducer,\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nexport function getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n"],"mappings":"AAAA,SAAS,uBAA2C;AAEpD,YAAY,sBAAsB;AAClC,YAAY,iBAAiB;AAC7B,YAAY,kBAAkB;AAC9B,YAAY,2BAA2B;AAIvC,SAAS,uBAAiE;AAEnE,MAAM,UAAU,gBAAgB;AAAA,EACrC,aAAa,iBAAiB;AAAA,EAC9B,QAAQ,YAAY;AAAA,EACpB,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAUM,SAAS,uBACd,OACA,QACA,YAC2B;AAC3B,SAAO,sBAAsB;AAAA,IAC3B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,OACA,cACA,YACA,QACS;AACT,UAAQ,cAAc;AAAA,IACpB,KAAK,gBAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aACE,eAAe,QACf,aAAa,kBAAkB,MAAM,cAAc,cAAc,aAAa,MAAM;AAAA,IAGxF;AACE,aAAO,aAAa,kBAAkB,MAAM,cAAc,cAAc,YAAY,MAAM;AAAA,EAC9F;AACF;AAEO,SAAS,eACd,OACA,cACA,YACA,QACgD;AAChD,UAAQ,cAAc;AAAA,IACpB,KAAK,gBAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aAAO,eAAe,OAClB,aAAa,eAAe,MAAM,cAAc,cAAc,aAAa,MAAM,IACjF;AAAA,IAEN;AACE,aAAO,aAAa,eAAe,MAAM,cAAc,cAAc,YAAY,MAAM;AAAA,EAC3F;AACF;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { configureStore as configureReduxStore } from "@reduxjs/toolkit";
2
+ import { reducer } from "./state";
3
+ function configureStore({ preloadedState }) {
4
+ return configureReduxStore({
5
+ reducer,
6
+ preloadedState
7
+ });
8
+ }
9
+ export {
10
+ configureStore
11
+ };
12
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/store.ts"],"sourcesContent":["import { configureStore as configureReduxStore } from '@reduxjs/toolkit'\n\nimport { type State, reducer } from './state'\n\nexport function configureStore({ preloadedState }: { preloadedState: Partial<State> }) {\n return configureReduxStore({\n reducer,\n preloadedState,\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":"AAAA,SAAS,kBAAkB,2BAA2B;AAEtD,SAAqB,eAAe;AAE7B,SAAS,eAAe,EAAE,eAAe,GAAuC;AACrF,SAAO,oBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,86 @@
1
+ const CLICK_NAVIGATION_THRESHOLD_MS = 100;
2
+ const CLICK_NAVIGATION_CHECK_INTERVAL_MS = 200;
3
+ const CLICK_NAVIGATION_MAX_CHECKS = 20;
4
+ function setupNavigationListener(callback) {
5
+ let previousLocation = null;
6
+ const handleNavigate = (event) => {
7
+ if (!event.navigationCompleted && event.url === previousLocation)
8
+ return;
9
+ callback(event);
10
+ previousLocation = event.url;
11
+ };
12
+ handleNavigate({ url: windowLocation(), navigationCompleted: "initial-page-load" });
13
+ if (typeof window === "undefined") {
14
+ return () => {
15
+ };
16
+ }
17
+ const unsubscribes = [];
18
+ if ("navigation" in window && window.navigation) {
19
+ const navigation = window.navigation;
20
+ const navigateHandler = ({ destination }) => handleNavigate({ url: destination.url });
21
+ const navigateSuccessHandler = () => {
22
+ handleNavigate({
23
+ url: navigation.currentEntry.url,
24
+ navigationCompleted: "client-side-navigation"
25
+ });
26
+ };
27
+ navigation.addEventListener("navigate", navigateHandler);
28
+ navigation.addEventListener("navigatesuccess", navigateSuccessHandler);
29
+ unsubscribes.push(() => navigation.removeEventListener("navigate", navigateHandler));
30
+ unsubscribes.push(
31
+ () => navigation.removeEventListener("navigatesuccess", navigateSuccessHandler)
32
+ );
33
+ return () => {
34
+ unsubscribes.forEach((u) => u());
35
+ };
36
+ }
37
+ let lastClickEvent = null;
38
+ const clickHandler = (e) => {
39
+ const a = e.composedPath?.()?.find((n) => n instanceof HTMLAnchorElement) ?? (e.target instanceof Element && e.target.closest?.("a"));
40
+ if (!a)
41
+ return;
42
+ lastClickEvent = { href: a.href, timestamp: Date.now() };
43
+ const pageUrlBeforeClick = windowLocation();
44
+ let navigationCheckCounter = 0;
45
+ const checkIfNavigationOccurred = () => {
46
+ const url = windowLocation();
47
+ if (url !== pageUrlBeforeClick) {
48
+ handleNavigate({ url, polyfilled: true });
49
+ return;
50
+ }
51
+ if (++navigationCheckCounter < CLICK_NAVIGATION_MAX_CHECKS) {
52
+ window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS);
53
+ }
54
+ };
55
+ window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS);
56
+ };
57
+ window.document.addEventListener(
58
+ "click",
59
+ clickHandler,
60
+ { capture: true }
61
+ // run before bubbling to fortify against `stopPropagation()` calls
62
+ );
63
+ unsubscribes.push(
64
+ () => window.document.removeEventListener("click", clickHandler, { capture: true })
65
+ );
66
+ const unloadHandler = () => {
67
+ if (!lastClickEvent)
68
+ return;
69
+ const msSinceLastClick = Date.now() - lastClickEvent.timestamp;
70
+ handleNavigate({
71
+ url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? lastClickEvent.href ?? null : null,
72
+ polyfilled: true
73
+ });
74
+ lastClickEvent = null;
75
+ };
76
+ window.addEventListener("beforeunload", unloadHandler);
77
+ unsubscribes.push(() => window.removeEventListener("beforeunload", unloadHandler));
78
+ return () => {
79
+ unsubscribes.forEach((u) => u());
80
+ };
81
+ }
82
+ const windowLocation = () => typeof window !== "undefined" ? window.location.href : null;
83
+ export {
84
+ setupNavigationListener
85
+ };
86
+ //# sourceMappingURL=navigation-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/builder-api/navigation-listener.ts"],"sourcesContent":["import { type HostNavigationEvent } from './api'\n\ntype ClickEvent = {\n href: string\n timestamp: number\n}\n\nconst CLICK_NAVIGATION_THRESHOLD_MS = 100\nconst CLICK_NAVIGATION_CHECK_INTERVAL_MS = 200\nconst CLICK_NAVIGATION_MAX_CHECKS = 20\n\nexport function setupNavigationListener(\n callback: (args: HostNavigationEvent) => void,\n): VoidFunction {\n let previousLocation: string | null = null\n\n const handleNavigate = (event: HostNavigationEvent) => {\n if (!event.navigationCompleted && event.url === previousLocation) return\n\n callback(event)\n previousLocation = event.url\n }\n\n // trigger navigation callback on initial page load\n handleNavigate({ url: windowLocation(), navigationCompleted: 'initial-page-load' })\n\n if (typeof window === 'undefined') {\n return () => {}\n }\n\n const unsubscribes: (() => void)[] = []\n\n // check for availability of the Navigation API (baseline feature since January 2026),\n // see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n if ('navigation' in window && window.navigation) {\n const navigation = window.navigation\n\n const navigateHandler = ({ destination }: NavigateEvent) =>\n handleNavigate({ url: destination.url })\n\n const navigateSuccessHandler = () => {\n handleNavigate({\n url: navigation.currentEntry.url,\n navigationCompleted: 'client-side-navigation',\n })\n }\n\n // note that in order to capture destination URLs that might not be Makeswift-enabled,\n // we send a `SiteNavigationEvent` at the start of navigation, but do not track whether\n // the navigation was successful or not (possible future improvement)\n navigation.addEventListener('navigate', navigateHandler)\n navigation.addEventListener('navigatesuccess', navigateSuccessHandler)\n unsubscribes.push(() => navigation.removeEventListener('navigate', navigateHandler))\n unsubscribes.push(() =>\n navigation.removeEventListener('navigatesuccess', navigateSuccessHandler),\n )\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n }\n\n // for browsers lacking Navigation API support, we manually track:\n // - link clicks to capture destination URLs\n // - page unload events to detect cross-page navigation\n //\n // this works well enough to keep this polyfill in place for now, but not nearly as\n // reliably as the Navigation API\n let lastClickEvent: ClickEvent | null = null\n\n const clickHandler = (e: MouseEvent) => {\n const a =\n e.composedPath?.()?.find(n => n instanceof HTMLAnchorElement) ??\n (e.target instanceof Element && e.target.closest?.('a'))\n\n if (!a) return\n\n lastClickEvent = { href: a.href, timestamp: Date.now() }\n\n const pageUrlBeforeClick = windowLocation()\n let navigationCheckCounter = 0\n\n // handle navigation between pages in the host; note that we intentionally are\n // not cancelling the timer on cleanup to ensure we report the navigation\n const checkIfNavigationOccurred = () => {\n const url = windowLocation()\n\n if (url !== pageUrlBeforeClick) {\n // the host navigated to a different page, report the new URL to the builder\n handleNavigate({ url, polyfilled: true })\n return\n }\n\n // we're still on the same page, recheck until the max number of checks is reached\n if (++navigationCheckCounter < CLICK_NAVIGATION_MAX_CHECKS) {\n window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS)\n }\n }\n\n window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS)\n }\n\n window.document.addEventListener(\n 'click',\n clickHandler,\n { capture: true }, // run before bubbling to fortify against `stopPropagation()` calls\n )\n\n unsubscribes.push(() =>\n window.document.removeEventListener('click', clickHandler, { capture: true }),\n )\n\n // handle external navigation\n const unloadHandler = () => {\n if (!lastClickEvent) return\n\n const msSinceLastClick = Date.now() - lastClickEvent.timestamp\n handleNavigate({\n url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? (lastClickEvent.href ?? null) : null,\n polyfilled: true,\n })\n\n lastClickEvent = null\n }\n\n window.addEventListener('beforeunload', unloadHandler)\n unsubscribes.push(() => window.removeEventListener('beforeunload', unloadHandler))\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n}\n\nconst windowLocation = (): string | null =>\n typeof window !== 'undefined' ? window.location.href : null\n"],"mappings":"AAOA,MAAM,gCAAgC;AACtC,MAAM,qCAAqC;AAC3C,MAAM,8BAA8B;AAE7B,SAAS,wBACd,UACc;AACd,MAAI,mBAAkC;AAEtC,QAAM,iBAAiB,CAAC,UAA+B;AACrD,QAAI,CAAC,MAAM,uBAAuB,MAAM,QAAQ;AAAkB;AAElE,aAAS,KAAK;AACd,uBAAmB,MAAM;AAAA,EAC3B;AAGA,iBAAe,EAAE,KAAK,eAAe,GAAG,qBAAqB,oBAAoB,CAAC;AAElF,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAEA,QAAM,eAA+B,CAAC;AAItC,MAAI,gBAAgB,UAAU,OAAO,YAAY;AAC/C,UAAM,aAAa,OAAO;AAE1B,UAAM,kBAAkB,CAAC,EAAE,YAAY,MACrC,eAAe,EAAE,KAAK,YAAY,IAAI,CAAC;AAEzC,UAAM,yBAAyB,MAAM;AACnC,qBAAe;AAAA,QACb,KAAK,WAAW,aAAa;AAAA,QAC7B,qBAAqB;AAAA,MACvB,CAAC;AAAA,IACH;AAKA,eAAW,iBAAiB,YAAY,eAAe;AACvD,eAAW,iBAAiB,mBAAmB,sBAAsB;AACrE,iBAAa,KAAK,MAAM,WAAW,oBAAoB,YAAY,eAAe,CAAC;AACnF,iBAAa;AAAA,MAAK,MAChB,WAAW,oBAAoB,mBAAmB,sBAAsB;AAAA,IAC1E;AAEA,WAAO,MAAM;AACX,mBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,IAC/B;AAAA,EACF;AAQA,MAAI,iBAAoC;AAExC,QAAM,eAAe,CAAC,MAAkB;AACtC,UAAM,IACJ,EAAE,eAAe,GAAG,KAAK,OAAK,aAAa,iBAAiB,MAC3D,EAAE,kBAAkB,WAAW,EAAE,OAAO,UAAU,GAAG;AAExD,QAAI,CAAC;AAAG;AAER,qBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,KAAK,IAAI,EAAE;AAEvD,UAAM,qBAAqB,eAAe;AAC1C,QAAI,yBAAyB;AAI7B,UAAM,4BAA4B,MAAM;AACtC,YAAM,MAAM,eAAe;AAE3B,UAAI,QAAQ,oBAAoB;AAE9B,uBAAe,EAAE,KAAK,YAAY,KAAK,CAAC;AACxC;AAAA,MACF;AAGA,UAAI,EAAE,yBAAyB,6BAA6B;AAC1D,eAAO,WAAW,2BAA2B,kCAAkC;AAAA,MACjF;AAAA,IACF;AAEA,WAAO,WAAW,2BAA2B,kCAAkC;AAAA,EACjF;AAEA,SAAO,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA,EAAE,SAAS,KAAK;AAAA;AAAA,EAClB;AAEA,eAAa;AAAA,IAAK,MAChB,OAAO,SAAS,oBAAoB,SAAS,cAAc,EAAE,SAAS,KAAK,CAAC;AAAA,EAC9E;AAGA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,CAAC;AAAgB;AAErB,UAAM,mBAAmB,KAAK,IAAI,IAAI,eAAe;AACrD,mBAAe;AAAA,MACb,KAAK,mBAAmB,gCAAiC,eAAe,QAAQ,OAAQ;AAAA,MACxF,YAAY;AAAA,IACd,CAAC;AAED,qBAAiB;AAAA,EACnB;AAEA,SAAO,iBAAiB,gBAAgB,aAAa;AACrD,eAAa,KAAK,MAAM,OAAO,oBAAoB,gBAAgB,aAAa,CAAC;AAEjF,SAAO,MAAM;AACX,iBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,EAC/B;AACF;AAEA,MAAM,iBAAiB,MACrB,OAAO,WAAW,cAAc,OAAO,SAAS,OAAO;","names":[]}
@@ -0,0 +1,48 @@
1
+ import { updateClientBreakpoint } from "../actions/internal/read-only-actions";
2
+ import { getDeviceQueries } from "../modules/breakpoints";
3
+ import { getBreakpoints } from "../read-only-state";
4
+ function breakpointWatchMixin({
5
+ dispatch,
6
+ getState,
7
+ subscribe: storeSubscribe
8
+ }) {
9
+ let mediaQueryUnsubscribes = [];
10
+ let storeUnsubscribe = null;
11
+ let watchedBreakpoints = [];
12
+ const startWatch = (breakpoints) => {
13
+ mediaQueryUnsubscribes.forEach((fn) => fn());
14
+ const updateState = () => dispatch(updateClientBreakpoint());
15
+ mediaQueryUnsubscribes = getDeviceQueries(breakpoints).map((q) => {
16
+ const mediaQueryList = window.matchMedia(q.query);
17
+ mediaQueryList.addEventListener("change", updateState);
18
+ return () => mediaQueryList.removeEventListener("change", updateState);
19
+ });
20
+ watchedBreakpoints = breakpoints;
21
+ updateState();
22
+ };
23
+ return {
24
+ startBreakpointWatch: () => {
25
+ if (storeUnsubscribe !== null) {
26
+ console.warn("Unexpected `BreakpointWatch.startBreakpointWatch` call, already watching");
27
+ return;
28
+ }
29
+ startWatch(getBreakpoints(getState()));
30
+ storeUnsubscribe = storeSubscribe(() => {
31
+ const breakpoints = getBreakpoints(getState());
32
+ if (breakpoints !== watchedBreakpoints) {
33
+ startWatch(breakpoints);
34
+ }
35
+ });
36
+ },
37
+ stopBreakpointWatch: () => {
38
+ mediaQueryUnsubscribes.forEach((fn) => fn());
39
+ mediaQueryUnsubscribes = [];
40
+ storeUnsubscribe?.();
41
+ storeUnsubscribe = null;
42
+ }
43
+ };
44
+ }
45
+ export {
46
+ breakpointWatchMixin
47
+ };
48
+ //# sourceMappingURL=breakpoint-watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/mixins/breakpoint-watch.ts"],"sourcesContent":["import { updateClientBreakpoint } from '../actions/internal/read-only-actions'\nimport { Breakpoints, getDeviceQueries } from '../modules/breakpoints'\n\nimport { type State, type Dispatch } from '../unified-state'\nimport { getBreakpoints } from '../read-only-state'\n\nexport interface BreakpointWatch {\n startBreakpointWatch(): void\n stopBreakpointWatch(): void\n}\n\nexport function breakpointWatchMixin({\n dispatch,\n getState,\n subscribe: storeSubscribe,\n}: {\n dispatch: Dispatch\n getState: () => State\n subscribe: (listener: VoidFunction) => VoidFunction\n}): BreakpointWatch {\n let mediaQueryUnsubscribes: VoidFunction[] = []\n let storeUnsubscribe: VoidFunction | null = null\n let watchedBreakpoints: Breakpoints = []\n\n // client-side breakpoint watch\n const startWatch = (breakpoints: Breakpoints) => {\n mediaQueryUnsubscribes.forEach(fn => fn())\n\n const updateState = () => dispatch(updateClientBreakpoint())\n\n mediaQueryUnsubscribes = getDeviceQueries(breakpoints).map(q => {\n const mediaQueryList = window.matchMedia(q.query)\n mediaQueryList.addEventListener('change', updateState)\n return () => mediaQueryList.removeEventListener('change', updateState)\n })\n\n watchedBreakpoints = breakpoints\n\n // reconcile the store with the current client breakpoint after subscribing;\n // this heals any stale breakpoint state from changes that happened\n // after the store was created or updated but before the listeners were attached\n updateState()\n }\n\n return {\n startBreakpointWatch: () => {\n if (storeUnsubscribe !== null) {\n console.warn('Unexpected `BreakpointWatch.startBreakpointWatch` call, already watching')\n return\n }\n\n startWatch(getBreakpoints(getState()))\n\n storeUnsubscribe = storeSubscribe(() => {\n const breakpoints = getBreakpoints(getState())\n if (breakpoints !== watchedBreakpoints) {\n startWatch(breakpoints)\n }\n })\n },\n\n stopBreakpointWatch: () => {\n mediaQueryUnsubscribes.forEach(fn => fn())\n mediaQueryUnsubscribes = []\n\n storeUnsubscribe?.()\n storeUnsubscribe = null\n },\n }\n}\n"],"mappings":"AAAA,SAAS,8BAA8B;AACvC,SAAsB,wBAAwB;AAG9C,SAAS,sBAAsB;AAOxB,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,WAAW;AACb,GAIoB;AAClB,MAAI,yBAAyC,CAAC;AAC9C,MAAI,mBAAwC;AAC5C,MAAI,qBAAkC,CAAC;AAGvC,QAAM,aAAa,CAAC,gBAA6B;AAC/C,2BAAuB,QAAQ,QAAM,GAAG,CAAC;AAEzC,UAAM,cAAc,MAAM,SAAS,uBAAuB,CAAC;AAE3D,6BAAyB,iBAAiB,WAAW,EAAE,IAAI,OAAK;AAC9D,YAAM,iBAAiB,OAAO,WAAW,EAAE,KAAK;AAChD,qBAAe,iBAAiB,UAAU,WAAW;AACrD,aAAO,MAAM,eAAe,oBAAoB,UAAU,WAAW;AAAA,IACvE,CAAC;AAED,yBAAqB;AAKrB,gBAAY;AAAA,EACd;AAEA,SAAO;AAAA,IACL,sBAAsB,MAAM;AAC1B,UAAI,qBAAqB,MAAM;AAC7B,gBAAQ,KAAK,0EAA0E;AACvF;AAAA,MACF;AAEA,iBAAW,eAAe,SAAS,CAAC,CAAC;AAErC,yBAAmB,eAAe,MAAM;AACtC,cAAM,cAAc,eAAe,SAAS,CAAC;AAC7C,YAAI,gBAAgB,oBAAoB;AACtC,qBAAW,WAAW;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEA,qBAAqB,MAAM;AACzB,6BAAuB,QAAQ,QAAM,GAAG,CAAC;AACzC,+BAAyB,CAAC;AAE1B,yBAAmB;AACnB,yBAAmB;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ function withSetupTeardown(setup, teardown) {
2
+ return (next) => (reducer, preloadedState) => ({
3
+ ...next(reducer, preloadedState),
4
+ setup,
5
+ teardown
6
+ });
7
+ }
8
+ export {
9
+ withSetupTeardown
10
+ };
11
+ //# sourceMappingURL=setup-teardown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/mixins/setup-teardown.ts"],"sourcesContent":["import { type StoreEnhancer } from '@reduxjs/toolkit'\n\nexport interface SetupTeardownMixin {\n setup: () => void\n teardown: () => void\n}\n\nexport function withSetupTeardown(\n setup: () => void,\n teardown: () => void,\n): StoreEnhancer<SetupTeardownMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n setup,\n teardown,\n })\n}\n"],"mappings":"AAOO,SAAS,kBACd,OACA,UACmC;AACnC,SAAO,UAAQ,CAAC,SAAS,oBAAqB;AAAA,IAC5C,GAAG,KAAK,SAAS,cAAc;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,98 @@
1
+ import {
2
+ createBox as createBoxWithoutScroll,
3
+ getBox as getBoxWithoutScroll,
4
+ withScroll
5
+ } from "css-box-model";
6
+ import { ActionTypes, isKnownAction } from "../actions";
7
+ function parse(rawString) {
8
+ const value = Number(rawString.replace(/px$/, ""));
9
+ return Number.isFinite(value) ? value : 0;
10
+ }
11
+ function createBox(boxArgs) {
12
+ return withScroll(createBoxWithoutScroll(boxArgs));
13
+ }
14
+ function getBox(element) {
15
+ return withScroll(getBoxWithoutScroll(element));
16
+ }
17
+ function isMeasurable(value) {
18
+ if (value instanceof Element)
19
+ return true;
20
+ if (typeof value === "object" && value !== null && "getBoxModel" in value && typeof value.getBoxModel === "function") {
21
+ return true;
22
+ }
23
+ return false;
24
+ }
25
+ function measure(measurable) {
26
+ if (measurable instanceof Element)
27
+ return getBox(measurable);
28
+ return measurable.getBoxModel();
29
+ }
30
+ function getInitialState() {
31
+ return { measurables: /* @__PURE__ */ new Map(), boxModels: /* @__PURE__ */ new Map() };
32
+ }
33
+ function getMeasurables(state) {
34
+ return state.measurables;
35
+ }
36
+ function getBoxModels(state) {
37
+ return state.boxModels;
38
+ }
39
+ function getBoxModel(state, documentKey, elementKey) {
40
+ return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null;
41
+ }
42
+ function reducer(state = getInitialState(), action) {
43
+ if (!isKnownAction(action))
44
+ return state;
45
+ switch (action.type) {
46
+ case ActionTypes.REGISTER_MEASURABLE: {
47
+ const { documentKey, elementKey, measurable } = action.payload;
48
+ return {
49
+ ...state,
50
+ measurables: new Map(state.measurables).set(
51
+ documentKey,
52
+ new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable)
53
+ )
54
+ };
55
+ }
56
+ case ActionTypes.UNREGISTER_MEASURABLE: {
57
+ const { documentKey, elementKey } = action.payload;
58
+ const nextMeasurables = new Map(state.measurables.get(documentKey) ?? []);
59
+ const deleted = nextMeasurables.delete(elementKey);
60
+ return deleted ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) } : state;
61
+ }
62
+ case ActionTypes.CHANGE_ELEMENT_BOX_MODELS: {
63
+ const { changedElementBoxModels } = action.payload;
64
+ if (changedElementBoxModels.size === 0)
65
+ return state;
66
+ const nextBoxModels = new Map(state.boxModels);
67
+ changedElementBoxModels.forEach((changedBoxModels, documentKey) => {
68
+ const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? []);
69
+ changedBoxModels.forEach((changedBoxModel, elementKey) => {
70
+ if (changedBoxModel == null)
71
+ nextDocumentBoxModels.delete(elementKey);
72
+ else
73
+ nextDocumentBoxModels.set(elementKey, changedBoxModel);
74
+ });
75
+ if (nextDocumentBoxModels.size > 0)
76
+ nextBoxModels.set(documentKey, nextDocumentBoxModels);
77
+ else
78
+ nextBoxModels.delete(documentKey);
79
+ });
80
+ return { ...state, boxModels: nextBoxModels };
81
+ }
82
+ default:
83
+ return state;
84
+ }
85
+ }
86
+ export {
87
+ createBox,
88
+ getBox,
89
+ getBoxModel,
90
+ getBoxModels,
91
+ getInitialState,
92
+ getMeasurables,
93
+ isMeasurable,
94
+ measure,
95
+ parse,
96
+ reducer
97
+ };
98
+ //# sourceMappingURL=box-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/box-models.ts"],"sourcesContent":["import { type BoxModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport type { BoxModel }\n\nexport function parse(rawString: string): number {\n const value = Number(rawString.replace(/px$/, ''))\n\n return Number.isFinite(value) ? value : 0\n}\n\nexport function createBox(boxArgs: CreateBoxArgs): BoxModel {\n return withScroll(createBoxWithoutScroll(boxArgs))\n}\n\nexport function getBox(element: Element): BoxModel {\n return withScroll(getBoxWithoutScroll(element))\n}\n\nexport interface BoxModelHandle {\n getBoxModel(): BoxModel | null\n}\n\nexport type Measurable = Element | BoxModelHandle\n\nexport function isMeasurable(value: unknown): value is Measurable {\n if (value instanceof Element) return true\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getBoxModel' in value &&\n typeof (value as { getBoxModel: unknown }).getBoxModel === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport function measure(measurable: Measurable): BoxModel | null {\n if (measurable instanceof Element) return getBox(measurable)\n\n return measurable.getBoxModel()\n}\n\nexport type State = {\n measurables: Map<string, Map<string, Measurable>>\n boxModels: Map<string, Map<string, BoxModel>>\n}\n\nexport function getInitialState(): State {\n return { measurables: new Map(), boxModels: new Map() }\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, Measurable>> {\n return state.measurables\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModel>> {\n return state.boxModels\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModel | null {\n return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.REGISTER_MEASURABLE: {\n const { documentKey, elementKey, measurable } = action.payload\n\n return {\n ...state,\n measurables: new Map(state.measurables).set(\n documentKey,\n new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_MEASURABLE: {\n const { documentKey, elementKey } = action.payload\n const nextMeasurables = new Map(state.measurables.get(documentKey) ?? [])\n\n const deleted = nextMeasurables.delete(elementKey)\n\n return deleted\n ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) }\n : state\n }\n\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS: {\n const { changedElementBoxModels } = action.payload\n\n if (changedElementBoxModels.size === 0) return state\n\n const nextBoxModels = new Map(state.boxModels)\n\n changedElementBoxModels.forEach((changedBoxModels, documentKey) => {\n const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? [])\n\n changedBoxModels.forEach((changedBoxModel, elementKey) => {\n if (changedBoxModel == null) nextDocumentBoxModels.delete(elementKey)\n else nextDocumentBoxModels.set(elementKey, changedBoxModel)\n })\n\n if (nextDocumentBoxModels.size > 0) nextBoxModels.set(documentKey, nextDocumentBoxModels)\n else nextBoxModels.delete(documentKey)\n })\n\n return { ...state, boxModels: nextBoxModels }\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA;AAAA,EACE,aAAa;AAAA,EAEb,UAAU;AAAA,EACV;AAAA,OACK;AAEP,SAA0C,aAAa,qBAAqB;AAIrE,SAAS,MAAM,WAA2B;AAC/C,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,EAAE,CAAC;AAEjD,SAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAEO,SAAS,UAAU,SAAkC;AAC1D,SAAO,WAAW,uBAAuB,OAAO,CAAC;AACnD;AAEO,SAAS,OAAO,SAA4B;AACjD,SAAO,WAAW,oBAAoB,OAAO,CAAC;AAChD;AAQO,SAAS,aAAa,OAAqC;AAChE,MAAI,iBAAiB;AAAS,WAAO;AAErC,MACE,OAAO,UAAU,YACjB,UAAU,QACV,iBAAiB,SACjB,OAAQ,MAAmC,gBAAgB,YAC3D;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,QAAQ,YAAyC;AAC/D,MAAI,sBAAsB;AAAS,WAAO,OAAO,UAAU;AAE3D,SAAO,WAAW,YAAY;AAChC;AAOO,SAAS,kBAAyB;AACvC,SAAO,EAAE,aAAa,oBAAI,IAAI,GAAG,WAAW,oBAAI,IAAI,EAAE;AACxD;AAEO,SAAS,eAAe,OAAoD;AACjF,SAAO,MAAM;AACf;AAEO,SAAS,aAAa,OAAkD;AAC7E,SAAO,MAAM;AACf;AAEO,SAAS,YACd,OACA,aACA,YACiB;AACjB,SAAO,aAAa,KAAK,EAAE,IAAI,WAAW,GAAG,IAAI,UAAU,KAAK;AAClE;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAgC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,YAAY,qBAAqB;AACpC,YAAM,EAAE,aAAa,YAAY,WAAW,IAAI,OAAO;AAEvD,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,IAAI,IAAI,MAAM,WAAW,EAAE;AAAA,UACtC;AAAA,UACA,IAAI,IAAI,MAAM,YAAY,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,IAAI,YAAY,UAAU;AAAA,QAC9E;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,YAAY,uBAAuB;AACtC,YAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,YAAM,kBAAkB,IAAI,IAAI,MAAM,YAAY,IAAI,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,gBAAgB,OAAO,UAAU;AAEjD,aAAO,UACH,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,MAAM,WAAW,EAAE,IAAI,aAAa,eAAe,EAAE,IACtF;AAAA,IACN;AAAA,IAEA,KAAK,YAAY,2BAA2B;AAC1C,YAAM,EAAE,wBAAwB,IAAI,OAAO;AAE3C,UAAI,wBAAwB,SAAS;AAAG,eAAO;AAE/C,YAAM,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAE7C,8BAAwB,QAAQ,CAAC,kBAAkB,gBAAgB;AACjE,cAAM,wBAAwB,IAAI,IAAI,cAAc,IAAI,WAAW,KAAK,CAAC,CAAC;AAE1E,yBAAiB,QAAQ,CAAC,iBAAiB,eAAe;AACxD,cAAI,mBAAmB;AAAM,kCAAsB,OAAO,UAAU;AAAA;AAC/D,kCAAsB,IAAI,YAAY,eAAe;AAAA,QAC5D,CAAC;AAED,YAAI,sBAAsB,OAAO;AAAG,wBAAc,IAAI,aAAa,qBAAqB;AAAA;AACnF,wBAAc,OAAO,WAAW;AAAA,MACvC,CAAC;AAED,aAAO,EAAE,GAAG,OAAO,WAAW,cAAc;AAAA,IAC9C;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -0,0 +1,35 @@
1
+ import { ActionTypes, isKnownAction } from "../actions";
2
+ function getElementImperativeHandles(state) {
3
+ return state;
4
+ }
5
+ function getInitialState() {
6
+ return /* @__PURE__ */ new Map();
7
+ }
8
+ function reducer(state = getInitialState(), action) {
9
+ if (!isKnownAction(action))
10
+ return state;
11
+ switch (action.type) {
12
+ case ActionTypes.REGISTER_COMPONENT_HANDLE:
13
+ return new Map(state).set(
14
+ action.payload.documentKey,
15
+ new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
16
+ action.payload.elementKey,
17
+ action.payload.componentHandle
18
+ )
19
+ );
20
+ case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {
21
+ const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
22
+ const deleted = byElementKey.delete(action.payload.elementKey);
23
+ if (!deleted)
24
+ return state;
25
+ return new Map(state).set(action.payload.documentKey, byElementKey);
26
+ }
27
+ default:
28
+ return state;
29
+ }
30
+ }
31
+ export {
32
+ getElementImperativeHandles,
33
+ reducer
34
+ };
35
+ //# sourceMappingURL=element-imperative-handles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,aAAa,qBAAqB;AAIrE,SAAS,4BACd,OACmD;AACnD,SAAO;AACT;AAEA,SAAS,kBAAyB;AAChC,SAAO,oBAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,YAAY;AACf,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAAA,UAC5D,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,YAAY,6BAA6B;AAC5C,YAAM,eAAe,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,aAAa,OAAO,OAAO,QAAQ,UAAU;AAE7D,UAAI,CAAC;AAAS,eAAO;AAErB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY;AAAA,IACpE;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -0,0 +1,21 @@
1
+ import { isKnownAction } from "../actions";
2
+ function getInitialState(isPreview = false) {
3
+ return isPreview;
4
+ }
5
+ function getIsPreview(state) {
6
+ return state;
7
+ }
8
+ function reducer(state = getInitialState(), action) {
9
+ if (!isKnownAction(action))
10
+ return state;
11
+ switch (action.type) {
12
+ default:
13
+ return state;
14
+ }
15
+ }
16
+ export {
17
+ getInitialState,
18
+ getIsPreview,
19
+ reducer
20
+ };
21
+ //# sourceMappingURL=is-preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/is-preview.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nexport type State = boolean\n\nexport function getInitialState(isPreview = false): State {\n return isPreview\n}\n\nexport function getIsPreview(state: State): boolean {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAIxD,SAAS,gBAAgB,YAAY,OAAc;AACxD,SAAO;AACT;AAEO,SAAS,aAAa,OAAuB;AAClD,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -0,0 +1,22 @@
1
+ import { ActionTypes, isKnownAction } from "../actions";
2
+ function getInitialState() {
3
+ return { pointer: null };
4
+ }
5
+ function getPointer(state) {
6
+ return state.pointer;
7
+ }
8
+ function reducer(state = getInitialState(), action) {
9
+ if (!isKnownAction(action))
10
+ return state;
11
+ switch (action.type) {
12
+ case ActionTypes.BUILDER_POINTER_MOVE:
13
+ return { ...state, pointer: action.payload.pointer };
14
+ default:
15
+ return state;
16
+ }
17
+ }
18
+ export {
19
+ getPointer,
20
+ reducer
21
+ };
22
+ //# sourceMappingURL=pointer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/modules/pointer.ts"],"sourcesContent":["import { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,aAAa,qBAAqB;AAQ5E,SAAS,kBAAyB;AAChC,SAAO,EAAE,SAAS,KAAK;AACzB;AAEO,SAAS,WAAW,OAA4B;AACrD,SAAO,MAAM;AACf;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,YAAY;AACf,aAAO,EAAE,GAAG,OAAO,SAAS,OAAO,QAAQ,QAAQ;AAAA,IAErD;AACE,aAAO;AAAA,EACX;AACF;","names":[]}