@wordpress/data 10.13.1-next.cd6172eb0.0 → 10.14.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 (63) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +4 -13
  3. package/build/components/use-dispatch/use-dispatch-with-map.js +1 -0
  4. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  5. package/build/components/use-select/index.js +12 -3
  6. package/build/components/use-select/index.js.map +1 -1
  7. package/build/create-selector.js.map +1 -1
  8. package/build/factory.js +9 -7
  9. package/build/factory.js.map +1 -1
  10. package/build/plugins/persistence/index.js +1 -0
  11. package/build/plugins/persistence/index.js.map +1 -1
  12. package/build/redux-store/index.js +1 -0
  13. package/build/redux-store/index.js.map +1 -1
  14. package/build/redux-store/metadata/reducer.js +1 -0
  15. package/build/redux-store/metadata/reducer.js.map +1 -1
  16. package/build/redux-store/metadata/selectors.js +1 -0
  17. package/build/redux-store/metadata/selectors.js.map +1 -1
  18. package/build/registry.js +1 -0
  19. package/build/registry.js.map +1 -1
  20. package/build/resolvers-cache-middleware.js +1 -0
  21. package/build/resolvers-cache-middleware.js.map +1 -1
  22. package/build/utils/emitter.js +1 -0
  23. package/build/utils/emitter.js.map +1 -1
  24. package/build-module/components/use-dispatch/use-dispatch-with-map.js +1 -0
  25. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  26. package/build-module/components/use-select/index.js +12 -3
  27. package/build-module/components/use-select/index.js.map +1 -1
  28. package/build-module/create-selector.js +0 -4
  29. package/build-module/create-selector.js.map +1 -1
  30. package/build-module/factory.js +9 -7
  31. package/build-module/factory.js.map +1 -1
  32. package/build-module/plugins/persistence/index.js +1 -0
  33. package/build-module/plugins/persistence/index.js.map +1 -1
  34. package/build-module/redux-store/index.js +1 -0
  35. package/build-module/redux-store/index.js.map +1 -1
  36. package/build-module/redux-store/metadata/reducer.js +1 -0
  37. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  38. package/build-module/redux-store/metadata/selectors.js +1 -0
  39. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  40. package/build-module/registry.js +1 -0
  41. package/build-module/registry.js.map +1 -1
  42. package/build-module/resolvers-cache-middleware.js +1 -0
  43. package/build-module/resolvers-cache-middleware.js.map +1 -1
  44. package/build-module/utils/emitter.js +1 -0
  45. package/build-module/utils/emitter.js.map +1 -1
  46. package/build-types/components/use-dispatch/use-dispatch.d.ts +1 -1
  47. package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
  48. package/build-types/components/use-select/index.d.ts.map +1 -1
  49. package/build-types/controls.d.ts +21 -3
  50. package/build-types/controls.d.ts.map +1 -1
  51. package/build-types/create-selector.d.ts +7 -1
  52. package/build-types/create-selector.d.ts.map +1 -1
  53. package/build-types/factory.d.ts +21 -7
  54. package/build-types/factory.d.ts.map +1 -1
  55. package/build-types/index.d.ts.map +1 -1
  56. package/build-types/registry.d.ts.map +1 -1
  57. package/package.json +9 -9
  58. package/src/components/use-select/index.js +21 -5
  59. package/src/components/use-select/test/index.js +13 -0
  60. package/src/components/with-select/test/index.js +13 -0
  61. package/src/{create-selector.js → create-selector.ts} +0 -4
  62. package/src/{factory.js → factory.ts} +25 -10
  63. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_equivalentKeyMap","_interopRequireDefault","require","_utils","subKeysIsResolved","onSubKey","state","EquivalentKeyMap","action","type","nextState","set","selectorArgsToStateKey","args","status","error","resolutionArgs","forEach","idx","resolutionState","undefined","errors","delete","isResolved","selectorName","removedSelector","restState","_default","exports","default"],"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":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,iBAA6D,GAAG,IAAAC,eAAQ,EAG3E,cAAe,CAAC,CAAE,CAAEC,KAAK,GAAG,IAAIC,yBAAgB,CAAC,CAAC,EAAEC,MAAc,KAAM;EAC1E,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MAAE;QACxB,MAAMC,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,CAAC;QAC/CI,SAAS,CAACC,GAAG,CAAE,IAAAC,6BAAsB,EAAEJ,MAAM,CAACK,IAAK,CAAC,EAAE;UACrDC,MAAM,EAAE;QACT,CAAE,CAAC;QACH,OAAOJ,SAAS;MACjB;IACA,KAAK,mBAAmB;MAAE;QACzB,MAAMA,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,CAAC;QAC/CI,SAAS,CAACC,GAAG,CAAE,IAAAC,6BAAsB,EAAEJ,MAAM,CAACK,IAAK,CAAC,EAAE;UACrDC,MAAM,EAAE;QACT,CAAE,CAAC;QACH,OAAOJ,SAAS;MACjB;IACA,KAAK,iBAAiB;MAAE;QACvB,MAAMA,SAAS,GAAG,IAAIH,yB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AC;QACF,CAAE,CAAC;QACH,OAAOT,SAAS;MACjB;IACA,KAAK,uBAAuB;MAAE;QAC7B,MAAMA,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,CAAC;QAC/CI,SAAS,CAACY,MAAM,CAAE,IAAAV,6BAAsB,EAAEJ,MAAM,CAACK,IAAK,CAAE,CAAC;QACzD,OAAOH,SAAS;MACjB;EACD;EACA,OAAOJ,KAAK;AACb,CAAE,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMiB,UAAU,GAAGA,CAAEjB,KAA8B,GAAG,CAAC,CAAC,EAAEE,MAAc,KAAM;EAC7E,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,iCAAiC;MACrC,OAAO,CAAC,CAAC;IACV,KAAK,0CAA0C;MAAE;QAChD,IAAKD,MAAM,CAACgB,YAAY,IAAIlB,KAAK,EAAG;UACnC,MAAM;YACL,CAAEE,MAAM,CAACgB,YAAY,GAAIC,eAAe;YACxC,GAAGC;UACJ,CAAC,GAAGpB,KAAK;UACT,OAAOoB,SAAS;QACjB;QACA,OAAOpB,KAAK;MACb;IACA,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,iBAAiB;IACtB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC3B,OAAOF,iBAAiB,CAAEE,KAAK,EAAEE,MAAO,CAAC;EAC3C;EACA,OAAOF,KAAK;AACb,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaN,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_equivalentKeyMap","_interopRequireDefault","require","_utils","subKeysIsResolved","onSubKey","state","EquivalentKeyMap","action","type","nextState","set","selectorArgsToStateKey","args","status","error","resolutionArgs","forEach","idx","resolutionState","undefined","errors","delete","isResolved","selectorName","removedSelector","restState","_default","exports","default"],"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":";;;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,iBAA6D,GAAG,IAAAC,eAAQ,EAG3E,cAAe,CAAC,CAAE,CAAEC,KAAK,GAAG,IAAIC,yBAAgB,CAAC,CAAC,EAAEC,MAAc,KAAM;EAC1E,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MAAE;QACxB,MAAMC,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,CAAC;QAC/CI,SAAS,CAACC,GAAG,CAAE,IAAAC,6BAAsB,EAAEJ,MAAM,CAACK,IAAK,CAAC,EAAE;UACrDC,MAAM,EAAE;QACT,CAAE,CAAC;QACH,OAAOJ,SAAS;MACjB;IACA,KAAK,mBAAmB;MAAE;QACzB,MAAMA,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,CAAC;QAC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+1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_deprecated","_interopRequireDefault","require","_createSelector","_utils","getResolutionState","state","selectorName","args","map","get","selectorArgsToStateKey","getIsResolving","deprecated","since","version","alternative","resolutionState","status","hasStartedResolution","undefined","hasFinishedResolution","hasResolutionFailed","getResolutionError","error","isResolving","getCachedResolvers","hasResolvingSelectors","Object","values","some","selectorState","Array","from","_map","resolution","countSelectorsByStatus","exports","createSelector","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":";;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,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,CAAE,IAAAC,6BAAsB,EAAEH,IAAK,CAAE,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEN,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAG;EAC3D,IAAAK,mBAAU,EAAE,wCAAwC,EAAE;IACrDC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE,KAAK;IACdC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,MAAMC,eAAe,GAAGZ,kBAAkB,CAAEC,KAAK,EAAEC,YAAY,EAAEC,IAAK,CAAC;EACvE,OAAOS,eAAe,IAAIA,eAAe,CAACC,MAAM,KAAK,WAAW;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CAAEb,KAAK,EAAEC,YAAY,EAAEC,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;AACA;AACO,SAASqB,qBAAqBA,CAAErB,KAAK,EAAG;EAC9C,OAAOsB,MAAM,CAACC,MAAM,CAAEvB,KAAM,CAAC,CAACwB,IAAI,CAAIC,aAAa;EAClD;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,KAAK,CAACC,IAAI,CAAEF,aAAa,CAACG,IAAI,CAACL,MAAM,CAAC,CAAE,CAAC,CAACC,IAAI,CAC3CK,UAAU,IAAMA,UAAU,CAAE,CAAC,CAAE,EAAEjB,MAAM,KAAK,WAC/C,CACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMkB,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,IAAAE,8BAAc,EACjDhC,KAAK,IAAM;EACZ,MAAMiC,iBAAiB,GAAG,CAAC,CAAC;EAE5BX,MAAM,CAACC,MAAM,CAAEvB,KAAM,CAAC,CAACkC,OAAO,CAAIT,aAAa;EAC9C;AACH;AACA;AACA;AACA;AACA;AACA;EACGC,KAAK,CAACC,IAAI,CAAEF,aAAa,CAACG,IAAI,CAACL,MAAM,CAAC,CAAE,CAAC,CAACW,OAAO,CAC9CL,UAAU,IAAM;IAAA,IAAAM,oBAAA;IACjB,MAAMC,aAAa,IAAAD,oBAAA,GAAGN,UAAU,CAAE,CAAC,CAAE,EAAEjB,MAAM,cAAAuB,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,EACCjC,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_deprecated","_interopRequireDefault","require","_createSelector","_utils","getResolutionState","state","selectorName","args","map","get","selectorArgsToStateKey","getIsResolving","deprecated","since","version","alternative","resolutionState","status","hasStartedResolution","undefined","hasFinishedResolution","hasResolutionFailed","getResolutionError","error","isResolving","getCachedResolvers","hasResolvingSelectors","Object","values","some","selectorState","Array","from","_map","resolution","countSelectorsByStatus","exports","createSelector","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);\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I,CAACL,MAAM,CAAC,CAAE,CAAC,CAACC,IAAI,CAC3CK,UAAU,IAAMA,UAAU,CAAE,CAAC,CAAE,EAAEjB,MAAM,KAAK,WAC/C,CACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMkB,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,IAAAE,8BAAc,EACjDhC,KAAK,IAAM;EACZ,MAAMiC,iBAAiB,GAAG,CAAC,CAAC;EAE5BX,MAAM,CAACC,MAAM,CAAEvB,KAAM,CAAC,CAACkC,OAAO,CAAIT,aAAa;EAC9C;AACH;AACA;AACA;AACA;AACA;AACA;EACGC,KAAK,CAACC,IAAI,CAAEF,aAAa,CAACG,IAAI,CAACL,MAAM,CAAC,CAAE,CAAC,CAACW,OAAO,CAC9CL,UAAU,IAAM;IAAA,IAAAM,oBAAA;IACjB,MAAMC,aAAa,IAAAD,oBAAA,GAAGN,UAAU,CAAE,CAAC,CAAE,EAAEjB,MAAM,cAAAuB,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,EACCjC,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC","ignoreList":[]}
