@makeswift/runtime 0.28.8-canary.13 → 0.28.8-canary.15
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/Form/Form.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/runtimes/react/components/Element.js +21 -6
- package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js +5 -3
- package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js +5 -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/rich-text.js +2 -2
- package/dist/cjs/runtimes/react/controls/rich-text/rich-text.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-instances.js +4 -3
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +10 -9
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- 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/testing/react-provider.js +38 -0
- package/dist/cjs/runtimes/react/testing/react-provider.js.map +1 -0
- 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 +41 -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 +62 -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 +12 -13
- 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 +5 -5
- 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 +3 -3
- package/dist/cjs/state/store.js.map +1 -1
- 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/translations/index.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/Form/Form.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/runtimes/react/components/Element.js +18 -6
- package/dist/esm/runtimes/react/components/Element.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js +4 -2
- package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/esm/runtimes/react/components/resolve-props.js +5 -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/rich-text.js +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/rich-text.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-instances.js +3 -2
- package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -9
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- 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/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 +17 -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 +51 -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 +19 -13
- 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 +2 -2
- 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 +1 -1
- package/dist/esm/state/store.js.map +1 -1
- 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/translations/index.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/Form/Form.d.ts +1 -1
- package/dist/types/components/builtin/Form/Form.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/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/runtimes/react/components/Element.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementRegistration.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
- 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/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/use-control-instances.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +4 -3
- 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/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/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 +6 -6
- package/dist/types/state/actions/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/action-types.d.ts +26 -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 +14 -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 +57 -9
- 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/prop-controller-handles.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 +1 -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 +55 -0
- package/dist/types/testing/element-data.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/package.json +2 -2
- 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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/state/modules/read-write/box-models.ts"],"sourcesContent":["import { type BoxDisplayModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/modules/read-write/box-models.ts"],"sourcesContent":["import { type BoxDisplayModel } from '@makeswift/controls'\nimport {\n createBox as createBoxWithoutScroll,\n CreateBoxArgs,\n getBox as getBoxWithoutScroll,\n withScroll,\n} from 'css-box-model'\n\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\nimport { BuilderActionTypes } from '../../builder-api/action-types'\n\nexport type { BoxDisplayModel }\n\nexport function parse(rawString: string): number {\n const value = Number(rawString.replace(/px$/, ''))\n\n return Number.isFinite(value) ? value : 0\n}\n\nexport function createBox(boxArgs: CreateBoxArgs & { visible?: boolean }): BoxDisplayModel {\n const box = withScroll(createBoxWithoutScroll(boxArgs))\n return { ...box, visible: boxArgs.visible }\n}\n\nexport function isElementVisible(element: Element): boolean {\n // checkVisibility is widely supported as of March 2024, but we're adding this\n // check as a precaution for browsers where it may not be available.\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility\n if (element.checkVisibility == null) {\n return true\n }\n\n return element.checkVisibility({\n visibilityProperty: true,\n contentVisibilityAuto: true,\n opacityProperty: true,\n })\n}\n\nexport function getBox(element: Element): BoxDisplayModel {\n const visible = isElementVisible(element)\n const boxModel = withScroll(getBoxWithoutScroll(element))\n\n return { ...boxModel, visible }\n}\n\nexport interface BoxModelHandle {\n getBoxModel(): BoxDisplayModel | null\n}\n\nexport type Measurable = Element | BoxModelHandle\n\nexport function isMeasurable(value: unknown): value is Measurable {\n if (value instanceof Element) return true\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'getBoxModel' in value &&\n typeof (value as { getBoxModel: unknown }).getBoxModel === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport function measure(measurable: Measurable): BoxDisplayModel | null {\n if (measurable instanceof Element) return getBox(measurable)\n\n return measurable.getBoxModel()\n}\n\nexport type State = {\n measurables: Map<string, Map<string, Measurable>>\n boxModels: Map<string, Map<string, BoxDisplayModel>>\n}\n\nexport function getInitialState(): State {\n return { measurables: new Map(), boxModels: new Map() }\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, Measurable>> {\n return state.measurables\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxDisplayModel>> {\n return state.boxModels\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxDisplayModel | null {\n return getBoxModels(state).get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction) {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_MEASURABLE: {\n const { documentKey, elementKey, measurable } = action.payload\n\n return {\n ...state,\n measurables: new Map(state.measurables).set(\n documentKey,\n new Map(state.measurables.get(documentKey) ?? []).set(elementKey, measurable),\n ),\n }\n }\n\n case ReadWriteActionTypes.UNREGISTER_MEASURABLE: {\n const { documentKey, elementKey } = action.payload\n const nextMeasurables = new Map(state.measurables.get(documentKey) ?? [])\n\n const deleted = nextMeasurables.delete(elementKey)\n\n return deleted\n ? { ...state, measurables: new Map(state.measurables).set(documentKey, nextMeasurables) }\n : state\n }\n\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS: {\n const { changedElementBoxModels } = action.payload\n\n if (changedElementBoxModels.size === 0) return state\n\n const nextBoxModels = new Map(state.boxModels)\n\n changedElementBoxModels.forEach((changedBoxModels, documentKey) => {\n const nextDocumentBoxModels = new Map(nextBoxModels.get(documentKey) ?? [])\n\n changedBoxModels.forEach((changedBoxModel, elementKey) => {\n if (changedBoxModel == null) nextDocumentBoxModels.delete(elementKey)\n else nextDocumentBoxModels.set(elementKey, changedBoxModel)\n })\n\n if (nextDocumentBoxModels.size > 0) nextBoxModels.set(documentKey, nextDocumentBoxModels)\n else nextBoxModels.delete(documentKey)\n })\n\n return { ...state, boxModels: nextBoxModels }\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA;AAAA,EACE,aAAa;AAAA,EAEb,UAAU;AAAA,EACV;AAAA,OACK;AAEP,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAI5B,SAAS,MAAM,WAA2B;AAC/C,QAAM,QAAQ,OAAO,UAAU,QAAQ,OAAO,EAA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
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isKnownAction } from "../../actions";
|
|
2
|
-
import {
|
|
2
|
+
import { ReadWriteActionTypes } from "../../actions/internal/read-write-action-types";
|
|
3
3
|
function getElementImperativeHandles(state) {
|
|
4
4
|
return state;
|
|
5
5
|
}
|
|
@@ -10,7 +10,7 @@ function reducer(state = getInitialState(), action) {
|
|
|
10
10
|
if (!isKnownAction(action))
|
|
11
11
|
return state;
|
|
12
12
|
switch (action.type) {
|
|
13
|
-
case
|
|
13
|
+
case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE:
|
|
14
14
|
return new Map(state).set(
|
|
15
15
|
action.payload.documentKey,
|
|
16
16
|
new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
|
|
@@ -18,7 +18,7 @@ function reducer(state = getInitialState(), action) {
|
|
|
18
18
|
action.payload.componentHandle
|
|
19
19
|
)
|
|
20
20
|
);
|
|
21
|
-
case
|
|
21
|
+
case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
|
|
22
22
|
const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
|
|
23
23
|
const deleted = byElementKey.delete(action.payload.elementKey);
|
|
24
24
|
if (!deleted)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/state/modules/read-write/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/modules/read-write/element-imperative-handles.ts"],"sourcesContent":["import { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\nimport { type Action, type UnknownAction, isKnownAction } from '../../actions'\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nexport type State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\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.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,qBAAqB;AAC/D,SAAS,4BAA4B;AAI9B,SAAS,4BACd,OACmD;AACnD,SAAO;AACT;AAEA,SAAS,kBAAyB;AAChC,SAAO,oBAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,qBAAqB;AACxB,aAAO,IAAI,IAAI,KAAK,EAAE;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAAA,UAC5D,OAAO,QAAQ;AAAA,UACf,OAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IAEF,KAAK,qBAAqB,6BAA6B;AACrD,YAAM,eAAe,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ,WAAW,KAAK,CAAC,CAAC;AAExE,YAAM,UAAU,aAAa,OAAO,OAAO,QAAQ,UAAU;AAE7D,UAAI,CAAC;AAAS,eAAO;AAErB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,aAAa,YAAY;AAAA,IACpE;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
package/dist/esm/state/modules/{prop-controller-handles.js → read-write/prop-controllers.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionTypes, isKnownAction } from "
|
|
1
|
+
import { ActionTypes, isKnownAction } from "../../actions";
|
|
2
2
|
function isPropControllersHandle(value) {
|
|
3
3
|
if (typeof value === "object" && value !== null && "setPropControllers" in value && typeof value.setPropControllers === "function") {
|
|
4
4
|
return true;
|
|
@@ -65,4 +65,4 @@ export {
|
|
|
65
65
|
isPropControllersHandle,
|
|
66
66
|
reducer
|
|
67
67
|
};
|
|
68
|
-
//# sourceMappingURL=prop-
|
|
68
|
+
//# sourceMappingURL=prop-controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/modules/read-write/prop-controllers.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../../actions'\nimport type { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport type { Descriptor } from '../../../prop-controllers/descriptors'\n\nexport interface PropControllersHandle<\n T extends Record<string, Descriptor> = Record<string, Descriptor>,\n> {\n setPropControllers(propControllers: DescriptorsPropControllers<T> | null): void\n}\n\nexport function isPropControllersHandle(value: unknown): value is PropControllersHandle {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'setPropControllers' in value &&\n typeof (value as { setPropControllers: unknown }).setPropControllers === 'function'\n ) {\n return true\n }\n\n return false\n}\n\nexport type State = {\n handles: Map<string, Map<string, PropControllersHandle>>\n instances: Map<string, Map<string, Record<string, ControlInstance>>>\n}\n\nexport function getInitialState(): State {\n return { handles: new Map(), instances: new Map() }\n}\n\nexport function getPropControllersHandle(\n state: State,\n documentKey: string,\n elementKey: string,\n): PropControllersHandle | null {\n return state.handles.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropControllers(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, ControlInstance> | null {\n return state.instances.get(documentKey)?.get(elementKey) ?? null\n}\n\nexport function getPropController(\n state: State,\n documentKey: string,\n elementKey: string,\n propName: string,\n): ControlInstance | null {\n return getPropControllers(state, documentKey, elementKey)?.[propName] ?? 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 ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey, handle } = action.payload\n\n return {\n ...state,\n handles: new Map(state.handles).set(\n documentKey,\n new Map(state.handles.get(documentKey) ?? []).set(elementKey, handle),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const nextHandles = new Map(state.handles.get(documentKey) ?? [])\n\n const deleted = nextHandles.delete(elementKey)\n\n return deleted\n ? { ...state, handles: new Map(state.handles).set(documentKey, nextHandles) }\n : state\n }\n\n case ActionTypes.REGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey, propControllers } = action.payload\n\n return {\n ...state,\n instances: new Map(state.instances).set(\n documentKey,\n new Map(state.instances.get(documentKey) ?? []).set(elementKey, propControllers),\n ),\n }\n }\n\n case ActionTypes.UNREGISTER_PROP_CONTROLLERS: {\n const { documentKey, elementKey } = action.payload\n const nextInstances = new Map(state.instances.get(documentKey) ?? [])\n\n const deleted = nextInstances.delete(elementKey)\n\n return deleted\n ? { ...state, instances: new Map(state.instances).set(documentKey, nextInstances) }\n : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AACA,SAA0C,aAAa,qBAAqB;AAUrE,SAAS,wBAAwB,OAAgD;AACtF,MACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACxB,OAAQ,MAA0C,uBAAuB,YACzE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOO,SAAS,kBAAyB;AACvC,SAAO,EAAE,SAAS,oBAAI,IAA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C;AAAA,UACA,IAAI,IAAI,MAAM,UAAU,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,IAAI,YAAY,eAAe;AAAA,QACjF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,KAAK,YAAY,6BAA6B;AAC5C,YAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,YAAM,gBAAgB,IAAI,IAAI,MAAM,UAAU,IAAI,WAAW,KAAK,CAAC,CAAC;AAEpE,YAAM,UAAU,cAAc,OAAO,UAAU;AAE/C,aAAO,UACH,EAAE,GAAG,OAAO,WAAW,IAAI,IAAI,MAAM,SAAS,EAAE,IAAI,aAAa,aAAa,EAAE,IAChF;AAAA,IACN;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -5,8 +5,7 @@ import * as Documents from "./modules/read-only-documents";
|
|
|
5
5
|
import * as ElementTrees from "./modules/element-trees";
|
|
6
6
|
import * as ReactComponents from "./modules/react-components";
|
|
7
7
|
import * as ComponentsMeta from "./modules/components-meta";
|
|
8
|
-
import * as
|
|
9
|
-
import * as PropControllerHandles from "./modules/prop-controller-handles";
|
|
8
|
+
import * as PropControllerDescriptors from "./modules/prop-controller-descriptors";
|
|
10
9
|
import * as IsInBuilder from "./modules/is-in-builder";
|
|
11
10
|
import * as IsReadOnly from "./modules/is-read-only";
|
|
12
11
|
import * as BuilderEditMode from "./modules/builder-edit-mode";
|
|
@@ -25,8 +24,7 @@ const reducers = {
|
|
|
25
24
|
elementTrees: ElementTrees.reducer,
|
|
26
25
|
reactComponents: ReactComponents.reducer,
|
|
27
26
|
componentsMeta: ComponentsMeta.reducer,
|
|
28
|
-
|
|
29
|
-
propControllerHandles: PropControllerHandles.reducer,
|
|
27
|
+
propControllerDescriptors: PropControllerDescriptors.reducer,
|
|
30
28
|
isInBuilder: IsInBuilder.reducer,
|
|
31
29
|
builderEditMode: BuilderEditMode.reducer,
|
|
32
30
|
breakpoints: Breakpoints.reducer
|
|
@@ -61,47 +59,20 @@ function getComponentsMeta(state) {
|
|
|
61
59
|
function getComponentMeta(state, type) {
|
|
62
60
|
return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type);
|
|
63
61
|
}
|
|
64
|
-
function
|
|
65
|
-
return state.
|
|
62
|
+
function getPropControllerDescriptorsStateSlice(state) {
|
|
63
|
+
return state.propControllerDescriptors;
|
|
66
64
|
}
|
|
67
65
|
function getPropControllerDescriptors(state) {
|
|
68
|
-
return
|
|
66
|
+
return PropControllerDescriptors.getPropControllerDescriptors(
|
|
67
|
+
getPropControllerDescriptorsStateSlice(state)
|
|
68
|
+
);
|
|
69
69
|
}
|
|
70
70
|
function getComponentPropControllerDescriptors(state, componentType) {
|
|
71
|
-
return
|
|
72
|
-
|
|
71
|
+
return PropControllerDescriptors.getComponentPropControllerDescriptors(
|
|
72
|
+
getPropControllerDescriptorsStateSlice(state),
|
|
73
73
|
componentType
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
function getPropControllerHandlesStateSlice(state) {
|
|
77
|
-
return state.propControllerHandles;
|
|
78
|
-
}
|
|
79
|
-
function getPropControllers(state, { documentKey, elementKey }) {
|
|
80
|
-
return PropControllerHandles.getPropControllers(
|
|
81
|
-
getPropControllerHandlesStateSlice(state),
|
|
82
|
-
documentKey,
|
|
83
|
-
elementKey
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
function getPropControllersHandle(state, { documentKey, elementKey }) {
|
|
87
|
-
return PropControllerHandles.getPropControllersHandle(
|
|
88
|
-
getPropControllerHandlesStateSlice(state),
|
|
89
|
-
documentKey,
|
|
90
|
-
elementKey
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
function getPropController(state, {
|
|
94
|
-
documentKey,
|
|
95
|
-
elementKey,
|
|
96
|
-
propName
|
|
97
|
-
}) {
|
|
98
|
-
return PropControllerHandles.getPropController(
|
|
99
|
-
getPropControllerHandlesStateSlice(state),
|
|
100
|
-
documentKey,
|
|
101
|
-
elementKey,
|
|
102
|
-
propName
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
76
|
const getDocumentKeysSortedByDepth = createSelector(
|
|
106
77
|
[getDocumentsStateSlice, getElementTreesSlice],
|
|
107
78
|
(documents, elementTrees) => {
|
|
@@ -164,10 +135,7 @@ export {
|
|
|
164
135
|
getIsInBuilder,
|
|
165
136
|
getIsReadOnly,
|
|
166
137
|
getLocale,
|
|
167
|
-
getPropController,
|
|
168
138
|
getPropControllerDescriptors,
|
|
169
|
-
getPropControllers,
|
|
170
|
-
getPropControllersHandle,
|
|
171
139
|
getReactComponent,
|
|
172
140
|
getRootElement,
|
|
173
141
|
isElementReference,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nfunction getBreakpointsStateSlice(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getBreakpoints(state: State): Breakpoints.Breakpoints {\n return getBreakpointsStateSlice(state).breakpoints\n}\n\nexport function getBaseBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).baseBreakpoint\n}\n\nexport function getClientBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).clientBreakpoint\n}\n\nexport function getLocale(state: State): string | null {\n return state.locale\n}\n"],"mappings":"AAEA,SAAS,sBAAsB;AAE/B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,YAAY,qBAAqB;AACjC,YAAY,2BAA2B;AACvC,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,qBAAqB;AACjC,YAAY,iBAAiB;AAa7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM,WAAW;AAAA,EACtB,aAAa,YAAY;AAAA,EACzB,YAAY,WAAW;AAAA,EACvB,QAAQ,OAAO;AAAA,EACf,WAAW,UAAU;AAAA,EACrB,cAAc,aAAa;AAAA,EAC3B,iBAAiB,gBAAgB;AAAA,EACjC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,gBAAgB;AAAA,EACjC,uBAAuB,sBAAsB;AAAA,EAC7C,aAAa,YAAY;AAAA,EACzB,iBAAiB,gBAAgB;AAAA,EACjC,aAAa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EAAE;AACzC;AAEO,SAAS,UAAU,OAA6B;AACrD,SAAO,MAAM;AACf;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Locale from './modules/locale'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllerDescriptors from './modules/prop-controller-descriptors'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n siteVersion: SiteVersion.reducer,\n isReadOnly: IsReadOnly.reducer,\n locale: Locale.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllerDescriptors: PropControllerDescriptors.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n siteVersion: SiteVersion.State\n isReadOnly: IsReadOnly.State\n locale: Locale.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllerDescriptors: PropControllerDescriptors.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllerDescriptorsStateSlice(state: State): PropControllerDescriptors.State {\n return state.propControllerDescriptors\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllerDescriptors.State {\n return PropControllerDescriptors.getPropControllerDescriptors(\n getPropControllerDescriptorsStateSlice(state),\n )\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllerDescriptors.DescriptorsByProp | null {\n return PropControllerDescriptors.getComponentPropControllerDescriptors(\n getPropControllerDescriptorsStateSlice(state),\n componentType,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllerDescriptors.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nfunction getBreakpointsStateSlice(state: State): Breakpoints.State {\n return state.breakpoints\n}\n\nexport function getBreakpoints(state: State): Breakpoints.Breakpoints {\n return getBreakpointsStateSlice(state).breakpoints\n}\n\nexport function getBaseBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).baseBreakpoint\n}\n\nexport function getClientBreakpoint(state: State): Breakpoints.BreakpointId {\n return getBreakpointsStateSlice(state).clientBreakpoint\n}\n\nexport function getLocale(state: State): string | null {\n return state.locale\n}\n"],"mappings":"AAEA,SAAS,sBAAsB;AAE/B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,YAAY,+BAA+B;AAC3C,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,qBAAqB;AACjC,YAAY,iBAAiB;AAa7B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toolkit";
|
|
|
2
2
|
import * as Documents from "./modules/read-write/read-write-documents";
|
|
3
3
|
import * as BoxModels from "./modules/read-write/box-models";
|
|
4
4
|
import * as Pointer from "./modules/read-write/pointer";
|
|
5
|
+
import * as PropControllers from "./modules/read-write/prop-controllers";
|
|
5
6
|
import * as ElementImperativeHandles from "./modules/read-write/element-imperative-handles";
|
|
6
7
|
import * as ReadOnlyState from "./read-only-state";
|
|
7
8
|
import { createBox, getBox, parse } from "./modules/read-write/box-models";
|
|
@@ -10,6 +11,7 @@ const reducers = {
|
|
|
10
11
|
documents: Documents.reducer,
|
|
11
12
|
boxModels: BoxModels.reducer,
|
|
12
13
|
pointer: Pointer.reducer,
|
|
14
|
+
propControllers: PropControllers.reducer,
|
|
13
15
|
elementImperativeHandles: ElementImperativeHandles.reducer
|
|
14
16
|
};
|
|
15
17
|
function createRootReducer() {
|
|
@@ -59,6 +61,35 @@ function getElementImperativeHandlesContainingElement(state, element) {
|
|
|
59
61
|
}
|
|
60
62
|
return filteredElementImperativeHandles;
|
|
61
63
|
}
|
|
64
|
+
function getPropControllersStateSlice(state) {
|
|
65
|
+
return state.propControllers;
|
|
66
|
+
}
|
|
67
|
+
function getPropControllers(state, { documentKey, elementKey }) {
|
|
68
|
+
return PropControllers.getPropControllers(
|
|
69
|
+
getPropControllersStateSlice(state),
|
|
70
|
+
documentKey,
|
|
71
|
+
elementKey
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function getPropControllersHandle(state, { documentKey, elementKey }) {
|
|
75
|
+
return PropControllers.getPropControllersHandle(
|
|
76
|
+
getPropControllersStateSlice(state),
|
|
77
|
+
documentKey,
|
|
78
|
+
elementKey
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function getPropController(state, {
|
|
82
|
+
documentKey,
|
|
83
|
+
elementKey,
|
|
84
|
+
propName
|
|
85
|
+
}) {
|
|
86
|
+
return PropControllers.getPropController(
|
|
87
|
+
getPropControllersStateSlice(state),
|
|
88
|
+
documentKey,
|
|
89
|
+
elementKey,
|
|
90
|
+
propName
|
|
91
|
+
);
|
|
92
|
+
}
|
|
62
93
|
function setupBuilderProxy(builderProxy) {
|
|
63
94
|
return (dispatch) => {
|
|
64
95
|
return builderProxy.setup({ onHostAction: (action) => dispatch(action) });
|
|
@@ -76,6 +107,9 @@ export {
|
|
|
76
107
|
getElementImperativeHandlesContainingElement,
|
|
77
108
|
getMeasurables,
|
|
78
109
|
getPointer,
|
|
110
|
+
getPropController,
|
|
111
|
+
getPropControllers,
|
|
112
|
+
getPropControllersHandle,
|
|
79
113
|
parse,
|
|
80
114
|
setupBuilderProxy
|
|
81
115
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxDisplayModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxDisplayModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<VoidFunction, State, unknown, Action> {\n return dispatch => {\n return builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":"AAAA,SAAS,uBAA6D;AAEtE,YAAY,eAAe;AAC3B,YAAY,eAAe;AAC3B,YAAY,aAAa;AACzB,YAAY,8BAA8B;AAO1C,YAAY,mBAAmB;AAI/B,SAAS,WAAW,QAAQ,aAAa;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,SAAO,gBAAgB,QAAQ;AACjC;
|
|
1
|
+
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as PropControllers from './modules/read-write/prop-controllers'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n propControllers: PropControllers.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n propControllers: PropControllers.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxDisplayModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxDisplayModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllers.getPropControllers(\n getPropControllersStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllers.getPropControllersHandle(\n getPropControllersStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllers.getPropController(\n getPropControllersStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<VoidFunction, State, unknown, Action> {\n return dispatch => {\n return builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":"AAAA,SAAS,uBAA6D;AAEtE,YAAY,eAAe;AAC3B,YAAY,eAAe;AAC3B,YAAY,aAAa;AACzB,YAAY,qBAAqB;AACjC,YAAY,8BAA8B;AAO1C,YAAY,mBAAmB;AAI/B,SAAS,WAAW,QAAQ,aAAa;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,iBAAiB,gBAAgB;AAAA,EACjC,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,SAAO,gBAAgB,QAAQ;AACjC;AAYA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;AACf;AAEO,SAAS,aAAa,OAA+B;AAC1D,SAAO,UAAU,aAAa,uBAAuB,KAAK,CAAC;AAC7D;AAEO,SAAS,YAAY,OAAc,aAAgD;AACxF,SAAO,UAAU,YAAY,uBAAuB,KAAK,GAAG,WAAW;AACzE;AAEA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;A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;AACF,GACA;AACA,SAAO,gBAAgB;AAAA,IACrB,6BAA6B,KAAK;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,cACmD;AACnD,SAAO,cAAY;AACjB,WAAO,aAAa,MAAM,EAAE,cAAc,YAAU,SAAS,MAAM,EAAE,CAAC;AAAA,EACxE;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/shared-api/action-types.ts"],"sourcesContent":["// bidirectional action types, both the host and the builder can dispatch these actions\nexport const SharedActionTypes = {\n MAKESWIFT_CONNECTION_INIT: 'MAKESWIFT_CONNECTION_INIT',\n\n REGISTER_DOCUMENT: 'REGISTER_DOCUMENT',\n UNREGISTER_DOCUMENT: 'UNREGISTER_DOCUMENT',\n} as const\n"],"mappings":"AACO,MAAM,oBAAoB;AAAA,EAC/B,2BAA2B;AAAA,EAE3B,mBAAmB;AAAA,EACnB,qBAAqB;AACvB;","names":[]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
MAKESWIFT_CONNECTION_INIT: "MAKESWIFT_CONNECTION_INIT",
|
|
3
|
-
REGISTER_DOCUMENT: "REGISTER_DOCUMENT",
|
|
4
|
-
UNREGISTER_DOCUMENT: "UNREGISTER_DOCUMENT"
|
|
5
|
-
};
|
|
1
|
+
import { SharedActionTypes } from "./action-types";
|
|
6
2
|
function makeswiftConnectionInit() {
|
|
7
3
|
return {
|
|
8
4
|
type: SharedActionTypes.MAKESWIFT_CONNECTION_INIT
|
|
@@ -26,10 +22,9 @@ function registerDocumentsEffect(documents) {
|
|
|
26
22
|
};
|
|
27
23
|
}
|
|
28
24
|
export {
|
|
29
|
-
SharedActionTypes,
|
|
30
25
|
makeswiftConnectionInit,
|
|
31
26
|
registerDocument,
|
|
32
27
|
registerDocumentsEffect,
|
|
33
28
|
unregisterDocument
|
|
34
29
|
};
|
|
35
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/shared-api/actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Element, type Document, EMBEDDED_DOCUMENT_TYPE } from '../modules/read-only-documents'\n\nimport { SharedActionTypes } from './action-types'\n\ntype DocumentPayloadBaseDocument = {\n key: string\n rootElement: Element\n locale?: string | null // older versions of the runtime may not provide this field\n}\n\ntype DocumentPayloadEmbeddedDocument = {\n key: string\n locale: string | null\n id: string\n type: string\n name: string\n rootElement: Element\n meta: { allowLocaleFallback: boolean; requestedLocale: string | null; description?: string }\n __type: typeof EMBEDDED_DOCUMENT_TYPE\n}\n\nexport type DocumentPayload = DocumentPayloadBaseDocument | DocumentPayloadEmbeddedDocument\n\ntype MakeswiftConnectionInitAction = { type: typeof SharedActionTypes.MAKESWIFT_CONNECTION_INIT }\n\ntype RegisterDocumentAction = {\n type: typeof SharedActionTypes.REGISTER_DOCUMENT\n payload: { documentKey: string; document: DocumentPayload }\n}\n\ntype UnregisterDocumentAction = {\n type: typeof SharedActionTypes.UNREGISTER_DOCUMENT\n payload: { documentKey: string }\n}\n\nexport type SharedAction =\n | MakeswiftConnectionInitAction\n | RegisterDocumentAction\n | UnregisterDocumentAction\n\nexport function makeswiftConnectionInit(): MakeswiftConnectionInitAction {\n return {\n type: SharedActionTypes.MAKESWIFT_CONNECTION_INIT,\n }\n}\n\nexport function registerDocument(document: Document): RegisterDocumentAction {\n return {\n type: SharedActionTypes.REGISTER_DOCUMENT,\n payload: { documentKey: document.key, document },\n }\n}\n\nexport function unregisterDocument(documentKey: string): UnregisterDocumentAction {\n return { type: SharedActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } }\n}\n\nexport function registerDocumentsEffect(\n documents: Document[],\n): ThunkAction<() => void, unknown, unknown, SharedAction> {\n return dispatch => {\n documents.forEach(document => dispatch(registerDocument(document)))\n\n return () => {\n documents.forEach(document => dispatch(unregisterDocument(document.key)))\n }\n }\n}\n"],"mappings":"AAIA,SAAS,yBAAyB;AAsC3B,SAAS,0BAAyD;AACvE,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,EAC1B;AACF;AAEO,SAAS,iBAAiB,UAA4C;AAC3E,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,SAAS,EAAE,aAAa,SAAS,KAAK,SAAS;AAAA,EACjD;AACF;AAEO,SAAS,mBAAmB,aAA+C;AAChF,SAAO,EAAE,MAAM,kBAAkB,qBAAqB,SAAS,EAAE,YAAY,EAAE;AACjF;AAEO,SAAS,wBACd,WACyD;AACzD,SAAO,cAAY;AACjB,cAAU,QAAQ,cAAY,SAAS,iBAAiB,QAAQ,CAAC,CAAC;AAElE,WAAO,MAAM;AACX,gBAAU,QAAQ,cAAY,SAAS,mBAAmB,SAAS,GAAG,CAAC,CAAC;AAAA,IAC1E;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/shared-api/index.ts"],"sourcesContent":["export * from './action-types'\nexport * from './actions'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
package/dist/esm/state/store.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
compose
|
|
6
6
|
} from "@reduxjs/toolkit";
|
|
7
7
|
import { actionMiddleware, middlewareOptions, devToolsConfig } from "./toolkit";
|
|
8
|
-
import { BuilderActionTypes } from "./builder-api/
|
|
8
|
+
import { BuilderActionTypes } from "./builder-api/action-types";
|
|
9
9
|
import { HostActionTypes } from "./host-api";
|
|
10
10
|
import * as Breakpoints from "./modules/breakpoints";
|
|
11
11
|
import { readOnlyElementTreeMiddleware } from "./middleware/read-only-element-tree";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n Tuple,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { ApiResourcesClient } from '../api/api-resources-client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\nimport { type BreakpointWatch, breakpointWatchMixin } from './mixins/breakpoint-watch'\n\nimport { type Action } from './actions'\n\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\n\nexport { type State } from './unified-state'\n\nconst configureStore = <Items extends readonly StoreEnhancer[] = []>({\n name,\n preloadedState,\n enhancers,\n middleware,\n}: {\n name: string\n preloadedState: Partial<State>\n enhancers: () => Tuple<Items>\n middleware?: () => Middleware[]\n}) => {\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n ...(middleware ? middleware() : []),\n ]),\n\n enhancers: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers()),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport function configureProtoStore({\n name,\n breakpoints,\n}: {\n name: string\n breakpoints: Breakpoints.Breakpoints | undefined\n}) {\n return configureStore({\n name,\n preloadedState: {\n breakpoints: Breakpoints.getInitialState(breakpoints),\n },\n enhancers: () => new Tuple(),\n })\n}\n\nexport type ProtoStore = ReturnType<typeof configureProtoStore>\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\nexport interface ReadWriteStateMixin {\n readonly apiResourcesClient: ApiResourcesClient\n\n loadReadWriteStateIfNeeded(): Promise<() => void>\n}\n\nfunction withMixin<M extends {}>(mixin: M): StoreEnhancer<M> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n ...mixin,\n })\n}\n\nexport function configureReadWriteStore({\n name,\n appOrigin,\n apiResourcesClient,\n preloadedState,\n}: {\n name: string\n appOrigin: string\n apiResourcesClient: ApiResourcesClient\n preloadedState: Partial<State>\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureStore({\n name,\n preloadedState,\n\n middleware: () => [\n makeswiftApiClientSyncMiddleware(apiResourcesClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ],\n\n enhancers: () =>\n new Tuple(\n withMixin<BreakpointWatch>(\n breakpointWatchMixin({\n dispatch: (...args: Parameters<Dispatch>) => store.dispatch(...args),\n getState: (): State => store.getState(),\n subscribe: (listener): VoidFunction => store.subscribe(listener),\n }),\n ),\n\n withMixin<ReadWriteStateMixin>({\n apiResourcesClient,\n loadReadWriteStateIfNeeded: async () => {\n const { isReadOnly } = store.getState()\n\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', { isReadOnly, refCount })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n },\n }),\n ),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureReadWriteStore>\n"],"mappings":"AAAA;AAAA,EAIE;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OACK;AAIP,SAAS,kBAAkB,mBAAmB,sBAAsB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,YAAY,iBAAiB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,wCAAwC;AACjD,SAA+B,4BAA4B;AAK3D,YAAY,mBAAmB;AAU/B,MAAM,iBAAiB,CAA8C;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,QAAQ,oBAAoB;AAAA,IAChC,SAAS,gBAAgB,cAAc,QAAQ;AAAA,IAC/C;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBAAiB,EAAE,OAAO;AAAA,MAC7C,8BAA8B;AAAA,MAC9B,GAAI,aAAa,WAAW,IAAI,CAAC;AAAA,IACnC,CAAC;AAAA,IAEH,WAAW,yBAAuB,oBAAoB,EAAE,OAAO,UAAU,CAAC;AAAA,IAE1E,UAAU,eAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAA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A,IAEA,WAAW,MACT,IAAI;AAAA,MACF;AAAA,QACE,qBAAqB;AAAA,UACnB,UAAU,IAAI,SAA+B,MAAM,SAAS,GAAG,IAAI;AAAA,UACnE,UAAU,MAAa,MAAM,SAAS;AAAA,UACtC,WAAW,CAAC,aAA2B,MAAM,UAAU,QAAQ;AAAA,QACjE,CAAC;AAAA,MACH;AAAA,MAEA,UAA+B;AAAA,QAC7B;AAAA,QACA,4BAA4B,YAAY;AACtC,gBAAM,EAAE,WAAW,IAAI,MAAM,SAAS;AAEtC,cAAI,YAAY;AACd,gBAAI,WAAW,GAAG;AAChB,sBAAQ,MAAM,6BAA6B,EAAE,YAAY,SAAS,CAAC;AAAA,YACrE;AAEA,mBAAO,MAAM;AAAA,YAAC;AAAA,UAChB;AAEA,gBAAM,mBAAmB;AACzB,sBAAY;AAEZ,cAAI,aAAa;AACjB,iBAAO,MAAM;AACX,gBAAI,YAAY;AACd;AAAA,YACF;AAEA,yBAAa;AACb,wBAAY;AACZ,gBAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,+BAAiB;AACjB,iCAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AAED,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n Tuple,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { ApiResourcesClient } from '../api/api-resources-client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/action-types'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\nimport { type BreakpointWatch, breakpointWatchMixin } from './mixins/breakpoint-watch'\n\nimport { type Action } from './actions'\n\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\n\nexport { type State } from './unified-state'\n\nconst configureStore = <Items extends readonly StoreEnhancer[] = []>({\n name,\n preloadedState,\n enhancers,\n middleware,\n}: {\n name: string\n preloadedState: Partial<State>\n enhancers: () => Tuple<Items>\n middleware?: () => Middleware[]\n}) => {\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n ...(middleware ? middleware() : []),\n ]),\n\n enhancers: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers()),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport function configureProtoStore({\n name,\n breakpoints,\n}: {\n name: string\n breakpoints: Breakpoints.Breakpoints | undefined\n}) {\n return configureStore({\n name,\n preloadedState: {\n breakpoints: Breakpoints.getInitialState(breakpoints),\n },\n enhancers: () => new Tuple(),\n })\n}\n\nexport type ProtoStore = ReturnType<typeof configureProtoStore>\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\nexport interface ReadWriteStateMixin {\n readonly apiResourcesClient: ApiResourcesClient\n\n loadReadWriteStateIfNeeded(): Promise<() => void>\n}\n\nfunction withMixin<M extends {}>(mixin: M): StoreEnhancer<M> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n ...mixin,\n })\n}\n\nexport function configureReadWriteStore({\n name,\n appOrigin,\n apiResourcesClient,\n preloadedState,\n}: {\n name: string\n appOrigin: string\n apiResourcesClient: ApiResourcesClient\n preloadedState: Partial<State>\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureStore({\n name,\n preloadedState,\n\n middleware: () => [\n makeswiftApiClientSyncMiddleware(apiResourcesClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ],\n\n enhancers: () =>\n new Tuple(\n withMixin<BreakpointWatch>(\n breakpointWatchMixin({\n dispatch: (...args: Parameters<Dispatch>) => store.dispatch(...args),\n getState: (): State => store.getState(),\n subscribe: (listener): VoidFunction => store.subscribe(listener),\n }),\n ),\n\n withMixin<ReadWriteStateMixin>({\n apiResourcesClient,\n loadReadWriteStateIfNeeded: async () => {\n const { isReadOnly } = store.getState()\n\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', { isReadOnly, refCount })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n },\n }),\n ),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureReadWriteStore>\n"],"mappings":"AAAA;AAAA,EAIE;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OACK;AAIP,SAAS,kBAAkB,mBAAmB,sBAAsB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,YAAY,iBAAiB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,wCAAwC;AACjD,SAA+B,4BAA4B;AAK3D,YAAY,mBAAmB;AAU/B,MAAM,iBAAiB,CAA8C;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,QAAQ,oBAAoB;AAAA,IAChC,SAAS,gBAAgB,cAAc,QAAQ;AAAA,IAC/C;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBAAiB,EAAE,OAAO;AAAA,MAC7C,8BAA8B;AAAA,MAC9B,GAAI,aAAa,WAAW,IAAI,CAAC;AAAA,IACnC,CAAC;AAAA,IAEH,WAAW,yBAAuB,oBAAoB,EAAE,OAAO,UAAU,CAAC;AAAA,IAE1E,UAAU,eAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,mBAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;AAEO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACD,SAAO,eAAe;AAAA,IACpB;AAAA,IACA,gBAAgB;AAAA,MACd,aAAa,YAAY,gBAAgB,WAAW;AAAA,IACtD;AAAA,IACA,WAAW,MAAM,IAAI,MAAM;AAAA,EAC7B,CAAC;AACH;AAY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,YAAY;AACd,gBAAI,WAAW,GAAG;AAChB,sBAAQ,MAAM,6BAA6B,EAAE,YAAY,SAAS,CAAC;AAAA,YACrE;AAEA,mBAAO,MAAM;AAAA,YAAC;AAAA,UAChB;AAEA,gBAAM,mBAAmB;AACzB,sBAAY;AAEZ,cAAI,aAAa;AACjB,iBAAO,MAAM;AACX,gBAAI,YAAY;AACd;AAAA,YACF;AAEA,yBAAa;AACb,wBAAY;AACZ,gBAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,+BAAiB;AACjB,iCAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AAED,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/translations/get.ts"],"sourcesContent":["import * as Documents from '../modules/read-only-documents'\nimport * as ElementTrees from '../modules/element-trees'\nimport { getTranslatableData } from '../../controls/control'\nimport type { DescriptorsByComponentType } from '../modules/prop-
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/translations/get.ts"],"sourcesContent":["import * as Documents from '../modules/read-only-documents'\nimport * as ElementTrees from '../modules/element-trees'\nimport { getTranslatableData } from '../../controls/control'\nimport type { DescriptorsByComponentType } from '../modules/prop-controller-descriptors'\n\nexport function getTranslatableContent(\n descriptors: DescriptorsByComponentType,\n elementTree: Documents.ElementData,\n): Record<string, Documents.Data> {\n const translatableData: Record<string, Documents.Data> = {}\n\n for (const element of ElementTrees.traverseElementTree(elementTree, descriptors)) {\n if (Documents.isElementReference(element)) continue\n\n const elementDescriptors = descriptors.get(element.type)\n if (elementDescriptors == null) continue\n\n Object.entries(elementDescriptors).forEach(([propName, descriptor]) => {\n const translatablePropData = getTranslatableData(descriptor, element.props[propName])\n\n if (translatablePropData != null) {\n translatableData[`${element.key}:${propName}`] = translatablePropData\n }\n })\n }\n\n return translatableData\n}\n"],"mappings":"AAAA,YAAY,eAAe;AAC3B,YAAY,kBAAkB;AAC9B,SAAS,2BAA2B;AAG7B,SAAS,uBACd,aACA,aACgC;AAChC,QAAM,mBAAmD,CAAC;AAE1D,aAAW,WAAW,aAAa,oBAAoB,aAAa,WAAW,GAAG;AAChF,QAAI,UAAU,mBAAmB,OAAO;AAAG;AAE3C,UAAM,qBAAqB,YAAY,IAAI,QAAQ,IAAI;AACvD,QAAI,sBAAsB;AAAM;AAEhC,WAAO,QAAQ,kBAAkB,EAAE,QAAQ,CAAC,CAAC,UAAU,UAAU,MAAM;AACrE,YAAM,uBAAuB,oBAAoB,YAAY,QAAQ,MAAM,QAAQ,CAAC;AAEpF,UAAI,wBAAwB,MAAM;AAChC,yBAAiB,GAAG,QAAQ,GAAG,IAAI,QAAQ,EAAE,IAAI;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
Types as PropControllerTypes
|
|
5
5
|
} from "@makeswift/prop-controllers";
|
|
6
6
|
import { ReactMergeTranslationsVisitor } from "../../controls/visitors/merge-translations-visitor";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
isLegacyDescriptor
|
|
9
|
+
} from "../../prop-controllers/descriptors";
|
|
8
10
|
function mergeTranslatedContent(descriptors, elementTree, translatedData) {
|
|
9
11
|
function merge(descriptorsByType, translatedData2) {
|
|
10
12
|
return function(node) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/translations/merge.ts"],"sourcesContent":["import { MergeTranslatableDataContext, type TranslationDto, type Data } from '@makeswift/controls'\nimport * as Documents from '../modules/read-only-documents'\nimport {\n GridPropControllerData,\n mergeGridPropControllerTranslatedData,\n Types as PropControllerTypes,\n} from '@makeswift/prop-controllers'\nimport { ReactMergeTranslationsVisitor } from '../../controls/visitors/merge-translations-visitor'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/translations/merge.ts"],"sourcesContent":["import { MergeTranslatableDataContext, type TranslationDto, type Data } from '@makeswift/controls'\nimport * as Documents from '../modules/read-only-documents'\nimport {\n GridPropControllerData,\n mergeGridPropControllerTranslatedData,\n Types as PropControllerTypes,\n} from '@makeswift/prop-controllers'\nimport { ReactMergeTranslationsVisitor } from '../../controls/visitors/merge-translations-visitor'\nimport {\n isLegacyDescriptor,\n Descriptor as PropControllerDescriptor,\n} from '../../prop-controllers/descriptors'\nimport type { DescriptorsByComponentType } from '../modules/prop-controller-descriptors'\n\nexport function mergeTranslatedContent(\n descriptors: DescriptorsByComponentType,\n elementTree: Documents.ElementData,\n translatedData: TranslationDto,\n): Documents.Element {\n function merge(descriptorsByType: DescriptorsByComponentType, translatedData: TranslationDto) {\n return function (node: Documents.Element): Documents.Element {\n if (Documents.isElementReference(node)) return node\n\n const elementDescriptors = descriptorsByType.get(node.type)\n\n if (elementDescriptors == null) {\n throw new Error(`Can't merge element of type \"${node.type}\" because it has no descriptors`)\n }\n\n const context: MergeTranslatableDataContext = {\n translatedData: translatedData,\n mergeTranslatedData: merge(descriptorsByType, translatedData),\n }\n const props = {} as Record<string, Documents.Data>\n\n for (const propName of Object.keys(elementDescriptors)) {\n const descriptor = elementDescriptors[propName]\n\n props[propName] = mergeTranslatedData(\n descriptor,\n node.props[propName],\n translatedData[`${node.key}:${propName}`],\n context,\n )\n }\n\n return { ...node, props }\n }\n }\n return merge(descriptors, translatedData)(elementTree)\n}\n\nexport function mergeTranslatedData(\n definition: PropControllerDescriptor,\n data: Data,\n translatedData: Data,\n context: MergeTranslatableDataContext,\n): Data {\n if (data == null) return data\n if (!isLegacyDescriptor(definition)) {\n const mergeTranslationsVisitor = new ReactMergeTranslationsVisitor(context)\n return definition.accept(mergeTranslationsVisitor, data, translatedData)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n if (translatedData == null) return data\n return translatedData\n\n case PropControllerTypes.Grid:\n return mergeGridPropControllerTranslatedData(data as GridPropControllerData, context)\n\n default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,KAAK,oBAAoB;AACvB,aAAO,sCAAsC,MAAgC,OAAO;AAAA,IAEtF;AACE,aAAO;AAAA,EACX;AACF;","names":["translatedData"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/unified-state.ts"],"sourcesContent":["import { type ThunkDispatch, type Reducer } from '@reduxjs/toolkit'\n\nimport { type State as ReadOnlyState } from './read-only-state'\nimport { type State as ReadWriteState } from './read-write-state'\nimport { type Action } from './actions'\n\nexport type State = ReadOnlyState | ReadWriteState\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type ReadOnlyReducer = Reducer<ReadOnlyState>\nexport type ReadWriteDispatch = ThunkDispatch<ReadWriteState, unknown, Action>\n\nexport const isReadWriteState = (state: State): state is ReadWriteState => 'boxModels' in state\n"],"mappings":"AAWO,MAAM,mBAAmB,CAAC,UAA0C,eAAe;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const DESKTOP_MEDIA_QUERY = "only screen and (min-width: 769px)";
|
|
2
|
+
const TABLET_MEDIA_QUERY = "only screen and (min-width: 769px)";
|
|
3
|
+
const MOBILE_MEDIA_QUERY = "only screen and (min-width: 769px)";
|
|
4
|
+
export {
|
|
5
|
+
DESKTOP_MEDIA_QUERY,
|
|
6
|
+
MOBILE_MEDIA_QUERY,
|
|
7
|
+
TABLET_MEDIA_QUERY
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=breakpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/testing/breakpoints.ts"],"sourcesContent":["export const DESKTOP_MEDIA_QUERY = 'only screen and (min-width: 769px)'\nexport const TABLET_MEDIA_QUERY = 'only screen and (min-width: 769px)'\nexport const MOBILE_MEDIA_QUERY = 'only screen and (min-width: 769px)'\n"],"mappings":"AAAO,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
2
|
+
import { CacheData } from "../api/api-resources-client";
|
|
3
|
+
import { MakeswiftComponentType } from "../components/builtin/constants";
|
|
4
|
+
function createRootComponent(elements, rootId) {
|
|
5
|
+
return {
|
|
6
|
+
key: rootId ?? uuid(),
|
|
7
|
+
type: MakeswiftComponentType.Root,
|
|
8
|
+
props: {
|
|
9
|
+
children: {
|
|
10
|
+
columns: [
|
|
11
|
+
{
|
|
12
|
+
deviceId: "desktop",
|
|
13
|
+
value: {
|
|
14
|
+
count: 12,
|
|
15
|
+
spans: elements?.map(() => [12])
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
elements
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const isDocument = (elementDataOrDocument) => "snippets" in elementDataOrDocument || "fonts" in elementDataOrDocument || "meta" in elementDataOrDocument || "seo" in elementDataOrDocument;
|
|
25
|
+
function createMakeswiftPageSnapshot(elementDataOrDocument, {
|
|
26
|
+
cacheData = {},
|
|
27
|
+
locale = null
|
|
28
|
+
} = {}) {
|
|
29
|
+
return {
|
|
30
|
+
document: isDocument(elementDataOrDocument) ? elementDataOrDocument : {
|
|
31
|
+
id: "test-page-id",
|
|
32
|
+
site: { id: "test-site-id" },
|
|
33
|
+
data: elementDataOrDocument,
|
|
34
|
+
snippets: [],
|
|
35
|
+
fonts: [],
|
|
36
|
+
meta: {},
|
|
37
|
+
seo: {},
|
|
38
|
+
localizedPages: [],
|
|
39
|
+
locale
|
|
40
|
+
},
|
|
41
|
+
cacheData: {
|
|
42
|
+
...CacheData.empty(),
|
|
43
|
+
...cacheData
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createMakeswiftComponentSnapshot(elementData, {
|
|
48
|
+
cacheData = {},
|
|
49
|
+
locale = null
|
|
50
|
+
} = {}) {
|
|
51
|
+
return {
|
|
52
|
+
key: uuid(),
|
|
53
|
+
document: {
|
|
54
|
+
id: "test-component-id",
|
|
55
|
+
name: "Test Component Document",
|
|
56
|
+
siteId: "test-site-id",
|
|
57
|
+
data: elementData,
|
|
58
|
+
inheritsFromParent: false,
|
|
59
|
+
locale
|
|
60
|
+
},
|
|
61
|
+
meta: {
|
|
62
|
+
allowLocaleFallback: false,
|
|
63
|
+
requestedLocale: locale
|
|
64
|
+
},
|
|
65
|
+
cacheData: {
|
|
66
|
+
...CacheData.empty(),
|
|
67
|
+
...cacheData
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createMakeswiftComponentSnapshot,
|
|
73
|
+
createMakeswiftPageSnapshot,
|
|
74
|
+
createRootComponent
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=element-data.js.map
|