@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,160 @@
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 api_resources_client_exports = {};
30
+ __export(api_resources_client_exports, {
31
+ ApiResourcesClient: () => ApiResourcesClient,
32
+ CacheData: () => CacheData
33
+ });
34
+ module.exports = __toCommonJS(api_resources_client_exports);
35
+ var ApiClientState = __toESM(require("../state/api-client/state"));
36
+ var import_types = require("./types");
37
+ const CacheData = {
38
+ empty() {
39
+ return {
40
+ apiResources: {},
41
+ localizedResourcesMap: {}
42
+ };
43
+ }
44
+ };
45
+ class ApiResourcesClient {
46
+ store;
47
+ subscribe;
48
+ constructor({ store }) {
49
+ this.store = store;
50
+ this.subscribe = this.store.subscribe;
51
+ }
52
+ readSwatch(swatchId) {
53
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Swatch, swatchId);
54
+ }
55
+ resolveSwatch(swatchId) {
56
+ return this.resolveResource(import_types.APIResourceType.Swatch, {
57
+ id: swatchId,
58
+ read: (id) => this.readSwatch(id),
59
+ fetch: (id) => this.fetchSwatch(id)
60
+ });
61
+ }
62
+ readFile(fileId) {
63
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.File, fileId);
64
+ }
65
+ resolveFile(fileId) {
66
+ return this.resolveResource(import_types.APIResourceType.File, {
67
+ id: fileId,
68
+ read: (id) => this.readFile(id),
69
+ fetch: (id) => this.fetchFile(id)
70
+ });
71
+ }
72
+ readTypography(typographyId) {
73
+ return ApiClientState.getAPIResource(
74
+ this.store.getState(),
75
+ import_types.APIResourceType.Typography,
76
+ typographyId
77
+ );
78
+ }
79
+ resolveTypography(typographyId) {
80
+ return this.resolveResource(import_types.APIResourceType.Typography, {
81
+ id: typographyId,
82
+ read: (id) => this.readTypography(id),
83
+ fetch: (id) => this.fetchTypography(id)
84
+ });
85
+ }
86
+ readGlobalElement(globalElementId) {
87
+ return ApiClientState.getAPIResource(
88
+ this.store.getState(),
89
+ import_types.APIResourceType.GlobalElement,
90
+ globalElementId
91
+ );
92
+ }
93
+ readLocalizedGlobalElement({
94
+ globalElementId,
95
+ locale
96
+ }) {
97
+ return ApiClientState.getAPIResource(
98
+ this.store.getState(),
99
+ import_types.APIResourceType.LocalizedGlobalElement,
100
+ globalElementId,
101
+ locale
102
+ );
103
+ }
104
+ readPagePathnameSlice({
105
+ pageId,
106
+ locale
107
+ }) {
108
+ return ApiClientState.getAPIResource(
109
+ this.store.getState(),
110
+ import_types.APIResourceType.PagePathnameSlice,
111
+ pageId,
112
+ locale
113
+ );
114
+ }
115
+ resolvePagePathnameSlice({
116
+ pageId,
117
+ locale
118
+ }) {
119
+ return this.resolveResource(import_types.APIResourceType.PagePathnameSlice, {
120
+ id: pageId,
121
+ read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
122
+ fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
123
+ });
124
+ }
125
+ resolveResource(type, {
126
+ id,
127
+ read,
128
+ fetch
129
+ }) {
130
+ const _read = () => id != null ? read(id) : null;
131
+ let lastValue = null;
132
+ return {
133
+ name: `${type}:${id}`,
134
+ readStable: () => lastValue = _read(),
135
+ subscribe: (onUpdate) => this.subscribe(() => {
136
+ if (_read() !== lastValue)
137
+ onUpdate();
138
+ }),
139
+ fetch: async () => id != null ? fetch(id) : null
140
+ };
141
+ }
142
+ readTable(tableId) {
143
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Table, tableId);
144
+ }
145
+ readSite(siteId) {
146
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Site, siteId);
147
+ }
148
+ readPage(pageId) {
149
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Page, pageId);
150
+ }
151
+ readSnippet(snippetId) {
152
+ return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Snippet, snippetId);
153
+ }
154
+ }
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ ApiResourcesClient,
158
+ CacheData
159
+ });
160
+ //# sourceMappingURL=api-resources-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/api-resources-client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport { type Store as ApiClientStore } from '../state/api-client/store'\nimport * as ApiClientState from '../state/api-client/state'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type Page,\n type PagePathnameSlice,\n type Site,\n type Snippet,\n type Swatch,\n type Table,\n type Typography,\n APIResourceType,\n} from './types'\n\nexport type CacheData = ApiClientState.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\nexport abstract class ApiResourcesClient {\n readonly store: ApiClientStore\n readonly subscribe: ApiClientStore['subscribe']\n\n constructor({ store }: { store: ApiClientStore }) {\n this.store = store\n this.subscribe = this.store.subscribe\n }\n\n abstract fetchSwatch(swatchId: string): Promise<Swatch | null>\n\n readSwatch(swatchId: string): Swatch | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Swatch, swatchId)\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 abstract fetchFile(fileId: string): Promise<File | null>\n\n readFile(fileId: string): File | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.File, fileId)\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 abstract fetchTypography(typographyId: string): Promise<Typography | null>\n\n readTypography(typographyId: string): Typography | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.Typography,\n typographyId,\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 abstract fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null>\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n abstract fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null>\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n abstract fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null>\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 abstract fetchTable(tableId: string): Promise<Table | null>\n\n readTable(tableId: string): Table | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Table, tableId)\n }\n\n readSite(siteId: string): Site | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Site, siteId)\n }\n\n readPage(pageId: string): Page | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Page, pageId)\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Snippet, snippetId)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgC;AAEhC,mBAYO;AAIA,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AACO,MAAe,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YAAY,EAAE,MAAM,GAA8B;AAChD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,MAAM;AAAA,EAC9B;AAAA,EAIA,WAAW,UAAiC;AAC1C,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,QAAQ,QAAQ;AAAA,EAC9F;AAAA,EAEA,cAAc,UAA6D;AACzE,WAAO,KAAK,gBAAgB,6BAAgB,QAAQ;AAAA,MAClD,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,WAAW,EAAE;AAAA,MAC9B,OAAO,QAAM,KAAK,YAAY,EAAE;AAAA,IAClC,CAAC;AAAA,E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,MAC7D,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,sBAAsB,EAAE,QAAQ,IAAI,OAAO,CAAC;AAAA,MAC7D,OAAO,QAAM,KAAK,uBAAuB,EAAE,QAAQ,IAAI,OAAO,CAAC;AAAA,IACjE,CAAC;AAAA,EACH;AAAA,EAEA,gBACE,MACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAK0B;AAC1B,UAAM,QAAQ,MAAO,MAAM,OAAO,KAAK,EAAE,IAAI;AAC7C,QAAI,YAAsB;AAC1B,WAAO;AAAA,MACL,MAAM,GAAG,IAAI,IAAI,EAAE;AAAA,MACnB,YAAY,MAAO,YAAY,MAAM;AAAA,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,EAIA,UAAU,SAA+B;AACvC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,OAAO,OAAO;AAAA,EAC5F;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,SAAS,SAAS;AAAA,EAChG;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,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAAoC;AACpC,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,IACA;AAAA,EACF,GAKG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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":[]}
@@ -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.27.1",
31
+ version: "0.27.3",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -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":[]}
@@ -0,0 +1,33 @@
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 box_model_exports = {};
20
+ __export(box_model_exports, {
21
+ createBox: () => import_box_models.createBox,
22
+ getBox: () => import_box_models.getBox,
23
+ parse: () => import_box_models.parse
24
+ });
25
+ module.exports = __toCommonJS(box_model_exports);
26
+ var import_box_models = require("./state/modules/box-models");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ createBox,
30
+ getBox,
31
+ parse
32
+ });
33
+ //# sourceMappingURL=box-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/box-model.ts"],"sourcesContent":["export { createBox, getBox, parse } from './state/modules/box-models'\nexport type { BoxModelHandle, BoxModel } from './state/modules/box-models'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAyC;","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