@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
package/build/reducer.js
CHANGED
|
@@ -1,143 +1,111 @@
|
|
|
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 reducer_exports = {};
|
|
30
|
+
__export(reducer_exports, {
|
|
31
|
+
autosaves: () => autosaves,
|
|
32
|
+
blockPatternCategories: () => blockPatternCategories,
|
|
33
|
+
blockPatterns: () => blockPatterns,
|
|
34
|
+
currentGlobalStylesId: () => currentGlobalStylesId,
|
|
35
|
+
currentTheme: () => currentTheme,
|
|
36
|
+
currentUser: () => currentUser,
|
|
37
|
+
default: () => reducer_default,
|
|
38
|
+
defaultTemplates: () => defaultTemplates,
|
|
39
|
+
editsReference: () => editsReference,
|
|
40
|
+
embedPreviews: () => embedPreviews,
|
|
41
|
+
entities: () => entities,
|
|
42
|
+
entitiesConfig: () => entitiesConfig,
|
|
43
|
+
navigationFallbackId: () => navigationFallbackId,
|
|
44
|
+
registeredPostMeta: () => registeredPostMeta,
|
|
45
|
+
templateAutoDraftId: () => templateAutoDraftId,
|
|
46
|
+
themeBaseGlobalStyles: () => themeBaseGlobalStyles,
|
|
47
|
+
themeGlobalStyleRevisions: () => themeGlobalStyleRevisions,
|
|
48
|
+
themeGlobalStyleVariations: () => themeGlobalStyleVariations,
|
|
49
|
+
undoManager: () => undoManager,
|
|
50
|
+
userPatternCategories: () => userPatternCategories,
|
|
51
|
+
userPermissions: () => userPermissions,
|
|
52
|
+
users: () => users
|
|
6
53
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.embedPreviews = embedPreviews;
|
|
17
|
-
exports.entities = void 0;
|
|
18
|
-
exports.entitiesConfig = entitiesConfig;
|
|
19
|
-
exports.navigationFallbackId = navigationFallbackId;
|
|
20
|
-
exports.registeredPostMeta = registeredPostMeta;
|
|
21
|
-
exports.templateAutoDraftId = templateAutoDraftId;
|
|
22
|
-
exports.themeBaseGlobalStyles = themeBaseGlobalStyles;
|
|
23
|
-
exports.themeGlobalStyleRevisions = themeGlobalStyleRevisions;
|
|
24
|
-
exports.themeGlobalStyleVariations = themeGlobalStyleVariations;
|
|
25
|
-
exports.undoManager = undoManager;
|
|
26
|
-
exports.userPatternCategories = userPatternCategories;
|
|
27
|
-
exports.userPermissions = userPermissions;
|
|
28
|
-
exports.users = users;
|
|
29
|
-
var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
|
|
30
|
-
var _compose = require("@wordpress/compose");
|
|
31
|
-
var _data = require("@wordpress/data");
|
|
32
|
-
var _undoManager = require("@wordpress/undo-manager");
|
|
33
|
-
var _utils = require("./utils");
|
|
34
|
-
var _queriedData = require("./queried-data");
|
|
35
|
-
var _entities = require("./entities");
|
|
36
|
-
/**
|
|
37
|
-
* External dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* WordPress dependencies
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Internal dependencies
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/** @typedef {import('./types').AnyFunction} AnyFunction */
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Reducer managing authors state. Keyed by id.
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} state Current state.
|
|
54
|
-
* @param {Object} action Dispatched action.
|
|
55
|
-
*
|
|
56
|
-
* @return {Object} Updated state.
|
|
57
|
-
*/
|
|
58
|
-
function users(state = {
|
|
59
|
-
byId: {},
|
|
60
|
-
queries: {}
|
|
61
|
-
}, action) {
|
|
54
|
+
module.exports = __toCommonJS(reducer_exports);
|
|
55
|
+
var import_es6 = __toESM(require("fast-deep-equal/es6"));
|
|
56
|
+
var import_compose = require("@wordpress/compose");
|
|
57
|
+
var import_data = require("@wordpress/data");
|
|
58
|
+
var import_undo_manager = require("@wordpress/undo-manager");
|
|
59
|
+
var import_utils = require("./utils");
|
|
60
|
+
var import_queried_data = require("./queried-data");
|
|
61
|
+
var import_entities = require("./entities");
|
|
62
|
+
function users(state = { byId: {}, queries: {} }, action) {
|
|
62
63
|
switch (action.type) {
|
|
63
|
-
case
|
|
64
|
+
case "RECEIVE_USER_QUERY":
|
|
64
65
|
return {
|
|
65
66
|
byId: {
|
|
66
67
|
...state.byId,
|
|
67
68
|
// Key users by their ID.
|
|
68
|
-
...action.users.reduce(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
...action.users.reduce(
|
|
70
|
+
(newUsers, user) => ({
|
|
71
|
+
...newUsers,
|
|
72
|
+
[user.id]: user
|
|
73
|
+
}),
|
|
74
|
+
{}
|
|
75
|
+
)
|
|
72
76
|
},
|
|
73
77
|
queries: {
|
|
74
78
|
...state.queries,
|
|
75
|
-
[action.queryID]: action.users.map(user => user.id)
|
|
79
|
+
[action.queryID]: action.users.map((user) => user.id)
|
|
76
80
|
}
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
return state;
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Reducer managing current user state.
|
|
84
|
-
*
|
|
85
|
-
* @param {Object} state Current state.
|
|
86
|
-
* @param {Object} action Dispatched action.
|
|
87
|
-
*
|
|
88
|
-
* @return {Object} Updated state.
|
|
89
|
-
*/
|
|
90
85
|
function currentUser(state = {}, action) {
|
|
91
86
|
switch (action.type) {
|
|
92
|
-
case
|
|
87
|
+
case "RECEIVE_CURRENT_USER":
|
|
93
88
|
return action.currentUser;
|
|
94
89
|
}
|
|
95
90
|
return state;
|
|
96
91
|
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Reducer managing the current theme.
|
|
100
|
-
*
|
|
101
|
-
* @param {string|undefined} state Current state.
|
|
102
|
-
* @param {Object} action Dispatched action.
|
|
103
|
-
*
|
|
104
|
-
* @return {string|undefined} Updated state.
|
|
105
|
-
*/
|
|
106
|
-
function currentTheme(state = undefined, action) {
|
|
92
|
+
function currentTheme(state = void 0, action) {
|
|
107
93
|
switch (action.type) {
|
|
108
|
-
case
|
|
94
|
+
case "RECEIVE_CURRENT_THEME":
|
|
109
95
|
return action.currentTheme.stylesheet;
|
|
110
96
|
}
|
|
111
97
|
return state;
|
|
112
98
|
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Reducer managing the current global styles id.
|
|
116
|
-
*
|
|
117
|
-
* @param {string|undefined} state Current state.
|
|
118
|
-
* @param {Object} action Dispatched action.
|
|
119
|
-
*
|
|
120
|
-
* @return {string|undefined} Updated state.
|
|
121
|
-
*/
|
|
122
|
-
function currentGlobalStylesId(state = undefined, action) {
|
|
99
|
+
function currentGlobalStylesId(state = void 0, action) {
|
|
123
100
|
switch (action.type) {
|
|
124
|
-
case
|
|
101
|
+
case "RECEIVE_CURRENT_GLOBAL_STYLES_ID":
|
|
125
102
|
return action.id;
|
|
126
103
|
}
|
|
127
104
|
return state;
|
|
128
105
|
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Reducer managing the theme base global styles.
|
|
132
|
-
*
|
|
133
|
-
* @param {Record<string, object>} state Current state.
|
|
134
|
-
* @param {Object} action Dispatched action.
|
|
135
|
-
*
|
|
136
|
-
* @return {Record<string, object>} Updated state.
|
|
137
|
-
*/
|
|
138
106
|
function themeBaseGlobalStyles(state = {}, action) {
|
|
139
107
|
switch (action.type) {
|
|
140
|
-
case
|
|
108
|
+
case "RECEIVE_THEME_GLOBAL_STYLES":
|
|
141
109
|
return {
|
|
142
110
|
...state,
|
|
143
111
|
[action.stylesheet]: action.globalStyles
|
|
@@ -145,18 +113,9 @@ function themeBaseGlobalStyles(state = {}, action) {
|
|
|
145
113
|
}
|
|
146
114
|
return state;
|
|
147
115
|
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Reducer managing the theme global styles variations.
|
|
151
|
-
*
|
|
152
|
-
* @param {Record<string, object>} state Current state.
|
|
153
|
-
* @param {Object} action Dispatched action.
|
|
154
|
-
*
|
|
155
|
-
* @return {Record<string, object>} Updated state.
|
|
156
|
-
*/
|
|
157
116
|
function themeGlobalStyleVariations(state = {}, action) {
|
|
158
117
|
switch (action.type) {
|
|
159
|
-
case
|
|
118
|
+
case "RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS":
|
|
160
119
|
return {
|
|
161
120
|
...state,
|
|
162
121
|
[action.stylesheet]: action.variations
|
|
@@ -164,241 +123,202 @@ function themeGlobalStyleVariations(state = {}, action) {
|
|
|
164
123
|
}
|
|
165
124
|
return state;
|
|
166
125
|
}
|
|
167
|
-
const withMultiEntityRecordEdits = reducer => (state, action) => {
|
|
168
|
-
if (action.type ===
|
|
169
|
-
const {
|
|
170
|
-
record
|
|
171
|
-
} = action;
|
|
126
|
+
const withMultiEntityRecordEdits = (reducer) => (state, action) => {
|
|
127
|
+
if (action.type === "UNDO" || action.type === "REDO") {
|
|
128
|
+
const { record } = action;
|
|
172
129
|
let newState = state;
|
|
173
|
-
record.forEach(({
|
|
174
|
-
id: {
|
|
175
|
-
kind,
|
|
176
|
-
name,
|
|
177
|
-
recordId
|
|
178
|
-
},
|
|
179
|
-
changes
|
|
180
|
-
}) => {
|
|
130
|
+
record.forEach(({ id: { kind, name, recordId }, changes }) => {
|
|
181
131
|
newState = reducer(newState, {
|
|
182
|
-
type:
|
|
132
|
+
type: "EDIT_ENTITY_RECORD",
|
|
183
133
|
kind,
|
|
184
134
|
name,
|
|
185
135
|
recordId,
|
|
186
|
-
edits: Object.entries(changes).reduce(
|
|
187
|
-
acc[key
|
|
188
|
-
|
|
189
|
-
|
|
136
|
+
edits: Object.entries(changes).reduce(
|
|
137
|
+
(acc, [key, value]) => {
|
|
138
|
+
acc[key] = action.type === "UNDO" ? value.from : value.to;
|
|
139
|
+
return acc;
|
|
140
|
+
},
|
|
141
|
+
{}
|
|
142
|
+
)
|
|
190
143
|
});
|
|
191
144
|
});
|
|
192
145
|
return newState;
|
|
193
146
|
}
|
|
194
147
|
return reducer(state, action);
|
|
195
148
|
};
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Higher Order Reducer for a given entity config. It supports:
|
|
199
|
-
*
|
|
200
|
-
* - Fetching
|
|
201
|
-
* - Editing
|
|
202
|
-
* - Saving
|
|
203
|
-
*
|
|
204
|
-
* @param {Object} entityConfig Entity config.
|
|
205
|
-
*
|
|
206
|
-
* @return {AnyFunction} Reducer.
|
|
207
|
-
*/
|
|
208
149
|
function entity(entityConfig) {
|
|
209
|
-
return (0,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
for (const record of action.items) {
|
|
233
|
-
const recordId = record?.[action.key];
|
|
234
|
-
const edits = nextState[recordId];
|
|
235
|
-
if (!edits) {
|
|
236
|
-
continue;
|
|
150
|
+
return (0, import_compose.compose)([
|
|
151
|
+
withMultiEntityRecordEdits,
|
|
152
|
+
// Limit to matching action type so we don't attempt to replace action on
|
|
153
|
+
// an unhandled action.
|
|
154
|
+
(0, import_utils.ifMatchingAction)(
|
|
155
|
+
(action) => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind
|
|
156
|
+
),
|
|
157
|
+
// Inject the entity config into the action.
|
|
158
|
+
(0, import_utils.replaceAction)((action) => {
|
|
159
|
+
return {
|
|
160
|
+
key: entityConfig.key || import_entities.DEFAULT_ENTITY_KEY,
|
|
161
|
+
...action
|
|
162
|
+
};
|
|
163
|
+
})
|
|
164
|
+
])(
|
|
165
|
+
(0, import_data.combineReducers)({
|
|
166
|
+
queriedData: import_queried_data.reducer,
|
|
167
|
+
edits: (state = {}, action) => {
|
|
168
|
+
switch (action.type) {
|
|
169
|
+
case "RECEIVE_ITEMS":
|
|
170
|
+
const context = action?.query?.context ?? "default";
|
|
171
|
+
if (context !== "default") {
|
|
172
|
+
return state;
|
|
237
173
|
}
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
174
|
+
const nextState = { ...state };
|
|
175
|
+
for (const record of action.items) {
|
|
176
|
+
const recordId = record?.[action.key];
|
|
177
|
+
const edits = nextState[recordId];
|
|
178
|
+
if (!edits) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const nextEdits2 = Object.keys(edits).reduce(
|
|
182
|
+
(acc, key) => {
|
|
183
|
+
if (
|
|
184
|
+
// Edits are the "raw" attribute values, but records may have
|
|
185
|
+
// objects with more properties, so we use `get` here for the
|
|
186
|
+
// comparison.
|
|
187
|
+
!(0, import_es6.default)(
|
|
188
|
+
edits[key],
|
|
189
|
+
record[key]?.raw ?? record[key]
|
|
190
|
+
) && // Sometimes the server alters the sent value which means
|
|
191
|
+
// we need to also remove the edits before the api request.
|
|
192
|
+
(!action.persistedEdits || !(0, import_es6.default)(
|
|
193
|
+
edits[key],
|
|
194
|
+
action.persistedEdits[key]
|
|
195
|
+
))
|
|
196
|
+
) {
|
|
197
|
+
acc[key] = edits[key];
|
|
198
|
+
}
|
|
199
|
+
return acc;
|
|
200
|
+
},
|
|
201
|
+
{}
|
|
202
|
+
);
|
|
203
|
+
if (Object.keys(nextEdits2).length) {
|
|
204
|
+
nextState[recordId] = nextEdits2;
|
|
205
|
+
} else {
|
|
206
|
+
delete nextState[recordId];
|
|
251
207
|
}
|
|
252
|
-
return acc;
|
|
253
|
-
}, {});
|
|
254
|
-
if (Object.keys(nextEdits).length) {
|
|
255
|
-
nextState[recordId] = nextEdits;
|
|
256
|
-
} else {
|
|
257
|
-
delete nextState[recordId];
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return nextState;
|
|
261
|
-
case 'EDIT_ENTITY_RECORD':
|
|
262
|
-
const nextEdits = {
|
|
263
|
-
...state[action.recordId],
|
|
264
|
-
...action.edits
|
|
265
|
-
};
|
|
266
|
-
Object.keys(nextEdits).forEach(key => {
|
|
267
|
-
// Delete cleared edits so that the properties
|
|
268
|
-
// are not considered dirty.
|
|
269
|
-
if (nextEdits[key] === undefined) {
|
|
270
|
-
delete nextEdits[key];
|
|
271
208
|
}
|
|
209
|
+
return nextState;
|
|
210
|
+
case "EDIT_ENTITY_RECORD":
|
|
211
|
+
const nextEdits = {
|
|
212
|
+
...state[action.recordId],
|
|
213
|
+
...action.edits
|
|
214
|
+
};
|
|
215
|
+
Object.keys(nextEdits).forEach((key) => {
|
|
216
|
+
if (nextEdits[key] === void 0) {
|
|
217
|
+
delete nextEdits[key];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
...state,
|
|
222
|
+
[action.recordId]: nextEdits
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return state;
|
|
226
|
+
},
|
|
227
|
+
saving: (state = {}, action) => {
|
|
228
|
+
switch (action.type) {
|
|
229
|
+
case "SAVE_ENTITY_RECORD_START":
|
|
230
|
+
case "SAVE_ENTITY_RECORD_FINISH":
|
|
231
|
+
return {
|
|
232
|
+
...state,
|
|
233
|
+
[action.recordId]: {
|
|
234
|
+
pending: action.type === "SAVE_ENTITY_RECORD_START",
|
|
235
|
+
error: action.error,
|
|
236
|
+
isAutosave: action.isAutosave
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return state;
|
|
241
|
+
},
|
|
242
|
+
deleting: (state = {}, action) => {
|
|
243
|
+
switch (action.type) {
|
|
244
|
+
case "DELETE_ENTITY_RECORD_START":
|
|
245
|
+
case "DELETE_ENTITY_RECORD_FINISH":
|
|
246
|
+
return {
|
|
247
|
+
...state,
|
|
248
|
+
[action.recordId]: {
|
|
249
|
+
pending: action.type === "DELETE_ENTITY_RECORD_START",
|
|
250
|
+
error: action.error
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return state;
|
|
255
|
+
},
|
|
256
|
+
revisions: (state = {}, action) => {
|
|
257
|
+
if (action.type === "RECEIVE_ITEM_REVISIONS") {
|
|
258
|
+
const recordKey = action.recordKey;
|
|
259
|
+
delete action.recordKey;
|
|
260
|
+
const newState = (0, import_queried_data.reducer)(state[recordKey], {
|
|
261
|
+
...action,
|
|
262
|
+
type: "RECEIVE_ITEMS"
|
|
272
263
|
});
|
|
273
264
|
return {
|
|
274
265
|
...state,
|
|
275
|
-
[
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
return state;
|
|
279
|
-
},
|
|
280
|
-
saving: (state = {}, action) => {
|
|
281
|
-
switch (action.type) {
|
|
282
|
-
case 'SAVE_ENTITY_RECORD_START':
|
|
283
|
-
case 'SAVE_ENTITY_RECORD_FINISH':
|
|
284
|
-
return {
|
|
285
|
-
...state,
|
|
286
|
-
[action.recordId]: {
|
|
287
|
-
pending: action.type === 'SAVE_ENTITY_RECORD_START',
|
|
288
|
-
error: action.error,
|
|
289
|
-
isAutosave: action.isAutosave
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
return state;
|
|
294
|
-
},
|
|
295
|
-
deleting: (state = {}, action) => {
|
|
296
|
-
switch (action.type) {
|
|
297
|
-
case 'DELETE_ENTITY_RECORD_START':
|
|
298
|
-
case 'DELETE_ENTITY_RECORD_FINISH':
|
|
299
|
-
return {
|
|
300
|
-
...state,
|
|
301
|
-
[action.recordId]: {
|
|
302
|
-
pending: action.type === 'DELETE_ENTITY_RECORD_START',
|
|
303
|
-
error: action.error
|
|
304
|
-
}
|
|
266
|
+
[recordKey]: newState
|
|
305
267
|
};
|
|
268
|
+
}
|
|
269
|
+
if (action.type === "REMOVE_ITEMS") {
|
|
270
|
+
return Object.fromEntries(
|
|
271
|
+
Object.entries(state).filter(
|
|
272
|
+
([id]) => !action.itemIds.some((itemId) => {
|
|
273
|
+
if (Number.isInteger(itemId)) {
|
|
274
|
+
return itemId === +id;
|
|
275
|
+
}
|
|
276
|
+
return itemId === id;
|
|
277
|
+
})
|
|
278
|
+
)
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
return state;
|
|
306
282
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
revisions: (state = {}, action) => {
|
|
310
|
-
// Use the same queriedDataReducer shape for revisions.
|
|
311
|
-
if (action.type === 'RECEIVE_ITEM_REVISIONS') {
|
|
312
|
-
const recordKey = action.recordKey;
|
|
313
|
-
delete action.recordKey;
|
|
314
|
-
const newState = (0, _queriedData.reducer)(state[recordKey], {
|
|
315
|
-
...action,
|
|
316
|
-
type: 'RECEIVE_ITEMS'
|
|
317
|
-
});
|
|
318
|
-
return {
|
|
319
|
-
...state,
|
|
320
|
-
[recordKey]: newState
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
if (action.type === 'REMOVE_ITEMS') {
|
|
324
|
-
return Object.fromEntries(Object.entries(state).filter(([id]) => !action.itemIds.some(itemId => {
|
|
325
|
-
if (Number.isInteger(itemId)) {
|
|
326
|
-
return itemId === +id;
|
|
327
|
-
}
|
|
328
|
-
return itemId === id;
|
|
329
|
-
})));
|
|
330
|
-
}
|
|
331
|
-
return state;
|
|
332
|
-
}
|
|
333
|
-
}));
|
|
283
|
+
})
|
|
284
|
+
);
|
|
334
285
|
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Reducer keeping track of the registered entities.
|
|
338
|
-
*
|
|
339
|
-
* @param {Object} state Current state.
|
|
340
|
-
* @param {Object} action Dispatched action.
|
|
341
|
-
*
|
|
342
|
-
* @return {Object} Updated state.
|
|
343
|
-
*/
|
|
344
|
-
function entitiesConfig(state = _entities.rootEntitiesConfig, action) {
|
|
286
|
+
function entitiesConfig(state = import_entities.rootEntitiesConfig, action) {
|
|
345
287
|
switch (action.type) {
|
|
346
|
-
case
|
|
288
|
+
case "ADD_ENTITIES":
|
|
347
289
|
return [...state, ...action.entities];
|
|
348
290
|
}
|
|
349
291
|
return state;
|
|
350
292
|
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Reducer keeping track of the registered entities config and data.
|
|
354
|
-
*
|
|
355
|
-
* @param {Object} state Current state.
|
|
356
|
-
* @param {Object} action Dispatched action.
|
|
357
|
-
*
|
|
358
|
-
* @return {Object} Updated state.
|
|
359
|
-
*/
|
|
360
293
|
const entities = (state = {}, action) => {
|
|
361
294
|
const newConfig = entitiesConfig(state.config, action);
|
|
362
|
-
|
|
363
|
-
// Generates a reducer for the entities nested by `kind` and `name`.
|
|
364
|
-
// A config array with shape:
|
|
365
|
-
// ```
|
|
366
|
-
// [
|
|
367
|
-
// { kind: 'taxonomy', name: 'category' },
|
|
368
|
-
// { kind: 'taxonomy', name: 'post_tag' },
|
|
369
|
-
// { kind: 'postType', name: 'post' },
|
|
370
|
-
// { kind: 'postType', name: 'page' },
|
|
371
|
-
// ]
|
|
372
|
-
// ```
|
|
373
|
-
// generates a reducer for state tree with shape:
|
|
374
|
-
// ```
|
|
375
|
-
// {
|
|
376
|
-
// taxonomy: {
|
|
377
|
-
// category,
|
|
378
|
-
// post_tag,
|
|
379
|
-
// },
|
|
380
|
-
// postType: {
|
|
381
|
-
// post,
|
|
382
|
-
// page,
|
|
383
|
-
// },
|
|
384
|
-
// }
|
|
385
|
-
// ```
|
|
386
295
|
let entitiesDataReducer = state.reducer;
|
|
387
296
|
if (!entitiesDataReducer || newConfig !== state.config) {
|
|
388
297
|
const entitiesByKind = newConfig.reduce((acc, record) => {
|
|
389
|
-
const {
|
|
390
|
-
kind
|
|
391
|
-
} = record;
|
|
298
|
+
const { kind } = record;
|
|
392
299
|
if (!acc[kind]) {
|
|
393
300
|
acc[kind] = [];
|
|
394
301
|
}
|
|
395
302
|
acc[kind].push(record);
|
|
396
303
|
return acc;
|
|
397
304
|
}, {});
|
|
398
|
-
entitiesDataReducer = (0,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
305
|
+
entitiesDataReducer = (0, import_data.combineReducers)(
|
|
306
|
+
Object.fromEntries(
|
|
307
|
+
Object.entries(entitiesByKind).map(
|
|
308
|
+
([kind, subEntities]) => {
|
|
309
|
+
const kindReducer = (0, import_data.combineReducers)(
|
|
310
|
+
Object.fromEntries(
|
|
311
|
+
subEntities.map((entityConfig) => [
|
|
312
|
+
entityConfig.name,
|
|
313
|
+
entity(entityConfig)
|
|
314
|
+
])
|
|
315
|
+
)
|
|
316
|
+
);
|
|
317
|
+
return [kind, kindReducer];
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
)
|
|
321
|
+
);
|
|
402
322
|
}
|
|
403
323
|
const newData = entitiesDataReducer(state.records, action);
|
|
404
324
|
if (newData === state.records && newConfig === state.config && entitiesDataReducer === state.reducer) {
|
|
@@ -410,39 +330,22 @@ const entities = (state = {}, action) => {
|
|
|
410
330
|
config: newConfig
|
|
411
331
|
};
|
|
412
332
|
};
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* @type {UndoManager}
|
|
416
|
-
*/
|
|
417
|
-
exports.entities = entities;
|
|
418
|
-
function undoManager(state = (0, _undoManager.createUndoManager)()) {
|
|
333
|
+
function undoManager(state = (0, import_undo_manager.createUndoManager)()) {
|
|
419
334
|
return state;
|
|
420
335
|
}
|
|
421
336
|
function editsReference(state = {}, action) {
|
|
422
337
|
switch (action.type) {
|
|
423
|
-
case
|
|
424
|
-
case
|
|
425
|
-
case
|
|
338
|
+
case "EDIT_ENTITY_RECORD":
|
|
339
|
+
case "UNDO":
|
|
340
|
+
case "REDO":
|
|
426
341
|
return {};
|
|
427
342
|
}
|
|
428
343
|
return state;
|
|
429
344
|
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Reducer managing embed preview data.
|
|
433
|
-
*
|
|
434
|
-
* @param {Object} state Current state.
|
|
435
|
-
* @param {Object} action Dispatched action.
|
|
436
|
-
*
|
|
437
|
-
* @return {Object} Updated state.
|
|
438
|
-
*/
|
|
439
345
|
function embedPreviews(state = {}, action) {
|
|
440
346
|
switch (action.type) {
|
|
441
|
-
case
|
|
442
|
-
const {
|
|
443
|
-
url,
|
|
444
|
-
preview
|
|
445
|
-
} = action;
|
|
347
|
+
case "RECEIVE_EMBED_PREVIEW":
|
|
348
|
+
const { url, preview } = action;
|
|
446
349
|
return {
|
|
447
350
|
...state,
|
|
448
351
|
[url]: preview
|
|
@@ -450,24 +353,14 @@ function embedPreviews(state = {}, action) {
|
|
|
450
353
|
}
|
|
451
354
|
return state;
|
|
452
355
|
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* State which tracks whether the user can perform an action on a REST
|
|
456
|
-
* resource.
|
|
457
|
-
*
|
|
458
|
-
* @param {Object} state Current state.
|
|
459
|
-
* @param {Object} action Dispatched action.
|
|
460
|
-
*
|
|
461
|
-
* @return {Object} Updated state.
|
|
462
|
-
*/
|
|
463
356
|
function userPermissions(state = {}, action) {
|
|
464
357
|
switch (action.type) {
|
|
465
|
-
case
|
|
358
|
+
case "RECEIVE_USER_PERMISSION":
|
|
466
359
|
return {
|
|
467
360
|
...state,
|
|
468
361
|
[action.key]: action.isAllowed
|
|
469
362
|
};
|
|
470
|
-
case
|
|
363
|
+
case "RECEIVE_USER_PERMISSIONS":
|
|
471
364
|
return {
|
|
472
365
|
...state,
|
|
473
366
|
...action.permissions
|
|
@@ -475,22 +368,10 @@ function userPermissions(state = {}, action) {
|
|
|
475
368
|
}
|
|
476
369
|
return state;
|
|
477
370
|
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Reducer returning autosaves keyed by their parent's post id.
|
|
481
|
-
*
|
|
482
|
-
* @param {Object} state Current state.
|
|
483
|
-
* @param {Object} action Dispatched action.
|
|
484
|
-
*
|
|
485
|
-
* @return {Object} Updated state.
|
|
486
|
-
*/
|
|
487
371
|
function autosaves(state = {}, action) {
|
|
488
372
|
switch (action.type) {
|
|
489
|
-
case
|
|
490
|
-
const {
|
|
491
|
-
postId,
|
|
492
|
-
autosaves: autosavesData
|
|
493
|
-
} = action;
|
|
373
|
+
case "RECEIVE_AUTOSAVES":
|
|
374
|
+
const { postId, autosaves: autosavesData } = action;
|
|
494
375
|
return {
|
|
495
376
|
...state,
|
|
496
377
|
[postId]: autosavesData
|
|
@@ -500,44 +381,35 @@ function autosaves(state = {}, action) {
|
|
|
500
381
|
}
|
|
501
382
|
function blockPatterns(state = [], action) {
|
|
502
383
|
switch (action.type) {
|
|
503
|
-
case
|
|
384
|
+
case "RECEIVE_BLOCK_PATTERNS":
|
|
504
385
|
return action.patterns;
|
|
505
386
|
}
|
|
506
387
|
return state;
|
|
507
388
|
}
|
|
508
389
|
function blockPatternCategories(state = [], action) {
|
|
509
390
|
switch (action.type) {
|
|
510
|
-
case
|
|
391
|
+
case "RECEIVE_BLOCK_PATTERN_CATEGORIES":
|
|
511
392
|
return action.categories;
|
|
512
393
|
}
|
|
513
394
|
return state;
|
|
514
395
|
}
|
|
515
396
|
function userPatternCategories(state = [], action) {
|
|
516
397
|
switch (action.type) {
|
|
517
|
-
case
|
|
398
|
+
case "RECEIVE_USER_PATTERN_CATEGORIES":
|
|
518
399
|
return action.patternCategories;
|
|
519
400
|
}
|
|
520
401
|
return state;
|
|
521
402
|
}
|
|
522
403
|
function navigationFallbackId(state = null, action) {
|
|
523
404
|
switch (action.type) {
|
|
524
|
-
case
|
|
405
|
+
case "RECEIVE_NAVIGATION_FALLBACK_ID":
|
|
525
406
|
return action.fallbackId;
|
|
526
407
|
}
|
|
527
408
|
return state;
|
|
528
409
|
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Reducer managing the theme global styles revisions.
|
|
532
|
-
*
|
|
533
|
-
* @param {Record<string, object>} state Current state.
|
|
534
|
-
* @param {Object} action Dispatched action.
|
|
535
|
-
*
|
|
536
|
-
* @return {Record<string, object>} Updated state.
|
|
537
|
-
*/
|
|
538
410
|
function themeGlobalStyleRevisions(state = {}, action) {
|
|
539
411
|
switch (action.type) {
|
|
540
|
-
case
|
|
412
|
+
case "RECEIVE_THEME_GLOBAL_STYLE_REVISIONS":
|
|
541
413
|
return {
|
|
542
414
|
...state,
|
|
543
415
|
[action.currentId]: action.revisions
|
|
@@ -545,18 +417,9 @@ function themeGlobalStyleRevisions(state = {}, action) {
|
|
|
545
417
|
}
|
|
546
418
|
return state;
|
|
547
419
|
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Reducer managing the template lookup per query.
|
|
551
|
-
*
|
|
552
|
-
* @param {Record<string, string>} state Current state.
|
|
553
|
-
* @param {Object} action Dispatched action.
|
|
554
|
-
*
|
|
555
|
-
* @return {Record<string, string>} Updated state.
|
|
556
|
-
*/
|
|
557
420
|
function defaultTemplates(state = {}, action) {
|
|
558
421
|
switch (action.type) {
|
|
559
|
-
case
|
|
422
|
+
case "RECEIVE_DEFAULT_TEMPLATE":
|
|
560
423
|
return {
|
|
561
424
|
...state,
|
|
562
425
|
[JSON.stringify(action.query)]: action.templateId
|
|
@@ -564,18 +427,9 @@ function defaultTemplates(state = {}, action) {
|
|
|
564
427
|
}
|
|
565
428
|
return state;
|
|
566
429
|
}
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* Reducer returning an object of registered post meta.
|
|
570
|
-
*
|
|
571
|
-
* @param {Object} state Current state.
|
|
572
|
-
* @param {Object} action Dispatched action.
|
|
573
|
-
*
|
|
574
|
-
* @return {Object} Updated state.
|
|
575
|
-
*/
|
|
576
430
|
function registeredPostMeta(state = {}, action) {
|
|
577
431
|
switch (action.type) {
|
|
578
|
-
case
|
|
432
|
+
case "RECEIVE_REGISTERED_POST_META":
|
|
579
433
|
return {
|
|
580
434
|
...state,
|
|
581
435
|
[action.postType]: action.registeredPostMeta
|
|
@@ -584,12 +438,9 @@ function registeredPostMeta(state = {}, action) {
|
|
|
584
438
|
return state;
|
|
585
439
|
}
|
|
586
440
|
function templateAutoDraftId(state = {}, action) {
|
|
587
|
-
return action.type ===
|
|
588
|
-
...state,
|
|
589
|
-
[action.target]: action.id
|
|
590
|
-
} : state;
|
|
441
|
+
return action.type === "RECEIVE_TEMPLATE_AUTO_DRAFT_ID" ? { ...state, [action.target]: action.id } : state;
|
|
591
442
|
}
|
|
592
|
-
var
|
|
443
|
+
var reducer_default = (0, import_data.combineReducers)({
|
|
593
444
|
users,
|
|
594
445
|
currentTheme,
|
|
595
446
|
currentGlobalStylesId,
|
|
@@ -611,4 +462,28 @@ var _default = exports.default = (0, _data.combineReducers)({
|
|
|
611
462
|
registeredPostMeta,
|
|
612
463
|
templateAutoDraftId
|
|
613
464
|
});
|
|
614
|
-
|
|
465
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
466
|
+
0 && (module.exports = {
|
|
467
|
+
autosaves,
|
|
468
|
+
blockPatternCategories,
|
|
469
|
+
blockPatterns,
|
|
470
|
+
currentGlobalStylesId,
|
|
471
|
+
currentTheme,
|
|
472
|
+
currentUser,
|
|
473
|
+
defaultTemplates,
|
|
474
|
+
editsReference,
|
|
475
|
+
embedPreviews,
|
|
476
|
+
entities,
|
|
477
|
+
entitiesConfig,
|
|
478
|
+
navigationFallbackId,
|
|
479
|
+
registeredPostMeta,
|
|
480
|
+
templateAutoDraftId,
|
|
481
|
+
themeBaseGlobalStyles,
|
|
482
|
+
themeGlobalStyleRevisions,
|
|
483
|
+
themeGlobalStyleVariations,
|
|
484
|
+
undoManager,
|
|
485
|
+
userPatternCategories,
|
|
486
|
+
userPermissions,
|
|
487
|
+
users
|
|
488
|
+
});
|
|
489
|
+
//# sourceMappingURL=reducer.js.map
|