@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.
Files changed (98) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +209 -119
  3. package/build/actions.js.map +1 -1
  4. package/build/batch/create-batch.js +1 -1
  5. package/build/batch/create-batch.js.map +1 -1
  6. package/build/entities.js +49 -35
  7. package/build/entities.js.map +1 -1
  8. package/build/entity-provider.js.map +1 -1
  9. package/build/entity-types/entities.js +6 -0
  10. package/build/entity-types/entities.js.map +1 -0
  11. package/build/hooks/constants.js +0 -2
  12. package/build/hooks/constants.js.map +1 -1
  13. package/build/hooks/index.js +38 -0
  14. package/build/hooks/index.js.map +1 -0
  15. package/build/hooks/use-entity-record.js +22 -8
  16. package/build/hooks/use-entity-record.js.map +1 -1
  17. package/build/hooks/use-entity-records.js +21 -8
  18. package/build/hooks/use-entity-records.js.map +1 -1
  19. package/build/hooks/use-query-select.js.map +1 -1
  20. package/build/index.js +17 -21
  21. package/build/index.js.map +1 -1
  22. package/build/queried-data/selectors.js.map +1 -1
  23. package/build/resolvers.js.map +1 -1
  24. package/build/selectors.js +206 -169
  25. package/build/selectors.js.map +1 -1
  26. package/build/utils/forward-resolver.js.map +1 -1
  27. package/build/utils/on-sub-key.js.map +1 -1
  28. package/build/utils/with-weak-map-cache.js +1 -7
  29. package/build/utils/with-weak-map-cache.js.map +1 -1
  30. package/build-module/actions.js.map +1 -1
  31. package/build-module/batch/create-batch.js +2 -2
  32. package/build-module/batch/create-batch.js.map +1 -1
  33. package/build-module/entities.js +49 -35
  34. package/build-module/entities.js.map +1 -1
  35. package/build-module/entity-provider.js.map +1 -1
  36. package/build-module/entity-types/entities.js +2 -0
  37. package/build-module/entity-types/entities.js.map +1 -0
  38. package/build-module/hooks/constants.js +0 -1
  39. package/build-module/hooks/constants.js.map +1 -1
  40. package/build-module/hooks/index.js +3 -0
  41. package/build-module/hooks/index.js.map +1 -0
  42. package/build-module/hooks/use-entity-record.js +18 -7
  43. package/build-module/hooks/use-entity-record.js.map +1 -1
  44. package/build-module/hooks/use-entity-records.js +17 -7
  45. package/build-module/hooks/use-entity-records.js.map +1 -1
  46. package/build-module/hooks/use-query-select.js.map +1 -1
  47. package/build-module/index.js +2 -3
  48. package/build-module/index.js.map +1 -1
  49. package/build-module/queried-data/selectors.js.map +1 -1
  50. package/build-module/resolvers.js.map +1 -1
  51. package/build-module/selectors.js +203 -166
  52. package/build-module/selectors.js.map +1 -1
  53. package/build-module/utils/forward-resolver.js.map +1 -1
  54. package/build-module/utils/on-sub-key.js.map +1 -1
  55. package/build-module/utils/with-weak-map-cache.js +1 -6
  56. package/build-module/utils/with-weak-map-cache.js.map +1 -1
  57. package/package.json +12 -12
  58. package/src/actions.js +389 -372
  59. package/src/batch/create-batch.js +2 -2
  60. package/src/entities.ts +357 -135
  61. package/src/entity-provider.js +4 -6
  62. package/src/entity-types/attachment.ts +4 -3
  63. package/src/entity-types/comment.ts +4 -3
  64. package/src/entity-types/entities.ts +130 -0
  65. package/src/entity-types/index.ts +115 -20
  66. package/src/entity-types/menu-location.ts +4 -3
  67. package/src/entity-types/nav-menu-item.ts +4 -3
  68. package/src/entity-types/nav-menu.ts +3 -3
  69. package/src/entity-types/page.ts +3 -3
  70. package/src/entity-types/plugin.ts +3 -3
  71. package/src/entity-types/post.ts +3 -3
  72. package/src/entity-types/settings.ts +3 -3
  73. package/src/entity-types/sidebar.ts +4 -3
  74. package/src/entity-types/taxonomy.ts +4 -3
  75. package/src/entity-types/theme.ts +3 -3
  76. package/src/entity-types/type.ts +3 -3
  77. package/src/entity-types/user.ts +3 -3
  78. package/src/entity-types/widget-type.ts +4 -3
  79. package/src/entity-types/widget.ts +3 -3
  80. package/src/entity-types/wp-template-part.ts +4 -3
  81. package/src/entity-types/wp-template.ts +4 -3
  82. package/src/fetch/test/__experimental-fetch-link-suggestions.js +2 -4
  83. package/src/hooks/constants.ts +1 -2
  84. package/src/hooks/index.ts +8 -0
  85. package/src/hooks/test/use-query-select.js +4 -2
  86. package/src/hooks/use-entity-record.ts +31 -9
  87. package/src/hooks/use-entity-records.ts +28 -30
  88. package/src/hooks/use-query-select.ts +26 -24
  89. package/src/index.js +2 -3
  90. package/src/locks/test/selectors.js +2 -1
  91. package/src/queried-data/selectors.js +2 -8
  92. package/src/resolvers.js +344 -325
  93. package/src/selectors.ts +639 -296
  94. package/src/test/resolvers.js +1 -3
  95. package/src/test/selectors.js +1 -2
  96. package/src/utils/forward-resolver.js +6 -5
  97. package/src/utils/on-sub-key.js +20 -20
  98. package/src/utils/with-weak-map-cache.js +1 -6
