@wordpress/core-data 6.15.0 → 6.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/build/actions.js +70 -135
- package/build/actions.js.map +1 -1
- package/build/batch/create-batch.js +0 -22
- package/build/batch/create-batch.js.map +1 -1
- package/build/batch/default-processor.js +3 -15
- package/build/batch/default-processor.js.map +1 -1
- package/build/batch/index.js +0 -3
- package/build/batch/index.js.map +1 -1
- package/build/entities.js +109 -36
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +34 -53
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/attachment.js.map +1 -1
- package/build/entity-types/base-entity-records.js +0 -3
- package/build/entity-types/base-entity-records.js.map +1 -1
- package/build/entity-types/comment.js.map +1 -1
- package/build/entity-types/helpers.js.map +1 -1
- package/build/entity-types/index.js.map +1 -1
- package/build/entity-types/menu-location.js.map +1 -1
- package/build/entity-types/nav-menu-item.js.map +1 -1
- package/build/entity-types/nav-menu.js.map +1 -1
- package/build/entity-types/page.js.map +1 -1
- package/build/entity-types/plugin.js.map +1 -1
- package/build/entity-types/post.js.map +1 -1
- package/build/entity-types/settings.js.map +1 -1
- package/build/entity-types/sidebar.js.map +1 -1
- package/build/entity-types/taxonomy.js.map +1 -1
- package/build/entity-types/theme.js.map +1 -1
- package/build/entity-types/type.js.map +1 -1
- package/build/entity-types/user.js.map +1 -1
- package/build/entity-types/widget-type.js.map +1 -1
- package/build/entity-types/widget.js.map +1 -1
- package/build/entity-types/wp-template-part.js.map +1 -1
- package/build/entity-types/wp-template.js.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +14 -20
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +4 -13
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/fetch/index.js +0 -3
- package/build/fetch/index.js.map +1 -1
- package/build/hooks/constants.js +4 -5
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +0 -5
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/memoize.js +0 -3
- package/build/hooks/memoize.js.map +1 -1
- package/build/hooks/use-entity-record.js +0 -9
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +2 -9
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js +1 -13
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/hooks/use-resource-permissions.js +0 -15
- package/build/hooks/use-resource-permissions.js.map +1 -1
- package/build/index.js +9 -41
- package/build/index.js.map +1 -1
- package/build/locks/actions.js +1 -6
- package/build/locks/actions.js.map +1 -1
- package/build/locks/engine.js +1 -9
- package/build/locks/engine.js.map +1 -1
- package/build/locks/reducer.js +8 -9
- package/build/locks/reducer.js.map +1 -1
- package/build/locks/selectors.js +8 -11
- package/build/locks/selectors.js.map +1 -1
- package/build/locks/utils.js +4 -19
- package/build/locks/utils.js.map +1 -1
- package/build/name.js +0 -1
- package/build/name.js.map +1 -1
- package/build/private-apis.js +1 -2
- package/build/private-apis.js.map +1 -1
- package/build/private-selectors.js +2 -5
- package/build/private-selectors.js.map +1 -1
- package/build/queried-data/actions.js +4 -6
- package/build/queried-data/actions.js.map +1 -1
- package/build/queried-data/get-query-parts.js +11 -24
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/index.js +0 -6
- package/build/queried-data/index.js.map +1 -1
- package/build/queried-data/reducer.js +33 -51
- package/build/queried-data/reducer.js.map +1 -1
- package/build/queried-data/selectors.js +4 -25
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +76 -128
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +91 -133
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +51 -145
- package/build/selectors.js.map +1 -1
- package/build/sync.js +19 -0
- package/build/sync.js.map +1 -0
- package/build/types.js.map +1 -1
- package/build/utils/conservative-map-item.js +3 -10
- package/build/utils/conservative-map-item.js.map +1 -1
- package/build/utils/forward-resolver.js +0 -2
- package/build/utils/forward-resolver.js.map +1 -1
- package/build/utils/get-normalized-comma-separable.js +0 -3
- package/build/utils/get-normalized-comma-separable.js.map +1 -1
- package/build/utils/if-matching-action.js +0 -3
- package/build/utils/if-matching-action.js.map +1 -1
- package/build/utils/index.js +0 -10
- package/build/utils/index.js.map +1 -1
- package/build/utils/is-raw-attribute.js +0 -1
- package/build/utils/is-raw-attribute.js.map +1 -1
- package/build/utils/on-sub-key.js +5 -9
- package/build/utils/on-sub-key.js.map +1 -1
- package/build/utils/replace-action.js +0 -2
- package/build/utils/replace-action.js.map +1 -1
- package/build/utils/set-nested-value.js +0 -4
- package/build/utils/set-nested-value.js.map +1 -1
- package/build/utils/with-weak-map-cache.js +3 -6
- package/build/utils/with-weak-map-cache.js.map +1 -1
- package/build-module/actions.js +73 -96
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/create-batch.js +1 -20
- package/build-module/batch/create-batch.js.map +1 -1
- package/build-module/batch/default-processor.js +4 -13
- package/build-module/batch/default-processor.js.map +1 -1
- package/build-module/batch/index.js.map +1 -1
- package/build-module/entities.js +109 -25
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js +35 -45
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/entity-types/attachment.js.map +1 -1
- package/build-module/entity-types/base-entity-records.js +0 -2
- package/build-module/entity-types/base-entity-records.js.map +1 -1
- package/build-module/entity-types/comment.js.map +1 -1
- package/build-module/entity-types/helpers.js.map +1 -1
- package/build-module/entity-types/index.js.map +1 -1
- package/build-module/entity-types/menu-location.js.map +1 -1
- package/build-module/entity-types/nav-menu-item.js.map +1 -1
- package/build-module/entity-types/nav-menu.js.map +1 -1
- package/build-module/entity-types/page.js.map +1 -1
- package/build-module/entity-types/plugin.js.map +1 -1
- package/build-module/entity-types/post.js.map +1 -1
- package/build-module/entity-types/settings.js.map +1 -1
- package/build-module/entity-types/sidebar.js.map +1 -1
- package/build-module/entity-types/taxonomy.js.map +1 -1
- package/build-module/entity-types/theme.js.map +1 -1
- package/build-module/entity-types/type.js.map +1 -1
- package/build-module/entity-types/user.js.map +1 -1
- package/build-module/entity-types/widget-type.js.map +1 -1
- package/build-module/entity-types/widget.js.map +1 -1
- package/build-module/entity-types/wp-template-part.js.map +1 -1
- package/build-module/entity-types/wp-template.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +15 -15
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +5 -10
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/fetch/index.js.map +1 -1
- package/build-module/hooks/constants.js +3 -4
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/memoize.js +2 -1
- package/build-module/hooks/memoize.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +1 -3
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +2 -3
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js +1 -9
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/hooks/use-resource-permissions.js +1 -10
- package/build-module/hooks/use-resource-permissions.js.map +1 -1
- package/build-module/index.js +11 -19
- package/build-module/index.js.map +1 -1
- package/build-module/locks/actions.js +0 -3
- package/build-module/locks/actions.js.map +1 -1
- package/build-module/locks/engine.js +0 -5
- package/build-module/locks/engine.js.map +1 -1
- package/build-module/locks/reducer.js +7 -7
- package/build-module/locks/reducer.js.map +1 -1
- package/build-module/locks/selectors.js +7 -8
- package/build-module/locks/selectors.js.map +1 -1
- package/build-module/locks/utils.js +4 -14
- package/build-module/locks/utils.js.map +1 -1
- package/build-module/name.js.map +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-selectors.js +2 -2
- package/build-module/private-selectors.js.map +1 -1
- package/build-module/queried-data/actions.js +4 -3
- package/build-module/queried-data/actions.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +13 -21
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/index.js.map +1 -1
- package/build-module/queried-data/reducer.js +33 -42
- package/build-module/queried-data/reducer.js.map +1 -1
- package/build-module/queried-data/selectors.js +6 -21
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/reducer.js +79 -104
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +94 -96
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +56 -92
- package/build-module/selectors.js.map +1 -1
- package/build-module/sync.js +12 -0
- package/build-module/sync.js.map +1 -0
- package/build-module/types.js.map +1 -1
- package/build-module/utils/conservative-map-item.js +4 -8
- package/build-module/utils/conservative-map-item.js.map +1 -1
- package/build-module/utils/forward-resolver.js +0 -1
- package/build-module/utils/forward-resolver.js.map +1 -1
- package/build-module/utils/get-normalized-comma-separable.js +0 -2
- package/build-module/utils/get-normalized-comma-separable.js.map +1 -1
- package/build-module/utils/if-matching-action.js +0 -2
- package/build-module/utils/if-matching-action.js.map +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/is-raw-attribute.js.map +1 -1
- package/build-module/utils/on-sub-key.js +5 -7
- package/build-module/utils/on-sub-key.js.map +1 -1
- package/build-module/utils/replace-action.js +0 -1
- package/build-module/utils/replace-action.js.map +1 -1
- package/build-module/utils/set-nested-value.js +0 -3
- package/build-module/utils/set-nested-value.js.map +1 -1
- package/build-module/utils/with-weak-map-cache.js +3 -5
- package/build-module/utils/with-weak-map-cache.js.map +1 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +53 -0
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/hooks/memoize.d.ts +1 -1
- package/build-types/hooks/memoize.d.ts.map +1 -1
- package/build-types/index.d.ts +4 -4
- package/build-types/index.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +2 -0
- package/build-types/sync.d.ts.map +1 -0
- package/package.json +17 -15
- package/src/actions.js +30 -17
- package/src/entities.js +91 -0
- package/src/entity-provider.js +11 -2
- package/src/resolvers.js +89 -41
- package/src/selectors.ts +1 -1
- package/src/sync.js +18 -0
- package/src/test/entity-provider.js +272 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import createSelector from 'rememo';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* WordPress dependencies
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
import { createRegistrySelector } from '@wordpress/data';
|
|
10
10
|
import { addQueryArgs } from '@wordpress/url';
|
|
11
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
import { STORE_NAME } from './name';
|
|
17
17
|
import { getQueriedItems } from './queried-data';
|
|
18
18
|
import { DEFAULT_ENTITY_KEY } from './entities';
|
|
19
19
|
import { getNormalizedCommaSeparable, isRawAttribute, setNestedValue } from './utils';
|
|
20
|
-
import { getUndoEdits, getRedoEdits } from './private-selectors';
|
|
20
|
+
import { getUndoEdits, getRedoEdits } from './private-selectors';
|
|
21
|
+
|
|
22
|
+
// This is an incomplete, high-level approximation of the State type.
|
|
21
23
|
// It makes the selectors slightly more safe, but is intended to evolve
|
|
22
24
|
// into a more detailed representation over time.
|
|
23
25
|
// See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.
|
|
@@ -30,6 +32,7 @@ import { getUndoEdits, getRedoEdits } from './private-selectors'; // This is an
|
|
|
30
32
|
* maintained by the reducer result in state.
|
|
31
33
|
*/
|
|
32
34
|
const EMPTY_OBJECT = {};
|
|
35
|
+
|
|
33
36
|
/**
|
|
34
37
|
* Returns true if a request is in progress for embed preview data, or false
|
|
35
38
|
* otherwise.
|
|
@@ -39,10 +42,10 @@ const EMPTY_OBJECT = {};
|
|
|
39
42
|
*
|
|
40
43
|
* @return Whether a request is in progress for an embed preview.
|
|
41
44
|
*/
|
|
42
|
-
|
|
43
45
|
export const isRequestingEmbedPreview = createRegistrySelector(select => (state, url) => {
|
|
44
46
|
return select(STORE_NAME).isResolving('getEmbedPreview', [url]);
|
|
45
47
|
});
|
|
48
|
+
|
|
46
49
|
/**
|
|
47
50
|
* Returns all available authors.
|
|
48
51
|
*
|
|
@@ -53,7 +56,6 @@ export const isRequestingEmbedPreview = createRegistrySelector(select => (state,
|
|
|
53
56
|
* include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).
|
|
54
57
|
* @return Authors list.
|
|
55
58
|
*/
|
|
56
|
-
|
|
57
59
|
export function getAuthors(state, query) {
|
|
58
60
|
deprecated("select( 'core' ).getAuthors()", {
|
|
59
61
|
since: '5.9',
|
|
@@ -62,6 +64,7 @@ export function getAuthors(state, query) {
|
|
|
62
64
|
const path = addQueryArgs('/wp/v2/users/?who=authors&per_page=100', query);
|
|
63
65
|
return getUserQueryResults(state, path);
|
|
64
66
|
}
|
|
67
|
+
|
|
65
68
|
/**
|
|
66
69
|
* Returns the current user.
|
|
67
70
|
*
|
|
@@ -69,10 +72,10 @@ export function getAuthors(state, query) {
|
|
|
69
72
|
*
|
|
70
73
|
* @return Current user object.
|
|
71
74
|
*/
|
|
72
|
-
|
|
73
75
|
export function getCurrentUser(state) {
|
|
74
76
|
return state.currentUser;
|
|
75
77
|
}
|
|
78
|
+
|
|
76
79
|
/**
|
|
77
80
|
* Returns all the users returned by a query ID.
|
|
78
81
|
*
|
|
@@ -81,13 +84,12 @@ export function getCurrentUser(state) {
|
|
|
81
84
|
*
|
|
82
85
|
* @return Users list.
|
|
83
86
|
*/
|
|
84
|
-
|
|
85
87
|
export const getUserQueryResults = createSelector((state, queryID) => {
|
|
86
88
|
var _state$users$queries$;
|
|
87
|
-
|
|
88
89
|
const queryResults = (_state$users$queries$ = state.users.queries[queryID]) !== null && _state$users$queries$ !== void 0 ? _state$users$queries$ : [];
|
|
89
90
|
return queryResults.map(id => state.users.byId[id]);
|
|
90
91
|
}, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
|
|
92
|
+
|
|
91
93
|
/**
|
|
92
94
|
* Returns the loaded entities for the given kind.
|
|
93
95
|
*
|
|
@@ -97,7 +99,6 @@ export const getUserQueryResults = createSelector((state, queryID) => {
|
|
|
97
99
|
*
|
|
98
100
|
* @return Array of entities with config matching kind.
|
|
99
101
|
*/
|
|
100
|
-
|
|
101
102
|
export function getEntitiesByKind(state, kind) {
|
|
102
103
|
deprecated("wp.data.select( 'core' ).getEntitiesByKind()", {
|
|
103
104
|
since: '6.0',
|
|
@@ -105,6 +106,7 @@ export function getEntitiesByKind(state, kind) {
|
|
|
105
106
|
});
|
|
106
107
|
return getEntitiesConfig(state, kind);
|
|
107
108
|
}
|
|
109
|
+
|
|
108
110
|
/**
|
|
109
111
|
* Returns the loaded entities for the given kind.
|
|
110
112
|
*
|
|
@@ -113,10 +115,10 @@ export function getEntitiesByKind(state, kind) {
|
|
|
113
115
|
*
|
|
114
116
|
* @return Array of entities with config matching kind.
|
|
115
117
|
*/
|
|
116
|
-
|
|
117
118
|
export function getEntitiesConfig(state, kind) {
|
|
118
119
|
return state.entities.config.filter(entity => entity.kind === kind);
|
|
119
120
|
}
|
|
121
|
+
|
|
120
122
|
/**
|
|
121
123
|
* Returns the entity config given its kind and name.
|
|
122
124
|
*
|
|
@@ -127,7 +129,6 @@ export function getEntitiesConfig(state, kind) {
|
|
|
127
129
|
*
|
|
128
130
|
* @return Entity config
|
|
129
131
|
*/
|
|
130
|
-
|
|
131
132
|
export function getEntity(state, kind, name) {
|
|
132
133
|
deprecated("wp.data.select( 'core' ).getEntity()", {
|
|
133
134
|
since: '6.0',
|
|
@@ -135,6 +136,7 @@ export function getEntity(state, kind, name) {
|
|
|
135
136
|
});
|
|
136
137
|
return getEntityConfig(state, kind, name);
|
|
137
138
|
}
|
|
139
|
+
|
|
138
140
|
/**
|
|
139
141
|
* Returns the entity config given its kind and name.
|
|
140
142
|
*
|
|
@@ -144,10 +146,10 @@ export function getEntity(state, kind, name) {
|
|
|
144
146
|
*
|
|
145
147
|
* @return Entity config
|
|
146
148
|
*/
|
|
147
|
-
|
|
148
149
|
export function getEntityConfig(state, kind, name) {
|
|
149
150
|
return state.entities.config?.find(config => config.kind === kind && config.name === name);
|
|
150
151
|
}
|
|
152
|
+
|
|
151
153
|
/**
|
|
152
154
|
* GetEntityRecord is declared as a *callable interface* with
|
|
153
155
|
* two signatures to work around the fact that TypeScript doesn't
|
|
@@ -189,32 +191,23 @@ export function getEntityConfig(state, kind, name) {
|
|
|
189
191
|
*/
|
|
190
192
|
export const getEntityRecord = createSelector((state, kind, name, key, query) => {
|
|
191
193
|
var _query$context;
|
|
192
|
-
|
|
193
194
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
194
|
-
|
|
195
195
|
if (!queriedState) {
|
|
196
196
|
return undefined;
|
|
197
197
|
}
|
|
198
|
-
|
|
199
198
|
const context = (_query$context = query?.context) !== null && _query$context !== void 0 ? _query$context : 'default';
|
|
200
|
-
|
|
201
199
|
if (query === undefined) {
|
|
202
200
|
// If expecting a complete item, validate that completeness.
|
|
203
201
|
if (!queriedState.itemIsComplete[context]?.[key]) {
|
|
204
202
|
return undefined;
|
|
205
203
|
}
|
|
206
|
-
|
|
207
204
|
return queriedState.items[context][key];
|
|
208
205
|
}
|
|
209
|
-
|
|
210
206
|
const item = queriedState.items[context]?.[key];
|
|
211
|
-
|
|
212
207
|
if (item && query._fields) {
|
|
213
208
|
var _getNormalizedCommaSe;
|
|
214
|
-
|
|
215
209
|
const filteredItem = {};
|
|
216
210
|
const fields = (_getNormalizedCommaSe = getNormalizedCommaSeparable(query._fields)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
|
|
217
|
-
|
|
218
211
|
for (let f = 0; f < fields.length; f++) {
|
|
219
212
|
const field = fields[f].split('.');
|
|
220
213
|
let value = item;
|
|
@@ -223,17 +216,15 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
|
|
|
223
216
|
});
|
|
224
217
|
setNestedValue(filteredItem, field, value);
|
|
225
218
|
}
|
|
226
|
-
|
|
227
219
|
return filteredItem;
|
|
228
220
|
}
|
|
229
|
-
|
|
230
221
|
return item;
|
|
231
222
|
}, (state, kind, name, recordId, query) => {
|
|
232
223
|
var _query$context2;
|
|
233
|
-
|
|
234
224
|
const context = (_query$context2 = query?.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
|
|
235
225
|
return [state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
|
|
236
226
|
});
|
|
227
|
+
|
|
237
228
|
/**
|
|
238
229
|
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
|
|
239
230
|
*
|
|
@@ -244,10 +235,10 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
|
|
|
244
235
|
*
|
|
245
236
|
* @return Record.
|
|
246
237
|
*/
|
|
247
|
-
|
|
248
238
|
export function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
249
239
|
return getEntityRecord(state, kind, name, key);
|
|
250
240
|
}
|
|
241
|
+
|
|
251
242
|
/**
|
|
252
243
|
* Returns the entity's record object by key,
|
|
253
244
|
* with its attributes mapped to their raw values.
|
|
@@ -259,13 +250,11 @@ export function __experimentalGetEntityRecordNoResolver(state, kind, name, key)
|
|
|
259
250
|
*
|
|
260
251
|
* @return Object with the entity's raw attributes.
|
|
261
252
|
*/
|
|
262
|
-
|
|
263
253
|
export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
264
254
|
const record = getEntityRecord(state, kind, name, key);
|
|
265
255
|
return record && Object.keys(record).reduce((accumulator, _key) => {
|
|
266
256
|
if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
|
|
267
257
|
var _record$_key$raw;
|
|
268
|
-
|
|
269
258
|
// Because edits are the "raw" attribute values,
|
|
270
259
|
// we return those from record selectors to make rendering,
|
|
271
260
|
// comparisons, and joins with edits easier.
|
|
@@ -273,15 +262,14 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
|
273
262
|
} else {
|
|
274
263
|
accumulator[_key] = record[_key];
|
|
275
264
|
}
|
|
276
|
-
|
|
277
265
|
return accumulator;
|
|
278
266
|
}, {});
|
|
279
267
|
}, (state, kind, name, recordId, query) => {
|
|
280
268
|
var _query$context3;
|
|
281
|
-
|
|
282
269
|
const context = (_query$context3 = query?.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
|
|
283
270
|
return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
|
|
284
271
|
});
|
|
272
|
+
|
|
285
273
|
/**
|
|
286
274
|
* Returns true if records have been received for the given set of parameters,
|
|
287
275
|
* or false otherwise.
|
|
@@ -293,10 +281,10 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
|
293
281
|
*
|
|
294
282
|
* @return Whether entity records have been received.
|
|
295
283
|
*/
|
|
296
|
-
|
|
297
284
|
export function hasEntityRecords(state, kind, name, query) {
|
|
298
285
|
return Array.isArray(getEntityRecords(state, kind, name, query));
|
|
299
286
|
}
|
|
287
|
+
|
|
300
288
|
/**
|
|
301
289
|
* GetEntityRecord is declared as a *callable interface* with
|
|
302
290
|
* two signatures to work around the fact that TypeScript doesn't
|
|
@@ -321,14 +309,11 @@ export const getEntityRecords = (state, kind, name, query) => {
|
|
|
321
309
|
// Queried data state is prepopulated for all known entities. If this is not
|
|
322
310
|
// assigned for the given parameters, then it is known to not exist.
|
|
323
311
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
324
|
-
|
|
325
312
|
if (!queriedState) {
|
|
326
313
|
return null;
|
|
327
314
|
}
|
|
328
|
-
|
|
329
315
|
return getQueriedItems(queriedState, query);
|
|
330
316
|
};
|
|
331
|
-
|
|
332
317
|
/**
|
|
333
318
|
* Returns the list of dirty entity records.
|
|
334
319
|
*
|
|
@@ -345,10 +330,10 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
|
|
|
345
330
|
const dirtyRecords = [];
|
|
346
331
|
Object.keys(records).forEach(kind => {
|
|
347
332
|
Object.keys(records[kind]).forEach(name => {
|
|
348
|
-
const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey =>
|
|
333
|
+
const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey =>
|
|
334
|
+
// The entity record must exist (not be deleted),
|
|
349
335
|
// and it must have edits.
|
|
350
336
|
getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
|
|
351
|
-
|
|
352
337
|
if (primaryKeys.length) {
|
|
353
338
|
const entityConfig = getEntityConfig(state, kind, name);
|
|
354
339
|
primaryKeys.forEach(primaryKey => {
|
|
@@ -367,6 +352,7 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
|
|
|
367
352
|
});
|
|
368
353
|
return dirtyRecords;
|
|
369
354
|
}, state => [state.entities.records]);
|
|
355
|
+
|
|
370
356
|
/**
|
|
371
357
|
* Returns the list of entities currently being saved.
|
|
372
358
|
*
|
|
@@ -374,7 +360,6 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
|
|
|
374
360
|
*
|
|
375
361
|
* @return The list of records being saved.
|
|
376
362
|
*/
|
|
377
|
-
|
|
378
363
|
export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
379
364
|
const {
|
|
380
365
|
entities: {
|
|
@@ -385,7 +370,6 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
|
385
370
|
Object.keys(records).forEach(kind => {
|
|
386
371
|
Object.keys(records[kind]).forEach(name => {
|
|
387
372
|
const primaryKeys = Object.keys(records[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
|
|
388
|
-
|
|
389
373
|
if (primaryKeys.length) {
|
|
390
374
|
const entityConfig = getEntityConfig(state, kind, name);
|
|
391
375
|
primaryKeys.forEach(primaryKey => {
|
|
@@ -404,6 +388,7 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
|
404
388
|
});
|
|
405
389
|
return recordsBeingSaved;
|
|
406
390
|
}, state => [state.entities.records]);
|
|
391
|
+
|
|
407
392
|
/**
|
|
408
393
|
* Returns the specified entity record's edits.
|
|
409
394
|
*
|
|
@@ -414,10 +399,10 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
|
414
399
|
*
|
|
415
400
|
* @return The entity record's edits.
|
|
416
401
|
*/
|
|
417
|
-
|
|
418
402
|
export function getEntityRecordEdits(state, kind, name, recordId) {
|
|
419
403
|
return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
|
|
420
404
|
}
|
|
405
|
+
|
|
421
406
|
/**
|
|
422
407
|
* Returns the specified entity record's non transient edits.
|
|
423
408
|
*
|
|
@@ -432,25 +417,22 @@ export function getEntityRecordEdits(state, kind, name, recordId) {
|
|
|
432
417
|
*
|
|
433
418
|
* @return The entity record's non transient edits.
|
|
434
419
|
*/
|
|
435
|
-
|
|
436
420
|
export const getEntityRecordNonTransientEdits = createSelector((state, kind, name, recordId) => {
|
|
437
421
|
const {
|
|
438
422
|
transientEdits
|
|
439
423
|
} = getEntityConfig(state, kind, name) || {};
|
|
440
424
|
const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
|
|
441
|
-
|
|
442
425
|
if (!transientEdits) {
|
|
443
426
|
return edits;
|
|
444
427
|
}
|
|
445
|
-
|
|
446
428
|
return Object.keys(edits).reduce((acc, key) => {
|
|
447
429
|
if (!transientEdits[key]) {
|
|
448
430
|
acc[key] = edits[key];
|
|
449
431
|
}
|
|
450
|
-
|
|
451
432
|
return acc;
|
|
452
433
|
}, {});
|
|
453
434
|
}, (state, kind, name, recordId) => [state.entities.config, state.entities.records?.[kind]?.[name]?.edits?.[recordId]]);
|
|
435
|
+
|
|
454
436
|
/**
|
|
455
437
|
* Returns true if the specified entity record has edits,
|
|
456
438
|
* and false otherwise.
|
|
@@ -462,10 +444,10 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
|
|
|
462
444
|
*
|
|
463
445
|
* @return Whether the entity record has edits or not.
|
|
464
446
|
*/
|
|
465
|
-
|
|
466
447
|
export function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
467
448
|
return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
|
|
468
449
|
}
|
|
450
|
+
|
|
469
451
|
/**
|
|
470
452
|
* Returns the specified entity record, merged with its edits.
|
|
471
453
|
*
|
|
@@ -476,15 +458,15 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
476
458
|
*
|
|
477
459
|
* @return The entity record, merged with its edits.
|
|
478
460
|
*/
|
|
479
|
-
|
|
480
|
-
|
|
461
|
+
export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({
|
|
462
|
+
...getRawEntityRecord(state, kind, name, recordId),
|
|
481
463
|
...getEntityRecordEdits(state, kind, name, recordId)
|
|
482
464
|
}), (state, kind, name, recordId, query) => {
|
|
483
465
|
var _query$context4;
|
|
484
|
-
|
|
485
466
|
const context = (_query$context4 = query?.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
|
|
486
467
|
return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId], state.entities.records?.[kind]?.[name]?.edits?.[recordId]];
|
|
487
468
|
});
|
|
469
|
+
|
|
488
470
|
/**
|
|
489
471
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
490
472
|
*
|
|
@@ -495,16 +477,15 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
|
|
|
495
477
|
*
|
|
496
478
|
* @return Whether the entity record is autosaving or not.
|
|
497
479
|
*/
|
|
498
|
-
|
|
499
480
|
export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
500
481
|
var _state$entities$recor;
|
|
501
|
-
|
|
502
482
|
const {
|
|
503
483
|
pending,
|
|
504
484
|
isAutosave
|
|
505
485
|
} = (_state$entities$recor = state.entities.records?.[kind]?.[name]?.saving?.[recordId]) !== null && _state$entities$recor !== void 0 ? _state$entities$recor : {};
|
|
506
486
|
return Boolean(pending && isAutosave);
|
|
507
487
|
}
|
|
488
|
+
|
|
508
489
|
/**
|
|
509
490
|
* Returns true if the specified entity record is saving, and false otherwise.
|
|
510
491
|
*
|
|
@@ -515,12 +496,11 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
515
496
|
*
|
|
516
497
|
* @return Whether the entity record is saving or not.
|
|
517
498
|
*/
|
|
518
|
-
|
|
519
499
|
export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
520
500
|
var _state$entities$recor2;
|
|
521
|
-
|
|
522
501
|
return (_state$entities$recor2 = state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending) !== null && _state$entities$recor2 !== void 0 ? _state$entities$recor2 : false;
|
|
523
502
|
}
|
|
503
|
+
|
|
524
504
|
/**
|
|
525
505
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
526
506
|
*
|
|
@@ -531,12 +511,11 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
531
511
|
*
|
|
532
512
|
* @return Whether the entity record is deleting or not.
|
|
533
513
|
*/
|
|
534
|
-
|
|
535
514
|
export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
536
515
|
var _state$entities$recor3;
|
|
537
|
-
|
|
538
516
|
return (_state$entities$recor3 = state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending) !== null && _state$entities$recor3 !== void 0 ? _state$entities$recor3 : false;
|
|
539
517
|
}
|
|
518
|
+
|
|
540
519
|
/**
|
|
541
520
|
* Returns the specified entity record's last save error.
|
|
542
521
|
*
|
|
@@ -547,10 +526,10 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
547
526
|
*
|
|
548
527
|
* @return The entity record's save error.
|
|
549
528
|
*/
|
|
550
|
-
|
|
551
529
|
export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
552
530
|
return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
|
|
553
531
|
}
|
|
532
|
+
|
|
554
533
|
/**
|
|
555
534
|
* Returns the specified entity record's last delete error.
|
|
556
535
|
*
|
|
@@ -561,10 +540,10 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
561
540
|
*
|
|
562
541
|
* @return The entity record's save error.
|
|
563
542
|
*/
|
|
564
|
-
|
|
565
543
|
export function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
566
544
|
return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
|
|
567
545
|
}
|
|
546
|
+
|
|
568
547
|
/**
|
|
569
548
|
* Returns the current undo offset for the
|
|
570
549
|
* entity records edits history. The offset
|
|
@@ -576,10 +555,10 @@ export function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
|
576
555
|
*
|
|
577
556
|
* @return The current undo offset.
|
|
578
557
|
*/
|
|
579
|
-
|
|
580
558
|
function getCurrentUndoOffset(state) {
|
|
581
559
|
return state.undo.offset;
|
|
582
560
|
}
|
|
561
|
+
|
|
583
562
|
/**
|
|
584
563
|
* Returns the previous edit from the current undo offset
|
|
585
564
|
* for the entity records edits history, if any.
|
|
@@ -590,14 +569,13 @@ function getCurrentUndoOffset(state) {
|
|
|
590
569
|
*
|
|
591
570
|
* @return The edit.
|
|
592
571
|
*/
|
|
593
|
-
|
|
594
|
-
|
|
595
572
|
export function getUndoEdit(state) {
|
|
596
573
|
deprecated("select( 'core' ).getUndoEdit()", {
|
|
597
574
|
since: '6.3'
|
|
598
575
|
});
|
|
599
576
|
return state.undo.list[state.undo.list.length - 2 + getCurrentUndoOffset(state)]?.[0];
|
|
600
577
|
}
|
|
578
|
+
|
|
601
579
|
/**
|
|
602
580
|
* Returns the next edit from the current undo offset
|
|
603
581
|
* for the entity records edits history, if any.
|
|
@@ -608,13 +586,13 @@ export function getUndoEdit(state) {
|
|
|
608
586
|
*
|
|
609
587
|
* @return The edit.
|
|
610
588
|
*/
|
|
611
|
-
|
|
612
589
|
export function getRedoEdit(state) {
|
|
613
590
|
deprecated("select( 'core' ).getRedoEdit()", {
|
|
614
591
|
since: '6.3'
|
|
615
592
|
});
|
|
616
593
|
return state.undo.list[state.undo.list.length + getCurrentUndoOffset(state)]?.[0];
|
|
617
594
|
}
|
|
595
|
+
|
|
618
596
|
/**
|
|
619
597
|
* Returns true if there is a previous edit from the current undo offset
|
|
620
598
|
* for the entity records edits history, and false otherwise.
|
|
@@ -623,10 +601,10 @@ export function getRedoEdit(state) {
|
|
|
623
601
|
*
|
|
624
602
|
* @return Whether there is a previous edit or not.
|
|
625
603
|
*/
|
|
626
|
-
|
|
627
604
|
export function hasUndo(state) {
|
|
628
605
|
return Boolean(getUndoEdits(state));
|
|
629
606
|
}
|
|
607
|
+
|
|
630
608
|
/**
|
|
631
609
|
* Returns true if there is a next edit from the current undo offset
|
|
632
610
|
* for the entity records edits history, and false otherwise.
|
|
@@ -635,10 +613,10 @@ export function hasUndo(state) {
|
|
|
635
613
|
*
|
|
636
614
|
* @return Whether there is a next edit or not.
|
|
637
615
|
*/
|
|
638
|
-
|
|
639
616
|
export function hasRedo(state) {
|
|
640
617
|
return Boolean(getRedoEdits(state));
|
|
641
618
|
}
|
|
619
|
+
|
|
642
620
|
/**
|
|
643
621
|
* Return the current theme.
|
|
644
622
|
*
|
|
@@ -646,10 +624,10 @@ export function hasRedo(state) {
|
|
|
646
624
|
*
|
|
647
625
|
* @return The current theme.
|
|
648
626
|
*/
|
|
649
|
-
|
|
650
627
|
export function getCurrentTheme(state) {
|
|
651
628
|
return getEntityRecord(state, 'root', 'theme', state.currentTheme);
|
|
652
629
|
}
|
|
630
|
+
|
|
653
631
|
/**
|
|
654
632
|
* Return the ID of the current global styles object.
|
|
655
633
|
*
|
|
@@ -657,10 +635,10 @@ export function getCurrentTheme(state) {
|
|
|
657
635
|
*
|
|
658
636
|
* @return The current global styles ID.
|
|
659
637
|
*/
|
|
660
|
-
|
|
661
638
|
export function __experimentalGetCurrentGlobalStylesId(state) {
|
|
662
639
|
return state.currentGlobalStylesId;
|
|
663
640
|
}
|
|
641
|
+
|
|
664
642
|
/**
|
|
665
643
|
* Return theme supports data in the index.
|
|
666
644
|
*
|
|
@@ -668,12 +646,11 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
|
|
|
668
646
|
*
|
|
669
647
|
* @return Index data.
|
|
670
648
|
*/
|
|
671
|
-
|
|
672
649
|
export function getThemeSupports(state) {
|
|
673
650
|
var _getCurrentTheme$them;
|
|
674
|
-
|
|
675
651
|
return (_getCurrentTheme$them = getCurrentTheme(state)?.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
|
|
676
652
|
}
|
|
653
|
+
|
|
677
654
|
/**
|
|
678
655
|
* Returns the embed preview for the given URL.
|
|
679
656
|
*
|
|
@@ -682,10 +659,10 @@ export function getThemeSupports(state) {
|
|
|
682
659
|
*
|
|
683
660
|
* @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
684
661
|
*/
|
|
685
|
-
|
|
686
662
|
export function getEmbedPreview(state, url) {
|
|
687
663
|
return state.embedPreviews[url];
|
|
688
664
|
}
|
|
665
|
+
|
|
689
666
|
/**
|
|
690
667
|
* Determines if the returned preview is an oEmbed link fallback.
|
|
691
668
|
*
|
|
@@ -698,17 +675,15 @@ export function getEmbedPreview(state, url) {
|
|
|
698
675
|
*
|
|
699
676
|
* @return Is the preview for the URL an oEmbed link fallback.
|
|
700
677
|
*/
|
|
701
|
-
|
|
702
678
|
export function isPreviewEmbedFallback(state, url) {
|
|
703
679
|
const preview = state.embedPreviews[url];
|
|
704
680
|
const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
|
|
705
|
-
|
|
706
681
|
if (!preview) {
|
|
707
682
|
return false;
|
|
708
683
|
}
|
|
709
|
-
|
|
710
684
|
return preview.html === oEmbedLinkCheck;
|
|
711
685
|
}
|
|
686
|
+
|
|
712
687
|
/**
|
|
713
688
|
* Returns whether the current user can perform the given action on the given
|
|
714
689
|
* REST resource.
|
|
@@ -726,11 +701,11 @@ export function isPreviewEmbedFallback(state, url) {
|
|
|
726
701
|
* @return Whether or not the user can perform the action,
|
|
727
702
|
* or `undefined` if the OPTIONS request is still being made.
|
|
728
703
|
*/
|
|
729
|
-
|
|
730
704
|
export function canUser(state, action, resource, id) {
|
|
731
705
|
const key = [action, resource, id].filter(Boolean).join('/');
|
|
732
706
|
return state.userPermissions[key];
|
|
733
707
|
}
|
|
708
|
+
|
|
734
709
|
/**
|
|
735
710
|
* Returns whether the current user can edit the given entity.
|
|
736
711
|
*
|
|
@@ -746,17 +721,15 @@ export function canUser(state, action, resource, id) {
|
|
|
746
721
|
* @return Whether or not the user can edit,
|
|
747
722
|
* or `undefined` if the OPTIONS request is still being made.
|
|
748
723
|
*/
|
|
749
|
-
|
|
750
724
|
export function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
751
725
|
const entityConfig = getEntityConfig(state, kind, name);
|
|
752
|
-
|
|
753
726
|
if (!entityConfig) {
|
|
754
727
|
return false;
|
|
755
728
|
}
|
|
756
|
-
|
|
757
729
|
const resource = entityConfig.__unstable_rest_base;
|
|
758
730
|
return canUser(state, 'update', resource, recordId);
|
|
759
731
|
}
|
|
732
|
+
|
|
760
733
|
/**
|
|
761
734
|
* Returns the latest autosaves for the post.
|
|
762
735
|
*
|
|
@@ -769,10 +742,10 @@ export function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
|
769
742
|
*
|
|
770
743
|
* @return An array of autosaves for the post, or undefined if there is none.
|
|
771
744
|
*/
|
|
772
|
-
|
|
773
745
|
export function getAutosaves(state, postType, postId) {
|
|
774
746
|
return state.autosaves[postId];
|
|
775
747
|
}
|
|
748
|
+
|
|
776
749
|
/**
|
|
777
750
|
* Returns the autosave for the post and author.
|
|
778
751
|
*
|
|
@@ -783,15 +756,14 @@ export function getAutosaves(state, postType, postId) {
|
|
|
783
756
|
*
|
|
784
757
|
* @return The autosave for the post and author.
|
|
785
758
|
*/
|
|
786
|
-
|
|
787
759
|
export function getAutosave(state, postType, postId, authorId) {
|
|
788
760
|
if (authorId === undefined) {
|
|
789
761
|
return;
|
|
790
762
|
}
|
|
791
|
-
|
|
792
763
|
const autosaves = state.autosaves[postId];
|
|
793
764
|
return autosaves?.find(autosave => autosave.author === authorId);
|
|
794
765
|
}
|
|
766
|
+
|
|
795
767
|
/**
|
|
796
768
|
* Returns true if the REST request for autosaves has completed.
|
|
797
769
|
*
|
|
@@ -801,10 +773,10 @@ export function getAutosave(state, postType, postId, authorId) {
|
|
|
801
773
|
*
|
|
802
774
|
* @return True if the REST request was completed. False otherwise.
|
|
803
775
|
*/
|
|
804
|
-
|
|
805
776
|
export const hasFetchedAutosaves = createRegistrySelector(select => (state, postType, postId) => {
|
|
806
777
|
return select(STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
|
|
807
778
|
});
|
|
779
|
+
|
|
808
780
|
/**
|
|
809
781
|
* Returns a new reference when edited values have changed. This is useful in
|
|
810
782
|
* inferring where an edit has been made between states by comparison of the
|
|
@@ -823,9 +795,10 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
|
|
|
823
795
|
*
|
|
824
796
|
* @return A value whose reference will change only when an edit occurs.
|
|
825
797
|
*/
|
|
826
|
-
|
|
827
|
-
|
|
798
|
+
export const getReferenceByDistinctEdits = createSelector(
|
|
799
|
+
// This unused state argument is listed here for the documentation generating tool (docgen).
|
|
828
800
|
state => [], state => [state.undo.list.length, state.undo.offset]);
|
|
801
|
+
|
|
829
802
|
/**
|
|
830
803
|
* Retrieve the frontend template used for a given link.
|
|
831
804
|
*
|
|
@@ -834,18 +807,16 @@ state => [], state => [state.undo.list.length, state.undo.offset]);
|
|
|
834
807
|
*
|
|
835
808
|
* @return The template record.
|
|
836
809
|
*/
|
|
837
|
-
|
|
838
810
|
export function __experimentalGetTemplateForLink(state, link) {
|
|
839
811
|
const records = getEntityRecords(state, 'postType', 'wp_template', {
|
|
840
812
|
'find-template': link
|
|
841
813
|
});
|
|
842
|
-
|
|
843
814
|
if (records?.length) {
|
|
844
815
|
return getEditedEntityRecord(state, 'postType', 'wp_template', records[0].id);
|
|
845
816
|
}
|
|
846
|
-
|
|
847
817
|
return null;
|
|
848
818
|
}
|
|
819
|
+
|
|
849
820
|
/**
|
|
850
821
|
* Retrieve the current theme's base global styles
|
|
851
822
|
*
|
|
@@ -853,16 +824,14 @@ export function __experimentalGetTemplateForLink(state, link) {
|
|
|
853
824
|
*
|
|
854
825
|
* @return The Global Styles object.
|
|
855
826
|
*/
|
|
856
|
-
|
|
857
827
|
export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
858
828
|
const currentTheme = getCurrentTheme(state);
|
|
859
|
-
|
|
860
829
|
if (!currentTheme) {
|
|
861
830
|
return null;
|
|
862
831
|
}
|
|
863
|
-
|
|
864
832
|
return state.themeBaseGlobalStyles[currentTheme.stylesheet];
|
|
865
833
|
}
|
|
834
|
+
|
|
866
835
|
/**
|
|
867
836
|
* Return the ID of the current global styles object.
|
|
868
837
|
*
|
|
@@ -870,16 +839,14 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
870
839
|
*
|
|
871
840
|
* @return The current global styles ID.
|
|
872
841
|
*/
|
|
873
|
-
|
|
874
842
|
export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
875
843
|
const currentTheme = getCurrentTheme(state);
|
|
876
|
-
|
|
877
844
|
if (!currentTheme) {
|
|
878
845
|
return null;
|
|
879
846
|
}
|
|
880
|
-
|
|
881
847
|
return state.themeGlobalStyleVariations[currentTheme.stylesheet];
|
|
882
848
|
}
|
|
849
|
+
|
|
883
850
|
/**
|
|
884
851
|
* Retrieve the list of registered block patterns.
|
|
885
852
|
*
|
|
@@ -887,10 +854,10 @@ export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
887
854
|
*
|
|
888
855
|
* @return Block pattern list.
|
|
889
856
|
*/
|
|
890
|
-
|
|
891
857
|
export function getBlockPatterns(state) {
|
|
892
858
|
return state.blockPatterns;
|
|
893
859
|
}
|
|
860
|
+
|
|
894
861
|
/**
|
|
895
862
|
* Retrieve the list of registered block pattern categories.
|
|
896
863
|
*
|
|
@@ -898,10 +865,10 @@ export function getBlockPatterns(state) {
|
|
|
898
865
|
*
|
|
899
866
|
* @return Block pattern category list.
|
|
900
867
|
*/
|
|
901
|
-
|
|
902
868
|
export function getBlockPatternCategories(state) {
|
|
903
869
|
return state.blockPatternCategories;
|
|
904
870
|
}
|
|
871
|
+
|
|
905
872
|
/**
|
|
906
873
|
* Returns the revisions of the current global styles theme.
|
|
907
874
|
*
|
|
@@ -909,14 +876,11 @@ export function getBlockPatternCategories(state) {
|
|
|
909
876
|
*
|
|
910
877
|
* @return The current global styles.
|
|
911
878
|
*/
|
|
912
|
-
|
|
913
879
|
export function getCurrentThemeGlobalStylesRevisions(state) {
|
|
914
880
|
const currentGlobalStylesId = __experimentalGetCurrentGlobalStylesId(state);
|
|
915
|
-
|
|
916
881
|
if (!currentGlobalStylesId) {
|
|
917
882
|
return null;
|
|
918
883
|
}
|
|
919
|
-
|
|
920
884
|
return state.themeGlobalStyleRevisions[currentGlobalStylesId];
|
|
921
885
|
}
|
|
922
886
|
//# sourceMappingURL=selectors.js.map
|