@makeswift/runtime 0.28.8-canary.2 → 0.28.8-canary.20
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/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/builder/host-to-builder-actions.js +5 -5
- package/dist/cjs/builder/host-to-builder-actions.js.map +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/components/builtin/Embed/Embed.js +2 -1
- package/dist/cjs/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/cjs/controls/index.js +4 -0
- package/dist/cjs/controls/index.js.map +1 -1
- package/dist/cjs/controls/link.js.map +1 -1
- package/dist/cjs/controls/rich-text/control.js +16 -3
- package/dist/cjs/controls/rich-text/control.js.map +1 -1
- package/dist/cjs/controls/rich-text/rich-text.js +2 -2
- package/dist/cjs/controls/rich-text/rich-text.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/control.js +15 -2
- package/dist/cjs/controls/rich-text-v2/control.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +2 -2
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/cjs/controls/serialization/base/index.js +1 -0
- package/dist/cjs/controls/serialization/base/index.js.map +1 -1
- package/dist/cjs/next/testing/breakpoints.js +3 -15
- package/dist/cjs/next/testing/breakpoints.js.map +1 -1
- package/dist/cjs/next/testing/element-data.js +3 -82
- package/dist/cjs/next/testing/element-data.js.map +1 -1
- package/dist/cjs/next/testing/react-runtime.js.map +1 -1
- package/dist/cjs/prop-controllers/instances.js +20 -4
- package/dist/cjs/prop-controllers/instances.js.map +1 -1
- package/dist/cjs/runtimes/react/components/Element.js +37 -12
- package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js +32 -11
- package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/cjs/runtimes/react/components/control-instances-context.js +38 -0
- package/dist/cjs/runtimes/react/components/control-instances-context.js.map +1 -0
- package/dist/cjs/runtimes/react/components/resolve-props.js +12 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +4 -2
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js +2 -2
- package/dist/cjs/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/style.js.map +1 -1
- package/dist/cjs/runtimes/react/element-imperative-handle.js +2 -2
- package/dist/cjs/runtimes/react/element-imperative-handle.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-control-instance.js +88 -0
- package/dist/cjs/runtimes/react/hooks/use-control-instance.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js +29 -0
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +17 -33
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +2 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/{utils/is.js → runtimes/react/stylesheet-factory.js} +3 -12
- package/dist/cjs/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/cjs/runtimes/react/testing/index.js +25 -0
- package/dist/cjs/runtimes/react/testing/index.js.map +1 -0
- package/dist/cjs/runtimes/react/{controls/group.js → testing/react-provider.js} +14 -21
- package/dist/cjs/runtimes/react/testing/react-provider.js.map +1 -0
- package/dist/cjs/slate/TypographyPlugin/normalizeTypographyUp.js.map +1 -1
- package/dist/cjs/slate/selectors.js.map +1 -1
- package/dist/cjs/slate/utils/toText.js.map +1 -1
- package/dist/cjs/state/actions/index.js +4 -4
- package/dist/cjs/state/actions/index.js.map +1 -1
- package/dist/cjs/state/actions/internal/action-types.js +34 -0
- package/dist/cjs/state/actions/internal/action-types.js.map +1 -0
- package/dist/cjs/state/actions/internal/index.js +0 -17
- package/dist/cjs/state/actions/internal/index.js.map +1 -1
- package/dist/cjs/state/actions/internal/read-only-action-types.js +44 -0
- package/dist/cjs/state/actions/internal/read-only-action-types.js.map +1 -0
- package/dist/cjs/state/actions/internal/read-only-actions.js +13 -92
- package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/cjs/state/actions/internal/read-write-action-types.js +42 -0
- package/dist/cjs/state/actions/internal/read-write-action-types.js.map +1 -0
- package/dist/cjs/state/actions/internal/read-write-actions.js +119 -14
- package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/cjs/state/builder-api/action-types.js +49 -0
- package/dist/cjs/state/builder-api/action-types.js.map +1 -0
- package/dist/cjs/state/builder-api/actions.js +14 -36
- package/dist/cjs/state/builder-api/actions.js.map +1 -1
- package/dist/cjs/state/builder-api/proxy.js +2 -1
- package/dist/cjs/state/builder-api/proxy.js.map +1 -1
- package/dist/cjs/state/host-api/action-types.js +43 -0
- package/dist/cjs/state/host-api/action-types.js.map +1 -0
- package/dist/cjs/state/{host-api.js → host-api/actions.js} +17 -33
- package/dist/cjs/state/host-api/actions.js.map +1 -0
- package/dist/cjs/state/host-api/index.js +25 -0
- package/dist/cjs/state/host-api/index.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/builder-api/index.js +15 -15
- package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/cjs/state/middleware/read-write/measure-box-models.js +3 -3
- package/dist/cjs/state/middleware/read-write/measure-box-models.js.map +1 -1
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +10 -47
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -1
- package/dist/cjs/state/modules/api-resources.js +5 -5
- package/dist/cjs/state/modules/api-resources.js.map +1 -1
- package/dist/cjs/state/modules/breakpoints.js +4 -4
- package/dist/cjs/state/modules/breakpoints.js.map +1 -1
- package/dist/cjs/state/modules/components-meta.js +3 -3
- package/dist/cjs/state/modules/components-meta.js.map +1 -1
- package/dist/cjs/state/modules/element-trees.js +53 -25
- package/dist/cjs/state/modules/element-trees.js.map +1 -1
- package/dist/cjs/state/modules/is-in-builder.js +2 -2
- package/dist/cjs/state/modules/is-in-builder.js.map +1 -1
- package/dist/cjs/state/modules/is-read-only.js +2 -2
- package/dist/cjs/state/modules/is-read-only.js.map +1 -1
- package/dist/cjs/state/modules/locale.js +2 -2
- package/dist/cjs/state/modules/locale.js.map +1 -1
- package/dist/cjs/state/modules/localized-resources-map.js +3 -3
- package/dist/cjs/state/modules/localized-resources-map.js.map +1 -1
- package/dist/cjs/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +7 -7
- package/dist/cjs/state/modules/prop-controller-descriptors.js.map +1 -0
- package/dist/cjs/state/modules/react-components.js +3 -3
- package/dist/cjs/state/modules/react-components.js.map +1 -1
- package/dist/cjs/state/modules/read-write/box-models.js +5 -5
- package/dist/cjs/state/modules/read-write/box-models.js.map +1 -1
- package/dist/cjs/state/modules/read-write/element-imperative-handles.js +3 -3
- package/dist/cjs/state/modules/read-write/element-imperative-handles.js.map +1 -1
- package/dist/cjs/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +5 -5
- package/dist/cjs/state/modules/read-write/prop-controllers.js.map +1 -0
- package/dist/cjs/state/read-only-state.js +9 -44
- package/dist/cjs/state/read-only-state.js.map +1 -1
- package/dist/cjs/state/read-write-state.js +37 -0
- package/dist/cjs/state/read-write-state.js.map +1 -1
- package/dist/cjs/state/shared-api/action-types.js +33 -0
- package/dist/cjs/state/shared-api/action-types.js.map +1 -0
- package/dist/cjs/state/{shared-api.js → shared-api/actions.js} +8 -14
- package/dist/cjs/state/shared-api/actions.js.map +1 -0
- package/dist/cjs/state/shared-api/index.js +25 -0
- package/dist/cjs/state/shared-api/index.js.map +1 -0
- package/dist/cjs/state/store.js +5 -3
- package/dist/cjs/state/store.js.map +1 -1
- package/dist/cjs/state/translations/get.js +1 -4
- package/dist/cjs/state/translations/get.js.map +1 -1
- package/dist/cjs/state/translations/merge.js.map +1 -1
- package/dist/cjs/state/unified-state.js +12 -0
- package/dist/cjs/state/unified-state.js.map +1 -1
- package/dist/cjs/testing/breakpoints.js +35 -0
- package/dist/cjs/testing/breakpoints.js.map +1 -0
- package/dist/cjs/testing/element-data.js +102 -0
- package/dist/cjs/testing/element-data.js.map +1 -0
- package/dist/cjs/testing/read-write-state.js +32 -0
- package/dist/cjs/testing/read-write-state.js.map +1 -0
- package/dist/cjs/translations/index.js.map +1 -1
- package/dist/cjs/utils/intersection.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/builder/host-to-builder-actions.js +2 -4
- package/dist/esm/builder/host-to-builder-actions.js.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/components/builtin/Embed/Embed.js +3 -2
- package/dist/esm/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/esm/components/builtin/Form/Form.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js +5 -1
- package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +5 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.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/link.js.map +1 -1
- package/dist/esm/controls/rich-text/control.js +16 -3
- package/dist/esm/controls/rich-text/control.js.map +1 -1
- package/dist/esm/controls/rich-text/rich-text.js +2 -2
- package/dist/esm/controls/rich-text/rich-text.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/control.js +15 -2
- package/dist/esm/controls/rich-text-v2/control.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js +2 -2
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/esm/controls/serialization/base/index.js +2 -0
- package/dist/esm/controls/serialization/base/index.js.map +1 -1
- package/dist/esm/next/testing/breakpoints.js +1 -8
- package/dist/esm/next/testing/breakpoints.js.map +1 -1
- package/dist/esm/next/testing/element-data.js +1 -75
- package/dist/esm/next/testing/element-data.js.map +1 -1
- package/dist/esm/next/testing/react-runtime.js.map +1 -1
- package/dist/esm/prop-controllers/instances.js +20 -4
- package/dist/esm/prop-controllers/instances.js.map +1 -1
- package/dist/esm/runtimes/react/components/Element.js +35 -13
- package/dist/esm/runtimes/react/components/Element.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js +37 -12
- package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/esm/runtimes/react/components/control-instances-context.js +13 -0
- package/dist/esm/runtimes/react/components/control-instances-context.js.map +1 -0
- package/dist/esm/runtimes/react/components/resolve-props.js +12 -1
- package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +4 -2
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.js +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.js.map +1 -1
- package/dist/esm/runtimes/react/controls/style.js.map +1 -1
- package/dist/esm/runtimes/react/element-imperative-handle.js +1 -1
- package/dist/esm/runtimes/react/element-imperative-handle.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-control-instance.js +62 -0
- package/dist/esm/runtimes/react/hooks/use-control-instance.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-control-instances.js +5 -0
- package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-disable-register-element.js +2 -2
- package/dist/esm/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +17 -23
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +2 -1
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/stylesheet-factory.js +1 -0
- package/dist/esm/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/esm/runtimes/react/testing/index.js +3 -0
- package/dist/esm/runtimes/react/testing/index.js.map +1 -0
- package/dist/esm/runtimes/react/testing/react-provider.js +14 -0
- package/dist/esm/runtimes/react/testing/react-provider.js.map +1 -0
- package/dist/esm/slate/TypographyPlugin/normalizeTypographyUp.js.map +1 -1
- package/dist/esm/slate/selectors.js.map +1 -1
- package/dist/esm/slate/utils/toText.js.map +1 -1
- package/dist/esm/state/actions/index.js +2 -2
- package/dist/esm/state/actions/index.js.map +1 -1
- package/dist/esm/state/actions/internal/action-types.js +10 -0
- package/dist/esm/state/actions/internal/action-types.js.map +1 -0
- package/dist/esm/state/actions/internal/index.js +0 -9
- package/dist/esm/state/actions/internal/index.js.map +1 -1
- package/dist/esm/state/actions/internal/read-only-action-types.js +20 -0
- package/dist/esm/state/actions/internal/read-only-action-types.js.map +1 -0
- package/dist/esm/state/actions/internal/read-only-actions.js +1 -73
- package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/esm/state/actions/internal/read-write-action-types.js +18 -0
- package/dist/esm/state/actions/internal/read-write-action-types.js.map +1 -0
- package/dist/esm/state/actions/internal/read-write-actions.js +94 -8
- package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/esm/state/builder-api/action-types.js +25 -0
- package/dist/esm/state/builder-api/action-types.js.map +1 -0
- package/dist/esm/state/builder-api/actions.js +1 -24
- package/dist/esm/state/builder-api/actions.js.map +1 -1
- package/dist/esm/state/builder-api/proxy.js +2 -1
- package/dist/esm/state/builder-api/proxy.js.map +1 -1
- package/dist/esm/state/host-api/action-types.js +19 -0
- package/dist/esm/state/host-api/action-types.js.map +1 -0
- package/dist/esm/state/{host-api.js → host-api/actions.js} +2 -17
- package/dist/esm/state/host-api/actions.js.map +1 -0
- package/dist/esm/state/host-api/index.js +3 -0
- package/dist/esm/state/host-api/index.js.map +1 -0
- package/dist/esm/state/middleware/read-write/builder-api/index.js +1 -1
- package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
- package/dist/esm/state/middleware/read-write/measure-box-models.js +3 -3
- package/dist/esm/state/middleware/read-write/measure-box-models.js.map +1 -1
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js +13 -47
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -1
- package/dist/esm/state/modules/api-resources.js +2 -2
- package/dist/esm/state/modules/api-resources.js.map +1 -1
- package/dist/esm/state/modules/breakpoints.js +2 -2
- package/dist/esm/state/modules/breakpoints.js.map +1 -1
- package/dist/esm/state/modules/components-meta.js +1 -1
- package/dist/esm/state/modules/components-meta.js.map +1 -1
- package/dist/esm/state/modules/element-trees.js +50 -22
- package/dist/esm/state/modules/element-trees.js.map +1 -1
- package/dist/esm/state/modules/is-in-builder.js +1 -1
- package/dist/esm/state/modules/is-in-builder.js.map +1 -1
- package/dist/esm/state/modules/is-read-only.js +1 -1
- package/dist/esm/state/modules/is-read-only.js.map +1 -1
- package/dist/esm/state/modules/locale.js +1 -1
- package/dist/esm/state/modules/locale.js.map +1 -1
- package/dist/esm/state/modules/localized-resources-map.js +1 -1
- package/dist/esm/state/modules/localized-resources-map.js.map +1 -1
- package/dist/esm/state/modules/{prop-controllers.js → prop-controller-descriptors.js} +2 -2
- package/dist/esm/state/modules/prop-controller-descriptors.js.map +1 -0
- package/dist/esm/state/modules/react-components.js +1 -1
- package/dist/esm/state/modules/react-components.js.map +1 -1
- package/dist/esm/state/modules/read-write/box-models.js +2 -2
- package/dist/esm/state/modules/read-write/box-models.js.map +1 -1
- package/dist/esm/state/modules/read-write/element-imperative-handles.js +3 -3
- package/dist/esm/state/modules/read-write/element-imperative-handles.js.map +1 -1
- package/dist/esm/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js} +2 -2
- package/dist/esm/state/modules/read-write/prop-controllers.js.map +1 -0
- package/dist/esm/state/read-only-state.js +9 -41
- package/dist/esm/state/read-only-state.js.map +1 -1
- package/dist/esm/state/read-write-state.js +34 -0
- package/dist/esm/state/read-write-state.js.map +1 -1
- package/dist/esm/state/shared-api/action-types.js +9 -0
- package/dist/esm/state/shared-api/action-types.js.map +1 -0
- package/dist/esm/state/{shared-api.js → shared-api/actions.js} +2 -7
- package/dist/esm/state/shared-api/actions.js.map +1 -0
- package/dist/esm/state/shared-api/index.js +3 -0
- package/dist/esm/state/shared-api/index.js.map +1 -0
- package/dist/esm/state/store.js +3 -1
- package/dist/esm/state/store.js.map +1 -1
- package/dist/esm/state/translations/get.js +1 -4
- package/dist/esm/state/translations/get.js.map +1 -1
- package/dist/esm/state/translations/merge.js +3 -1
- package/dist/esm/state/translations/merge.js.map +1 -1
- package/dist/esm/state/unified-state.js +4 -0
- package/dist/esm/state/unified-state.js.map +1 -1
- package/dist/esm/testing/breakpoints.js +9 -0
- package/dist/esm/testing/breakpoints.js.map +1 -0
- package/dist/esm/testing/element-data.js +76 -0
- package/dist/esm/testing/element-data.js.map +1 -0
- package/dist/esm/testing/read-write-state.js +8 -0
- package/dist/esm/testing/read-write-state.js.map +1 -0
- package/dist/esm/translations/index.js.map +1 -1
- package/dist/esm/utils/intersection.js.map +1 -1
- package/dist/types/api/schema/page-pathname-slice.d.ts +2 -2
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +6 -6
- package/dist/types/api-handler/handlers/webhook/types.d.ts +20 -20
- package/dist/types/builder/host-to-builder-actions.d.ts.map +1 -1
- package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
- package/dist/types/controls/__tests__/slot.test.d.ts +3 -0
- package/dist/types/controls/__tests__/slot.test.d.ts.map +1 -0
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/rich-text/control.d.ts +5 -1
- package/dist/types/controls/rich-text/control.d.ts.map +1 -1
- package/dist/types/controls/rich-text/rich-text.d.ts +2 -2
- package/dist/types/controls/rich-text/rich-text.d.ts.map +1 -1
- package/dist/types/controls/rich-text-v2/control.d.ts +6 -2
- package/dist/types/controls/rich-text-v2/control.d.ts.map +1 -1
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +2 -2
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/controls/serialization/base/index.d.ts.map +1 -1
- package/dist/types/locale.d.ts +1 -1
- package/dist/types/next/testing/breakpoints.d.ts +1 -3
- package/dist/types/next/testing/breakpoints.d.ts.map +1 -1
- package/dist/types/next/testing/element-data.d.ts +1 -54
- package/dist/types/next/testing/element-data.d.ts.map +1 -1
- package/dist/types/next/testing/react-runtime.d.ts.map +1 -1
- package/dist/types/prop-controllers/instances.d.ts +9 -3
- package/dist/types/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementRegistration.d.ts +4 -4
- package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts +3 -0
- package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/control-instances-context.d.ts +9 -0
- package/dist/types/runtimes/react/components/control-instances-context.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map +1 -1
- package/dist/types/runtimes/react/element-imperative-handle.d.ts +1 -1
- package/dist/types/runtimes/react/element-imperative-handle.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/__tests__/use-control-instance.test.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-control-instance.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-control-instance.d.ts +7 -0
- package/dist/types/runtimes/react/hooks/use-control-instance.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +9 -2
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-store.d.ts +2 -4
- package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts +1 -5
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts +9 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/stylesheet-factory.d.ts +6 -0
- package/dist/types/runtimes/react/stylesheet-factory.d.ts.map +1 -0
- package/dist/types/runtimes/react/testing/index.d.ts +3 -0
- package/dist/types/runtimes/react/testing/index.d.ts.map +1 -0
- package/dist/types/runtimes/react/testing/react-provider.d.ts +8 -0
- package/dist/types/runtimes/react/testing/react-provider.d.ts.map +1 -0
- package/dist/types/slate/InlineModePlugin/index.d.ts +1 -1
- package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
- package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
- package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/selectors.d.ts +2 -2
- package/dist/types/slate/selectors.d.ts.map +1 -1
- package/dist/types/slate/utils/toText.d.ts.map +1 -1
- package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts.map +1 -1
- package/dist/types/state/__tests__/fixtures/translatable-content-sample.d.ts.map +1 -1
- package/dist/types/state/__tests__/test-store.d.ts +2 -4
- package/dist/types/state/__tests__/test-store.d.ts.map +1 -1
- package/dist/types/state/actions/index.d.ts +7 -6
- package/dist/types/state/actions/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/action-types.d.ts +27 -0
- package/dist/types/state/actions/internal/action-types.d.ts.map +1 -0
- package/dist/types/state/actions/internal/index.d.ts +0 -25
- package/dist/types/state/actions/internal/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-only-action-types.d.ts +15 -0
- package/dist/types/state/actions/internal/read-only-action-types.d.ts.map +1 -0
- package/dist/types/state/actions/internal/read-only-actions.d.ts +3 -76
- package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-write-action-types.d.ts +15 -0
- package/dist/types/state/actions/internal/read-write-action-types.d.ts.map +1 -0
- package/dist/types/state/actions/internal/read-write-actions.d.ts +71 -8
- package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
- package/dist/types/state/builder-api/action-types.d.ts +22 -0
- package/dist/types/state/builder-api/action-types.d.ts.map +1 -0
- package/dist/types/state/builder-api/actions.d.ts +1 -21
- package/dist/types/state/builder-api/actions.d.ts.map +1 -1
- package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
- package/dist/types/state/host-api/action-types.d.ts +17 -0
- package/dist/types/state/host-api/action-types.d.ts.map +1 -0
- package/dist/types/state/{host-api.d.ts → host-api/actions.d.ts} +7 -22
- package/dist/types/state/host-api/actions.d.ts.map +1 -0
- package/dist/types/state/host-api/index.d.ts +3 -0
- package/dist/types/state/host-api/index.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/__tests__/fixtures/operations.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/__tests__/fixtures/root-elements.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts +2 -0
- package/dist/types/state/middleware/read-write/__tests__/prop-controller-handles.test.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts +2 -0
- package/dist/types/state/middleware/read-write/__tests__/update-element-tree.test.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -1
- package/dist/types/state/modules/__tests__/fixtures/element-trees.d.ts +737 -0
- package/dist/types/state/modules/__tests__/fixtures/element-trees.d.ts.map +1 -1
- package/dist/types/state/modules/components-meta.d.ts +3 -0
- package/dist/types/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/state/modules/element-trees.d.ts +1 -1
- package/dist/types/state/modules/element-trees.d.ts.map +1 -1
- package/dist/types/state/modules/{prop-controllers.d.ts → prop-controller-descriptors.d.ts} +1 -1
- package/dist/types/state/modules/prop-controller-descriptors.d.ts.map +1 -0
- package/dist/types/state/modules/{prop-controller-handles.d.ts → read-write/prop-controllers.d.ts} +4 -4
- package/dist/types/state/modules/{prop-controller-handles.d.ts.map → read-write/prop-controllers.d.ts.map} +1 -1
- package/dist/types/state/read-only-state.d.ts +6 -70
- package/dist/types/state/read-only-state.d.ts.map +1 -1
- package/dist/types/state/read-write-state.d.ts +67 -4
- package/dist/types/state/read-write-state.d.ts.map +1 -1
- package/dist/types/state/shared-api/action-types.d.ts +6 -0
- package/dist/types/state/shared-api/action-types.d.ts.map +1 -0
- package/dist/types/state/{shared-api.d.ts → shared-api/actions.d.ts} +3 -7
- package/dist/types/state/shared-api/actions.d.ts.map +1 -0
- package/dist/types/state/shared-api/index.d.ts +3 -0
- package/dist/types/state/shared-api/index.d.ts.map +1 -0
- package/dist/types/state/store.d.ts +4 -8
- package/dist/types/state/store.d.ts.map +1 -1
- package/dist/types/state/translations/get.d.ts +1 -1
- package/dist/types/state/translations/get.d.ts.map +1 -1
- package/dist/types/state/translations/merge.d.ts +1 -1
- package/dist/types/state/translations/merge.d.ts.map +1 -1
- package/dist/types/state/unified-state.d.ts +2 -0
- package/dist/types/state/unified-state.d.ts.map +1 -1
- package/dist/types/testing/breakpoints.d.ts +4 -0
- package/dist/types/testing/breakpoints.d.ts.map +1 -0
- package/dist/types/testing/element-data.d.ts +59 -0
- package/dist/types/testing/element-data.d.ts.map +1 -0
- package/dist/types/testing/read-write-state.d.ts +3 -0
- package/dist/types/testing/read-write-state.d.ts.map +1 -0
- package/dist/types/translations/index.d.ts +1 -1
- package/dist/types/translations/index.d.ts.map +1 -1
- package/dist/types/utils/intersection.d.ts +2 -1
- package/dist/types/utils/intersection.d.ts.map +1 -1
- package/package.json +9 -6
- package/react/builtins/package.json +1 -1
- package/dist/cjs/runtimes/react/controls/group.js.map +0 -1
- package/dist/cjs/state/host-api.js.map +0 -1
- package/dist/cjs/state/modules/prop-controller-handles.js.map +0 -1
- package/dist/cjs/state/modules/prop-controllers.js.map +0 -1
- package/dist/cjs/state/shared-api.js.map +0 -1
- package/dist/cjs/utils/is.js.map +0 -1
- package/dist/esm/runtimes/react/controls/group.js +0 -23
- package/dist/esm/runtimes/react/controls/group.js.map +0 -1
- package/dist/esm/state/host-api.js.map +0 -1
- package/dist/esm/state/modules/prop-controller-handles.js.map +0 -1
- package/dist/esm/state/modules/prop-controllers.js.map +0 -1
- package/dist/esm/state/shared-api.js.map +0 -1
- package/dist/esm/utils/is.js +0 -6
- package/dist/esm/utils/is.js.map +0 -1
- package/dist/types/runtimes/react/controls/group.d.ts +0 -11
- package/dist/types/runtimes/react/controls/group.d.ts.map +0 -1
- package/dist/types/state/__tests__/fixtures/operations.d.ts.map +0 -1
- package/dist/types/state/__tests__/fixtures/root-elements.d.ts.map +0 -1
- package/dist/types/state/__tests__/react-builder-preview.test.d.ts +0 -2
- package/dist/types/state/__tests__/react-builder-preview.test.d.ts.map +0 -1
- package/dist/types/state/host-api.d.ts.map +0 -1
- package/dist/types/state/modules/prop-controllers.d.ts.map +0 -1
- package/dist/types/state/shared-api.d.ts.map +0 -1
- package/dist/types/utils/is.d.ts +0 -3
- package/dist/types/utils/is.d.ts.map +0 -1
- /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/operations.d.ts +0 -0
- /package/dist/types/state/{__tests__ → middleware/read-write/__tests__}/fixtures/root-elements.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/host-api/actions.ts"],"sourcesContent":["import { isAction } from '@reduxjs/toolkit'\n\nimport { type Operation } from 'ot-json0'\n\nimport { type PropControllerMessage } from '../../prop-controllers/instances'\nimport { type APIResource, APIResourceLocale } from '../../api/types'\n\nimport { BuilderEditMode } from '../modules/builder-edit-mode'\nimport { type Point } from '../modules/read-write/pointer'\n\nimport { type SharedAction } from '../shared-api'\n\nimport { HostActionTypes } from './action-types'\n\ntype InitAction = { type: typeof HostActionTypes.INIT }\n\ntype CleanUpAction = { type: typeof HostActionTypes.CLEAN_UP }\n\ntype ChangeDocumentAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT\n payload: { documentKey: string; operation: Operation }\n}\n\ntype ChangeDocumentElementScrollTopAction = {\n type: typeof HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP\n payload: { scrollTop: number }\n}\n\ntype ScrollDocumentElementAction = {\n type: typeof HostActionTypes.SCROLL_DOCUMENT_ELEMENT\n payload: { scrollTopDelta: number }\n}\n\ntype MessageHostPropControllerAction<T = PropControllerMessage> = {\n type: typeof HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER\n payload: { documentKey: string; elementKey: string; propName: string; message: T }\n}\n\ntype ChangeAPIResourceAction = {\n type: typeof HostActionTypes.CHANGE_API_RESOURCE\n payload: { resource: APIResource; locale?: string | null }\n}\n\ntype EvictAPIResourceAction = {\n type: typeof HostActionTypes.EVICT_API_RESOURCE\n payload: { id: string; locale?: string | null }\n}\n\ntype SetBuilderEditModeAction = {\n type: typeof HostActionTypes.SET_BUILDER_EDIT_MODE\n payload: { editMode: BuilderEditMode }\n}\n\ntype SetLocalizedResourceIdAction = {\n type: typeof HostActionTypes.SET_LOCALIZED_RESOURCE_ID\n // TODO: make `locale` required once we've upgraded the builder to always provide it\n payload: { locale?: string; resourceId: string; localizedResourceId: string | null }\n}\n\ntype BuilderPointerMoveAction = {\n type: typeof HostActionTypes.BUILDER_POINTER_MOVE\n payload: { pointer: Point | null }\n}\n\nexport type HostAction =\n | SharedAction\n | InitAction\n | CleanUpAction\n | ChangeDocumentAction\n | ChangeDocumentElementScrollTopAction\n | ScrollDocumentElementAction\n | MessageHostPropControllerAction\n | ChangeAPIResourceAction\n | EvictAPIResourceAction\n | SetBuilderEditModeAction\n | SetLocalizedResourceIdAction\n | BuilderPointerMoveAction\n\nexport function init(): InitAction {\n return { type: HostActionTypes.INIT }\n}\n\nexport function cleanUp(): CleanUpAction {\n return { type: HostActionTypes.CLEAN_UP }\n}\n\nexport function changeDocument(documentKey: string, operation: Operation): ChangeDocumentAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT, payload: { documentKey, operation } }\n}\n\nexport function changeDocumentElementScrollTop(\n scrollTop: number,\n): ChangeDocumentElementScrollTopAction {\n return { type: HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP, payload: { scrollTop } }\n}\n\nexport function scrollDocumentElement(scrollTopDelta: number): ScrollDocumentElementAction {\n return { type: HostActionTypes.SCROLL_DOCUMENT_ELEMENT, payload: { scrollTopDelta } }\n}\n\nexport function messageHostPropController<T>(\n documentKey: string,\n elementKey: string,\n propName: string,\n message: T,\n): MessageHostPropControllerAction<T> {\n return {\n type: HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER,\n payload: { documentKey, elementKey, propName, message },\n }\n}\n\nexport function changeApiResource<R extends APIResource>(\n resource: R,\n locale?: APIResourceLocale<R>,\n): ChangeAPIResourceAction {\n return { type: HostActionTypes.CHANGE_API_RESOURCE, payload: { resource, locale } }\n}\n\nexport function evictApiResource(id: string, locale?: string | null): EvictAPIResourceAction {\n return { type: HostActionTypes.EVICT_API_RESOURCE, payload: { id, locale } }\n}\n\nexport function setBuilderEditMode(editMode: BuilderEditMode): SetBuilderEditModeAction {\n return {\n type: HostActionTypes.SET_BUILDER_EDIT_MODE,\n payload: { editMode },\n }\n}\n\nexport function setLocalizedResourceId({\n resourceId,\n localizedResourceId,\n locale,\n}: {\n resourceId: string\n localizedResourceId: string | null\n locale?: string\n}): SetLocalizedResourceIdAction {\n return {\n type: HostActionTypes.SET_LOCALIZED_RESOURCE_ID,\n payload: { resourceId, localizedResourceId, locale },\n }\n}\n\nexport function builderPointerMove(pointer: Point | null): BuilderPointerMoveAction {\n return { type: HostActionTypes.BUILDER_POINTER_MOVE, payload: { pointer } }\n}\n\nexport function isHostAction(action: unknown): action is HostAction {\n return isAction(action) && Object.hasOwn(HostActionTypes, action.type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyB;AAYzB,0BAAgC;AAkEzB,SAAS,OAAmB;AACjC,SAAO,EAAE,MAAM,oCAAgB,KAAK;AACtC;AAEO,SAAS,UAAyB;AACvC,SAAO,EAAE,MAAM,oCAAgB,SAAS;AAC1C;AAEO,SAAS,eAAe,aAAqB,WAA4C;AAC9F,SAAO,EAAE,MAAM,oCAAgB,iBAAiB,SAAS,EAAE,aAAa,UAAU,EAAE;AACtF;AAEO,SAAS,+BACd,WACsC;AACtC,SAAO,EAAE,MAAM,oCAAgB,oCAAoC,SAAS,EAAE,UAAU,EAAE;AAC5F;AAEO,SAAS,sBAAsB,gBAAqD;AACzF,SAAO,EAAE,MAAM,oCAAgB,yBAAyB,SAAS,EAAE,eAAe,EAAE;AACtF;AAEO,SAAS,0BACd,aACA,YACA,UACA,SACoC;AACpC,SAAO;AAAA,IACL,MAAM,oCAAgB;AAAA,IACtB,SAAS,EAAE,aAAa,YAAY,UAAU,QAAQ;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,UACA,QACyB;AACzB,SAAO,EAAE,MAAM,oCAAgB,qBAAqB,SAAS,EAAE,UAAU,OAAO,EAAE;AACpF;AAEO,SAAS,iBAAiB,IAAY,QAAgD;AAC3F,SAAO,EAAE,MAAM,oCAAgB,oBAAoB,SAAS,EAAE,IAAI,OAAO,EAAE;AAC7E;AAEO,SAAS,mBAAmB,UAAqD;AACtF,SAAO;AAAA,IACL,MAAM,oCAAgB;AAAA,IACtB,SAAS,EAAE,SAAS;AAAA,EACtB;AACF;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAIiC;AAC/B,SAAO;AAAA,IACL,MAAM,oCAAgB;AAAA,IACtB,SAAS,EAAE,YAAY,qBAAqB,OAAO;AAAA,EACrD;AACF;AAEO,SAAS,mBAAmB,SAAiD;AAClF,SAAO,EAAE,MAAM,oCAAgB,sBAAsB,SAAS,EAAE,QAAQ,EAAE;AAC5E;AAEO,SAAS,aAAa,QAAuC;AAClE,aAAO,yBAAS,MAAM,KAAK,OAAO,OAAO,qCAAiB,OAAO,IAAI;AACvE;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var host_api_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(host_api_exports);
|
|
18
|
+
__reExport(host_api_exports, require("./action-types"), module.exports);
|
|
19
|
+
__reExport(host_api_exports, require("./actions"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./action-types"),
|
|
23
|
+
...require("./actions")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/host-api/index.ts"],"sourcesContent":["export * from './action-types'\nexport * from './actions'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,2BAAd;AACA,6BAAc,sBADd;","names":[]}
|
|
@@ -21,7 +21,7 @@ __export(builder_api_exports, {
|
|
|
21
21
|
builderAPIMiddleware: () => builderAPIMiddleware
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(builder_api_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_action_types = require("../../../builder-api/action-types");
|
|
25
25
|
var import_toolkit2 = require("../../../toolkit");
|
|
26
26
|
var import_host_api = require("../../../host-api");
|
|
27
27
|
var import_initialize_connection = require("./initialize-connection");
|
|
@@ -33,20 +33,20 @@ function builderAPIMiddleware(builderProxy) {
|
|
|
33
33
|
};
|
|
34
34
|
return (action) => {
|
|
35
35
|
switch (action.type) {
|
|
36
|
-
case
|
|
37
|
-
case
|
|
38
|
-
case
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
36
|
+
case import_action_types.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:
|
|
37
|
+
case import_action_types.BuilderActionTypes.MOUNT_COMPONENT:
|
|
38
|
+
case import_action_types.BuilderActionTypes.UNMOUNT_COMPONENT:
|
|
39
|
+
case import_action_types.BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:
|
|
40
|
+
case import_action_types.BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:
|
|
41
|
+
case import_action_types.BuilderActionTypes.HANDLE_WHEEL:
|
|
42
|
+
case import_action_types.BuilderActionTypes.HANDLE_POINTER_MOVE:
|
|
43
|
+
case import_action_types.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:
|
|
44
|
+
case import_action_types.BuilderActionTypes.SET_LOCALE:
|
|
45
|
+
case import_action_types.BuilderActionTypes.SET_BREAKPOINTS:
|
|
46
|
+
case import_action_types.BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:
|
|
47
|
+
case import_action_types.BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:
|
|
48
|
+
case import_action_types.BuilderActionTypes.REGISTER_BUILDER_COMPONENT:
|
|
49
|
+
case import_action_types.BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:
|
|
50
50
|
builderProxy.execute(action);
|
|
51
51
|
break;
|
|
52
52
|
case import_host_api.HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/action-types'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTo({\n top: action.payload.scrollTop,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollBy({\n top: action.payload.scrollTopDelta,\n behavior: 'instant',\n })\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n // and in response to host's client-side navigation\n cleanUp() // cleanup existing connection setup, if any\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n cleanUp = () => {}\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAmC;AAEnC,IAAAA,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS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_box_models_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(measure_box_models_exports);
|
|
34
34
|
var BoxModels = __toESM(require("../../modules/read-write/box-models"));
|
|
35
|
-
var
|
|
35
|
+
var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
|
|
36
36
|
var ReadWriteActions = __toESM(require("../../actions/internal/read-write-actions"));
|
|
37
37
|
var import_toolkit2 = require("../../toolkit");
|
|
38
38
|
function measureBoxModelsMiddleware() {
|
|
39
39
|
return (0, import_toolkit2.actionMiddleware)(({ dispatch }) => (next) => {
|
|
40
40
|
return (action) => {
|
|
41
41
|
switch (action.type) {
|
|
42
|
-
case
|
|
42
|
+
case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
43
43
|
if (BoxModels.isMeasurable(action.payload.componentHandle)) {
|
|
44
44
|
dispatch(
|
|
45
45
|
ReadWriteActions.registerMeasurable(
|
|
@@ -51,7 +51,7 @@ function measureBoxModelsMiddleware() {
|
|
|
51
51
|
}
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
|
-
case
|
|
54
|
+
case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE:
|
|
55
55
|
dispatch(
|
|
56
56
|
ReadWriteActions.unregisterMeasurable(
|
|
57
57
|
action.payload.documentKey,
|
|
@@ -1 +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 {
|
|
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 { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\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 ReadWriteActionTypes.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 ReadWriteActionTypes.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAA2B;AAG3B,qCAAqC;AACrC,uBAAkC;AAElC,IAAAA,kBAAiC;AAI1B,SAAS,6BAAoE;AAClF,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oDAAqB,2BAA2B;AACnD,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,oDAAqB;AACxB;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":["import_toolkit"]}
|
|
@@ -31,70 +31,33 @@ __export(prop_controller_handles_exports, {
|
|
|
31
31
|
propControllerHandlesMiddleware: () => propControllerHandlesMiddleware
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(prop_controller_handles_exports);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var import_read_only_actions = require("../../actions/internal/read-only-actions");
|
|
37
|
-
var ReadOnly = __toESM(require("../../actions/internal/read-only-actions"));
|
|
34
|
+
var PropControllers = __toESM(require("../../modules/read-write/prop-controllers"));
|
|
35
|
+
var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
|
|
38
36
|
var import_toolkit2 = require("../../toolkit");
|
|
39
|
-
var import_instances = require("../../../prop-controllers/instances");
|
|
40
37
|
var import_host_api = require("../../host-api");
|
|
41
38
|
var ReadOnlyState = __toESM(require("../../read-only-state"));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const descriptors = ReadOnlyState.getElementPropControllerDescriptors(
|
|
45
|
-
getState(),
|
|
46
|
-
documentKey,
|
|
47
|
-
elementKey
|
|
48
|
-
);
|
|
49
|
-
if (descriptors == null)
|
|
50
|
-
return null;
|
|
51
|
-
const propControllers = Object.entries(descriptors).reduce(
|
|
52
|
-
(acc, [propName, descriptor]) => {
|
|
53
|
-
const propController = (0, import_instances.createPropController)(
|
|
54
|
-
descriptor,
|
|
55
|
-
(message) => dispatch(
|
|
56
|
-
Builder.messageBuilderPropController(documentKey, elementKey, propName, message)
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
return { ...acc, [propName]: propController };
|
|
60
|
-
},
|
|
61
|
-
{}
|
|
62
|
-
);
|
|
63
|
-
dispatch(ReadOnly.registerPropControllers(documentKey, elementKey, propControllers));
|
|
64
|
-
return propControllers;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
39
|
+
var import_read_write_state = require("../../read-write-state");
|
|
40
|
+
var import_read_write_actions = require("../../actions/internal/read-write-actions");
|
|
67
41
|
function propControllerHandlesMiddleware() {
|
|
68
42
|
return (0, import_toolkit2.actionMiddleware)(({ dispatch, getState }) => (next) => {
|
|
69
43
|
return (action) => {
|
|
70
44
|
switch (action.type) {
|
|
71
|
-
case
|
|
45
|
+
case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
72
46
|
const { documentKey, elementKey, componentHandle } = action.payload;
|
|
73
47
|
const element = ReadOnlyState.getElement(getState(), documentKey, elementKey);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
if (element != null && !ReadOnlyState.isElementReference(element) && PropControllerHandles.isPropControllersHandle(componentHandle)) {
|
|
78
|
-
dispatch(
|
|
79
|
-
ReadOnly.registerPropControllersHandle(documentKey, elementKey, componentHandle)
|
|
80
|
-
);
|
|
81
|
-
componentHandle.setPropControllers(propControllers);
|
|
48
|
+
if (element != null && !ReadOnlyState.isElementReference(element) && PropControllers.isPropControllersHandle(componentHandle)) {
|
|
49
|
+
dispatch((0, import_read_write_actions.registerPropControllersHandle)(documentKey, elementKey, componentHandle));
|
|
82
50
|
}
|
|
83
51
|
break;
|
|
84
52
|
}
|
|
85
|
-
case
|
|
53
|
+
case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
|
|
86
54
|
const { documentKey, elementKey } = action.payload;
|
|
87
|
-
|
|
88
|
-
documentKey,
|
|
89
|
-
elementKey
|
|
90
|
-
});
|
|
91
|
-
handle?.setPropControllers(null);
|
|
92
|
-
dispatch(ReadOnly.unregisterPropControllers(documentKey, elementKey));
|
|
55
|
+
dispatch((0, import_read_write_actions.unregisterPropControllersHandle)(documentKey, elementKey));
|
|
93
56
|
break;
|
|
94
57
|
}
|
|
95
58
|
case import_host_api.HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {
|
|
96
59
|
const { documentKey, elementKey, propName, message } = action.payload;
|
|
97
|
-
const propController =
|
|
60
|
+
const propController = (0, import_read_write_state.getPropController)(getState(), {
|
|
98
61
|
documentKey,
|
|
99
62
|
elementKey,
|
|
100
63
|
propName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport * as PropControllers from '../../modules/read-write/prop-controllers'\n\nimport { type Action } from '../../actions'\n\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nimport { actionMiddleware } from '../../toolkit'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\n\nimport { type State, type Dispatch, getPropController } from '../../read-write-state'\n\nimport {\n registerPropControllersHandle,\n unregisterPropControllersHandle,\n} from '../../actions/internal/read-write-actions'\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllers.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n }\n\n break\n }\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n dispatch(unregisterPropControllersHandle(documentKey, elementKey))\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAiC;AAIjC,qCAAqC;AAErC,IAAAA,kBAAiC;AACjC,sBAAgC;AAEhC,oBAA+B;AAE/B,8BAA6D;AAE7D,gCAGO;AAEA,SAAS,kCAAyE;AACvF,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oDAAqB,2BAA2B;AACnD,gBAAM,EAAE,aAAa,YAAY,gBAAgB,IAAI,OAAO;AAC5D,gBAAM,UAAU,cAAc,WAAW,SAAS,GAAG,aAAa,UAAU;AAE5E,cACE,WAAW,QACX,CAAC,cAAc,mBAAmB,OAAO,KACzC,gBAAgB,wBAAwB,eAAe,GACvD;AACA,yBAAS,yDAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,UAClF;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oDAAqB,6BAA6B;AACrD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,uBAAS,2DAAgC,aAAa,UAAU,CAAC;AACjE;AAAA,QACF;AAAA,QAEA,KAAK,gCAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,qBAAiB,2CAAkB,SAAS,GAAG;AAAA,YACnD;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":["import_toolkit"]}
|
|
@@ -38,8 +38,8 @@ module.exports = __toCommonJS(api_resources_exports);
|
|
|
38
38
|
var import_api = require("../../api");
|
|
39
39
|
var import_deepEqual = __toESM(require("../../utils/deepEqual"));
|
|
40
40
|
var import_actions = require("../actions");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
41
|
+
var import_read_only_action_types = require("../actions/internal/read-only-action-types");
|
|
42
|
+
var import_read_write_action_types = require("../actions/internal/read-write-action-types");
|
|
43
43
|
var import_host_api = require("../host-api");
|
|
44
44
|
function isValidAPIResourceType(resourceType) {
|
|
45
45
|
return resourceType in import_api.APIResourceType;
|
|
@@ -119,7 +119,7 @@ function reducer(state = getInitialState(), action) {
|
|
|
119
119
|
if (!(0, import_actions.isKnownAction)(action))
|
|
120
120
|
return state;
|
|
121
121
|
switch (action.type) {
|
|
122
|
-
case
|
|
122
|
+
case import_read_write_action_types.ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {
|
|
123
123
|
const { apiResources } = action.payload;
|
|
124
124
|
return Object.entries(apiResources).reduce((state2, [resourceType, cachedResources]) => {
|
|
125
125
|
const resType = resourceType;
|
|
@@ -132,10 +132,10 @@ function reducer(state = getInitialState(), action) {
|
|
|
132
132
|
return updated == null || updated === existing ? state2 : new Map(state2).set(resType, updated);
|
|
133
133
|
}, state);
|
|
134
134
|
}
|
|
135
|
-
case
|
|
135
|
+
case import_read_write_action_types.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {
|
|
136
136
|
return getInitialState();
|
|
137
137
|
}
|
|
138
|
-
case
|
|
138
|
+
case import_read_only_action_types.ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {
|
|
139
139
|
const { resourceType, resourceId, resource, locale } = action.payload;
|
|
140
140
|
return new Map(state).set(
|
|
141
141
|
resourceType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-actions'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-actions'\nimport { HostActionTypes } from '../host-api'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : 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 ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return deepEqual(r.get(cid), value) ? r : new Map(r).set(cid, value)\n }, existing)\n\n return updated == null || updated === existing\n ? state\n : new Map(state).set(resType, updated)\n }, state)\n }\n\n case ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n case ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,qBAA+D;AAC/D,+BAAoC;AACpC,gCAAqC;AACrC,sBAAgC;AAIhC,SAAS,uBAAuB,cAAuD;AACrF,SAAO,gBAAgB;AACzB;AAEA,SAAS,6BACP,cAC4C;AAC5C,SAAO,gBAAgB;AACzB;AAEA,SAAS,YACP,YACA,cACA,QACqB;AACrB,SACE,UAAU,QAAQ,6BAA6B,YAAY,IACvD,GAAG,UAAU,IAAI,MAAM,KACvB;AAER;AAEA,SAAS,iBAAiBA,cAA2D;AACnF,QAAM,CAAC,YAAY,MAAM,IAAIA,aAAY,MAAM,GAAG;AAClD,SAAO,CAAC,YAAY,UAAU,IAAI;AACpC;AAYO,SAAS,gBACd,kBAAmC;AAAA,EACjC,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,mBAAmB,CAAC;AAAA,EACpB,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,wBAAwB,CAAC;AAC3B,GACO;AACP,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,e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;AAAA,IAEA,KAAK,gCAAgB,qBAAqB;AACxC,YAAM,EAAE,UAAU,OAAO,IAAI,OAAO;AACpC,YAAM,sBAAsB,eAAe,OAAO,SAAS,YAAY,SAAS,IAAI,MAAM;AAE1F,cAAI,iBAAAC,SAAU,qBAAqB,QAAQ;AAAG,eAAO;AAErD,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,SAAS;AAAA,QACT,IAAI,IAAI,MAAM,IAAI,SAAS,UAAU,CAAE,EAAE;AAAA,UACvC,YAAY,SAAS,IAAI,SAAS,YAAY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,gCAAgB,oBAAoB;AACvC,YAAM,EAAE,IAAI,OAAO,IAAI,OAAO;AAC9B,YAAM,CAAC,cAAc,UAAU,IAAI,GAAG,MAAM,GAAG;AAE/C,UAAI,CAAC,uBAAuB,YAAY;AAAG,eAAO;AAElD,YAAM,YAAY,IAAI,IAAI,MAAM,IAAI,YAA+B,CAAE;AAErE,YAAM,UAAU,UAAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/api-resources.ts"],"sourcesContent":["import {\n APIResourceType,\n APIResourceLocale,\n LocalizableAPIResourceType,\n type APIResource,\n} from '../../api'\n\nimport deepEqual from '../../utils/deepEqual'\nimport { Branded } from '../../utils/branded'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\nimport { ReadWriteActionTypes } from '../actions/internal/read-write-action-types'\nimport { HostActionTypes } from '../host-api'\n\ntype CompositeResourceId = Branded<string, 'CompositeResourceId'>\n\nfunction isValidAPIResourceType(resourceType: string): resourceType is APIResourceType {\n return resourceType in APIResourceType\n}\n\nfunction isLocalizableAPIResourceType(\n resourceType: APIResourceType,\n): resourceType is LocalizableAPIResourceType {\n return resourceType in LocalizableAPIResourceType\n}\n\nfunction compositeId(\n resourceId: string,\n resourceType: APIResourceType,\n locale?: string | null,\n): CompositeResourceId {\n return (\n locale != null && isLocalizableAPIResourceType(resourceType)\n ? `${resourceId}@${locale}`\n : resourceId\n ) as CompositeResourceId\n}\n\nfunction parseCompositeId(compositeId: CompositeResourceId): [string, string | null] {\n const [resourceId, locale] = compositeId.split('@')\n return [resourceId, locale ?? null]\n}\n\nexport type State = Map<APIResourceType, Map<CompositeResourceId, APIResource | null>>\n\nexport type SerializedState = {\n [key in APIResourceType]?: {\n id: string\n value: Extract<APIResource, { __typename: key }> | null\n locale?: APIResourceLocale<key>\n }[]\n}\n\nexport function getInitialState(\n serializedState: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n },\n): State {\n return new Map(\n Object.entries(serializedState).map(([resourceType, resources]) => [\n resourceType,\n new Map(\n resources.map(({ id, value, locale }) => [\n compositeId(id, resourceType as APIResourceType, locale),\n value,\n ]),\n ),\n ]),\n ) as State\n}\n\nexport function getSerializedState(state: State): SerializedState {\n const resourceMap: SerializedState = {\n Swatch: [],\n File: [],\n Typography: [],\n PagePathnameSlice: [],\n GlobalElement: [],\n Table: [],\n Snippet: [],\n Page: [],\n Site: [],\n LocalizedGlobalElement: [],\n }\n\n Array.from(state.entries()).forEach(([resourceType, resources]) => {\n const particularResourceMap: { id: string; value: any; locale?: any }[] = []\n\n Array.from(resources.entries()).forEach(([compositeId, value]) => {\n if (value != null) {\n const [id, locale] = parseCompositeId(compositeId)\n console.assert(\n locale == null || isLocalizableAPIResourceType(resourceType),\n `Unexpected locale for non-localizable resource type ${resourceType}`,\n { id, locale },\n )\n\n particularResourceMap.push(locale != null ? { id, value, locale } : { id, value })\n }\n })\n\n resourceMap[resourceType] = particularResourceMap\n })\n\n return resourceMap\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n return state.get(resourceType)?.has(compositeId(resourceId, resourceType, locale)) ?? false\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n const resource = state.get(resourceType)?.get(compositeId(resourceId, resourceType, locale))\n\n return resource?.__typename === resourceType\n ? (resource as Extract<typeof resource, { __typename: T }>)\n : 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 ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE: {\n const { apiResources } = action.payload\n\n return Object.entries(apiResources).reduce((state, [resourceType, cachedResources]) => {\n const resType = resourceType as APIResourceType\n const cached:\n | { id: string; value: APIResource | null; locale?: string | null }[]\n | undefined = cachedResources\n\n const existing = state.get(resType) ?? new Map<CompositeResourceId, APIResource | null>()\n const updated = cached?.reduce((r, { id, value, locale }) => {\n const cid = compositeId(id, resType, locale)\n return deepEqual(r.get(cid), value) ? r : new Map(r).set(cid, value)\n }, existing)\n\n return updated == null || updated === existing\n ? state\n : new Map(state).set(resType, updated)\n }, state)\n }\n\n case ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE: {\n return getInitialState()\n }\n\n case ReadOnlyActionTypes.API_RESOURCE_FULFILLED: {\n const { resourceType, resourceId, resource, locale } = action.payload\n return new Map(state).set(\n resourceType,\n new Map(state.get(resourceType)!).set(\n compositeId(resourceId, resourceType, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.CHANGE_API_RESOURCE: {\n const { resource, locale } = action.payload\n const existingApiResource = getAPIResource(state, resource.__typename, resource.id, locale)\n\n if (deepEqual(existingApiResource, resource)) return state\n\n return new Map(state).set(\n resource.__typename,\n new Map(state.get(resource.__typename)!).set(\n compositeId(resource.id, resource.__typename, locale),\n resource,\n ),\n )\n }\n\n case HostActionTypes.EVICT_API_RESOURCE: {\n const { id, locale } = action.payload\n const [resourceType, resourceId] = id.split(':')\n\n if (!isValidAPIResourceType(resourceType)) return state\n\n const resources = new Map(state.get(resourceType as APIResourceType)!)\n\n const deleted = resources.delete(compositeId(resourceId, resourceType, locale))\n\n return deleted ? new Map(state).set(resourceType as APIResourceType, resources) : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;AAEP,uBAAsB;AAGtB,qBAA+D;AAC/D,oCAAoC;AACpC,qCAAqC;AACrC,sBAAgC;AAIhC,SAAS,uBAAuB,cAAuD;AACrF,SAAO,gBAAgB;AACzB;AAEA,SAAS,6BACP,cAC4C;AAC5C,SAAO,gBAAgB;AACzB;AAEA,SAAS,YACP,YACA,cACA,QACqB;AACrB,SACE,UAAU,QAAQ,6BAA6B,YAAY,IACvD,GAAG,UAAU,IAAI,MAAM,KACvB;AAER;AAEA,SAAS,iBAAiBA,cAA2D;AACnF,QAAM,CAAC,YAAY,MAAM,IAAIA,aAAY,MAAM,GAAG;AAClD,SAAO,CAAC,YAAY,UAAU,IAAI;AACpC;AAYO,SAAS,gBACd,kBAAmC;AAAA,EACjC,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,mBAAmB,CAAC;AAAA,EACpB,eAAe,CAAC;AAAA,EAChB,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,wBAAwB,CAAC;AAC3B,GACO;AACP,SAAO,IAAI;AAAA,IACT,OAAO,QAAQ,eAAe,EAAE,IAAI,CAAC,CA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B,qBAAqB;AACxC,YAAM,EAAE,UAAU,OAAO,IAAI,OAAO;AACpC,YAAM,sBAAsB,eAAe,OAAO,SAAS,YAAY,SAAS,IAAI,MAAM;AAE1F,cAAI,iBAAAC,SAAU,qBAAqB,QAAQ;AAAG,eAAO;AAErD,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,SAAS;AAAA,QACT,IAAI,IAAI,MAAM,IAAI,SAAS,UAAU,CAAE,EAAE;AAAA,UACvC,YAAY,SAAS,IAAI,SAAS,YAAY,MAAM;AAAA,UACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,gCAAgB,oBAAoB;AACvC,YAAM,EAAE,IAAI,OAAO,IAAI,OAAO;AAC9B,YAAM,CAAC,cAAc,UAAU,IAAI,GAAG,MAAM,GAAG;AAE/C,UAAI,CAAC,uBAAuB,YAAY;AAAG,eAAO;AAElD,YAAM,YAAY,IAAI,IAAI,MAAM,IAAI,YAA+B,CAAE;AAErE,YAAM,UAAU,UAAU,OAAO,YAAY,YAAY,cAAc,MAAM,CAAC;AAE9E,aAAO,UAAU,IAAI,IAAI,KAAK,EAAE,IAAI,cAAiC,SAAS,IAAI;AAAA,IACpF;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":["compositeId","state","deepEqual"]}
|
|
@@ -30,8 +30,8 @@ __export(breakpoints_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(breakpoints_exports);
|
|
31
31
|
var import_controls = require("@makeswift/controls");
|
|
32
32
|
var import_actions = require("../actions");
|
|
33
|
-
var
|
|
34
|
-
var
|
|
33
|
+
var import_action_types = require("../actions/internal/action-types");
|
|
34
|
+
var import_action_types2 = require("../builder-api/action-types");
|
|
35
35
|
var import_is_server = require("../../utils/is-server");
|
|
36
36
|
var import_controls2 = require("@makeswift/controls");
|
|
37
37
|
const DefaultBreakpointID = {
|
|
@@ -84,7 +84,7 @@ function reducer(state = getInitialState(), action) {
|
|
|
84
84
|
if (!(0, import_actions.isKnownAction)(action))
|
|
85
85
|
return state;
|
|
86
86
|
switch (action.type) {
|
|
87
|
-
case
|
|
87
|
+
case import_action_types2.BuilderActionTypes.SET_BREAKPOINTS: {
|
|
88
88
|
const breakpoints = action.payload.breakpoints;
|
|
89
89
|
if (breakpoints.length === 0)
|
|
90
90
|
throw new Error("Breakpoints cannot be empty.");
|
|
@@ -94,7 +94,7 @@ function reducer(state = getInitialState(), action) {
|
|
|
94
94
|
clientBreakpoint: getMatchingMediaBreakpointId(breakpoints)
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
case
|
|
97
|
+
case import_action_types.InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {
|
|
98
98
|
const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints);
|
|
99
99
|
if (clientBreakpoint === state.clientBreakpoint)
|
|
100
100
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal'\nimport { BuilderActionTypes } from '../builder-api/
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/breakpoints.ts"],"sourcesContent":["import {\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n getBaseBreakpoint,\n getBreakpointMediaQuery,\n} from '@makeswift/controls'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { InternalActionTypes } from '../actions/internal/action-types'\nimport { BuilderActionTypes } from '../builder-api/action-types'\nimport { isServer } from '../../utils/is-server'\n\nexport {\n getBreakpoint,\n type Breakpoint,\n type BreakpointId,\n type Breakpoints,\n} from '@makeswift/controls'\n\nexport type State = {\n breakpoints: Breakpoints\n baseBreakpoint: BreakpointId\n clientBreakpoint: BreakpointId\n}\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = (typeof DefaultBreakpointID)[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport const getDeviceQueries = (breakpoints: Breakpoints) =>\n breakpoints.map(device => ({\n id: device.id,\n query: getBreakpointMediaQuery(device).replace('@media', ''),\n }))\n\nconst getBaseBreakpointId = (breakpoints: Breakpoints): BreakpointId =>\n getBaseBreakpoint(breakpoints).id\n\n// Intentional impurity in the reducer buys us several practical upsides here:\n//\n// - We can keep `SET_BREAKPOINTS` atomic by recalculating the client breakpoint\n// state when we update the set of available breakpoints; if we don't do that\n// here, we'll have to do it from the outside, and the state will temporarily\n// hold a stale client breakpoint value in between\n//\n// - We can have a valid, internally consistent *initial* state for the client\n// breakpoint; if we move the client breakpoint calculation out of the reducer,\n// we'll be forced to start with a stale initial state, which will introduce\n// implicit coupling and potential timing issues between the\n// `useCurrentBreakpoint` hook and the client breakpoint synchronization code\n// in `BreakpointWatch`\n//\n// - `UPDATE_CLIENT_BREAKPOINT` can compute the client breakpoint from browser\n// state using the current breakpoint set instead of having to validate and\n// handle external payload\n\nexport function getMatchingMediaBreakpointId(breakpoints: Breakpoints): BreakpointId {\n const baseBreakpoint = getBaseBreakpointId(breakpoints)\n if (isServer()) return baseBreakpoint\n\n // using `findLast` to preserve the legacy behavior; might not be necessary\n const matchingBreakpoint = getDeviceQueries(breakpoints).findLast(\n ({ query }) => window.matchMedia(query).matches,\n )\n\n return matchingBreakpoint?.id ?? baseBreakpoint\n}\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\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 BuilderActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return {\n breakpoints,\n baseBreakpoint: getBaseBreakpointId(breakpoints),\n clientBreakpoint: getMatchingMediaBreakpointId(breakpoints),\n }\n }\n\n case InternalActionTypes.UPDATE_CLIENT_BREAKPOINT: {\n const clientBreakpoint = getMatchingMediaBreakpointId(state.breakpoints)\n if (clientBreakpoint === state.clientBreakpoint) return state\n\n return { ...state, clientBreakpoint }\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width.\n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMO;AAEP,qBAA+D;AAC/D,0BAAoC;AACpC,IAAAA,uBAAmC;AACnC,uBAAyB;AAEzB,IAAAC,mBAKO;AAQA,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,MAAM,mBAAmB,CAAC,gBAC/B,YAAY,IAAI,aAAW;AAAA,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QAAQ,CAAC;AAE5B,QAAI,YAAY,QAAQ,WAAW,KAAK,OAAO;AAC7C,YAAM,IAAI;AAAA,QACR,wBAAwB,EAAE;AAAA,WACvB,EAAE,uBAAuB,QAAQ,+BAA+B,KAAK,EAAE,oBAAoB,KAAK,KAAK;AAAA,MAC1G;AAAA,IACF;AAEA,QAAI,QAAQ,UAAU,KAAK,OAAO;AAChC,YAAM,IAAI;AAAA,QACR,4CAA4C,EAAE,UAAU,KAAK,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_action_types","import_controls"]}
|
|
@@ -26,7 +26,7 @@ __export(components_meta_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(components_meta_exports);
|
|
28
28
|
var import_actions = require("../actions");
|
|
29
|
-
var
|
|
29
|
+
var import_read_only_action_types = require("../actions/internal/read-only-action-types");
|
|
30
30
|
const ComponentIcon = {
|
|
31
31
|
Accordion: "accordion",
|
|
32
32
|
Audio: "audio",
|
|
@@ -75,9 +75,9 @@ function reducer(state = getInitialState(), action) {
|
|
|
75
75
|
if (!(0, import_actions.isKnownAction)(action))
|
|
76
76
|
return state;
|
|
77
77
|
switch (action.type) {
|
|
78
|
-
case
|
|
78
|
+
case import_read_only_action_types.ReadOnlyActionTypes.REGISTER_COMPONENT:
|
|
79
79
|
return new Map(state).set(action.payload.type, action.payload.meta);
|
|
80
|
-
case
|
|
80
|
+
case import_read_only_action_types.ReadOnlyActionTypes.UNREGISTER_COMPONENT: {
|
|
81
81
|
const nextState = new Map(state);
|
|
82
82
|
const deleted = nextState.delete(action.payload.type);
|
|
83
83
|
return deleted ? nextState : state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? 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.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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C/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -43,8 +43,8 @@ var import_immutable = require("immutable");
|
|
|
43
43
|
var import_controls = require("@makeswift/controls");
|
|
44
44
|
var Introspection = __toESM(require("../../prop-controllers/introspection"));
|
|
45
45
|
var import_actions = require("../actions");
|
|
46
|
-
var
|
|
47
|
-
var
|
|
46
|
+
var import_read_only_action_types = require("../actions/internal/read-only-action-types");
|
|
47
|
+
var import_read_write_action_types = require("../actions/internal/read-write-action-types");
|
|
48
48
|
var import_read_only_documents = require("./read-only-documents");
|
|
49
49
|
function getInitialState(documents, descriptors) {
|
|
50
50
|
const state = /* @__PURE__ */ new Map();
|
|
@@ -74,19 +74,19 @@ function reducer(state = getInitialState(), action) {
|
|
|
74
74
|
if (!(0, import_actions.isKnownAction)(action))
|
|
75
75
|
return state;
|
|
76
76
|
switch (action.type) {
|
|
77
|
-
case
|
|
77
|
+
case import_read_only_action_types.ReadOnlyActionTypes.CREATE_ELEMENT_TREE: {
|
|
78
78
|
const { document, descriptors } = action.payload;
|
|
79
79
|
return new Map(state).set(
|
|
80
80
|
document.key,
|
|
81
81
|
buildElementTree((0, import_read_only_documents.getRootElement)(document), descriptors)
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
-
case
|
|
84
|
+
case import_read_only_action_types.ReadOnlyActionTypes.DELETE_ELEMENT_TREE: {
|
|
85
85
|
const nextState = new Map(state);
|
|
86
86
|
const deleted = nextState.delete(action.payload.documentKey);
|
|
87
87
|
return deleted ? nextState : state;
|
|
88
88
|
}
|
|
89
|
-
case
|
|
89
|
+
case import_read_write_action_types.ReadWriteActionTypes.CHANGE_ELEMENT_TREE: {
|
|
90
90
|
const { oldDocument, newDocument, descriptors, operation } = action.payload;
|
|
91
91
|
const documentKey = oldDocument.key;
|
|
92
92
|
console.assert(
|
|
@@ -199,32 +199,60 @@ function updateParentElements(elements, elementPaths, rootElement) {
|
|
|
199
199
|
elements.set(element.key, element);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function getPropChildren(element, propName, descriptors) {
|
|
203
203
|
if ((0, import_controls.isElementReference)(element))
|
|
204
|
-
return
|
|
204
|
+
return null;
|
|
205
205
|
const propDescriptor = descriptors.get(element.type)?.[propName];
|
|
206
206
|
if (propDescriptor == null)
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
return children.length > 0;
|
|
207
|
+
return null;
|
|
208
|
+
return Introspection.getElementChildren(propDescriptor, element.props[propName]);
|
|
210
209
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
function isChildrenProp(element, propName, descriptors) {
|
|
211
|
+
const children = getPropChildren(element, propName, descriptors);
|
|
212
|
+
return children != null;
|
|
213
|
+
}
|
|
214
|
+
function deleteElement({ elements, elementIds }, elementToDelete, descriptors) {
|
|
215
|
+
for (const element of traverseElementTree(elementToDelete, descriptors)) {
|
|
216
|
+
elements.delete(element.key);
|
|
217
|
+
elementIds.delete(element.key);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function deleteChildrenInProp(elementTree, parentElement, propName, descriptors) {
|
|
221
|
+
const childrenInProp = getPropChildren(parentElement, propName, descriptors);
|
|
222
|
+
if (childrenInProp == null) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
for (const child of childrenInProp) {
|
|
226
|
+
deleteElement(elementTree, child, descriptors);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors) {
|
|
230
|
+
if (propName == null) {
|
|
231
|
+
deleteElement({ elements, elementIds }, targetElement, descriptors);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (isChildrenProp(targetElement, propName, descriptors)) {
|
|
235
|
+
deleteChildrenInProp({ elements, elementIds }, targetElement, propName, descriptors);
|
|
236
|
+
}
|
|
237
|
+
const elementInTree = elements.get(targetElement.key);
|
|
238
|
+
if (!elementInTree) {
|
|
239
|
+
console.error(
|
|
240
|
+
`Attempting to remove prop ${propName} from element ${targetElement.key} not found in tree`
|
|
241
|
+
);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (!(0, import_controls.isElementReference)(elementInTree)) {
|
|
245
|
+
const newProps = { ...elementInTree.props };
|
|
246
|
+
delete newProps[propName];
|
|
247
|
+
elements.set(targetElement.key, { ...elementInTree, props: newProps });
|
|
220
248
|
}
|
|
221
249
|
}
|
|
222
250
|
function applyDelete(elementTree, descriptors, rootElements, path) {
|
|
223
|
-
const [
|
|
224
|
-
const [
|
|
251
|
+
const [targetElementPath, ...parentElementPaths] = getChangedElementsPaths(path);
|
|
252
|
+
const [targetElement, propName] = getElementAndPropName(rootElements.before, targetElementPath);
|
|
225
253
|
const elements = new Map(elementTree.elements);
|
|
226
254
|
const elementIds = new Map(elementTree.elementIds);
|
|
227
|
-
|
|
255
|
+
deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors);
|
|
228
256
|
updateParentElements(elements, parentElementPaths, rootElements.after);
|
|
229
257
|
return {
|
|
230
258
|
elements,
|
|
@@ -232,7 +260,7 @@ function applyDelete(elementTree, descriptors, rootElements, path) {
|
|
|
232
260
|
};
|
|
233
261
|
}
|
|
234
262
|
function insertElement({ elements, elementIds }, insertedElement, propName, descriptors) {
|
|
235
|
-
if (propName == null ||
|
|
263
|
+
if (propName == null || isChildrenProp(insertedElement, propName, descriptors)) {
|
|
236
264
|
for (const element of traverseElementTree(insertedElement, descriptors)) {
|
|
237
265
|
elements.set(element.key, element);
|
|
238
266
|
if (!(0, import_controls.isElementReference)(element)) {
|
|
@@ -264,11 +292,11 @@ function applyInsert(elementTree, descriptors, rootElements, path) {
|
|
|
264
292
|
}
|
|
265
293
|
function applyUpdate(elementTree, descriptors, rootElements, path) {
|
|
266
294
|
const [updateElementPath, ...parentElementPaths] = getChangedElementsPaths(path);
|
|
267
|
-
const [
|
|
295
|
+
const [targetElement, propName] = getElementAndPropName(rootElements.before, updateElementPath);
|
|
268
296
|
const [insertedElement, _] = getElementAndPropName(rootElements.after, updateElementPath);
|
|
269
297
|
const elements = new Map(elementTree.elements);
|
|
270
298
|
const elementIds = new Map(elementTree.elementIds);
|
|
271
|
-
|
|
299
|
+
deleteElementOrProp({ elements, elementIds }, targetElement, propName, descriptors);
|
|
272
300
|
insertElement({ elements, elementIds }, insertedElement, propName, descriptors);
|
|
273
301
|
updateParentElements(elements, parentElementPaths, rootElements.after);
|
|
274
302
|
return {
|