@makeswift/runtime 0.26.4-canary.1 → 0.26.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/client.js +2 -13
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api/react.js +256 -0
- package/dist/cjs/api/react.js.map +1 -0
- package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/api-handler/handlers/merge-translated-data.js.map +1 -1
- package/dist/cjs/api-handler/handlers/translatable-data.js.map +1 -1
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js +62 -0
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js.map +1 -0
- package/dist/cjs/builder/host-to-builder-actions.js +3 -3
- package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
- package/dist/cjs/builder/index.js +2 -2
- package/dist/cjs/builder/index.js.map +1 -1
- package/dist/cjs/builder/serialization.js +78 -0
- package/dist/cjs/builder/serialization.js.map +1 -0
- package/dist/cjs/client/index.js +8 -8
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/components/builtin/Box/Box.js +1 -1
- package/dist/cjs/components/builtin/Box/Box.js.map +1 -1
- package/dist/cjs/components/builtin/Form/Form.js +1 -1
- package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
- package/dist/cjs/components/hooks/useTableFormFieldRefs.js +1 -1
- package/dist/cjs/components/hooks/useTableFormFieldRefs.js.map +1 -1
- package/dist/cjs/controls/serialization/base/index.js +78 -0
- package/dist/cjs/controls/serialization/base/index.js.map +1 -0
- package/dist/cjs/controls/serialization/base/visitor.js +59 -0
- package/dist/cjs/controls/serialization/base/visitor.js.map +1 -0
- package/dist/cjs/controls/serialization/index.js +55 -0
- package/dist/cjs/controls/serialization/index.js.map +1 -0
- package/dist/cjs/controls/serialization/message-port/function-serialization.js +79 -0
- package/dist/cjs/controls/serialization/message-port/function-serialization.js.map +1 -0
- package/dist/cjs/controls/serialization/message-port/index.js +25 -0
- package/dist/cjs/controls/serialization/message-port/index.js.map +1 -0
- package/dist/cjs/controls/serialization/message-port/visitor.js +48 -0
- package/dist/cjs/controls/serialization/message-port/visitor.js.map +1 -0
- package/dist/cjs/next/api-handler/config/app-router.js +10 -1
- package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
- package/dist/cjs/next/api-handler/config/pages-router.js +1 -1
- package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/index.js +1 -1
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/color-control/fixtures.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -1
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
- package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +2 -1
- package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -1
- package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
- package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
- package/dist/cjs/next/fetch.js +30 -0
- package/dist/cjs/next/fetch.js.map +1 -0
- package/dist/cjs/next/runtime.js +35 -0
- package/dist/cjs/next/runtime.js.map +1 -0
- package/dist/cjs/next/testing/element-data.js +3 -3
- package/dist/cjs/next/testing/element-data.js.map +1 -1
- package/dist/cjs/next/testing/index.js +0 -2
- package/dist/cjs/next/testing/index.js.map +1 -1
- package/dist/cjs/next/testing/page-rendering.js +3 -3
- package/dist/cjs/next/testing/page-rendering.js.map +1 -1
- package/dist/cjs/prop-controllers/descriptors.js.map +1 -1
- package/dist/cjs/prop-controllers/instances.js.map +1 -1
- package/dist/cjs/prop-controllers/serialization.js +355 -0
- package/dist/cjs/prop-controllers/serialization.js.map +1 -0
- package/dist/cjs/runtimes/react/components/Document.js +2 -2
- package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
- package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
- package/dist/cjs/runtimes/react/components/Element.js +2 -2
- package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js +2 -2
- package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js +55 -0
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -0
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +33 -0
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +1 -0
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +5 -6
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +13 -3
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +3 -2
- package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls.js +2 -2
- package/dist/cjs/runtimes/react/controls.js.map +1 -1
- package/dist/cjs/runtimes/react/element-imperative-handle.js +1 -1
- package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js +55 -0
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-breakpoints.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-breakpoints.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-component.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-component.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js +39 -0
- package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-dispatch.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-document.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-document.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-element-id.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-element-id.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js +33 -0
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
- package/dist/cjs/runtimes/react/host-api-client.js +3 -4
- package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
- package/dist/cjs/runtimes/react/index.js +3 -3
- package/dist/cjs/runtimes/react/index.js.map +1 -1
- package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js +59 -0
- package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
- package/dist/cjs/runtimes/react/poll-box-model.js +1 -1
- package/dist/cjs/runtimes/react/poll-box-model.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +3 -3
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/runtime-core.js +2 -4
- package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/testing/react-runtime.js +3 -2
- package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/cjs/runtimes/react/utils/can-accept-ref.js.map +1 -1
- package/dist/cjs/runtimes/react/utils/google-fonts-url.js +49 -0
- package/dist/cjs/runtimes/react/utils/google-fonts-url.js.map +1 -0
- package/dist/cjs/state/actions/internal/read-only-actions.js +25 -17
- package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/cjs/state/actions/internal/read-write-actions.js +7 -1
- package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/cjs/state/actions/internal.js +205 -0
- package/dist/cjs/state/actions/internal.js.map +1 -0
- package/dist/cjs/state/builder-api/actions.js +8 -11
- package/dist/cjs/state/builder-api/actions.js.map +1 -1
- package/dist/cjs/state/builder-api/api.js +17 -0
- package/dist/cjs/state/builder-api/api.js.map +1 -0
- package/dist/cjs/state/builder-api/navigation-listener.js +110 -0
- package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -0
- package/dist/cjs/state/host-api.js.map +1 -1
- package/dist/cjs/state/makeswift-api-client.js +20 -34
- package/dist/cjs/state/makeswift-api-client.js.map +1 -1
- package/dist/cjs/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/builder-api/index.js +11 -2
- package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
- package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
- package/dist/cjs/state/middleware/read-write/index.js +40 -0
- package/dist/cjs/state/middleware/read-write/index.js.map +1 -0
- package/dist/cjs/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/cjs/state/mixins/breakpoint-watch.js +72 -0
- package/dist/cjs/state/mixins/breakpoint-watch.js.map +1 -0
- package/dist/cjs/state/modules/api-resources.js +4 -7
- package/dist/cjs/state/modules/api-resources.js.map +1 -1
- package/dist/cjs/state/modules/box-models.js +127 -0
- package/dist/cjs/state/modules/box-models.js.map +1 -0
- package/dist/cjs/state/modules/breakpoints.js +1 -2
- package/dist/cjs/state/modules/breakpoints.js.map +1 -1
- package/dist/cjs/state/modules/builder-edit-mode.js +1 -2
- package/dist/cjs/state/modules/builder-edit-mode.js.map +1 -1
- package/dist/cjs/state/modules/components-meta.js +2 -3
- package/dist/cjs/state/modules/components-meta.js.map +1 -1
- package/dist/cjs/state/modules/element-imperative-handles.js +60 -0
- package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
- package/dist/cjs/state/modules/element-trees.js +3 -5
- package/dist/cjs/state/modules/element-trees.js.map +1 -1
- package/dist/cjs/state/modules/is-in-builder.js +1 -2
- package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
- package/dist/cjs/state/modules/is-preview.js +47 -0
- package/dist/cjs/state/modules/is-preview.js.map +1 -0
- package/dist/cjs/state/modules/locale.js +1 -4
- package/dist/cjs/state/modules/locale.js.map +1 -1
- package/dist/cjs/state/modules/localized-resources-map.js +2 -4
- package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
- package/dist/cjs/state/modules/pointer.js +47 -0
- package/dist/cjs/state/modules/pointer.js.map +1 -0
- package/dist/cjs/state/modules/prop-controllers.js +2 -3
- package/dist/cjs/state/modules/prop-controllers.js.map +1 -1
- package/dist/cjs/state/modules/react-components.js +2 -3
- package/dist/cjs/state/modules/react-components.js.map +1 -1
- package/dist/cjs/state/modules/read-only-documents.js +2 -3
- package/dist/cjs/state/modules/read-only-documents.js.map +1 -1
- package/dist/cjs/state/modules/read-write/box-models.js +17 -2
- package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
- package/dist/cjs/state/modules/read-write-documents.js +98 -0
- package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
- package/dist/cjs/state/modules/site-version.js +0 -3
- package/dist/cjs/state/modules/site-version.js.map +1 -1
- package/dist/cjs/state/react-builder-preview.js +508 -18
- package/dist/cjs/state/react-builder-preview.js.map +1 -1
- package/dist/cjs/state/react-page.js +250 -6
- package/dist/cjs/state/react-page.js.map +1 -1
- package/dist/cjs/state/read-only-state.js +23 -1
- package/dist/cjs/state/read-only-state.js.map +1 -1
- package/dist/cjs/state/read-write-state.js +9 -2
- package/dist/cjs/state/read-write-state.js.map +1 -1
- package/dist/cjs/state/shared-api.js.map +1 -1
- package/dist/cjs/state/store.js +219 -0
- package/dist/cjs/state/store.js.map +1 -0
- package/dist/cjs/state/translations/get.js +2 -2
- package/dist/cjs/state/translations/get.js.map +1 -1
- package/dist/cjs/state/translations/merge.js +2 -2
- package/dist/cjs/state/translations/merge.js.map +1 -1
- package/dist/cjs/state/unified-state.js +17 -0
- package/dist/cjs/state/unified-state.js.map +1 -0
- package/dist/cjs/translations/index.js +32 -0
- package/dist/cjs/translations/index.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js +4 -2
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/cjs/utils/deferred.js +39 -0
- package/dist/cjs/utils/deferred.js.map +1 -0
- package/dist/cjs/utils/ref-counted-map.js +120 -0
- package/dist/cjs/utils/ref-counted-map.js.map +1 -0
- package/dist/esm/api/client.js +2 -13
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api/react.js +223 -0
- package/dist/esm/api/react.js.map +1 -0
- package/dist/esm/api-handler/handlers/element-tree.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -1
- package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -1
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js +38 -0
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js.map +1 -0
- package/dist/esm/builder/host-to-builder-actions.js +4 -4
- package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
- package/dist/esm/builder/index.js +1 -1
- package/dist/esm/builder/index.js.map +1 -1
- package/dist/esm/builder/serialization.js +59 -0
- package/dist/esm/builder/serialization.js.map +1 -0
- package/dist/esm/client/index.js +5 -5
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/components/builtin/Box/Box.js +1 -1
- package/dist/esm/components/builtin/Box/Box.js.map +1 -1
- package/dist/esm/components/builtin/Form/Form.js +1 -1
- package/dist/esm/components/builtin/Form/Form.js.map +1 -1
- package/dist/esm/components/hooks/useTableFormFieldRefs.js +1 -1
- package/dist/esm/components/hooks/useTableFormFieldRefs.js.map +1 -1
- package/dist/esm/controls/serialization/base/index.js +78 -0
- package/dist/esm/controls/serialization/base/index.js.map +1 -0
- package/dist/esm/controls/serialization/base/visitor.js +39 -0
- package/dist/esm/controls/serialization/base/visitor.js.map +1 -0
- package/dist/esm/controls/serialization/index.js +30 -0
- package/dist/esm/controls/serialization/index.js.map +1 -0
- package/dist/esm/controls/serialization/message-port/function-serialization.js +52 -0
- package/dist/esm/controls/serialization/message-port/function-serialization.js.map +1 -0
- package/dist/esm/controls/serialization/message-port/index.js +3 -0
- package/dist/esm/controls/serialization/message-port/index.js.map +1 -0
- package/dist/esm/controls/serialization/message-port/visitor.js +24 -0
- package/dist/esm/controls/serialization/message-port/visitor.js.map +1 -0
- package/dist/esm/next/api-handler/config/app-router.js +10 -1
- package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
- package/dist/esm/next/api-handler/config/pages-router.js +1 -1
- package/dist/esm/next/api-handler/config/pages-router.js.map +1 -1
- package/dist/esm/next/components/framework-provider/index.js +5 -2
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +2 -1
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
- package/dist/esm/next/components/tests/makeswift-component/fixtures.js +2 -1
- package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -1
- package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +3 -2
- package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
- package/dist/esm/next/fetch.js +6 -0
- package/dist/esm/next/fetch.js.map +1 -0
- package/dist/esm/next/runtime.js +11 -0
- package/dist/esm/next/runtime.js.map +1 -0
- package/dist/esm/next/testing/element-data.js +1 -1
- package/dist/esm/next/testing/element-data.js.map +1 -1
- package/dist/esm/next/testing/index.js +0 -1
- package/dist/esm/next/testing/index.js.map +1 -1
- package/dist/esm/next/testing/page-rendering.js +3 -3
- package/dist/esm/next/testing/page-rendering.js.map +1 -1
- package/dist/esm/prop-controllers/descriptors.js.map +1 -1
- package/dist/esm/prop-controllers/instances.js.map +1 -1
- package/dist/esm/prop-controllers/serialization.js +338 -0
- package/dist/esm/prop-controllers/serialization.js.map +1 -0
- package/dist/esm/runtimes/react/components/Document.js +1 -1
- package/dist/esm/runtimes/react/components/Document.js.map +1 -1
- package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
- package/dist/esm/runtimes/react/components/Element.js +1 -3
- package/dist/esm/runtimes/react/components/Element.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/esm/runtimes/react/components/GoogleFontLink.js +35 -0
- package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -0
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js +1 -1
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js +9 -0
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +4 -5
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +14 -2
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +3 -2
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +2 -2
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/esm/runtimes/react/controls.js +2 -2
- package/dist/esm/runtimes/react/controls.js.map +1 -1
- package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
- package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-async-effect.js +31 -0
- package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-breakpoints.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-builder-edit-mode.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-component.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-component.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js +15 -0
- package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-document.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-document.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-element-id.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-element-id.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-is-in-builder.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
- package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +2 -2
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -1
- package/dist/esm/runtimes/react/host-api-client.js +2 -3
- package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
- package/dist/esm/runtimes/react/index.js +2 -2
- package/dist/esm/runtimes/react/index.js.map +1 -1
- package/dist/esm/runtimes/react/lib/resolved-style-to-css.js +38 -0
- package/dist/esm/runtimes/react/lib/resolved-style-to-css.js.map +1 -0
- package/dist/esm/runtimes/react/poll-box-model.js +1 -1
- package/dist/esm/runtimes/react/poll-box-model.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +1 -4
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/runtime-core.js +5 -3
- package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/testing/react-runtime.js +3 -2
- package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/esm/runtimes/react/utils/can-accept-ref.js.map +1 -1
- package/dist/esm/runtimes/react/utils/google-fonts-url.js +23 -0
- package/dist/esm/runtimes/react/utils/google-fonts-url.js.map +1 -0
- package/dist/esm/state/actions/internal/read-only-actions.js +21 -14
- package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/esm/state/actions/internal/read-write-actions.js +6 -1
- package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/esm/state/actions/internal.js +162 -0
- package/dist/esm/state/actions/internal.js.map +1 -0
- package/dist/esm/state/builder-api/actions.js +7 -8
- package/dist/esm/state/builder-api/actions.js.map +1 -1
- package/dist/esm/state/builder-api/api.js +1 -0
- package/dist/esm/state/builder-api/api.js.map +1 -0
- package/dist/esm/state/builder-api/navigation-listener.js +86 -0
- package/dist/esm/state/builder-api/navigation-listener.js.map +1 -0
- package/dist/esm/state/host-api.js.map +1 -1
- package/dist/esm/state/makeswift-api-client.js +19 -33
- package/dist/esm/state/makeswift-api-client.js.map +1 -1
- package/dist/esm/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/esm/state/middleware/read-write/builder-api/index.js +11 -2
- package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +3 -0
- package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -1
- package/dist/esm/state/middleware/read-write/index.js +16 -0
- package/dist/esm/state/middleware/read-write/index.js.map +1 -0
- package/dist/esm/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/esm/state/mixins/breakpoint-watch.js +48 -0
- package/dist/esm/state/mixins/breakpoint-watch.js.map +1 -0
- package/dist/esm/state/modules/api-resources.js +5 -8
- package/dist/esm/state/modules/api-resources.js.map +1 -1
- package/dist/esm/state/modules/box-models.js +98 -0
- package/dist/esm/state/modules/box-models.js.map +1 -0
- package/dist/esm/state/modules/breakpoints.js +2 -3
- package/dist/esm/state/modules/breakpoints.js.map +1 -1
- package/dist/esm/state/modules/builder-edit-mode.js +2 -3
- package/dist/esm/state/modules/builder-edit-mode.js.map +1 -1
- package/dist/esm/state/modules/components-meta.js +3 -4
- package/dist/esm/state/modules/components-meta.js.map +1 -1
- package/dist/esm/state/modules/element-imperative-handles.js +35 -0
- package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
- package/dist/esm/state/modules/element-trees.js +4 -6
- package/dist/esm/state/modules/element-trees.js.map +1 -1
- package/dist/esm/state/modules/is-in-builder.js +2 -3
- package/dist/esm/state/modules/is-in-builder.js.map +1 -1
- package/dist/esm/state/modules/is-preview.js +21 -0
- package/dist/esm/state/modules/is-preview.js.map +1 -0
- package/dist/esm/state/modules/locale.js +1 -4
- package/dist/esm/state/modules/locale.js.map +1 -1
- package/dist/esm/state/modules/localized-resources-map.js +3 -5
- package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
- package/dist/esm/state/modules/pointer.js +22 -0
- package/dist/esm/state/modules/pointer.js.map +1 -0
- package/dist/esm/state/modules/prop-controllers.js +3 -4
- package/dist/esm/state/modules/prop-controllers.js.map +1 -1
- package/dist/esm/state/modules/react-components.js +3 -4
- package/dist/esm/state/modules/react-components.js.map +1 -1
- package/dist/esm/state/modules/read-only-documents.js +6 -4
- package/dist/esm/state/modules/read-only-documents.js.map +1 -1
- package/dist/esm/state/modules/read-write/box-models.js +16 -2
- package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
- package/dist/esm/state/modules/read-write-documents.js +60 -0
- package/dist/esm/state/modules/read-write-documents.js.map +1 -0
- package/dist/esm/state/modules/site-version.js +0 -3
- package/dist/esm/state/modules/site-version.js.map +1 -1
- package/dist/esm/state/react-builder-preview.js +500 -15
- package/dist/esm/state/react-builder-preview.js.map +1 -1
- package/dist/esm/state/react-page.js +240 -7
- package/dist/esm/state/react-page.js.map +1 -1
- package/dist/esm/state/read-only-state.js +20 -1
- package/dist/esm/state/read-only-state.js.map +1 -1
- package/dist/esm/state/read-write-state.js +7 -1
- package/dist/esm/state/read-write-state.js.map +1 -1
- package/dist/esm/state/shared-api.js.map +1 -1
- package/dist/esm/state/store.js +188 -0
- package/dist/esm/state/store.js.map +1 -0
- package/dist/esm/state/translations/get.js +1 -1
- package/dist/esm/state/translations/get.js.map +1 -1
- package/dist/esm/state/translations/merge.js +1 -1
- package/dist/esm/state/translations/merge.js.map +1 -1
- package/dist/esm/state/unified-state.js +1 -0
- package/dist/esm/state/unified-state.js.map +1 -0
- package/dist/esm/translations/index.js +7 -0
- package/dist/esm/translations/index.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js +4 -2
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/utils/deferred.js +15 -0
- package/dist/esm/utils/deferred.js.map +1 -0
- package/dist/esm/utils/ref-counted-map.js +96 -0
- package/dist/esm/utils/ref-counted-map.js.map +1 -0
- package/dist/types/api/client.d.ts +2 -5
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/react.d.ts +82 -0
- package/dist/types/api/react.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/element-tree.d.ts +1 -1
- package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/merge-translated-data.d.ts +1 -1
- package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/translatable-data.d.ts +1 -1
- package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +201 -0
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
- package/dist/types/builder/host-to-builder-actions.d.ts +2 -2
- package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
- package/dist/types/builder/index.d.ts +2 -2
- package/dist/types/builder/index.d.ts.map +1 -1
- package/dist/types/builder/serialization.d.ts +23 -0
- package/dist/types/builder/serialization.d.ts.map +1 -0
- package/dist/types/builder/serialization.test.d.ts +2 -0
- package/dist/types/builder/serialization.test.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +2 -2
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/tests/client.get-component-snapshots.test.d.ts +2 -0
- package/dist/types/client/tests/client.get-component-snapshots.test.d.ts.map +1 -0
- package/dist/types/client/tests/client.get-fonts.test.d.ts +2 -0
- package/dist/types/client/tests/client.get-fonts.test.d.ts.map +1 -0
- package/dist/types/client/tests/client.introspect-many.test.d.ts +2 -0
- package/dist/types/client/tests/client.introspect-many.test.d.ts.map +1 -0
- package/dist/types/components/builtin/Box/Box.d.ts +1 -1
- package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
- package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts +3 -0
- package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
- package/dist/types/controls/serialization/base/index.d.ts +10 -0
- package/dist/types/controls/serialization/base/index.d.ts.map +1 -0
- package/dist/types/controls/serialization/base/visitor.d.ts +7 -0
- package/dist/types/controls/serialization/base/visitor.d.ts.map +1 -0
- package/dist/types/controls/serialization/index.d.ts +10 -0
- package/dist/types/controls/serialization/index.d.ts.map +1 -0
- package/dist/types/controls/serialization/message-port/function-serialization.d.ts +16 -0
- package/dist/types/controls/serialization/message-port/function-serialization.d.ts.map +1 -0
- package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts +2 -0
- package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts.map +1 -0
- package/dist/types/controls/serialization/message-port/index.d.ts +3 -0
- package/dist/types/controls/serialization/message-port/index.d.ts.map +1 -0
- package/dist/types/controls/serialization/message-port/visitor.d.ts +7 -0
- package/dist/types/controls/serialization/message-port/visitor.d.ts.map +1 -0
- package/dist/types/locale.d.ts +1 -1
- package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
- package/dist/types/next/api-handler/config/pages-router.test.d.ts +2 -0
- package/dist/types/next/api-handler/config/pages-router.test.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/code-control.test.d.ts +2 -0
- package/dist/types/next/components/tests/controls/code-control.test.d.ts.map +1 -0
- package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
- package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +3 -3
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
- package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
- package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +1 -1
- package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -1
- package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts +1 -1
- package/dist/types/next/components/tests/prop-controllers/page-prop-controller.d.ts.map +1 -1
- package/dist/types/next/fetch.d.ts +3 -0
- package/dist/types/next/fetch.d.ts.map +1 -0
- package/dist/types/next/runtime.d.ts +10 -0
- package/dist/types/next/runtime.d.ts.map +1 -0
- package/dist/types/next/testing/element-data.d.ts +1 -1
- package/dist/types/next/testing/element-data.d.ts.map +1 -1
- package/dist/types/next/testing/index.d.ts +0 -1
- package/dist/types/next/testing/index.d.ts.map +1 -1
- package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/prop-controllers/instances.d.ts +1 -1
- package/dist/types/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/prop-controllers/serialization.d.ts +228 -0
- package/dist/types/prop-controllers/serialization.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/Document.d.ts +1 -1
- package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
- package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/Element.d.ts +1 -1
- package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/GoogleFontLink.d.ts +14 -0
- package/dist/types/runtimes/react/components/GoogleFontLink.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +7 -0
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +1 -1
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +4 -2
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/Page.d.ts +1 -1
- package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls.d.ts +2 -2
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
- package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-component.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-component.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-dispatch.d.ts +3 -3
- package/dist/types/runtimes/react/hooks/use-dispatch.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-document.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-document.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-register-document.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-register-document.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-selector.d.ts +3 -3
- package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-store.d.ts +4 -4
- package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-universal-dispatch.d.ts.map +1 -1
- package/dist/types/runtimes/react/host-api-client.d.ts +1 -1
- package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts +1 -1
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts +4 -0
- package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts.map +1 -0
- package/dist/types/runtimes/react/poll-box-model.d.ts +1 -1
- package/dist/types/runtimes/react/poll-box-model.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/runtime-core.d.ts +1 -2
- package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/testing/react-runtime.d.ts +4 -1
- package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
- package/dist/types/runtimes/react/utils/can-accept-ref.d.ts +1 -1
- package/dist/types/runtimes/react/utils/can-accept-ref.d.ts.map +1 -1
- package/dist/types/runtimes/react/utils/google-fonts-url.d.ts +6 -0
- package/dist/types/runtimes/react/utils/google-fonts-url.d.ts.map +1 -0
- package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts +5 -0
- package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts.map +1 -0
- package/dist/types/state/__tests__/fixtures/translatable-content-sample.d.ts +3 -0
- package/dist/types/state/__tests__/fixtures/translatable-content-sample.d.ts.map +1 -0
- package/dist/types/state/__tests__/get-translatable-content.test.d.ts +2 -0
- package/dist/types/state/__tests__/get-translatable-content.test.d.ts.map +1 -0
- package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
- package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts +2 -0
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts.map +1 -0
- package/dist/types/state/__tests__/test-store.d.ts +31 -0
- package/dist/types/state/__tests__/test-store.d.ts.map +1 -0
- package/dist/types/state/actions/index.d.ts +5 -8
- package/dist/types/state/actions/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/index.d.ts +4 -2
- package/dist/types/state/actions/internal/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-only-actions.d.ts +25 -13
- package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-write-actions.d.ts +6 -1
- package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
- package/dist/types/state/actions/internal.d.ts +181 -0
- package/dist/types/state/actions/internal.d.ts.map +1 -0
- package/dist/types/state/builder-api/actions.d.ts +14 -14
- package/dist/types/state/builder-api/actions.d.ts.map +1 -1
- package/dist/types/state/builder-api/api.d.ts +9 -0
- package/dist/types/state/builder-api/api.d.ts.map +1 -0
- package/dist/types/state/builder-api/navigation-listener.d.ts +3 -0
- package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -0
- package/dist/types/state/host-api.d.ts +1 -1
- package/dist/types/state/host-api.d.ts.map +1 -1
- package/dist/types/state/makeswift-api-client.d.ts +2 -11
- package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts +5 -0
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -1
- package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +1 -1
- package/dist/types/state/middleware/read-write/index.d.ts +5 -0
- package/dist/types/state/middleware/read-write/index.d.ts.map +1 -0
- package/dist/types/state/middleware/{prop-controller-handles.d.ts → read-write/prop-controller-handles.d.ts} +1 -1
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -0
- package/dist/types/state/mixins/breakpoint-watch.d.ts +11 -0
- package/dist/types/state/mixins/breakpoint-watch.d.ts.map +1 -0
- package/dist/types/state/modules/api-resources.d.ts.map +1 -1
- package/dist/types/state/modules/box-models.d.ts +23 -0
- package/dist/types/state/modules/box-models.d.ts.map +1 -0
- package/dist/types/state/modules/breakpoints.d.ts.map +1 -1
- package/dist/types/state/modules/builder-edit-mode.d.ts.map +1 -1
- package/dist/types/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
- package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
- package/dist/types/state/modules/element-trees.d.ts.map +1 -1
- package/dist/types/state/modules/is-in-builder.d.ts.map +1 -1
- package/dist/types/state/modules/is-preview.d.ts +6 -0
- package/dist/types/state/modules/is-preview.d.ts.map +1 -0
- package/dist/types/state/modules/locale.d.ts.map +1 -1
- package/dist/types/state/modules/localized-resources-map.d.ts.map +1 -1
- package/dist/types/state/modules/pointer.d.ts +12 -0
- package/dist/types/state/modules/pointer.d.ts.map +1 -0
- package/dist/types/state/modules/prop-controllers.d.ts.map +1 -1
- package/dist/types/state/modules/react-components.d.ts.map +1 -1
- package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
- package/dist/types/state/modules/read-write/box-models.d.ts +12 -9
- package/dist/types/state/modules/read-write/box-models.d.ts.map +1 -1
- package/dist/types/state/modules/read-write-documents.d.ts +14 -0
- package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
- package/dist/types/state/modules/site-version.d.ts.map +1 -1
- package/dist/types/state/react-builder-preview.d.ts +93 -26
- package/dist/types/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/state/react-page.d.ts +136 -20
- package/dist/types/state/react-page.d.ts.map +1 -1
- package/dist/types/state/read-only-state.d.ts +10 -1
- package/dist/types/state/read-only-state.d.ts.map +1 -1
- package/dist/types/state/read-write-state.d.ts +12 -6
- package/dist/types/state/read-write-state.d.ts.map +1 -1
- package/dist/types/state/shared-api.d.ts.map +1 -1
- package/dist/types/state/store.d.ts +86 -0
- package/dist/types/state/store.d.ts.map +1 -0
- package/dist/types/state/translations/get.d.ts +1 -1
- package/dist/types/state/translations/get.d.ts.map +1 -1
- package/dist/types/state/translations/merge.d.ts +1 -1
- package/dist/types/state/translations/merge.d.ts.map +1 -1
- package/dist/types/state/unified-state.d.ts +9 -0
- package/dist/types/state/unified-state.d.ts.map +1 -0
- package/dist/types/translations/index.d.ts +6 -0
- package/dist/types/translations/index.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +1 -1
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/dist/types/utils/__tests__/ref-counted-map.test.d.ts +2 -0
- package/dist/types/utils/__tests__/ref-counted-map.test.d.ts.map +1 -0
- package/dist/types/utils/deferred.d.ts +7 -0
- package/dist/types/utils/deferred.d.ts.map +1 -0
- package/dist/types/utils/ref-counted-map.d.ts +32 -0
- package/dist/types/utils/ref-counted-map.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
- package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
- package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts.map +0 -1
package/dist/cjs/api/client.js
CHANGED
|
@@ -33,9 +33,6 @@ __export(client_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(client_exports);
|
|
35
35
|
var MakeswiftApiClient = __toESM(require("../state/makeswift-api-client"));
|
|
36
|
-
var import_shared_api = require("../state/shared-api");
|
|
37
|
-
var import_read_only_actions = require("../state/actions/internal/read-only-actions");
|
|
38
|
-
var import_read_only_actions2 = require("../state/actions/internal/read-only-actions");
|
|
39
36
|
var import_types = require("./types");
|
|
40
37
|
var import_client = require("./graphql/client");
|
|
41
38
|
var import_documents = require("./graphql/documents");
|
|
@@ -55,20 +52,12 @@ class MakeswiftHostApiClient {
|
|
|
55
52
|
constructor({
|
|
56
53
|
uri,
|
|
57
54
|
fetch,
|
|
58
|
-
|
|
59
|
-
locale,
|
|
60
|
-
siteVersion
|
|
55
|
+
preloadedState
|
|
61
56
|
}) {
|
|
62
57
|
this.graphqlClient = new import_client.GraphQLClient(uri);
|
|
63
|
-
this.makeswiftApiClient = MakeswiftApiClient.configureStore({
|
|
64
|
-
serializedState: cacheData
|
|
65
|
-
});
|
|
58
|
+
this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState });
|
|
66
59
|
this.fetch = fetch;
|
|
67
60
|
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
68
|
-
this.makeswiftApiClient.dispatch(
|
|
69
|
-
locale != null ? (0, import_shared_api.setLocale)(new Intl.Locale(locale)) : (0, import_read_only_actions.resetLocaleState)()
|
|
70
|
-
);
|
|
71
|
-
this.makeswiftApiClient.dispatch((0, import_read_only_actions2.setSiteVersion)(siteVersion));
|
|
72
61
|
}
|
|
73
62
|
readSwatch(swatchId) {
|
|
74
63
|
return MakeswiftApiClient.getAPIResource(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport { setLocale } from '../state/shared-api'\nimport { resetLocaleState } from '../state/actions/internal/read-only-actions'\nimport { setSiteVersion } from '../state/actions/internal/read-only-actions'\n\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\nimport { SiteVersion } from './site-version'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n siteVersion,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n siteVersion: SiteVersion | null\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n\n this.makeswiftApiClient.dispatch(\n locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState(),\n )\n\n this.makeswiftApiClient.dispatch(setSiteVersion(siteVersion))\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoC;AACpC,wBAA0B;AAC1B,+BAAiC;AACjC,IAAAA,4BAA+B;AAE/B,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AASnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,IACnB,CAAC;AACD,SAAK,QAAQ;AACb,SAAK,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AAK,KAAK;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_read_only_actions"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\n\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n preloadedState,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n preloadedState: Partial<MakeswiftApiClient.State>\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoC;AAEpC,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AAQnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe,EAAE,eAAe,CAAC;AAC9E,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAAA,EAC3C;AAAA,EAEA,WAAW,UAAiC;AAC1C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,6BAAgB,QAAQ,UAAU,KAAK,KAAK;AAAA,IAClF;AAAA,EACF;AAAA,EAEA,cAAc,UAA6D;AACzE,WAAO,KAAK,gBAAgB,6BAAgB,QAAQ;AAAA,MAClD,IAAI;AAA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B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var react_exports = {};
|
|
30
|
+
__export(react_exports, {
|
|
31
|
+
CacheData: () => CacheData,
|
|
32
|
+
MakeswiftHostApiClient: () => MakeswiftHostApiClient
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(react_exports);
|
|
35
|
+
var MakeswiftApiClient = __toESM(require("../state/makeswift-api-client"));
|
|
36
|
+
var import_types = require("./types");
|
|
37
|
+
var import_client = require("./graphql/client");
|
|
38
|
+
var import_documents = require("./graphql/documents");
|
|
39
|
+
const CacheData = {
|
|
40
|
+
empty() {
|
|
41
|
+
return {
|
|
42
|
+
apiResources: {},
|
|
43
|
+
localizedResourcesMap: {}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
class MakeswiftHostApiClient {
|
|
48
|
+
graphqlClient;
|
|
49
|
+
makeswiftApiClient;
|
|
50
|
+
subscribe;
|
|
51
|
+
fetch;
|
|
52
|
+
constructor({
|
|
53
|
+
uri,
|
|
54
|
+
fetch,
|
|
55
|
+
cacheData,
|
|
56
|
+
locale
|
|
57
|
+
}) {
|
|
58
|
+
this.graphqlClient = new import_client.GraphQLClient(uri);
|
|
59
|
+
this.makeswiftApiClient = MakeswiftApiClient.configureStore({
|
|
60
|
+
serializedState: cacheData,
|
|
61
|
+
defaultLocale: locale
|
|
62
|
+
});
|
|
63
|
+
this.fetch = fetch;
|
|
64
|
+
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
65
|
+
}
|
|
66
|
+
readSwatch(swatchId) {
|
|
67
|
+
return MakeswiftApiClient.getAPIResource(
|
|
68
|
+
this.makeswiftApiClient.getState(),
|
|
69
|
+
import_types.APIResourceType.Swatch,
|
|
70
|
+
swatchId
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
async fetchSwatch(swatchId) {
|
|
74
|
+
return await this.makeswiftApiClient.dispatch(
|
|
75
|
+
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Swatch, swatchId, this.fetch)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
resolveSwatch(swatchId) {
|
|
79
|
+
return this.resolveResource(import_types.APIResourceType.Swatch, {
|
|
80
|
+
id: swatchId,
|
|
81
|
+
read: (id) => this.readSwatch(id),
|
|
82
|
+
fetch: (id) => this.fetchSwatch(id)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
readFile(fileId) {
|
|
86
|
+
return MakeswiftApiClient.getAPIResource(
|
|
87
|
+
this.makeswiftApiClient.getState(),
|
|
88
|
+
import_types.APIResourceType.File,
|
|
89
|
+
fileId
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
async fetchFile(fileId) {
|
|
93
|
+
return await this.makeswiftApiClient.dispatch(
|
|
94
|
+
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.File, fileId, this.fetch)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
resolveFile(fileId) {
|
|
98
|
+
return this.resolveResource(import_types.APIResourceType.File, {
|
|
99
|
+
id: fileId,
|
|
100
|
+
read: (id) => this.readFile(id),
|
|
101
|
+
fetch: (id) => this.fetchFile(id)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
readTypography(typographyId) {
|
|
105
|
+
return MakeswiftApiClient.getAPIResource(
|
|
106
|
+
this.makeswiftApiClient.getState(),
|
|
107
|
+
import_types.APIResourceType.Typography,
|
|
108
|
+
typographyId
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
async fetchTypography(typographyId) {
|
|
112
|
+
return await this.makeswiftApiClient.dispatch(
|
|
113
|
+
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Typography, typographyId, this.fetch)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
resolveTypography(typographyId) {
|
|
117
|
+
return this.resolveResource(import_types.APIResourceType.Typography, {
|
|
118
|
+
id: typographyId,
|
|
119
|
+
read: (id) => this.readTypography(id),
|
|
120
|
+
fetch: (id) => this.fetchTypography(id)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
readGlobalElement(globalElementId) {
|
|
124
|
+
return MakeswiftApiClient.getAPIResource(
|
|
125
|
+
this.makeswiftApiClient.getState(),
|
|
126
|
+
import_types.APIResourceType.GlobalElement,
|
|
127
|
+
globalElementId
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
async fetchGlobalElement(globalElementId) {
|
|
131
|
+
return await this.makeswiftApiClient.dispatch(
|
|
132
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
133
|
+
import_types.APIResourceType.GlobalElement,
|
|
134
|
+
globalElementId,
|
|
135
|
+
this.fetch
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
readLocalizedGlobalElement({
|
|
140
|
+
globalElementId,
|
|
141
|
+
locale
|
|
142
|
+
}) {
|
|
143
|
+
return MakeswiftApiClient.getAPIResource(
|
|
144
|
+
this.makeswiftApiClient.getState(),
|
|
145
|
+
import_types.APIResourceType.LocalizedGlobalElement,
|
|
146
|
+
globalElementId,
|
|
147
|
+
locale
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
async fetchLocalizedGlobalElement({
|
|
151
|
+
globalElementId,
|
|
152
|
+
locale
|
|
153
|
+
}) {
|
|
154
|
+
return await this.makeswiftApiClient.dispatch(
|
|
155
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
156
|
+
import_types.APIResourceType.LocalizedGlobalElement,
|
|
157
|
+
globalElementId,
|
|
158
|
+
this.fetch,
|
|
159
|
+
locale
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
readPagePathnameSlice({
|
|
164
|
+
pageId,
|
|
165
|
+
locale
|
|
166
|
+
}) {
|
|
167
|
+
return MakeswiftApiClient.getAPIResource(
|
|
168
|
+
this.makeswiftApiClient.getState(),
|
|
169
|
+
import_types.APIResourceType.PagePathnameSlice,
|
|
170
|
+
pageId,
|
|
171
|
+
locale
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
async fetchPagePathnameSlice({
|
|
175
|
+
pageId,
|
|
176
|
+
locale
|
|
177
|
+
}) {
|
|
178
|
+
return await this.makeswiftApiClient.dispatch(
|
|
179
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
180
|
+
import_types.APIResourceType.PagePathnameSlice,
|
|
181
|
+
pageId,
|
|
182
|
+
this.fetch,
|
|
183
|
+
locale
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
resolvePagePathnameSlice({
|
|
188
|
+
pageId,
|
|
189
|
+
locale
|
|
190
|
+
}) {
|
|
191
|
+
return this.resolveResource(import_types.APIResourceType.PagePathnameSlice, {
|
|
192
|
+
id: pageId,
|
|
193
|
+
read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
|
|
194
|
+
fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
resolveResource(type, {
|
|
198
|
+
id,
|
|
199
|
+
read,
|
|
200
|
+
fetch
|
|
201
|
+
}) {
|
|
202
|
+
const _read = () => id != null ? read(id) : null;
|
|
203
|
+
let lastValue = null;
|
|
204
|
+
return {
|
|
205
|
+
name: `${type}:${id}`,
|
|
206
|
+
readStable: () => lastValue = _read(),
|
|
207
|
+
subscribe: (onUpdate) => this.subscribe(() => {
|
|
208
|
+
if (_read() !== lastValue)
|
|
209
|
+
onUpdate();
|
|
210
|
+
}),
|
|
211
|
+
fetch: async () => id != null ? fetch(id) : null
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
readTable(tableId) {
|
|
215
|
+
return MakeswiftApiClient.getAPIResource(
|
|
216
|
+
this.makeswiftApiClient.getState(),
|
|
217
|
+
import_types.APIResourceType.Table,
|
|
218
|
+
tableId
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
async fetchTable(tableId) {
|
|
222
|
+
return await this.makeswiftApiClient.dispatch(
|
|
223
|
+
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Table, tableId, this.fetch)
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
async createTableRecord(tableId, columns) {
|
|
227
|
+
await this.graphqlClient.request(import_documents.CreateTableRecordMutation, { input: { data: { tableId, columns } } });
|
|
228
|
+
}
|
|
229
|
+
readSite(siteId) {
|
|
230
|
+
return MakeswiftApiClient.getAPIResource(
|
|
231
|
+
this.makeswiftApiClient.getState(),
|
|
232
|
+
import_types.APIResourceType.Site,
|
|
233
|
+
siteId
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
readPage(pageId) {
|
|
237
|
+
return MakeswiftApiClient.getAPIResource(
|
|
238
|
+
this.makeswiftApiClient.getState(),
|
|
239
|
+
import_types.APIResourceType.Page,
|
|
240
|
+
pageId
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
readSnippet(snippetId) {
|
|
244
|
+
return MakeswiftApiClient.getAPIResource(
|
|
245
|
+
this.makeswiftApiClient.getState(),
|
|
246
|
+
import_types.APIResourceType.Snippet,
|
|
247
|
+
snippetId
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
252
|
+
0 && (module.exports = {
|
|
253
|
+
CacheData,
|
|
254
|
+
MakeswiftHostApiClient
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/react.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n defaultLocale: locale,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\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;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,MACjB,eAAe;AAAA,IACjB,CAAC;AACD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAAA,EAC3C;AAAA,EAEA,WAAW,UAAiC;AAC1C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO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AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { ReactRuntimeCore } from '../../runtimes/react/react-runtime-core'\nimport { type Element } from '../../state/
|
|
1
|
+
{"version":3,"sources":["../../../../src/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { ReactRuntimeCore } from '../../runtimes/react/react-runtime-core'\nimport { type Element } from '../../state/react-page'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\n\nexport async function elementTreeHandler(\n req: ApiRequest,\n { runtime }: { runtime: ReactRuntimeCore },\n): Promise<ApiResponse<{ elementTree: Element } | ErrorResponseBody>> {\n const body = await req.json()\n const { elementTree, replacementContext } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n if (replacementContext == null) {\n return ApiResponse.json({ message: 'replacementContext must be defined' }, { status: 400 })\n }\n\n const generatedElementTree = runtime.copyElementTree(elementTree, replacementContext)\n return ApiResponse.json({ elementTree: generatedElementTree })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AAErE,eAAsB,mBACpB,KACA,EAAE,QAAQ,GAC0D;AACpE,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAE5C,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI,sBAAsB,MAAM;AAC9B,WAAO,oCAAY,KAAK,EAAE,SAAS,qCAAqC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC5F;AAEA,QAAM,uBAAuB,QAAQ,gBAAgB,aAAa,kBAAkB;AACpF,SAAO,oCAAY,KAAK,EAAE,aAAa,qBAAqB,CAAC;AAC/D;","names":[]}
|
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.26.
|
|
31
|
+
version: "0.26.5",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { type Element } from '../../state/
|
|
1
|
+
{"version":3,"sources":["../../../../src/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { type Element } from '../../state/react-page'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse, type ErrorResponseBody } from '../request-response'\nimport isErrorWithMessage from '../../utils/isErrorWithMessage'\n\ntype TranslatedData = { elementTree: Element }\n\nexport async function mergeTranslatedDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse<TranslatedData | ErrorResponseBody>> {\n const body = await req.json()\n const { translatedData, elementTree } = body\n\n if (translatedData == null) {\n return ApiResponse.json({ message: 'translatedData must be defined' }, { status: 400 })\n }\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined' }, { status: 400 })\n }\n\n try {\n const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData)\n return ApiResponse.json({ elementTree: translatedElementTree })\n } catch (error) {\n if (isErrorWithMessage(error)) {\n return ApiResponse.json({ message: error.message }, { status: 500 })\n }\n return ApiResponse.json({ message: 'Error merging translated data' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAqE;AACrE,gCAA+B;AAI/B,eAAsB,2BACpB,KACA,EAAE,OAAO,GACiD;AAC1D,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,QAAM,EAAE,gBAAgB,YAAY,IAAI;AAExC,MAAI,kBAAkB,MAAM;AAC1B,WAAO,oCAAY,KAAK,EAAE,SAAS,iCAAiC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACxF;AAEA,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,8BAA8B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrF;AAEA,MAAI;AACF,UAAM,wBAAwB,OAAO,oBAAoB,aAAa,cAAc;AACpF,WAAO,oCAAY,KAAK,EAAE,aAAa,sBAAsB,CAAC;AAAA,EAChE,SAAS,OAAO;AACd,YAAI,0BAAAA,SAAmB,KAAK,GAAG;AAC7B,aAAO,oCAAY,KAAK,EAAE,SAAS,MAAM,QAAQ,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACrE;AACA,WAAO,oCAAY,KAAK,EAAE,SAAS,gCAAgC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACvF;AACF;","names":["isErrorWithMessage"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { type Data } from '../../state/
|
|
1
|
+
{"version":3,"sources":["../../../../src/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { type Data } from '../../state/react-page'\nimport { MakeswiftClient } from '../../client'\nimport { type ApiRequest, ApiResponse } from '../request-response'\n\ntype TranslatableDataResult = { translatableData: Record<string, Data> }\ntype TranslatableDataError = { message: string }\n\nexport type TranslatableDataResponse = TranslatableDataResult | TranslatableDataError\n\nexport async function translatableDataHandler(\n req: ApiRequest,\n { client }: { client: MakeswiftClient },\n): Promise<ApiResponse> {\n const body = await req.json()\n\n const { elementTree } = body\n\n if (elementTree == null) {\n return ApiResponse.json({ message: 'elementTree must be defined.' }, { status: 400 })\n }\n\n try {\n let translatableData = client.getTranslatableData(elementTree)\n return ApiResponse.json({ translatableData })\n } catch (error) {\n return ApiResponse.json({ message: 'Failed to get translatable data.' }, { status: 500 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAA6C;AAO7C,eAAsB,wBACpB,KACA,EAAE,OAAO,GACa;AACtB,QAAM,OAAO,MAAM,IAAI,KAAK;AAE5B,QAAM,EAAE,YAAY,IAAI;AAExB,MAAI,eAAe,MAAM;AACvB,WAAO,oCAAY,KAAK,EAAE,SAAS,+BAA+B,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACtF;AAEA,MAAI;AACF,QAAI,mBAAmB,OAAO,oBAAoB,WAAW;AAC7D,WAAO,oCAAY,KAAK,EAAE,iBAAiB,CAAC;AAAA,EAC9C,SAAS,OAAO;AACd,WAAO,oCAAY,KAAK,EAAE,SAAS,mCAAmC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC1F;AACF;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var diff_projection_exports = {};
|
|
20
|
+
__export(diff_projection_exports, {
|
|
21
|
+
diffProjectionSchema: () => diffProjectionSchema
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(diff_projection_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
const changeTypeSchema = import_zod.z.enum(["created", "updated", "deleted"]);
|
|
26
|
+
const componentChangeSchema = import_zod.z.object({
|
|
27
|
+
id: import_zod.z.string(),
|
|
28
|
+
locale: import_zod.z.string().nullable(),
|
|
29
|
+
changeType: changeTypeSchema
|
|
30
|
+
});
|
|
31
|
+
const pageChangeSchema = import_zod.z.object({
|
|
32
|
+
pageId: import_zod.z.string().uuid(),
|
|
33
|
+
locale: import_zod.z.string().nullable(),
|
|
34
|
+
changeType: changeTypeSchema,
|
|
35
|
+
pathname: import_zod.z.string(),
|
|
36
|
+
previousPathname: import_zod.z.string().optional()
|
|
37
|
+
});
|
|
38
|
+
const globalElementChangeSchema = import_zod.z.object({
|
|
39
|
+
id: import_zod.z.string().uuid(),
|
|
40
|
+
locale: import_zod.z.string().nullable(),
|
|
41
|
+
changeType: changeTypeSchema
|
|
42
|
+
});
|
|
43
|
+
const swatchChangeSchema = import_zod.z.object({
|
|
44
|
+
id: import_zod.z.string().uuid(),
|
|
45
|
+
changeType: changeTypeSchema
|
|
46
|
+
});
|
|
47
|
+
const typographyChangeSchema = import_zod.z.object({
|
|
48
|
+
id: import_zod.z.string().uuid(),
|
|
49
|
+
changeType: changeTypeSchema
|
|
50
|
+
});
|
|
51
|
+
const diffProjectionSchema = import_zod.z.object({
|
|
52
|
+
components: import_zod.z.array(componentChangeSchema),
|
|
53
|
+
pages: import_zod.z.array(pageChangeSchema),
|
|
54
|
+
globalElements: import_zod.z.array(globalElementChangeSchema),
|
|
55
|
+
swatches: import_zod.z.array(swatchChangeSchema),
|
|
56
|
+
typographies: import_zod.z.array(typographyChangeSchema)
|
|
57
|
+
}).passthrough();
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
diffProjectionSchema
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=diff-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/diff-projection.ts"],"sourcesContent":["import { z } from 'zod'\n\nconst changeTypeSchema = z.enum(['created', 'updated', 'deleted'])\n\n// `locale` is null for the default locale. We'd prefer explicit locale strings\n// (e.g. \"en-US\"), but both server and runtime treat the default locale as null\n// today — changing that requires a broader localization rework.\nconst componentChangeSchema = z.object({\n id: z.string(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst pageChangeSchema = z.object({\n pageId: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n pathname: z.string(),\n previousPathname: z.string().optional(),\n})\n\nconst globalElementChangeSchema = z.object({\n id: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst swatchChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nconst typographyChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nexport const diffProjectionSchema = z\n .object({\n components: z.array(componentChangeSchema),\n pages: z.array(pageChangeSchema),\n globalElements: z.array(globalElementChangeSchema),\n swatches: z.array(swatchChangeSchema),\n typographies: z.array(typographyChangeSchema),\n })\n // passthrough() preserves unknown resource types the server may add in the\n // future (e.g. `fonts`), so onPublish consumers can access them without a\n // runtime upgrade.\n .passthrough()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,MAAM,mBAAmB,aAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,aAAE,OAAO;AAAA,EACrC,IAAI,aAAE,OAAO;AAAA,EACb,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,aAAE,OAAO;AAAA,EAChC,QAAQ,aAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,aAAE,OAAO;AAAA,EACnB,kBAAkB,aAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,aAAE,OAAO;AAAA,EACzC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,aAAE,OAAO;AAAA,EAClC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,aACjC,OAAO;AAAA,EACN,YAAY,aAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,aAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,aAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,aAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,aAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
|
|
@@ -23,12 +23,12 @@ __export(host_to_builder_actions_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(host_to_builder_actions_exports);
|
|
25
25
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
26
|
-
var
|
|
26
|
+
var import_internal = require("../state/actions/internal");
|
|
27
27
|
var import_actions = require("../state/builder-api/actions");
|
|
28
28
|
const HostToBuilderActionTypes = {
|
|
29
29
|
...import_actions.BuilderActionTypes,
|
|
30
|
-
REGISTER_COMPONENT:
|
|
31
|
-
UNREGISTER_COMPONENT:
|
|
30
|
+
REGISTER_COMPONENT: import_internal.InternalActionTypes.REGISTER_COMPONENT,
|
|
31
|
+
UNREGISTER_COMPONENT: import_internal.InternalActionTypes.UNREGISTER_COMPONENT
|
|
32
32
|
};
|
|
33
33
|
function isHostToBuilderAction(action) {
|
|
34
34
|
return (0, import_toolkit.isAction)(action) && Object.hasOwn(HostToBuilderActionTypes, action.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/builder/host-to-builder-actions.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\n// in the past, we reused the same action type for registering components both internally\n// and in the builder; they have been since split into two separate action types,\n// REGISTER_COMPONENT and REGISTER_BUILDER_COMPONENT, but we still have to expose what\n// are now internal actions to the builder for backward compatibility with the older runtimes\nimport {\n type RegisterComponentAction,\n type UnregisterComponentAction,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/builder/host-to-builder-actions.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\n// in the past, we reused the same action type for registering components both internally\n// and in the builder; they have been since split into two separate action types,\n// REGISTER_COMPONENT and REGISTER_BUILDER_COMPONENT, but we still have to expose what\n// are now internal actions to the builder for backward compatibility with the older runtimes\nimport {\n type RegisterComponentAction,\n type UnregisterComponentAction,\n InternalActionTypes,\n} from '../state/actions/internal'\n\nimport { type BuilderAction, BuilderActionTypes } from '../state/builder-api/actions'\n\nexport const HostToBuilderActionTypes = {\n ...BuilderActionTypes,\n REGISTER_COMPONENT: InternalActionTypes.REGISTER_COMPONENT,\n UNREGISTER_COMPONENT: InternalActionTypes.UNREGISTER_COMPONENT,\n} as const\n\nexport type HostToBuilderAction =\n | BuilderAction\n | RegisterComponentAction\n | UnregisterComponentAction\n\nexport function isHostToBuilderAction(action: unknown): action is HostToBuilderAction {\n return isAction(action) && Object.hasOwn(HostToBuilderActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAMzB,sBAIO;AAEP,qBAAuD;AAEhD,MAAM,2BAA2B;AAAA,EACtC,GAAG;AAAA,EACH,oBAAoB,oCAAoB;AAAA,EACxC,sBAAsB,oCAAoB;AAC5C;AAOO,SAAS,sBAAsB,QAAgD;AACpF,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,0BAA0B,OAAO,IAAI;AAChF;","names":[]}
|
|
@@ -33,14 +33,14 @@ __export(builder_exports, {
|
|
|
33
33
|
Introspection: () => Introspection,
|
|
34
34
|
Props: () => Props,
|
|
35
35
|
TableFormFieldsMessageType: () => import_instances.TableFormFieldsMessageType,
|
|
36
|
-
createBaseDocument: () =>
|
|
36
|
+
createBaseDocument: () => import_react_page.createBaseDocument
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(builder_exports);
|
|
39
39
|
__reExport(builder_exports, require("./serialization"), module.exports);
|
|
40
40
|
__reExport(builder_exports, require("./unstructured-introspection"), module.exports);
|
|
41
41
|
__reExport(builder_exports, require("./host-to-builder-actions"), module.exports);
|
|
42
42
|
__reExport(builder_exports, require("./host-api"), module.exports);
|
|
43
|
-
var
|
|
43
|
+
var import_react_page = require("../state/react-page");
|
|
44
44
|
var Props = __toESM(require("../prop-controllers/descriptors"));
|
|
45
45
|
var import_instances = require("../prop-controllers/instances");
|
|
46
46
|
var Introspection = __toESM(require("../prop-controllers/introspection"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\nexport * from './host-to-builder-actions'\nexport * from './host-api'\n\nexport { type Operation } from '../state/modules/read-write
|
|
1
|
+
{"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './serialization'\nexport * from './unstructured-introspection'\nexport * from './host-to-builder-actions'\nexport * from './host-api'\n\nexport { type Operation } from '../state/modules/read-write-documents'\n\nexport { createBaseDocument } from '../state/react-page'\n\nexport type {\n Descriptor as PropControllerDescriptor,\n DescriptorValueType as PropControllerDescriptorValueType,\n PanelDescriptor,\n PanelDescriptorType,\n PanelDescriptorValueType,\n} from '../prop-controllers/descriptors'\n\nexport * as Props from '../prop-controllers/descriptors'\nexport type { PropControllerMessage, TableFormFieldsMessage } from '../prop-controllers/instances'\nexport { TableFormFieldsMessageType } from '../prop-controllers/instances'\nexport * as Introspection from '../prop-controllers/introspection'\nexport { DELETED_PROP_CONTROLLER_TYPES } from '../prop-controllers/deleted'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAc,4BAAd;AACA,4BAAc,yCADd;AAEA,4BAAc,sCAFd;AAGA,4BAAc,uBAHd;AAOA,wBAAmC;AAUnC,YAAuB;AAEvB,uBAA2C;AAC3C,oBAA+B;AAC/B,qBAA8C;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var serialization_exports = {};
|
|
21
|
+
__export(serialization_exports, {
|
|
22
|
+
deserializeControl: () => deserializeControl,
|
|
23
|
+
deserializeControls: () => deserializeControls,
|
|
24
|
+
serializeControl: () => serializeControl,
|
|
25
|
+
serializeControls: () => serializeControls
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(serialization_exports);
|
|
28
|
+
var import_controls = require("@makeswift/controls");
|
|
29
|
+
var import_serialization = require("../prop-controllers/serialization");
|
|
30
|
+
var import_descriptors = require("../prop-controllers/descriptors");
|
|
31
|
+
var import_base = require("../controls/serialization/base");
|
|
32
|
+
var import_message_port = require("../controls/serialization/message-port");
|
|
33
|
+
var import_serialization2 = require("../controls/serialization");
|
|
34
|
+
__reExport(serialization_exports, require("../prop-controllers/serialization"), module.exports);
|
|
35
|
+
function serializeControl(control) {
|
|
36
|
+
if ((0, import_descriptors.isLegacyDescriptor)(control)) {
|
|
37
|
+
return (0, import_serialization.serializeLegacyControl)(control);
|
|
38
|
+
}
|
|
39
|
+
const messagePortVisitor = new import_message_port.ClientMessagePortSerializationVisitor();
|
|
40
|
+
const serializedControl = control.accept(messagePortVisitor);
|
|
41
|
+
return [serializedControl, messagePortVisitor.getTransferables()];
|
|
42
|
+
}
|
|
43
|
+
function isSerializedLegacyControl(control) {
|
|
44
|
+
return "options" in control;
|
|
45
|
+
}
|
|
46
|
+
function deserializeControl(serializedControl, options) {
|
|
47
|
+
if (isSerializedLegacyControl(serializedControl)) {
|
|
48
|
+
const record = options?.plugins ? (0, import_controls.deserializeObject)(serializedControl, options?.plugins) : serializedControl;
|
|
49
|
+
return (0, import_serialization.deserializeLegacyControl)(record);
|
|
50
|
+
}
|
|
51
|
+
const plugins = [import_message_port.functionDeserializationPlugin, ...options?.plugins ?? []];
|
|
52
|
+
return (0, import_base.deserializeControl)(serializedControl, { plugins });
|
|
53
|
+
}
|
|
54
|
+
function serializeControls(controls) {
|
|
55
|
+
return Object.entries(controls).reduce(
|
|
56
|
+
([accControls, accTransferables], [key, control]) => {
|
|
57
|
+
const [serializedControl, transferables] = serializeControl(control);
|
|
58
|
+
return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]];
|
|
59
|
+
},
|
|
60
|
+
[{}, []]
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function deserializeControls(serializedControls, { onError, plugins } = {}) {
|
|
64
|
+
return (0, import_serialization2.deserializeControlRecords)(
|
|
65
|
+
serializedControls,
|
|
66
|
+
(serializedControl, options) => deserializeControl(serializedControl, options),
|
|
67
|
+
{ onError, plugins }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
deserializeControl,
|
|
73
|
+
deserializeControls,
|
|
74
|
+
serializeControl,
|
|
75
|
+
serializeControls,
|
|
76
|
+
...require("../prop-controllers/serialization")
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=serialization.js.map
|