@makeswift/runtime 0.26.4 → 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 +252 -0
- package/dist/cjs/api/client.js.map +1 -0
- package/dist/cjs/api-handler/handlers/manifest.js +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/serialization.js +78 -0
- package/dist/cjs/builder/serialization.js.map +1 -0
- package/dist/cjs/client/index.js +3 -3
- 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/pages-router.js +1 -1
- package/dist/cjs/next/api-handler/config/pages-router.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/react-runtime.js +29 -0
- package/dist/cjs/next/testing/react-runtime.js.map +1 -0
- 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/GoogleFontLink.js +55 -0
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -0
- 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/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-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-is-read-only.js +33 -0
- package/dist/cjs/runtimes/react/hooks/use-is-read-only.js.map +1 -0
- 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/testing/react-runtime.js +33 -0
- package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -0
- 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/index.js +34 -0
- package/dist/cjs/state/actions/internal/index.js.map +1 -0
- package/dist/cjs/state/actions/internal/read-only-actions.js +195 -0
- package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -0
- package/dist/cjs/state/actions/internal/read-write-actions.js +76 -0
- package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -0
- 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/middleware/makeswift-api-client-sync.js +37 -0
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/cjs/state/middleware/read-only-element-tree.js +52 -0
- package/dist/cjs/state/middleware/read-only-element-tree.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/builder-api/element-size.js +40 -0
- package/dist/cjs/state/middleware/read-write/builder-api/element-size.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/builder-api/index.js +85 -0
- package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js +281 -0
- package/dist/cjs/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -0
- 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/read-write/measure-box-models.js +71 -0
- package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +114 -0
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/update-element-tree.js +59 -0
- package/dist/cjs/state/middleware/read-write/update-element-tree.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/is-read-only.js +50 -0
- package/dist/cjs/state/modules/is-read-only.js.map +1 -0
- package/dist/cjs/state/modules/locale.js +50 -0
- package/dist/cjs/state/modules/locale.js.map +1 -0
- package/dist/cjs/state/modules/read-write/box-models.js +144 -0
- package/dist/cjs/state/modules/read-write/box-models.js.map +1 -0
- package/dist/cjs/state/modules/read-write/element-imperative-handles.js +61 -0
- package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +1 -0
- package/dist/cjs/state/modules/read-write/pointer.js +48 -0
- package/dist/cjs/state/modules/read-write/pointer.js.map +1 -0
- package/dist/cjs/state/modules/read-write/read-write-documents.js +98 -0
- package/dist/cjs/state/modules/read-write/read-write-documents.js.map +1 -0
- package/dist/cjs/state/modules/site-version.js +47 -0
- package/dist/cjs/state/modules/site-version.js.map +1 -0
- package/dist/cjs/state/ops/copy-element-tree.js +67 -0
- package/dist/cjs/state/ops/copy-element-tree.js.map +1 -0
- package/dist/cjs/state/ops/merge-element.js +73 -0
- package/dist/cjs/state/ops/merge-element.js.map +1 -0
- package/dist/cjs/state/read-only-state.js +231 -0
- package/dist/cjs/state/read-only-state.js.map +1 -0
- package/dist/cjs/state/read-write-state.js +128 -0
- package/dist/cjs/state/read-write-state.js.map +1 -0
- package/dist/cjs/state/store.js +219 -0
- package/dist/cjs/state/store.js.map +1 -0
- 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/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 +219 -0
- package/dist/esm/api/client.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +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/serialization.js +59 -0
- package/dist/esm/builder/serialization.js.map +1 -0
- package/dist/esm/client/index.js +3 -3
- 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/pages-router.js +1 -1
- package/dist/esm/next/api-handler/config/pages-router.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/react-runtime.js +5 -0
- package/dist/esm/next/testing/react-runtime.js.map +1 -0
- 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/GoogleFontLink.js +35 -0
- package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -0
- 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/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-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-is-read-only.js +9 -0
- package/dist/esm/runtimes/react/hooks/use-is-read-only.js.map +1 -0
- 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/testing/react-runtime.js +9 -0
- package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -0
- 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/index.js +10 -0
- package/dist/esm/state/actions/internal/index.js.map +1 -0
- package/dist/esm/state/actions/internal/read-only-actions.js +153 -0
- package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -0
- package/dist/esm/state/actions/internal/read-write-actions.js +46 -0
- package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -0
- 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/middleware/makeswift-api-client-sync.js +13 -0
- package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/esm/state/middleware/read-only-element-tree.js +28 -0
- package/dist/esm/state/middleware/read-only-element-tree.js.map +1 -0
- package/dist/esm/state/middleware/read-write/builder-api/element-size.js +16 -0
- package/dist/esm/state/middleware/read-write/builder-api/element-size.js.map +1 -0
- package/dist/esm/state/middleware/read-write/builder-api/index.js +61 -0
- package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -0
- package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js +254 -0
- package/dist/esm/state/middleware/read-write/builder-api/initialize-connection.js.map +1 -0
- 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/read-write/measure-box-models.js +37 -0
- package/dist/esm/state/middleware/read-write/measure-box-models.js.map +1 -0
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js +80 -0
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/esm/state/middleware/read-write/update-element-tree.js +35 -0
- package/dist/esm/state/middleware/read-write/update-element-tree.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/is-read-only.js +24 -0
- package/dist/esm/state/modules/is-read-only.js.map +1 -0
- package/dist/esm/state/modules/locale.js +24 -0
- package/dist/esm/state/modules/locale.js.map +1 -0
- package/dist/esm/state/modules/read-write/box-models.js +114 -0
- package/dist/esm/state/modules/read-write/box-models.js.map +1 -0
- package/dist/esm/state/modules/read-write/element-imperative-handles.js +36 -0
- package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +1 -0
- package/dist/esm/state/modules/read-write/pointer.js +23 -0
- package/dist/esm/state/modules/read-write/pointer.js.map +1 -0
- package/dist/esm/state/modules/read-write/read-write-documents.js +60 -0
- package/dist/esm/state/modules/read-write/read-write-documents.js.map +1 -0
- package/dist/esm/state/modules/site-version.js +21 -0
- package/dist/esm/state/modules/site-version.js.map +1 -0
- package/dist/esm/state/ops/copy-element-tree.js +37 -0
- package/dist/esm/state/ops/copy-element-tree.js.map +1 -0
- package/dist/esm/state/ops/merge-element.js +39 -0
- package/dist/esm/state/ops/merge-element.js.map +1 -0
- package/dist/esm/state/read-only-state.js +176 -0
- package/dist/esm/state/read-only-state.js.map +1 -0
- package/dist/esm/state/read-write-state.js +82 -0
- package/dist/esm/state/read-write-state.js.map +1 -0
- package/dist/esm/state/store.js +188 -0
- package/dist/esm/state/store.js.map +1 -0
- 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/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 +81 -0
- package/dist/types/api/client.d.ts.map +1 -0
- 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/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/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/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/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/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/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/react-runtime.d.ts +2 -0
- package/dist/types/next/testing/react-runtime.d.ts.map +1 -0
- 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/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/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-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-is-read-only.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/use-is-read-only.d.ts.map +1 -0
- 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/testing/react-runtime.d.ts +6 -0
- package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -0
- 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__/merge-element.test.d.ts +2 -0
- package/dist/types/state/__tests__/merge-element.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/internal/index.d.ts +29 -0
- package/dist/types/state/actions/internal/index.d.ts.map +1 -0
- package/dist/types/state/actions/internal/read-only-actions.d.ts +171 -0
- package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -0
- package/dist/types/state/actions/internal/read-write-actions.d.ts +53 -0
- package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -0
- 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/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-only-element-tree.d.ts +4 -0
- package/dist/types/state/middleware/read-only-element-tree.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts +12 -0
- package/dist/types/state/middleware/read-write/builder-api/element-size.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/builder-api/index.d.ts +5 -0
- package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts +6 -0
- package/dist/types/state/middleware/read-write/builder-api/initialize-connection.d.ts.map +1 -0
- 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/read-write/measure-box-models.d.ts +4 -0
- package/dist/types/state/middleware/read-write/measure-box-models.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts +4 -0
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/update-element-tree.d.ts +4 -0
- package/dist/types/state/middleware/read-write/update-element-tree.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/is-read-only.d.ts +6 -0
- package/dist/types/state/modules/is-read-only.d.ts.map +1 -0
- package/dist/types/state/modules/locale.d.ts +6 -0
- package/dist/types/state/modules/locale.d.ts.map +1 -0
- package/dist/types/state/modules/read-write/box-models.d.ts +26 -0
- package/dist/types/state/modules/read-write/box-models.d.ts.map +1 -0
- package/dist/types/state/modules/read-write/element-imperative-handles.d.ts +6 -0
- package/dist/types/state/modules/read-write/element-imperative-handles.d.ts.map +1 -0
- package/dist/types/state/modules/read-write/pointer.d.ts +11 -0
- package/dist/types/state/modules/read-write/pointer.d.ts.map +1 -0
- package/dist/types/state/modules/read-write/read-write-documents.d.ts +14 -0
- package/dist/types/state/modules/read-write/read-write-documents.d.ts.map +1 -0
- package/dist/types/state/modules/site-version.d.ts +7 -0
- package/dist/types/state/modules/site-version.d.ts.map +1 -0
- package/dist/types/state/ops/copy-element-tree.d.ts +37 -0
- package/dist/types/state/ops/copy-element-tree.d.ts.map +1 -0
- package/dist/types/state/ops/merge-element.d.ts +4 -0
- package/dist/types/state/ops/merge-element.d.ts.map +1 -0
- package/dist/types/state/read-only-state.d.ts +131 -0
- package/dist/types/state/read-only-state.d.ts.map +1 -0
- package/dist/types/state/read-write-state.d.ts +62 -0
- package/dist/types/state/read-write-state.d.ts.map +1 -0
- package/dist/types/state/store.d.ts +86 -0
- package/dist/types/state/store.d.ts.map +1 -0
- 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/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 +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
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 translations_exports = {};
|
|
20
|
+
__export(translations_exports, {
|
|
21
|
+
getTranslatableContent: () => import_get.getTranslatableContent,
|
|
22
|
+
mergeTranslatedContent: () => import_merge.mergeTranslatedContent
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(translations_exports);
|
|
25
|
+
var import_get = require("../state/translations/get");
|
|
26
|
+
var import_merge = require("../state/translations/merge");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
getTranslatableContent,
|
|
30
|
+
mergeTranslatedContent
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/translations/index.ts"],"sourcesContent":["export { getTranslatableContent } from '../state/translations/get'\nexport { mergeTranslatedContent } from '../state/translations/merge'\nexport type { DescriptorsByComponentType, DescriptorsByProp } from '../state/modules/prop-controllers'\nexport type { ElementData, Data, Element } from '../state/read-only-state'\nexport type { TranslationDto } from '@makeswift/controls'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAuC;AACvC,mBAAuC;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 deferred_exports = {};
|
|
20
|
+
__export(deferred_exports, {
|
|
21
|
+
createDeferred: () => createDeferred
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(deferred_exports);
|
|
24
|
+
function createDeferred() {
|
|
25
|
+
let resolve = () => {
|
|
26
|
+
};
|
|
27
|
+
let reject = () => {
|
|
28
|
+
};
|
|
29
|
+
const promise = new Promise((resolveFn, rejectFn) => {
|
|
30
|
+
resolve = resolveFn;
|
|
31
|
+
reject = rejectFn;
|
|
32
|
+
});
|
|
33
|
+
return { promise, resolve, reject };
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
createDeferred
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=deferred.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/deferred.ts"],"sourcesContent":["export type Deferred<T> = {\n promise: Promise<T>\n resolve: (value: T) => void\n reject: (reason?: unknown) => void\n}\n\nexport function createDeferred<T>(): Deferred<T> {\n let resolve: (value: T) => void = () => {}\n let reject: (reason?: unknown) => void = () => {}\n\n const promise = new Promise<T>((resolveFn, rejectFn) => {\n resolve = resolveFn\n reject = rejectFn\n })\n\n return { promise, resolve, reject }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,iBAAiC;AAC/C,MAAI,UAA8B,MAAM;AAAA,EAAC;AACzC,MAAI,SAAqC,MAAM;AAAA,EAAC;AAEhD,QAAM,UAAU,IAAI,QAAW,CAAC,WAAW,aAAa;AACtD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,SAAO,EAAE,SAAS,SAAS,OAAO;AACpC;","names":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
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 ref_counted_map_exports = {};
|
|
20
|
+
__export(ref_counted_map_exports, {
|
|
21
|
+
RefCountedMap: () => RefCountedMap
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ref_counted_map_exports);
|
|
24
|
+
const TTLCheck = {
|
|
25
|
+
ON_GET: 1 << 0,
|
|
26
|
+
ON_RETAIN: 1 << 1,
|
|
27
|
+
ON_RELEASE: 1 << 2
|
|
28
|
+
};
|
|
29
|
+
class RefCountedMap {
|
|
30
|
+
map = /* @__PURE__ */ new Map();
|
|
31
|
+
unownedEntryTtlMs;
|
|
32
|
+
ttlCheck;
|
|
33
|
+
static TTLCheck = TTLCheck;
|
|
34
|
+
constructor({
|
|
35
|
+
unownedEntryTtlMs,
|
|
36
|
+
ttlCheck = TTLCheck.ON_GET | TTLCheck.ON_RETAIN | TTLCheck.ON_RELEASE
|
|
37
|
+
}) {
|
|
38
|
+
this.unownedEntryTtlMs = unownedEntryTtlMs;
|
|
39
|
+
this.ttlCheck = ttlCheck;
|
|
40
|
+
}
|
|
41
|
+
get size() {
|
|
42
|
+
return this.map.size;
|
|
43
|
+
}
|
|
44
|
+
get(key) {
|
|
45
|
+
return this.map.get(key)?.value;
|
|
46
|
+
}
|
|
47
|
+
getOrCreate(key, init) {
|
|
48
|
+
try {
|
|
49
|
+
const existing = this.map.get(key);
|
|
50
|
+
if (existing) {
|
|
51
|
+
if (isUnowned(existing))
|
|
52
|
+
existing.accessedAt = Date.now();
|
|
53
|
+
return existing.value;
|
|
54
|
+
}
|
|
55
|
+
const value = init();
|
|
56
|
+
this.map.set(key, { value, count: void 0, accessedAt: Date.now() });
|
|
57
|
+
return value;
|
|
58
|
+
} finally {
|
|
59
|
+
if (this.ttlCheck & TTLCheck.ON_GET)
|
|
60
|
+
this.removeExpired();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns true on transition from unowned to owned
|
|
65
|
+
*/
|
|
66
|
+
retain(key, value) {
|
|
67
|
+
try {
|
|
68
|
+
const existing = this.map.get(key);
|
|
69
|
+
if (existing == null) {
|
|
70
|
+
this.map.set(key, { value, count: 1 });
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (existing.value === value) {
|
|
74
|
+
existing.count = (existing.count ?? 0) + 1;
|
|
75
|
+
return existing.count === 1;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
} finally {
|
|
79
|
+
if (this.ttlCheck & TTLCheck.ON_RETAIN)
|
|
80
|
+
this.removeExpired();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns true on transition from owned to unowned
|
|
85
|
+
*/
|
|
86
|
+
release(key, value) {
|
|
87
|
+
try {
|
|
88
|
+
const existing = this.map.get(key);
|
|
89
|
+
if (existing == null)
|
|
90
|
+
return false;
|
|
91
|
+
if (isUnowned(existing))
|
|
92
|
+
return false;
|
|
93
|
+
if (existing.value !== value)
|
|
94
|
+
return false;
|
|
95
|
+
if (existing.count === 1) {
|
|
96
|
+
this.map.delete(key);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
existing.count -= 1;
|
|
100
|
+
return false;
|
|
101
|
+
} finally {
|
|
102
|
+
if (this.ttlCheck & TTLCheck.ON_RELEASE)
|
|
103
|
+
this.removeExpired();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
removeExpired() {
|
|
107
|
+
const now = Date.now();
|
|
108
|
+
const isExpired = (entry) => isUnowned(entry) && now - entry.accessedAt > this.unownedEntryTtlMs;
|
|
109
|
+
this.map.forEach((entry, key) => {
|
|
110
|
+
if (isExpired(entry))
|
|
111
|
+
this.map.delete(key);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const isUnowned = (entry) => entry.count === void 0;
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
RefCountedMap
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=ref-counted-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/ref-counted-map.ts"],"sourcesContent":["type RefCountedMapEntry<V> = {\n value: V\n count: number\n}\n\ntype UnownedMapEntry<V> = {\n value: V\n count: undefined\n accessedAt: number\n}\n\ntype MapEntry<V> = RefCountedMapEntry<V> | UnownedMapEntry<V>\n\nconst TTLCheck = {\n ON_GET: 1 << 0,\n ON_RETAIN: 1 << 1,\n ON_RELEASE: 1 << 2,\n} as const\n\n/**\n * Ref-counted map with explicit retention semantics. Entries are unowned by default and may be evicted after their\n * TTL unless explicitly retained. This provides TTL-based caching for unowned entries, while allowing consumers to\n * opt into stronger lifetime control via explicit retention.\n */\nexport class RefCountedMap<K, V> {\n private readonly map = new Map<K, MapEntry<V>>()\n private readonly unownedEntryTtlMs: number\n private readonly ttlCheck: number\n\n static readonly TTLCheck = TTLCheck\n\n constructor({\n unownedEntryTtlMs,\n ttlCheck = TTLCheck.ON_GET | TTLCheck.ON_RETAIN | TTLCheck.ON_RELEASE,\n }: {\n unownedEntryTtlMs: number\n ttlCheck?: number\n }) {\n this.unownedEntryTtlMs = unownedEntryTtlMs\n this.ttlCheck = ttlCheck\n }\n\n get size(): number {\n return this.map.size\n }\n\n get(key: K): V | undefined {\n return this.map.get(key)?.value\n }\n\n getOrCreate(key: K, init: () => V): V {\n try {\n const existing = this.map.get(key)\n\n if (existing) {\n if (isUnowned(existing)) existing.accessedAt = Date.now()\n return existing.value\n }\n\n const value = init()\n this.map.set(key, { value, count: undefined, accessedAt: Date.now() })\n return value\n } finally {\n if (this.ttlCheck & TTLCheck.ON_GET) this.removeExpired()\n }\n }\n\n /**\n * Returns true on transition from unowned to owned\n */\n retain(key: K, value: V): boolean {\n try {\n const existing = this.map.get(key)\n\n if (existing == null) {\n this.map.set(key, { value, count: 1 })\n return true\n }\n\n // `retain` might be called on a unowned entry that has already been evicted from the map due to TTL expiration\n // *and* possibly replaced by a new unowned entry with the same key; handle this gracefully\n if (existing.value === value) {\n existing.count = (existing.count ?? 0) + 1\n return existing.count === 1\n }\n\n return false\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RETAIN) this.removeExpired()\n }\n }\n\n /**\n * Returns true on transition from owned to unowned\n */\n release(key: K, value: V): boolean {\n try {\n const existing = this.map.get(key)\n\n // `release` might be called on an entry that remained unowned due being superseded by a new entry with the same\n // key after TTL expiration of the original entry; handle this gracefully\n if (existing == null) return false\n if (isUnowned(existing)) return false\n if (existing.value !== value) return false\n\n if (existing.count === 1) {\n this.map.delete(key)\n return true\n }\n\n existing.count -= 1\n return false\n } finally {\n if (this.ttlCheck & TTLCheck.ON_RELEASE) this.removeExpired()\n }\n }\n\n private removeExpired(): void {\n const now = Date.now()\n const isExpired = (entry: MapEntry<V>): boolean =>\n isUnowned(entry) && now - entry.accessedAt > this.unownedEntryTtlMs\n\n this.map.forEach((entry, key) => {\n if (isExpired(entry)) this.map.delete(key)\n })\n }\n}\n\nconst isUnowned = <V>(entry: MapEntry<V>): entry is UnownedMapEntry<V> => entry.count === undefined\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,MAAM,WAAW;AAAA,EACf,QAAQ,KAAK;AAAA,EACb,WAAW,KAAK;AAAA,EAChB,YAAY,KAAK;AACnB;AAOO,MAAM,cAAoB;AAAA,EACd,MAAM,oBAAI,IAAoB;AAAA,EAC9B;AAAA,EACA;AAAA,EAEjB,OAAgB,WAAW;AAAA,EAE3B,YAAY;AAAA,IACV;AAAA,IACA,WAAW,SAAS,SAAS,SAAS,YAAY,SAAS;AAAA,EAC7D,GAGG;AACD,SAAK,oBAAoB;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,K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S;AAClB,aAAO;AAAA,IACT,UAAE;AACA,UAAI,KAAK,WAAW,SAAS;AAAY,aAAK,cAAc;AAAA,IAC9D;AAAA,EACF;AAAA,EAEQ,gBAAsB;AAC5B,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,YAAY,CAAC,UACjB,UAAU,KAAK,KAAK,MAAM,MAAM,aAAa,KAAK;AAEpD,SAAK,IAAI,QAAQ,CAAC,OAAO,QAAQ;AAC/B,UAAI,UAAU,KAAK;AAAG,aAAK,IAAI,OAAO,GAAG;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;AAEA,MAAM,YAAY,CAAI,UAAoD,MAAM,UAAU;","names":[]}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as MakeswiftApiClient from "../state/makeswift-api-client";
|
|
2
|
+
import {
|
|
3
|
+
APIResourceType
|
|
4
|
+
} from "./types";
|
|
5
|
+
import { GraphQLClient } from "./graphql/client";
|
|
6
|
+
import { CreateTableRecordMutation } from "./graphql/documents";
|
|
7
|
+
const CacheData = {
|
|
8
|
+
empty() {
|
|
9
|
+
return {
|
|
10
|
+
apiResources: {},
|
|
11
|
+
localizedResourcesMap: {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
class MakeswiftHostApiClient {
|
|
16
|
+
graphqlClient;
|
|
17
|
+
makeswiftApiClient;
|
|
18
|
+
subscribe;
|
|
19
|
+
fetch;
|
|
20
|
+
constructor({
|
|
21
|
+
uri,
|
|
22
|
+
fetch,
|
|
23
|
+
preloadedState
|
|
24
|
+
}) {
|
|
25
|
+
this.graphqlClient = new GraphQLClient(uri);
|
|
26
|
+
this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState });
|
|
27
|
+
this.fetch = fetch;
|
|
28
|
+
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
29
|
+
}
|
|
30
|
+
readSwatch(swatchId) {
|
|
31
|
+
return MakeswiftApiClient.getAPIResource(
|
|
32
|
+
this.makeswiftApiClient.getState(),
|
|
33
|
+
APIResourceType.Swatch,
|
|
34
|
+
swatchId
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async fetchSwatch(swatchId) {
|
|
38
|
+
return await this.makeswiftApiClient.dispatch(
|
|
39
|
+
MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
resolveSwatch(swatchId) {
|
|
43
|
+
return this.resolveResource(APIResourceType.Swatch, {
|
|
44
|
+
id: swatchId,
|
|
45
|
+
read: (id) => this.readSwatch(id),
|
|
46
|
+
fetch: (id) => this.fetchSwatch(id)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
readFile(fileId) {
|
|
50
|
+
return MakeswiftApiClient.getAPIResource(
|
|
51
|
+
this.makeswiftApiClient.getState(),
|
|
52
|
+
APIResourceType.File,
|
|
53
|
+
fileId
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
async fetchFile(fileId) {
|
|
57
|
+
return await this.makeswiftApiClient.dispatch(
|
|
58
|
+
MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
resolveFile(fileId) {
|
|
62
|
+
return this.resolveResource(APIResourceType.File, {
|
|
63
|
+
id: fileId,
|
|
64
|
+
read: (id) => this.readFile(id),
|
|
65
|
+
fetch: (id) => this.fetchFile(id)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
readTypography(typographyId) {
|
|
69
|
+
return MakeswiftApiClient.getAPIResource(
|
|
70
|
+
this.makeswiftApiClient.getState(),
|
|
71
|
+
APIResourceType.Typography,
|
|
72
|
+
typographyId
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
async fetchTypography(typographyId) {
|
|
76
|
+
return await this.makeswiftApiClient.dispatch(
|
|
77
|
+
MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
resolveTypography(typographyId) {
|
|
81
|
+
return this.resolveResource(APIResourceType.Typography, {
|
|
82
|
+
id: typographyId,
|
|
83
|
+
read: (id) => this.readTypography(id),
|
|
84
|
+
fetch: (id) => this.fetchTypography(id)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
readGlobalElement(globalElementId) {
|
|
88
|
+
return MakeswiftApiClient.getAPIResource(
|
|
89
|
+
this.makeswiftApiClient.getState(),
|
|
90
|
+
APIResourceType.GlobalElement,
|
|
91
|
+
globalElementId
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
async fetchGlobalElement(globalElementId) {
|
|
95
|
+
return await this.makeswiftApiClient.dispatch(
|
|
96
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
97
|
+
APIResourceType.GlobalElement,
|
|
98
|
+
globalElementId,
|
|
99
|
+
this.fetch
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
readLocalizedGlobalElement({
|
|
104
|
+
globalElementId,
|
|
105
|
+
locale
|
|
106
|
+
}) {
|
|
107
|
+
return MakeswiftApiClient.getAPIResource(
|
|
108
|
+
this.makeswiftApiClient.getState(),
|
|
109
|
+
APIResourceType.LocalizedGlobalElement,
|
|
110
|
+
globalElementId,
|
|
111
|
+
locale
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
async fetchLocalizedGlobalElement({
|
|
115
|
+
globalElementId,
|
|
116
|
+
locale
|
|
117
|
+
}) {
|
|
118
|
+
return await this.makeswiftApiClient.dispatch(
|
|
119
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
120
|
+
APIResourceType.LocalizedGlobalElement,
|
|
121
|
+
globalElementId,
|
|
122
|
+
this.fetch,
|
|
123
|
+
locale
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
readPagePathnameSlice({
|
|
128
|
+
pageId,
|
|
129
|
+
locale
|
|
130
|
+
}) {
|
|
131
|
+
return MakeswiftApiClient.getAPIResource(
|
|
132
|
+
this.makeswiftApiClient.getState(),
|
|
133
|
+
APIResourceType.PagePathnameSlice,
|
|
134
|
+
pageId,
|
|
135
|
+
locale
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
async fetchPagePathnameSlice({
|
|
139
|
+
pageId,
|
|
140
|
+
locale
|
|
141
|
+
}) {
|
|
142
|
+
return await this.makeswiftApiClient.dispatch(
|
|
143
|
+
MakeswiftApiClient.fetchAPIResource(
|
|
144
|
+
APIResourceType.PagePathnameSlice,
|
|
145
|
+
pageId,
|
|
146
|
+
this.fetch,
|
|
147
|
+
locale
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
resolvePagePathnameSlice({
|
|
152
|
+
pageId,
|
|
153
|
+
locale
|
|
154
|
+
}) {
|
|
155
|
+
return this.resolveResource(APIResourceType.PagePathnameSlice, {
|
|
156
|
+
id: pageId,
|
|
157
|
+
read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
|
|
158
|
+
fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
resolveResource(type, {
|
|
162
|
+
id,
|
|
163
|
+
read,
|
|
164
|
+
fetch
|
|
165
|
+
}) {
|
|
166
|
+
const _read = () => id != null ? read(id) : null;
|
|
167
|
+
let lastValue = null;
|
|
168
|
+
return {
|
|
169
|
+
name: `${type}:${id}`,
|
|
170
|
+
readStable: () => lastValue = _read(),
|
|
171
|
+
subscribe: (onUpdate) => this.subscribe(() => {
|
|
172
|
+
if (_read() !== lastValue)
|
|
173
|
+
onUpdate();
|
|
174
|
+
}),
|
|
175
|
+
fetch: async () => id != null ? fetch(id) : null
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
readTable(tableId) {
|
|
179
|
+
return MakeswiftApiClient.getAPIResource(
|
|
180
|
+
this.makeswiftApiClient.getState(),
|
|
181
|
+
APIResourceType.Table,
|
|
182
|
+
tableId
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
async fetchTable(tableId) {
|
|
186
|
+
return await this.makeswiftApiClient.dispatch(
|
|
187
|
+
MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch)
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
async createTableRecord(tableId, columns) {
|
|
191
|
+
await this.graphqlClient.request(CreateTableRecordMutation, { input: { data: { tableId, columns } } });
|
|
192
|
+
}
|
|
193
|
+
readSite(siteId) {
|
|
194
|
+
return MakeswiftApiClient.getAPIResource(
|
|
195
|
+
this.makeswiftApiClient.getState(),
|
|
196
|
+
APIResourceType.Site,
|
|
197
|
+
siteId
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
readPage(pageId) {
|
|
201
|
+
return MakeswiftApiClient.getAPIResource(
|
|
202
|
+
this.makeswiftApiClient.getState(),
|
|
203
|
+
APIResourceType.Page,
|
|
204
|
+
pageId
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
readSnippet(snippetId) {
|
|
208
|
+
return MakeswiftApiClient.getAPIResource(
|
|
209
|
+
this.makeswiftApiClient.getState(),
|
|
210
|
+
APIResourceType.Snippet,
|
|
211
|
+
snippetId
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
CacheData,
|
|
217
|
+
MakeswiftHostApiClient
|
|
218
|
+
};
|
|
219
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +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'\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":"AAEA,YAAY,wBAAwB;AAEpC;AAAA,EACE;AAAA,OAWK;AACP,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;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,cAAc,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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AAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.26.
|
|
11
|
+
version: "0.26.5",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const changeTypeSchema = z.enum(["created", "updated", "deleted"]);
|
|
3
|
+
const componentChangeSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
locale: z.string().nullable(),
|
|
6
|
+
changeType: changeTypeSchema
|
|
7
|
+
});
|
|
8
|
+
const pageChangeSchema = z.object({
|
|
9
|
+
pageId: z.string().uuid(),
|
|
10
|
+
locale: z.string().nullable(),
|
|
11
|
+
changeType: changeTypeSchema,
|
|
12
|
+
pathname: z.string(),
|
|
13
|
+
previousPathname: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
const globalElementChangeSchema = z.object({
|
|
16
|
+
id: z.string().uuid(),
|
|
17
|
+
locale: z.string().nullable(),
|
|
18
|
+
changeType: changeTypeSchema
|
|
19
|
+
});
|
|
20
|
+
const swatchChangeSchema = z.object({
|
|
21
|
+
id: z.string().uuid(),
|
|
22
|
+
changeType: changeTypeSchema
|
|
23
|
+
});
|
|
24
|
+
const typographyChangeSchema = z.object({
|
|
25
|
+
id: z.string().uuid(),
|
|
26
|
+
changeType: changeTypeSchema
|
|
27
|
+
});
|
|
28
|
+
const diffProjectionSchema = z.object({
|
|
29
|
+
components: z.array(componentChangeSchema),
|
|
30
|
+
pages: z.array(pageChangeSchema),
|
|
31
|
+
globalElements: z.array(globalElementChangeSchema),
|
|
32
|
+
swatches: z.array(swatchChangeSchema),
|
|
33
|
+
typographies: z.array(typographyChangeSchema)
|
|
34
|
+
}).passthrough();
|
|
35
|
+
export {
|
|
36
|
+
diffProjectionSchema
|
|
37
|
+
};
|
|
38
|
+
//# 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,SAAS,SAAS;AAElB,MAAM,mBAAmB,EAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,IAAI,EAAE,OAAO;AAAA,EACb,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,QAAQ,EAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,EAAE,OAAO;AAAA,EACnB,kBAAkB,EAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,YAAY,EAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,EAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,EAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,EAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,EAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deserializeObject
|
|
3
|
+
} from "@makeswift/controls";
|
|
4
|
+
import {
|
|
5
|
+
serializeLegacyControl,
|
|
6
|
+
deserializeLegacyControl
|
|
7
|
+
} from "../prop-controllers/serialization";
|
|
8
|
+
import { isLegacyDescriptor } from "../prop-controllers/descriptors";
|
|
9
|
+
import { deserializeControl as deserializeUnifiedControl } from "../controls/serialization/base";
|
|
10
|
+
import {
|
|
11
|
+
ClientMessagePortSerializationVisitor,
|
|
12
|
+
functionDeserializationPlugin
|
|
13
|
+
} from "../controls/serialization/message-port";
|
|
14
|
+
import {
|
|
15
|
+
deserializeControlRecords
|
|
16
|
+
} from "../controls/serialization";
|
|
17
|
+
export * from "../prop-controllers/serialization";
|
|
18
|
+
function serializeControl(control) {
|
|
19
|
+
if (isLegacyDescriptor(control)) {
|
|
20
|
+
return serializeLegacyControl(control);
|
|
21
|
+
}
|
|
22
|
+
const messagePortVisitor = new ClientMessagePortSerializationVisitor();
|
|
23
|
+
const serializedControl = control.accept(messagePortVisitor);
|
|
24
|
+
return [serializedControl, messagePortVisitor.getTransferables()];
|
|
25
|
+
}
|
|
26
|
+
function isSerializedLegacyControl(control) {
|
|
27
|
+
return "options" in control;
|
|
28
|
+
}
|
|
29
|
+
function deserializeControl(serializedControl, options) {
|
|
30
|
+
if (isSerializedLegacyControl(serializedControl)) {
|
|
31
|
+
const record = options?.plugins ? deserializeObject(serializedControl, options?.plugins) : serializedControl;
|
|
32
|
+
return deserializeLegacyControl(record);
|
|
33
|
+
}
|
|
34
|
+
const plugins = [functionDeserializationPlugin, ...options?.plugins ?? []];
|
|
35
|
+
return deserializeUnifiedControl(serializedControl, { plugins });
|
|
36
|
+
}
|
|
37
|
+
function serializeControls(controls) {
|
|
38
|
+
return Object.entries(controls).reduce(
|
|
39
|
+
([accControls, accTransferables], [key, control]) => {
|
|
40
|
+
const [serializedControl, transferables] = serializeControl(control);
|
|
41
|
+
return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]];
|
|
42
|
+
},
|
|
43
|
+
[{}, []]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function deserializeControls(serializedControls, { onError, plugins } = {}) {
|
|
47
|
+
return deserializeControlRecords(
|
|
48
|
+
serializedControls,
|
|
49
|
+
(serializedControl, options) => deserializeControl(serializedControl, options),
|
|
50
|
+
{ onError, plugins }
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
deserializeControl,
|
|
55
|
+
deserializeControls,
|
|
56
|
+
serializeControl,
|
|
57
|
+
serializeControls
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/builder/serialization.ts"],"sourcesContent":["import {\n type Data,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n DeserializationPlugin,\n deserializeObject,\n} from '@makeswift/controls'\n\nimport {\n type SerializedLegacyControl,\n type DeserializedLegacyControl,\n serializeLegacyControl,\n deserializeLegacyControl,\n} from '../prop-controllers/serialization'\n\nimport { type Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\n\nimport { deserializeControl as deserializeUnifiedControl } from '../controls/serialization/base'\nimport {\n type DeserializedFunction,\n type SerializedFunction,\n ClientMessagePortSerializationVisitor,\n functionDeserializationPlugin,\n} from '../controls/serialization/message-port'\n\nimport {\n type DeserializeControlRecordsOptions,\n deserializeControlRecords,\n} from '../controls/serialization'\n\nexport * from '../prop-controllers/serialization'\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport function serializeControl<T extends Data>(\n control: Descriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const messagePortVisitor = new ClientMessagePortSerializationVisitor()\n const serializedControl = control.accept(messagePortVisitor)\n return [serializedControl, messagePortVisitor.getTransferables()]\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport type DeserializeControlOptions = {\n plugins?: DeserializationPlugin<any>[]\n}\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n options?: DeserializeControlOptions,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n // Parity with controls deserialization logic below: \"preprocess\" serialized\n // legacy controls if the caller provided custom deserialization plugins\n const record = options?.plugins\n ? deserializeObject(serializedControl, options?.plugins)\n : serializedControl\n return deserializeLegacyControl(record as SerializedLegacyControl<T>)\n }\n\n const plugins = [functionDeserializationPlugin, ...(options?.plugins ?? [])]\n return deserializeUnifiedControl(serializedControl, { plugins })\n}\n\nexport function serializeControls(\n controls: Record<string, Descriptor>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n { onError, plugins }: DeserializeControlRecordsOptions = {},\n): Record<string, DeserializedControl> {\n return deserializeControlRecords<DeserializedControl>(\n serializedControls,\n (serializedControl, options) => deserializeControl(serializedControl, options),\n { onError, plugins },\n )\n}\n\ntype AnyFunction = (...args: any[]) => any\n\nexport type Serialize<T> = T extends AnyFunction\n ? SerializedFunction<T>\n : T extends Record<string, unknown>\n ? { [K in keyof T]: Serialize<T[K]> }\n : T\n\nexport type Deserialize<T> =\n T extends SerializedFunction<infer U>\n ? DeserializedFunction<U>\n : T extends Record<string, unknown>\n ? { [K in keyof T]: Deserialize<T[K]> }\n : T\n"],"mappings":"AAAA;AAAA,EAKE;AAAA,OACK;AAEP;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAA0B,0BAA0B;AAEpD,SAAS,sB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m/client/index.js
CHANGED
|
@@ -196,7 +196,7 @@ Received "${apiKey}" instead.`
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
this.graphqlClient = new GraphQLClient(new URL("graphql", apiOrigin).href, {
|
|
199
|
-
"makeswift-runtime-version": "0.26.
|
|
199
|
+
"makeswift-runtime-version": "0.26.5"
|
|
200
200
|
});
|
|
201
201
|
this.runtime = runtime;
|
|
202
202
|
}
|
|
@@ -205,7 +205,7 @@ Received "${apiKey}" instead.`
|
|
|
205
205
|
const requestHeaders = new Headers({
|
|
206
206
|
"x-api-key": this.apiKey,
|
|
207
207
|
"makeswift-site-api-key": this.apiKey,
|
|
208
|
-
"makeswift-runtime-version": "0.26.
|
|
208
|
+
"makeswift-runtime-version": "0.26.5"
|
|
209
209
|
});
|
|
210
210
|
if (siteVersion?.token) {
|
|
211
211
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -652,7 +652,7 @@ Received "${apiKey}" instead.`
|
|
|
652
652
|
headers: {
|
|
653
653
|
"x-api-key": this.apiKey,
|
|
654
654
|
"makeswift-site-api-key": this.apiKey,
|
|
655
|
-
"makeswift-runtime-version": "0.26.
|
|
655
|
+
"makeswift-runtime-version": "0.26.5",
|
|
656
656
|
"content-type": "application/json"
|
|
657
657
|
},
|
|
658
658
|
body: JSON.stringify({ token }),
|