@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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/build/actions.js +375 -632
- package/build/actions.js.map +7 -1
- package/build/batch/create-batch.js +49 -62
- package/build/batch/create-batch.js.map +7 -1
- package/build/batch/default-processor.js +43 -39
- package/build/batch/default-processor.js.map +7 -1
- package/build/batch/index.js +38 -17
- package/build/batch/index.js.map +7 -1
- package/build/dynamic-entities.js +30 -32
- package/build/dynamic-entities.js.map +7 -1
- package/build/entities.js +298 -410
- package/build/entities.js.map +7 -1
- package/build/entity-context.js +29 -12
- package/build/entity-context.js.map +7 -1
- package/build/entity-provider.js +38 -46
- package/build/entity-provider.js.map +7 -1
- package/build/entity-types/attachment.js +16 -5
- package/build/entity-types/attachment.js.map +7 -1
- package/build/entity-types/base-entity-records.js +16 -42
- package/build/entity-types/base-entity-records.js.map +7 -1
- package/build/entity-types/base.js +16 -5
- package/build/entity-types/base.js.map +7 -1
- package/build/entity-types/comment.js +16 -5
- package/build/entity-types/comment.js.map +7 -1
- package/build/entity-types/global-styles-revision.js +16 -5
- package/build/entity-types/global-styles-revision.js.map +7 -1
- package/build/entity-types/helpers.js +16 -5
- package/build/entity-types/helpers.js.map +7 -1
- package/build/entity-types/index.js +16 -5
- package/build/entity-types/index.js.map +7 -1
- package/build/entity-types/menu-location.js +16 -5
- package/build/entity-types/menu-location.js.map +7 -1
- package/build/entity-types/nav-menu-item.js +16 -5
- package/build/entity-types/nav-menu-item.js.map +7 -1
- package/build/entity-types/nav-menu.js +16 -5
- package/build/entity-types/nav-menu.js.map +7 -1
- package/build/entity-types/page.js +16 -5
- package/build/entity-types/page.js.map +7 -1
- package/build/entity-types/plugin.js +16 -5
- package/build/entity-types/plugin.js.map +7 -1
- package/build/entity-types/post-revision.js +16 -5
- package/build/entity-types/post-revision.js.map +7 -1
- package/build/entity-types/post-status.js +16 -5
- package/build/entity-types/post-status.js.map +7 -1
- package/build/entity-types/post.js +16 -5
- package/build/entity-types/post.js.map +7 -1
- package/build/entity-types/settings.js +16 -5
- package/build/entity-types/settings.js.map +7 -1
- package/build/entity-types/sidebar.js +16 -5
- package/build/entity-types/sidebar.js.map +7 -1
- package/build/entity-types/taxonomy.js +16 -5
- package/build/entity-types/taxonomy.js.map +7 -1
- package/build/entity-types/term.js +16 -5
- package/build/entity-types/term.js.map +7 -1
- package/build/entity-types/theme.js +16 -5
- package/build/entity-types/theme.js.map +7 -1
- package/build/entity-types/type.js +16 -5
- package/build/entity-types/type.js.map +7 -1
- package/build/entity-types/user.js +16 -5
- package/build/entity-types/user.js.map +7 -1
- package/build/entity-types/widget-type.js +16 -5
- package/build/entity-types/widget-type.js.map +7 -1
- package/build/entity-types/widget.js +16 -5
- package/build/entity-types/widget.js.map +7 -1
- package/build/entity-types/wp-template-part.js +16 -5
- package/build/entity-types/wp-template-part.js.map +7 -1
- package/build/entity-types/wp-template.js +16 -5
- package/build/entity-types/wp-template.js.map +7 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build/fetch/__experimental-fetch-url-data.js +47 -59
- package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build/fetch/index.js +53 -32
- package/build/fetch/index.js.map +7 -1
- package/build/footnotes/get-footnotes-order.js +38 -25
- package/build/footnotes/get-footnotes-order.js.map +7 -1
- package/build/footnotes/get-rich-text-values-cached.js +26 -27
- package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build/footnotes/index.js +68 -55
- package/build/footnotes/index.js.map +7 -1
- package/build/hooks/constants.js +33 -12
- package/build/hooks/constants.js.map +7 -1
- package/build/hooks/index.js +59 -68
- package/build/hooks/index.js.map +7 -1
- package/build/hooks/memoize.js +34 -12
- package/build/hooks/memoize.js.map +7 -1
- package/build/hooks/use-entity-block-editor.js +111 -119
- package/build/hooks/use-entity-block-editor.js.map +7 -1
- package/build/hooks/use-entity-id.js +25 -23
- package/build/hooks/use-entity-id.js.map +7 -1
- package/build/hooks/use-entity-prop.js +59 -60
- package/build/hooks/use-entity-prop.js.map +7 -1
- package/build/hooks/use-entity-record.js +95 -155
- package/build/hooks/use-entity-record.js.map +7 -1
- package/build/hooks/use-entity-records.js +131 -139
- package/build/hooks/use-entity-records.js.map +7 -1
- package/build/hooks/use-query-select.js +65 -84
- package/build/hooks/use-query-select.js.map +7 -1
- package/build/hooks/use-resource-permissions.js +92 -145
- package/build/hooks/use-resource-permissions.js.map +7 -1
- package/build/index.js +96 -153
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/locks/actions.js +36 -19
- package/build/locks/actions.js.map +7 -1
- package/build/locks/engine.js +48 -47
- package/build/locks/engine.js.map +7 -1
- package/build/locks/reducer.js +54 -63
- package/build/locks/reducer.js.map +7 -1
- package/build/locks/selectors.js +35 -30
- package/build/locks/selectors.js.map +7 -1
- package/build/locks/utils.js +37 -16
- package/build/locks/utils.js.map +7 -1
- package/build/name.js +27 -12
- package/build/name.js.map +7 -1
- package/build/private-actions.js +67 -75
- package/build/private-actions.js.map +7 -1
- package/build/private-apis.js +33 -16
- package/build/private-apis.js.map +7 -1
- package/build/private-selectors.js +204 -184
- package/build/private-selectors.js.map +7 -1
- package/build/queried-data/actions.js +32 -41
- package/build/queried-data/actions.js.map +7 -1
- package/build/queried-data/get-query-parts.js +41 -79
- package/build/queried-data/get-query-parts.js.map +7 -1
- package/build/queried-data/index.js +39 -36
- package/build/queried-data/index.js.map +7 -1
- package/build/queried-data/reducer.js +162 -193
- package/build/queried-data/reducer.js.map +7 -1
- package/build/queried-data/selectors.js +57 -85
- package/build/queried-data/selectors.js.map +7 -1
- package/build/reducer.js +279 -404
- package/build/reducer.js.map +7 -1
- package/build/resolvers.js +553 -600
- package/build/resolvers.js.map +7 -1
- package/build/selectors.js +456 -981
- package/build/selectors.js.map +7 -1
- package/build/sync.js +34 -22
- package/build/sync.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/conservative-map-item.js +34 -27
- package/build/utils/conservative-map-item.js.map +7 -1
- package/build/utils/crdt-blocks.js +289 -0
- package/build/utils/crdt-blocks.js.map +7 -0
- package/build/utils/crdt.js +202 -0
- package/build/utils/crdt.js.map +7 -0
- package/build/utils/forward-resolver.js +24 -16
- package/build/utils/forward-resolver.js.map +7 -1
- package/build/utils/get-nested-value.js +26 -21
- package/build/utils/get-nested-value.js.map +7 -1
- package/build/utils/get-normalized-comma-separable.js +25 -17
- package/build/utils/get-normalized-comma-separable.js.map +7 -1
- package/build/utils/if-matching-action.js +25 -19
- package/build/utils/if-matching-action.js.map +7 -1
- package/build/utils/index.js +77 -108
- package/build/utils/index.js.map +7 -1
- package/build/utils/is-numeric-id.js +22 -12
- package/build/utils/is-numeric-id.js.map +7 -1
- package/build/utils/is-raw-attribute.js +22 -13
- package/build/utils/is-raw-attribute.js.map +7 -1
- package/build/utils/log-entity-deprecation.js +37 -38
- package/build/utils/log-entity-deprecation.js.map +7 -1
- package/build/utils/on-sub-key.js +30 -24
- package/build/utils/on-sub-key.js.map +7 -1
- package/build/utils/receive-intermediate-results.js +29 -6
- package/build/utils/receive-intermediate-results.js.map +7 -1
- package/build/utils/replace-action.js +24 -17
- package/build/utils/replace-action.js.map +7 -1
- package/build/utils/set-nested-value.js +25 -30
- package/build/utils/set-nested-value.js.map +7 -1
- package/build/utils/user-permissions.js +41 -13
- package/build/utils/user-permissions.js.map +7 -1
- package/build/utils/with-weak-map-cache.js +26 -22
- package/build/utils/with-weak-map-cache.js.map +7 -1
- package/build-module/actions.js +322 -601
- package/build-module/actions.js.map +7 -1
- package/build-module/batch/create-batch.js +21 -57
- package/build-module/batch/create-batch.js.map +7 -1
- package/build-module/batch/default-processor.js +14 -33
- package/build-module/batch/default-processor.js.map +7 -1
- package/build-module/batch/index.js +7 -3
- package/build-module/batch/index.js.map +7 -1
- package/build-module/dynamic-entities.js +7 -28
- package/build-module/dynamic-entities.js.map +7 -1
- package/build-module/entities.js +263 -399
- package/build-module/entities.js.map +7 -1
- package/build-module/entity-context.js +7 -7
- package/build-module/entity-context.js.map +7 -1
- package/build-module/entity-provider.js +19 -42
- package/build-module/entity-provider.js.map +7 -1
- package/build-module/entity-types/attachment.js +1 -2
- package/build-module/entity-types/attachment.js.map +7 -1
- package/build-module/entity-types/base-entity-records.js +1 -37
- package/build-module/entity-types/base-entity-records.js.map +7 -1
- package/build-module/entity-types/base.js +1 -2
- package/build-module/entity-types/base.js.map +7 -1
- package/build-module/entity-types/comment.js +1 -2
- package/build-module/entity-types/comment.js.map +7 -1
- package/build-module/entity-types/global-styles-revision.js +1 -2
- package/build-module/entity-types/global-styles-revision.js.map +7 -1
- package/build-module/entity-types/helpers.js +1 -2
- package/build-module/entity-types/helpers.js.map +7 -1
- package/build-module/entity-types/index.js +1 -2
- package/build-module/entity-types/index.js.map +7 -1
- package/build-module/entity-types/menu-location.js +1 -2
- package/build-module/entity-types/menu-location.js.map +7 -1
- package/build-module/entity-types/nav-menu-item.js +1 -2
- package/build-module/entity-types/nav-menu-item.js.map +7 -1
- package/build-module/entity-types/nav-menu.js +1 -2
- package/build-module/entity-types/nav-menu.js.map +7 -1
- package/build-module/entity-types/page.js +1 -2
- package/build-module/entity-types/page.js.map +7 -1
- package/build-module/entity-types/plugin.js +1 -2
- package/build-module/entity-types/plugin.js.map +7 -1
- package/build-module/entity-types/post-revision.js +1 -2
- package/build-module/entity-types/post-revision.js.map +7 -1
- package/build-module/entity-types/post-status.js +1 -2
- package/build-module/entity-types/post-status.js.map +7 -1
- package/build-module/entity-types/post.js +1 -2
- package/build-module/entity-types/post.js.map +7 -1
- package/build-module/entity-types/settings.js +1 -2
- package/build-module/entity-types/settings.js.map +7 -1
- package/build-module/entity-types/sidebar.js +1 -2
- package/build-module/entity-types/sidebar.js.map +7 -1
- package/build-module/entity-types/taxonomy.js +1 -2
- package/build-module/entity-types/taxonomy.js.map +7 -1
- package/build-module/entity-types/term.js +1 -2
- package/build-module/entity-types/term.js.map +7 -1
- package/build-module/entity-types/theme.js +1 -2
- package/build-module/entity-types/theme.js.map +7 -1
- package/build-module/entity-types/type.js +1 -2
- package/build-module/entity-types/type.js.map +7 -1
- package/build-module/entity-types/user.js +1 -2
- package/build-module/entity-types/user.js.map +7 -1
- package/build-module/entity-types/widget-type.js +1 -2
- package/build-module/entity-types/widget-type.js.map +7 -1
- package/build-module/entity-types/widget.js +1 -2
- package/build-module/entity-types/widget.js.map +7 -1
- package/build-module/entity-types/wp-template-part.js +1 -2
- package/build-module/entity-types/wp-template-part.js.map +7 -1
- package/build-module/entity-types/wp-template.js +1 -2
- package/build-module/entity-types/wp-template.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
- package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build-module/fetch/index.js +20 -15
- package/build-module/fetch/index.js.map +7 -1
- package/build-module/footnotes/get-footnotes-order.js +10 -19
- package/build-module/footnotes/get-footnotes-order.js.map +7 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
- package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build-module/footnotes/index.js +34 -47
- package/build-module/footnotes/index.js.map +7 -1
- package/build-module/hooks/constants.js +11 -8
- package/build-module/hooks/constants.js.map +7 -1
- package/build-module/hooks/index.js +27 -15
- package/build-module/hooks/index.js.map +7 -1
- package/build-module/hooks/memoize.js +6 -8
- package/build-module/hooks/memoize.js.map +7 -1
- package/build-module/hooks/use-entity-block-editor.js +80 -110
- package/build-module/hooks/use-entity-block-editor.js.map +7 -1
- package/build-module/hooks/use-entity-id.js +7 -19
- package/build-module/hooks/use-entity-id.js.map +7 -1
- package/build-module/hooks/use-entity-prop.js +31 -55
- package/build-module/hooks/use-entity-prop.js.map +7 -1
- package/build-module/hooks/use-entity-record.js +63 -148
- package/build-module/hooks/use-entity-record.js.map +7 -1
- package/build-module/hooks/use-entity-records.js +98 -131
- package/build-module/hooks/use-entity-records.js.map +7 -1
- package/build-module/hooks/use-query-select.js +27 -71
- package/build-module/hooks/use-query-select.js.map +7 -1
- package/build-module/hooks/use-resource-permissions.js +57 -136
- package/build-module/hooks/use-resource-permissions.js.map +7 -1
- package/build-module/index.js +49 -71
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/locks/actions.js +8 -13
- package/build-module/locks/actions.js.map +7 -1
- package/build-module/locks/engine.js +17 -38
- package/build-module/locks/engine.js.map +7 -1
- package/build-module/locks/reducer.js +37 -59
- package/build-module/locks/reducer.js.map +7 -1
- package/build-module/locks/selectors.js +16 -23
- package/build-module/locks/selectors.js.map +7 -1
- package/build-module/locks/utils.js +15 -12
- package/build-module/locks/utils.js.map +7 -1
- package/build-module/name.js +5 -8
- package/build-module/name.js.map +7 -1
- package/build-module/private-actions.js +35 -69
- package/build-module/private-actions.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-selectors.js +167 -174
- package/build-module/private-selectors.js.map +7 -1
- package/build-module/queried-data/actions.js +11 -38
- package/build-module/queried-data/actions.js.map +7 -1
- package/build-module/queried-data/get-query-parts.js +20 -75
- package/build-module/queried-data/get-query-parts.js.map +7 -1
- package/build-module/queried-data/index.js +7 -4
- package/build-module/queried-data/index.js.map +7 -1
- package/build-module/queried-data/reducer.js +134 -185
- package/build-module/queried-data/reducer.js.map +7 -1
- package/build-module/queried-data/selectors.js +23 -78
- package/build-module/queried-data/selectors.js.map +7 -1
- package/build-module/reducer.js +243 -393
- package/build-module/reducer.js.map +7 -1
- package/build-module/resolvers.js +478 -549
- package/build-module/resolvers.js.map +7 -1
- package/build-module/selectors.js +410 -953
- package/build-module/selectors.js.map +7 -1
- package/build-module/sync.js +14 -17
- package/build-module/sync.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/conservative-map-item.js +6 -22
- package/build-module/utils/conservative-map-item.js.map +7 -1
- package/build-module/utils/crdt-blocks.js +255 -0
- package/build-module/utils/crdt-blocks.js.map +7 -0
- package/build-module/utils/crdt.js +167 -0
- package/build-module/utils/crdt.js.map +7 -0
- package/build-module/utils/forward-resolver.js +6 -12
- package/build-module/utils/forward-resolver.js.map +7 -1
- package/build-module/utils/get-nested-value.js +9 -18
- package/build-module/utils/get-nested-value.js.map +7 -1
- package/build-module/utils/get-normalized-comma-separable.js +7 -13
- package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
- package/build-module/utils/if-matching-action.js +7 -15
- package/build-module/utils/if-matching-action.js.map +7 -1
- package/build-module/utils/index.js +35 -14
- package/build-module/utils/index.js.map +7 -1
- package/build-module/utils/is-numeric-id.js +5 -9
- package/build-module/utils/is-numeric-id.js.map +7 -1
- package/build-module/utils/is-raw-attribute.js +5 -10
- package/build-module/utils/is-raw-attribute.js.map +7 -1
- package/build-module/utils/log-entity-deprecation.js +8 -31
- package/build-module/utils/log-entity-deprecation.js.map +7 -1
- package/build-module/utils/on-sub-key.js +8 -19
- package/build-module/utils/on-sub-key.js.map +7 -1
- package/build-module/utils/receive-intermediate-results.js +7 -2
- package/build-module/utils/receive-intermediate-results.js.map +7 -1
- package/build-module/utils/replace-action.js +6 -13
- package/build-module/utils/replace-action.js.map +7 -1
- package/build-module/utils/set-nested-value.js +8 -27
- package/build-module/utils/set-nested-value.js.map +7 -1
- package/build-module/utils/user-permissions.js +19 -9
- package/build-module/utils/user-permissions.js.map +7 -1
- package/build-module/utils/with-weak-map-cache.js +8 -18
- package/build-module/utils/with-weak-map-cache.js.map +7 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +0 -56
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +6 -1
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +30 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +49 -0
- package/build-types/utils/crdt.d.ts.map +1 -0
- package/package.json +26 -19
- package/src/actions.js +56 -74
- package/src/entities.js +59 -113
- package/src/private-selectors.ts +32 -7
- package/src/resolvers.js +173 -120
- package/src/selectors.ts +0 -13
- package/src/sync.ts +12 -0
- package/src/test/resolvers.js +183 -0
- package/src/types.ts +12 -0
- package/src/utils/crdt-blocks.ts +503 -0
- package/src/utils/crdt.ts +310 -0
- package/src/utils/test/crdt-blocks.ts +375 -0
- package/src/utils/test/crdt.ts +254 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/sync.js +0 -27
|
@@ -1,214 +1,234 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var private_selectors_exports = {};
|
|
30
|
+
__export(private_selectors_exports, {
|
|
31
|
+
getBlockPatternsForPostType: () => getBlockPatternsForPostType,
|
|
32
|
+
getEntityRecordPermissions: () => getEntityRecordPermissions,
|
|
33
|
+
getEntityRecordsPermissions: () => getEntityRecordsPermissions,
|
|
34
|
+
getHomePage: () => getHomePage,
|
|
35
|
+
getNavigationFallbackId: () => getNavigationFallbackId,
|
|
36
|
+
getPostsPageId: () => getPostsPageId,
|
|
37
|
+
getRegisteredPostMeta: () => getRegisteredPostMeta,
|
|
38
|
+
getTemplateAutoDraftId: () => getTemplateAutoDraftId,
|
|
39
|
+
getTemplateId: () => getTemplateId,
|
|
40
|
+
getUndoManager: () => getUndoManager
|
|
6
41
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.getTemplateAutoDraftId = getTemplateAutoDraftId;
|
|
14
|
-
exports.getTemplateId = void 0;
|
|
15
|
-
exports.getUndoManager = getUndoManager;
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
var _selectors = require("./selectors");
|
|
18
|
-
var _name = require("./name");
|
|
19
|
-
var _lockUnlock = require("./lock-unlock");
|
|
20
|
-
var _logEntityDeprecation = _interopRequireDefault(require("./utils/log-entity-deprecation"));
|
|
21
|
-
/**
|
|
22
|
-
* WordPress dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Internal dependencies
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns the previous edit from the current undo offset
|
|
31
|
-
* for the entity records edits history, if any.
|
|
32
|
-
*
|
|
33
|
-
* @param state State tree.
|
|
34
|
-
*
|
|
35
|
-
* @return The undo manager.
|
|
36
|
-
*/
|
|
42
|
+
module.exports = __toCommonJS(private_selectors_exports);
|
|
43
|
+
var import_data = require("@wordpress/data");
|
|
44
|
+
var import_selectors = require("./selectors");
|
|
45
|
+
var import_name = require("./name");
|
|
46
|
+
var import_lock_unlock = require("./lock-unlock");
|
|
47
|
+
var import_log_entity_deprecation = __toESM(require("./utils/log-entity-deprecation"));
|
|
37
48
|
function getUndoManager(state) {
|
|
38
49
|
return state.undoManager;
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Retrieve the fallback Navigation.
|
|
43
|
-
*
|
|
44
|
-
* @param state Data state.
|
|
45
|
-
* @return The ID for the fallback Navigation post.
|
|
46
|
-
*/
|
|
47
51
|
function getNavigationFallbackId(state) {
|
|
48
52
|
return state.navigationFallbackId;
|
|
49
53
|
}
|
|
50
|
-
const getBlockPatternsForPostType =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* @param name Entity name.
|
|
79
|
-
* @param id Entity record id.
|
|
80
|
-
*
|
|
81
|
-
* @return The entity record permissions.
|
|
82
|
-
*/
|
|
54
|
+
const getBlockPatternsForPostType = (0, import_data.createRegistrySelector)(
|
|
55
|
+
(select) => (0, import_data.createSelector)(
|
|
56
|
+
(state, postType) => select(import_name.STORE_NAME).getBlockPatterns().filter(
|
|
57
|
+
({ postTypes }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)
|
|
58
|
+
),
|
|
59
|
+
() => [select(import_name.STORE_NAME).getBlockPatterns()]
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
const getEntityRecordsPermissions = (0, import_data.createRegistrySelector)(
|
|
63
|
+
(select) => (0, import_data.createSelector)(
|
|
64
|
+
(state, kind, name, ids) => {
|
|
65
|
+
const normalizedIds = Array.isArray(ids) ? ids : [ids];
|
|
66
|
+
return normalizedIds.map((id) => ({
|
|
67
|
+
delete: select(import_name.STORE_NAME).canUser("delete", {
|
|
68
|
+
kind,
|
|
69
|
+
name,
|
|
70
|
+
id
|
|
71
|
+
}),
|
|
72
|
+
update: select(import_name.STORE_NAME).canUser("update", {
|
|
73
|
+
kind,
|
|
74
|
+
name,
|
|
75
|
+
id
|
|
76
|
+
})
|
|
77
|
+
}));
|
|
78
|
+
},
|
|
79
|
+
(state) => [state.userPermissions]
|
|
80
|
+
)
|
|
81
|
+
);
|
|
83
82
|
function getEntityRecordPermissions(state, kind, name, id) {
|
|
84
|
-
(0,
|
|
83
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordPermissions");
|
|
85
84
|
return getEntityRecordsPermissions(state, kind, name, id)[0];
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Returns the registered post meta fields for a given post type.
|
|
90
|
-
*
|
|
91
|
-
* @param state Data state.
|
|
92
|
-
* @param postType Post type.
|
|
93
|
-
*
|
|
94
|
-
* @return Registered post meta fields.
|
|
95
|
-
*/
|
|
96
86
|
function getRegisteredPostMeta(state, postType) {
|
|
97
|
-
|
|
98
|
-
return (_state$registeredPost = state.registeredPostMeta?.[postType]) !== null && _state$registeredPost !== void 0 ? _state$registeredPost : {};
|
|
87
|
+
return state.registeredPostMeta?.[postType] ?? {};
|
|
99
88
|
}
|
|
100
89
|
function normalizePageId(value) {
|
|
101
|
-
if (!value || ![
|
|
90
|
+
if (!value || !["number", "string"].includes(typeof value)) {
|
|
102
91
|
return null;
|
|
103
92
|
}
|
|
104
|
-
|
|
105
|
-
// We also need to check if it's not zero (`'0'`).
|
|
106
93
|
if (Number(value) === 0) {
|
|
107
94
|
return null;
|
|
108
95
|
}
|
|
109
96
|
return value.toString();
|
|
110
97
|
}
|
|
111
|
-
const getHomePage =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,
|
|
137
|
-
// it doesn't seem to invalidate this cache, I'm not sure why.
|
|
138
|
-
(0,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
98
|
+
const getHomePage = (0, import_data.createRegistrySelector)(
|
|
99
|
+
(select) => (0, import_data.createSelector)(
|
|
100
|
+
() => {
|
|
101
|
+
const siteData = select(import_name.STORE_NAME).getEntityRecord(
|
|
102
|
+
"root",
|
|
103
|
+
"__unstableBase"
|
|
104
|
+
);
|
|
105
|
+
if (!siteData) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const homepageId = siteData?.show_on_front === "page" ? normalizePageId(siteData.page_on_front) : null;
|
|
109
|
+
if (homepageId) {
|
|
110
|
+
return { postType: "page", postId: homepageId };
|
|
111
|
+
}
|
|
112
|
+
const frontPageTemplateId = select(
|
|
113
|
+
import_name.STORE_NAME
|
|
114
|
+
).getDefaultTemplateId({
|
|
115
|
+
slug: "front-page"
|
|
116
|
+
});
|
|
117
|
+
if (!frontPageTemplateId) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return { postType: "wp_template", postId: frontPageTemplateId };
|
|
121
|
+
},
|
|
122
|
+
(state) => [
|
|
123
|
+
// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,
|
|
124
|
+
// it doesn't seem to invalidate this cache, I'm not sure why.
|
|
125
|
+
(0, import_selectors.getEntityRecord)(state, "root", "site"),
|
|
126
|
+
(0, import_selectors.getEntityRecord)(state, "root", "__unstableBase"),
|
|
127
|
+
(0, import_selectors.getDefaultTemplateId)(state, {
|
|
128
|
+
slug: "front-page"
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
const getPostsPageId = (0, import_data.createRegistrySelector)((select) => () => {
|
|
134
|
+
const siteData = select(import_name.STORE_NAME).getEntityRecord(
|
|
135
|
+
"root",
|
|
136
|
+
"__unstableBase"
|
|
137
|
+
);
|
|
138
|
+
return siteData?.show_on_front === "page" ? normalizePageId(siteData.page_for_posts) : null;
|
|
144
139
|
});
|
|
145
|
-
const getTemplateId =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// For the front page, we always use the front page template if existing.
|
|
152
|
-
if (postType === 'page' && postType === homepage?.postType && postId.toString() === homepage?.postId) {
|
|
153
|
-
// The /lookup endpoint cannot currently handle a lookup
|
|
154
|
-
// when a page is set as the front page, so specifically in
|
|
155
|
-
// that case, we want to check if there is a front page
|
|
156
|
-
// template, and instead of falling back to the home
|
|
157
|
-
// template, we want to fall back to the page template.
|
|
158
|
-
const templates = select(_name.STORE_NAME).getEntityRecords('postType', 'wp_template', {
|
|
159
|
-
per_page: -1
|
|
160
|
-
});
|
|
161
|
-
if (!templates) {
|
|
140
|
+
const getTemplateId = (0, import_data.createRegistrySelector)(
|
|
141
|
+
(select) => (state, postType, postId) => {
|
|
142
|
+
const homepage = (0, import_lock_unlock.unlock)(select(import_name.STORE_NAME)).getHomePage();
|
|
143
|
+
if (!homepage) {
|
|
162
144
|
return;
|
|
163
145
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
146
|
+
if (postType === "page" && postType === homepage?.postType && postId.toString() === homepage?.postId) {
|
|
147
|
+
const templates = select(import_name.STORE_NAME).getEntityRecords(
|
|
148
|
+
"postType",
|
|
149
|
+
"wp_template",
|
|
150
|
+
{
|
|
151
|
+
per_page: -1
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
if (!templates) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const id = templates.find(({ slug }) => slug === "front-page")?.id;
|
|
158
|
+
if (id) {
|
|
159
|
+
return id;
|
|
160
|
+
}
|
|
169
161
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const postsPageId = (0, _lockUnlock.unlock)(select(_name.STORE_NAME)).getPostsPageId();
|
|
178
|
-
// Check if the current page is the posts page.
|
|
179
|
-
if (postType === 'page' && postsPageId === postId.toString()) {
|
|
180
|
-
return select(_name.STORE_NAME).getDefaultTemplateId({
|
|
181
|
-
slug: 'home'
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// First see if the post/page has an assigned template and fetch it.
|
|
185
|
-
const currentTemplateSlug = editedEntity.template;
|
|
186
|
-
if (currentTemplateSlug) {
|
|
187
|
-
const currentTemplate = select(_name.STORE_NAME).getEntityRecords('postType', 'wp_template', {
|
|
188
|
-
per_page: -1
|
|
189
|
-
})?.find(({
|
|
190
|
-
slug
|
|
191
|
-
}) => slug === currentTemplateSlug);
|
|
192
|
-
if (currentTemplate) {
|
|
193
|
-
return currentTemplate.id;
|
|
162
|
+
const editedEntity = select(import_name.STORE_NAME).getEditedEntityRecord(
|
|
163
|
+
"postType",
|
|
164
|
+
postType,
|
|
165
|
+
postId
|
|
166
|
+
);
|
|
167
|
+
if (!editedEntity) {
|
|
168
|
+
return;
|
|
194
169
|
}
|
|
170
|
+
const postsPageId = (0, import_lock_unlock.unlock)(select(import_name.STORE_NAME)).getPostsPageId();
|
|
171
|
+
if (postType === "page" && postsPageId === postId.toString()) {
|
|
172
|
+
return select(import_name.STORE_NAME).getDefaultTemplateId({
|
|
173
|
+
slug: "home"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const currentTemplateSlug = editedEntity.template;
|
|
177
|
+
if (currentTemplateSlug) {
|
|
178
|
+
const userTemplates = select(import_name.STORE_NAME).getEntityRecords(
|
|
179
|
+
"postType",
|
|
180
|
+
"wp_template",
|
|
181
|
+
{ per_page: -1 }
|
|
182
|
+
);
|
|
183
|
+
if (!userTemplates) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const userTemplateWithSlug = userTemplates.find(
|
|
187
|
+
({ slug }) => slug === currentTemplateSlug
|
|
188
|
+
);
|
|
189
|
+
if (userTemplateWithSlug) {
|
|
190
|
+
return userTemplateWithSlug.id;
|
|
191
|
+
}
|
|
192
|
+
const registeredTemplates = select(import_name.STORE_NAME).getEntityRecords(
|
|
193
|
+
"postType",
|
|
194
|
+
"wp_registered_template",
|
|
195
|
+
{ per_page: -1 }
|
|
196
|
+
);
|
|
197
|
+
if (!registeredTemplates) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const registeredTemplateWithSlug = registeredTemplates.find(
|
|
201
|
+
({ slug }) => slug === currentTemplateSlug
|
|
202
|
+
);
|
|
203
|
+
if (registeredTemplateWithSlug) {
|
|
204
|
+
return registeredTemplateWithSlug.id;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
let slugToCheck;
|
|
208
|
+
if (editedEntity.slug) {
|
|
209
|
+
slugToCheck = postType === "page" ? `${postType}-${editedEntity.slug}` : `single-${postType}-${editedEntity.slug}`;
|
|
210
|
+
} else {
|
|
211
|
+
slugToCheck = postType === "page" ? "page" : `single-${postType}`;
|
|
212
|
+
}
|
|
213
|
+
return select(import_name.STORE_NAME).getDefaultTemplateId({
|
|
214
|
+
slug: slugToCheck
|
|
215
|
+
});
|
|
195
216
|
}
|
|
196
|
-
|
|
197
|
-
let slugToCheck;
|
|
198
|
-
// In `draft` status we might not have a slug available, so we use the `single`
|
|
199
|
-
// post type templates slug(ex page, single-post, single-product etc..).
|
|
200
|
-
// Pages do not need the `single` prefix in the slug to be prioritized
|
|
201
|
-
// through template hierarchy.
|
|
202
|
-
if (editedEntity.slug) {
|
|
203
|
-
slugToCheck = postType === 'page' ? `${postType}-${editedEntity.slug}` : `single-${postType}-${editedEntity.slug}`;
|
|
204
|
-
} else {
|
|
205
|
-
slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
|
|
206
|
-
}
|
|
207
|
-
return select(_name.STORE_NAME).getDefaultTemplateId({
|
|
208
|
-
slug: slugToCheck
|
|
209
|
-
});
|
|
210
|
-
});
|
|
217
|
+
);
|
|
211
218
|
function getTemplateAutoDraftId(state, staticTemplateId) {
|
|
212
219
|
return state.templateAutoDraftId[staticTemplateId];
|
|
213
220
|
}
|
|
214
|
-
|
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
222
|
+
0 && (module.exports = {
|
|
223
|
+
getBlockPatternsForPostType,
|
|
224
|
+
getEntityRecordPermissions,
|
|
225
|
+
getEntityRecordsPermissions,
|
|
226
|
+
getHomePage,
|
|
227
|
+
getNavigationFallbackId,
|
|
228
|
+
getPostsPageId,
|
|
229
|
+
getRegisteredPostMeta,
|
|
230
|
+
getTemplateAutoDraftId,
|
|
231
|
+
getTemplateId,
|
|
232
|
+
getUndoManager
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=private-selectors.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_selectors","_name","_lockUnlock","_logEntityDeprecation","_interopRequireDefault","getUndoManager","state","undoManager","getNavigationFallbackId","navigationFallbackId","getBlockPatternsForPostType","exports","createRegistrySelector","select","createSelector","postType","STORE_NAME","getBlockPatterns","filter","postTypes","Array","isArray","includes","getEntityRecordsPermissions","kind","name","ids","normalizedIds","map","id","delete","canUser","update","userPermissions","getEntityRecordPermissions","logEntityDeprecation","getRegisteredPostMeta","_state$registeredPost","registeredPostMeta","normalizePageId","value","Number","toString","getHomePage","siteData","getEntityRecord","homepageId","show_on_front","page_on_front","postId","frontPageTemplateId","getDefaultTemplateId","slug","getPostsPageId","page_for_posts","getTemplateId","homepage","unlock","templates","getEntityRecords","per_page","find","editedEntity","getEditedEntityRecord","postsPageId","currentTemplateSlug","template","currentTemplate","slugToCheck","getTemplateAutoDraftId","staticTemplateId","templateAutoDraftId"],"sources":["@wordpress/core-data/src/private-selectors.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t(\n\t\t\tstate: State,\n\t\t\tkind: string,\n\t\t\tname: string,\n\t\t\tids: string | string[]\n\t\t) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param id Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordPermissions' );\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase'\n\t\t\t) as SiteData | undefined;\n\t\t\t// Still resolving getEntityRecord.\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\t// Still resolving getDefaultTemplateId.\n\t\t\tif ( ! frontPageTemplateId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\t// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,\n\t\t\t// it doesn't seem to invalidate this cache, I'm not sure why.\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetEntityRecord( state, 'root', '__unstableBase' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t'root',\n\t\t'__unstableBase'\n\t) as SiteData | undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst currentTemplate = select( STORE_NAME )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} )\n\t\t\t\t?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\tif ( currentTemplate ) {\n\t\t\t\treturn currentTemplate.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n\nexport function getTemplateAutoDraftId(\n\tstate: State,\n\tstaticTemplateId: string\n) {\n\treturn state.templateAutoDraftId[ staticTemplateId ];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,MAAM,CAAEG,gBAAW,CAAC,CAC1C2C,gBAAgB,CAAE,UAAU,EAAE,aAAa,EAAE;MAC7CC,QAAQ,EAAE,CAAC;IACZ,CAAE,CAAC,EACDC,IAAI,CAAE,CAAE;MAAET;IAAK,CAAC,KAAMA,IAAI,KAAKa,mBAAoB,CAAC;IACvD,IAAKE,eAAe,EAAG;MACtB,OAAOA,eAAe,CAACtC,EAAE;IAC1B;EACD;EACA;EACA,IAAIuC,WAAW;EACf;EACA;EACA;EACA;EACA,IAAKN,YAAY,CAACV,IAAI,EAAG;IACxBgB,WAAW,GACVrD,QAAQ,KAAK,MAAM,GAChB,GAAIA,QAAQ,IAAM+C,YAAY,CAACV,IAAI,EAAG,GACtC,UAAWrC,QAAQ,IAAM+C,YAAY,CAACV,IAAI,EAAG;EAClD,CAAC,MAAM;IACNgB,WAAW,GAAGrD,QAAQ,KAAK,MAAM,GAAG,MAAM,GAAG,UAAWA,QAAQ,EAAG;EACpE;EACA,OAAOF,MAAM,CAAEG,gBAAW,CAAC,CAACmC,oBAAoB,CAAE;IACjDC,IAAI,EAAEgB;EACP,CAAE,CAAC;AACJ,CACD,CAAC;AAEM,SAASC,sBAAsBA,CACrC/D,KAAY,EACZgE,gBAAwB,EACvB;EACD,OAAOhE,KAAK,CAACiE,mBAAmB,CAAED,gBAAgB,CAAE;AACrD","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/private-selectors.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t(\n\t\t\tstate: State,\n\t\t\tkind: string,\n\t\t\tname: string,\n\t\t\tids: string | string[]\n\t\t) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param id Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordPermissions' );\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase'\n\t\t\t) as SiteData | undefined;\n\t\t\t// Still resolving getEntityRecord.\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\t// Still resolving getDefaultTemplateId.\n\t\t\tif ( ! frontPageTemplateId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\t// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,\n\t\t\t// it doesn't seem to invalidate this cache, I'm not sure why.\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetEntityRecord( state, 'root', '__unstableBase' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t'root',\n\t\t'__unstableBase'\n\t) as SiteData | undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst userTemplates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{ per_page: -1 }\n\t\t\t);\n\t\t\tif ( ! userTemplates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst userTemplateWithSlug = userTemplates.find(\n\t\t\t\t( { slug } ) => slug === currentTemplateSlug\n\t\t\t);\n\n\t\t\tif ( userTemplateWithSlug ) {\n\t\t\t\treturn userTemplateWithSlug.id;\n\t\t\t}\n\n\t\t\tconst registeredTemplates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_registered_template',\n\t\t\t\t{ per_page: -1 }\n\t\t\t);\n\n\t\t\tif ( ! registeredTemplates ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst registeredTemplateWithSlug = registeredTemplates.find(\n\t\t\t\t( { slug } ) => slug === currentTemplateSlug\n\t\t\t);\n\n\t\t\tif ( registeredTemplateWithSlug ) {\n\t\t\t\treturn registeredTemplateWithSlug.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n\nexport function getTemplateAutoDraftId(\n\tstate: State,\n\tstaticTemplateId: string\n) {\n\treturn state.templateAutoDraftId[ staticTemplateId ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuD;AAKvD,uBAAkE;AAClE,kBAA2B;AAC3B,yBAAuB;AACvB,oCAAiC;AAY1B,SAAS,eAAgB,OAAe;AAC9C,SAAO,MAAM;AACd;AAQO,SAAS,wBACf,OAC8B;AAC9B,SAAO,MAAM;AACd;AAEO,MAAM,kCAA8B;AAAA,EAC1C,CAAE,eACD;AAAA,IACC,CAAE,OAAO,aACR,OAAQ,sBAAW,EACjB,iBAAiB,EACjB;AAAA,MACA,CAAE,EAAE,UAAU,MACb,CAAE,aACA,MAAM,QAAS,SAAU,KAC1B,UAAU,SAAU,QAAS;AAAA,IAChC;AAAA,IACF,MAAM,CAAE,OAAQ,sBAAW,EAAE,iBAAiB,CAAE;AAAA,EACjD;AACF;AAKO,MAAM,kCAA8B;AAAA,EAAwB,CAAE,eACpE;AAAA,IACC,CACC,OACA,MACA,MACA,QACI;AACJ,YAAM,gBAAgB,MAAM,QAAS,GAAI,IAAI,MAAM,CAAE,GAAI;AACzD,aAAO,cAAc,IAAK,CAAE,QAAU;AAAA,QACrC,QAAQ,OAAQ,sBAAW,EAAE,QAAS,UAAU;AAAA,UAC/C;AAAA,UACA;AAAA,UACA;AAAA,QACD,CAAE;AAAA,QACF,QAAQ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,QAC1C;AAAA,QACA;AAAA,QACA,EAAE,UAAU,GAAG;AAAA,MAChB;AACA,UAAK,CAAE,eAAgB;AACtB;AAAA,MACD;AACA,YAAM,uBAAuB,cAAc;AAAA,QAC1C,CAAE,EAAE,KAAK,MAAO,SAAS;AAAA,MAC1B;AAEA,UAAK,sBAAuB;AAC3B,eAAO,qBAAqB;AAAA,MAC7B;AAEA,YAAM,sBAAsB,OAAQ,sBAAW,EAAE;AAAA,QAChD;AAAA,QACA;AAAA,QACA,EAAE,UAAU,GAAG;AAAA,MAChB;AAEA,UAAK,CAAE,qBAAsB;AAC5B;AAAA,MACD;AAEA,YAAM,6BAA6B,oBAAoB;AAAA,QACtD,CAAE,EAAE,KAAK,MAAO,SAAS;AAAA,MAC1B;AAEA,UAAK,4BAA6B;AACjC,eAAO,2BAA2B;AAAA,MACnC;AAAA,IACD;AAEA,QAAI;AAKJ,QAAK,aAAa,MAAO;AACxB,oBACC,aAAa,SACV,GAAI,QAAS,IAAK,aAAa,IAAK,KACpC,UAAW,QAAS,IAAK,aAAa,IAAK;AAAA,IAChD,OAAO;AACN,oBAAc,aAAa,SAAS,SAAS,UAAW,QAAS;AAAA,IAClE;AACA,WAAO,OAAQ,sBAAW,EAAE,qBAAsB;AAAA,MACjD,MAAM;AAAA,IACP,CAAE;AAAA,EACH;AACD;AAEO,SAAS,uBACf,OACA,kBACC;AACD,SAAO,MAAM,oBAAqB,gBAAiB;AACpD;",
|
|
6
|
+
"names": ["logEntityDeprecation"]
|
|
7
|
+
}
|
|
@@ -1,64 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var actions_exports = {};
|
|
20
|
+
__export(actions_exports, {
|
|
21
|
+
receiveItems: () => receiveItems,
|
|
22
|
+
receiveQueriedItems: () => receiveQueriedItems,
|
|
23
|
+
removeItems: () => removeItems
|
|
5
24
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.receiveQueriedItems = receiveQueriedItems;
|
|
8
|
-
exports.removeItems = removeItems;
|
|
9
|
-
/**
|
|
10
|
-
* Returns an action object used in signalling that items have been received.
|
|
11
|
-
*
|
|
12
|
-
* @param {Array} items Items received.
|
|
13
|
-
* @param {?Object} edits Optional edits to reset.
|
|
14
|
-
* @param {?Object} meta Meta information about pagination.
|
|
15
|
-
*
|
|
16
|
-
* @return {Object} Action object.
|
|
17
|
-
*/
|
|
25
|
+
module.exports = __toCommonJS(actions_exports);
|
|
18
26
|
function receiveItems(items, edits, meta) {
|
|
19
27
|
return {
|
|
20
|
-
type:
|
|
28
|
+
type: "RECEIVE_ITEMS",
|
|
21
29
|
items: Array.isArray(items) ? items : [items],
|
|
22
30
|
persistedEdits: edits,
|
|
23
31
|
meta
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns an action object used in signalling that entity records have been
|
|
29
|
-
* deleted and they need to be removed from entities state.
|
|
30
|
-
*
|
|
31
|
-
* @param {string} kind Kind of the removed entities.
|
|
32
|
-
* @param {string} name Name of the removed entities.
|
|
33
|
-
* @param {Array|number|string} records Record IDs of the removed entities.
|
|
34
|
-
* @param {boolean} invalidateCache Controls whether we want to invalidate the cache.
|
|
35
|
-
* @return {Object} Action object.
|
|
36
|
-
*/
|
|
37
34
|
function removeItems(kind, name, records, invalidateCache = false) {
|
|
38
35
|
return {
|
|
39
|
-
type:
|
|
36
|
+
type: "REMOVE_ITEMS",
|
|
40
37
|
itemIds: Array.isArray(records) ? records : [records],
|
|
41
38
|
kind,
|
|
42
39
|
name,
|
|
43
40
|
invalidateCache
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Returns an action object used in signalling that queried data has been
|
|
49
|
-
* received.
|
|
50
|
-
*
|
|
51
|
-
* @param {Array} items Queried items received.
|
|
52
|
-
* @param {?Object} query Optional query object.
|
|
53
|
-
* @param {?Object} edits Optional edits to reset.
|
|
54
|
-
* @param {?Object} meta Meta information about pagination.
|
|
55
|
-
*
|
|
56
|
-
* @return {Object} Action object.
|
|
57
|
-
*/
|
|
58
43
|
function receiveQueriedItems(items, query = {}, edits, meta) {
|
|
59
44
|
return {
|
|
60
45
|
...receiveItems(items, edits, meta),
|
|
61
46
|
query
|
|
62
47
|
};
|
|
63
48
|
}
|
|
64
|
-
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
receiveItems,
|
|
52
|
+
receiveQueriedItems,
|
|
53
|
+
removeItems
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/queried-data/actions.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns an action object used in signalling that items have been received.\n *\n * @param {Array} items Items received.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveItems( items, edits, meta ) {\n\treturn {\n\t\ttype: 'RECEIVE_ITEMS',\n\t\titems: Array.isArray( items ) ? items : [ items ],\n\t\tpersistedEdits: edits,\n\t\tmeta,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been\n * deleted and they need to be removed from entities state.\n *\n * @param {string} kind Kind of the removed entities.\n * @param {string} name Name of the removed entities.\n * @param {Array|number|string} records Record IDs of the removed entities.\n * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.\n * @return {Object} Action object.\n */\nexport function removeItems( kind, name, records, invalidateCache = false ) {\n\treturn {\n\t\ttype: 'REMOVE_ITEMS',\n\t\titemIds: Array.isArray( records ) ? records : [ records ],\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that queried data has been\n * received.\n *\n * @param {Array} items Queried items received.\n * @param {?Object} query Optional query object.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveQueriedItems( items, query = {}, edits, meta ) {\n\treturn {\n\t\t...receiveItems( items, edits, meta ),\n\t\tquery,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,aAAc,OAAO,OAAO,MAAO;AAClD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO,MAAM,QAAS,KAAM,IAAI,QAAQ,CAAE,KAAM;AAAA,IAChD,gBAAgB;AAAA,IAChB;AAAA,EACD;AACD;AAYO,SAAS,YAAa,MAAM,MAAM,SAAS,kBAAkB,OAAQ;AAC3E,SAAO;AAAA,IACN,MAAM;AAAA,IACN,SAAS,MAAM,QAAS,OAAQ,IAAI,UAAU,CAAE,OAAQ;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAaO,SAAS,oBAAqB,OAAO,QAAQ,CAAC,GAAG,OAAO,MAAO;AACrE,SAAO;AAAA,IACN,GAAG,aAAc,OAAO,OAAO,IAAK;AAAA,IACpC;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|