@wordpress/core-data 4.8.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 (70) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -56
  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.map +1 -1
  7. package/build/entity-provider.js.map +1 -1
  8. package/build/hooks/use-entity-record.js.map +1 -1
  9. package/build/hooks/use-query-select.js.map +1 -1
  10. package/build/queried-data/selectors.js.map +1 -1
  11. package/build/resolvers.js.map +1 -1
  12. package/build/selectors.js +45 -8
  13. package/build/selectors.js.map +1 -1
  14. package/build/utils/forward-resolver.js.map +1 -1
  15. package/build/utils/on-sub-key.js.map +1 -1
  16. package/build/utils/with-weak-map-cache.js +1 -7
  17. package/build/utils/with-weak-map-cache.js.map +1 -1
  18. package/build-module/actions.js.map +1 -1
  19. package/build-module/batch/create-batch.js +2 -2
  20. package/build-module/batch/create-batch.js.map +1 -1
  21. package/build-module/entities.js.map +1 -1
  22. package/build-module/entity-provider.js.map +1 -1
  23. package/build-module/hooks/use-entity-record.js.map +1 -1
  24. package/build-module/hooks/use-query-select.js.map +1 -1
  25. package/build-module/queried-data/selectors.js.map +1 -1
  26. package/build-module/resolvers.js.map +1 -1
  27. package/build-module/selectors.js +40 -4
  28. package/build-module/selectors.js.map +1 -1
  29. package/build-module/utils/forward-resolver.js.map +1 -1
  30. package/build-module/utils/on-sub-key.js.map +1 -1
  31. package/build-module/utils/with-weak-map-cache.js +1 -6
  32. package/build-module/utils/with-weak-map-cache.js.map +1 -1
  33. package/package.json +11 -11
  34. package/src/actions.js +389 -372
  35. package/src/batch/create-batch.js +2 -2
  36. package/src/entities.ts +16 -17
  37. package/src/entity-provider.js +4 -6
  38. package/src/entity-types/attachment.ts +4 -3
  39. package/src/entity-types/comment.ts +4 -3
  40. package/src/entity-types/entities.ts +5 -2
  41. package/src/entity-types/index.ts +114 -20
  42. package/src/entity-types/menu-location.ts +4 -3
  43. package/src/entity-types/nav-menu-item.ts +4 -3
  44. package/src/entity-types/nav-menu.ts +3 -3
  45. package/src/entity-types/page.ts +3 -3
  46. package/src/entity-types/plugin.ts +3 -3
  47. package/src/entity-types/post.ts +3 -3
  48. package/src/entity-types/settings.ts +3 -3
  49. package/src/entity-types/sidebar.ts +4 -3
  50. package/src/entity-types/taxonomy.ts +4 -3
  51. package/src/entity-types/theme.ts +3 -3
  52. package/src/entity-types/type.ts +3 -3
  53. package/src/entity-types/user.ts +3 -3
  54. package/src/entity-types/widget-type.ts +4 -3
  55. package/src/entity-types/widget.ts +3 -3
  56. package/src/entity-types/wp-template-part.ts +4 -3
  57. package/src/entity-types/wp-template.ts +4 -3
  58. package/src/fetch/test/__experimental-fetch-link-suggestions.js +2 -4
  59. package/src/hooks/test/use-query-select.js +4 -2
  60. package/src/hooks/use-entity-record.ts +0 -1
  61. package/src/hooks/use-query-select.ts +26 -24
  62. package/src/locks/test/selectors.js +2 -1
  63. package/src/queried-data/selectors.js +2 -8
  64. package/src/resolvers.js +344 -325
  65. package/src/selectors.ts +347 -194
  66. package/src/test/resolvers.js +1 -3
  67. package/src/test/selectors.js +1 -2
  68. package/src/utils/forward-resolver.js +6 -5
  69. package/src/utils/on-sub-key.js +20 -20
  70. package/src/utils/with-weak-map-cache.js +1 -6
