@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/entities.js
CHANGED
|
@@ -1,482 +1,370 @@
|
|
|
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 entities_exports = {};
|
|
30
|
+
__export(entities_exports, {
|
|
31
|
+
DEFAULT_ENTITY_KEY: () => DEFAULT_ENTITY_KEY,
|
|
32
|
+
additionalEntityConfigLoaders: () => additionalEntityConfigLoaders,
|
|
33
|
+
deprecatedEntities: () => deprecatedEntities,
|
|
34
|
+
getMethodName: () => getMethodName,
|
|
35
|
+
prePersistPostType: () => prePersistPostType,
|
|
36
|
+
rootEntitiesConfig: () => rootEntitiesConfig
|
|
6
37
|
});
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
fromCRDTDoc: doc => {
|
|
50
|
-
return doc.getMap('document').toJSON();
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
syncObjectType: 'root/base',
|
|
54
|
-
getSyncObjectId: () => 'index'
|
|
55
|
-
}, {
|
|
56
|
-
label: (0, _i18n.__)('Post Type'),
|
|
57
|
-
name: 'postType',
|
|
58
|
-
kind: 'root',
|
|
59
|
-
key: 'slug',
|
|
60
|
-
baseURL: '/wp/v2/types',
|
|
61
|
-
baseURLParams: {
|
|
62
|
-
context: 'edit'
|
|
63
|
-
},
|
|
64
|
-
plural: 'postTypes',
|
|
65
|
-
syncConfig: {
|
|
66
|
-
fetch: async id => {
|
|
67
|
-
return (0, _apiFetch.default)({
|
|
68
|
-
path: `/wp/v2/types/${id}?context=edit`
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
applyChangesToDoc: (doc, changes) => {
|
|
72
|
-
const document = doc.getMap('document');
|
|
73
|
-
Object.entries(changes).forEach(([key, value]) => {
|
|
74
|
-
if (document.get(key) !== value) {
|
|
75
|
-
document.set(key, value);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
38
|
+
module.exports = __toCommonJS(entities_exports);
|
|
39
|
+
var import_change_case = require("change-case");
|
|
40
|
+
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
41
|
+
var import_blocks = require("@wordpress/blocks");
|
|
42
|
+
var import_i18n = require("@wordpress/i18n");
|
|
43
|
+
var import_crdt = require("./utils/crdt");
|
|
44
|
+
const DEFAULT_ENTITY_KEY = "id";
|
|
45
|
+
const POST_RAW_ATTRIBUTES = ["title", "excerpt", "content"];
|
|
46
|
+
const blocksTransientEdits = {
|
|
47
|
+
blocks: {
|
|
48
|
+
read: (record) => (0, import_blocks.parse)(record.content?.raw ?? ""),
|
|
49
|
+
write: (record) => ({
|
|
50
|
+
content: (0, import_blocks.__unstableSerializeAndClean)(record.blocks)
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const rootEntitiesConfig = [
|
|
55
|
+
{
|
|
56
|
+
label: (0, import_i18n.__)("Base"),
|
|
57
|
+
kind: "root",
|
|
58
|
+
name: "__unstableBase",
|
|
59
|
+
baseURL: "/",
|
|
60
|
+
baseURLParams: {
|
|
61
|
+
// Please also change the preload path when changing this.
|
|
62
|
+
// @see lib/compat/wordpress-6.8/preload.php
|
|
63
|
+
_fields: [
|
|
64
|
+
"description",
|
|
65
|
+
"gmt_offset",
|
|
66
|
+
"home",
|
|
67
|
+
"name",
|
|
68
|
+
"site_icon",
|
|
69
|
+
"site_icon_url",
|
|
70
|
+
"site_logo",
|
|
71
|
+
"timezone_string",
|
|
72
|
+
"url",
|
|
73
|
+
"page_for_posts",
|
|
74
|
+
"page_on_front",
|
|
75
|
+
"show_on_front"
|
|
76
|
+
].join(",")
|
|
78
77
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
syncObjectType: 'root/postType',
|
|
84
|
-
getSyncObjectId: id => id
|
|
85
|
-
}, {
|
|
86
|
-
name: 'media',
|
|
87
|
-
kind: 'root',
|
|
88
|
-
baseURL: '/wp/v2/media',
|
|
89
|
-
baseURLParams: {
|
|
90
|
-
context: 'edit'
|
|
91
|
-
},
|
|
92
|
-
plural: 'mediaItems',
|
|
93
|
-
label: (0, _i18n.__)('Media'),
|
|
94
|
-
rawAttributes: ['caption', 'title', 'description'],
|
|
95
|
-
supportsPagination: true
|
|
96
|
-
}, {
|
|
97
|
-
name: 'taxonomy',
|
|
98
|
-
kind: 'root',
|
|
99
|
-
key: 'slug',
|
|
100
|
-
baseURL: '/wp/v2/taxonomies',
|
|
101
|
-
baseURLParams: {
|
|
102
|
-
context: 'edit'
|
|
78
|
+
// The entity doesn't support selecting multiple records.
|
|
79
|
+
// The property is maintained for backward compatibility.
|
|
80
|
+
plural: "__unstableBases"
|
|
103
81
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
82
|
+
{
|
|
83
|
+
label: (0, import_i18n.__)("Post Type"),
|
|
84
|
+
name: "postType",
|
|
85
|
+
kind: "root",
|
|
86
|
+
key: "slug",
|
|
87
|
+
baseURL: "/wp/v2/types",
|
|
88
|
+
baseURLParams: { context: "edit" },
|
|
89
|
+
plural: "postTypes"
|
|
112
90
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
91
|
+
{
|
|
92
|
+
name: "media",
|
|
93
|
+
kind: "root",
|
|
94
|
+
baseURL: "/wp/v2/media",
|
|
95
|
+
baseURLParams: { context: "edit" },
|
|
96
|
+
plural: "mediaItems",
|
|
97
|
+
label: (0, import_i18n.__)("Media"),
|
|
98
|
+
rawAttributes: ["caption", "title", "description"],
|
|
99
|
+
supportsPagination: true
|
|
116
100
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
101
|
+
{
|
|
102
|
+
name: "taxonomy",
|
|
103
|
+
kind: "root",
|
|
104
|
+
key: "slug",
|
|
105
|
+
baseURL: "/wp/v2/taxonomies",
|
|
106
|
+
baseURLParams: { context: "edit" },
|
|
107
|
+
plural: "taxonomies",
|
|
108
|
+
label: (0, import_i18n.__)("Taxonomy")
|
|
124
109
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
{
|
|
111
|
+
name: "sidebar",
|
|
112
|
+
kind: "root",
|
|
113
|
+
baseURL: "/wp/v2/sidebars",
|
|
114
|
+
baseURLParams: { context: "edit" },
|
|
115
|
+
plural: "sidebars",
|
|
116
|
+
transientEdits: { blocks: true },
|
|
117
|
+
label: (0, import_i18n.__)("Widget areas")
|
|
128
118
|
},
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
{
|
|
120
|
+
name: "widget",
|
|
121
|
+
kind: "root",
|
|
122
|
+
baseURL: "/wp/v2/widgets",
|
|
123
|
+
baseURLParams: { context: "edit" },
|
|
124
|
+
plural: "widgets",
|
|
125
|
+
transientEdits: { blocks: true },
|
|
126
|
+
label: (0, import_i18n.__)("Widgets")
|
|
136
127
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
getTitle: record => record?.name || record?.slug,
|
|
145
|
-
baseURLParams: {
|
|
146
|
-
context: 'edit'
|
|
128
|
+
{
|
|
129
|
+
name: "widgetType",
|
|
130
|
+
kind: "root",
|
|
131
|
+
baseURL: "/wp/v2/widget-types",
|
|
132
|
+
baseURLParams: { context: "edit" },
|
|
133
|
+
plural: "widgetTypes",
|
|
134
|
+
label: (0, import_i18n.__)("Widget types")
|
|
147
135
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
136
|
+
{
|
|
137
|
+
label: (0, import_i18n.__)("User"),
|
|
138
|
+
name: "user",
|
|
139
|
+
kind: "root",
|
|
140
|
+
baseURL: "/wp/v2/users",
|
|
141
|
+
getTitle: (record) => record?.name || record?.slug,
|
|
142
|
+
baseURLParams: { context: "edit" },
|
|
143
|
+
plural: "users",
|
|
144
|
+
supportsPagination: true
|
|
156
145
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
context: 'edit'
|
|
146
|
+
{
|
|
147
|
+
name: "comment",
|
|
148
|
+
kind: "root",
|
|
149
|
+
baseURL: "/wp/v2/comments",
|
|
150
|
+
baseURLParams: { context: "edit" },
|
|
151
|
+
plural: "comments",
|
|
152
|
+
label: (0, import_i18n.__)("Comment"),
|
|
153
|
+
supportsPagination: true
|
|
166
154
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
context: 'edit'
|
|
155
|
+
{
|
|
156
|
+
name: "menu",
|
|
157
|
+
kind: "root",
|
|
158
|
+
baseURL: "/wp/v2/menus",
|
|
159
|
+
baseURLParams: { context: "edit" },
|
|
160
|
+
plural: "menus",
|
|
161
|
+
label: (0, import_i18n.__)("Menu"),
|
|
162
|
+
supportsPagination: true
|
|
176
163
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
context: 'edit'
|
|
164
|
+
{
|
|
165
|
+
name: "menuItem",
|
|
166
|
+
kind: "root",
|
|
167
|
+
baseURL: "/wp/v2/menu-items",
|
|
168
|
+
baseURLParams: { context: "edit" },
|
|
169
|
+
plural: "menuItems",
|
|
170
|
+
label: (0, import_i18n.__)("Menu Item"),
|
|
171
|
+
rawAttributes: ["title"],
|
|
172
|
+
supportsPagination: true
|
|
187
173
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
baseURLParams: {
|
|
197
|
-
context: 'edit'
|
|
174
|
+
{
|
|
175
|
+
name: "menuLocation",
|
|
176
|
+
kind: "root",
|
|
177
|
+
baseURL: "/wp/v2/menu-locations",
|
|
178
|
+
baseURLParams: { context: "edit" },
|
|
179
|
+
plural: "menuLocations",
|
|
180
|
+
label: (0, import_i18n.__)("Menu Location"),
|
|
181
|
+
key: "name"
|
|
198
182
|
},
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
context: 'edit'
|
|
183
|
+
{
|
|
184
|
+
label: (0, import_i18n.__)("Global Styles"),
|
|
185
|
+
name: "globalStyles",
|
|
186
|
+
kind: "root",
|
|
187
|
+
baseURL: "/wp/v2/global-styles",
|
|
188
|
+
baseURLParams: { context: "edit" },
|
|
189
|
+
plural: "globalStylesVariations",
|
|
190
|
+
// Should be different from name.
|
|
191
|
+
getTitle: () => (0, import_i18n.__)("Custom Styles"),
|
|
192
|
+
getRevisionsUrl: (parentId, revisionId) => `/wp/v2/global-styles/${parentId}/revisions${revisionId ? "/" + revisionId : ""}`,
|
|
193
|
+
supportsPagination: true
|
|
211
194
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
context: 'edit'
|
|
195
|
+
{
|
|
196
|
+
label: (0, import_i18n.__)("Themes"),
|
|
197
|
+
name: "theme",
|
|
198
|
+
kind: "root",
|
|
199
|
+
baseURL: "/wp/v2/themes",
|
|
200
|
+
baseURLParams: { context: "edit" },
|
|
201
|
+
plural: "themes",
|
|
202
|
+
key: "stylesheet"
|
|
221
203
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
context: 'edit'
|
|
204
|
+
{
|
|
205
|
+
label: (0, import_i18n.__)("Plugins"),
|
|
206
|
+
name: "plugin",
|
|
207
|
+
kind: "root",
|
|
208
|
+
baseURL: "/wp/v2/plugins",
|
|
209
|
+
baseURLParams: { context: "edit" },
|
|
210
|
+
plural: "plugins",
|
|
211
|
+
key: "plugin"
|
|
231
212
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
213
|
+
{
|
|
214
|
+
label: (0, import_i18n.__)("Status"),
|
|
215
|
+
name: "status",
|
|
216
|
+
kind: "root",
|
|
217
|
+
baseURL: "/wp/v2/statuses",
|
|
218
|
+
baseURLParams: { context: "edit" },
|
|
219
|
+
plural: "statuses",
|
|
220
|
+
key: "slug"
|
|
221
|
+
}
|
|
222
|
+
];
|
|
223
|
+
const deprecatedEntities = {
|
|
236
224
|
root: {
|
|
237
225
|
media: {
|
|
238
|
-
since:
|
|
226
|
+
since: "6.9",
|
|
239
227
|
alternative: {
|
|
240
|
-
kind:
|
|
241
|
-
name:
|
|
228
|
+
kind: "postType",
|
|
229
|
+
name: "attachment"
|
|
242
230
|
}
|
|
243
231
|
}
|
|
244
232
|
}
|
|
245
233
|
};
|
|
246
|
-
const additionalEntityConfigLoaders =
|
|
247
|
-
kind:
|
|
248
|
-
loadEntities:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
loadEntities: loadSiteEntity
|
|
257
|
-
}];
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Returns a function to be used to retrieve extra edits to apply before persisting a post type.
|
|
261
|
-
*
|
|
262
|
-
* @param {Object} persistedRecord Already persisted Post
|
|
263
|
-
* @param {Object} edits Edits.
|
|
264
|
-
* @return {Object} Updated edits.
|
|
265
|
-
*/
|
|
234
|
+
const additionalEntityConfigLoaders = [
|
|
235
|
+
{ kind: "postType", loadEntities: loadPostTypeEntities },
|
|
236
|
+
{ kind: "taxonomy", loadEntities: loadTaxonomyEntities },
|
|
237
|
+
{
|
|
238
|
+
kind: "root",
|
|
239
|
+
name: "site",
|
|
240
|
+
plural: "sites",
|
|
241
|
+
loadEntities: loadSiteEntity
|
|
242
|
+
}
|
|
243
|
+
];
|
|
266
244
|
const prePersistPostType = (persistedRecord, edits) => {
|
|
267
245
|
const newEdits = {};
|
|
268
|
-
if (persistedRecord?.status ===
|
|
269
|
-
// Saving an auto-draft should create a draft by default.
|
|
246
|
+
if (persistedRecord?.status === "auto-draft") {
|
|
270
247
|
if (!edits.status && !newEdits.status) {
|
|
271
|
-
newEdits.status =
|
|
248
|
+
newEdits.status = "draft";
|
|
272
249
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if ((!edits.title || edits.title === 'Auto Draft') && !newEdits.title && (!persistedRecord?.title || persistedRecord?.title === 'Auto Draft')) {
|
|
276
|
-
newEdits.title = '';
|
|
250
|
+
if ((!edits.title || edits.title === "Auto Draft") && !newEdits.title && (!persistedRecord?.title || persistedRecord?.title === "Auto Draft")) {
|
|
251
|
+
newEdits.title = "";
|
|
277
252
|
}
|
|
278
253
|
}
|
|
279
254
|
return newEdits;
|
|
280
255
|
};
|
|
281
|
-
exports.prePersistPostType = prePersistPostType;
|
|
282
|
-
const serialisableBlocksCache = new WeakMap();
|
|
283
|
-
function makeBlockAttributesSerializable(attributes) {
|
|
284
|
-
const newAttributes = {
|
|
285
|
-
...attributes
|
|
286
|
-
};
|
|
287
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
288
|
-
if (value instanceof _richText.RichTextData) {
|
|
289
|
-
newAttributes[key] = value.valueOf();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return newAttributes;
|
|
293
|
-
}
|
|
294
|
-
function makeBlocksSerializable(blocks) {
|
|
295
|
-
return blocks.map(block => {
|
|
296
|
-
const {
|
|
297
|
-
innerBlocks,
|
|
298
|
-
attributes,
|
|
299
|
-
...rest
|
|
300
|
-
} = block;
|
|
301
|
-
return {
|
|
302
|
-
...rest,
|
|
303
|
-
attributes: makeBlockAttributesSerializable(attributes),
|
|
304
|
-
innerBlocks: makeBlocksSerializable(innerBlocks)
|
|
305
|
-
};
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Returns the list of post type entities.
|
|
311
|
-
*
|
|
312
|
-
* @return {Promise} Entities promise
|
|
313
|
-
*/
|
|
314
256
|
async function loadPostTypeEntities() {
|
|
315
|
-
const postTypes = await (0,
|
|
316
|
-
path:
|
|
257
|
+
const postTypes = await (0, import_api_fetch.default)({
|
|
258
|
+
path: "/wp/v2/types?context=view"
|
|
317
259
|
});
|
|
318
|
-
return Object.entries(postTypes
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
260
|
+
return Object.entries(postTypes ?? {}).map(([name, postType]) => {
|
|
261
|
+
const isTemplate = ["wp_template", "wp_template_part"].includes(
|
|
262
|
+
name
|
|
263
|
+
);
|
|
264
|
+
const namespace = postType?.rest_namespace ?? "wp/v2";
|
|
265
|
+
const syncConfig = {
|
|
266
|
+
/**
|
|
267
|
+
* Apply changes from the local editor to the local CRDT document so
|
|
268
|
+
* that those changes can be synced to other peers (via the provider).
|
|
269
|
+
*
|
|
270
|
+
* @param {import('@wordpress/sync').CRDTDoc} crdtDoc
|
|
271
|
+
* @param {Partial< import('@wordpress/sync').ObjectData >} changes
|
|
272
|
+
* @return {void}
|
|
273
|
+
*/
|
|
274
|
+
applyChangesToCRDTDoc: (crdtDoc, changes) => (0, import_crdt.applyPostChangesToCRDTDoc)(crdtDoc, changes, postType),
|
|
275
|
+
/**
|
|
276
|
+
* Extract changes from a CRDT document that can be used to update the
|
|
277
|
+
* local editor state.
|
|
278
|
+
*
|
|
279
|
+
* @param {import('@wordpress/sync').CRDTDoc} crdtDoc
|
|
280
|
+
* @param {import('@wordpress/sync').ObjectData} editedRecord
|
|
281
|
+
* @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record
|
|
282
|
+
*/
|
|
283
|
+
getChangesFromCRDTDoc: (crdtDoc, editedRecord) => (0, import_crdt.getPostChangesFromCRDTDoc)(crdtDoc, editedRecord, postType),
|
|
284
|
+
/**
|
|
285
|
+
* Sync features supported by the entity.
|
|
286
|
+
*
|
|
287
|
+
* @type {Record< string, boolean >}
|
|
288
|
+
*/
|
|
289
|
+
supports: {}
|
|
290
|
+
};
|
|
322
291
|
return {
|
|
323
|
-
kind:
|
|
292
|
+
kind: "postType",
|
|
324
293
|
baseURL: `/${namespace}/${postType.rest_base}`,
|
|
325
|
-
baseURLParams: {
|
|
326
|
-
context: 'edit'
|
|
327
|
-
},
|
|
294
|
+
baseURLParams: { context: "edit" },
|
|
328
295
|
name,
|
|
329
296
|
label: postType.name,
|
|
330
297
|
transientEdits: {
|
|
331
|
-
|
|
298
|
+
...blocksTransientEdits,
|
|
332
299
|
selection: true
|
|
333
300
|
},
|
|
334
|
-
mergedEdits: {
|
|
335
|
-
meta: true
|
|
336
|
-
},
|
|
301
|
+
mergedEdits: { meta: true },
|
|
337
302
|
rawAttributes: POST_RAW_ATTRIBUTES,
|
|
338
|
-
getTitle: record =>
|
|
339
|
-
|
|
340
|
-
return record?.title?.rendered || record?.title || (isTemplate ? (0, _changeCase.capitalCase)((_record$slug = record.slug) !== null && _record$slug !== void 0 ? _record$slug : '') : String(record.id));
|
|
341
|
-
},
|
|
342
|
-
__unstablePrePersist: isTemplate ? undefined : prePersistPostType,
|
|
303
|
+
getTitle: (record) => record?.title?.rendered || record?.title || (isTemplate ? (0, import_change_case.capitalCase)(record.slug ?? "") : String(record.id)),
|
|
304
|
+
__unstablePrePersist: isTemplate ? void 0 : prePersistPostType,
|
|
343
305
|
__unstable_rest_base: postType.rest_base,
|
|
344
|
-
syncConfig
|
|
345
|
-
fetch: async id => {
|
|
346
|
-
return (0, _apiFetch.default)({
|
|
347
|
-
path: `/${namespace}/${postType.rest_base}/${id}?context=edit`
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
applyChangesToDoc: (doc, changes) => {
|
|
351
|
-
const document = doc.getMap('document');
|
|
352
|
-
Object.entries(changes).forEach(([key, value]) => {
|
|
353
|
-
if (typeof value !== 'function') {
|
|
354
|
-
if (key === 'blocks') {
|
|
355
|
-
if (!serialisableBlocksCache.has(value)) {
|
|
356
|
-
serialisableBlocksCache.set(value, makeBlocksSerializable(value));
|
|
357
|
-
}
|
|
358
|
-
value = serialisableBlocksCache.get(value);
|
|
359
|
-
}
|
|
360
|
-
if (document.get(key) !== value) {
|
|
361
|
-
document.set(key, value);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
},
|
|
366
|
-
fromCRDTDoc: doc => {
|
|
367
|
-
return doc.getMap('document').toJSON();
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
syncObjectType: 'postType/' + postType.name,
|
|
371
|
-
getSyncObjectId: id => id,
|
|
306
|
+
syncConfig,
|
|
372
307
|
supportsPagination: true,
|
|
373
|
-
getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ?
|
|
308
|
+
getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ? "/" + revisionId : ""}`,
|
|
374
309
|
revisionKey: DEFAULT_ENTITY_KEY
|
|
375
310
|
};
|
|
376
311
|
});
|
|
377
312
|
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Returns the list of the taxonomies entities.
|
|
381
|
-
*
|
|
382
|
-
* @return {Promise} Entities promise
|
|
383
|
-
*/
|
|
384
313
|
async function loadTaxonomyEntities() {
|
|
385
|
-
const taxonomies = await (0,
|
|
386
|
-
path:
|
|
314
|
+
const taxonomies = await (0, import_api_fetch.default)({
|
|
315
|
+
path: "/wp/v2/taxonomies?context=view"
|
|
387
316
|
});
|
|
388
|
-
return Object.entries(taxonomies
|
|
389
|
-
|
|
390
|
-
const namespace = (_taxonomy$rest_namesp = taxonomy?.rest_namespace) !== null && _taxonomy$rest_namesp !== void 0 ? _taxonomy$rest_namesp : 'wp/v2';
|
|
317
|
+
return Object.entries(taxonomies ?? {}).map(([name, taxonomy]) => {
|
|
318
|
+
const namespace = taxonomy?.rest_namespace ?? "wp/v2";
|
|
391
319
|
return {
|
|
392
|
-
kind:
|
|
320
|
+
kind: "taxonomy",
|
|
393
321
|
baseURL: `/${namespace}/${taxonomy.rest_base}`,
|
|
394
|
-
baseURLParams: {
|
|
395
|
-
context: 'edit'
|
|
396
|
-
},
|
|
322
|
+
baseURLParams: { context: "edit" },
|
|
397
323
|
name,
|
|
398
324
|
label: taxonomy.name,
|
|
399
|
-
getTitle: record => record?.name,
|
|
325
|
+
getTitle: (record) => record?.name,
|
|
400
326
|
supportsPagination: true
|
|
401
327
|
};
|
|
402
328
|
});
|
|
403
329
|
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Returns the Site entity.
|
|
407
|
-
*
|
|
408
|
-
* @return {Promise} Entity promise
|
|
409
|
-
*/
|
|
410
330
|
async function loadSiteEntity() {
|
|
411
|
-
var _site$schema$properti;
|
|
412
331
|
const entity = {
|
|
413
|
-
label: (0,
|
|
414
|
-
name:
|
|
415
|
-
kind:
|
|
416
|
-
baseURL:
|
|
332
|
+
label: (0, import_i18n.__)("Site"),
|
|
333
|
+
name: "site",
|
|
334
|
+
kind: "root",
|
|
335
|
+
baseURL: "/wp/v2/settings",
|
|
417
336
|
syncConfig: {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
path: '/wp/v2/settings'
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
applyChangesToDoc: (doc, changes) => {
|
|
424
|
-
const document = doc.getMap('document');
|
|
425
|
-
Object.entries(changes).forEach(([key, value]) => {
|
|
426
|
-
if (document.get(key) !== value) {
|
|
427
|
-
document.set(key, value);
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
},
|
|
431
|
-
fromCRDTDoc: doc => {
|
|
432
|
-
return doc.getMap('document').toJSON();
|
|
433
|
-
}
|
|
337
|
+
applyChangesToCRDTDoc: import_crdt.defaultApplyChangesToCRDTDoc,
|
|
338
|
+
getChangesFromCRDTDoc: import_crdt.defaultGetChangesFromCRDTDoc
|
|
434
339
|
},
|
|
435
|
-
syncObjectType: 'root/site',
|
|
436
|
-
getSyncObjectId: () => 'index',
|
|
437
340
|
meta: {}
|
|
438
341
|
};
|
|
439
|
-
const site = await (0,
|
|
342
|
+
const site = await (0, import_api_fetch.default)({
|
|
440
343
|
path: entity.baseURL,
|
|
441
|
-
method:
|
|
344
|
+
method: "OPTIONS"
|
|
442
345
|
});
|
|
443
346
|
const labels = {};
|
|
444
|
-
Object.entries(
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
});
|
|
450
|
-
return [{
|
|
451
|
-
...entity,
|
|
452
|
-
meta: {
|
|
453
|
-
labels
|
|
347
|
+
Object.entries(site?.schema?.properties ?? {}).forEach(
|
|
348
|
+
([key, value]) => {
|
|
349
|
+
if (typeof value === "object" && value.title) {
|
|
350
|
+
labels[key] = value.title;
|
|
351
|
+
}
|
|
454
352
|
}
|
|
455
|
-
|
|
353
|
+
);
|
|
354
|
+
return [{ ...entity, meta: { labels } }];
|
|
456
355
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*
|
|
461
|
-
* @example
|
|
462
|
-
* ```js
|
|
463
|
-
* const nameSingular = getMethodName( 'root', 'theme', 'get' );
|
|
464
|
-
* // nameSingular is getRootTheme
|
|
465
|
-
*
|
|
466
|
-
* const namePlural = getMethodName( 'root', 'themes', 'set' );
|
|
467
|
-
* // namePlural is setRootThemes
|
|
468
|
-
* ```
|
|
469
|
-
*
|
|
470
|
-
* @param {string} kind Entity kind.
|
|
471
|
-
* @param {string} name Entity name or plural name.
|
|
472
|
-
* @param {string} prefix Function prefix.
|
|
473
|
-
*
|
|
474
|
-
* @return {string} Method name
|
|
475
|
-
*/
|
|
476
|
-
const getMethodName = (kind, name, prefix = 'get') => {
|
|
477
|
-
const kindPrefix = kind === 'root' ? '' : (0, _changeCase.pascalCase)(kind);
|
|
478
|
-
const suffix = (0, _changeCase.pascalCase)(name);
|
|
356
|
+
const getMethodName = (kind, name, prefix = "get") => {
|
|
357
|
+
const kindPrefix = kind === "root" ? "" : (0, import_change_case.pascalCase)(kind);
|
|
358
|
+
const suffix = (0, import_change_case.pascalCase)(name);
|
|
479
359
|
return `${prefix}${kindPrefix}${suffix}`;
|
|
480
360
|
};
|
|
481
|
-
|
|
482
|
-
|
|
361
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
362
|
+
0 && (module.exports = {
|
|
363
|
+
DEFAULT_ENTITY_KEY,
|
|
364
|
+
additionalEntityConfigLoaders,
|
|
365
|
+
deprecatedEntities,
|
|
366
|
+
getMethodName,
|
|
367
|
+
prePersistPostType,
|
|
368
|
+
rootEntitiesConfig
|
|
369
|
+
});
|
|
370
|
+
//# sourceMappingURL=entities.js.map
|