@@ -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 {Object} state Data state.
95
- * @param {string} url URL the preview would be for.
93
+ * @param state Data state.
94
+ * @param url URL the preview would be for.
96
95
  *
97
- * @return {boolean} Whether a request is in progress for an embed preview.
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 {Object} state Data state.
109
- * @param {Object|undefined} query Optional object of query parameters to
110
- * include with request.
111
- * @return {Array} Authors list.
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 {Object} state Data state.
126
+ * @param state Data state.
128
127
  *
129
- * @return {Object} Current user object.
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 {Object} state Data state.
140
- * @param {string} queryID Query ID.
138
+ * @param state Data state.
139
+ * @param queryID Query ID.
141
140
  *
142
- * @return {Array} Users list.
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 {Object} state Data state.
155
- * @param {string} kind Entity kind.
153
+ * @param state Data state.
154
+ * @param kind Entity kind.
156
155
  *
157
- * @return {Array<Object>} Array of entities with config matching kind.
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 {Object} state Data state.
173
- * @param {string} kind Entity kind.
171
+ * @param state Data state.
172
+ * @param kind Entity kind.
174
173
  *
175
- * @return {Array<Object>} Array of entities with config matching kind.
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 {Object} state Data state.
189
- * @param {string} kind Entity kind.
190
- * @param {string} name Entity name.
187
+ * @param state Data state.
188
+ * @param kind Entity kind.
189
+ * @param name Entity name.
191
190
  *
192
- * @return {Object} Entity config
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 {Object} state Data state.
207
- * @param {string} kind Entity kind.
208
- * @param {string} name Entity name.
205
+ * @param state Data state.
206
+ * @param kind Entity kind.
207
+ * @param name Entity name.
209
208
  *
