@wordpress/data 10.32.0 → 10.32.1-next.ff1cebbba.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/build/components/async-mode-provider/context.js +35 -54
  2. package/build/components/async-mode-provider/context.js.map +7 -1
  3. package/build/components/async-mode-provider/index.js +40 -25
  4. package/build/components/async-mode-provider/index.js.map +7 -1
  5. package/build/components/async-mode-provider/use-async-mode.js +25 -16
  6. package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
  7. package/build/components/registry-provider/context.js +46 -64
  8. package/build/components/registry-provider/context.js.map +7 -1
  9. package/build/components/registry-provider/index.js +40 -25
  10. package/build/components/registry-provider/index.js.map +7 -1
  11. package/build/components/registry-provider/use-registry.js +25 -55
  12. package/build/components/registry-provider/use-registry.js.map +7 -1
  13. package/build/components/use-dispatch/index.js +38 -17
  14. package/build/components/use-dispatch/index.js.map +7 -1
  15. package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
  16. package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  17. package/build/components/use-dispatch/use-dispatch.js +36 -71
  18. package/build/components/use-dispatch/use-dispatch.js.map +7 -1
  19. package/build/components/use-select/index.js +79 -208
  20. package/build/components/use-select/index.js.map +7 -1
  21. package/build/components/with-dispatch/index.js +34 -107
  22. package/build/components/with-dispatch/index.js.map +7 -1
  23. package/build/components/with-registry/index.js +30 -30
  24. package/build/components/with-registry/index.js.map +7 -1
  25. package/build/components/with-select/index.js +44 -67
  26. package/build/components/with-select/index.js.map +7 -1
  27. package/build/controls.js +49 -110
  28. package/build/controls.js.map +7 -1
  29. package/build/create-selector.js +36 -11
  30. package/build/create-selector.js.map +7 -1
  31. package/build/default-registry.js +24 -10
  32. package/build/default-registry.js.map +7 -1
  33. package/build/dispatch.js +38 -31
  34. package/build/dispatch.js.map +7 -1
  35. package/build/factory.js +29 -85
  36. package/build/factory.js.map +7 -1
  37. package/build/index.js +114 -301
  38. package/build/index.js.map +7 -1
  39. package/build/lock-unlock.js +31 -14
  40. package/build/lock-unlock.js.map +7 -1
  41. package/build/plugins/index.js +36 -11
  42. package/build/plugins/index.js.map +7 -1
  43. package/build/plugins/persistence/index.js +74 -139
  44. package/build/plugins/persistence/index.js.map +7 -1
  45. package/build/plugins/persistence/storage/default.js +37 -18
  46. package/build/plugins/persistence/storage/default.js.map +7 -1
  47. package/build/plugins/persistence/storage/object.js +24 -7
  48. package/build/plugins/persistence/storage/object.js.map +7 -1
  49. package/build/promise-middleware.js +37 -20
  50. package/build/promise-middleware.js.map +7 -1
  51. package/build/redux-store/combine-reducers.js +26 -5
  52. package/build/redux-store/combine-reducers.js.map +7 -1
  53. package/build/redux-store/index.js +221 -331
  54. package/build/redux-store/index.js.map +7 -1
  55. package/build/redux-store/metadata/actions.js +51 -112
  56. package/build/redux-store/metadata/actions.js.map +7 -1
  57. package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
  58. package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  59. package/build/redux-store/metadata/reducer.js +111 -115
  60. package/build/redux-store/metadata/reducer.js.map +7 -1
  61. package/build/redux-store/metadata/selectors.js +109 -181
  62. package/build/redux-store/metadata/selectors.js.map +7 -1
  63. package/build/redux-store/metadata/utils.js +32 -35
  64. package/build/redux-store/metadata/utils.js.map +7 -1
  65. package/build/redux-store/thunk-middleware.js +24 -7
  66. package/build/redux-store/thunk-middleware.js.map +7 -1
  67. package/build/registry.js +94 -198
  68. package/build/registry.js.map +7 -1
  69. package/build/resolvers-cache-middleware.js +26 -27
  70. package/build/resolvers-cache-middleware.js.map +7 -1
  71. package/build/select.js +38 -31
  72. package/build/select.js.map +7 -1
  73. package/build/store/index.js +52 -16
  74. package/build/store/index.js.map +7 -1
  75. package/build/types.js +16 -5
  76. package/build/types.js.map +7 -1
  77. package/build/utils/emitter.js +33 -16
  78. package/build/utils/emitter.js.map +7 -1
  79. package/build-module/components/async-mode-provider/context.js +12 -49
  80. package/build-module/components/async-mode-provider/context.js.map +7 -1
  81. package/build-module/components/async-mode-provider/index.js +8 -3
  82. package/build-module/components/async-mode-provider/index.js.map +7 -1
  83. package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
  84. package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
  85. package/build-module/components/registry-provider/context.js +13 -58
  86. package/build-module/components/registry-provider/context.js.map +7 -1
  87. package/build-module/components/registry-provider/index.js +8 -3
  88. package/build-module/components/registry-provider/index.js.map +7 -1
  89. package/build-module/components/registry-provider/use-registry.js +7 -51
  90. package/build-module/components/registry-provider/use-registry.js.map +7 -1
  91. package/build-module/components/use-dispatch/index.js +7 -3
  92. package/build-module/components/use-dispatch/index.js.map +7 -1
  93. package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
  94. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  95. package/build-module/components/use-dispatch/use-dispatch.js +8 -66
  96. package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
  97. package/build-module/components/use-select/index.js +45 -193
  98. package/build-module/components/use-select/index.js.map +7 -1
  99. package/build-module/components/with-dispatch/index.js +16 -104
  100. package/build-module/components/with-dispatch/index.js.map +7 -1
  101. package/build-module/components/with-registry/index.js +12 -27
  102. package/build-module/components/with-registry/index.js.map +7 -1
  103. package/build-module/components/with-select/index.js +16 -63
  104. package/build-module/components/with-select/index.js.map +7 -1
  105. package/build-module/controls.js +25 -105
  106. package/build-module/controls.js.map +7 -1
  107. package/build-module/create-selector.js +5 -8
  108. package/build-module/create-selector.js.map +7 -1
  109. package/build-module/default-registry.js +6 -6
  110. package/build-module/default-registry.js.map +7 -1
  111. package/build-module/dispatch.js +6 -27
  112. package/build-module/dispatch.js.map +7 -1
  113. package/build-module/factory.js +8 -82
  114. package/build-module/factory.js.map +7 -1
  115. package/build-module/index.js +62 -185
  116. package/build-module/index.js.map +7 -1
  117. package/build-module/lock-unlock.js +8 -7
  118. package/build-module/lock-unlock.js.map +7 -1
  119. package/build-module/plugins/index.js +5 -2
  120. package/build-module/plugins/index.js.map +7 -1
  121. package/build-module/plugins/persistence/index.js +38 -129
  122. package/build-module/plugins/persistence/index.js.map +7 -1
  123. package/build-module/plugins/persistence/storage/default.js +8 -11
  124. package/build-module/plugins/persistence/storage/default.js.map +7 -1
  125. package/build-module/plugins/persistence/storage/object.js +6 -3
  126. package/build-module/plugins/persistence/storage/object.js.map +7 -1
  127. package/build-module/promise-middleware.js +8 -14
  128. package/build-module/promise-middleware.js.map +7 -1
  129. package/build-module/redux-store/combine-reducers.js +5 -2
  130. package/build-module/redux-store/combine-reducers.js.map +7 -1
  131. package/build-module/redux-store/index.js +180 -310
  132. package/build-module/redux-store/index.js.map +7 -1
  133. package/build-module/redux-store/metadata/actions.js +30 -109
  134. package/build-module/redux-store/metadata/actions.js.map +7 -1
  135. package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
  136. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  137. package/build-module/redux-store/metadata/reducer.js +83 -108
  138. package/build-module/redux-store/metadata/reducer.js.map +7 -1
  139. package/build-module/redux-store/metadata/selectors.js +76 -175
  140. package/build-module/redux-store/metadata/selectors.js.map +7 -1
  141. package/build-module/redux-store/metadata/utils.js +10 -30
  142. package/build-module/redux-store/metadata/utils.js.map +7 -1
  143. package/build-module/redux-store/thunk-middleware.js +7 -4
  144. package/build-module/redux-store/thunk-middleware.js.map +7 -1
  145. package/build-module/registry.js +56 -187
  146. package/build-module/registry.js.map +7 -1
  147. package/build-module/resolvers-cache-middleware.js +8 -23
  148. package/build-module/resolvers-cache-middleware.js.map +7 -1
  149. package/build-module/select.js +6 -27
  150. package/build-module/select.js.map +7 -1
  151. package/build-module/store/index.js +34 -12
  152. package/build-module/store/index.js.map +7 -1
  153. package/build-module/types.js +1 -2
  154. package/build-module/types.js.map +7 -1
  155. package/build-module/utils/emitter.js +12 -13
  156. package/build-module/utils/emitter.js.map +7 -1
  157. package/package.json +17 -10
