@wordpress/core-data 4.6.0 → 4.9.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 +11 -1
- package/README.md +209 -119
- package/build/actions.js.map +1 -1
- package/build/batch/create-batch.js +1 -1
- package/build/batch/create-batch.js.map +1 -1
- package/build/entities.js +49 -35
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/entities.js +6 -0
- package/build/entity-types/entities.js.map +1 -0
- package/build/hooks/constants.js +0 -2
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +38 -0
- package/build/hooks/index.js.map +1 -0
- package/build/hooks/use-entity-record.js +22 -8
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +21 -8
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/index.js +17 -21
- package/build/index.js.map +1 -1
- package/build/queried-data/selectors.js.map +1 -1
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +206 -169
- package/build/selectors.js.map +1 -1
- package/build/utils/forward-resolver.js.map +1 -1
- package/build/utils/on-sub-key.js.map +1 -1
- package/build/utils/with-weak-map-cache.js +1 -7
- package/build/utils/with-weak-map-cache.js.map +1 -1
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/create-batch.js +2 -2
- package/build-module/batch/create-batch.js.map +1 -1
- package/build-module/entities.js +49 -35
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/entity-types/entities.js +2 -0
- package/build-module/entity-types/entities.js.map +1 -0
- package/build-module/hooks/constants.js +0 -1
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +18 -7
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +17 -7
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/index.js +2 -3
- package/build-module/index.js.map +1 -1
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +203 -166
- package/build-module/selectors.js.map +1 -1
- package/build-module/utils/forward-resolver.js.map +1 -1
- package/build-module/utils/on-sub-key.js.map +1 -1
- package/build-module/utils/with-weak-map-cache.js +1 -6
- package/build-module/utils/with-weak-map-cache.js.map +1 -1
- package/package.json +12 -12
- package/src/actions.js +389 -372
- package/src/batch/create-batch.js +2 -2
- package/src/entities.ts +357 -135
- package/src/entity-provider.js +4 -6
- package/src/entity-types/attachment.ts +4 -3
- package/src/entity-types/comment.ts +4 -3
- package/src/entity-types/entities.ts +130 -0
- package/src/entity-types/index.ts +115 -20
- package/src/entity-types/menu-location.ts +4 -3
- package/src/entity-types/nav-menu-item.ts +4 -3
- package/src/entity-types/nav-menu.ts +3 -3
- package/src/entity-types/page.ts +3 -3
- package/src/entity-types/plugin.ts +3 -3
- package/src/entity-types/post.ts +3 -3
- package/src/entity-types/settings.ts +3 -3
- package/src/entity-types/sidebar.ts +4 -3
- package/src/entity-types/taxonomy.ts +4 -3
- package/src/entity-types/theme.ts +3 -3
- package/src/entity-types/type.ts +3 -3
- package/src/entity-types/user.ts +3 -3
- package/src/entity-types/widget-type.ts +4 -3
- package/src/entity-types/widget.ts +3 -3
- package/src/entity-types/wp-template-part.ts +4 -3
- package/src/entity-types/wp-template.ts +4 -3
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +2 -4
- package/src/hooks/constants.ts +1 -2
- package/src/hooks/index.ts +8 -0
- package/src/hooks/test/use-query-select.js +4 -2
- package/src/hooks/use-entity-record.ts +31 -9
- package/src/hooks/use-entity-records.ts +28 -30
- package/src/hooks/use-query-select.ts +26 -24
- package/src/index.js +2 -3
- package/src/locks/test/selectors.js +2 -1
- package/src/queried-data/selectors.js +2 -8
- package/src/resolvers.js +344 -325
- package/src/selectors.ts +639 -296
- package/src/test/resolvers.js +1 -3
- package/src/test/selectors.js +1 -2
- package/src/utils/forward-resolver.js +6 -5
- package/src/utils/on-sub-key.js +20 -20
- package/src/utils/with-weak-map-cache.js +1 -6
package/build/selectors.js
CHANGED
|
@@ -28,8 +28,7 @@ exports.getEntity = getEntity;
|
|
|
28
28
|
exports.getEntityConfig = getEntityConfig;
|
|
29
29
|
exports.getEntityRecord = void 0;
|
|
30
30
|
exports.getEntityRecordEdits = getEntityRecordEdits;
|
|
31
|
-
exports.getEntityRecordNonTransientEdits = void 0;
|
|
32
|
-
exports.getEntityRecords = getEntityRecords;
|
|
31
|
+
exports.getEntityRecords = exports.getEntityRecordNonTransientEdits = void 0;
|
|
33
32
|
exports.getLastEntityDeleteError = getLastEntityDeleteError;
|
|
34
33
|
exports.getLastEntitySaveError = getLastEntitySaveError;
|
|
35
34
|
exports.getRawEntityRecord = void 0;
|
|
@@ -91,10 +90,10 @@ const EMPTY_OBJECT = {};
|
|
|
91
90
|
* Returns true if a request is in progress for embed preview data, or false
|
|
92
91
|
* otherwise.
|
|
93
92
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
93
|
+
* @param state Data state.
|
|
94
|
+
* @param url URL the preview would be for.
|
|
96
95
|
*
|
|
97
|
-
* @return
|
|
96
|
+
* @return Whether a request is in progress for an embed preview.
|
|
98
97
|
*/
|
|
99
98
|
|
|
100
99
|
const isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (state, url) => {
|
|
@@ -105,10 +104,10 @@ const isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (st
|
|
|
105
104
|
*
|
|
106
105
|
* @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
|
|
107
106
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @param
|
|
110
|
-
*
|
|
111
|
-
* @return
|
|
107
|
+
* @param state Data state.
|
|
108
|
+
* @param query Optional object of query parameters to
|
|
109
|
+
* include with request.
|
|
110
|
+
* @return Authors list.
|
|
112
111
|
*/
|
|
113
112
|
|
|
114
113
|
exports.isRequestingEmbedPreview = isRequestingEmbedPreview;
|
|
@@ -124,9 +123,9 @@ function getAuthors(state, query) {
|
|
|
124
123
|
/**
|
|
125
124
|
* Returns the current user.
|
|
126
125
|
*
|
|
127
|
-
* @param
|
|
126
|
+
* @param state Data state.
|
|
128
127
|
*
|
|
129
|
-
* @return
|
|
128
|
+
* @return Current user object.
|
|
130
129
|
*/
|
|
131
130
|
|
|
132
131
|
|
|
@@ -136,10 +135,10 @@ function getCurrentUser(state) {
|
|
|
136
135
|
/**
|
|
137
136
|
* Returns all the users returned by a query ID.
|
|
138
137
|
*
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
138
|
+
* @param state Data state.
|
|
139
|
+
* @param queryID Query ID.
|
|
141
140
|
*
|
|
142
|
-
* @return
|
|
141
|
+
* @return Users list.
|
|
143
142
|
*/
|
|
144
143
|
|
|
145
144
|
|
|
@@ -151,10 +150,10 @@ const getUserQueryResults = (0, _rememo.default)((state, queryID) => {
|
|
|
151
150
|
* Returns the loaded entities for the given kind.
|
|
152
151
|
*
|
|
153
152
|
* @deprecated since WordPress 6.0. Use getEntitiesConfig instead
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
153
|
+
* @param state Data state.
|
|
154
|
+
* @param kind Entity kind.
|
|
156
155
|
*
|
|
157
|
-
* @return
|
|
156
|
+
* @return Array of entities with config matching kind.
|
|
158
157
|
*/
|
|
159
158
|
|
|
160
159
|
exports.getUserQueryResults = getUserQueryResults;
|
|
@@ -169,10 +168,10 @@ function getEntitiesByKind(state, kind) {
|
|
|
169
168
|
/**
|
|
170
169
|
* Returns the loaded entities for the given kind.
|
|
171
170
|
*
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
171
|
+
* @param state Data state.
|
|
172
|
+
* @param kind Entity kind.
|
|
174
173
|
*
|
|
175
|
-
* @return
|
|
174
|
+
* @return Array of entities with config matching kind.
|
|
176
175
|
*/
|
|
177
176
|
|
|
178
177
|
|
|
@@ -185,11 +184,11 @@ function getEntitiesConfig(state, kind) {
|
|
|
185
184
|
* Returns the entity config given its kind and name.
|
|
186
185
|
*
|
|
187
186
|
* @deprecated since WordPress 6.0. Use getEntityConfig instead
|
|
188
|
-
* @param
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
187
|
+
* @param state Data state.
|
|
188
|
+
* @param kind Entity kind.
|
|
189
|
+
* @param name Entity name.
|
|
191
190
|
*
|
|
192
|
-
* @return
|
|
191
|
+
* @return Entity config
|
|
193
192
|
*/
|
|
194
193
|
|
|
195
194
|
|
|
@@ -203,11 +202,11 @@ function getEntity(state, kind, name) {
|
|
|
203
202
|
/**
|
|
204
203
|
* Returns the entity config given its kind and name.
|
|
205
204
|
*
|
|
206
|
-
* @param
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
205
|
+
* @param state Data state.
|
|
206
|
+
* @param kind Entity kind.
|
|
207
|
+
* @param name Entity name.
|
|
209
208
|
*
|
|
210
|
-
* @return
|
|
209
|
+
* @return Entity config
|
|
211
210
|
*/
|
|
212
211
|
|
|
213
212
|
|
|
@@ -217,21 +216,39 @@ function getEntityConfig(state, kind, name) {
|
|
|
217
216
|
name
|
|
218
217
|
});
|
|
219
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* GetEntityRecord is declared as an *interface*, but it actually describes
|
|
221
|
+
* the specifies the getEntityRecord *function* signature. It may seem unusual,
|
|
222
|
+
* but it's just how TypeScript implements function overloading.
|
|
223
|
+
*
|
|
224
|
+
* More accurately, GetEntityRecord distinguishes between two different signatures
|
|
225
|
+
* the getEntityRecord selector has:
|
|
226
|
+
*
|
|
227
|
+
* 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >
|
|
228
|
+
* 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>
|
|
229
|
+
*
|
|
230
|
+
* Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
|
|
231
|
+
* we can't use a single function signature with a return type such as:
|
|
232
|
+
*
|
|
233
|
+
* Fields extends undefined
|
|
234
|
+
* ? EntityRecordOf< K, N, C >
|
|
235
|
+
* : Partial< EntityRecordOf< K, N, C > >
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
|
|
220
239
|
/**
|
|
221
240
|
* Returns the Entity's record object by key. Returns `null` if the value is not
|
|
222
241
|
* yet received, undefined if the value entity is known to not exist, or the
|
|
223
242
|
* entity object if it exists and is received.
|
|
224
243
|
*
|
|
225
|
-
* @param
|
|
226
|
-
* @param
|
|
227
|
-
* @param
|
|
228
|
-
* @param
|
|
229
|
-
* @param
|
|
244
|
+
* @param state State tree
|
|
245
|
+
* @param kind Entity kind.
|
|
246
|
+
* @param name Entity name.
|
|
247
|
+
* @param key Record's key
|
|
248
|
+
* @param query Optional query.
|
|
230
249
|
*
|
|
231
|
-
* @return
|
|
250
|
+
* @return Record.
|
|
232
251
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
252
|
const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) => {
|
|
236
253
|
var _query$context, _queriedState$items$c;
|
|
237
254
|
|
|
@@ -281,12 +298,12 @@ const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) =>
|
|
|
281
298
|
/**
|
|
282
299
|
* 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.
|
|
283
300
|
*
|
|
284
|
-
* @param
|
|
285
|
-
* @param
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
301
|
+
* @param state State tree
|
|
302
|
+
* @param kind Entity kind.
|
|
303
|
+
* @param name Entity name.
|
|
304
|
+
* @param key Record's key
|
|
288
305
|
*
|
|
289
|
-
* @return
|
|
306
|
+
* @return Record.
|
|
290
307
|
*/
|
|
291
308
|
|
|
292
309
|
exports.getEntityRecord = getEntityRecord;
|
|
@@ -298,12 +315,12 @@ function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
|
298
315
|
* Returns the entity's record object by key,
|
|
299
316
|
* with its attributes mapped to their raw values.
|
|
300
317
|
*
|
|
301
|
-
* @param
|
|
302
|
-
* @param
|
|
303
|
-
* @param
|
|
304
|
-
* @param
|
|
318
|
+
* @param state State tree.
|
|
319
|
+
* @param kind Entity kind.
|
|
320
|
+
* @param name Entity name.
|
|
321
|
+
* @param key Record's key.
|
|
305
322
|
*
|
|
306
|
-
* @return
|
|
323
|
+
* @return Object with the entity's raw attributes.
|
|
307
324
|
*/
|
|
308
325
|
|
|
309
326
|
|
|
@@ -331,12 +348,12 @@ const getRawEntityRecord = (0, _rememo.default)((state, kind, name, key) => {
|
|
|
331
348
|
* Returns true if records have been received for the given set of parameters,
|
|
332
349
|
* or false otherwise.
|
|
333
350
|
*
|
|
334
|
-
* @param
|
|
335
|
-
* @param
|
|
336
|
-
* @param
|
|
337
|
-
* @param
|
|
351
|
+
* @param state State tree
|
|
352
|
+
* @param kind Entity kind.
|
|
353
|
+
* @param name Entity name.
|
|
354
|
+
* @param query Optional terms query.
|
|
338
355
|
*
|
|
339
|
-
* @return
|
|
356
|
+
* @return Whether entity records have been received.
|
|
340
357
|
*/
|
|
341
358
|
|
|
342
359
|
exports.getRawEntityRecord = getRawEntityRecord;
|
|
@@ -345,18 +362,36 @@ function hasEntityRecords(state, kind, name, query) {
|
|
|
345
362
|
return Array.isArray(getEntityRecords(state, kind, name, query));
|
|
346
363
|
}
|
|
347
364
|
/**
|
|
348
|
-
*
|
|
365
|
+
* GetEntityRecord is declared as an *interface*, but it actually describes
|
|
366
|
+
* the specifies the getEntityRecord *function* signature. It may seem unusual,
|
|
367
|
+
* but it's just how TypeScript implements function overloading.
|
|
368
|
+
*
|
|
369
|
+
* More accurately, GetEntityRecord distinguishes between two different signatures
|
|
370
|
+
* the getEntityRecord selector has:
|
|
349
371
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* @param {string} name Entity name.
|
|
353
|
-
* @param {?Object} query Optional terms query.
|
|
372
|
+
* 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >[]
|
|
373
|
+
* 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>[]
|
|
354
374
|
*
|
|
355
|
-
*
|
|
375
|
+
* Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
|
|
376
|
+
* we can't use a single function signature with a return type such as:
|
|
377
|
+
*
|
|
378
|
+
* Fields extends undefined
|
|
379
|
+
* ? EntityRecordOf< K, N, C >[]
|
|
380
|
+
* : Partial< EntityRecordOf< K, N, C > >[]
|
|
356
381
|
*/
|
|
357
382
|
|
|
358
383
|
|
|
359
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Returns the Entity's records.
|
|
386
|
+
*
|
|
387
|
+
* @param state State tree
|
|
388
|
+
* @param kind Entity kind.
|
|
389
|
+
* @param name Entity name.
|
|
390
|
+
* @param query Optional terms query.
|
|
391
|
+
*
|
|
392
|
+
* @return Records.
|
|
393
|
+
*/
|
|
394
|
+
const getEntityRecords = (state, kind, name, query) => {
|
|
360
395
|
// Queried data state is prepopulated for all known entities. If this is not
|
|
361
396
|
// assigned for the given parameters, then it is known to not exist.
|
|
362
397
|
const queriedState = (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData']);
|
|
@@ -366,16 +401,17 @@ function getEntityRecords(state, kind, name, query) {
|
|
|
366
401
|
}
|
|
367
402
|
|
|
368
403
|
return (0, _queriedData.getQueriedItems)(queriedState, query);
|
|
369
|
-
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
exports.getEntityRecords = getEntityRecords;
|
|
407
|
+
|
|
370
408
|
/**
|
|
371
409
|
* Returns the list of dirty entity records.
|
|
372
410
|
*
|
|
373
|
-
* @param
|
|
411
|
+
* @param state State tree.
|
|
374
412
|
*
|
|
375
|
-
* @return
|
|
413
|
+
* @return The list of updated records
|
|
376
414
|
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
415
|
const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
380
416
|
const {
|
|
381
417
|
entities: {
|
|
@@ -412,9 +448,9 @@ const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
|
412
448
|
/**
|
|
413
449
|
* Returns the list of entities currently being saved.
|
|
414
450
|
*
|
|
415
|
-
* @param
|
|
451
|
+
* @param state State tree.
|
|
416
452
|
*
|
|
417
|
-
* @return
|
|
453
|
+
* @return The list of records being saved.
|
|
418
454
|
*/
|
|
419
455
|
|
|
420
456
|
|
|
@@ -454,12 +490,12 @@ const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
|
|
|
454
490
|
/**
|
|
455
491
|
* Returns the specified entity record's edits.
|
|
456
492
|
*
|
|
457
|
-
* @param
|
|
458
|
-
* @param
|
|
459
|
-
* @param
|
|
460
|
-
* @param
|
|
493
|
+
* @param state State tree.
|
|
494
|
+
* @param kind Entity kind.
|
|
495
|
+
* @param name Entity name.
|
|
496
|
+
* @param recordId Record ID.
|
|
461
497
|
*
|
|
462
|
-
* @return
|
|
498
|
+
* @return The entity record's edits.
|
|
463
499
|
*/
|
|
464
500
|
|
|
465
501
|
|
|
@@ -475,12 +511,12 @@ function getEntityRecordEdits(state, kind, name, recordId) {
|
|
|
475
511
|
* are not considered for change detection.
|
|
476
512
|
* They are defined in the entity's config.
|
|
477
513
|
*
|
|
478
|
-
* @param
|
|
479
|
-
* @param
|
|
480
|
-
* @param
|
|
481
|
-
* @param
|
|
514
|
+
* @param state State tree.
|
|
515
|
+
* @param kind Entity kind.
|
|
516
|
+
* @param name Entity name.
|
|
517
|
+
* @param recordId Record ID.
|
|
482
518
|
*
|
|
483
|
-
* @return
|
|
519
|
+
* @return The entity record's non transient edits.
|
|
484
520
|
*/
|
|
485
521
|
|
|
486
522
|
|
|
@@ -506,12 +542,12 @@ const getEntityRecordNonTransientEdits = (0, _rememo.default)((state, kind, name
|
|
|
506
542
|
* Returns true if the specified entity record has edits,
|
|
507
543
|
* and false otherwise.
|
|
508
544
|
*
|
|
509
|
-
* @param
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
* @param
|
|
545
|
+
* @param state State tree.
|
|
546
|
+
* @param kind Entity kind.
|
|
547
|
+
* @param name Entity name.
|
|
548
|
+
* @param recordId Record ID.
|
|
513
549
|
*
|
|
514
|
-
* @return
|
|
550
|
+
* @return Whether the entity record has edits or not.
|
|
515
551
|
*/
|
|
516
552
|
|
|
517
553
|
exports.getEntityRecordNonTransientEdits = getEntityRecordNonTransientEdits;
|
|
@@ -522,12 +558,12 @@ function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
522
558
|
/**
|
|
523
559
|
* Returns the specified entity record, merged with its edits.
|
|
524
560
|
*
|
|
525
|
-
* @param
|
|
526
|
-
* @param
|
|
527
|
-
* @param
|
|
528
|
-
* @param
|
|
561
|
+
* @param state State tree.
|
|
562
|
+
* @param kind Entity kind.
|
|
563
|
+
* @param name Entity name.
|
|
564
|
+
* @param recordId Record ID.
|
|
529
565
|
*
|
|
530
|
-
* @return
|
|
566
|
+
* @return The entity record, merged with its edits.
|
|
531
567
|
*/
|
|
532
568
|
|
|
533
569
|
|
|
@@ -542,12 +578,12 @@ const getEditedEntityRecord = (0, _rememo.default)((state, kind, name, recordId)
|
|
|
542
578
|
/**
|
|
543
579
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
544
580
|
*
|
|
545
|
-
* @param
|
|
546
|
-
* @param
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
581
|
+
* @param state State tree.
|
|
582
|
+
* @param kind Entity kind.
|
|
583
|
+
* @param name Entity name.
|
|
584
|
+
* @param recordId Record ID.
|
|
549
585
|
*
|
|
550
|
-
* @return
|
|
586
|
+
* @return Whether the entity record is autosaving or not.
|
|
551
587
|
*/
|
|
552
588
|
|
|
553
589
|
exports.getEditedEntityRecord = getEditedEntityRecord;
|
|
@@ -562,12 +598,12 @@ function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
562
598
|
/**
|
|
563
599
|
* Returns true if the specified entity record is saving, and false otherwise.
|
|
564
600
|
*
|
|
565
|
-
* @param
|
|
566
|
-
* @param
|
|
567
|
-
* @param
|
|
568
|
-
* @param
|
|
601
|
+
* @param state State tree.
|
|
602
|
+
* @param kind Entity kind.
|
|
603
|
+
* @param name Entity name.
|
|
604
|
+
* @param recordId Record ID.
|
|
569
605
|
*
|
|
570
|
-
* @return
|
|
606
|
+
* @return Whether the entity record is saving or not.
|
|
571
607
|
*/
|
|
572
608
|
|
|
573
609
|
|
|
@@ -577,12 +613,12 @@ function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
577
613
|
/**
|
|
578
614
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
579
615
|
*
|
|
580
|
-
* @param
|
|
581
|
-
* @param
|
|
582
|
-
* @param
|
|
583
|
-
* @param
|
|
616
|
+
* @param state State tree.
|
|
617
|
+
* @param kind Entity kind.
|
|
618
|
+
* @param name Entity name.
|
|
619
|
+
* @param recordId Record ID.
|
|
584
620
|
*
|
|
585
|
-
* @return
|
|
621
|
+
* @return Whether the entity record is deleting or not.
|
|
586
622
|
*/
|
|
587
623
|
|
|
588
624
|
|
|
@@ -592,12 +628,12 @@ function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
592
628
|
/**
|
|
593
629
|
* Returns the specified entity record's last save error.
|
|
594
630
|
*
|
|
595
|
-
* @param
|
|
596
|
-
* @param
|
|
597
|
-
* @param
|
|
598
|
-
* @param
|
|
631
|
+
* @param state State tree.
|
|
632
|
+
* @param kind Entity kind.
|
|
633
|
+
* @param name Entity name.
|
|
634
|
+
* @param recordId Record ID.
|
|
599
635
|
*
|
|
600
|
-
* @return
|
|
636
|
+
* @return The entity record's save error.
|
|
601
637
|
*/
|
|
602
638
|
|
|
603
639
|
|
|
@@ -607,12 +643,12 @@ function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
607
643
|
/**
|
|
608
644
|
* Returns the specified entity record's last delete error.
|
|
609
645
|
*
|
|
610
|
-
* @param
|
|
611
|
-
* @param
|
|
612
|
-
* @param
|
|
613
|
-
* @param
|
|
646
|
+
* @param state State tree.
|
|
647
|
+
* @param kind Entity kind.
|
|
648
|
+
* @param name Entity name.
|
|
649
|
+
* @param recordId Record ID.
|
|
614
650
|
*
|
|
615
|
-
* @return
|
|
651
|
+
* @return The entity record's save error.
|
|
616
652
|
*/
|
|
617
653
|
|
|
618
654
|
|
|
@@ -626,9 +662,9 @@ function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
|
626
662
|
* of the history stack we are at. 0 is the
|
|
627
663
|
* last edit, -1 is the second last, and so on.
|
|
628
664
|
*
|
|
629
|
-
* @param
|
|
665
|
+
* @param state State tree.
|
|
630
666
|
*
|
|
631
|
-
* @return
|
|
667
|
+
* @return The current undo offset.
|
|
632
668
|
*/
|
|
633
669
|
|
|
634
670
|
|
|
@@ -639,9 +675,9 @@ function getCurrentUndoOffset(state) {
|
|
|
639
675
|
* Returns the previous edit from the current undo offset
|
|
640
676
|
* for the entity records edits history, if any.
|
|
641
677
|
*
|
|
642
|
-
* @param
|
|
678
|
+
* @param state State tree.
|
|
643
679
|
*
|
|
644
|
-
* @return
|
|
680
|
+
* @return The edit.
|
|
645
681
|
*/
|
|
646
682
|
|
|
647
683
|
|
|
@@ -652,9 +688,9 @@ function getUndoEdit(state) {
|
|
|
652
688
|
* Returns the next edit from the current undo offset
|
|
653
689
|
* for the entity records edits history, if any.
|
|
654
690
|
*
|
|
655
|
-
* @param
|
|
691
|
+
* @param state State tree.
|
|
656
692
|
*
|
|
657
|
-
* @return
|
|
693
|
+
* @return The edit.
|
|
658
694
|
*/
|
|
659
695
|
|
|
660
696
|
|
|
@@ -665,9 +701,9 @@ function getRedoEdit(state) {
|
|
|
665
701
|
* Returns true if there is a previous edit from the current undo offset
|
|
666
702
|
* for the entity records edits history, and false otherwise.
|
|
667
703
|
*
|
|
668
|
-
* @param
|
|
704
|
+
* @param state State tree.
|
|
669
705
|
*
|
|
670
|
-
* @return
|
|
706
|
+
* @return Whether there is a previous edit or not.
|
|
671
707
|
*/
|
|
672
708
|
|
|
673
709
|
|
|
@@ -678,9 +714,9 @@ function hasUndo(state) {
|
|
|
678
714
|
* Returns true if there is a next edit from the current undo offset
|
|
679
715
|
* for the entity records edits history, and false otherwise.
|
|
680
716
|
*
|
|
681
|
-
* @param
|
|
717
|
+
* @param state State tree.
|
|
682
718
|
*
|
|
683
|
-
* @return
|
|
719
|
+
* @return Whether there is a next edit or not.
|
|
684
720
|
*/
|
|
685
721
|
|
|
686
722
|
|
|
@@ -690,9 +726,9 @@ function hasRedo(state) {
|
|
|
690
726
|
/**
|
|
691
727
|
* Return the current theme.
|
|
692
728
|
*
|
|
693
|
-
* @param
|
|
729
|
+
* @param state Data state.
|
|
694
730
|
*
|
|
695
|
-
* @return
|
|
731
|
+
* @return The current theme.
|
|
696
732
|
*/
|
|
697
733
|
|
|
698
734
|
|
|
@@ -702,9 +738,9 @@ function getCurrentTheme(state) {
|
|
|
702
738
|
/**
|
|
703
739
|
* Return the ID of the current global styles object.
|
|
704
740
|
*
|
|
705
|
-
* @param
|
|
741
|
+
* @param state Data state.
|
|
706
742
|
*
|
|
707
|
-
* @return
|
|
743
|
+
* @return The current global styles ID.
|
|
708
744
|
*/
|
|
709
745
|
|
|
710
746
|
|
|
@@ -714,9 +750,9 @@ function __experimentalGetCurrentGlobalStylesId(state) {
|
|
|
714
750
|
/**
|
|
715
751
|
* Return theme supports data in the index.
|
|
716
752
|
*
|
|
717
|
-
* @param
|
|
753
|
+
* @param state Data state.
|
|
718
754
|
*
|
|
719
|
-
* @return
|
|
755
|
+
* @return Index data.
|
|
720
756
|
*/
|
|
721
757
|
|
|
722
758
|
|
|
@@ -728,10 +764,10 @@ function getThemeSupports(state) {
|
|
|
728
764
|
/**
|
|
729
765
|
* Returns the embed preview for the given URL.
|
|
730
766
|
*
|
|
731
|
-
* @param
|
|
732
|
-
* @param
|
|
767
|
+
* @param state Data state.
|
|
768
|
+
* @param url Embedded URL.
|
|
733
769
|
*
|
|
734
|
-
* @return
|
|
770
|
+
* @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
735
771
|
*/
|
|
736
772
|
|
|
737
773
|
|
|
@@ -745,10 +781,10 @@ function getEmbedPreview(state, url) {
|
|
|
745
781
|
* We need to be able to determine if a URL is embeddable or not, based on what we
|
|
746
782
|
* get back from the oEmbed preview API.
|
|
747
783
|
*
|
|
748
|
-
* @param
|
|
749
|
-
* @param
|
|
784
|
+
* @param state Data state.
|
|
785
|
+
* @param url Embedded URL.
|
|
750
786
|
*
|
|
751
|
-
* @return
|
|
787
|
+
* @return Is the preview for the URL an oEmbed link fallback.
|
|
752
788
|
*/
|
|
753
789
|
|
|
754
790
|
|
|
@@ -771,12 +807,12 @@ function isPreviewEmbedFallback(state, url) {
|
|
|
771
807
|
*
|
|
772
808
|
* https://developer.wordpress.org/rest-api/reference/
|
|
773
809
|
*
|
|
774
|
-
* @param
|
|
775
|
-
* @param
|
|
776
|
-
* @param
|
|
777
|
-
* @param
|
|
810
|
+
* @param state Data state.
|
|
811
|
+
* @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
812
|
+
* @param resource REST resource to check, e.g. 'media' or 'posts'.
|
|
813
|
+
* @param id Optional ID of the rest resource to check.
|
|
778
814
|
*
|
|
779
|
-
* @return
|
|
815
|
+
* @return Whether or not the user can perform the action,
|
|
780
816
|
* or `undefined` if the OPTIONS request is still being made.
|
|
781
817
|
*/
|
|
782
818
|
|
|
@@ -793,11 +829,11 @@ function canUser(state, action, resource, id) {
|
|
|
793
829
|
*
|
|
794
830
|
* https://developer.wordpress.org/rest-api/reference/
|
|
795
831
|
*
|
|
796
|
-
* @param
|
|
797
|
-
* @param
|
|
798
|
-
* @param
|
|
799
|
-
* @param
|
|
800
|
-
* @return
|
|
832
|
+
* @param state Data state.
|
|
833
|
+
* @param kind Entity kind.
|
|
834
|
+
* @param name Entity name.
|
|
835
|
+
* @param recordId Record's id.
|
|
836
|
+
* @return Whether or not the user can edit,
|
|
801
837
|
* or `undefined` if the OPTIONS request is still being made.
|
|
802
838
|
*/
|
|
803
839
|
|
|
@@ -818,11 +854,11 @@ function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
|
818
854
|
* May return multiple autosaves since the backend stores one autosave per
|
|
819
855
|
* author for each post.
|
|
820
856
|
*
|
|
821
|
-
* @param
|
|
822
|
-
* @param
|
|
823
|
-
* @param
|
|
857
|
+
* @param state State tree.
|
|
858
|
+
* @param postType The type of the parent post.
|
|
859
|
+
* @param postId The id of the parent post.
|
|
824
860
|
*
|
|
825
|
-
* @return
|
|
861
|
+
* @return An array of autosaves for the post, or undefined if there is none.
|
|
826
862
|
*/
|
|
827
863
|
|
|
828
864
|
|
|
@@ -832,12 +868,12 @@ function getAutosaves(state, postType, postId) {
|
|
|
832
868
|
/**
|
|
833
869
|
* Returns the autosave for the post and author.
|
|
834
870
|
*
|
|
835
|
-
* @param
|
|
836
|
-
* @param
|
|
837
|
-
* @param
|
|
838
|
-
* @param
|
|
871
|
+
* @param state State tree.
|
|
872
|
+
* @param postType The type of the parent post.
|
|
873
|
+
* @param postId The id of the parent post.
|
|
874
|
+
* @param authorId The id of the author.
|
|
839
875
|
*
|
|
840
|
-
* @return
|
|
876
|
+
* @return The autosave for the post and author.
|
|
841
877
|
*/
|
|
842
878
|
|
|
843
879
|
|
|
@@ -854,11 +890,11 @@ function getAutosave(state, postType, postId, authorId) {
|
|
|
854
890
|
/**
|
|
855
891
|
* Returns true if the REST request for autosaves has completed.
|
|
856
892
|
*
|
|
857
|
-
* @param
|
|
858
|
-
* @param
|
|
859
|
-
* @param
|
|
893
|
+
* @param state State tree.
|
|
894
|
+
* @param postType The type of the parent post.
|
|
895
|
+
* @param postId The id of the parent post.
|
|
860
896
|
*
|
|
861
|
-
* @return
|
|
897
|
+
* @return True if the REST request was completed. False otherwise.
|
|
862
898
|
*/
|
|
863
899
|
|
|
864
900
|
|
|
@@ -879,20 +915,21 @@ const hasFetchedAutosaves = (0, _data.createRegistrySelector)(select => (state,
|
|
|
879
915
|
* );
|
|
880
916
|
* ```
|
|
881
917
|
*
|
|
882
|
-
* @param
|
|
918
|
+
* @param state Editor state.
|
|
883
919
|
*
|
|
884
|
-
* @return
|
|
920
|
+
* @return A value whose reference will change only when an edit occurs.
|
|
885
921
|
*/
|
|
886
922
|
|
|
887
923
|
exports.hasFetchedAutosaves = hasFetchedAutosaves;
|
|
888
|
-
const getReferenceByDistinctEdits = (0, _rememo.default)(
|
|
924
|
+
const getReferenceByDistinctEdits = (0, _rememo.default)( // This unused state argument is listed here for the documentation generating tool (docgen).
|
|
925
|
+
state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
|
|
889
926
|
/**
|
|
890
927
|
* Retrieve the frontend template used for a given link.
|
|
891
928
|
*
|
|
892
|
-
* @param
|
|
893
|
-
* @param
|
|
929
|
+
* @param state Editor state.
|
|
930
|
+
* @param link Link.
|
|
894
931
|
*
|
|
895
|
-
* @return
|
|
932
|
+
* @return The template record.
|
|
896
933
|
*/
|
|
897
934
|
|
|
898
935
|
exports.getReferenceByDistinctEdits = getReferenceByDistinctEdits;
|
|
@@ -912,9 +949,9 @@ function __experimentalGetTemplateForLink(state, link) {
|
|
|
912
949
|
/**
|
|
913
950
|
* Retrieve the current theme's base global styles
|
|
914
951
|
*
|
|
915
|
-
* @param
|
|
952
|
+
* @param state Editor state.
|
|
916
953
|
*
|
|
917
|
-
* @return
|
|
954
|
+
* @return The Global Styles object.
|
|
918
955
|
*/
|
|
919
956
|
|
|
920
957
|
|
|
@@ -930,9 +967,9 @@ function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
930
967
|
/**
|
|
931
968
|
* Return the ID of the current global styles object.
|
|
932
969
|
*
|
|
933
|
-
* @param
|
|
970
|
+
* @param state Data state.
|
|
934
971
|
*
|
|
935
|
-
* @return
|
|
972
|
+
* @return The current global styles ID.
|
|
936
973
|
*/
|
|
937
974
|
|
|
938
975
|
|
|
@@ -948,9 +985,9 @@ function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
948
985
|
/**
|
|
949
986
|
* Retrieve the list of registered block patterns.
|
|
950
987
|
*
|
|
951
|
-
* @param
|
|
988
|
+
* @param state Data state.
|
|
952
989
|
*
|
|
953
|
-
* @return
|
|
990
|
+
* @return Block pattern list.
|
|
954
991
|
*/
|
|
955
992
|
|
|
956
993
|
|
|
@@ -960,9 +997,9 @@ function getBlockPatterns(state) {
|
|
|
960
997
|
/**
|
|
961
998
|
* Retrieve the list of registered block pattern categories.
|
|
962
999
|
*
|
|
963
|
-
* @param
|
|
1000
|
+
* @param state Data state.
|
|
964
1001
|
*
|
|
965
|
-
* @return
|
|
1002
|
+
* @return Block pattern category list.
|
|
966
1003
|
*/
|
|
967
1004
|
|
|
968
1005
|
|