@wordpress/core-data 7.52.0 → 7.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -0
- package/build/actions.cjs +18 -9
- package/build/actions.cjs.map +2 -2
- package/build/awareness/awareness-state.cjs.map +2 -2
- package/build/awareness/base-awareness.cjs.map +2 -2
- package/build/awareness/block-lookup.cjs.map +2 -2
- package/build/awareness/post-editor-awareness.cjs +7 -0
- package/build/awareness/post-editor-awareness.cjs.map +2 -2
- package/build/awareness/typed-awareness.cjs.map +2 -2
- package/build/awareness/types.cjs.map +1 -1
- package/build/awareness/utils.cjs.map +2 -2
- package/build/batch/create-batch.cjs.map +2 -2
- package/build/batch/default-processor.cjs.map +2 -2
- package/build/components/entities-saved-states/entity-record-item.cjs.map +2 -2
- package/build/components/entities-saved-states/entity-type-list.cjs.map +2 -2
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs +4 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs.map +2 -2
- package/build/components/entities-saved-states/index.cjs.map +2 -2
- package/build/dynamic-entities.cjs.map +2 -2
- package/build/entities.cjs.map +2 -2
- package/build/entity-context.cjs.map +2 -2
- package/build/entity-provider.cjs.map +2 -2
- package/build/entity-types/attachment.cjs.map +1 -1
- package/build/entity-types/base.cjs.map +1 -1
- package/build/entity-types/comment.cjs.map +1 -1
- package/build/entity-types/font-collection.cjs.map +1 -1
- package/build/entity-types/font-family.cjs.map +1 -1
- package/build/entity-types/global-styles-revision.cjs.map +1 -1
- package/build/entity-types/helpers.cjs.map +1 -1
- package/build/entity-types/icon.cjs.map +1 -1
- package/build/entity-types/index.cjs.map +1 -1
- package/build/entity-types/menu-location.cjs.map +1 -1
- package/build/entity-types/nav-menu-item.cjs.map +1 -1
- package/build/entity-types/nav-menu.cjs.map +1 -1
- package/build/entity-types/page.cjs.map +1 -1
- package/build/entity-types/plugin.cjs.map +1 -1
- package/build/entity-types/post-revision.cjs.map +1 -1
- package/build/entity-types/post-status.cjs.map +1 -1
- package/build/entity-types/post.cjs.map +1 -1
- package/build/entity-types/settings.cjs.map +1 -1
- package/build/entity-types/sidebar.cjs.map +1 -1
- package/build/entity-types/taxonomy.cjs.map +1 -1
- package/build/entity-types/term.cjs.map +1 -1
- package/build/entity-types/theme.cjs.map +1 -1
- package/build/entity-types/type.cjs.map +1 -1
- package/build/entity-types/user.cjs.map +1 -1
- package/build/entity-types/widget-type.cjs.map +1 -1
- package/build/entity-types/widget.cjs.map +1 -1
- package/build/entity-types/wp-template-part.cjs.map +1 -1
- package/build/entity-types/wp-template.cjs.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.cjs.map +2 -2
- package/build/fetch/__experimental-fetch-url-data.cjs.map +2 -2
- package/build/fetch/index.cjs.map +2 -2
- package/build/footnotes/get-footnotes-order.cjs.map +2 -2
- package/build/footnotes/get-rich-text-values-cached.cjs.map +2 -2
- package/build/footnotes/index.cjs +12 -1
- package/build/footnotes/index.cjs.map +3 -3
- package/build/hooks/index.cjs.map +2 -2
- package/build/hooks/use-entity-block-editor.cjs.map +2 -2
- package/build/hooks/use-entity-id.cjs.map +2 -2
- package/build/hooks/use-entity-prop.cjs.map +2 -2
- package/build/hooks/use-entity-record.cjs.map +2 -2
- package/build/hooks/use-entity-records.cjs +2 -2
- package/build/hooks/use-entity-records.cjs.map +2 -2
- package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
- package/build/hooks/use-query-select.cjs.map +2 -2
- package/build/hooks/use-resource-permissions.cjs.map +2 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/locks/actions.cjs.map +2 -2
- package/build/locks/engine.cjs.map +2 -2
- package/build/locks/reducer.cjs.map +2 -2
- package/build/locks/selectors.cjs.map +2 -2
- package/build/private-actions.cjs +54 -7
- package/build/private-actions.cjs.map +2 -2
- package/build/private-apis.cjs +3 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/private-selectors.cjs +5 -0
- package/build/private-selectors.cjs.map +2 -2
- package/build/queried-data/get-query-parts.cjs.map +2 -2
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/queried-data/selectors.cjs.map +2 -2
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +21 -26
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs.map +2 -2
- package/build/sync.cjs +26 -0
- package/build/sync.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/block-selection-history.cjs.map +2 -2
- package/build/utils/clear-unchanged-edits.cjs.map +2 -2
- package/build/utils/conservative-map-item.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-selection.cjs.map +2 -2
- package/build/utils/crdt-text.cjs.map +2 -2
- package/build/utils/crdt-user-selections.cjs +43 -16
- package/build/utils/crdt-user-selections.cjs.map +3 -3
- package/build/utils/crdt-utils.cjs.map +2 -2
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/get-template-info.cjs.map +2 -2
- package/build/utils/get-template-part-icon.cjs.map +2 -2
- package/build/utils/log-entity-deprecation.cjs.map +2 -2
- package/build/utils/save-crdt-doc.cjs.map +2 -2
- package/build-module/actions.mjs +19 -9
- package/build-module/actions.mjs.map +2 -2
- package/build-module/awareness/awareness-state.mjs.map +2 -2
- package/build-module/awareness/base-awareness.mjs.map +2 -2
- package/build-module/awareness/block-lookup.mjs.map +2 -2
- package/build-module/awareness/post-editor-awareness.mjs +7 -0
- package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
- package/build-module/awareness/typed-awareness.mjs.map +2 -2
- package/build-module/awareness/utils.mjs.map +2 -2
- package/build-module/batch/create-batch.mjs.map +2 -2
- package/build-module/batch/default-processor.mjs.map +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.mjs.map +2 -2
- package/build-module/components/entities-saved-states/entity-type-list.mjs.map +2 -2
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs +4 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs.map +2 -2
- package/build-module/components/entities-saved-states/index.mjs.map +2 -2
- package/build-module/dynamic-entities.mjs.map +2 -2
- package/build-module/entities.mjs.map +2 -2
- package/build-module/entity-context.mjs.map +2 -2
- package/build-module/entity-provider.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-link-suggestions.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-url-data.mjs.map +2 -2
- package/build-module/fetch/index.mjs.map +2 -2
- package/build-module/footnotes/get-footnotes-order.mjs.map +2 -2
- package/build-module/footnotes/get-rich-text-values-cached.mjs.map +2 -2
- package/build-module/footnotes/index.mjs +12 -1
- package/build-module/footnotes/index.mjs.map +2 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/use-entity-block-editor.mjs.map +2 -2
- package/build-module/hooks/use-entity-id.mjs.map +2 -2
- package/build-module/hooks/use-entity-prop.mjs.map +2 -2
- package/build-module/hooks/use-entity-record.mjs.map +2 -2
- package/build-module/hooks/use-entity-records.mjs +2 -2
- package/build-module/hooks/use-entity-records.mjs.map +2 -2
- package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
- package/build-module/hooks/use-query-select.mjs.map +2 -2
- package/build-module/hooks/use-resource-permissions.mjs.map +2 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/locks/actions.mjs.map +2 -2
- package/build-module/locks/engine.mjs.map +2 -2
- package/build-module/locks/reducer.mjs.map +2 -2
- package/build-module/locks/selectors.mjs.map +2 -2
- package/build-module/private-actions.mjs +54 -7
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +9 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/private-selectors.mjs +4 -0
- package/build-module/private-selectors.mjs.map +2 -2
- package/build-module/queried-data/get-query-parts.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/queried-data/selectors.mjs.map +2 -2
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +21 -26
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/sync.mjs +23 -0
- package/build-module/sync.mjs.map +2 -2
- package/build-module/utils/block-selection-history.mjs.map +2 -2
- package/build-module/utils/clear-unchanged-edits.mjs.map +2 -2
- package/build-module/utils/conservative-map-item.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-selection.mjs.map +2 -2
- package/build-module/utils/crdt-text.mjs.map +2 -2
- package/build-module/utils/crdt-user-selections.mjs +43 -16
- package/build-module/utils/crdt-user-selections.mjs.map +3 -3
- package/build-module/utils/crdt-utils.mjs.map +2 -2
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/get-template-info.mjs.map +2 -2
- package/build-module/utils/get-template-part-icon.mjs.map +2 -2
- package/build-module/utils/log-entity-deprecation.mjs.map +2 -2
- package/build-module/utils/save-crdt-doc.mjs.map +2 -2
- package/build-types/actions.d.ts +4 -0
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/awareness/awareness-state.d.ts.map +1 -1
- package/build-types/awareness/base-awareness.d.ts +0 -3
- package/build-types/awareness/base-awareness.d.ts.map +1 -1
- package/build-types/awareness/block-lookup.d.ts +0 -3
- package/build-types/awareness/block-lookup.d.ts.map +1 -1
- package/build-types/awareness/post-editor-awareness.d.ts +0 -3
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
- package/build-types/awareness/typed-awareness.d.ts +0 -3
- package/build-types/awareness/typed-awareness.d.ts.map +1 -1
- package/build-types/awareness/types.d.ts +0 -6
- package/build-types/awareness/types.d.ts.map +1 -1
- package/build-types/awareness/utils.d.ts +0 -3
- package/build-types/awareness/utils.d.ts.map +1 -1
- package/build-types/batch/create-batch.d.ts.map +1 -1
- package/build-types/batch/default-processor.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/dynamic-entities.d.ts +0 -3
- package/build-types/dynamic-entities.d.ts.map +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-context.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/entity-types/attachment.d.ts +0 -3
- package/build-types/entity-types/attachment.d.ts.map +1 -1
- package/build-types/entity-types/base.d.ts +0 -3
- package/build-types/entity-types/base.d.ts.map +1 -1
- package/build-types/entity-types/comment.d.ts +0 -3
- package/build-types/entity-types/comment.d.ts.map +1 -1
- package/build-types/entity-types/font-collection.d.ts +0 -3
- package/build-types/entity-types/font-collection.d.ts.map +1 -1
- package/build-types/entity-types/font-family.d.ts +0 -3
- package/build-types/entity-types/font-family.d.ts.map +1 -1
- package/build-types/entity-types/global-styles-revision.d.ts +0 -3
- package/build-types/entity-types/global-styles-revision.d.ts.map +1 -1
- package/build-types/entity-types/helpers.d.ts +0 -3
- package/build-types/entity-types/helpers.d.ts.map +1 -1
- package/build-types/entity-types/icon.d.ts +0 -3
- package/build-types/entity-types/icon.d.ts.map +1 -1
- package/build-types/entity-types/index.d.ts +0 -3
- package/build-types/entity-types/index.d.ts.map +1 -1
- package/build-types/entity-types/menu-location.d.ts +0 -3
- package/build-types/entity-types/menu-location.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu-item.d.ts +0 -3
- package/build-types/entity-types/nav-menu-item.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu.d.ts +0 -3
- package/build-types/entity-types/nav-menu.d.ts.map +1 -1
- package/build-types/entity-types/page.d.ts +0 -3
- package/build-types/entity-types/page.d.ts.map +1 -1
- package/build-types/entity-types/plugin.d.ts +0 -3
- package/build-types/entity-types/plugin.d.ts.map +1 -1
- package/build-types/entity-types/post-revision.d.ts +0 -3
- package/build-types/entity-types/post-revision.d.ts.map +1 -1
- package/build-types/entity-types/post-status.d.ts +0 -3
- package/build-types/entity-types/post-status.d.ts.map +1 -1
- package/build-types/entity-types/post.d.ts +0 -3
- package/build-types/entity-types/post.d.ts.map +1 -1
- package/build-types/entity-types/settings.d.ts +0 -3
- package/build-types/entity-types/settings.d.ts.map +1 -1
- package/build-types/entity-types/sidebar.d.ts +0 -3
- package/build-types/entity-types/sidebar.d.ts.map +1 -1
- package/build-types/entity-types/taxonomy.d.ts +0 -3
- package/build-types/entity-types/taxonomy.d.ts.map +1 -1
- package/build-types/entity-types/term.d.ts +0 -3
- package/build-types/entity-types/term.d.ts.map +1 -1
- package/build-types/entity-types/test/attachment.test.d.ts +0 -8
- package/build-types/entity-types/test/attachment.test.d.ts.map +1 -1
- package/build-types/entity-types/theme.d.ts +0 -3
- package/build-types/entity-types/theme.d.ts.map +1 -1
- package/build-types/entity-types/type.d.ts +0 -3
- package/build-types/entity-types/type.d.ts.map +1 -1
- package/build-types/entity-types/user.d.ts +0 -3
- package/build-types/entity-types/user.d.ts.map +1 -1
- package/build-types/entity-types/widget-type.d.ts +0 -3
- package/build-types/entity-types/widget-type.d.ts.map +1 -1
- package/build-types/entity-types/widget.d.ts +0 -3
- package/build-types/entity-types/widget.d.ts.map +1 -1
- package/build-types/entity-types/wp-template-part.d.ts +0 -3
- package/build-types/entity-types/wp-template-part.d.ts.map +1 -1
- package/build-types/entity-types/wp-template.d.ts +0 -3
- package/build-types/entity-types/wp-template.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-url-data.d.ts.map +1 -1
- package/build-types/fetch/index.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -1
- package/build-types/footnotes/get-rich-text-values-cached.d.ts.map +1 -1
- package/build-types/footnotes/index.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +0 -3
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/use-entity-block-editor.d.ts.map +1 -1
- package/build-types/hooks/use-entity-id.d.ts.map +1 -1
- package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
- package/build-types/hooks/use-entity-record.d.ts.map +1 -1
- package/build-types/hooks/use-entity-records.d.ts.map +1 -1
- package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
- package/build-types/hooks/use-query-select.d.ts.map +1 -1
- package/build-types/hooks/use-resource-permissions.d.ts.map +1 -1
- package/build-types/hooks/utils.d.ts +0 -6
- package/build-types/hooks/utils.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/locks/actions.d.ts.map +1 -1
- package/build-types/locks/engine.d.ts.map +1 -1
- package/build-types/locks/reducer.d.ts.map +1 -1
- package/build-types/locks/selectors.d.ts.map +1 -1
- package/build-types/private-actions.d.ts +1 -1
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +4 -3
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +12 -3
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/queried-data/get-query-parts.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +1 -2
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +31 -3
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -8
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/block-selection-history.d.ts +0 -6
- package/build-types/utils/block-selection-history.d.ts.map +1 -1
- package/build-types/utils/clear-unchanged-edits.d.ts.map +1 -1
- package/build-types/utils/conservative-map-item.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +0 -3
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-selection.d.ts +0 -3
- package/build-types/utils/crdt-selection.d.ts.map +1 -1
- package/build-types/utils/crdt-text.d.ts +0 -3
- package/build-types/utils/crdt-text.d.ts.map +1 -1
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
- package/build-types/utils/crdt-utils.d.ts +0 -6
- package/build-types/utils/crdt-utils.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/get-template-info.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/log-entity-deprecation.d.ts.map +1 -1
- package/build-types/utils/save-crdt-doc.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/actions.js +45 -29
- package/src/awareness/awareness-state.ts +0 -3
- package/src/awareness/base-awareness.ts +0 -8
- package/src/awareness/block-lookup.ts +1 -8
- package/src/awareness/post-editor-awareness.ts +13 -10
- package/src/awareness/test/awareness-state.ts +0 -11
- package/src/awareness/test/base-awareness.ts +0 -7
- package/src/awareness/test/block-lookup.ts +0 -8
- package/src/awareness/test/post-editor-awareness.ts +0 -7
- package/src/awareness/test/typed-awareness.ts +0 -11
- package/src/awareness/test/utils.ts +0 -3
- package/src/awareness/typed-awareness.ts +0 -7
- package/src/awareness/types.ts +0 -7
- package/src/awareness/utils.ts +0 -3
- package/src/batch/create-batch.js +0 -3
- package/src/batch/default-processor.js +0 -4
- package/src/batch/test/create-batch.js +0 -3
- package/src/batch/test/default-processor.js +0 -7
- package/src/components/entities-saved-states/entity-record-item.js +0 -7
- package/src/components/entities-saved-states/entity-type-list.js +0 -7
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +4 -7
- package/src/components/entities-saved-states/index.js +0 -11
- package/src/components/entities-saved-states/test/use-is-dirty.js +70 -11
- package/src/dynamic-entities.ts +0 -3
- package/src/entities.js +0 -11
- package/src/entity-context.js +0 -3
- package/src/entity-provider.js +0 -7
- package/src/entity-types/attachment.ts +0 -4
- package/src/entity-types/base.ts +0 -3
- package/src/entity-types/comment.ts +0 -3
- package/src/entity-types/font-collection.ts +0 -3
- package/src/entity-types/font-family.ts +0 -3
- package/src/entity-types/global-styles-revision.ts +0 -4
- package/src/entity-types/helpers.ts +0 -3
- package/src/entity-types/icon.ts +0 -4
- package/src/entity-types/index.ts +0 -3
- package/src/entity-types/menu-location.ts +0 -4
- package/src/entity-types/nav-menu-item.ts +0 -4
- package/src/entity-types/nav-menu.ts +0 -4
- package/src/entity-types/page.ts +0 -4
- package/src/entity-types/plugin.ts +0 -4
- package/src/entity-types/post-revision.ts +0 -4
- package/src/entity-types/post-status.ts +0 -3
- package/src/entity-types/post.ts +0 -4
- package/src/entity-types/settings.ts +0 -4
- package/src/entity-types/sidebar.ts +0 -4
- package/src/entity-types/taxonomy.ts +0 -4
- package/src/entity-types/term.ts +0 -4
- package/src/entity-types/test/attachment.test.ts +0 -4
- package/src/entity-types/theme.ts +0 -4
- package/src/entity-types/type.ts +0 -4
- package/src/entity-types/user.ts +0 -4
- package/src/entity-types/widget-type.ts +0 -4
- package/src/entity-types/widget.ts +0 -4
- package/src/entity-types/wp-template-part.ts +0 -4
- package/src/entity-types/wp-template.ts +0 -4
- package/src/fetch/__experimental-fetch-link-suggestions.ts +0 -3
- package/src/fetch/__experimental-fetch-url-data.js +0 -3
- package/src/fetch/index.js +0 -7
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +0 -3
- package/src/fetch/test/__experimental-fetch-url-data.js +1 -7
- package/src/footnotes/get-footnotes-order.js +0 -3
- package/src/footnotes/get-rich-text-values-cached.js +0 -7
- package/src/footnotes/index.js +21 -8
- package/src/footnotes/test/index.js +57 -0
- package/src/hooks/index.ts +0 -3
- package/src/hooks/test/use-entity-record.js +0 -12
- package/src/hooks/test/use-entity-records.js +0 -12
- package/src/hooks/test/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/test/use-query-select.js +0 -11
- package/src/hooks/test/use-resource-permissions.js +0 -12
- package/src/hooks/use-entity-block-editor.js +0 -7
- package/src/hooks/use-entity-id.js +0 -7
- package/src/hooks/use-entity-prop.js +0 -7
- package/src/hooks/use-entity-record.ts +0 -7
- package/src/hooks/use-entity-records.ts +2 -9
- package/src/hooks/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/use-query-select.ts +0 -7
- package/src/hooks/use-resource-permissions.ts +0 -7
- package/src/hooks/utils.ts +0 -7
- package/src/index.js +0 -7
- package/src/lock-unlock.ts +0 -3
- package/src/locks/actions.js +0 -3
- package/src/locks/engine.js +0 -3
- package/src/locks/reducer.js +0 -3
- package/src/locks/selectors.js +0 -3
- package/src/locks/test/engine.js +0 -3
- package/src/locks/test/reducer.js +0 -7
- package/src/locks/test/selectors.js +0 -7
- package/src/locks/test/utils.js +0 -7
- package/src/private-actions.js +63 -15
- package/src/private-apis.ts +9 -4
- package/src/private-selectors.ts +22 -7
- package/src/queried-data/get-query-parts.js +0 -7
- package/src/queried-data/reducer.js +0 -7
- package/src/queried-data/selectors.js +0 -7
- package/src/queried-data/test/actions.js +0 -3
- package/src/queried-data/test/get-query-parts.js +0 -3
- package/src/queried-data/test/reducer.js +0 -7
- package/src/queried-data/test/selectors.js +0 -3
- package/src/reducer.js +0 -11
- package/src/resolvers.js +23 -40
- package/src/selectors.ts +0 -7
- package/src/sync.ts +64 -7
- package/src/test/actions.js +256 -8
- package/src/test/deprecated-entity-logging.js +0 -7
- package/src/test/entities.js +0 -8
- package/src/test/entity-provider.js +0 -11
- package/src/test/private-actions.js +297 -7
- package/src/test/private-selectors.js +0 -3
- package/src/test/reducer.js +0 -7
- package/src/test/resolvers.js +0 -12
- package/src/test/rtc-rich-text-offset-space.test.js +0 -12
- package/src/test/selectors.js +0 -7
- package/src/test/store.js +8 -15
- package/src/types.ts +14 -12
- package/src/utils/block-selection-history.ts +0 -10
- package/src/utils/clear-unchanged-edits.ts +0 -3
- package/src/utils/conservative-map-item.js +0 -3
- package/src/utils/crdt-blocks.ts +0 -11
- package/src/utils/crdt-selection.ts +0 -7
- package/src/utils/crdt-text.ts +0 -3
- package/src/utils/crdt-user-selections.ts +85 -23
- package/src/utils/crdt-utils.ts +0 -7
- package/src/utils/crdt.ts +0 -11
- package/src/utils/get-template-info.js +0 -6
- package/src/utils/get-template-part-icon.js +0 -3
- package/src/utils/log-entity-deprecation.ts +0 -7
- package/src/utils/save-crdt-doc.js +0 -7
- package/src/utils/test/block-selection-history.test.ts +0 -7
- package/src/utils/test/clear-unchanged-edits.js +0 -3
- package/src/utils/test/conservative-map-item.js +0 -3
- package/src/utils/test/crdt-blocks.ts +0 -17
- package/src/utils/test/crdt-user-selections.ts +107 -30
- package/src/utils/test/crdt-utils.ts +0 -7
- package/src/utils/test/crdt.ts +0 -16
- package/src/utils/test/get-nested-value.js +0 -3
- package/src/utils/test/get-normalized-comma-separable.js +0 -3
- package/src/utils/test/get-template-info.js +0 -6
- package/src/utils/test/if-matching-action.js +0 -7
- package/src/utils/test/is-numeric-id.js +0 -3
- package/src/utils/test/log-entity-deprecation.js +0 -7
- package/src/utils/test/replace-action.js +0 -3
- package/src/utils/test/rtc-rich-text-cursor-scope.test.js +0 -14
- package/src/utils/test/rtc-rich-text-offset-space.test.js +0 -14
- package/src/utils/test/save-crdt-doc.js +0 -7
- package/src/utils/test/set-nested-value.js +0 -3
- package/src/utils/test/with-weak-map-cache.js +0 -3
- package/build-types/utils/on-sub-key.d.ts +0 -4
- package/build-types/utils/on-sub-key.d.ts.map +0 -1
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { usePrevious } from '@wordpress/compose';
|
|
5
2
|
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
6
3
|
import type { Y } from '@wordpress/sync';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
4
|
import { getSyncManager } from '../sync';
|
|
12
5
|
import { usePostContentBlocks } from '../awareness/block-lookup';
|
|
13
6
|
import type { EditorStoreBlock } from '../awareness/block-lookup';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import deprecated from '@wordpress/deprecated';
|
|
5
2
|
import warning from '@wordpress/warning';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { store as coreStore } from '../';
|
|
11
4
|
import { Status } from './constants';
|
|
12
5
|
import useQuerySelect from './use-query-select';
|
package/src/hooks/utils.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import reducer from './reducer';
|
|
10
3
|
import * as selectors from './selectors';
|
|
11
4
|
import * as privateSelectors from './private-selectors';
|
package/src/lock-unlock.ts
CHANGED
package/src/locks/actions.js
CHANGED
package/src/locks/engine.js
CHANGED
package/src/locks/reducer.js
CHANGED
package/src/locks/selectors.js
CHANGED
package/src/locks/test/engine.js
CHANGED
package/src/locks/test/utils.js
CHANGED
package/src/private-actions.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
2
|
import { store as noticesStore } from '@wordpress/notices';
|
|
6
3
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
4
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
5
|
import { __ } from '@wordpress/i18n';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
6
|
import { STORE_NAME } from './name';
|
|
13
7
|
import { getSyncManager, hasSyncManager } from './sync';
|
|
14
8
|
|
|
@@ -313,7 +307,10 @@ export const saveDirtyEntities =
|
|
|
313
307
|
pendingSavedRecords.push(
|
|
314
308
|
registry
|
|
315
309
|
.dispatch( STORE_NAME )
|
|
316
|
-
.saveEditedEntityRecord( kind, name, key
|
|
310
|
+
.saveEditedEntityRecord( kind, name, key, {
|
|
311
|
+
throwOnError: true,
|
|
312
|
+
} )
|
|
313
|
+
.catch( ensureError )
|
|
317
314
|
);
|
|
318
315
|
}
|
|
319
316
|
} );
|
|
@@ -325,15 +322,19 @@ export const saveDirtyEntities =
|
|
|
325
322
|
'root',
|
|
326
323
|
'site',
|
|
327
324
|
undefined,
|
|
328
|
-
siteItemsToSave
|
|
325
|
+
siteItemsToSave,
|
|
326
|
+
{
|
|
327
|
+
throwOnError: true,
|
|
328
|
+
}
|
|
329
329
|
)
|
|
330
|
+
.catch( ensureError )
|
|
330
331
|
);
|
|
331
332
|
}
|
|
332
333
|
registry
|
|
333
334
|
.dispatch( blockEditorStore )
|
|
334
335
|
.__unstableMarkLastChangeAsPersistent();
|
|
335
336
|
|
|
336
|
-
Promise.all( pendingSavedRecords )
|
|
337
|
+
return Promise.all( pendingSavedRecords )
|
|
337
338
|
.then( async ( values ) => {
|
|
338
339
|
if ( onSave ) {
|
|
339
340
|
await onSave();
|
|
@@ -341,12 +342,23 @@ export const saveDirtyEntities =
|
|
|
341
342
|
return values;
|
|
342
343
|
} )
|
|
343
344
|
.then( ( values ) => {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
const errors = values.filter( ( v ) => v instanceof Error );
|
|
346
|
+
if ( errors.length ) {
|
|
347
|
+
const firstMessage = errors.find(
|
|
348
|
+
( e ) => e.message
|
|
349
|
+
)?.message;
|
|
350
|
+
|
|
347
351
|
registry
|
|
348
352
|
.dispatch( noticesStore )
|
|
349
|
-
.createErrorNotice(
|
|
353
|
+
.createErrorNotice(
|
|
354
|
+
decodeEntities(
|
|
355
|
+
firstMessage || __( 'Saving failed.' )
|
|
356
|
+
),
|
|
357
|
+
{
|
|
358
|
+
type: 'snackbar',
|
|
359
|
+
id: saveNoticeId,
|
|
360
|
+
}
|
|
361
|
+
);
|
|
350
362
|
} else {
|
|
351
363
|
registry
|
|
352
364
|
.dispatch( noticesStore )
|
|
@@ -370,7 +382,43 @@ export const saveDirtyEntities =
|
|
|
370
382
|
registry
|
|
371
383
|
.dispatch( noticesStore )
|
|
372
384
|
.createErrorNotice(
|
|
373
|
-
|
|
385
|
+
decodeEntities(
|
|
386
|
+
error?.message || __( 'Saving failed.' )
|
|
387
|
+
),
|
|
388
|
+
{
|
|
389
|
+
type: 'snackbar',
|
|
390
|
+
id: saveNoticeId,
|
|
391
|
+
}
|
|
374
392
|
)
|
|
375
393
|
);
|
|
394
|
+
|
|
395
|
+
function ensureError( error ) {
|
|
396
|
+
if ( error instanceof Error ) {
|
|
397
|
+
return error;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Expect certain errors to be plain objects with a `message`
|
|
401
|
+
// property, such as those thrown by `apiFetch`. Otherwise, do our
|
|
402
|
+
// best to infer a message via duck typing.
|
|
403
|
+
let message;
|
|
404
|
+
if ( ! error ) {
|
|
405
|
+
} else if ( typeof error.message === 'string' ) {
|
|
406
|
+
message = error.message;
|
|
407
|
+
} else if ( typeof error === 'string' ) {
|
|
408
|
+
message = error;
|
|
409
|
+
} else if (
|
|
410
|
+
// Only consider own method, lest we erroneously end up calling
|
|
411
|
+
// `Object#toString` at the end of the prototype chain, thereby
|
|
412
|
+
// returning `"[object Object]"`.
|
|
413
|
+
Object.hasOwn( error, 'toString' ) &&
|
|
414
|
+
typeof error.toString === 'function'
|
|
415
|
+
) {
|
|
416
|
+
const result = error.toString();
|
|
417
|
+
if ( typeof result === 'string' ) {
|
|
418
|
+
message = result;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return new Error( message, { cause: error } );
|
|
423
|
+
}
|
|
376
424
|
};
|
package/src/private-apis.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { useEntityRecordsWithPermissions } from './hooks/use-entity-records';
|
|
5
2
|
import { RECEIVE_INTERMEDIATE_RESULTS } from './utils';
|
|
6
3
|
import {
|
|
@@ -18,7 +15,12 @@ import {
|
|
|
18
15
|
} from './components/entities-saved-states';
|
|
19
16
|
import { useIsDirty as useEntitiesSavedStatesIsDirty } from './components/entities-saved-states/hooks/use-is-dirty';
|
|
20
17
|
import { lock } from './lock-unlock';
|
|
21
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
CRDT_AUTOSAVE_SNAPSHOT_KEY,
|
|
20
|
+
entityContainsSnapshot,
|
|
21
|
+
getEntitySnapshot,
|
|
22
|
+
retrySyncConnection,
|
|
23
|
+
} from './sync';
|
|
22
24
|
import {
|
|
23
25
|
SelectionType,
|
|
24
26
|
SelectionDirection,
|
|
@@ -32,6 +34,9 @@ const lockedApis = {
|
|
|
32
34
|
useEntitiesSavedStatesIsDirty,
|
|
33
35
|
useEntityRecordsWithPermissions,
|
|
34
36
|
RECEIVE_INTERMEDIATE_RESULTS,
|
|
37
|
+
CRDT_AUTOSAVE_SNAPSHOT_KEY,
|
|
38
|
+
entityContainsSnapshot,
|
|
39
|
+
getEntitySnapshot,
|
|
35
40
|
retrySyncConnection,
|
|
36
41
|
useActiveCollaborators,
|
|
37
42
|
useResolvedSelection,
|
package/src/private-selectors.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
5
2
|
import type { ConnectionStatus } from '@wordpress/sync';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { getDefaultTemplateId, getEntityRecord, type State } from './selectors';
|
|
11
4
|
import { STORE_NAME } from './name';
|
|
12
5
|
import { unlock } from './lock-unlock';
|
|
@@ -374,3 +367,25 @@ export function getSyncConnectionStatus(
|
|
|
374
367
|
|
|
375
368
|
return coalesced;
|
|
376
369
|
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Returns the sync connection status for a single entity, or undefined if
|
|
373
|
+
* the entity is not being synced or no provider has reported a status yet.
|
|
374
|
+
*
|
|
375
|
+
* @param state Data state.
|
|
376
|
+
* @param kind Entity kind.
|
|
377
|
+
* @param name Entity name.
|
|
378
|
+
* @param recordId Record ID.
|
|
379
|
+
*
|
|
380
|
+
* @return The sync connection status for the entity.
|
|
381
|
+
*/
|
|
382
|
+
export function getEntitySyncConnectionStatus(
|
|
383
|
+
state: State,
|
|
384
|
+
kind: string,
|
|
385
|
+
name: string,
|
|
386
|
+
recordId: EntityRecordKey
|
|
387
|
+
): ConnectionStatus | undefined {
|
|
388
|
+
return state.syncConnectionStatuses?.[
|
|
389
|
+
`${ kind }/${ name }:${ recordId }`
|
|
390
|
+
];
|
|
391
|
+
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { combineReducers, keyedReducer } from '@wordpress/data';
|
|
5
2
|
import { compose } from '@wordpress/compose';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { conservativeMapItem, ifMatchingAction, replaceAction } from '../utils';
|
|
11
4
|
import { DEFAULT_ENTITY_KEY } from '../entities';
|
|
12
5
|
import getQueryParts from './get-query-parts';
|
package/src/reducer.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import fastDeepEqual from 'fast-deep-equal/es6/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { compose } from '@wordpress/compose';
|
|
10
3
|
import { combineReducers } from '@wordpress/data';
|
|
11
4
|
import { createUndoManager } from '@wordpress/undo-manager';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
5
|
import { clearUnchangedEdits, ifMatchingAction, replaceAction } from './utils';
|
|
17
6
|
import { reducer as queriedDataReducer } from './queried-data';
|
|
18
7
|
import { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
|
package/src/resolvers.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { camelCase } from 'change-case';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { addQueryArgs } from '@wordpress/url';
|
|
10
3
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
5
|
import { STORE_NAME } from './name';
|
|
17
6
|
import { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';
|
|
18
7
|
import { getSyncManager } from './sync';
|
|
@@ -1067,7 +1056,7 @@ getDefaultTemplateId.shouldInvalidate = ( action ) => {
|
|
|
1067
1056
|
*/
|
|
1068
1057
|
export const getRevisions =
|
|
1069
1058
|
( kind, name, recordKey, query = {} ) =>
|
|
1070
|
-
async ( { dispatch,
|
|
1059
|
+
async ( { dispatch, resolveSelect } ) => {
|
|
1071
1060
|
const configs = await resolveSelect.getEntitiesConfig( kind );
|
|
1072
1061
|
const entityConfig = configs.find(
|
|
1073
1062
|
( config ) => config.name === name && config.kind === kind
|
|
@@ -1142,37 +1131,31 @@ export const getRevisions =
|
|
|
1142
1131
|
} );
|
|
1143
1132
|
}
|
|
1144
1133
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1134
|
+
await dispatch.receiveRevisions(
|
|
1135
|
+
kind,
|
|
1136
|
+
name,
|
|
1137
|
+
recordKey,
|
|
1138
|
+
records,
|
|
1139
|
+
query,
|
|
1140
|
+
false,
|
|
1141
|
+
meta
|
|
1142
|
+
);
|
|
1143
|
+
|
|
1144
|
+
// Mark individual getRevision resolutions as done so that
|
|
1145
|
+
// subsequent getRevision calls skip redundant API fetches.
|
|
1146
|
+
const key = entityConfig.revisionKey || DEFAULT_ENTITY_KEY;
|
|
1147
|
+
const normalizedQuery = normalizeQueryForResolution( rawQuery );
|
|
1148
|
+
const resolutionsArgs = records
|
|
1149
|
+
.filter( ( record ) => record[ key ] )
|
|
1150
|
+
.map( ( record ) => [
|
|
1147
1151
|
kind,
|
|
1148
1152
|
name,
|
|
1149
1153
|
recordKey,
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
meta
|
|
1154
|
-
);
|
|
1154
|
+
record[ key ],
|
|
1155
|
+
normalizedQuery,
|
|
1156
|
+
] );
|
|
1155
1157
|
|
|
1156
|
-
|
|
1157
|
-
// subsequent getRevision calls skip redundant API fetches.
|
|
1158
|
-
const key = entityConfig.revisionKey || DEFAULT_ENTITY_KEY;
|
|
1159
|
-
const normalizedQuery =
|
|
1160
|
-
normalizeQueryForResolution( rawQuery );
|
|
1161
|
-
const resolutionsArgs = records
|
|
1162
|
-
.filter( ( record ) => record[ key ] )
|
|
1163
|
-
.map( ( record ) => [
|
|
1164
|
-
kind,
|
|
1165
|
-
name,
|
|
1166
|
-
recordKey,
|
|
1167
|
-
record[ key ],
|
|
1168
|
-
normalizedQuery,
|
|
1169
|
-
] );
|
|
1170
|
-
|
|
1171
|
-
dispatch.finishResolutions(
|
|
1172
|
-
'getRevision',
|
|
1173
|
-
resolutionsArgs
|
|
1174
|
-
);
|
|
1175
|
-
} );
|
|
1158
|
+
dispatch.finishResolutions( 'getRevision', resolutionsArgs );
|
|
1176
1159
|
}
|
|
1177
1160
|
} finally {
|
|
1178
1161
|
dispatch.__unstableReleaseStoreLock( lock );
|
|
@@ -1261,7 +1244,7 @@ export const getRevision =
|
|
|
1261
1244
|
}
|
|
1262
1245
|
|
|
1263
1246
|
if ( record ) {
|
|
1264
|
-
dispatch.receiveRevisions(
|
|
1247
|
+
await dispatch.receiveRevisions(
|
|
1265
1248
|
kind,
|
|
1266
1249
|
name,
|
|
1267
1250
|
recordKey,
|
package/src/selectors.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
5
2
|
import { addQueryArgs } from '@wordpress/url';
|
|
6
3
|
import type { UndoManager } from '@wordpress/undo-manager';
|
|
7
4
|
import deprecated from '@wordpress/deprecated';
|
|
8
5
|
import type { ConnectionStatus } from '@wordpress/sync';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
6
|
import { STORE_NAME } from './name';
|
|
14
7
|
import {
|
|
15
8
|
getQueriedItems,
|
package/src/sync.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import {
|
|
5
2
|
privateApis as syncPrivateApis,
|
|
6
3
|
type SyncManager,
|
|
7
4
|
} from '@wordpress/sync';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
5
|
import { unlock } from './lock-unlock';
|
|
13
6
|
|
|
14
7
|
const {
|
|
@@ -32,6 +25,16 @@ export {
|
|
|
32
25
|
retrySyncConnection,
|
|
33
26
|
};
|
|
34
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Key under which an autosave records the CRDT snapshot describing its
|
|
30
|
+
* content. Used both as the REST autosave request parameter and as the key in
|
|
31
|
+
* the local (sessionStorage) autosave backup.
|
|
32
|
+
*
|
|
33
|
+
* This string must match CRDT_SNAPSHOT_PARAM in
|
|
34
|
+
* Gutenberg_REST_Autosaves_Controller on the PHP side.
|
|
35
|
+
*/
|
|
36
|
+
export const CRDT_AUTOSAVE_SNAPSHOT_KEY = 'crdt_snapshot';
|
|
37
|
+
|
|
35
38
|
let syncManager: SyncManager;
|
|
36
39
|
|
|
37
40
|
export function getSyncManager(): SyncManager | undefined {
|
|
@@ -52,3 +55,57 @@ export function getSyncManager(): SyncManager | undefined {
|
|
|
52
55
|
export function hasSyncManager(): boolean {
|
|
53
56
|
return Boolean( syncManager );
|
|
54
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Encode a synced entity's current CRDT state as a snapshot. Returns undefined
|
|
61
|
+
* when the entity is not being synced.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} kind Entity kind.
|
|
64
|
+
* @param {string} name Entity name.
|
|
65
|
+
* @param {string|number} recordId Record ID.
|
|
66
|
+
* @return {string|undefined} Base64-encoded snapshot.
|
|
67
|
+
*/
|
|
68
|
+
export function getEntitySnapshot(
|
|
69
|
+
kind: string,
|
|
70
|
+
name: string,
|
|
71
|
+
recordId: string | number
|
|
72
|
+
): string | undefined {
|
|
73
|
+
if ( ! hasSyncManager() ) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return getSyncManager()?.getEntitySnapshot(
|
|
78
|
+
`${ kind }/${ name }`,
|
|
79
|
+
`${ recordId }`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Determine whether a synced entity's CRDT document contains everything the
|
|
85
|
+
* given snapshot describes. Returns false when the entity is not being synced
|
|
86
|
+
* or the snapshot cannot be decoded, so callers fail open.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} kind Entity kind.
|
|
89
|
+
* @param {string} name Entity name.
|
|
90
|
+
* @param {string|number} recordId Record ID.
|
|
91
|
+
* @param {string} encodedSnapshot Base64-encoded snapshot.
|
|
92
|
+
* @return {boolean} Whether the document contains the snapshotted state.
|
|
93
|
+
*/
|
|
94
|
+
export function entityContainsSnapshot(
|
|
95
|
+
kind: string,
|
|
96
|
+
name: string,
|
|
97
|
+
recordId: string | number,
|
|
98
|
+
encodedSnapshot: string
|
|
99
|
+
): boolean {
|
|
100
|
+
if ( ! hasSyncManager() ) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
getSyncManager()?.entityContainsSnapshot(
|
|
106
|
+
`${ kind }/${ name }`,
|
|
107
|
+
`${ recordId }`,
|
|
108
|
+
encodedSnapshot
|
|
109
|
+
) ?? false
|
|
110
|
+
);
|
|
111
|
+
}
|