@@ -1 +1,7 @@
1
- {"version":3,"names":["EquivalentKeyMap","selectorArgsToStateKey","onSubKey","subKeysIsResolved","state","action","type","nextState","set","args","status","error","resolutionArgs","forEach","idx","resolutionState","undefined","errors","delete","isResolved","selectorName","removedSelector","restState"],"sources":["@wordpress/data/src/redux-store/metadata/reducer.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport type { Reducer } from 'redux';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey, onSubKey } from './utils';\n\ntype Action =\n\t| ReturnType< typeof import('./actions').startResolution >\n\t| ReturnType< typeof import('./actions').finishResolution >\n\t| ReturnType< typeof import('./actions').failResolution >\n\t| ReturnType< typeof import('./actions').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\n\t| ReturnType< typeof import('./actions').failResolutions >\n\t| ReturnType< typeof import('./actions').invalidateResolution >\n\t| ReturnType< typeof import('./actions').invalidateResolutionForStore >\n\t| ReturnType<\n\t\t\ttypeof import('./actions').invalidateResolutionForStoreSelector\n\t >;\n\ntype StateKey = unknown[] | unknown;\nexport type StateValue =\n\t| { status: 'resolving' | 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\nexport type Status = StateValue[ 'status' ];\nexport type State = EquivalentKeyMap< StateKey, StateValue >;\n\n/**\n * Reducer function returning next state for selector resolution of\n * subkeys, object form:\n *\n * selectorName -> EquivalentKeyMap<Array,boolean>\n */\nconst subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<\n\tState,\n\tAction\n>( 'selectorName' )( ( state = new EquivalentKeyMap(), action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'START_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'resolving',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'finished',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'error',\n\t\t\t\terror: action.error,\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'resolving',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'finished',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\taction.args.forEach( ( resolutionArgs, idx ) => {\n\t\t\t\tconst resolutionState: StateValue = {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\terror: undefined,\n\t\t\t\t};\n\n\t\t\t\tconst error = action.errors[ idx ];\n\t\t\t\tif ( error ) {\n\t\t\t\t\tresolutionState.error = error;\n\t\t\t\t}\n\n\t\t\t\tnextState.set(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs as unknown[] ),\n\t\t\t\t\tresolutionState\n\t\t\t\t);\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'INVALIDATE_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.delete( selectorArgsToStateKey( action.args ) );\n\t\t\treturn nextState;\n\t\t}\n\t}\n\treturn state;\n} );\n\n/**\n * Reducer function returning next state for selector resolution, object form:\n *\n * selectorName -> EquivalentKeyMap<Array, boolean>\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Next state.\n */\nconst isResolved = ( state: Record< string, State > = {}, action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE':\n\t\t\treturn {};\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': {\n\t\t\tif ( action.selectorName in state ) {\n\t\t\t\tconst {\n\t\t\t\t\t[ action.selectorName ]: removedSelector,\n\t\t\t\t\t...restState\n\t\t\t\t} = state;\n\t\t\t\treturn restState;\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'FAIL_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'FAIL_RESOLUTIONS':\n\t\tcase 'INVALIDATE_RESOLUTION':\n\t\t\treturn subKeysIsResolved( state, action );\n\t}\n\treturn state;\n};\n\nexport default isResolved;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAgB,MAAM,oBAAoB;AAGjD;AACA;AACA;AACA,SAASC,sBAAsB,EAAEC,QAAQ,QAAQ,SAAS;AAuB1D;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAA6D,GAAGD,QAAQ,CAG3E,cAAe,CAAC,CAAE,CAAEE,KAAK,GAAG,IAAIJ,gBAAgB,CAAC,CAAC,EAAEK,MAAc,KAAM;EAC1E,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MAAE;QACxB,MAAMC,SAAS,GAAG,IAAIP,gBAAgB,CAAEI,KAAM,CAAC;QAC/CG,SAAS,CAACC,GAAG,CAAEP,sBAAsB,CAAEI,MAAM,C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EC,MAAO,CAAC;EAC3C;EACA,OAAOD,KAAK;AACb,CAAC;AAED,eAAee,UAAU","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/redux-store/metadata/reducer.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport type { Reducer } from 'redux';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey, onSubKey } from './utils';\n\ntype Action =\n\t| ReturnType< typeof import('./actions').startResolution >\n\t| ReturnType< typeof import('./actions').finishResolution >\n\t| ReturnType< typeof import('./actions').failResolution >\n\t| ReturnType< typeof import('./actions').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\n\t| ReturnType< typeof import('./actions').failResolutions >\n\t| ReturnType< typeof import('./actions').invalidateResolution >\n\t| ReturnType< typeof import('./actions').invalidateResolutionForStore >\n\t| ReturnType<\n\t\t\ttypeof import('./actions').invalidateResolutionForStoreSelector\n\t >;\n\ntype StateKey = unknown[] | unknown;\nexport type StateValue =\n\t| { status: 'resolving' | 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\nexport type Status = StateValue[ 'status' ];\nexport type State = EquivalentKeyMap< StateKey, StateValue >;\n\n/**\n * Reducer function returning next state for selector resolution of\n * subkeys, object form:\n *\n * selectorName -> EquivalentKeyMap<Array,boolean>\n */\nconst subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<\n\tState,\n\tAction\n>( 'selectorName' )( ( state = new EquivalentKeyMap(), action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'START_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'resolving',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'finished',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'error',\n\t\t\t\terror: action.error,\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'resolving',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'finished',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\taction.args.forEach( ( resolutionArgs, idx ) => {\n\t\t\t\tconst resolutionState: StateValue = {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\terror: undefined,\n\t\t\t\t};\n\n\t\t\t\tconst error = action.errors[ idx ];\n\t\t\t\tif ( error ) {\n\t\t\t\t\tresolutionState.error = error;\n\t\t\t\t}\n\n\t\t\t\tnextState.set(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs as unknown[] ),\n\t\t\t\t\tresolutionState\n\t\t\t\t);\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'INVALIDATE_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.delete( selectorArgsToStateKey( action.args ) );\n\t\t\treturn nextState;\n\t\t}\n\t}\n\treturn state;\n} );\n\n/**\n * Reducer function returning next state for selector resolution, object form:\n *\n * selectorName -> EquivalentKeyMap<Array, boolean>\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Next state.\n */\nconst isResolved = ( state: Record< string, State > = {}, action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE':\n\t\t\treturn {};\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': {\n\t\t\tif ( action.selectorName in state ) {\n\t\t\t\tconst {\n\t\t\t\t\t[ action.selectorName ]: removedSelector,\n\t\t\t\t\t...restState\n\t\t\t\t} = state;\n\t\t\t\treturn restState;\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'FAIL_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'FAIL_RESOLUTIONS':\n\t\tcase 'INVALIDATE_RESOLUTION':\n\t\t\treturn subKeysIsResolved( state, action );\n\t}\n\treturn state;\n};\n\nexport default isResolved;\n"],
5
+ "mappings": "AAGA,OAAO,sBAAsB;AAM7B,SAAS,wBAAwB,gBAAgB;AA6BjD,MAAM,oBAAgE,SAGnE,cAAe,EAAG,CAAE,QAAQ,IAAI,iBAAiB,GAAG,WAAoB;AAC1E,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,oBAAoB;AACxB,YAAM,YAAY,IAAI,iBAAkB,KAAM;AAC9C,gBAAU,IAAK,uBAAwB,OAAO,IAAK,GAAG;AAAA,QACrD,QAAQ;AAAA,MACT,CAAE;AACF,aAAO;AAAA,IACR;AAAA,IACA,KAAK,qBAAqB;AACzB,YAAM,YAAY,IAAI,iBAAkB,KAAM;AAC9C,gBAAU,IAAK,uBAAwB,OAAO,IAAK,GAAG;AAAA,QACrD,QAAQ;AAAA,MACT,CAAE;AACF,aAAO;AAAA,IACR;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tB,KAAK;AACJ,aAAO,CAAC;AAAA,IACT,KAAK,4CAA4C;AAChD,UAAK,OAAO,gBAAgB,OAAQ;AACnC,cAAM;AAAA,UACL,CAAE,OAAO,YAAa,GAAG;AAAA,UACzB,GAAG;AAAA,QACJ,IAAI;AACJ,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,kBAAmB,OAAO,MAAO;AAAA,EAC1C;AACA,SAAO;AACR;AAEA,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -1,194 +1,95 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import deprecated from '@wordpress/deprecated';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { createSelector } from '../../create-selector';
10
- import { selectorArgsToStateKey } from './utils';
11
-
12
- /** @typedef {Record<string, import('./reducer').State>} State */
13
- /** @typedef {import('./reducer').StateValue} StateValue */
14
- /** @typedef {import('./reducer').Status} Status */
15
-
16
- /**
17
- * Returns the raw resolution state value for a given selector name,
18
- * and arguments set. May be undefined if the selector has never been resolved
19
- * or not resolved for the given set of arguments, otherwise true or false for
20
- * resolution started and completed respectively.
21
- *
22
- * @param {State} state Data state.
23
- * @param {string} selectorName Selector name.
24
- * @param {unknown[]?} args Arguments passed to selector.
25
- *
26
- * @return {StateValue|undefined} isResolving value.
27
- */
28
- export function getResolutionState(state, selectorName, args) {
1
+ import deprecated from "@wordpress/deprecated";
2
+ import { createSelector } from "../../create-selector";
3
+ import { selectorArgsToStateKey } from "./utils";
4
+ function getResolutionState(state, selectorName, args) {
29
5
  const map = state[selectorName];
30
6
  if (!map) {
31
7
  return;
32
8
  }
33
9
  return map.get(selectorArgsToStateKey(args));
34
10
  }
35
-
36
- /**
37
- * Returns an `isResolving`-like value for a given selector name and arguments set.
38
- * Its value is either `undefined` if the selector has never been resolved or has been
39
- * invalidated, or a `true`/`false` boolean value if the resolution is in progress or
40
- * has finished, respectively.
41
- *
42
- * This is a legacy selector that was implemented when the "raw" internal data had
43
- * this `undefined | boolean` format. Nowadays the internal value is an object that
44
- * can be retrieved with `getResolutionState`.
45
- *
46
- * @deprecated
47
- *
48
- * @param {State} state Data state.
49
- * @param {string} selectorName Selector name.
50
- * @param {unknown[]?} args Arguments passed to selector.
51
- *
52
- * @return {boolean | undefined} isResolving value.
53
- */
54
- export function getIsResolving(state, selectorName, args) {
55
- deprecated('wp.data.select( store ).getIsResolving', {
56
- since: '6.6',
57
- version: '6.8',
58
- alternative: 'wp.data.select( store ).getResolutionState'
11
+ function getIsResolving(state, selectorName, args) {
12
+ deprecated("wp.data.select( store ).getIsResolving", {
13
+ since: "6.6",
14
+ version: "6.8",
15
+ alternative: "wp.data.select( store ).getResolutionState"
59
16
  });
60
17
  const resolutionState = getResolutionState(state, selectorName, args);
61
- return resolutionState && resolutionState.status === 'resolving';
18
+ return resolutionState && resolutionState.status === "resolving";
62
19
  }
63
-
64
- /**
65
- * Returns true if resolution has already been triggered for a given
66
- * selector name, and arguments set.
67
- *
68
- * @param {State} state Data state.
69
- * @param {string} selectorName Selector name.
70
- * @param {unknown[]?} args Arguments passed to selector.
71
- *
72
- * @return {boolean} Whether resolution has been triggered.
73
- */
74
- export function hasStartedResolution(state, selectorName, args) {
75
- return getResolutionState(state, selectorName, args) !== undefined;
20
+ function hasStartedResolution(state, selectorName, args) {
21
+ return getResolutionState(state, selectorName, args) !== void 0;
76
22
  }
77
-
78
- /**
79
- * Returns true if resolution has completed for a given selector
80
- * name, and arguments set.
81
- *
82
- * @param {State} state Data state.
83
- * @param {string} selectorName Selector name.
84
- * @param {unknown[]?} args Arguments passed to selector.
85
- *
86
- * @return {boolean} Whether resolution has completed.
87
- */
88
- export function hasFinishedResolution(state, selectorName, args) {
23
+ function hasFinishedResolution(state, selectorName, args) {
89
24
  const status = getResolutionState(state, selectorName, args)?.status;
90
- return status === 'finished' || status === 'error';
25
+ return status === "finished" || status === "error";
91
26
  }
92
-
93
- /**
94
- * Returns true if resolution has failed for a given selector
95
- * name, and arguments set.
96
- *
97
- * @param {State} state Data state.
98
- * @param {string} selectorName Selector name.
99
- * @param {unknown[]?} args Arguments passed to selector.
100
- *
101
- * @return {boolean} Has resolution failed
102
- */
103
- export function hasResolutionFailed(state, selectorName, args) {
104
- return getResolutionState(state, selectorName, args)?.status === 'error';
27
+ function hasResolutionFailed(state, selectorName, args) {
28
+ return getResolutionState(state, selectorName, args)?.status === "error";
105
29
  }
106
-
107
- /**
108
- * Returns the resolution error for a given selector name, and arguments set.
109
- * Note it may be of an Error type, but may also be null, undefined, or anything else
110
- * that can be `throw`-n.
111
- *
112
- * @param {State} state Data state.
113
- * @param {string} selectorName Selector name.
114
- * @param {unknown[]?} args Arguments passed to selector.
115
- *
116
- * @return {Error|unknown} Last resolution error
117
- */
118
- export function getResolutionError(state, selectorName, args) {
30
+ function getResolutionError(state, selectorName, args) {
119
31
  const resolutionState = getResolutionState(state, selectorName, args);
120
- return resolutionState?.status === 'error' ? resolutionState.error : null;
32
+ return resolutionState?.status === "error" ? resolutionState.error : null;
121
33
  }
122
-
123
- /**
124
- * Returns true if resolution has been triggered but has not yet completed for
125
- * a given selector name, and arguments set.
126
- *
127
- * @param {State} state Data state.
128
- * @param {string} selectorName Selector name.
129
- * @param {unknown[]?} args Arguments passed to selector.
130
- *
131
- * @return {boolean} Whether resolution is in progress.
132
- */
133
- export function isResolving(state, selectorName, args) {
134
- return getResolutionState(state, selectorName, args)?.status === 'resolving';
34
+ function isResolving(state, selectorName, args) {
35
+ return getResolutionState(state, selectorName, args)?.status === "resolving";
135
36
  }
136
-
137
- /**
138
- * Returns the list of the cached resolvers.
139
- *
140
- * @param {State} state Data state.
141
- *
142
- * @return {State} Resolvers mapped by args and selectorName.
143
- */
144
- export function getCachedResolvers(state) {
37
+ function getCachedResolvers(state) {
145
38
  return state;
146
39
  }
147
-
148
- /**
149
- * Whether the store has any currently resolving selectors.
150
- *
151
- * @param {State} state Data state.
152
- *
153
- * @return {boolean} True if one or more selectors are resolving, false otherwise.
154
- */
155
- export function hasResolvingSelectors(state) {
156
- return Object.values(state).some(selectorState =>
157
- /**
158
- * This uses the internal `_map` property of `EquivalentKeyMap` for
159
- * optimization purposes, since the `EquivalentKeyMap` implementation
160
- * does not support a `.values()` implementation.
161
- *
162
- * @see https://github.com/aduth/equivalent-key-map
163
- */
164
- Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving'));
40
+ function hasResolvingSelectors(state) {
41
+ return Object.values(state).some(
42
+ (selectorState) => (
43
+ /**
44
+ * This uses the internal `_map` property of `EquivalentKeyMap` for
45
+ * optimization purposes, since the `EquivalentKeyMap` implementation
46
+ * does not support a `.values()` implementation.
47
+ *
48
+ * @see https://github.com/aduth/equivalent-key-map
49
+ */
50
+ Array.from(selectorState._map.values()).some(
51
+ (resolution) => resolution[1]?.status === "resolving"
52
+ )
53
+ )
54
+ );
165
55
  }
166
-
167
- /**
168
- * Retrieves the total number of selectors, grouped per status.
169
- *
170
- * @param {State} state Data state.
171
- *
172
- * @return {Object} Object, containing selector totals by status.
173
- */
174
- export const countSelectorsByStatus = createSelector(state => {
175
- const selectorsByStatus = {};
176
- Object.values(state).forEach(selectorState =>
177
- /**
178
- * This uses the internal `_map` property of `EquivalentKeyMap` for
179
- * optimization purposes, since the `EquivalentKeyMap` implementation
180
- * does not support a `.values()` implementation.
181
- *
182
- * @see https://github.com/aduth/equivalent-key-map
183
- */
184
- Array.from(selectorState._map.values()).forEach(resolution => {
185
- var _resolution$1$status;
186
- const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error';
187
- if (!selectorsByStatus[currentStatus]) {
188
- selectorsByStatus[currentStatus] = 0;
189
- }
190
- selectorsByStatus[currentStatus]++;
191
- }));
192
- return selectorsByStatus;
193
- }, state => [state]);
194
- //# sourceMappingURL=selectors.js.map
56
+ const countSelectorsByStatus = createSelector(
57
+ (state) => {
58
+ const selectorsByStatus = {};
59
+ Object.values(state).forEach(
60
+ (selectorState) => (
61
+ /**
62
+ * This uses the internal `_map` property of `EquivalentKeyMap` for
63
+ * optimization purposes, since the `EquivalentKeyMap` implementation
64
+ * does not support a `.values()` implementation.
65
+ *
66
+ * @see https://github.com/aduth/equivalent-key-map
67
+ */
68
+ Array.from(selectorState._map.values()).forEach(
69
+ (resolution) => {
70
+ const currentStatus = resolution[1]?.status ?? "error";
71
+ if (!selectorsByStatus[currentStatus]) {
72
+ selectorsByStatus[currentStatus] = 0;
73
+ }
74
+ selectorsByStatus[currentStatus]++;
75
+ }
76
+ )
77
+ )
78
+ );
79
+ return selectorsByStatus;
80
+ },
81
+ (state) => [state]
82
+ );
83
+ export {
84
+ countSelectorsByStatus,
85
+ getCachedResolvers,
86
+ getIsResolving,
87
+ getResolutionError,
88
+ getResolutionState,
89
+ hasFinishedResolution,
90
+ hasResolutionFailed,
91
+ hasResolvingSelectors,
92
+ hasStartedResolution,
93
+ isResolving
94
+ };
95
+ //# sourceMappingURL=selectors.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["deprecated","createSelector","selectorArgsToStateKey","getResolutionState","state","selectorName","args","map","get","getIsResolving","since","version","alternative","resolutionState","status","hasStartedResolution","undefined","hasFinishedResolution","hasResolutionFailed","getResolutionError","error","isResolving","getCachedResolvers","hasResolvingSelectors","Object","values","some","selectorState","Array","from","_map","resolution","countSelectorsByStatus","selectorsByStatus","forEach","_resolution$1$status","currentStatus"],"sources":["@wordpress/data/src/redux-store/metadata/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createSelector } from '../../create-selector';\nimport { selectorArgsToStateKey } from './utils';\n\n/** @typedef {Record<string, import('./reducer').State>} State */\n/** @typedef {import('./reducer').StateValue} StateValue */\n/** @typedef {import('./reducer').Status} Status */\n\n/**\n * Returns the raw resolution state value for a given selector name,\n * and arguments set. May be undefined if the selector has never been resolved\n * or not resolved for the given set of arguments, otherwise true or false for\n * resolution started and completed respectively.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {StateValue|undefined} isResolving value.\n */\nexport function getResolutionState( state, selectorName, args ) {\n\tconst map = state[ selectorName ];\n\tif ( ! map ) {\n\t\treturn;\n\t}\n\n\treturn map.get( selectorArgsToStateKey( args ) );\n}\n\n/**\n * Returns an `isResolving`-like value for a given selector name and arguments set.\n * Its value is either `undefined` if the selector has never been resolved or has been\n * invalidated, or a `true`/`false` boolean value if the resolution is in progress or\n * has finished, respectively.\n *\n * This is a legacy selector that was implemented when the \"raw\" internal data had\n * this `undefined | boolean` format. Nowadays the internal value is an object that\n * can be retrieved with `getResolutionState`.\n *\n * @deprecated\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean | undefined} isResolving value.\n */\nexport function getIsResolving( state, selectorName, args ) {\n\tdeprecated( 'wp.data.select( store ).getIsResolving', {\n\t\tsince: '6.6',\n\t\tversion: '6.8',\n\t\talternative: 'wp.data.select( store ).getResolutionState',\n\t} );\n\n\tconst resolutionState = getResolutionState( state, selectorName, args );\n\treturn resolutionState && resolutionState.status === 'resolving';\n}\n\n/**\n * Returns true if resolution has already been triggered for a given\n * selector name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution has been triggered.\n */\nexport function hasStartedResolution( state, selectorName, args ) {\n\treturn getResolutionState( state, selectorName, args ) !== undefined;\n}\n\n/**\n * Returns true if resolution has completed for a given selector\n * name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution has completed.\n */\nexport function hasFinishedResolution( state, selectorName, args ) {\n\tconst status = getResolutionState( state, selectorName, args )?.status;\n\treturn status === 'finished' || status === 'error';\n}\n\n/**\n * Returns true if resolution has failed for a given selector\n * name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Has resolution failed\n */\nexport function hasResolutionFailed( state, selectorName, args ) {\n\treturn getResolutionState( state, selectorName, args )?.status === 'error';\n}\n\n/**\n * Returns the resolution error for a given selector name, and arguments set.\n * Note it may be of an Error type, but may also be null, undefined, or anything else\n * that can be `throw`-n.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {Error|unknown} Last resolution error\n */\nexport function getResolutionError( state, selectorName, args ) {\n\tconst resolutionState = getResolutionState( state, selectorName, args );\n\treturn resolutionState?.status === 'error' ? resolutionState.error : null;\n}\n\n/**\n * Returns true if resolution has been triggered but has not yet completed for\n * a given selector name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution is in progress.\n */\nexport function isResolving( state, selectorName, args ) {\n\treturn (\n\t\tgetResolutionState( state, selectorName, args )?.status === 'resolving'\n\t);\n}\n\n/**\n * Returns the list of the cached resolvers.\n *\n * @param {State} state Data state.\n *\n * @return {State} Resolvers mapped by args and selectorName.\n */\nexport function getCachedResolvers( state ) {\n\treturn state;\n}\n\n/**\n * Whether the store has any currently resolving selectors.\n *\n * @param {State} state Data state.\n *\n * @return {boolean} True if one or more selectors are resolving, false otherwise.\n */\nexport function hasResolvingSelectors( state ) {\n\treturn Object.values( state ).some( ( selectorState ) =>\n\t\t/**\n\t\t * This uses the internal `_map` property of `EquivalentKeyMap` for\n\t\t * optimization purposes, since the `EquivalentKeyMap` implementation\n\t\t * does not support a `.values()` implementation.\n\t\t *\n\t\t * @see https://github.com/aduth/equivalent-key-map\n\t\t */\n\t\tArray.from( selectorState._map.values() ).some(\n\t\t\t( resolution ) => resolution[ 1 ]?.status === 'resolving'\n\t\t)\n\t);\n}\n\n/**\n * Retrieves the total number of selectors, grouped per status.\n *\n * @param {State} state Data state.\n *\n * @return {Object} Object, containing selector totals by status.\n */\nexport const countSelectorsByStatus = createSelector(\n\t( state ) => {\n\t\tconst selectorsByStatus = {};\n\n\t\tObject.values( state ).forEach( ( selectorState ) =>\n\t\t\t/**\n\t\t\t * This uses the internal `_map` property of `EquivalentKeyMap` for\n\t\t\t * optimization purposes, since the `EquivalentKeyMap` implementation\n\t\t\t * does not support a `.values()` implementation.\n\t\t\t *\n\t\t\t * @see https://github.com/aduth/equivalent-key-map\n\t\t\t */\n\t\t\tArray.from( selectorState._map.values() ).forEach(\n\t\t\t\t( resolution ) => {\n\t\t\t\t\tconst currentStatus = resolution[ 1 ]?.status ?? 'error';\n\t\t\t\t\tif ( ! selectorsByStatus[ currentStatus ] ) {\n\t\t\t\t\t\tselectorsByStatus[ currentStatus ] = 0;\n\t\t\t\t\t}\n\t\t\t\t\tselectorsByStatus[ currentStatus ]++;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\treturn selectorsByStatus;\n\t},\n\t( state ) => [ state ]\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,sBAAsB,QAAQ,SAAS;;AAEhD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEC,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAG;EAC/D,MAAMC,GAAG,GAAGH,KAAK,CAAEC,YAAY,CAAE;EACjC,IAAK,CAAEE,GAAG,EAAG;IACZ;EACD;EAEA,OAAOA,GAAG,CAACC,GAAG,CAAEN,sBAAsB,CAAEI,IAA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L,MAAM,CAAC,CAAE,CAAC,CAACS,OAAO,CAC9CH,UAAU,IAAM;IAAA,IAAAI,oBAAA;IACjB,MAAMC,aAAa,IAAAD,oBAAA,GAAGJ,UAAU,CAAE,CAAC,CAAE,EAAEjB,MAAM,cAAAqB,oBAAA,cAAAA,oBAAA,GAAI,OAAO;IACxD,IAAK,CAAEF,iBAAiB,CAAEG,aAAa,CAAE,EAAG;MAC3CH,iBAAiB,CAAEG,aAAa,CAAE,GAAG,CAAC;IACvC;IACAH,iBAAiB,CAAEG,aAAa,CAAE,EAAE;EACrC,CACD,CACD,CAAC;EAED,OAAOH,iBAAiB;AACzB,CAAC,EACC7B,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/redux-store/metadata/selectors.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createSelector } from '../../create-selector';\nimport { selectorArgsToStateKey } from './utils';\n\n/** @typedef {Record<string, import('./reducer').State>} State */\n/** @typedef {import('./reducer').StateValue} StateValue */\n/** @typedef {import('./reducer').Status} Status */\n\n/**\n * Returns the raw resolution state value for a given selector name,\n * and arguments set. May be undefined if the selector has never been resolved\n * or not resolved for the given set of arguments, otherwise true or false for\n * resolution started and completed respectively.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {StateValue|undefined} isResolving value.\n */\nexport function getResolutionState( state, selectorName, args ) {\n\tconst map = state[ selectorName ];\n\tif ( ! map ) {\n\t\treturn;\n\t}\n\n\treturn map.get( selectorArgsToStateKey( args ) );\n}\n\n/**\n * Returns an `isResolving`-like value for a given selector name and arguments set.\n * Its value is either `undefined` if the selector has never been resolved or has been\n * invalidated, or a `true`/`false` boolean value if the resolution is in progress or\n * has finished, respectively.\n *\n * This is a legacy selector that was implemented when the \"raw\" internal data had\n * this `undefined | boolean` format. Nowadays the internal value is an object that\n * can be retrieved with `getResolutionState`.\n *\n * @deprecated\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean | undefined} isResolving value.\n */\nexport function getIsResolving( state, selectorName, args ) {\n\tdeprecated( 'wp.data.select( store ).getIsResolving', {\n\t\tsince: '6.6',\n\t\tversion: '6.8',\n\t\talternative: 'wp.data.select( store ).getResolutionState',\n\t} );\n\n\tconst resolutionState = getResolutionState( state, selectorName, args );\n\treturn resolutionState && resolutionState.status === 'resolving';\n}\n\n/**\n * Returns true if resolution has already been triggered for a given\n * selector name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution has been triggered.\n */\nexport function hasStartedResolution( state, selectorName, args ) {\n\treturn getResolutionState( state, selectorName, args ) !== undefined;\n}\n\n/**\n * Returns true if resolution has completed for a given selector\n * name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution has completed.\n */\nexport function hasFinishedResolution( state, selectorName, args ) {\n\tconst status = getResolutionState( state, selectorName, args )?.status;\n\treturn status === 'finished' || status === 'error';\n}\n\n/**\n * Returns true if resolution has failed for a given selector\n * name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Has resolution failed\n */\nexport function hasResolutionFailed( state, selectorName, args ) {\n\treturn getResolutionState( state, selectorName, args )?.status === 'error';\n}\n\n/**\n * Returns the resolution error for a given selector name, and arguments set.\n * Note it may be of an Error type, but may also be null, undefined, or anything else\n * that can be `throw`-n.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {Error|unknown} Last resolution error\n */\nexport function getResolutionError( state, selectorName, args ) {\n\tconst resolutionState = getResolutionState( state, selectorName, args );\n\treturn resolutionState?.status === 'error' ? resolutionState.error : null;\n}\n\n/**\n * Returns true if resolution has been triggered but has not yet completed for\n * a given selector name, and arguments set.\n *\n * @param {State} state Data state.\n * @param {string} selectorName Selector name.\n * @param {unknown[]?} args Arguments passed to selector.\n *\n * @return {boolean} Whether resolution is in progress.\n */\nexport function isResolving( state, selectorName, args ) {\n\treturn (\n\t\tgetResolutionState( state, selectorName, args )?.status === 'resolving'\n\t);\n}\n\n/**\n * Returns the list of the cached resolvers.\n *\n * @param {State} state Data state.\n *\n * @return {State} Resolvers mapped by args and selectorName.\n */\nexport function getCachedResolvers( state ) {\n\treturn state;\n}\n\n/**\n * Whether the store has any currently resolving selectors.\n *\n * @param {State} state Data state.\n *\n * @return {boolean} True if one or more selectors are resolving, false otherwise.\n */\nexport function hasResolvingSelectors( state ) {\n\treturn Object.values( state ).some( ( selectorState ) =>\n\t\t/**\n\t\t * This uses the internal `_map` property of `EquivalentKeyMap` for\n\t\t * optimization purposes, since the `EquivalentKeyMap` implementation\n\t\t * does not support a `.values()` implementation.\n\t\t *\n\t\t * @see https://github.com/aduth/equivalent-key-map\n\t\t */\n\t\tArray.from( selectorState._map.values() ).some(\n\t\t\t( resolution ) => resolution[ 1 ]?.status === 'resolving'\n\t\t)\n\t);\n}\n\n/**\n * Retrieves the total number of selectors, grouped per status.\n *\n * @param {State} state Data state.\n *\n * @return {Object} Object, containing selector totals by status.\n */\nexport const countSelectorsByStatus = createSelector(\n\t( state ) => {\n\t\tconst selectorsByStatus = {};\n\n\t\tObject.values( state ).forEach( ( selectorState ) =>\n\t\t\t/**\n\t\t\t * This uses the internal `_map` property of `EquivalentKeyMap` for\n\t\t\t * optimization purposes, since the `EquivalentKeyMap` implementation\n\t\t\t * does not support a `.values()` implementation.\n\t\t\t *\n\t\t\t * @see https://github.com/aduth/equivalent-key-map\n\t\t\t */\n\t\t\tArray.from( selectorState._map.values() ).forEach(\n\t\t\t\t( resolution ) => {\n\t\t\t\t\tconst currentStatus = resolution[ 1 ]?.status ?? 'error';\n\t\t\t\t\tif ( ! selectorsByStatus[ currentStatus ] ) {\n\t\t\t\t\t\tselectorsByStatus[ currentStatus ] = 0;\n\t\t\t\t\t}\n\t\t\t\t\tselectorsByStatus[ currentStatus ]++;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\treturn selectorsByStatus;\n\t},\n\t( state ) => [ state ]\n);\n"],
5
+ "mappings": "AAGA,OAAO,gBAAgB;AAKvB,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AAkBhC,SAAS,mBAAoB,OAAO,cAAc,MAAO;AAC/D,QAAM,MAAM,MAAO,YAAa;AAChC,MAAK,CAAE,KAAM;AACZ;AAAA,EACD;AAEA,SAAO,IAAI,IAAK,uBAAwB,IAAK,CAAE;AAChD;AAoBO,SAAS,eAAgB,OAAO,cAAc,MAAO;AAC3D,aAAY,0CAA0C;AAAA,IACrD,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,EACd,CAAE;AAEF,QAAM,kBAAkB,mBAAoB,OAAO,cAAc,IAAK;AACtE,SAAO,mBAAmB,gBAAgB,WAAW;AACtD;AAYO,SAAS,qBAAsB,OAAO,cAAc,MAAO;AACjE,SAAO,mBAAoB,OAAO,cAAc,IAAK,MAAM;AAC5D;AAYO,SAAS,sBAAuB,OAAO,cAAc,MAAO;AAClE,QAAM,SAAS,mBAAoB,OAAO,cAAc,IAAK,GAAG;AAChE,SAAO,WAAW,cAAc,WAAW;AAC5C;AAYO,SAAS,oBAAqB,OAAO,cAAc,MAAO;AAChE,SAAO,mBAAoB,OAAO,cAAc,IAAK,GAAG,WAAW;AACpE;AAaO,SAAS,mBAAoB,OAAO,cAAc,MAAO;AAC/D,QAAM,kBAAkB,mBAAoB,OAAO,cAAc,IAAK;AACtE,SAAO,iBAAiB,WAAW,UAAU,gBAAgB,QAAQ;AACtE;AAYO,SAAS,YAAa,OAAO,cAAc,MAAO;AACxD,SACC,mBAAoB,OAAO,cAAc,IAAK,GAAG,WAAW;AAE9D;AASO,SAAS,mBAAoB,OAAQ;AAC3C,SAAO;AACR;AASO,SAAS,sBAAuB,OAAQ;AAC9C,SAAO,OAAO,OAAQ,KAAM,EAAE;AAAA,IAAM,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQrC,MAAM,KAAM,cAAc,KAAK,OAAO,CAAE,EAAE;AAAA,QACzC,CAAE,eAAgB,WAAY,CAAE,GAAG,WAAW;AAAA,MAC/C;AAAA;AAAA,EACD;AACD;AASO,MAAM,yBAAyB;AAAA,EACrC,CAAE,UAAW;AACZ,UAAM,oBAAoB,CAAC;AAE3B,WAAO,OAAQ,KAAM,EAAE;AAAA,MAAS,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQjC,MAAM,KAAM,cAAc,KAAK,OAAO,CAAE,EAAE;AAAA,UACzC,CAAE,eAAgB;AACjB,kBAAM,gBAAgB,WAAY,CAAE,GAAG,UAAU;AACjD,gBAAK,CAAE,kBAAmB,aAAc,GAAI;AAC3C,gCAAmB,aAAc,IAAI;AAAA,YACtC;AACA,8BAAmB,aAAc;AAAA,UAClC;AAAA,QACD;AAAA;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA,EACA,CAAE,UAAW,CAAE,KAAM;AACtB;",
6
+ "names": []
7
+ }
@@ -1,24 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- /**
6
- * Higher-order reducer creator which creates a combined reducer object, keyed
7
- * by a property on the action object.
8
- *
9
- * @param actionProperty Action property by which to key object.
10
- * @return Higher-order reducer.
11
- */
12
- export const onSubKey = actionProperty => reducer => (state = {}, action) => {
13
- // Retrieve subkey from action. Do not track if undefined; useful for cases
14
- // where reducer is scoped by action shape.
1
+ const onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
15
2
  const key = action[actionProperty];
16
- if (key === undefined) {
3
+ if (key === void 0) {
17
4
  return state;
18
5
  }
19
-
20
- // Avoid updating state if unchanged. Note that this also accounts for a
21
- // reducer which returns undefined on a key which is not yet tracked.
22
6
  const nextKeyState = reducer(state[key], action);
23
7
  if (nextKeyState === state[key]) {
24
8
  return state;
@@ -28,23 +12,19 @@ export const onSubKey = actionProperty => reducer => (state = {}, action) => {
28
12
  [key]: nextKeyState
29
13
  };
30
14
  };
31
-
32
- /**
33
- * Normalize selector argument array by defaulting `undefined` value to an empty array
34
- * and removing trailing `undefined` values.
35
- *
36
- * @param args Selector argument array
37
- * @return Normalized state key array
38
- */
39
- export function selectorArgsToStateKey(args) {
40
- if (args === undefined || args === null) {
15
+ function selectorArgsToStateKey(args) {
16
+ if (args === void 0 || args === null) {
41
17
  return [];
42
18
  }
43
19
  const len = args.length;
44
20
  let idx = len;
45
- while (idx > 0 && args[idx - 1] === undefined) {
21
+ while (idx > 0 && args[idx - 1] === void 0) {
46
22
  idx--;
47
23
  }
48
24
  return idx === len ? args : args.slice(0, idx);
49
25
  }
50
- //# sourceMappingURL=utils.js.map
26
+ export {
27
+ onSubKey,
28
+ selectorArgsToStateKey
29
+ };
30
+ //# sourceMappingURL=utils.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState","selectorArgsToStateKey","args","len","length","idx","slice"],"sources":["@wordpress/data/src/redux-store/metadata/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { AnyAction, Reducer } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param actionProperty Action property by which to key object.\n * @return Higher-order reducer.\n */\nexport const onSubKey =\n\t< TState extends unknown, TAction extends AnyAction >(\n\t\tactionProperty: string\n\t) =>\n\t(\n\t\treducer: Reducer< TState, TAction >\n\t): Reducer< Record< string, TState >, TAction > =>\n\t( state: Record< string, TState > = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\n/**\n * Normalize selector argument array by defaulting `undefined` value to an empty array\n * and removing trailing `undefined` values.\n *\n * @param args Selector argument array\n * @return Normalized state key array\n */\nexport function selectorArgsToStateKey( args: unknown[] | null | undefined ) {\n\tif ( args === undefined || args === null ) {\n\t\treturn [];\n\t}\n\n\tconst len = args.length;\n\tlet idx = len;\n\twhile ( idx > 0 && args[ idx - 1 ] === undefined ) {\n\t\tidx--;\n\t}\n\treturn idx === len ? args : args.slice( 0, idx );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAEnBC,cAAsB,IAGtBC,OAAmC,IAEpC,CAAEC,KAA+B,GAAG,CAAC,CAAC,EAAEC,MAAM,KAAM;EACnD;EACA;EACA,MAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAc,CAAE;EACpC,IAAKI,GAAG,KAAKC,SAAS,EAAG;IACxB,OAAOH,KAAK;EACb;;EAEA;EACA;EACA,MAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAG,CAAE,EAAED,MAAO,CAAC;EACpD,IAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAG,CAAE,EAAG;IACpC,OAAOF,KAAK;EACb;EAEA,OAAO;IACN,GAAGA,KAAK;IACR,CAAEE,GAAG,GAAIE;EACV,CAAC;AACF,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAEC,IAAkC,EAAG;EAC5E,IAAKA,IAAI,KAAKH,SAAS,IAAIG,IAAI,KAAK,IAAI,EAAG;IAC1C,OAAO,EAAE;EACV;EAEA,MAAMC,GAAG,GAAGD,IAAI,CAACE,MAAM;EACvB,IAAIC,GAAG,GAAGF,GAAG;EACb,OAAQE,GAAG,GAAG,CAAC,IAAIH,IAAI,CAAEG,GAAG,GAAG,CAAC,CAAE,KAAKN,SAAS,EAAG;IAClDM,GAAG,EAAE;EACN;EACA,OAAOA,GAAG,KAAKF,GAAG,GAAGD,IAAI,GAAGA,IAAI,CAACI,KAAK,CAAE,CAAC,EAAED,GAAI,CAAC;AACjD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/redux-store/metadata/utils.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { AnyAction, Reducer } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param actionProperty Action property by which to key object.\n * @return Higher-order reducer.\n */\nexport const onSubKey =\n\t< TState extends unknown, TAction extends AnyAction >(\n\t\tactionProperty: string\n\t) =>\n\t(\n\t\treducer: Reducer< TState, TAction >\n\t): Reducer< Record< string, TState >, TAction > =>\n\t( state: Record< string, TState > = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\n/**\n * Normalize selector argument array by defaulting `undefined` value to an empty array\n * and removing trailing `undefined` values.\n *\n * @param args Selector argument array\n * @return Normalized state key array\n */\nexport function selectorArgsToStateKey( args: unknown[] | null | undefined ) {\n\tif ( args === undefined || args === null ) {\n\t\treturn [];\n\t}\n\n\tconst len = args.length;\n\tlet idx = len;\n\twhile ( idx > 0 && args[ idx - 1 ] === undefined ) {\n\t\tidx--;\n\t}\n\treturn idx === len ? args : args.slice( 0, idx );\n}\n"],
5
+ "mappings": "AAYO,MAAM,WACZ,CACC,mBAED,CACC,YAED,CAAE,QAAkC,CAAC,GAAG,WAAY;AAGnD,QAAM,MAAM,OAAQ,cAAe;AACnC,MAAK,QAAQ,QAAY;AACxB,WAAO;AAAA,EACR;AAIA,QAAM,eAAe,QAAS,MAAO,GAAI,GAAG,MAAO;AACnD,MAAK,iBAAiB,MAAO,GAAI,GAAI;AACpC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,GAAI,GAAG;AAAA,EACV;AACD;AASM,SAAS,uBAAwB,MAAqC;AAC5E,MAAK,SAAS,UAAa,SAAS,MAAO;AAC1C,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,MAAM,KAAK;AACjB,MAAI,MAAM;AACV,SAAQ,MAAM,KAAK,KAAM,MAAM,CAAE,MAAM,QAAY;AAClD;AAAA,EACD;AACA,SAAO,QAAQ,MAAM,OAAO,KAAK,MAAO,GAAG,GAAI;AAChD;",
6
+ "names": []
7
+ }
@@ -1,9 +1,12 @@
1
- export default function createThunkMiddleware(args) {
2
- return () => next => action => {
3
- if (typeof action === 'function') {
1
+ function createThunkMiddleware(args) {
2
+ return () => (next) => (action) => {
3
+ if (typeof action === "function") {
4
4
  return action(args);
5
5
  }
6
6
  return next(action);
7
7
  };
8
8
  }
9
- //# sourceMappingURL=thunk-middleware.js.map
9
+ export {
10
+ createThunkMiddleware as default
11
+ };
12
+ //# sourceMappingURL=thunk-middleware.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createThunkMiddleware","args","next","action"],"sources":["@wordpress/data/src/redux-store/thunk-middleware.js"],"sourcesContent":["export default function createThunkMiddleware( args ) {\n\treturn () => ( next ) => ( action ) => {\n\t\tif ( typeof action === 'function' ) {\n\t\t\treturn action( args );\n\t\t}\n\n\t\treturn next( action );\n\t};\n}\n"],"mappings":"AAAA,eAAe,SAASA,qBAAqBA,CAAEC,IAAI,EAAG;EACrD,OAAO,MAAQC,IAAI,IAAQC,MAAM,IAAM;IACtC,IAAK,OAAOA,MAAM,KAAK,UAAU,EAAG;MACnC,OAAOA,MAAM,CAAEF,IAAK,CAAC;IACtB;IAEA,OAAOC,IAAI,CAAEC,MAAO,CAAC;EACtB,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/redux-store/thunk-middleware.js"],
4
+ "sourcesContent": ["export default function createThunkMiddleware( args ) {\n\treturn () => ( next ) => ( action ) => {\n\t\tif ( typeof action === 'function' ) {\n\t\t\treturn action( args );\n\t\t}\n\n\t\treturn next( action );\n\t};\n}\n"],
5
+ "mappings": "AAAe,SAAR,sBAAwC,MAAO;AACrD,SAAO,MAAM,CAAE,SAAU,CAAE,WAAY;AACtC,QAAK,OAAO,WAAW,YAAa;AACnC,aAAO,OAAQ,IAAK;AAAA,IACrB;AAEA,WAAO,KAAM,MAAO;AAAA,EACrB;AACD;",
6
+ "names": []
7
+ }