@makeswift/runtime 0.28.6-canary.6 → 0.28.7-canary.0
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.map +1 -0
- package/dist/cjs/api/fragments.js.map +1 -0
- package/dist/cjs/api/graphql/client.js.map +1 -0
- package/dist/cjs/api/graphql/documents/index.js.map +1 -0
- package/dist/cjs/api/index.js.map +1 -0
- package/dist/cjs/api/site-version/index.js.map +1 -0
- package/dist/cjs/api-handler/cookies.js.map +1 -0
- package/dist/cjs/api-handler/cors.js.map +1 -0
- package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -0
- package/dist/cjs/api-handler/handlers/fonts.js.map +1 -0
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/api-handler/handlers/webhook/index.js.map +1 -0
- package/dist/cjs/api-handler/index.js.map +1 -0
- package/dist/cjs/builder/breakpoints/index.js.map +1 -0
- package/dist/cjs/builder/core/index.js.map +1 -0
- package/dist/cjs/builder/host-api.js.map +1 -0
- package/dist/cjs/builder/host-to-builder-actions.js.map +1 -0
- package/dist/cjs/builder/index.js.map +1 -0
- package/dist/cjs/builder/unstructured-introspection/__fixtures__/index.js.map +1 -0
- package/dist/cjs/builder/unstructured-introspection/index.js.map +1 -0
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/components/builtin/Box/index.js.map +1 -0
- package/dist/cjs/components/builtin/Button/index.js.map +1 -0
- package/dist/cjs/components/builtin/Carousel/index.js.map +1 -0
- package/dist/cjs/components/builtin/Countdown/index.js.map +1 -0
- package/dist/cjs/components/builtin/Divider/index.js.map +1 -0
- package/dist/cjs/components/builtin/Embed/index.js.map +1 -0
- package/dist/cjs/components/builtin/Form/index.js.map +1 -0
- package/dist/cjs/components/builtin/Image/Image.js.map +1 -0
- package/dist/cjs/components/builtin/Image/index.js.map +1 -0
- package/dist/cjs/components/builtin/Navigation/index.js.map +1 -0
- package/dist/cjs/components/builtin/Root/index.js.map +1 -0
- package/dist/cjs/components/builtin/Slot/index.js.map +1 -0
- package/dist/cjs/components/builtin/SocialLinks/index.js.map +1 -0
- package/dist/cjs/components/builtin/Text/index.js.map +1 -0
- package/dist/cjs/components/builtin/Video/index.js.map +1 -0
- package/dist/cjs/components/builtin/constants.js.map +1 -0
- package/dist/cjs/components/hooks/index.js.map +1 -0
- package/dist/cjs/components/shared/BackgroundsContainer/index.js.map +1 -0
- package/dist/cjs/components/shared/ErrorBoundary.js.map +1 -0
- package/dist/cjs/components/shared/FallbackComponent/FallbackComponent.js +3 -2
- package/dist/cjs/components/shared/FallbackComponent/FallbackComponent.js.map +1 -1
- package/dist/cjs/components/shared/FallbackComponent/index.js.map +1 -0
- package/dist/cjs/components/shared/GutterContainer/index.js.map +1 -0
- package/dist/cjs/components/shared/Link/index.js.map +1 -0
- package/dist/cjs/components/shared/grid-item.js.map +1 -0
- package/dist/cjs/components/utils/drop-first.js.map +1 -0
- package/dist/cjs/controls/control.js.map +1 -0
- package/dist/cjs/controls/index.js +4 -0
- package/dist/cjs/controls/index.js.map +1 -0
- package/dist/cjs/controls/rich-text/index.js.map +1 -0
- package/dist/cjs/controls/rich-text-v2/index.js.map +1 -0
- package/dist/cjs/controls/serialization/base/index.js +1 -0
- package/dist/cjs/controls/serialization/base/index.js.map +1 -0
- package/dist/cjs/controls/serialization/index.js.map +1 -0
- package/dist/cjs/controls/serialization/message-port/index.js.map +1 -0
- package/dist/cjs/controls/style-v2/index.js.map +1 -0
- package/dist/cjs/global.d.js.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/next/api-handler/index.js.map +1 -0
- package/dist/cjs/next/client.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/app-router/index.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/pages-router/index.js.map +1 -0
- package/dist/cjs/next/document.js.map +1 -0
- package/dist/cjs/next/fetch.js.map +1 -0
- package/dist/cjs/next/index.js.map +1 -0
- package/dist/cjs/next/middleware/index.js.map +1 -0
- package/dist/cjs/next/testing/element-data.js.map +1 -0
- package/dist/cjs/next/testing/index.js.map +1 -0
- package/dist/cjs/prop-controllers/copy.js.map +1 -0
- package/dist/cjs/prop-controllers/deleted.js.map +1 -0
- package/dist/cjs/prop-controllers/descriptors.js.map +1 -0
- package/dist/cjs/react/builtins/countdown.js.map +1 -0
- package/dist/cjs/react/builtins/divider.js.map +1 -0
- package/dist/cjs/react/builtins/embed.js.map +1 -0
- package/dist/cjs/react/builtins/form.js.map +1 -0
- package/dist/cjs/react/builtins/image.js.map +1 -0
- package/dist/cjs/react/builtins/index.js.map +1 -0
- package/dist/cjs/react/core/index.js.map +1 -0
- package/dist/cjs/react/index.js.map +1 -0
- package/dist/cjs/runtimes/react/components/index.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/index.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/rich-text/components/Element/inline.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/rich-text/components/Leaf/leaf.js.map +1 -0
- package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -0
- package/dist/cjs/runtimes/react/find-dom-node.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +5 -32
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/cjs/runtimes/react/host-api-client.js.map +1 -0
- package/dist/cjs/runtimes/react/index.js.map +1 -0
- package/dist/cjs/runtimes/react/legacy-controls.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/slate/BlockPlugin/indent.js.map +1 -0
- package/dist/cjs/slate/BlockPlugin/index.js.map +1 -0
- package/dist/cjs/slate/BuilderPlugin/index.js.map +1 -0
- package/dist/cjs/slate/InlineModePlugin/index.js.map +1 -0
- package/dist/cjs/slate/InlinePlugin/getValue.js.map +1 -0
- package/dist/cjs/slate/InlinePlugin/index.js.map +1 -0
- package/dist/cjs/slate/LinkPlugin/getValue.js.map +1 -0
- package/dist/cjs/slate/LinkPlugin/index.js.map +1 -0
- package/dist/cjs/slate/LocalChangesPlugin/index.js.map +1 -0
- package/dist/cjs/slate/TextAlignPlugin/getValue.js.map +1 -0
- package/dist/cjs/slate/TextAlignPlugin/index.js.map +1 -0
- package/dist/cjs/slate/TypographyPlugin/getValue.js.map +1 -0
- package/dist/cjs/slate/TypographyPlugin/index.js.map +1 -0
- package/dist/cjs/slate/index.js.map +1 -0
- package/dist/cjs/slate/utils/editor.js.map +1 -0
- package/dist/cjs/slate/utils/element.js.map +1 -0
- package/dist/cjs/slate/utils/filterForSubtreeRoots.js.map +1 -0
- package/dist/cjs/slate/utils/index.js.map +1 -0
- package/dist/cjs/state/actions/index.js.map +1 -0
- package/dist/cjs/state/actions/internal/index.js.map +1 -0
- package/dist/cjs/state/host-api.js.map +1 -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.map +1 -0
- package/dist/cjs/state/modules/element-trees.js.map +1 -0
- package/dist/cjs/state/modules/is-in-builder.js.map +1 -0
- package/dist/cjs/state/modules/is-read-only.js.map +1 -0
- package/dist/cjs/testing/fixtures.js.map +1 -0
- package/dist/cjs/translations/index.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js.map +1 -0
- package/dist/cjs/utils/deepEqual.js.map +1 -0
- package/dist/cjs/utils/deferred.js.map +1 -0
- package/dist/cjs/utils/deterministic-uuid.js.map +1 -0
- package/dist/cjs/utils/esm-compat.js.map +1 -0
- package/dist/cjs/utils/is-server.js.map +1 -0
- package/dist/cjs/utils/isNonNullable.js.map +1 -0
- package/dist/esm/api/graphql/documents/queries.js.map +1 -0
- package/dist/esm/api/graphql/generated/types.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/api-handler/handlers/webhook/site-published.js.map +1 -0
- package/dist/esm/api-handler/handlers/webhook/types.js.map +1 -0
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/components/builtin/Box/register.js.map +1 -0
- package/dist/esm/components/builtin/Button/register.js.map +1 -0
- package/dist/esm/components/builtin/Carousel/register.js.map +1 -0
- package/dist/esm/components/builtin/Countdown/register.js.map +1 -0
- package/dist/esm/components/builtin/Divider/register.js.map +1 -0
- package/dist/esm/components/builtin/Embed/register.js.map +1 -0
- package/dist/esm/components/builtin/Form/components/Field/services/responsiveField.js.map +1 -0
- package/dist/esm/components/builtin/Form/register.js.map +1 -0
- package/dist/esm/components/builtin/Form/types.js.map +1 -0
- package/dist/esm/components/builtin/Image/register.js.map +1 -0
- package/dist/esm/components/builtin/Navigation/register.js.map +1 -0
- package/dist/esm/components/builtin/Root/Root.js.map +1 -0
- package/dist/esm/components/builtin/Root/register.js.map +1 -0
- package/dist/esm/components/builtin/Slot/Slot.js.map +1 -0
- package/dist/esm/components/builtin/Slot/register.js.map +1 -0
- package/dist/esm/components/builtin/SocialLinks/SocialLinks.js.map +1 -0
- package/dist/esm/components/builtin/SocialLinks/options.js.map +1 -0
- package/dist/esm/components/builtin/SocialLinks/register.js.map +1 -0
- package/dist/esm/components/builtin/Text/Text.js.map +1 -0
- package/dist/esm/components/builtin/Text/register.js.map +1 -0
- package/dist/esm/components/builtin/Video/Video.js +49 -0
- package/dist/esm/components/builtin/Video/Video.js.map +1 -0
- package/dist/esm/components/builtin/Video/register.js.map +1 -0
- package/dist/esm/components/hooks/useTableFormFieldsPropControllerData.js +10 -0
- package/dist/esm/components/hooks/useTablePropControllerData.js +12 -0
- package/dist/esm/components/hooks/useTextAreaPropControllerData.js +12 -0
- package/dist/esm/components/hooks/useTextInputPropControllerData.js +10 -0
- package/dist/esm/components/hooks/useTextStylePropControllerData.js +12 -0
- package/dist/esm/components/hooks/useVideoPropControllerData.js +12 -0
- package/dist/esm/components/icons/Warning20.js +15 -0
- package/dist/esm/components/shared/FallbackComponent/FallbackComponent.js +3 -2
- package/dist/esm/components/shared/FallbackComponent/FallbackComponent.js.map +1 -1
- package/dist/esm/controls/index.js +4 -0
- package/dist/esm/controls/index.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/translations/merge-translations.js.map +1 -0
- package/dist/esm/controls/rich-text-v2/translations/translations-core.js.map +1 -0
- package/dist/esm/controls/serialization/base/index.js +2 -0
- package/dist/esm/controls/serialization/base/index.js.map +1 -1
- 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/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.map +1 -0
- package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/page-document.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js.map +1 -0
- package/dist/esm/next/components/tests/controls/fixtures/rich-text-v2.js.map +1 -0
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -0
- package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -0
- package/dist/esm/next/hooks/use-router-locale-sync.js.map +1 -0
- package/dist/esm/next/tests/__fixtures__/resources.js.map +1 -0
- package/dist/esm/next/tests/__fixtures__/translated-data.js.map +1 -0
- package/dist/esm/react/builtins/video.js +7 -0
- package/dist/esm/react/builtins/video.js.map +1 -0
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -0
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -0
- package/dist/esm/runtimes/react/components/Slot.js.map +1 -0
- package/dist/esm/runtimes/react/components/SlotProvider.js.map +1 -0
- package/dist/esm/runtimes/react/components/hooks/use-framework-context.js.map +1 -0
- package/dist/esm/runtimes/react/components/hooks/use-page-snippets.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/Page.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/PageHead.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/page-seo-settings.js.map +1 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
- package/dist/esm/runtimes/react/components/render-hook.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.js +39 -0
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +35 -0
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js +39 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +1 -0
- package/dist/esm/runtimes/react/controls/slot.js.map +1 -0
- package/dist/esm/runtimes/react/controls/style.js.map +1 -0
- package/dist/esm/runtimes/react/controls/typography.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-breakpoints.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-builtin-suspense.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-component.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-css-id.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-disable-register-element.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-dispatch.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-document-context.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-document-cycles.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-document.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-element-id.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-is-read-only.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-react-runtime.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-register-document.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolvable-record.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-value.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +5 -34
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-universal-dispatch.js.map +1 -0
- package/dist/esm/runtimes/react/lib/react-dom.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.map +1 -0
- package/dist/esm/runtimes/react/use-global-style.js.map +1 -0
- package/dist/esm/runtimes/react/use-style.js.map +1 -0
- package/dist/esm/runtimes/react/utils/prop-error-handling-proxy.js.map +1 -0
- package/dist/esm/runtimes/react/utils/suppress-ref-warning.js.map +1 -0
- package/dist/esm/slate/BlockPlugin/utils/location.js.map +1 -0
- package/dist/esm/slate/BlockPlugin/wrapInline.js +12 -0
- package/dist/esm/slate/BlockPlugin/wrapInline.js.map +1 -0
- package/dist/esm/slate/BlockPlugin/wrapList.js +44 -0
- package/dist/esm/slate/BlockPlugin/wrapList.js.map +1 -0
- package/dist/esm/slate/utils/responsive.js.map +1 -0
- package/dist/esm/slate/utils/toText.js.map +1 -0
- package/dist/esm/slate/utils/unhangRange.js.map +1 -0
- package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -0
- package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -0
- package/dist/esm/state/builder-api/proxy.js.map +1 -0
- package/dist/esm/state/middleware/read-only-element-tree.js.map +1 -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.map +1 -0
- package/dist/esm/state/middleware/read-write/update-element-tree.js.map +1 -0
- package/dist/esm/state/modules/prop-controllers.js.map +1 -0
- package/dist/esm/state/modules/react-components.js.map +1 -0
- package/dist/esm/state/modules/read-only-documents.js.map +1 -0
- package/dist/esm/state/modules/read-write/pointer.js.map +1 -0
- package/dist/esm/state/modules/read-write/read-write-documents.js.map +1 -0
- package/dist/esm/state/modules/site-version.js.map +1 -0
- package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts +1 -0
- package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts.map +1 -1
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/serialization/base/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.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/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolvable-record.tsx"],"sourcesContent":["import { type Resolvable } from '@makeswift/controls'\nimport { useMemo, useRef } from 'react'\n\ntype Snapshot = {\n resolvedValues: Record<string, unknown>\n dirtyProps: Set<string>\n}\n\nexport function useResolvableRecord(\n resolvables: Record<string, Resolvable<unknown>>,\n): Resolvable<Record<string, unknown>> {\n const snapshot = useRef<Snapshot>({ resolvedValues: {}, dirtyProps: new Set() })\n\n return useMemo<Resolvable<Record<string, unknown>>>(() => {\n return {\n name: 'resolvable-record',\n subscribe: (onUpdate: () => void): (() => void) => {\n const unsubscribes = Object.values(resolvables).map(s => s.subscribe(onUpdate))\n return () => {\n unsubscribes.forEach(u => u())\n }\n },\n\n readStable: () => {\n const nextSnapshot = Object.entries(resolvables).reduce<Snapshot>(\n ({ dirtyProps, resolvedValues }, [propName, subscription]) => {\n const lastPropValue = snapshot.current.resolvedValues[propName]\n const propValue = subscription.readStable()\n const isDirty = propValue !== lastPropValue\n\n return {\n dirtyProps: isDirty ? dirtyProps.add(propName) : dirtyProps,\n resolvedValues: { ...resolvedValues, [propName]: propValue },\n }\n },\n { resolvedValues: {}, dirtyProps: new Set() },\n )\n\n if (nextSnapshot.dirtyProps.size > 0) {\n snapshot.current = nextSnapshot\n }\n\n return snapshot.current.resolvedValues\n },\n\n triggerResolve: async () => {\n // While we _could_ only trigger resolution on the dirty props, this is\n // not an airtight solution. Some controls will resolve to nullish\n // values even when the underlying data changes, so they won't be dirty\n // (ex: an Image control where the data changes from `undefined` to a\n // file that has not yet been fetched). Even if you add a nullish check\n // on the resolved value, some controls can resolve to non-nullish value\n // when the resolution does not occur (ex: swatches can resolve to\n // black). The true solution is to trigger resolve on underlying data\n // change, and moving these dirtiness optimizations for resolution\n // triggering at the control level.\n return await Promise.all(\n Object.entries(resolvables).map(([propName, sub]) =>\n sub.triggerResolve(snapshot.current.resolvedValues[propName]),\n ),\n )\n },\n }\n }, [resolvables])\n}\n"],"mappings":"AACA,SAAS,SAAS,cAAc;AAOzB,SAAS,oBACd,aACqC;AACrC,QAAM,WAAW,OAAiB,EAAE,gBAAgB,CAAC,GAAG,YAAY,oBAAI,IAAI,EAAE,CAAC;AAE/E,SAAO,QAA6C,MAAM;AACxD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW,CAAC,aAAuC;AACjD,cAAM,eAAe,OAAO,OAAO,WAAW,EAAE,IAAI,OAAK,EAAE,UAAU,QAAQ,CAAC;AAC9E,eAAO,MAAM;AACX,uBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,QAC/B;AAAA,MACF;AAAA,MAEA,YAAY,MAAM;AAChB,cAAM,eAAe,OAAO,QAAQ,WAAW,EAAE;AAAA,UAC/C,CAAC,EAAE,YAAY,eAAe,GAAG,CAAC,UAAU,YAAY,MAAM;AAC5D,kBAAM,gBAAgB,SAAS,QAAQ,eAAe,QAAQ;AAC9D,kBAAM,YAAY,aAAa,WAAW;AAC1C,kBAAM,UAAU,cAAc;AAE9B,mBAAO;AAAA,cACL,YAAY,UAAU,WAAW,IAAI,QAAQ,IAAI;AAAA,cACjD,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,QAAQ,GAAG,UAAU;AAAA,YAC7D;AAAA,UACF;AAAA,UACA,EAAE,gBAAgB,CAAC,GAAG,YAAY,oBAAI,IAAI,EAAE;AAAA,QAC9C;AAEA,YAAI,aAAa,WAAW,OAAO,GAAG;AACpC,mBAAS,UAAU;AAAA,QACrB;AAEA,eAAO,SAAS,QAAQ;AAAA,MAC1B;AAAA,MAEA,gBAAgB,YAAY;AAW1B,eAAO,MAAM,QAAQ;AAAA,UACnB,OAAO,QAAQ,WAAW,EAAE;AAAA,YAAI,CAAC,CAAC,UAAU,GAAG,MAC7C,IAAI,eAAe,SAAS,QAAQ,eAAe,QAAQ,CAAC;AAAA,UAC9D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAClB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport * as ReactPage from '../../../state/read-only-state'\nimport { useResourceResolver } from './use-resource-resolver'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nimport { useStylesheetFactory } from './use-stylesheet-factory'\n\nimport { useResolvableRecord } from './use-resolvable-record'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nfunction useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return ReactPage.getPropControllers(state, { documentKey, elementKey })\n })\n}\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps(\n propDefs: Record<string, ControlDefinition>,\n elementData: Record<string, Data>,\n elementKey: string,\n): Record<string, unknown> {\n const stylesheetFactory = useStylesheetFactory()\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = elementData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, elementData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,YAAY,eAAe;AAC3B,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAE5B,SAAS,4BAA4B;AAErC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AAEvC,SAAS,oBAAoB,YAA4D;AACvF,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,WAAO,UAAU,mBAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EACxE,CAAC;AACH;AAQO,SAAS,iBACd,UACA,aACA,YACyB;AACzB,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,WAAW,oBAAoB,UAAU;AAE/C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,YAAY,QAAQ;AACjC,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,aAAa,kBAAkB,iBAAiB;AAAA,EAC7D;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-value.ts"],"sourcesContent":["import { useMemo, useEffect, useSyncExternalStore } from 'react'\nimport { Resolvable, ResourceResolver } from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nexport function useResolvedValue<D, T>(\n data: D,\n resolver: (data: D, resourceResolver: ResourceResolver) => Resolvable<T>,\n defaultValue?: T,\n): T | undefined {\n const resourceResolver = useResourceResolver()\n const resolvable = useMemo(() => {\n return propErrorHandlingProxy(resolver(data, resourceResolver), defaultValue, error => {\n console.warn(`Error resolving data, falling back to \\`${defaultValue}\\`.`, { error, data })\n })\n }, [data, resourceResolver, defaultValue])\n\n useEffect(() => {\n resolvable.triggerResolve()\n }, [resolvable])\n\n return useSyncExternalStore(resolvable.subscribe, resolvable.readStable, resolvable.readStable)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,4BAA4B;AAGzD,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AAEhC,SAAS,iBACd,MACA,UACA,cACe;AACf,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,aAAa,QAAQ,MAAM;AAC/B,WAAO,uBAAuB,SAAS,MAAM,gBAAgB,GAAG,cAAc,WAAS;AACrF,cAAQ,KAAK,2CAA2C,YAAY,OAAO,EAAE,OAAO,KAAK,CAAC;AAAA,IAC5F,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,kBAAkB,YAAY,CAAC;AAEzC,YAAU,MAAM;AACd,eAAW,eAAe;AAAA,EAC5B,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,qBAAqB,WAAW,WAAW,WAAW,YAAY,WAAW,UAAU;AAChG;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resource-resolver.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type ResourceResolver } from '@makeswift/controls'\n\nimport * as ReactPage from '../../../state/read-only-state'\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useStore } from './use-store'\nimport { useDocumentKey, useDocumentLocale } from './use-document-context'\n\nexport function useResourceResolver(): ResourceResolver {\n const store = useStore()\n const client = useMakeswiftHostApiClient()\n\n const documentKey = useDocumentKey()\n const locale = useDocumentLocale()\n\n return useMemo<ResourceResolver>(() => {\n return {\n resolveSwatch: swatchId => client.resolveSwatch(swatchId),\n resolveFile: fileId => client.resolveFile(fileId),\n resolveTypography: typographyId => client.resolveTypography(typographyId),\n resolvePagePathnameSlice: pageId => client.resolvePagePathnameSlice({ pageId, locale }),\n resolveElementId: elementKey => {\n const read = () =>\n documentKey == null\n ? null\n : ReactPage.getElementId(store.getState(), documentKey, elementKey)\n\n let lastValue: string | null = null\n return {\n name: `element-id:${documentKey}:${elementKey}`,\n readStable: () => (lastValue = read()),\n subscribe: (onUpdate: () => void) =>\n store.subscribe(() => {\n if (read() !== lastValue) onUpdate()\n }),\n }\n },\n }\n }, [client, store, documentKey, locale])\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAGxB,YAAY,eAAe;AAC3B,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,yBAAyB;AAE3C,SAAS,sBAAwC;AACtD,QAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,0BAA0B;AAEzC,QAAM,cAAc,eAAe;AACnC,QAAM,SAAS,kBAAkB;AAEjC,SAAO,QAA0B,MAAM;AACrC,WAAO;AAAA,MACL,eAAe,cAAY,OAAO,cAAc,QAAQ;AAAA,MACxD,aAAa,YAAU,OAAO,YAAY,MAAM;AAAA,MAChD,mBAAmB,kBAAgB,OAAO,kBAAkB,YAAY;AAAA,MACxE,0BAA0B,YAAU,OAAO,yBAAyB,EAAE,QAAQ,OAAO,CAAC;AAAA,MACtF,kBAAkB,gBAAc;AAC9B,cAAM,OAAO,MACX,eAAe,OACX,OACA,UAAU,aAAa,MAAM,SAAS,GAAG,aAAa,UAAU;AAEtE,YAAI,YAA2B;AAC/B,eAAO;AAAA,UACL,MAAM,cAAc,WAAW,IAAI,UAAU;AAAA,UAC7C,YAAY,MAAO,YAAY,KAAK;AAAA,UACpC,WAAW,CAAC,aACV,MAAM,UAAU,MAAM;AACpB,gBAAI,KAAK,MAAM;AAAW,uBAAS;AAAA,UACrC,CAAC;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,aAAa,MAAM,CAAC;AACzC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'\n\nimport { useStore } from './use-store'\nimport { type State as ReadOnlyState } from '../../../state/read-only-state'\nimport { type State as ReadWriteState } from '../../../state/read-write-state'\n\ntype State = ReadOnlyState | ReadWriteState\n\nexport function useSelector<R>(selector: (state: State) => R): R {\n const store = useStore()\n\n return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector)\n}\n"],"mappings":"AAAA,SAAS,wCAAwC;AAEjD,SAAS,gBAAgB;AAMlB,SAAS,YAAe,UAAkC;AAC/D,QAAM,QAAQ,SAAS;AAEvB,SAAO,iCAAiC,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,QAAQ;AACnG;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-store.ts"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\nimport { type Store } from '../../../state/store'\n\nexport const StoreContext = createContext<Store | null>(null)\n\nexport function useStore(): Store {\n const store = useContext(StoreContext)\n if (store == null) {\n throw new Error('`useStore` must be used within a `StoreProvider`')\n }\n\n return store\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAGnC,MAAM,eAAe,cAA4B,IAAI;AAErD,SAAS,WAAkB;AAChC,QAAM,QAAQ,WAAW,YAAY;AACrC,MAAI,SAAS,MAAM;AACjB,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useMemo, useEffect, useRef } from "react";
|
|
2
2
|
import { serializeStyles } from "@emotion/serialize";
|
|
3
3
|
import {
|
|
4
|
-
isNotNil
|
|
5
|
-
getBaseBreakpoint,
|
|
6
|
-
getBreakpointMediaQuery
|
|
4
|
+
isNotNil
|
|
7
5
|
} from "@makeswift/controls";
|
|
8
6
|
import { useCache } from "../root-style-registry";
|
|
9
|
-
import {
|
|
10
|
-
import { typographyCss } from "../controls/typography";
|
|
7
|
+
import { resolvedStyleToCss } from "../lib/resolved-style-to-css";
|
|
11
8
|
import { useBreakpoints } from "./use-breakpoints";
|
|
12
9
|
import { useCssId } from "./use-css-id";
|
|
13
10
|
import { useStyles, serializedStyleClassName } from "../use-style";
|
|
@@ -17,7 +14,9 @@ function useStylesheetFactory() {
|
|
|
17
14
|
const cache = useCache();
|
|
18
15
|
const componentUid = useCssId();
|
|
19
16
|
const computedStyles = useRef({}).current;
|
|
20
|
-
const boxModelCallbacks = useRef(
|
|
17
|
+
const boxModelCallbacks = useRef(
|
|
18
|
+
{}
|
|
19
|
+
).current;
|
|
21
20
|
return useMemo(() => {
|
|
22
21
|
const getStylesheet = (styleSheetId) => ({
|
|
23
22
|
breakpoints() {
|
|
@@ -56,34 +55,6 @@ function useStylesheetFactory() {
|
|
|
56
55
|
};
|
|
57
56
|
}, [breakpoints, cache, componentUid]);
|
|
58
57
|
}
|
|
59
|
-
function isTypographyStyle(style) {
|
|
60
|
-
return Array.isArray(style);
|
|
61
|
-
}
|
|
62
|
-
function isStyleV2(style) {
|
|
63
|
-
return typeof style === "object" && "getStyle" in style && typeof style.getStyle === "function";
|
|
64
|
-
}
|
|
65
|
-
function styleV2Css(breakpoints, style) {
|
|
66
|
-
return {
|
|
67
|
-
...style.getStyle(getBaseBreakpoint(breakpoints)),
|
|
68
|
-
...breakpoints.reduce(
|
|
69
|
-
(styles, breakpoint) => ({
|
|
70
|
-
...styles,
|
|
71
|
-
[getBreakpointMediaQuery(breakpoint)]: style.getStyle(breakpoint)
|
|
72
|
-
}),
|
|
73
|
-
{}
|
|
74
|
-
)
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function resolvedStyleToCss(breakpoints, style) {
|
|
78
|
-
if (isTypographyStyle(style)) {
|
|
79
|
-
return typographyCss(breakpoints, style);
|
|
80
|
-
}
|
|
81
|
-
if (isStyleV2(style)) {
|
|
82
|
-
return styleV2Css(breakpoints, style);
|
|
83
|
-
}
|
|
84
|
-
const { properties, styleData } = style;
|
|
85
|
-
return styleV1Css(breakpoints, styleData, properties);
|
|
86
|
-
}
|
|
87
58
|
function serializeStyle(breakpoints, style, cache) {
|
|
88
59
|
const css = resolvedStyleToCss(breakpoints, style);
|
|
89
60
|
return serializeStyles([css], cache.registered);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport { useCache } from '../root-style-registry'\nimport { resolvedStyleToCss } from '../lib/resolved-style-to-css'\n\nimport { useBreakpoints } from './use-breakpoints'\nimport { useCssId } from './use-css-id'\nimport { useStyles, serializedStyleClassName } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport type StylesheetFactory = {\n get(propName: string): Stylesheet\n useDefinedStyles(): void\n}\n\nexport function useStylesheetFactory(): StylesheetFactory {\n const breakpoints = useBreakpoints()\n const cache = useCache()\n const componentUid = useCssId()\n\n const computedStyles = useRef<Record<string, SerializedStyles>>({}).current\n const boxModelCallbacks = useRef<Record<string, (boxModel: BoxDisplayModel | null) => void>>(\n {},\n ).current\n\n return useMemo(() => {\n const getStylesheet = (styleSheetId: string): Stylesheet => ({\n breakpoints(): Breakpoints {\n return breakpoints\n },\n\n defineStyle(\n style: ResolvedStyle,\n onBoxModelChange?: (boxModel: BoxDisplayModel | null) => void,\n ): string {\n const serialized = serializeStyle(breakpoints, style, cache)\n const uid = `u-${componentUid}-${styleSheetId}`\n computedStyles[uid] = serialized\n\n const className = serializedStyleClassName(cache, serialized)\n if (!onBoxModelChange) return className\n\n boxModelCallbacks[uid] = onBoxModelChange\n return `${className} ${uid}`\n },\n\n child(id: string): Stylesheet {\n return getStylesheet(`${styleSheetId}-${id}`)\n },\n })\n\n return {\n get(propName: string): Stylesheet {\n return getStylesheet(propName)\n },\n\n useDefinedStyles() {\n useStyles(cache, Object.values(computedStyles))\n\n useEffect(() => {\n const unsubscribes = Object.entries(boxModelCallbacks)\n .map(([uid, callback]) =>\n callback != null\n ? pollBoxModel({\n element: document.querySelector(`.${uid}`),\n onBoxModelChange: callback,\n })\n : undefined,\n )\n .filter(isNotNil)\n\n return () => unsubscribes.forEach(fn => fn())\n }, [Object.keys(boxModelCallbacks).join(' ')])\n },\n }\n }, [breakpoints, cache, componentUid])\n}\n\nfunction serializeStyle(\n breakpoints: Breakpoints,\n style: ResolvedStyle,\n cache: EmotionCache,\n): SerializedStyles {\n const css = resolvedStyleToCss(breakpoints, style)\n return serializeStyles([css], cache.registered)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,cAAc;AAC3C,SAAS,uBAAuB;AAIhC;AAAA,EAKE;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,WAAW,gCAAgC;AACpD,SAAS,oBAAoB;AAOtB,SAAS,uBAA0C;AACxD,QAAM,cAAc,eAAe;AACnC,QAAM,QAAQ,SAAS;AACvB,QAAM,eAAe,SAAS;AAE9B,QAAM,iBAAiB,OAAyC,CAAC,CAAC,EAAE;AACpE,QAAM,oBAAoB;AAAA,IACxB,CAAC;AAAA,EACH,EAAE;AAEF,SAAO,QAAQ,MAAM;AACnB,UAAM,gBAAgB,CAAC,kBAAsC;AAAA,MAC3D,cAA2B;AACzB,eAAO;AAAA,MACT;AAAA,MAEA,YACE,OACA,kBACQ;AACR,cAAM,aAAa,eAAe,aAAa,OAAO,KAAK;AAC3D,cAAM,MAAM,KAAK,YAAY,IAAI,YAAY;AAC7C,uBAAe,GAAG,IAAI;AAEtB,cAAM,YAAY,yBAAyB,OAAO,UAAU;AAC5D,YAAI,CAAC;AAAkB,iBAAO;AAE9B,0BAAkB,GAAG,IAAI;AACzB,eAAO,GAAG,SAAS,IAAI,GAAG;AAAA,MAC5B;AAAA,MAEA,MAAM,IAAwB;AAC5B,eAAO,cAAc,GAAG,YAAY,IAAI,EAAE,EAAE;AAAA,MAC9C;AAAA,IACF;AAEA,WAAO;AAAA,MACL,IAAI,UAA8B;AAChC,eAAO,cAAc,QAAQ;AAAA,MAC/B;AAAA,MAEA,mBAAmB;AACjB,kBAAU,OAAO,OAAO,OAAO,cAAc,CAAC;AAE9C,kBAAU,MAAM;AACd,gBAAM,eAAe,OAAO,QAAQ,iBAAiB,EAClD;AAAA,YAAI,CAAC,CAAC,KAAK,QAAQ,MAClB,YAAY,OACR,aAAa;AAAA,cACX,SAAS,SAAS,cAAc,IAAI,GAAG,EAAE;AAAA,cACzC,kBAAkB;AAAA,YACpB,CAAC,IACD;AAAA,UACN,EACC,OAAO,QAAQ;AAElB,iBAAO,MAAM,aAAa,QAAQ,QAAM,GAAG,CAAC;AAAA,QAC9C,GAAG,CAAC,OAAO,KAAK,iBAAiB,EAAE,KAAK,GAAG,CAAC,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,YAAY,CAAC;AACvC;AAEA,SAAS,eACP,aACA,OACA,OACkB;AAClB,QAAM,MAAM,mBAAmB,aAAa,KAAK;AACjD,SAAO,gBAAgB,CAAC,GAAG,GAAG,MAAM,UAAU;AAChD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-universal-dispatch.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport type { ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Dispatch } from '../../../state/read-only-state'\nimport { type Action } from '../../../state/actions'\n\nimport { isServer } from '../../../utils/is-server'\n\n// overloaded signatures\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => A,\n args: Args,\n): void\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => ThunkAction<() => void, any, any, A>,\n args: Args,\n): void\n// implementation\nexport function useUniversalDispatch<Args extends any[], A extends Action>(\n dispatch: Dispatch,\n action: (...args: Args) => ThunkAction<() => void, any, any, A>,\n args: Args,\n) {\n if (isServer()) {\n dispatch(action(...args))\n }\n\n useEffect(() => {\n dispatch(action(...args))\n }, [dispatch, action, ...args])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAM1B,SAAS,gBAAgB;AAclB,SAAS,qBACd,UACA,QACA,MACA;AACA,MAAI,SAAS,GAAG;AACd,aAAS,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1B;AAEA,YAAU,MAAM;AACd,aAAS,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1B,GAAG,CAAC,UAAU,QAAQ,GAAG,IAAI,CAAC;AAChC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/lib/react-dom.ts"],"sourcesContent":["import { type Component } from 'react'\nimport ReactDOM from 'react-dom'\n\ntype FindDOMNodeFn = (instance: Component | null | undefined) => Element | Text | null\n\ntype ReactDOMWithLegacyFindDOMNode = typeof ReactDOM & { findDOMNode?: FindDOMNodeFn }\n\n// For React 18 and below\nconst ReactDOMCompat = ReactDOM as ReactDOMWithLegacyFindDOMNode\n\n// For React 19\n// https://github.com/facebook/react/blob/main/packages/shared/ReactDOMSharedInternals.js\nconst reactDOMInternals = (ReactDOM as any)\n .__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE as {\n findDOMNode: FindDOMNodeFn\n}\n\nexport function findDOMNode(instance: Component | null | undefined): Element | Text | null {\n return ReactDOMCompat.findDOMNode\n ? ReactDOMCompat.findDOMNode(instance)\n : reactDOMInternals.findDOMNode(instance)\n}\n"],"mappings":"AACA,OAAO,cAAc;AAOrB,MAAM,iBAAiB;AAIvB,MAAM,oBAAqB,SACxB;AAII,SAAS,YAAY,UAA+D;AACzF,SAAO,eAAe,cAClB,eAAe,YAAY,QAAQ,IACnC,kBAAkB,YAAY,QAAQ;AAC5C;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBaseBreakpoint,
|
|
3
|
+
getBreakpointMediaQuery
|
|
4
|
+
} from "@makeswift/controls";
|
|
5
|
+
import { styleV1Css } from "../controls/style";
|
|
6
|
+
import { typographyCss } from "../controls/typography";
|
|
7
|
+
function isTypographyStyle(style) {
|
|
8
|
+
return Array.isArray(style);
|
|
9
|
+
}
|
|
10
|
+
function isStyleV2(style) {
|
|
11
|
+
return typeof style === "object" && "getStyle" in style && typeof style.getStyle === "function";
|
|
12
|
+
}
|
|
13
|
+
function styleV2Css(breakpoints, style) {
|
|
14
|
+
return {
|
|
15
|
+
...style.getStyle(getBaseBreakpoint(breakpoints)),
|
|
16
|
+
...breakpoints.reduce(
|
|
17
|
+
(styles, breakpoint) => ({
|
|
18
|
+
...styles,
|
|
19
|
+
[getBreakpointMediaQuery(breakpoint)]: style.getStyle(breakpoint)
|
|
20
|
+
}),
|
|
21
|
+
{}
|
|
22
|
+
)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolvedStyleToCss(breakpoints, style) {
|
|
26
|
+
if (isTypographyStyle(style)) {
|
|
27
|
+
return typographyCss(breakpoints, style);
|
|
28
|
+
}
|
|
29
|
+
if (isStyleV2(style)) {
|
|
30
|
+
return styleV2Css(breakpoints, style);
|
|
31
|
+
}
|
|
32
|
+
const { properties, styleData } = style;
|
|
33
|
+
return styleV1Css(breakpoints, styleData, properties);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
resolvedStyleToCss
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=resolved-style-to-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/lib/resolved-style-to-css.ts"],"sourcesContent":["import { type CSSObject } from '@emotion/serialize'\n\nimport {\n type Breakpoints,\n type ResolvedStyle,\n type ResolvedStyleV2,\n type ResolvedTypographyStyle,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { styleV1Css } from '../controls/style'\nimport { typographyCss } from '../controls/typography'\n\nfunction isTypographyStyle(style: ResolvedStyle): style is ResolvedTypographyStyle {\n return Array.isArray(style)\n}\n\nfunction isStyleV2(style: ResolvedStyle): style is ResolvedStyleV2 {\n return typeof style === 'object' && 'getStyle' in style && typeof style.getStyle === 'function'\n}\n\nfunction styleV2Css(breakpoints: Breakpoints, style: ResolvedStyleV2<CSSObject>): CSSObject {\n return {\n ...style.getStyle(getBaseBreakpoint(breakpoints)),\n ...breakpoints.reduce(\n (styles, breakpoint) => ({\n ...styles,\n [getBreakpointMediaQuery(breakpoint)]: style.getStyle(breakpoint),\n }),\n {},\n ),\n }\n}\n\nexport function resolvedStyleToCss(breakpoints: Breakpoints, style: ResolvedStyle): CSSObject {\n if (isTypographyStyle(style)) {\n return typographyCss(breakpoints, style)\n }\n\n if (isStyleV2(style)) {\n return styleV2Css(breakpoints, style as ResolvedStyleV2<CSSObject>)\n }\n\n const { properties, styleData } = style\n return styleV1Css(breakpoints, styleData, properties)\n}\n"],"mappings":"AAEA;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAE9B,SAAS,kBAAkB,OAAwD;AACjF,SAAO,MAAM,QAAQ,KAAK;AAC5B;AAEA,SAAS,UAAU,OAAgD;AACjE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,OAAO,MAAM,aAAa;AACvF;AAEA,SAAS,WAAW,aAA0B,OAA8C;AAC1F,SAAO;AAAA,IACL,GAAG,MAAM,SAAS,kBAAkB,WAAW,CAAC;AAAA,IAChD,GAAG,YAAY;AAAA,MACb,CAAC,QAAQ,gBAAgB;AAAA,QACvB,GAAG;AAAA,QACH,CAAC,wBAAwB,UAAU,CAAC,GAAG,MAAM,SAAS,UAAU;AAAA,MAClE;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,aAA0B,OAAiC;AAC5F,MAAI,kBAAkB,KAAK,GAAG;AAC5B,WAAO,cAAc,aAAa,KAAK;AAAA,EACzC;AAEA,MAAI,UAAU,KAAK,GAAG;AACpB,WAAO,WAAW,aAAa,KAAmC;AAAA,EACpE;AAEA,QAAM,EAAE,YAAY,UAAU,IAAI;AAClC,SAAO,WAAW,aAAa,WAAW,UAAU;AACtD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { type BreakpointsInput } from '../../../state/modules/breakpoints'\nimport { TestOrigins } from '../../../testing/fixtures'\nimport { ReactRuntime } from '../react-runtime'\n\nexport function createReactRuntime({ breakpoints }: { breakpoints?: BreakpointsInput } = {}) {\n return new ReactRuntime({ fetch, breakpoints, ...TestOrigins })\n}\n"],"mappings":"AACA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAEtB,SAAS,mBAAmB,EAAE,YAAY,IAAwC,CAAC,GAAG;AAC3F,SAAO,IAAI,aAAa,EAAE,OAAO,aAAa,GAAG,YAAY,CAAC;AAChE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/use-global-style.ts"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useRef } from 'react'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nimport { useCache } from './root-style-registry'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n const cache = useCache()\n const serialized = serializeStyles(args, cache.registered)\n\n if (isServer) {\n if (cache.inserted[serialized.name] === undefined) {\n cache.insert('', serialized, cache.sheet, true)\n }\n }\n\n const sheetRef = useRef<[StyleSheet, boolean] | null>(null)\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAA2B,uBAAuB;AAElD,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAEzB,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,8BAA8B;AACpC,MAAM,qBAAqB,MAAM,2BAA2B,KAAK,MAAM;AAEhE,SAAS,kBAAkB,MAAgC;AAChE,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,gBAAgB,MAAM,MAAM,UAAU;AAEzD,MAAI,UAAU;AACZ,QAAI,MAAM,SAAS,WAAW,IAAI,MAAM,QAAW;AACjD,YAAM,OAAO,IAAI,YAAY,MAAM,OAAO,IAAI;AAAA,IAChD;AAAA,EACF;AAEA,QAAM,WAAW,OAAqC,IAAI;AAG1D,qBAAmB,MAAM;AACvB,UAAM,MAAM,GAAG,MAAM,GAAG;AAExB,UAAM,aAAa,MAAM;AACzB,UAAM,QAAQ,IAAK,WAAW,YAAkC;AAAA,MAC9D;AAAA,MACA,OAAO,WAAW;AAAA,MAClB,WAAW,WAAW;AAAA,MACtB,QAAQ,WAAW;AAAA,IACrB,CAAC;AAED,UAAM,OAAO,SAAS;AAAA,MACpB,uBAAuB,GAAG,IAAI,WAAW,IAAI;AAAA,IAC/C;AAEA,QAAI,MAAM,MAAM,KAAK,SAAS,GAAG;AAC/B,YAAM,SAAS,MAAM,MAAM,KAAK,CAAC;AAAA,IACnC;AAEA,QAAI,cAAc;AAElB,QAAI,QAAQ,MAAM;AAChB,oBAAc;AACd,WAAK,aAAa,gBAAgB,GAAG;AACrC,YAAM,QAAQ,CAAC,IAAI,CAAC;AAAA,IACtB;AAEA,aAAS,UAAU,CAAC,OAAO,WAAW;AAEtC,WAAO,MAAM;AACX,YAAM,MAAM;AAAA,IACd;AAAA,EACF,CAAC;AAGD,qBAAmB,MAAM;AACvB,UAAM,CAAC,OAAO,WAAW,IAAI,SAAS,WAAW,CAAC;AAElD,QAAI,SAAS,QAAQ,eAAe;AAAM;AAE1C,QAAI,aAAa;AACf,eAAS,UAAU,CAAC,OAAO,KAAK;AAEhC;AAAA,IACF;AAEA,QAAI,WAAW,QAAQ,MAAM;AAC3B,mBAAa,OAAO,WAAW,MAAM,IAAI;AAAA,IAC3C;AAEA,QAAI,MAAM,KAAK,SAAS,GAAG;AACzB,YAAM,UAAU,MAAM,KAAK,MAAM,KAAK,SAAS,CAAC,EAAE;AAElD,YAAM,SAAS;AAEf,YAAM,MAAM;AAAA,IACd;AAEA,UAAM,OAAO,IAAI,YAAY,OAAO,KAAK;AAAA,EAC3C,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/use-style.ts"],"sourcesContent":["import React from 'react'\nimport { type CSSObject } from '@emotion/serialize'\nimport { EmotionCache } from '@emotion/cache'\nimport { serializeStyles } from '@emotion/serialize'\nimport { registerStyles, insertStyles, type SerializedStyles } from '@emotion/utils'\n\nimport { isServer } from '../../utils/is-server'\n\nimport { useCache } from './root-style-registry'\n\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useStyle(style: CSSObject): string {\n const cache = useCache()\n const serialized = serializeStyles([style], cache.registered)\n\n registerStyles(cache, serialized, false)\n\n useUniversalInsertionEffect(() => {\n insertStyles(cache, serialized, false)\n })\n\n return serializedStyleClassName(cache, serialized)\n}\n\nexport function useStyles(cache: EmotionCache, styles: SerializedStyles[]) {\n styles.forEach(s => registerStyles(cache, s, false))\n\n useUniversalInsertionEffect(() => {\n styles.forEach(s => insertStyles(cache, s, false))\n })\n}\n\nfunction useUniversalInsertionEffect(effect: () => void) {\n useInsertionEffect(effect)\n if (isServer()) effect()\n}\n\nexport function serializedStyleClassName(\n cache: EmotionCache,\n serialized: SerializedStyles,\n): string {\n // see https://github.com/emotion-js/emotion/blob/main/packages/utils/src/index.ts#L26\n return `${cache.key}-${serialized.name}`\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAGlB,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,oBAA2C;AAEpE,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AAEzB,MAAM,8BAA8B;AACpC,MAAM,qBAAqB,MAAM,2BAA2B,KAAK,MAAM;AAEhE,SAAS,SAAS,OAA0B;AACjD,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,gBAAgB,CAAC,KAAK,GAAG,MAAM,UAAU;AAE5D,iBAAe,OAAO,YAAY,KAAK;AAEvC,8BAA4B,MAAM;AAChC,iBAAa,OAAO,YAAY,KAAK;AAAA,EACvC,CAAC;AAED,SAAO,yBAAyB,OAAO,UAAU;AACnD;AAEO,SAAS,UAAU,OAAqB,QAA4B;AACzE,SAAO,QAAQ,OAAK,eAAe,OAAO,GAAG,KAAK,CAAC;AAEnD,8BAA4B,MAAM;AAChC,WAAO,QAAQ,OAAK,aAAa,OAAO,GAAG,KAAK,CAAC;AAAA,EACnD,CAAC;AACH;AAEA,SAAS,4BAA4B,QAAoB;AACvD,qBAAmB,MAAM;AACzB,MAAI,SAAS;AAAG,WAAO;AACzB;AAEO,SAAS,yBACd,OACA,YACQ;AAER,SAAO,GAAG,MAAM,GAAG,IAAI,WAAW,IAAI;AACxC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/utils/prop-error-handling-proxy.ts"],"sourcesContent":["import { type Resolvable } from '@makeswift/controls'\n\nexport function propErrorHandlingProxy<T>(\n resolvable: Resolvable<T>,\n fallback: T,\n onError?: (error: unknown) => void,\n): Resolvable<T> {\n return {\n ...resolvable,\n readStable: () => {\n try {\n return resolvable.readStable()\n } catch (err: unknown) {\n onError?.(err)\n return fallback\n }\n },\n }\n}\n"],"mappings":"AAEO,SAAS,uBACd,YACA,UACA,SACe;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY,MAAM;AAChB,UAAI;AACF,eAAO,WAAW,WAAW;AAAA,MAC/B,SAAS,KAAc;AACrB,kBAAU,GAAG;AACb,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/utils/suppress-ref-warning.ts"],"sourcesContent":["const originalError = console.error\nlet patched = false\n\n/**\n * @see https://github.com/facebook/react/blob/a2505792ed17fd4d7ddc69561053c3ac90899491/packages/react-reconciler/src/ReactFiberBeginWork.new.js#L1814-L1890\n */\nexport function suppressRefWarning(ownerName: string): void {\n if (patched === false) {\n console.error = (...args) => {\n if (\n typeof args[0] === 'string' &&\n args[0].includes('Function components cannot be given refs.') &&\n args[0].includes(`Check the render method of \\`${ownerName}\\`.`)\n ) {\n return\n }\n\n return originalError(...args)\n }\n\n patched = true\n }\n}\n"],"mappings":"AAAA,MAAM,gBAAgB,QAAQ;AAC9B,IAAI,UAAU;AAKP,SAAS,mBAAmB,WAAyB;AAC1D,MAAI,YAAY,OAAO;AACrB,YAAQ,QAAQ,IAAI,SAAS;AAC3B,UACE,OAAO,KAAK,CAAC,MAAM,YACnB,KAAK,CAAC,EAAE,SAAS,2CAA2C,KAC5D,KAAK,CAAC,EAAE,SAAS,gCAAgC,SAAS,KAAK,GAC/D;AACA;AAAA,MACF;AAEA,aAAO,cAAc,GAAG,IAAI;AAAA,IAC9B;AAEA,cAAU;AAAA,EACZ;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/slate/BlockPlugin/utils/location.ts"],"sourcesContent":["import { Range, Point, Path, Location } from 'slate'\n\nexport const LocationUtils = {\n getStartPath(location: Location): Path {\n if (Range.isRange(location)) return Range.start(location).path\n if (Point.isPoint(location)) return location.path\n return location\n },\n}\n"],"mappings":"AAAA,SAAS,OAAO,aAA6B;AAEtC,MAAM,gBAAgB;AAAA,EAC3B,aAAa,UAA0B;AACrC,QAAI,MAAM,QAAQ,QAAQ;AAAG,aAAO,MAAM,MAAM,QAAQ,EAAE;AAC1D,QAAI,MAAM,QAAQ,QAAQ;AAAG,aAAO,SAAS;AAC7C,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Transforms } from "slate";
|
|
2
|
+
import { getSelection } from "../selectors";
|
|
3
|
+
function wrapInline(editor, inline) {
|
|
4
|
+
Transforms.wrapNodes(editor, inline, {
|
|
5
|
+
at: getSelection(editor),
|
|
6
|
+
split: true
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
wrapInline
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=wrapInline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/BlockPlugin/wrapInline.ts"],"sourcesContent":["import { Editor, Transforms } from 'slate'\nimport { Slate } from '@makeswift/controls'\n\nimport { getSelection } from '../selectors'\n\nexport function wrapInline(editor: Editor, inline: Slate.Inline) {\n Transforms.wrapNodes(editor, inline, {\n at: getSelection(editor),\n split: true,\n })\n}\n"],"mappings":"AAAA,SAAiB,kBAAkB;AAGnC,SAAS,oBAAoB;AAEtB,SAAS,WAAW,QAAgB,QAAsB;AAC/D,aAAW,UAAU,QAAQ,QAAQ;AAAA,IACnC,IAAI,aAAa,MAAM;AAAA,IACvB,OAAO;AAAA,EACT,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Editor, Element, Transforms } from "slate";
|
|
2
|
+
import { Slate } from "@makeswift/controls";
|
|
3
|
+
import { ElementUtils } from "../utils/element";
|
|
4
|
+
import { BlockType } from "../../slate/types";
|
|
5
|
+
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
6
|
+
const at = options.at ?? editor.selection;
|
|
7
|
+
if (!at)
|
|
8
|
+
return;
|
|
9
|
+
const nonListEntries = Array.from(
|
|
10
|
+
Editor.nodes(editor, {
|
|
11
|
+
at,
|
|
12
|
+
match: (node) => {
|
|
13
|
+
return Element.isElement(node) && Slate.isConvertibleToListTextNode(node);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
|
|
18
|
+
refs.forEach((ref) => {
|
|
19
|
+
const path = ref.current;
|
|
20
|
+
if (path) {
|
|
21
|
+
Editor.withoutNormalizing(editor, () => {
|
|
22
|
+
Transforms.setNodes(
|
|
23
|
+
editor,
|
|
24
|
+
{ type: BlockType.ListItemChild },
|
|
25
|
+
{
|
|
26
|
+
at: path
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
30
|
+
match: (node) => Slate.isListItemChild(node),
|
|
31
|
+
at: path
|
|
32
|
+
});
|
|
33
|
+
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
34
|
+
at: path
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
ref.unref();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
wrapList
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=wrapList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/BlockPlugin/wrapList.ts"],"sourcesContent":["import { Editor, Element, Location, Span, Transforms } from 'slate'\nimport { Slate } from '@makeswift/controls'\n\nimport { ElementUtils } from '../utils/element'\nimport { BlockType } from '../../slate/types'\n\ntype WrapListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n at?: Location | Span\n}\n\nexport function wrapList(\n editor: Editor,\n options: WrapListOptions = { type: BlockType.UnorderedList },\n) {\n const at = options.at ?? editor.selection\n if (!at) return\n\n const nonListEntries = Array.from(\n Editor.nodes(editor, {\n at,\n match: node => {\n return Element.isElement(node) && Slate.isConvertibleToListTextNode(node)\n },\n }),\n )\n\n const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n const path = ref.current\n if (path) {\n Editor.withoutNormalizing(editor, () => {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: path,\n },\n )\n Transforms.wrapNodes(editor, ElementUtils.createListItem(), {\n match: node => Slate.isListItemChild(node),\n at: path,\n })\n Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {\n at: path,\n })\n })\n }\n ref.unref()\n })\n}\n"],"mappings":"AAAA,SAAS,QAAQ,SAAyB,kBAAkB;AAC5D,SAAS,aAAa;AAEtB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAOnB,SAAS,SACd,QACA,UAA2B,EAAE,MAAM,UAAU,cAAc,GAC3D;AACA,QAAM,KAAK,QAAQ,MAAM,OAAO;AAChC,MAAI,CAAC;AAAI;AAET,QAAM,iBAAiB,MAAM;AAAA,IAC3B,OAAO,MAAM,QAAQ;AAAA,MACnB;AAAA,MACA,OAAO,UAAQ;AACb,eAAO,QAAQ,UAAU,IAAI,KAAK,MAAM,4BAA4B,IAAI;AAAA,MAC1E;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,eAAe,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,OAAO,QAAQ,QAAQ,IAAI,CAAC;AAE3E,OAAK,QAAQ,SAAO;AAClB,UAAM,OAAO,IAAI;AACjB,QAAI,MAAM;AACR,aAAO,mBAAmB,QAAQ,MAAM;AACtC,mBAAW;AAAA,UACT;AAAA,UACA,EAAE,MAAM,UAAU,cAAc;AAAA,UAChC;AAAA,YACE,IAAI;AAAA,UACN;AAAA,QACF;AACA,mBAAW,UAAU,QAAQ,aAAa,eAAe,GAAG;AAAA,UAC1D,OAAO,UAAQ,MAAM,gBAAgB,IAAI;AAAA,UACzC,IAAI;AAAA,QACN,CAAC;AACD,mBAAW,UAAU,QAAQ,aAAa,WAAW,QAAQ,IAAI,GAAG;AAAA,UAClE,IAAI;AAAA,QACN,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AACA,QAAI,MAAM;AAAA,EACZ,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/utils/responsive.ts"],"sourcesContent":["import { Editor, Transforms, NodeMatch, Descendant, NodeEntry } from 'slate'\nimport { Slate, type ResponsiveValue } from '@makeswift/controls'\n\nimport { getSelection } from '../selectors'\nimport shallowEqual from '../../utils/shallowEqual'\n\ntype SetResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n split: boolean\n}\n\nexport function setResponsiveValue<T extends Descendant, K extends keyof T>(\n editor: Editor,\n key: K,\n value: T[K] | undefined | null,\n options: SetResponsiveValueOptions<T>,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = getSelection(editor)\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes<Descendant>(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: options.match,\n split: options.split,\n },\n )\n }\n\n if (atRef.current) {\n const nodesToUpdate = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: (node, path) => options.match(node, path) && (node as T).slice === true,\n }),\n )\n\n for (const [, path] of nodesToUpdate) {\n Transforms.setNodes(\n editor,\n {\n [key]: value,\n },\n { at: path },\n )\n }\n }\n\n atRef.unref()\n })\n}\n\ntype NormalizeResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n}\n\nexport function normalizeResponsiveValue<T extends Descendant, K extends keyof T & string>(\n editor: Editor,\n key: K,\n options: NormalizeResponsiveValueOptions<T>,\n) {\n return (entry: NodeEntry<T>) => {\n const [node, path] = entry\n\n if (!options.match(node, path)) {\n return false\n }\n\n const responsiveValue = node?.[key]\n\n if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {\n Transforms.unsetNodes(editor, key, { at: path })\n return true\n }\n\n if (node?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: path })\n return true\n }\n\n return false\n }\n}\n\nexport function responsiveShallowEqual<T>(\n a: ResponsiveValue<T> = [],\n b: ResponsiveValue<T> = [],\n): ResponsiveValue<T> {\n const aObject: Record<string, Slate.BlockTextAlignment> = a.reduce(\n (acc, curr) => ({\n ...acc,\n [curr.deviceId]: curr.value,\n }),\n {},\n )\n const bObject: Record<string, Slate.BlockTextAlignment> = b.reduce(\n (acc, curr) => ({\n ...acc,\n [curr.deviceId]: curr.value,\n }),\n {},\n )\n\n const definedDevices = new Set([...a.map(a => a.deviceId), ...b.map(b => b.deviceId)])\n\n return Array.from(definedDevices).map(deviceId => {\n const aVal = aObject[deviceId]\n const bVal = bObject[deviceId]\n\n if (aVal === undefined && bVal === undefined) return { deviceId, value: undefined }\n\n return shallowEqual(aVal, bVal) ? { deviceId, value: aVal } : { deviceId, value: null }\n }) as ResponsiveValue<T>\n}\n"],"mappings":"AAAA,SAAS,QAAQ,kBAAoD;AAGrE,SAAS,oBAAoB;AAC7B,OAAO,kBAAkB;AAOlB,SAAS,mBACd,QACA,KACA,OACA,SACA;AACA,SAAO,mBAAmB,QAAQ,MAAM;AACtC,UAAM,KAAK,aAAa,MAAM;AAC9B,QAAI,CAAC;AAAI;AACT,UAAM,QAAQ,OAAO,SAAS,QAAQ,EAAE;AAExC,QAAI,MAAM,SAAS;AACjB,iBAAW;AAAA,QACT;AAAA,QACA;AAAA,UACE,OAAO;AAAA,QACT;AAAA,QACA;AAAA,UACE,IAAI,MAAM;AAAA,UACV,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,MAAM,SAAS;AACjB,YAAM,gBAAgB,MAAM;AAAA,QAC1B,OAAO,MAAM,QAAQ;AAAA,UACnB,IAAI,MAAM;AAAA,UACV,OAAO,CAAC,MAAM,SAAS,QAAQ,MAAM,MAAM,IAAI,KAAM,KAAW,UAAU;AAAA,QAC5E,CAAC;AAAA,MACH;AAEA,iBAAW,CAAC,EAAE,IAAI,KAAK,eAAe;AACpC,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE,CAAC,GAAG,GAAG;AAAA,UACT;AAAA,UACA,EAAE,IAAI,KAAK;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM;AAAA,EACd,CAAC;AACH;AAMO,SAAS,yBACd,QACA,KACA,SACA;AACA,SAAO,CAAC,UAAwB;AAC9B,UAAM,CAAC,MAAM,IAAI,IAAI;AAErB,QAAI,CAAC,QAAQ,MAAM,MAAM,IAAI,GAAG;AAC9B,aAAO;AAAA,IACT;AAEA,UAAM,kBAAkB,OAAO,GAAG;AAElC,QAAI,MAAM,QAAQ,eAAe,KAAK,gBAAgB,WAAW,GAAG;AAClE,iBAAW,WAAW,QAAQ,KAAK,EAAE,IAAI,KAAK,CAAC;AAC/C,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,SAAS,MAAM;AACvB,iBAAW,WAAW,QAAQ,SAAS,EAAE,IAAI,KAAK,CAAC;AACnD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,uBACd,IAAwB,CAAC,GACzB,IAAwB,CAAC,GACL;AACpB,QAAM,UAAoD,EAAE;AAAA,IAC1D,CAAC,KAAK,UAAU;AAAA,MACd,GAAG;AAAA,MACH,CAAC,KAAK,QAAQ,GAAG,KAAK;AAAA,IACxB;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,UAAoD,EAAE;AAAA,IAC1D,CAAC,KAAK,UAAU;AAAA,MACd,GAAG;AAAA,MACH,CAAC,KAAK,QAAQ,GAAG,KAAK;AAAA,IACxB;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,oBAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAAA,OAAKA,GAAE,QAAQ,GAAG,GAAG,EAAE,IAAI,CAAAC,OAAKA,GAAE,QAAQ,CAAC,CAAC;AAErF,SAAO,MAAM,KAAK,cAAc,EAAE,IAAI,cAAY;AAChD,UAAM,OAAO,QAAQ,QAAQ;AAC7B,UAAM,OAAO,QAAQ,QAAQ;AAE7B,QAAI,SAAS,UAAa,SAAS;AAAW,aAAO,EAAE,UAAU,OAAO,OAAU;AAElF,WAAO,aAAa,MAAM,IAAI,IAAI,EAAE,UAAU,OAAO,KAAK,IAAI,EAAE,UAAU,OAAO,KAAK;AAAA,EACxF,CAAC;AACH;","names":["a","b"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/utils/toText.ts"],"sourcesContent":["import { type Descendant } from 'slate'\nimport { Slate } from '@makeswift/controls'\n\nimport { RichText, RichTextV2Mode } from '../../controls/rich-text-v2'\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if (Slate.isText(descendant)) return false\n return Slate.isBlock(descendant)\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (Slate.isText(descendant)) {\n return descendant.text ?? ''\n }\n\n if (Slate.isDefaultElement(descendant)) {\n return mode === RichText.Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n }\n\n if (Slate.isBlock(descendant)) {\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n }\n\n if (Slate.isInline(descendant)) {\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n }\n\n return ''\n}\n\nexport function toText(descendants: Descendant[], mode: RichTextV2Mode): string {\n return descendants.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"mappings":"AACA,SAAS,aAAa;AAEtB,SAAS,gBAAgC;AAEzC,SAAS,QAAQ,YAAmD;AAClE,MAAI,MAAM,OAAO,UAAU;AAAG,WAAO;AACrC,SAAO,MAAM,QAAQ,UAAU;AACjC;AAEA,SAAS,oBAAoB,YAAwB,MAA8B;AACjF,MAAI,MAAM,OAAO,UAAU,GAAG;AAC5B,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,MAAI,MAAM,iBAAiB,UAAU,GAAG;AACtC,WAAO,SAAS,SAAS,KAAK,SAC1B,WAAW,SAAS,IAAI,CAAAA,gBAAc,oBAAoBA,aAAY,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,KACzF,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,aAAY,IAAI,CAAC,EACvD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,EACjE;AAEA,MAAI,MAAM,QAAQ,UAAU,GAAG;AAC7B,WACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,aAAY,IAAI,CAAC,EACvD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,EAE/D;AAEA,MAAI,MAAM,SAAS,UAAU,GAAG;AAC9B,WACE,WAAW,SAAS,IAAI,CAAAA,gBAAc,oBAAoBA,aAAY,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,EAE7F;AAEA,SAAO;AACT;AAEO,SAAS,OAAO,aAA2B,MAA8B;AAC9E,SAAO,YAAY,IAAI,UAAQ,oBAAoB,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI;AAC3E;","names":["descendant"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/utils/unhangRange.ts"],"sourcesContent":["import { Editor, Range, Element, Text, Path } from 'slate'\n\n/**\n * The `Editor.unhangeRange` within Slate early exits if `Path.hasPrevious(end.path)` ie if this isn't a root block.\n * Unfortunately when you `setNode(..., {split:true})` or `wrapNodes()` you also have a hanging selection, but not in the root position.\n *\n * This c/p removes the `Path.hasPrevious(end.path)` from the early exit but it the same otherwise\n */\nfunction unhangRange(editor: Editor, range: Range): Range {\n // eslint-disable-next-line prefer-const\n let [start, end] = Range.edges(range)\n // PERF: exit early if we can guarantee that the range isn't hanging.\n if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {\n return range\n }\n\n const endBlock = Editor.above(editor, {\n at: end,\n match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n })\n const blockPath = endBlock ? endBlock[1] : []\n const first = Editor.start(editor, start)\n const before = { anchor: first, focus: end }\n let skip = true\n\n for (const [node, path] of Editor.nodes(editor, {\n at: before,\n match: Text.isText,\n reverse: true,\n })) {\n if (skip) {\n skip = false\n continue\n }\n\n if (node.text !== '' || Path.isBefore(path, blockPath)) {\n end = { path, offset: node.text.length }\n break\n }\n }\n\n return { anchor: start, focus: end }\n}\n\nexport default unhangRange\n"],"mappings":"AAAA,SAAS,QAAQ,OAAO,SAAS,MAAM,YAAY;AAQnD,SAAS,YAAY,QAAgB,OAAqB;AAExD,MAAI,CAAC,OAAO,GAAG,IAAI,MAAM,MAAM,KAAK;AAEpC,MAAI,MAAM,WAAW,KAAK,IAAI,WAAW,KAAK,MAAM,YAAY,KAAK,GAAG;AACtE,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,OAAO,MAAM,QAAQ;AAAA,IACpC,IAAI;AAAA,IACJ,OAAO,OAAK,QAAQ,UAAU,CAAC,KAAK,OAAO,QAAQ,QAAQ,CAAC;AAAA,EAC9D,CAAC;AACD,QAAM,YAAY,WAAW,SAAS,CAAC,IAAI,CAAC;AAC5C,QAAM,QAAQ,OAAO,MAAM,QAAQ,KAAK;AACxC,QAAM,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI;AAC3C,MAAI,OAAO;AAEX,aAAW,CAAC,MAAM,IAAI,KAAK,OAAO,MAAM,QAAQ;AAAA,IAC9C,IAAI;AAAA,IACJ,OAAO,KAAK;AAAA,IACZ,SAAS;AAAA,EACX,CAAC,GAAG;AACF,QAAI,MAAM;AACR,aAAO;AACP;AAAA,IACF;AAEA,QAAI,KAAK,SAAS,MAAM,KAAK,SAAS,MAAM,SAAS,GAAG;AACtD,YAAM,EAAE,MAAM,QAAQ,KAAK,KAAK,OAAO;AACvC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,OAAO,OAAO,IAAI;AACrC;AAEA,IAAO,sBAAQ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/actions/internal/read-only-actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\n\nimport { type APIResource, APIResourceType, APIResourceLocale } from '../../../api/types'\nimport { type Descriptor as PropControllerDescriptor } from '../../../prop-controllers/descriptors'\n\nimport { type Breakpoints } from '../../modules/breakpoints'\nimport { type ComponentMeta } from '../../modules/components-meta'\nimport { type PropControllersHandle } from '../../modules/prop-controller-handles'\nimport { type ComponentType } from '../../modules/react-components'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type LocaleString, localeStringSchema } from '../../../locale'\nimport { type DocumentPayload } from '../../shared-api'\n\nexport const ReadOnlyActionTypes = {\n // TODO: this one should be a read-write action and we should refuse\n // to fetch resources on the client in read-only mode\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n SET_BREAKPOINTS: 'SET_BREAKPOINTS',\n UPDATE_CLIENT_BREAKPOINT: 'UPDATE_CLIENT_BREAKPOINT',\n\n SET_LOCALE: 'SET_LOCALE',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n SET_IS_READ_ONLY: 'SET_IS_READ_ONLY',\n} as const\n\ntype APIResourceFulfilledAction = {\n type: typeof ReadOnlyActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype CreateElementTreeAction = {\n type: typeof ReadOnlyActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof ReadOnlyActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\nexport type RegisterComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\nexport type UnregisterComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\nexport type SetBreakpointsAction = {\n type: typeof ReadOnlyActionTypes.SET_BREAKPOINTS\n payload: { breakpoints: Breakpoints }\n}\n\ntype UpdateClientBreakpointAction = {\n type: typeof ReadOnlyActionTypes.UPDATE_CLIENT_BREAKPOINT\n}\n\nexport type SetLocaleAction = {\n type: typeof ReadOnlyActionTypes.SET_LOCALE\n payload: { locale: LocaleString; pathname?: string }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype SetIsReadOnlyAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_READ_ONLY\n payload: boolean\n}\n\nexport type ReadOnlyAction =\n | APIResourceFulfilledAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | SetBreakpointsAction\n | UpdateClientBreakpointAction\n | SetLocaleAction\n | SetIsInBuilderAction\n | SetIsReadOnlyAction\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: ReadOnlyActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: ReadOnlyActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: ReadOnlyActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: ReadOnlyActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function setBreakpoints(breakpoints: Breakpoints): SetBreakpointsAction {\n return { type: ReadOnlyActionTypes.SET_BREAKPOINTS, payload: { breakpoints } }\n}\n\nexport function updateClientBreakpoint(): UpdateClientBreakpointAction {\n return { type: ReadOnlyActionTypes.UPDATE_CLIENT_BREAKPOINT }\n}\n\nexport function setLocale(locale: Intl.Locale, pathname?: string): SetLocaleAction {\n return {\n type: ReadOnlyActionTypes.SET_LOCALE,\n payload: { locale: localeStringSchema.parse(locale.toString()), pathname },\n }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: ReadOnlyActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function setIsReadOnly(isReadOnly: boolean): SetIsReadOnlyAction {\n return { type: ReadOnlyActionTypes.SET_IS_READ_ONLY, payload: isReadOnly }\n}\n"],"mappings":"AAeA,SAA4B,0BAA0B;AAG/C,MAAM,sBAAsB;AAAA;AAAA;AAAA,EAGjC,wBAAwB;AAAA,EAExB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,kCAAkC;AAAA,EAClC,oCAAoC;AAAA,EAEpC,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,EAE1B,YAAY;AAAA,EAEZ,mBAAmB;AAAA,EACnB,kBAAkB;AACpB;AA4HO,SAAS,qBACd,cACA,YACA,UACA,QAC4B;AAC5B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,cAAc,YAAY,UAAU,OAAO;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO,EAAE,MAAM,oBAAoB,qBAAqB,QAAQ;AAClE;AAEO,SAAS,kBACd,MACA,MACA,2BACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,MAAM,MAAM,0BAA0B;AAAA,EACnD;AACF;AAEO,SAAS,oBAAoB,MAAyC;AAC3E,SAAO,EAAE,MAAM,oBAAoB,sBAAsB,SAAS,EAAE,KAAK,EAAE;AAC7E;AAEO,SAAS,wBACd,MACA,MACA,2BAC2D;AAC3D,SAAO,cAAY;AACjB,aAAS,kBAAkB,MAAM,MAAM,yBAAyB,CAAC;AAEjE,WAAO,MAAM;AACX,eAAS,oBAAoB,IAAI,CAAC;AAAA,IACpC;AAAA,EACF;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEA,SAAS,0BACP,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,8BACd,aACA,YACA,iBAC2D;AAC3D,SAAO,cAAY;AACjB,aAAS,wBAAwB,aAAa,YAAY,eAAe,CAAC;AAE1E,WAAO,MAAM;AACX,eAAS,0BAA0B,aAAa,UAAU,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;AAEO,SAAS,8BACd,aACA,YACA,QACqC;AACrC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,YAAY,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,gCACd,aACA,YACuC;AACvC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEA,SAAS,uBACP,MACA,WAC8B;AAC9B,SAAO,EAAE,MAAM,oBAAoB,0BAA0B,SAAS,EAAE,MAAM,UAAU,EAAE;AAC5F;AAEA,SAAS,yBAAyB,MAA8C;AAC9E,SAAO,EAAE,MAAM,oBAAoB,4BAA4B,SAAS,EAAE,KAAK,EAAE;AACnF;AAEO,SAAS,6BACd,MACA,WAC2D;AAC3D,SAAO,cAAY;AACjB,aAAS,uBAAuB,MAAM,SAAS,CAAC;AAEhD,WAAO,MAAM;AACX,eAAS,yBAAyB,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,SAAS,eAAe,aAAgD;AAC7E,SAAO,EAAE,MAAM,oBAAoB,iBAAiB,SAAS,EAAE,YAAY,EAAE;AAC/E;AAEO,SAAS,yBAAuD;AACrE,SAAO,EAAE,MAAM,oBAAoB,yBAAyB;AAC9D;AAEO,SAAS,UAAU,QAAqB,UAAoC;AACjF,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,QAAQ,mBAAmB,MAAM,OAAO,SAAS,CAAC,GAAG,SAAS;AAAA,EAC3E;AACF;AAEO,SAAS,eAAe,aAA4C;AACzE,SAAO,EAAE,MAAM,oBAAoB,mBAAmB,SAAS,YAAY;AAC7E;AAEO,SAAS,cAAc,YAA0C;AACtE,SAAO,EAAE,MAAM,oBAAoB,kBAAkB,SAAS,WAAW;AAC3E;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/actions/internal/read-write-actions.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Measurable } from '../../modules/read-write/box-models'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\nimport { type SerializedState as APIClientCache } from '../../makeswift-api-client'\n\nexport const ReadWriteActionTypes = {\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n CLEAR_API_CLIENT_CACHE: 'CLEAR_API_CLIENT_CACHE',\n} as const\n\ntype ChangeElementTreeAction = {\n type: typeof ReadWriteActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UpdateAPIClientCache = {\n type: typeof ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\ntype ClearAPIClientCache = {\n type: typeof ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE\n}\n\nexport type ReadWriteAction =\n | ChangeElementTreeAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | UpdateAPIClientCache\n | ClearAPIClientCache\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ReadWriteActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: ReadWriteActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ReadWriteActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n\nexport function clearAPIClientCache(): ClearAPIClientCache {\n return { type: ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE }\n}\n"],"mappings":"AASO,MAAM,uBAAuB;AAAA,EAClC,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EAEvB,yBAAyB;AAAA,EACzB,wBAAwB;AAC1B;AAsCO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,qBAAqB;AAAA,IAC3B;AAAA,EACF;AACF;AAEO,SAAS,mBACd,aACA,YACA,YAC0B;AAC1B,SAAO;AAAA,IACL,MAAM,qBAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,WAAW;AAAA,EACjD;AACF;AAEO,SAAS,qBACd,aACA,YAC4B;AAC5B,SAAO,EAAE,MAAM,qBAAqB,uBAAuB,SAAS,EAAE,aAAa,WAAW,EAAE;AAClG;AAEO,SAAS,yBACd,aACA,YACA,YAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,mBAAmB,aAAa,YAAY,UAAU,CAAC;AAEhE,WAAO,MAAM;AACX,eAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,qBAAqB,yBAAyB,QAAQ;AACvE;AAEO,SAAS,sBAA2C;AACzD,SAAO,EAAE,MAAM,qBAAqB,uBAAuB;AAC7D;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/proxy.ts"],"sourcesContent":["import { type HostAction, isHostAction } from '../host-api'\n\nimport { type BuilderAction, BuilderActionTypes, hasTransferables } from './actions'\nimport { MessageChannel } from './message-channel'\nimport { setupNavigationListener } from './navigation-listener'\nimport { type BuilderApi, type HostNavigationEvent } from './api'\n\nexport class BuilderAPIProxy implements BuilderApi {\n private messageChannel: MessageChannel\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.messageChannel = new MessageChannel({ appOrigin })\n }\n\n handleHostNavigate(event: HostNavigationEvent) {\n this.execute({ type: BuilderActionTypes.HANDLE_HOST_NAVIGATE, payload: event })\n }\n\n // low-level, action-based API\n\n setup({ onHostAction }: { onHostAction: (action: HostAction) => void }): VoidFunction {\n const channelCleanup = this.messageChannel.setup({\n onMessage: (event: MessageEvent) => {\n const action = event.data\n\n if (!isHostAction(action)) {\n console.warn('Unexpected host action', action)\n return\n }\n\n onHostAction(action)\n },\n })\n\n const navigationListenerCleanup = setupNavigationListener(event =>\n this.handleHostNavigate(event),\n )\n\n return () => {\n channelCleanup()\n navigationListenerCleanup()\n }\n }\n\n execute(action: BuilderAction): void {\n if (hasTransferables(action)) {\n const { transferables, ...forwardedAction } = action\n this.messageChannel.postMessage(forwardedAction, transferables)\n return\n }\n\n this.messageChannel.postMessage(action)\n }\n\n dispatchBuffered(): void {\n this.messageChannel.dispatchBuffered()\n }\n}\n"],"mappings":"AAAA,SAA0B,oBAAoB;AAE9C,SAA6B,oBAAoB,wBAAwB;AACzE,SAAS,sBAAsB;AAC/B,SAAS,+BAA+B;AAGjC,MAAM,gBAAsC;AAAA,EACzC;AAAA,EAER,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,iBAAiB,IAAI,eAAe,EAAE,UAAU,CAAC;AAAA,EACxD;AAAA,EAEA,mBAAmB,OAA4B;AAC7C,SAAK,QAAQ,EAAE,MAAM,mBAAmB,sBAAsB,SAAS,MAAM,CAAC;AAAA,EAChF;AAAA;AAAA,EAIA,MAAM,EAAE,aAAa,GAAiE;AACpF,UAAM,iBAAiB,KAAK,eAAe,MAAM;AAAA,MAC/C,WAAW,CAAC,UAAwB;AAClC,cAAM,SAAS,MAAM;AAErB,YAAI,CAAC,aAAa,MAAM,GAAG;AACzB,kBAAQ,KAAK,0BAA0B,MAAM;AAC7C;AAAA,QACF;AAEA,qBAAa,MAAM;AAAA,MACrB;AAAA,IACF,CAAC;AAED,UAAM,4BAA4B;AAAA,MAAwB,WACxD,KAAK,mBAAmB,KAAK;AAAA,IAC/B;AAEA,WAAO,MAAM;AACX,qBAAe;AACf,gCAA0B;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,QAAQ,QAA6B;AACnC,QAAI,iBAAiB,MAAM,GAAG;AAC5B,YAAM,EAAE,eAAe,GAAG,gBAAgB,IAAI;AAC9C,WAAK,eAAe,YAAY,iBAAiB,aAAa;AAC9D;AAAA,IACF;AAEA,SAAK,eAAe,YAAY,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAyB;AACvB,SAAK,eAAe,iBAAiB;AAAA,EACvC;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/middleware/read-only-element-tree.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { ActionTypes } from '../actions'\nimport { createElementTree, deleteElementTree } from '../actions/internal/read-only-actions'\n\nimport { actionMiddleware } from '../toolkit'\n\nimport { type Dispatch, type State, getPropControllerDescriptors } from '../read-only-state'\n\nexport function readOnlyElementTreeMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return action => {\n switch (action.type) {\n case ActionTypes.REGISTER_DOCUMENT:\n dispatch(\n createElementTree({\n document: action.payload.document,\n descriptors: getPropControllerDescriptors(getState()),\n }),\n )\n break\n\n case ActionTypes.UNREGISTER_DOCUMENT:\n dispatch(deleteElementTree(action.payload))\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":"AAEA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,yBAAyB;AAErD,SAAS,wBAAwB;AAEjC,SAAoC,oCAAoC;AAEjE,SAAS,gCAAuE;AACrF,SAAO,iBAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,YAAU;AACf,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,YAAY;AACf;AAAA,YACE,kBAAkB;AAAA,cAChB,UAAU,OAAO,QAAQ;AAAA,cACzB,aAAa,6BAA6B,SAAS,CAAC;AAAA,YACtD,CAAC;AAAA,UACH;AACA;AAAA,QAEF,KAAK,YAAY;AACf,mBAAS,kBAAkB,OAAO,OAAO,CAAC;AAC1C;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/measure-box-models.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport * as BoxModels from '../../modules/read-write/box-models'\nimport { type Action } from '../../actions'\n\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\nimport * as ReadWriteActions from '../../actions/internal/read-write-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { type State, type Dispatch } from '../../read-write-state'\n\nexport function measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n ReadWriteActions.registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(\n ReadWriteActions.unregisterMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n ),\n )\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":"AAEA,YAAY,eAAe;AAG3B,SAAS,2BAA2B;AACpC,YAAY,sBAAsB;AAElC,SAAS,wBAAwB;AAI1B,SAAS,6BAAoE;AAClF,SAAO,iBAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oBAAoB,2BAA2B;AAClD,cAAI,UAAU,aAAa,OAAO,QAAQ,eAAe,GAAG;AAC1D;AAAA,cACE,iBAAiB;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,gBACf,OAAO,QAAQ;AAAA,cACjB;AAAA,YACF;AAAA,UACF;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oBAAoB;AACvB;AAAA,YACE,iBAAiB;AAAA,cACf,OAAO,QAAQ;AAAA,cACf,OAAO,QAAQ;AAAA,YACjB;AAAA,UACF;AACA;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware, type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport * as PropControllerHandles from '../../modules/prop-controller-handles'\n\nimport { type Action } from '../../actions'\n\nimport * as Builder from '../../builder-api/actions'\n\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\nimport * as ReadOnly from '../../actions/internal/read-only-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { createPropController } from '../../../prop-controllers/instances'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\nimport { type State, type Dispatch } from '../../read-write-state'\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReadOnlyState.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n ) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n dispatch(ReadOnly.registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(\n ReadOnly.registerPropControllersHandle(documentKey, elementKey, componentHandle),\n )\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = ReadOnlyState.getPropControllersHandle(getState(), {\n documentKey,\n elementKey,\n })\n\n handle?.setPropControllers(null)\n\n dispatch(ReadOnly.unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = ReadOnlyState.getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":"AAIA,YAAY,2BAA2B;AAIvC,YAAY,aAAa;AAEzB,SAAS,2BAA2B;AACpC,YAAY,cAAc;AAE1B,SAAS,wBAAwB;AAEjC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAEhC,YAAY,mBAAmB;AAG/B,SAAS,iCACP,aACA,YAC6E;AAC7E,SAAO,CAAC,UAAU,aAAa;AAC7B,UAAM,cAAc,cAAc;AAAA,MAChC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAEA,QAAI,eAAe;AAAM,aAAO;AAEhC,UAAM,kBAAkB,OAAO,QAAQ,WAAW,EAAE;AAAA,MAClD,CAAC,KAAK,CAAC,UAAU,UAAU,MAAM;AAC/B,cAAM,iBAAiB;AAAA,UAAqB;AAAA,UAAY,aACtD;AAAA,YACE,QAAQ,6BAA6B,aAAa,YAAY,UAAU,OAAO;AAAA,UACjF;AAAA,QACF;AAEA,eAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,eAAe;AAAA,MAC9C;AAAA,MACA,CAAC;AAAA,IACH;AAEA,aAAS,SAAS,wBAAwB,aAAa,YAAY,eAAe,CAAC;AAEnF,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kCAAyE;AACvF,SAAO,iBAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oBAAoB,2BAA2B;AAClD,gBAAM,EAAE,aAAa,YAAY,gBAAgB,IAAI,OAAO;AAC5D,gBAAM,UAAU,cAAc,WAAW,SAAS,GAAG,aAAa,UAAU;AAC5E,gBAAM,kBAAkB;AAAA,YACtB,iCAAiC,aAAa,UAAU;AAAA,UAC1D;AAEA,cACE,WAAW,QACX,CAAC,cAAc,mBAAmB,OAAO,KACzC,sBAAsB,wBAAwB,eAAe,GAC7D;AACA;AAAA,cACE,SAAS,8BAA8B,aAAa,YAAY,eAAe;AAAA,YACjF;AACA,4BAAgB,mBAAmB,eAAe;AAAA,UACpD;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oBAAoB,6BAA6B;AACpD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,gBAAM,SAAS,cAAc,yBAAyB,SAAS,GAAG;AAAA,YAChE;AAAA,YACA;AAAA,UACF,CAAC;AAED,kBAAQ,mBAAmB,IAAI;AAE/B,mBAAS,SAAS,0BAA0B,aAAa,UAAU,CAAC;AAEpE;AAAA,QACF;AAAA,QAEA,KAAK,gBAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,iBAAiB,cAAc,kBAAkB,SAAS,GAAG;AAAA,YACjE;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAED,cAAI;AAAgB,2BAAe,KAAK,OAAO;AAAA,QACjD;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/update-element-tree.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { HostActionTypes } from '../../host-api'\nimport { changeElementTree } from '../../actions/internal/read-write-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { type Dispatch, type State, getDocument } from '../../read-write-state'\nimport { getPropControllerDescriptors } from '../../read-only-state'\n\nexport function updateElementTreeMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return action => {\n switch (action.type) {\n case HostActionTypes.CHANGE_DOCUMENT: {\n const { documentKey, operation } = action.payload\n\n const oldDocument = getDocument(getState(), documentKey)\n const result = next(action)\n const newDocument = getDocument(getState(), documentKey)\n\n if (oldDocument != null && newDocument != null && newDocument !== oldDocument) {\n dispatch(\n changeElementTree({\n oldDocument,\n newDocument,\n descriptors: getPropControllerDescriptors(getState()),\n operation,\n }),\n )\n }\n\n return result\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":"AAEA,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAElC,SAAS,wBAAwB;AAEjC,SAAoC,mBAAmB;AACvD,SAAS,oCAAoC;AAEtC,SAAS,8BAAqE;AACnF,SAAO,iBAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,YAAU;AACf,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,gBAAgB,iBAAiB;AACpC,gBAAM,EAAE,aAAa,UAAU,IAAI,OAAO;AAE1C,gBAAM,cAAc,YAAY,SAAS,GAAG,WAAW;AACvD,gBAAM,SAAS,KAAK,MAAM;AAC1B,gBAAM,cAAc,YAAY,SAAS,GAAG,WAAW;AAEvD,cAAI,eAAe,QAAQ,eAAe,QAAQ,gBAAgB,aAAa;AAC7E;AAAA,cACE,kBAAkB;AAAA,gBAChB;AAAA,gBACA;AAAA,gBACA,aAAa,6BAA6B,SAAS,CAAC;AAAA,gBACpD;AAAA,cACF,CAAC;AAAA,YACH;AAAA,UACF;AAEA,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/prop-controllers.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nimport { Descriptor as PropControllerDescriptor } from '../../prop-controllers/descriptors'\n\nexport type { PropControllerDescriptor }\n\nexport type DescriptorsByProp = Record<string, PropControllerDescriptor>\nexport type DescriptorsByComponentType = Map<string, DescriptorsByProp>\nexport type State = DescriptorsByComponentType\n\nexport function getInitialState({\n propControllerDescriptors = new Map(),\n}: {\n propControllerDescriptors?: State\n} = {}): State {\n return propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(state: State): State {\n return state\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): DescriptorsByProp | null {\n return getPropControllerDescriptors(state).get(componentType) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n const deleted = nextState.delete(action.payload.type)\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAU7B,SAAS,gBAAgB;AAAA,EAC9B,4BAA4B,oBAAI,IAAI;AACtC,IAEI,CAAC,GAAU;AACb,SAAO;AACT;AAEO,SAAS,6BAA6B,OAAqB;AAChE,SAAO;AACT;AAEO,SAAS,sCACd,OACA,eAC0B;AAC1B,SAAO,6BAA6B,KAAK,EAAE,IAAI,aAAa,KAAK;AACnE;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,yBAAyB;AAAA,IAEzF,KAAK,oBAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAC/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AACpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/react-components.tsx"],"sourcesContent":["import type { Component, PropsWithoutRef, ReactNode, RefAttributes } from 'react'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\n\nexport type ComponentType<P = Record<string, any>, T = any> =\n | { new (props: PropsWithoutRef<P> & RefAttributes<T>, context?: any): Component<P> }\n | ((props: PropsWithoutRef<P> & RefAttributes<T>, context?: any) => ReactNode)\n\nexport type State = Map<string, ComponentType>\n\nexport function getInitialState({\n reactComponents = new Map(),\n}: { reactComponents?: Map<string, ComponentType> } = {}): State {\n return reactComponents\n}\n\nfunction getReactComponents(state: State): Map<string, ComponentType> {\n return state\n}\n\nexport function getReactComponent(state: State, type: string): ComponentType | null {\n return getReactComponents(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_REACT_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.component)\n\n case ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAEA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAQ7B,SAAS,gBAAgB;AAAA,EAC9B,kBAAkB,oBAAI,IAAI;AAC5B,IAAsD,CAAC,GAAU;AAC/D,SAAO;AACT;AAEA,SAAS,mBAAmB,OAA0C;AACpE,SAAO;AACT;AAEO,SAAS,kBAAkB,OAAc,MAAoC;AAClF,SAAO,mBAAmB,KAAK,EAAE,IAAI,IAAI,KAAK;AAChD;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAgC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS;AAAA,IAEzE,KAAK,oBAAoB,4BAA4B;AACnD,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/read-only-documents.ts"],"sourcesContent":["import { type Element } from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, type DocumentPayload, isKnownAction } from '../actions'\n\nimport { SharedActionTypes } from '../shared-api'\n\nexport {\n type Data,\n type ElementData,\n type ElementReference,\n type Element,\n isElementReference,\n} from '@makeswift/controls'\n\nexport type DocumentReference = {\n key: string\n}\n\nexport function createDocumentReference(key: string): DocumentReference {\n return { key }\n}\n\ntype BaseDocument = {\n key: string\n rootElement: Element\n locale: string | null\n}\n\nexport const EMBEDDED_DOCUMENT_TYPE = 'EMBEDDED_DOCUMENT' as const\n\nexport type EmbeddedDocument = {\n key: string\n locale: string | null\n id: string\n type: string\n name: string\n rootElement: Element\n meta: { allowLocaleFallback: boolean; requestedLocale: string | null; description?: string }\n __type: typeof EMBEDDED_DOCUMENT_TYPE\n}\n\nexport type Document = BaseDocument | EmbeddedDocument\n\nexport function getRootElement(document: Document | DocumentPayload): Element {\n return document.rootElement\n}\n\nexport function createBaseDocument(\n key: string,\n rootElement: Element,\n locale: string | null,\n): Document {\n return { key, rootElement, locale }\n}\n\nexport type State = Map<string, Document>\n\nexport function getInitialState({ documents = [] }: { documents?: Document[] } = {}): State {\n return new Map(documents.map(document => [document.key, document]))\n}\n\nexport function getDocuments(state: State): State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): Document | null {\n return getDocuments(state).get(documentKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case SharedActionTypes.REGISTER_DOCUMENT:\n const { documentKey, document } = action.payload\n return new Map(state).set(documentKey, { ...document, locale: document.locale ?? null })\n\n case SharedActionTypes.UNREGISTER_DOCUMENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.documentKey)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAEA,SAAgE,qBAAqB;AAErF,SAAS,yBAAyB;AAElC;AAAA,EAKE;AAAA,OACK;AAMA,SAAS,wBAAwB,KAAgC;AACtE,SAAO,EAAE,IAAI;AACf;AAQO,MAAM,yBAAyB;AAe/B,SAAS,eAAe,UAA+C;AAC5E,SAAO,SAAS;AAClB;AAEO,SAAS,mBACd,KACA,aACA,QACU;AACV,SAAO,EAAE,KAAK,aAAa,OAAO;AACpC;AAIO,SAAS,gBAAgB,EAAE,YAAY,CAAC,EAAE,IAAgC,CAAC,GAAU;AAC1F,SAAO,IAAI,IAAI,UAAU,IAAI,cAAY,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;AACpE;AAEO,SAAS,aAAa,OAAqB;AAChD,SAAO;AACT;AAEO,SAAS,YAAY,OAAc,aAAsC;AAC9E,SAAO,aAAa,KAAK,EAAE,IAAI,WAAW,KAAK;AACjD;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,kBAAkB;AACrB,YAAM,EAAE,aAAa,SAAS,IAAI,OAAO;AACzC,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,aAAa,EAAE,GAAG,UAAU,QAAQ,SAAS,UAAU,KAAK,CAAC;AAAA,IAEzF,KAAK,kBAAkB,qBAAqB;AAC1C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,WAAW;AAE3D,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/modules/read-write/pointer.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { HostActionTypes } from '../../host-api'\n\nexport type Point = { x: number; y: number }\n\nexport type State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case HostActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,uBAAuB;AAQhC,SAAS,kBAAyB;AAChC,SAAO,EAAE,SAAS,KAAK;AACzB;AAEO,SAAS,WAAW,OAA4B;AACrD,SAAO,MAAM;AACf;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,gBAAgB;AACnB,aAAO,EAAE,GAAG,OAAO,SAAS,OAAO,QAAQ,QAAQ;AAAA,IAErD;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/modules/read-write/read-write-documents.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from '../read-only-documents'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from '../read-only-documents'\nexport { isElementReference } from '../read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n documents = [],\n}: { documents?: ReadOnlyDocuments.Document[] } = {}): State {\n return ReadOnlyDocuments.getInitialState({ documents })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function getDocuments(state: State): ReadOnlyDocuments.State {\n return ReadOnlyDocuments.getDocuments(getReadOnlyDocumentsStateSlice(state))\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const document = getDocument(nextState, action.payload.documentKey)\n if (document == null) return nextState\n\n const currentRootElement = ReadOnlyDocuments.getRootElement(document)\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(action.payload.documentKey, {\n ...document,\n rootElement: nextRootElement,\n })\n }\n\n default:\n return nextState\n }\n}\n"],"mappings":"AACA,SAAS,UAAU,aAAa;AAEhC,YAAY,uBAAuB;AACnC,SAA0C,aAAa,qBAAqB;AAG5E,SAAS,0BAA0B;AAGnC,SAAS,MAAM,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,eAAa;AAE7B,QAAI,UAAU,MAAM;AAAM,gBAAU,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAU,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAC9E,CAAC;AAED,SAAO;AACT;AAIO,SAAS,gBAAgB;AAAA,EAC9B,YAAY,CAAC;AACf,IAAkD,CAAC,GAAU;AAC3D,SAAO,kBAAkB,gBAAgB,EAAE,UAAU,CAAC;AACxD;AAEA,SAAS,+BAA+B,OAAuC;AAC7E,SAAO;AACT;AAEO,SAAS,YAAY,OAAc,aAAwD;AAChG,SAAO,kBAAkB,YAAY,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEO,SAAS,aAAa,OAAuC;AAClE,SAAO,kBAAkB,aAAa,+BAA+B,KAAK,CAAC;AAC7E;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,QAAM,YAAY,kBAAkB,QAAQ,OAAO,MAAM;AAEzD,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,YAAY,iBAAiB;AAChC,YAAM,WAAW,YAAY,WAAW,OAAO,QAAQ,WAAW;AAClE,UAAI,YAAY;AAAM,eAAO;AAE7B,YAAM,qBAAqB,kBAAkB,eAAe,QAAQ;AAEpE,YAAM,kBAAkB,MAAM,oBAAoB,OAAO,QAAQ,SAAS;AAE1E,aAAO,uBAAuB,kBAC1B,YACA,IAAI,IAAI,SAAS,EAAE,IAAI,OAAO,QAAQ,aAAa;AAAA,QACjD,GAAG;AAAA,QACH,aAAa;AAAA,MACf,CAAC;AAAA,IACP;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/site-version.ts"],"sourcesContent":["import { type SiteVersion } from '../../api/site-version'\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\n\nexport type State = SiteVersion | null\n\nexport function getInitialState(siteVersion: SiteVersion | null = null): State {\n return siteVersion\n}\n\nexport function getSiteVersion(state: State): SiteVersion | null {\n return state\n}\n\nexport function reducer(state = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,qBAAqB;AAIxD,SAAS,gBAAgB,cAAkC,MAAa;AAC7E,SAAO;AACT;AAEO,SAAS,eAAe,OAAkC;AAC/D,SAAO;AACT;AAEO,SAAS,QAAQ,QAAQ,gBAAgB,GAAG,QAAuC;AACxF,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FallbackComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/shared/FallbackComponent/FallbackComponent.tsx"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"FallbackComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/shared/FallbackComponent/FallbackComponent.tsx"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,iBAAiB,kGA2B5B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './control';
|
|
2
|
-
export { ControlDefinition, Checkbox, CheckboxDefinition, Code, CodeDefinition, Color, ColorDefinition, Combobox, ComboboxDefinition, Font, FontDefinition, Group, GroupDefinition, GroupControl, IconRadioGroupDefinition, type IconRadioGroupIcon, unstable_IconRadioGroup, Image, ImageDefinition, List, ListDefinition, ListControl, Number, NumberDefinition, Select, SelectDefinition, Shape, ShapeDefinition, ShapeControl, Style, StyleDefinition, type StyleProperty, StyleControl, TextInput, TextInputDefinition, TextArea, TextAreaDefinition, unstable_Typography, unstable_TypographyDefinition, } from '@makeswift/controls';
|
|
2
|
+
export { ControlDefinition, Checkbox, CheckboxDefinition, Code, CodeDefinition, Color, ColorDefinition, Combobox, ComboboxDefinition, Font, FontDefinition, Group, GroupDefinition, GroupControl, IconRadioGroupDefinition, type IconRadioGroupIcon, unstable_IconRadioGroup, Image, ImageDefinition, List, ListDefinition, ListControl, Number, NumberDefinition, Select, SelectDefinition, Shape, ShapeDefinition, ShapeControl, Slider, SliderDefinition, Style, StyleDefinition, type StyleProperty, StyleControl, TextInput, TextInputDefinition, TextArea, TextAreaDefinition, unstable_Typography, unstable_TypographyDefinition, } from '@makeswift/controls';
|
|
3
3
|
export { Link, LinkDefinition } from './link';
|
|
4
4
|
export { RichTextV1Definition, RichTextV1Control } from './rich-text';
|
|
5
5
|
export { RichText, RichTextV2Definition, RichTextV2Control } from './rich-text-v2';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AAEzB,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,KAAK,EACL,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,KAAK,EACL,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,uBAAuB,EACvB,KAAK,EACL,eAAe,EACf,IAAI,EACJ,cAAc,EACd,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,YAAY,EACZ,KAAK,EACL,eAAe,EACf,KAAK,aAAa,EAClB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AAEzB,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,KAAK,EACL,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,KAAK,EACL,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,uBAAuB,EACvB,KAAK,EACL,eAAe,EACf,IAAI,EACJ,cAAc,EACd,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,KAAK,aAAa,EAClB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/controls/serialization/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAA;AA2B5B,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAA;AAE3D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAEpF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC3C,OAAO,EAAE,+BAA+B,GACvC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAOlC;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAA;CACtC,CAAA;AAED,wBAAgB,kBAAkB,CAChC,iBAAiB,EAAE,gBAAgB,EACnC,OAAO,EAAE,yBAAyB,GACjC,iBAAiB,CAInB;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,kBAAkB,GAAG,iBAAiB,CAwC1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,qBAAqB,CAAA;AAU5B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,gBAAgB,IAAI,IAAI,CAAA;CACzB,CAAA;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CA6DxD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CSSObject } from '@emotion/serialize';
|
|
2
|
+
import { type Breakpoints, type ResolvedStyle } from '@makeswift/controls';
|
|
3
|
+
export declare function resolvedStyleToCss(breakpoints: Breakpoints, style: ResolvedStyle): CSSObject;
|
|
4
|
+
//# sourceMappingURL=resolved-style-to-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolved-style-to-css.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/lib/resolved-style-to-css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAA;AA0B5B,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,CAW5F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.7-canary.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "makeswift/makeswift",
|
|
@@ -238,9 +238,9 @@
|
|
|
238
238
|
"use-sync-external-store": "^1.5.0",
|
|
239
239
|
"uuid": "^9.0.0",
|
|
240
240
|
"zod": "^3.21.4",
|
|
241
|
-
"@makeswift/controls": "0.
|
|
241
|
+
"@makeswift/controls": "0.1.20-canary.0",
|
|
242
242
|
"@makeswift/next-plugin": "0.6.1",
|
|
243
|
-
"@makeswift/prop-controllers": "0.4.
|
|
243
|
+
"@makeswift/prop-controllers": "0.4.14-canary.0"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
246
|
"@emotion/jest": "^11.11.0",
|