@@ -208,9 +208,7 @@ describe( 'getEntityRecords', () => {
208
208
  } );
209
209
 
210
210
  // The record should have been received.
211
- expect(
212
- dispatch.__unstableAcquireStoreLock
213
- ).toHaveBeenCalledWith(
211
+ expect( dispatch.__unstableAcquireStoreLock ).toHaveBeenCalledWith(
214
212
  'core',
215
213
  [ 'entities', 'records', 'root', 'postType' ],
216
214
  { exclusive: false }
@@ -611,8 +611,7 @@ describe( 'isPreviewEmbedFallback()', () => {
611
611
  const state = deepFreeze( {
612
612
  embedPreviews: {
613
613
  'http://example.com/': {
614
- html:
615
- '<a href="http://example.com/">http://example.com/</a>',
614
+ html: '<a href="http://example.com/">http://example.com/</a>',
616
615
  },
617
616
  },
618
617
  } );
@@ -5,10 +5,11 @@
5
5
  *
6
6
  * @return {Function} Enhanced resolver.
7
7
  */
8
- const forwardResolver = ( resolverName ) => ( ...args ) => async ( {
9
- resolveSelect,
10
- } ) => {
11
- await resolveSelect[ resolverName ]( ...args );
12
- };
8
+ const forwardResolver =
9
+ ( resolverName ) =>
10
+ ( ...args ) =>
11
+ async ( { resolveSelect } ) => {
12
+ await resolveSelect[ resolverName ]( ...args );
13
+ };
13
14
 
14
15
  export default forwardResolver;
@@ -8,28 +8,28 @@
8
8
  *
9
9
  * @return {AnyFunction} Higher-order reducer.
10
10
  */
11
- export const onSubKey = ( actionProperty ) => ( reducer ) => (
12
- state = {},
13
- action
14
- ) => {
15
- // Retrieve subkey from action. Do not track if undefined; useful for cases
16
- // where reducer is scoped by action shape.
17
- const key = action[ actionProperty ];
18
- if ( key === undefined ) {
19
- return state;
20
- }
11
+ export const onSubKey =
12
+ ( actionProperty ) =>
13
+ ( reducer ) =>
14
+ ( state = {}, action ) => {
15
+ // Retrieve subkey from action. Do not track if undefined; useful for cases
16
+ // where reducer is scoped by action shape.
17
+ const key = action[ actionProperty ];
18
+ if ( key === undefined ) {
19
+ return state;
20
+ }
21
21
 
22
- // Avoid updating state if unchanged. Note that this also accounts for a
23
- // reducer which returns undefined on a key which is not yet tracked.
24
- const nextKeyState = reducer( state[ key ], action );
25
- if ( nextKeyState === state[ key ] ) {
26
- return state;
27
- }
22
+ // Avoid updating state if unchanged. Note that this also accounts for a
23
+ // reducer which returns undefined on a key which is not yet tracked.
24
+ const nextKeyState = reducer( state[ key ], action );
25
+ if ( nextKeyState === state[ key ] ) {
26
+ return state;
27
+ }
28
28
 
29
- return {
30
- ...state,
31
- [ key ]: nextKeyState,
29
+ return {
30
+ ...state,
31
+ [ key ]: nextKeyState,
32
+ };
32
33
  };
33
- };
34
34
 
35
35
  export default onSubKey;
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isObjectLike } from 'lodash';
5
-
6
1
  /**
7
2
  * Given a function, returns an enhanced function which caches the result and
8
3
  * tracks in WeakMap. The result is only cached if the original function is
@@ -25,7 +20,7 @@ function withWeakMapCache( fn ) {
25
20
  // Can reach here if key is not valid for WeakMap, since `has`
26
21
  // will return false for invalid key. Since `set` will throw,
27
22
  // ensure that key is valid before setting into cache.
28
- if ( isObjectLike( key ) ) {
23
+ if ( key !== null && typeof key === 'object' ) {
29
24
  cache.set( key, value );
30
25
  }
31
26
  }