210
- * @return {Object} Entity config
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 {Object} state State tree
226
- * @param {string} kind Entity kind.
227
- * @param {string} name Entity name.
228
- * @param {number} key Record's key
229
- * @param {?Object} query Optional query.
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 {Object|undefined} Record.
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 {Object} state State tree
285
- * @param {string} kind Entity kind.
286
- * @param {string} name Entity name.
287
- * @param {number} key Record's key
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 {Object|null} Record.
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 {Object} state State tree.
302
- * @param {string} kind Entity kind.
303
- * @param {string} name Entity name.
304
- * @param {number} key Record's key.
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 {Object?} Object with the entity's raw attributes.
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 {Object} state State tree
335
- * @param {string} kind Entity kind.
336
- * @param {string} name Entity name.
337
- * @param {?Object} query Optional terms query.
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 {boolean} Whether entity records have been received.
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
- * Returns the Entity's records.
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
- * @param {Object} state State tree
351
- * @param {string} kind Entity kind.
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
- * @return {?Array} Records.
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
- function getEntityRecords(state, kind, name, query) {
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 {Object} state State tree.
411
+ * @param state State tree.
374
412
  *
375
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records
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 {Object} state State tree.
451
+ * @param state State tree.
416
452
  *
417
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of records being saved.
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 {Object} state State tree.
458
- * @param {string} kind Entity kind.
459
- * @param {string} name Entity name.
460
- * @param {number} recordId Record ID.
493
+ * @param state State tree.
494
+ * @param kind Entity kind.
495
+ * @param name Entity name.
496
+ * @param recordId Record ID.
461
497
  *
462
- * @return {Object?} The entity record's edits.
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 {Object} state State tree.
479
- * @param {string} kind Entity kind.
480
- * @param {string} name Entity name.
481
- * @param {number} recordId Record ID.
514
+ * @param state State tree.
515
+ * @param kind Entity kind.
516
+ * @param name Entity name.
517
+ * @param recordId Record ID.
482
518
  *
483
- * @return {Object?} The entity record's non transient edits.
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 {Object} state State tree.
510
- * @param {string} kind Entity kind.
511
- * @param {string} name Entity name.
512
- * @param {number|string} recordId Record ID.
545
+ * @param state State tree.
546
+ * @param kind Entity kind.
547
+ * @param name Entity name.
548
+ * @param recordId Record ID.
513
549
  *
514
- * @return {boolean} Whether the entity record has edits or not.
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 {Object} state State tree.
526
- * @param {string} kind Entity kind.
527
- * @param {string} name Entity name.
528
- * @param {number|string} recordId Record ID.
561
+ * @param state State tree.
562
+ * @param kind Entity kind.
563
+ * @param name Entity name.
564
+ * @param recordId Record ID.
529
565
  *
530
- * @return {Object?} The entity record, merged with its edits.
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 {Object} state State tree.
546
- * @param {string} kind Entity kind.
547
- * @param {string} name Entity name.
548
- * @param {number} recordId Record ID.
581
+ * @param state State tree.
582
+ * @param kind Entity kind.
583
+ * @param name Entity name.
584
+ * @param recordId Record ID.
549
585
  *
550
- * @return {boolean} Whether the entity record is autosaving or not.
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 {Object} state State tree.
566
- * @param {string} kind Entity kind.
567
- * @param {string} name Entity name.
568
- * @param {number|string} recordId Record ID.
601
+ * @param state State tree.
602
+ * @param kind Entity kind.
603
+ * @param name Entity name.
604
+ * @param recordId Record ID.
569
605
  *
570
- * @return {boolean} Whether the entity record is saving or not.
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 {Object} state State tree.
581
- * @param {string} kind Entity kind.
582
- * @param {string} name Entity name.
583
- * @param {number} recordId Record ID.
616
+ * @param state State tree.
617
+ * @param kind Entity kind.
618
+ * @param name Entity name.
619
+ * @param recordId Record ID.
584
620
  *
585
- * @return {boolean} Whether the entity record is deleting or not.
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 {Object} state State tree.
596
- * @param {string} kind Entity kind.
597
- * @param {string} name Entity name.
598
- * @param {number} recordId Record ID.
631
+ * @param state State tree.
632
+ * @param kind Entity kind.
633
+ * @param name Entity name.
634
+ * @param recordId Record ID.
599
635
  *
600
- * @return {Object?} The entity record's save error.
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 {Object} state State tree.
611
- * @param {string} kind Entity kind.
612
- * @param {string} name Entity name.
613
- * @param {number} recordId Record ID.
646
+ * @param state State tree.
647
+ * @param kind Entity kind.
648
+ * @param name Entity name.
649
+ * @param recordId Record ID.
614
650
  *
615
- * @return {Object?} The entity record's save error.
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 {Object} state State tree.
665
+ * @param state State tree.
630
666
  *
631
- * @return {number} The current undo offset.
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 {Object} state State tree.
678
+ * @param state State tree.
643
679
  *
644
- * @return {Object?} The edit.
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 {Object} state State tree.
691
+ * @param state State tree.
656
692
  *
657
- * @return {Object?} The edit.
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 {Object} state State tree.
704
+ * @param state State tree.
669
705
  *
670
- * @return {boolean} Whether there is a previous edit or not.
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 {Object} state State tree.
717
+ * @param state State tree.
682
718
  *
683
- * @return {boolean} Whether there is a next edit or not.
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 {Object} state Data state.
729
+ * @param state Data state.
694
730
  *
695
- * @return {Object} The current theme.
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 {Object} state Data state.
741
+ * @param state Data state.
706
742
  *
707
- * @return {string} The current global styles ID.
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 {Object} state Data state.
753
+ * @param state Data state.
718
754
  *
719
- * @return {*} Index data.
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 {Object} state Data state.
732
- * @param {string} url Embedded URL.
767
+ * @param state Data state.
768
+ * @param url Embedded URL.
733
769
  *
734
- * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
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 {Object} state Data state.
749
- * @param {string} url Embedded URL.
784
+ * @param state Data state.
785
+ * @param url Embedded URL.
750
786
  *
751
- * @return {boolean} Is the preview for the URL an oEmbed link fallback.
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 {Object} state Data state.
775
- * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'.
776
- * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
777
- * @param {string=} id Optional ID of the rest resource to check.
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 {boolean|undefined} Whether or not the user can perform the action,
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 {Object} state Data state.
797
- * @param {string} kind Entity kind.
798
- * @param {string} name Entity name.
799
- * @param {string} recordId Record's id.
800
- * @return {boolean|undefined} Whether or not the user can edit,
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 {Object} state State tree.
822
- * @param {string} postType The type of the parent post.
823
- * @param {number} postId The id of the parent post.
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 {?Array} An array of autosaves for the post, or undefined if there is none.
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 {Object} state State tree.
836
- * @param {string} postType The type of the parent post.
837
- * @param {number} postId The id of the parent post.
838
- * @param {number} authorId The id of the author.
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 {?Object} The autosave for the post and author.
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 {Object} state State tree.
858
- * @param {string} postType The type of the parent post.
859
- * @param {number} postId The id of the parent post.
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 {boolean} True if the REST request was completed. False otherwise.
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 {Object} state Editor state.
918
+ * @param state Editor state.
883
919
  *
884
- * @return {*} A value whose reference will change only when an edit occurs.
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)(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
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 {Object} state Editor state.
893
- * @param {string} link Link.
929
+ * @param state Editor state.
930
+ * @param link Link.
894
931
  *
895
- * @return {Object?} The template record.
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 {Object} state Editor state.
952
+ * @param state Editor state.
916
953
  *
917
- * @return {Object|null} The Global Styles object.
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 {Object} state Data state.
970
+ * @param state Data state.
934
971
  *
935
- * @return {string|null} The current global styles ID.
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 {Object} state Data state.
988
+ * @param state Data state.
952
989
  *
953
- * @return {Array} Block pattern list.
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 {Object} state Data state.
1000
+ * @param state Data state.
964
1001
  *
965
- * @return {Array} Block pattern category list.
1002
+ * @return Block pattern category list.
966
1003
  */
967
1004
 
968
1005