package/build/registry.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_deprecated","_interopRequireDefault","require","_reduxStore","_store","_emitter","_lockUnlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","createEmitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","unlock","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","deprecated","since","alternative","registerStore","options","reducer","createReduxStore","batch","pause","values","forEach","resume","namespaces","use","plugin","coreDataStore","config","registryWithPlugins","lock","privateActions","privateSelectors"],"sources":["@wordpress/data/src/registry.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins( attributes ) {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store = createStore();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"],"mappings":";;;;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BAAgB,EAAElE,IAAI,EAAE4E,MAAO,CAAE,CAAC;EACtD;EAEA,IAAKzE,MAAM,EAAG;IACbA,MAAM,CAACO,SAAS,CAAEF,cAAe,CAAC;EACnC;EAEA,MAAMqE,mBAAmB,GAAG9C,WAAW,CAAEQ,QAAS,CAAC;EACnD,IAAAuC,gBAAI,EAAED,mBAAmB,EAAE;IAC1BxB,gBAAgB,EAAIrD,IAAI,IAAM;MAC7B,IAAI;QACH,OAAO,IAAAmD,kBAAM,EAAE/C,MAAM,CAAEJ,IAAI,CAAE,CAACa,KAAM,CAAC,CAACkE,cAAc;MACrD,CAAC,CAAC,OAAQvB,CAAC,EAAG;QACb;QACA;QACA,OAAO,CAAC,CAAC;MACV;IACD,CAAC;IACDD,kBAAkB,EAAIvD,IAAI,IAAM;MAC/B,IAAI;QACH,OAAO,IAAAmD,kBAAM,EAAE/C,MAAM,CAAEJ,IAAI,CAAE,CAACa,KAAM,CAAC,CAACmE,gBAAgB;MACvD,CAAC,CAAC,OAAQxB,CAAC,EAAG;QACb,OAAO,CAAC,CAAC;MACV;IACD;EACD,CAAE,CAAC;EACH,OAAOqB,mBAAmB;AAC3B","ignoreList":[]}
1
+ {"version":3,"names":["_deprecated","_interopRequireDefault","require","_reduxStore","_store","_emitter","_lockUnlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","createEmitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","unlock","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","deprecated","since","alternative","registerStore","options","reducer","createReduxStore","batch","pause","values","forEach","resume","namespaces","use","plugin","coreDataStore","config","registryWithPlugins","lock","privateActions","privateSelectors"],"sources":["@wordpress/data/src/registry.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins( attributes ) {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store = createStore();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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EJ,IAAI,CAAE,CAACa,KAAM,CAAC,CAACkE,cAAc;MACrD,CAAC,CAAC,OAAQvB,CAAC,EAAG;QACb;QACA;QACA,OAAO,CAAC,CAAC;MACV;IACD,CAAC;IACDD,kBAAkB,EAAIvD,IAAI,IAAM;MAC/B,IAAI;QACH,OAAO,IAAAmD,kBAAM,EAAE/C,MAAM,CAAEJ,IAAI,CAAE,CAACa,KAAM,CAAC,CAACmE,gBAAgB;MACvD,CAAC,CAAC,OAAQxB,CAAC,EAAG;QACb,OAAO,CAAC,CAAC;MACV;IACD;EACD,CAAE,CAAC;EACH,OAAOqB,mBAAmB;AAC3B","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["createResolversCacheMiddleware","registry","storeName","next","action","resolvers","select","getCachedResolvers","resolverEntries","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","undefined","status","dispatch","invalidateResolution","_default","exports","default"],"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"sourcesContent":["/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry Registry for which to create the middleware.\n * @param {string} storeName Name of the store for which to create the middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, storeName ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry.select( storeName ).getCachedResolvers();\n\t\tconst resolverEntries = Object.entries( resolvers );\n\t\tresolverEntries.forEach( ( [ selectorName, resolversByArgs ] ) => {\n\t\t\tconst resolver =\n\t\t\t\tregistry.stores[ storeName ]?.resolvers?.[ selectorName ];\n\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t// Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value\n\t\t\t\t// to `undefined` and `map.forEach` then iterates also over these orphaned entries.\n\t\t\t\tif ( value === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\tif ( value.status !== 'finished' && value.status !== 'error' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! resolver.shouldInvalidate( action, ...args ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Trigger cache invalidation\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( storeName )\n\t\t\t\t\t.invalidateResolution( selectorName, args );\n\t\t\t} );\n\t\t} );\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"],"mappings":";;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,8BAA8B,GACnCA,CAAEC,QAAQ,EAAEC,SAAS,KAAM,MAAQC,IAAI,IAAQC,MAAM,IAAM;EAC1D,MAAMC,SAAS,GAAGJ,QAAQ,CAACK,MAAM,CAAEJ,SAAU,CAAC,CAACK,kBAAkB,CAAC,CAAC;EACnE,MAAMC,eAAe,GAAGC,MAAM,CAACC,OAAO,CAAEL,SAAU,CAAC;EACnDG,eAAe,CAACG,OAAO,CAAE,CAAE,CAAEC,YAAY,EAAEC,eAAe,CAAE,KAAM;IACjE,MAAMC,QAAQ,GACbb,QAAQ,CAACc,MAAM,CAAEb,SAAS,CAAE,EAAEG,SAAS,GAAIO,YAAY,CAAE;IAC1D,IAAK,CAAEE,QAAQ,IAAI,CAAEA,QAAQ,CAACE,gBAAgB,EAAG;MAChD;IACD;IACAH,eAAe,CAACF,OAAO,CAAE,CAAEM,KAAK,EAAEC,IAAI,KAAM;MAC3C;MACA;MACA,IAAKD,KAAK,KAAKE,SAAS,EAAG;QAC1B;MACD;;MAEA;MACA;MACA;MACA,IAAKF,KAAK,CAACG,MAAM,KAAK,UAAU,IAAIH,KAAK,CAACG,MAAM,KAAK,OAAO,EAAG;QAC9D;MACD;MAEA,IAAK,CAAEN,QAAQ,CAACE,gBAAgB,CAAEZ,MAAM,EAAE,GAAGc,IAAK,CAAC,EAAG;QACrD;MACD;;MAEA;MACAjB,QAAQ,CACNoB,QAAQ,CAAEnB,SAAU,CAAC,CACrBoB,oBAAoB,CAAEV,YAAY,EAAEM,IAAK,CAAC;IAC7C,CAAE,CAAC;EACJ,CAAE,CAAC;EACH,OAAOf,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYzB,8BAA8B","ignoreList":[]}
1
+ {"version":3,"names":["createResolversCacheMiddleware","registry","storeName","next","action","resolvers","select","getCachedResolvers","resolverEntries","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","undefined","status","dispatch","invalidateResolution","_default","exports","default"],"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"sourcesContent":["/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry Registry for which to create the middleware.\n * @param {string} storeName Name of the store for which to create the middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, storeName ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry.select( storeName ).getCachedResolvers();\n\t\tconst resolverEntries = Object.entries( resolvers );\n\t\tresolverEntries.forEach( ( [ selectorName, resolversByArgs ] ) => {\n\t\t\tconst resolver =\n\t\t\t\tregistry.stores[ storeName ]?.resolvers?.[ selectorName ];\n\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t// Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value\n\t\t\t\t// to `undefined` and `map.forEach` then iterates also over these orphaned entries.\n\t\t\t\tif ( value === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\tif ( value.status !== 'finished' && value.status !== 'error' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! resolver.shouldInvalidate( action, ...args ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Trigger cache invalidation\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( storeName )\n\t\t\t\t\t.invalidateResolution( selectorName, args );\n\t\t\t} );\n\t\t} );\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,8BAA8B,GACnCA,CAAEC,QAAQ,EAAEC,SAAS,KAAM,MAAQC,IAAI,IAAQC,MAAM,IAAM;EAC1D,MAAMC,SAAS,GAAGJ,QAAQ,CAACK,MAAM,CAAEJ,SAAU,CAAC,CAACK,kBAAkB,CAAC,CAAC;EACnE,MAAMC,eAAe,GAAGC,MAAM,CAACC,OAAO,CAAEL,SAAU,CAAC;EACnDG,eAAe,CAACG,OAAO,CAAE,CAAE,CAAEC,YAAY,EAAEC,eAAe,CAAE,KAAM;IACjE,MAAMC,QAAQ,GACbb,QAAQ,CAACc,MAAM,CAAEb,SAAS,CAAE,EAAEG,SAAS,GAAIO,YAAY,CAAE;IAC1D,IAAK,CAAEE,QAAQ,IAAI,CAAEA,QAAQ,CAACE,gBAAgB,EAAG;MAChD;IACD;IACAH,eAAe,CAACF,OAAO,CAAE,CAAEM,KAAK,EAAEC,IAAI,KAAM;MAC3C;MACA;MACA,IAAKD,KAAK,KAAKE,SAAS,EAAG;QAC1B;MACD;;MAEA;MACA;MACA;MACA,IAAKF,KAAK,CAACG,MAAM,KAAK,UAAU,IAAIH,KAAK,CAACG,MAAM,KAAK,OAAO,EAAG;QAC9D;MACD;MAEA,IAAK,CAAEN,QAAQ,CAACE,gBAAgB,CAAEZ,MAAM,EAAE,GAAGc,IAAK,CAAC,EAAG;QACrD;MACD;;MAEA;MACAjB,QAAQ,CACNoB,QAAQ,CAAEnB,SAAU,CAAC,CACrBoB,oBAAoB,CAAEV,YAAY,EAAEM,IAAK,CAAC;IAC7C,CAAE,CAAC;EACJ,CAAE,CAAC;EACH,OAAOf,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYzB,8BAA8B","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["createEmitter","isPaused","isPending","listeners","Set","notifyListeners","Array","from","forEach","listener","subscribe","add","delete","pause","resume","emit"],"sources":["@wordpress/data/src/utils/emitter.ts"],"sourcesContent":["export interface DataEmitter {\n\temit: VoidFunction;\n\tsubscribe: ( listener: VoidFunction ) => VoidFunction;\n\tpause: VoidFunction;\n\tresume: VoidFunction;\n\tisPaused: boolean;\n}\n\n/**\n * Create an event emitter.\n *\n * @return The event emitter.\n */\nexport function createEmitter(): DataEmitter {\n\tlet isPaused = false;\n\tlet isPending = false;\n\tconst listeners = new Set< VoidFunction >();\n\tconst notifyListeners = () =>\n\t\t// We use Array.from to clone the listeners Set\n\t\t// This ensures that we don't run a listener\n\t\t// that was added as a response to another listener.\n\t\tArray.from( listeners ).forEach( ( listener ) => listener() );\n\n\treturn {\n\t\tget isPaused() {\n\t\t\treturn isPaused;\n\t\t},\n\n\t\tsubscribe( listener ) {\n\t\t\tlisteners.add( listener );\n\t\t\treturn () => listeners.delete( listener );\n\t\t},\n\n\t\tpause() {\n\t\t\tisPaused = true;\n\t\t},\n\n\t\tresume() {\n\t\t\tisPaused = false;\n\t\t\tif ( isPending ) {\n\t\t\t\tisPending = false;\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t},\n\n\t\temit() {\n\t\t\tif ( isPaused ) {\n\t\t\t\tisPending = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnotifyListeners();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAQA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAAA,EAAgB;EAC5C,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,SAAS,GAAG,KAAK;EACrB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAC3C,MAAMC,eAAe,GAAGA,CAAA;EACvB;EACA;EACA;EACAC,KAAK,CAACC,IAAI,CAAEJ,SAAU,CAAC,CAACK,OAAO,CAAIC,QAAQ,IAAMA,QAAQ,CAAC,CAAE,CAAC;EAE9D,OAAO;IACN,IAAIR,QAAQA,CAAA,EAAG;MACd,OAAOA,QAAQ;IAChB,CAAC;IAEDS,SAASA,CAAED,QAAQ,EAAG;MACrBN,SAAS,CAACQ,GAAG,CAAEF,QAAS,CAAC;MACzB,OAAO,MAAMN,SAAS,CAACS,MAAM,CAAEH,QAAS,CAAC;IAC1C,CAAC;IAEDI,KAAKA,CAAA,EAAG;MACPZ,QAAQ,GAAG,IAAI;IAChB,CAAC;IAEDa,MAAMA,CAAA,EAAG;MACRb,QAAQ,GAAG,KAAK;MAChB,IAAKC,SAAS,EAAG;QAChBA,SAAS,GAAG,KAAK;QACjBG,eAAe,CAAC,CAAC;MAClB;IACD,CAAC;IAEDU,IAAIA,CAAA,EAAG;MACN,IAAKd,QAAQ,EAAG;QACfC,SAAS,GAAG,IAAI;QAChB;MACD;MACAG,eAAe,CAAC,CAAC;IAClB;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["createEmitter","isPaused","isPending","listeners","Set","notifyListeners","Array","from","forEach","listener","subscribe","add","delete","pause","resume","emit"],"sources":["@wordpress/data/src/utils/emitter.ts"],"sourcesContent":["export interface DataEmitter {\n\temit: VoidFunction;\n\tsubscribe: ( listener: VoidFunction ) => VoidFunction;\n\tpause: VoidFunction;\n\tresume: VoidFunction;\n\tisPaused: boolean;\n}\n\n/**\n * Create an event emitter.\n *\n * @return The event emitter.\n */\nexport function createEmitter(): DataEmitter {\n\tlet isPaused = false;\n\tlet isPending = false;\n\tconst listeners = new Set< VoidFunction >();\n\tconst notifyListeners = () =>\n\t\t// We use Array.from to clone the listeners Set\n\t\t// This ensures that we don't run a listener\n\t\t// that was added as a response to another listener.\n\t\tArray.from( listeners ).forEach( ( listener ) => listener() );\n\n\treturn {\n\t\tget isPaused() {\n\t\t\treturn isPaused;\n\t\t},\n\n\t\tsubscribe( listener ) {\n\t\t\tlisteners.add( listener );\n\t\t\treturn () => listeners.delete( listener );\n\t\t},\n\n\t\tpause() {\n\t\t\tisPaused = true;\n\t\t},\n\n\t\tresume() {\n\t\t\tisPaused = false;\n\t\t\tif ( isPending ) {\n\t\t\t\tisPending = false;\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t},\n\n\t\temit() {\n\t\t\tif ( isPaused ) {\n\t\t\t\tisPending = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnotifyListeners();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAQA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAAA,EAAgB;EAC5C,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,SAAS,GAAG,KAAK;EACrB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAC3C,MAAMC,eAAe,GAAGA,CAAA;EACvB;EACA;EACA;EACAC,KAAK,CAACC,IAAI,CAAEJ,SAAU,CAAC,CAACK,OAAO,CAAIC,QAAQ,IAAMA,QAAQ,CAAC,CAAE,CAAC;EAE9D,OAAO;IACN,IAAIR,QAAQA,CAAA,EAAG;MACd,OAAOA,QAAQ;IAChB,CAAC;IAEDS,SAASA,CAAED,QAAQ,EAAG;MACrBN,SAAS,CAACQ,GAAG,CAAEF,QAAS,CAAC;MACzB,OAAO,MAAMN,SAAS,CAACS,MAAM,CAAEH,QAAS,CAAC;IAC1C,CAAC;IAEDI,KAAKA,CAAA,EAAG;MACPZ,QAAQ,GAAG,IAAI;IAChB,CAAC;IAEDa,MAAMA,CAAA,EAAG;MACRb,QAAQ,GAAG,KAAK;MAChB,IAAKC,SAAS,EAAG;QAChBA,SAAS,GAAG,KAAK;QACjBG,eAAe,CAAC,CAAC;MAClB;IACD,CAAC;IAEDU,IAAIA,CAAA,EAAG;MACN,IAAKd,QAAQ,EAAG;QACfC,SAAS,GAAG,IAAI;QAChB;MACD;MACAG,eAAe,CAAC,CAAC;IAClB;EACD,CAAC;AACF","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * WordPress dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useRef","useIsomorphicLayoutEffect","useRegistry","useDispatchWithMap","dispatchMap","deps","registry","currentDispatchMapRef","current","currentDispatchProps","dispatch","Object","fromEntries","entries","map","propName","dispatcher","console","warn","args"],"sources":["@wordpress/data/src/components/use-dispatch/use-dispatch-with-map.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param {Function} dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param {Array} deps An array of dependencies for the hook.\n * @return {Object} An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = ( dispatchMap, deps ) => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACpD,SAASC,yBAAyB,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,OAAOC,WAAW,MAAM,mCAAmC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAAEC,WAAW,EAAEC,IAAI,KAAM;EACnD,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAC9B,MAAMK,qBAAqB,GAAGP,MAAM,CAAEI,WAAY,CAAC;EAEnDH,yBAAyB,CAAE,MAAM;IAChCM,qBAAqB,CAACC,OAAO,GAAGJ,WAAW;EAC5C,CAAE,CAAC;EAEH,OAAOL,OAAO,CAAE,MAAM;IACrB,MAAMU,oBAAoB,GAAGF,qBAAqB,CAACC,OAAO,CACzDF,QAAQ,CAACI,QAAQ,EACjBJ,QACD,CAAC;IACD,OAAOK,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAEJ,oBAAqB,CAAC,CAACK,GAAG,CACzC,CAAE,CAAEC,QAAQ,EAAEC,UAAU,CAAE,KAAM;MAC/B,IAAK,OAAOA,UAAU,KAAK,UAAU,EAAG;QACvC;QACAC,OAAO,CAACC,IAAI,CACX,YAAaH,QAAQ,sEACtB,CAAC;MACF;MACA,OAAO,CACNA,QAAQ,EACR,CAAE,GAAGI,IAAI,KACRZ,qBAAqB,CACnBC,OAAO,CAAEF,QAAQ,CAACI,QAAQ,EAAEJ,QAAS,CAAC,CACrCS,QAAQ,CAAE,CAAE,GAAGI,IAAK,CAAC,CACzB;IACF,CACD,CACD,CAAC;EACF,CAAC,EAAE,CAAEb,QAAQ,EAAE,GAAGD,IAAI,CAAG,CAAC;AAC3B,CAAC;AAED,eAAeF,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","useRef","useIsomorphicLayoutEffect","useRegistry","useDispatchWithMap","dispatchMap","deps","registry","currentDispatchMapRef","current","currentDispatchProps","dispatch","Object","fromEntries","entries","map","propName","dispatcher","console","warn","args"],"sources":["@wordpress/data/src/components/use-dispatch/use-dispatch-with-map.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param {Function} dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param {Array} deps An array of dependencies for the hook.\n * @return {Object} An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = ( dispatchMap, deps ) => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACpD,SAASC,yBAAyB,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,OAAOC,WAAW,MAAM,mCAAmC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAAEC,WAAW,EAAEC,IAAI,KAAM;EACnD,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAC9B,MAAMK,qBAAqB,GAAGP,MAAM,CAAEI,WAAY,CAAC;EAEnDH,yBAAyB,CAAE,MAAM;IAChCM,qBAAqB,CAACC,OAAO,GAAGJ,WAAW;EAC5C,CAAE,CAAC;EAEH,OAAOL,OAAO,CAAE,MAAM;IACrB,MAAMU,oBAAoB,GAAGF,qBAAqB,CAACC,OAAO,CACzDF,QAAQ,CAACI,QAAQ,EACjBJ,QACD,CAAC;IACD,OAAOK,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAEJ,oBAAqB,CAAC,CAACK,GAAG,CACzC,CAAE,CAAEC,QAAQ,EAAEC,UAAU,CAAE,KAAM;MAC/B,IAAK,OAAOA,UAAU,KAAK,UAAU,EAAG;QACvC;QACAC,OAAO,CAACC,IAAI,CACX,YAAaH,QAAQ,sEACtB,CAAC;MACF;MACA,OAAO,CACNA,QAAQ,EACR,CAAE,GAAGI,IAAI,KACRZ,qBAAqB,CACnBC,OAAO,CAAEF,QAAQ,CAACI,QAAQ,EAAEJ,QAAS,CAAC,CACrCS,QAAQ,CAAE,CAAE,GAAGI,IAAK,CAAC,CACzB;IACF,CACD,CACD,CAAC;EACF,CAAC,EAAE,CAAEb,QAAQ,EAAE,GAAGD,IAAI,CAAG,CAAC;AAC3B,CAAC;AAED,eAAeF,kBAAkB","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * WordPress dependencies
3
4
  */
@@ -11,6 +12,15 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
11
12
  import useRegistry from '../registry-provider/use-registry';
12
13
  import useAsyncMode from '../async-mode-provider/use-async-mode';
13
14
  const renderQueue = createQueue();
15
+ function warnOnUnstableReference(a, b) {
16
+ if (!a || !b) {
17
+ return;
18
+ }
19
+ const keys = typeof a === 'object' && typeof b === 'object' ? Object.keys(a).filter(k => a[k] !== b[k]) : [];
20
+
21
+ // eslint-disable-next-line no-console
22
+ console.warn('The `useSelect` hook returns different values when called with the same state and parameters.\n' + 'This can lead to unnecessary re-renders and performance issues if not fixed.\n\n' + 'Non-equal value keys: %s\n\n', keys.join(', '));
23
+ }
14
24
 
15
25
  /**
16
26
  * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
@@ -134,12 +144,11 @@ function Store(registry, suspense) {
134
144
  current: null
135
145
  };
136
146
  const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores);
137
- if (process.env.NODE_ENV === 'development') {
147
+ if (globalThis.SCRIPT_DEBUG) {
138
148
  if (!didWarnUnstableReference) {
139
149
  const secondMapResult = mapSelect(select, registry);
140
150
  if (!isShallowEqual(mapResult, secondMapResult)) {
141
- // eslint-disable-next-line no-console
142
- console.warn(`The 'useSelect' hook returns different values when called with the same state and parameters. This can lead to unnecessary rerenders.`);
151
+ warnOnUnstableReference(mapResult, secondMapResult);
143
152
  didWarnUnstableReference = true;
144
153
  }
145
154
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createQueue","useRef","useCallback","useMemo","useSyncExternalStore","useDebugValue","isShallowEqual","useRegistry","useAsyncMode","renderQueue","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","didWarnUnstableReference","storeStatesOnMount","Map","getStoreState","name","_registry$stores$name","stores","store","getState","createSubscriber","activeStores","activeSubscriptions","Set","subscribe","listener","get","clear","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","process","env","NODE_ENV","secondMapResult","console","warn","set","getValue","_useStaticSelect","_useMappingSelect","deps","selector","result","useSelect","staticSelectMode","staticSelectModeRef","prevMode","nextMode","Error","useSuspenseSelect"],"sources":["@wordpress/data/src/components/use-select/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\tconst storeStatesOnMount = new Map();\n\n\tfunction getStoreState( name ) {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( process.env.NODE_ENV === 'development' ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`The 'useSelect' hook returns different values when called with the same state and parameters. This can lead to unnecessary rerenders.`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? _useStaticSelect( mapSelect )\n\t\t: _useMappingSelect( false, mapSelect, deps );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @template {MapSelect} T\n * @param {T} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param {Array} deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws {Promise} A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return {ReturnType<T>} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn _useMappingSelect( true, mapSelect, deps );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,2BAA2B;AACvD,SACCC,MAAM,EACNC,WAAW,EACXC,OAAO,EACPC,oBAAoB,EACpBC,aAAa,QACP,oBAAoB;AAC3B,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,mCAAmC;AAC3D,OAAOC,YAAY,MAAM,uCAAuC;AAEhE,MAAMC,WAAW,GAAGT,WAAW,CAAC,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASU,KAAKA,CAAEC,QAAQ,EAAEC,QAAQ,EAAG;EACpC,MAAMC,MAAM,GAAGD,QAAQ,GAAGD,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S,KAAK,UAAU;EACxD,MAAMsB,mBAAmB,GAAG3E,MAAM,CAAE0E,gBAAiB,CAAC;EAEtD,IAAKA,gBAAgB,KAAKC,mBAAmB,CAAClB,OAAO,EAAG;IACvD,MAAMmB,QAAQ,GAAGD,mBAAmB,CAAClB,OAAO,GAAG,QAAQ,GAAG,SAAS;IACnE,MAAMoB,QAAQ,GAAGH,gBAAgB,GAAG,QAAQ,GAAG,SAAS;IACxD,MAAM,IAAII,KAAK,CACd,4BAA6BF,QAAQ,OAASC,QAAQ,iBACvD,CAAC;EACF;;EAEA;EACA;EACA,OAAOH,gBAAgB,GACpBN,gBAAgB,CAAEf,SAAU,CAAC,GAC7BgB,iBAAiB,CAAE,KAAK,EAAEhB,SAAS,EAAEiB,IAAK,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,iBAAiBA,CAAE1B,SAAS,EAAEiB,IAAI,EAAG;EACpD,OAAOD,iBAAiB,CAAE,IAAI,EAAEhB,SAAS,EAAEiB,IAAK,CAAC;AAClD","ignoreList":[]}
1
+ {"version":3,"names":["createQueue","useRef","useCallback","useMemo","useSyncExternalStore","useDebugValue","isShallowEqual","useRegistry","useAsyncMode","renderQueue","warnOnUnstableReference","a","b","keys","Object","filter","k","console","warn","join","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","didWarnUnstableReference","storeStatesOnMount","Map","getStoreState","name","_registry$stores$name","stores","store","getState","createSubscriber","activeStores","activeSubscriptions","Set","subscribe","listener","get","clear","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","globalThis","SCRIPT_DEBUG","secondMapResult","set","getValue","_useStaticSelect","_useMappingSelect","deps","selector","result","useSelect","staticSelectMode","staticSelectModeRef","prevMode","nextMode","Error","useSuspenseSelect"],"sources":["@wordpress/data/src/components/use-select/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference( a, b ) {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\tconst storeStatesOnMount = new Map();\n\n\tfunction getStoreState( name ) {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( globalThis.SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? _useStaticSelect( mapSelect )\n\t\t: _useMappingSelect( false, mapSelect, deps );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @template {MapSelect} T\n * @param {T} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param {Array} deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws {Promise} A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return {ReturnType<T>} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn _useMappingSelect( true, mapSelect, deps );\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,2BAA2B;AACvD,SACCC,MAAM,EACNC,WAAW,EACXC,OAAO,EACPC,oBAAoB,EACpBC,aAAa,QACP,oBAAoB;AAC3B,OAAOC,cAAc,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EAAEc,IAAK,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,iBAAiBA,CAAEvB,SAAS,EAAEc,IAAI,EAAG;EACpD,OAAOD,iBAAiB,CAAE,IAAI,EAAEb,SAAS,EAAEc,IAAK,CAAC;AAClD","ignoreList":[]}
@@ -3,10 +3,6 @@
3
3
  * and the selector parameters, and recomputes the values only when any of them changes.
4
4
  *
5
5
  * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.
6
- *
7
- * @param {Function} selector Selector function that calculates a value from state and parameters.
8
- * @param {Function} getDependants Function that returns an array of "dependant" objects.
9
- * @return {Function} A memoized version of `selector` that caches the calculated return values.
10
6
  */
11
7
  export { default as createSelector } from 'rememo';
12
8
  //# sourceMappingURL=create-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","createSelector"],"sources":["@wordpress/data/src/create-selector.js"],"sourcesContent":["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n *\n * @param {Function} selector Selector function that calculates a value from state and parameters.\n * @param {Function} getDependants Function that returns an array of \"dependant\" objects.\n * @return {Function} A memoized version of `selector` that caches the calculated return values.\n */\nexport { default as createSelector } from 'rememo';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,cAAc,QAAQ,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["default","createSelector"],"sources":["@wordpress/data/src/create-selector.ts"],"sourcesContent":["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport { default as createSelector } from 'rememo';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,cAAc,QAAQ,QAAQ","ignoreList":[]}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+
1
5
  /**
2
6
  * Creates a selector function that takes additional curried argument with the
3
7
  * registry `select` function. While a regular selector has signature
@@ -33,10 +37,10 @@
33
37
  * registry as argument. The registry binding happens automatically when registering the selector
34
38
  * with a store.
35
39
  *
36
- * @param {Function} registrySelector Function receiving a registry `select`
37
- * function and returning a state selector.
40
+ * @param registrySelector Function receiving a registry `select`
41
+ * function and returning a state selector.
38
42
  *
39
- * @return {Function} Registry selector that can be registered with a store.
43
+ * @return Registry selector that can be registered with a store.
40
44
  */
41
45
  export function createRegistrySelector(registrySelector) {
42
46
  const selectorsByRegistry = new WeakMap();
@@ -60,8 +64,6 @@ export function createRegistrySelector(registrySelector) {
60
64
  * Flag indicating that the selector is a registry selector that needs the correct registry
61
65
  * reference to be assigned to `selector.registry` to make it work correctly.
62
66
  * be mapped as a registry selector.
63
- *
64
- * @type {boolean}
65
67
  */
66
68
  wrappedSelector.isRegistrySelector = true;
67
69
  return wrappedSelector;
@@ -83,9 +85,9 @@ export function createRegistrySelector(registrySelector) {
83
85
  * When registering a control created with `createRegistryControl` with a store, the store
84
86
  * knows which calling convention to use when executing the control.
85
87
  *
86
- * @param {Function} registryControl Function receiving a registry object and returning a control.
88
+ * @param registryControl Function receiving a registry object and returning a control.
87
89
  *
88
- * @return {Function} Registry control that can be registered with a store.
90
+ * @return Registry control that can be registered with a store.
89
91
  */
90
92
  export function createRegistryControl(registryControl) {
91
93
  registryControl.isRegistryControl = true;
@@ -1 +1 @@
1
- {"version":3,"names":["createRegistrySelector","registrySelector","selectorsByRegistry","WeakMap","wrappedSelector","args","selector","get","registry","select","set","isRegistrySelector","createRegistryControl","registryControl","isRegistryControl"],"sources":["@wordpress/data/src/factory.js"],"sourcesContent":["/**\n * Creates a selector function that takes additional curried argument with the\n * registry `select` function. While a regular selector has signature\n * ```js\n * ( state, ...selectorArgs ) => ( result )\n * ```\n * that allows to select data from the store's `state`, a registry selector\n * has signature:\n * ```js\n * ( select ) => ( state, ...selectorArgs ) => ( result )\n * ```\n * that supports also selecting from other registered stores.\n *\n * @example\n * ```js\n * import { store as coreStore } from '@wordpress/core-data';\n * import { store as editorStore } from '@wordpress/editor';\n *\n * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {\n * return select( editorStore ).getCurrentPostId();\n * } );\n *\n * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {\n * // calling another registry selector just like any other function\n * const postType = getCurrentPostType( state );\n * const postId = getCurrentPostId( state );\n *\t return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );\n * } );\n * ```\n *\n * Note how the `getCurrentPostId` selector can be called just like any other function,\n * (it works even inside a regular non-registry selector) and we don't need to pass the\n * registry as argument. The registry binding happens automatically when registering the selector\n * with a store.\n *\n * @param {Function} registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return {Function} Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector( registrySelector ) {\n\tconst selectorsByRegistry = new WeakMap();\n\t// Create a selector function that is bound to the registry referenced by `selector.registry`\n\t// and that has the same API as a regular selector. Binding it in such a way makes it\n\t// possible to call the selector directly from another selector.\n\tconst wrappedSelector = ( ...args ) => {\n\t\tlet selector = selectorsByRegistry.get( wrappedSelector.registry );\n\t\t// We want to make sure the cache persists even when new registry\n\t\t// instances are created. For example patterns create their own editors\n\t\t// with their own core/block-editor stores, so we should keep track of\n\t\t// the cache for each registry instance.\n\t\tif ( ! selector ) {\n\t\t\tselector = registrySelector( wrappedSelector.registry.select );\n\t\t\tselectorsByRegistry.set( wrappedSelector.registry, selector );\n\t\t}\n\t\treturn selector( ...args );\n\t};\n\n\t/**\n\t * Flag indicating that the selector is a registry selector that needs the correct registry\n\t * reference to be assigned to `selector.registry` to make it work correctly.\n\t * be mapped as a registry selector.\n\t *\n\t * @type {boolean}\n\t */\n\twrappedSelector.isRegistrySelector = true;\n\n\treturn wrappedSelector;\n}\n\n/**\n * Creates a control function that takes additional curried argument with the `registry` object.\n * While a regular control has signature\n * ```js\n * ( action ) => ( iteratorOrPromise )\n * ```\n * where the control works with the `action` that it's bound to, a registry control has signature:\n * ```js\n * ( registry ) => ( action ) => ( iteratorOrPromise )\n * ```\n * A registry control is typically used to select data or dispatch an action to a registered\n * store.\n *\n * When registering a control created with `createRegistryControl` with a store, the store\n * knows which calling convention to use when executing the control.\n *\n * @param {Function} registryControl Function receiving a registry object and returning a control.\n *\n * @return {Function} Registry control that can be registered with a store.\n */\nexport function createRegistryControl( registryControl ) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sBAAsBA,CAAEC,gBAAgB,EAAG;EAC1D,MAAMC,mBAAmB,GAAG,IAAIC,OAAO,CAAC,CAAC;EACzC;EACA;EACA;EACA,MAAMC,eAAe,GAAGA,CAAE,GAAGC,IAAI,KAAM;IACtC,IAAIC,QAAQ,GAAGJ,mBAAmB,CAACK,GAAG,CAAEH,eAAe,CAACI,QAAS,CAAC;IAClE;IACA;IACA;IACA;IACA,IAAK,CAAEF,QAAQ,EAAG;MACjBA,QAAQ,GAAGL,gBAAgB,CAAEG,eAAe,CAACI,QAAQ,CAACC,MAAO,CAAC;MAC9DP,mBAAmB,CAACQ,GAAG,CAAEN,eAAe,CAACI,QAAQ,EAAEF,QAAS,CAAC;IAC9D;IACA,OAAOA,QAAQ,CAAE,GAAGD,IAAK,CAAC;EAC3B,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;EACCD,eAAe,CAACO,kBAAkB,GAAG,IAAI;EAEzC,OAAOP,eAAe;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,qBAAqBA,CAAEC,eAAe,EAAG;EACxDA,eAAe,CAACC,iBAAiB,GAAG,IAAI;EAExC,OAAOD,eAAe;AACvB","ignoreList":[]}
1
+ {"version":3,"names":["createRegistrySelector","registrySelector","selectorsByRegistry","WeakMap","wrappedSelector","args","selector","get","registry","select","set","isRegistrySelector","createRegistryControl","registryControl","isRegistryControl"],"sources":["@wordpress/data/src/factory.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { select as globalSelect } from './select';\n\ntype RegistrySelector< Selector extends ( ...args: any[] ) => any > = {\n\t( ...args: Parameters< Selector > ): ReturnType< Selector >;\n\tisRegistrySelector?: boolean;\n\tregistry?: any;\n};\n\n/**\n * Creates a selector function that takes additional curried argument with the\n * registry `select` function. While a regular selector has signature\n * ```js\n * ( state, ...selectorArgs ) => ( result )\n * ```\n * that allows to select data from the store's `state`, a registry selector\n * has signature:\n * ```js\n * ( select ) => ( state, ...selectorArgs ) => ( result )\n * ```\n * that supports also selecting from other registered stores.\n *\n * @example\n * ```js\n * import { store as coreStore } from '@wordpress/core-data';\n * import { store as editorStore } from '@wordpress/editor';\n *\n * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {\n * return select( editorStore ).getCurrentPostId();\n * } );\n *\n * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {\n * // calling another registry selector just like any other function\n * const postType = getCurrentPostType( state );\n * const postId = getCurrentPostId( state );\n *\t return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );\n * } );\n * ```\n *\n * Note how the `getCurrentPostId` selector can be called just like any other function,\n * (it works even inside a regular non-registry selector) and we don't need to pass the\n * registry as argument. The registry binding happens automatically when registering the selector\n * with a store.\n *\n * @param registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector<\n\tSelector extends ( ...args: any[] ) => any,\n>(\n\tregistrySelector: ( select: typeof globalSelect ) => Selector\n): RegistrySelector< Selector > {\n\tconst selectorsByRegistry = new WeakMap();\n\t// Create a selector function that is bound to the registry referenced by `selector.registry`\n\t// and that has the same API as a regular selector. Binding it in such a way makes it\n\t// possible to call the selector directly from another selector.\n\tconst wrappedSelector: RegistrySelector< Selector > = ( ...args ) => {\n\t\tlet selector = selectorsByRegistry.get( wrappedSelector.registry );\n\t\t// We want to make sure the cache persists even when new registry\n\t\t// instances are created. For example patterns create their own editors\n\t\t// with their own core/block-editor stores, so we should keep track of\n\t\t// the cache for each registry instance.\n\t\tif ( ! selector ) {\n\t\t\tselector = registrySelector( wrappedSelector.registry.select );\n\t\t\tselectorsByRegistry.set( wrappedSelector.registry, selector );\n\t\t}\n\t\treturn selector( ...args );\n\t};\n\n\t/**\n\t * Flag indicating that the selector is a registry selector that needs the correct registry\n\t * reference to be assigned to `selector.registry` to make it work correctly.\n\t * be mapped as a registry selector.\n\t */\n\twrappedSelector.isRegistrySelector = true;\n\n\treturn wrappedSelector;\n}\n\n/**\n * Creates a control function that takes additional curried argument with the `registry` object.\n * While a regular control has signature\n * ```js\n * ( action ) => ( iteratorOrPromise )\n * ```\n * where the control works with the `action` that it's bound to, a registry control has signature:\n * ```js\n * ( registry ) => ( action ) => ( iteratorOrPromise )\n * ```\n * A registry control is typically used to select data or dispatch an action to a registered\n * store.\n *\n * When registering a control created with `createRegistryControl` with a store, the store\n * knows which calling convention to use when executing the control.\n *\n * @param registryControl Function receiving a registry object and returning a control.\n *\n * @return Registry control that can be registered with a store.\n */\nexport function createRegistryControl< T extends ( ...args: any ) => any >(\n\tregistryControl: T & { isRegistryControl?: boolean }\n) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"],"mappings":"AAAA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sBAAsBA,CAGrCC,gBAA6D,EAC9B;EAC/B,MAAMC,mBAAmB,GAAG,IAAIC,OAAO,CAAC,CAAC;EACzC;EACA;EACA;EACA,MAAMC,eAA6C,GAAGA,CAAE,GAAGC,IAAI,KAAM;IACpE,IAAIC,QAAQ,GAAGJ,mBAAmB,CAACK,GAAG,CAAEH,eAAe,CAACI,QAAS,CAAC;IAClE;IACA;IACA;IACA;IACA,IAAK,CAAEF,QAAQ,EAAG;MACjBA,QAAQ,GAAGL,gBAAgB,CAAEG,eAAe,CAACI,QAAQ,CAACC,MAAO,CAAC;MAC9DP,mBAAmB,CAACQ,GAAG,CAAEN,eAAe,CAACI,QAAQ,EAAEF,QAAS,CAAC;IAC9D;IACA,OAAOA,QAAQ,CAAE,GAAGD,IAAK,CAAC;EAC3B,CAAC;;EAED;AACD;AACA;AACA;AACA;EACCD,eAAe,CAACO,kBAAkB,GAAG,IAAI;EAEzC,OAAOP,eAAe;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,qBAAqBA,CACpCC,eAAoD,EACnD;EACDA,eAAe,CAACC,iBAAiB,GAAG,IAAI;EAExC,OAAOD,eAAe;AACvB","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * External dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["isPlainObject","deepmerge","defaultStorage","combineReducers","DEFAULT_STORAGE","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","lastState","registerStore","persist","persistedState","initialState","type","isMergeableObject","store","subscribe","__unstableMigrate"],"sources":["@wordpress/data/src/plugins/persistence/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { isPlainObject } from 'is-plain-object';\nimport deepmerge from 'deepmerge';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst { storage = DEFAULT_STORAGE, storageKey = DEFAULT_STORAGE_KEY } =\n\t\toptions;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = deepmerge( initialState, persistedState, {\n\t\t\t\t\t\tisMergeableObject: isPlainObject,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\npersistencePlugin.__unstableMigrate = () => {};\n\nexport default persistencePlugin;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,OAAOC,SAAS,MAAM,WAAW;;AAEjC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,SAASC,eAAe,QAAQ,QAAQ;;AAExC;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGF,cAAc;;AAEtC;AACA;AACA;AACA;AACA;AACA,MAAMG,mBAAmB,GAAG,SAAS;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAKC,OAAO,IAAM,CAAEC,KAAK,EAAEC,MAAM,KAAM;EACpE,IAAKA,MAAM,CAACC,SAAS,KAAKF,KAAK,EAAG;IACjC,OAAOA,KAAK;EACb;EAEA,OAAOD,OAAO,CAAEC,KAAK,EAAEC,MAAO,CAAC;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,0BAA0BA,CAAEC,OAAO,EAAG;EACrD,MAAM;IAAEC,OAAO,GAAGT,eAAe;IAAEU,UAAU,GAAGT;EAAoB,CAAC,GACpEO,OAAO;EAER,IAAIG,IAAI;;EAER;AACD;AACA;AACA;AACA;EACC,SAASC,OAAOA,CAAA,EAAG;IAClB,IAA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AAEiD,YAAY,EAAED,cAAc,EAAE;YACvDG,iBAAiB,EAAEpD;UACpB,CAAE,CAAC;QACJ,CAAC,MAAM;UACN;UACA;UACAkD,YAAY,GAAGD,cAAc;QAC9B;QAEArC,OAAO,GAAG;UACT,GAAGA,OAAO;UACVsC;QACD,CAAC;MACF;MAEA,MAAMG,KAAK,GAAGtB,QAAQ,CAACgB,aAAa,CAAEX,SAAS,EAAExB,OAAQ,CAAC;MAE1DyC,KAAK,CAACC,SAAS,CACdpB,qBAAqB,CACpBmB,KAAK,CAAClB,QAAQ,EACdC,SAAS,EACTxB,OAAO,CAACoC,OACT,CACD,CAAC;MAED,OAAOK,KAAK;IACb;EACD,CAAC;AACF;AAEAvB,iBAAiB,CAACyB,iBAAiB,GAAG,MAAM,CAAC,CAAC;AAE9C,eAAezB,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["isPlainObject","deepmerge","defaultStorage","combineReducers","DEFAULT_STORAGE","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","lastState","registerStore","persist","persistedState","initialState","type","isMergeableObject","store","subscribe","__unstableMigrate"],"sources":["@wordpress/data/src/plugins/persistence/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { isPlainObject } from 'is-plain-object';\nimport deepmerge from 'deepmerge';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst { storage = DEFAULT_STORAGE, storageKey = DEFAULT_STORAGE_KEY } =\n\t\toptions;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = deepmerge( initialState, persistedState, {\n\t\t\t\t\t\tisMergeableObject: isPlainObject,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\npersistencePlugin.__unstableMigrate = () => {};\n\nexport default persistencePlugin;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,OAAOC,SAAS,MAAM,WAAW;;AAEjC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,SAASC,eAAe,QAAQ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