@wordpress/data 8.3.3 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +9 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js +6 -10
- package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch.js +2 -2
- package/build/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build/components/use-select/index.js +7 -5
- package/build/components/use-select/index.js.map +1 -1
- package/build/index.js +14 -5
- package/build/index.js.map +1 -1
- package/build/plugins/persistence/index.js +4 -2
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/redux-store/index.js +35 -17
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/reducer.js +2 -2
- package/build/redux-store/metadata/reducer.js.map +1 -1
- package/build/redux-store/metadata/selectors.js +1 -7
- package/build/redux-store/metadata/selectors.js.map +1 -1
- package/build/redux-store/metadata/utils.js +2 -2
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build/registry.js +7 -11
- package/build/registry.js.map +1 -1
- package/build/resolvers-cache-middleware.js +3 -7
- package/build/resolvers-cache-middleware.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +6 -9
- package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +2 -2
- package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build-module/components/use-select/index.js +7 -5
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/index.js +6 -2
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/persistence/index.js +4 -2
- package/build-module/plugins/persistence/index.js.map +1 -1
- package/build-module/redux-store/index.js +25 -6
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/reducer.js +2 -2
- package/build-module/redux-store/metadata/reducer.js.map +1 -1
- package/build-module/redux-store/metadata/selectors.js +1 -6
- package/build-module/redux-store/metadata/selectors.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js +2 -2
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-module/registry.js +7 -10
- package/build-module/registry.js.map +1 -1
- package/build-module/resolvers-cache-middleware.js +3 -6
- package/build-module/resolvers-cache-middleware.js.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch.d.ts +4 -4
- package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
- package/build-types/components/use-select/index.d.ts +3 -3
- package/build-types/components/use-select/index.d.ts.map +1 -1
- package/build-types/index.d.ts +41 -41
- package/build-types/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/index.d.ts.map +1 -1
- package/build-types/redux-store/index.d.ts +6 -4
- package/build-types/redux-store/index.d.ts.map +1 -1
- package/build-types/redux-store/metadata/reducer.d.ts +2 -2
- package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
- package/build-types/redux-store/metadata/utils.d.ts +2 -2
- package/build-types/registry.d.ts.map +1 -1
- package/build-types/resolvers-cache-middleware.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/components/use-dispatch/use-dispatch-with-map.js +19 -17
- package/src/components/use-dispatch/use-dispatch.js +2 -2
- package/src/components/use-select/index.js +6 -4
- package/src/index.js +6 -2
- package/src/plugins/persistence/index.js +4 -2
- package/src/redux-store/index.js +25 -5
- package/src/redux-store/metadata/reducer.ts +2 -2
- package/src/redux-store/metadata/selectors.js +1 -6
- package/src/redux-store/metadata/utils.ts +2 -2
- package/src/registry.js +13 -13
- package/src/resolvers-cache-middleware.js +4 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/selectors.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/selectors.js"],"names":["selectorArgsToStateKey","getResolutionState","state","selectorName","args","map","get","getIsResolving","resolutionState","status","hasStartedResolution","undefined","hasFinishedResolution","hasResolutionFailed","getResolutionError","error","isResolving","getCachedResolvers"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,SAAvC;AAEA;;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,KAA7B,EAAoCC,YAApC,EAAkDC,IAAlD,EAAyD;AAC/D,QAAMC,GAAG,GAAGH,KAAK,CAAEC,YAAF,CAAjB;;AACA,MAAK,CAAEE,GAAP,EAAa;AACZ;AACA;;AAED,SAAOA,GAAG,CAACC,GAAJ,CAASN,sBAAsB,CAAEI,IAAF,CAA/B,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,cAAT,CAAyBL,KAAzB,EAAgCC,YAAhC,EAA8CC,IAA9C,EAAqD;AAC3D,QAAMI,eAAe,GAAGP,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAA1C;AAEA,SAAOI,eAAe,IAAIA,eAAe,CAACC,MAAhB,KAA2B,WAArD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,CAA+BR,KAA/B,EAAsCC,YAAtC,EAAoDC,IAApD,EAA2D;AACjE,SAAOH,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAlB,KAAoDO,SAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCV,KAAhC,EAAuCC,YAAvC,EAAqDC,IAArD,EAA4D;AAAA;;AAClE,QAAMK,MAAM,0BAAGR,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAArB,wDAAG,oBAAiDK,MAAhE;AACA,SAAOA,MAAM,KAAK,UAAX,IAAyBA,MAAM,KAAK,OAA3C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,mBAAT,CAA8BX,KAA9B,EAAqCC,YAArC,EAAmDC,IAAnD,EAA0D;AAAA;;AAChE,SAAO,yBAAAH,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAlB,8EAAiDK,MAAjD,MAA4D,OAAnE;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,kBAAT,CAA6BZ,KAA7B,EAAoCC,YAApC,EAAkDC,IAAlD,EAAyD;AAC/D,QAAMI,eAAe,GAAGP,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAA1C;AACA,SAAO,CAAAI,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAEC,MAAjB,MAA4B,OAA5B,GAAsCD,eAAe,CAACO,KAAtD,GAA8D,IAArE;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBd,KAAtB,EAA6BC,YAA7B,EAA2CC,IAA3C,EAAkD;AAAA;;AACxD,SACC,yBAAAH,kBAAkB,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAlB,8EAAiDK,MAAjD,MAA4D,WAD7D;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASQ,kBAAT,CAA6Bf,KAA7B,EAAqC;AAC3C,SAAOA,KAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\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 the raw `isResolving` 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 {boolean | undefined} isResolving value.\n */\nexport function getIsResolving( state, selectorName, args ) {\n\tconst resolutionState = getResolutionState( state, selectorName, args );\n\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"]}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
7
7
|
* by a property on the action object.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param actionProperty Action property by which to key object.
|
|
10
10
|
* @return Higher-order reducer.
|
|
11
11
|
*/
|
|
12
12
|
export const onSubKey = actionProperty => reducer => function () {
|
|
@@ -36,7 +36,7 @@ export const onSubKey = actionProperty => reducer => function () {
|
|
|
36
36
|
* Normalize selector argument array by defaulting `undefined` value to an empty array
|
|
37
37
|
* and removing trailing `undefined` values.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
39
|
+
* @param args Selector argument array
|
|
40
40
|
* @return Normalized state key array
|
|
41
41
|
*/
|
|
42
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/utils.ts"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState","selectorArgsToStateKey","args","len","length","idx","slice"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAEnBC,cADD,IAICC,OADD,IAGA,YAAoD;AAAA,MAAlDC,KAAkD,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;AACnD;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANkD,CAQnD;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CA1BK;AA4BP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,IAAjC,EAAsE;AAC5E,MAAKA,IAAI,KAAKH,SAAT,IAAsBG,IAAI,KAAK,IAApC,EAA2C;AAC1C,WAAO,EAAP;AACA;;AAED,QAAMC,GAAG,GAAGD,IAAI,CAACE,MAAjB;AACA,MAAIC,GAAG,GAAGF,GAAV;;AACA,SAAQE,GAAG,GAAG,CAAN,IAAWH,IAAI,CAAEG,GAAG,GAAG,CAAR,CAAJ,KAAoBN,SAAvC,EAAmD;AAClDM,IAAAA,GAAG;AACH;;AACD,SAAOA,GAAG,KAAKF,GAAR,GAAcD,IAAd,GAAqBA,IAAI,CAACI,KAAL,CAAY,CAAZ,EAAeD,GAAf,CAA5B;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport type { AnyAction, Reducer } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/utils.ts"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState","selectorArgsToStateKey","args","len","length","idx","slice"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAEnBC,cADD,IAICC,OADD,IAGA,YAAoD;AAAA,MAAlDC,KAAkD,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;AACnD;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANkD,CAQnD;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CA1BK;AA4BP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,IAAjC,EAAsE;AAC5E,MAAKA,IAAI,KAAKH,SAAT,IAAsBG,IAAI,KAAK,IAApC,EAA2C;AAC1C,WAAO,EAAP;AACA;;AAED,QAAMC,GAAG,GAAGD,IAAI,CAACE,MAAjB;AACA,MAAIC,GAAG,GAAGF,GAAV;;AACA,SAAQE,GAAG,GAAG,CAAN,IAAWH,IAAI,CAAEG,GAAG,GAAG,CAAR,CAAJ,KAAoBN,SAAvC,EAAmD;AAClDM,IAAAA,GAAG;AACH;;AACD,SAAOA,GAAG,KAAKF,GAAR,GAAcD,IAAd,GAAqBA,IAAI,CAACI,KAAL,CAAY,CAAZ,EAAeD,GAAf,CAA5B;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport type { AnyAction, Reducer } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param actionProperty Action property by which to key object.\n * @return Higher-order reducer.\n */\nexport const onSubKey =\n\t< TState extends unknown, TAction extends AnyAction >(\n\t\tactionProperty: string\n\t) =>\n\t(\n\t\treducer: Reducer< TState, TAction >\n\t): Reducer< Record< string, TState >, TAction > =>\n\t( state: Record< string, TState > = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\n/**\n * Normalize selector argument array by defaulting `undefined` value to an empty array\n * and removing trailing `undefined` values.\n *\n * @param args Selector argument array\n * @return Normalized state key array\n */\nexport function selectorArgsToStateKey( args: unknown[] | null | undefined ) {\n\tif ( args === undefined || args === null ) {\n\t\treturn [];\n\t}\n\n\tconst len = args.length;\n\tlet idx = len;\n\twhile ( idx > 0 && args[ idx - 1 ] === undefined ) {\n\t\tidx--;\n\t}\n\treturn idx === len ? args : args.slice( 0, idx );\n}\n"]}
|
package/build-module/registry.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { mapValues } from 'lodash';
|
|
5
1
|
/**
|
|
6
2
|
* WordPress dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import deprecated from '@wordpress/deprecated';
|
|
10
5
|
/**
|
|
11
6
|
* Internal dependencies
|
|
@@ -216,15 +211,17 @@ export function createRegistry() {
|
|
|
216
211
|
|
|
217
212
|
|
|
218
213
|
function withPlugins(attributes) {
|
|
219
|
-
return
|
|
214
|
+
return Object.fromEntries(Object.entries(attributes).map(_ref => {
|
|
215
|
+
let [key, attribute] = _ref;
|
|
216
|
+
|
|
220
217
|
if (typeof attribute !== 'function') {
|
|
221
|
-
return attribute;
|
|
218
|
+
return [key, attribute];
|
|
222
219
|
}
|
|
223
220
|
|
|
224
|
-
return function () {
|
|
221
|
+
return [key, function () {
|
|
225
222
|
return registry[key].apply(null, arguments);
|
|
226
|
-
};
|
|
227
|
-
});
|
|
223
|
+
}];
|
|
224
|
+
}));
|
|
228
225
|
}
|
|
229
226
|
/**
|
|
230
227
|
* Registers a store instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["mapValues","deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","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","attribute","key","registry","apply","arguments","registerStoreInstance","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","Object","values","forEach","resume","namespaces","use","plugin","config","entries","registryWithPlugins","privateActions","privateSelectors"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,IAAT,EAAeC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A+BwD,cAAtC;AACA,OAFD,CAEE,OAAQrB,CAAR,EAAY;AACb;AACA;AACA,eAAO,EAAP;AACA;AACD,KATyB;AAU1BD,IAAAA,kBAAkB,EAAI9C,IAAF,IAAY;AAC/B,UAAI;AACH,eAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAF,CAAN,CAAeY,KAAjB,CAAN,CAA+ByD,gBAAtC;AACA,OAFD,CAEE,OAAQtB,CAAR,EAAY;AACb,eAAO,EAAP;AACA;AACD;AAhByB,GAAvB,CAAJ;AAkBA,SAAOoB,mBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\n/**\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 './private-apis';\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 mapValues( attributes, ( attribute, key ) => {\n\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\treturn attribute;\n\t\t\t}\n\t\t\treturn function () {\n\t\t\t\treturn registry[ key ].apply( null, arguments );\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 {Object} store Store instance object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, store ) {\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\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, store.instantiate( registry ) );\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 = createReduxStore( storeName, options ).instantiate(\n\t\t\tregistry\n\t\t);\n\t\tregisterStoreInstance( storeName, store );\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","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","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","values","forEach","resume","namespaces","use","plugin","config","registryWithPlugins","privateActions","privateSelectors"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,IAAT,EAAeC,MAAf,QAA6B,gBAA7B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,SAASC,YAAT,CAAuBC,qBAAvB,EAA+C;AAC9C,SAAO,OAAOA,qBAAP,KAAiC,QAAjC,GACJA,qBADI,GAEJA,qBAAqB,CAACC,IAFzB;AAGA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,cAAT,GAA4D;AAAA,MAAnCC,YAAmC,uEAApB,EAAoB;AAAA,MAAhBC,MAAgB,uEAAP,IAAO;AAClE,QAAMC,MAAM,GAAG,EAAf;AACA,QAAMC,OAAO,GAAGV,aAAa,EAA7B;AACA,MAAIW,eAAe,GAAG,IAAtB;AAEA;AACD;AACA;;AACC,WAASC,cAAT,GAA0B;AACzBF,IAAAA,OAAO,CAACG,IAAR;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMC,SAAS,GAAG,CAAEC,QAAF,EAAYX,qBAAZ,KAAuC;AACxD;AACA,QAAK,CAAEA,qBAAP,EAA+B;AAC9B,aAAOM,OAAO,CAACI,SAAR,CAAmBC,QAAnB,CAAP;AACA,KAJuD,CAMxD;;;AACA,UAAMC,SAAS,GAAGb,YAAY,CAAEC,qBAAF,CAA9B;AACA,UAAMa,KAAK,GAAGR,MAAM,CAAEO,SAAF,CAApB;;AACA,QAAKC,KAAL,EAAa;AACZ,aAAOA,KAAK,CAAC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Q,CAACc,QAAT,CAAmB3D,gBAAgB,CAAEO,IAAF,EAAQoE,MAAR,CAAnC;AACA;;AAED,MAAKjE,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACM,SAAP,CAAkBF,cAAlB;AACA;;AAED,QAAM8D,mBAAmB,GAAGvC,WAAW,CAAEQ,QAAF,CAAvC;AACA1C,EAAAA,IAAI,CAAEyE,mBAAF,EAAuB;AAC1BrB,IAAAA,gBAAgB,EAAIhD,IAAF,IAAY;AAC7B,UAAI;AACH,eAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAF,CAAN,CAAeY,KAAjB,CAAN,CAA+B0D,cAAtC;AACA,OAFD,CAEE,OAAQnB,CAAR,EAAY;AACb;AACA;AACA,eAAO,EAAP;AACA;AACD,KATyB;AAU1BD,IAAAA,kBAAkB,EAAIlD,IAAF,IAAY;AAC/B,UAAI;AACH,eAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAF,CAAN,CAAeY,KAAjB,CAAN,CAA+B2D,gBAAtC;AACA,OAFD,CAEE,OAAQpB,CAAR,EAAY;AACb,eAAO,EAAP;AACA;AACD;AAhByB,GAAvB,CAAJ;AAkBA,SAAOkB,mBAAP;AACA","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 './private-apis';\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 {Object} store Store instance object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, store ) {\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\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, store.instantiate( registry ) );\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 = createReduxStore( storeName, options ).instantiate(\n\t\t\tregistry\n\t\t);\n\t\tregisterStoreInstance( storeName, store );\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\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"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
1
|
/**
|
|
6
2
|
* Internal dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import coreDataStore from './store';
|
|
10
5
|
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
|
|
11
6
|
|
|
@@ -23,8 +18,10 @@ import coreDataStore from './store';
|
|
|
23
18
|
const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
|
|
24
19
|
const resolvers = registry.select(coreDataStore).getCachedResolvers(reducerKey);
|
|
25
20
|
Object.entries(resolvers).forEach(_ref => {
|
|
21
|
+
var _registry$stores, _registry$stores$redu, _registry$stores$redu2;
|
|
22
|
+
|
|
26
23
|
let [selectorName, resolversByArgs] = _ref;
|
|
27
|
-
const resolver =
|
|
24
|
+
const resolver = (_registry$stores = registry.stores) === null || _registry$stores === void 0 ? void 0 : (_registry$stores$redu = _registry$stores[reducerKey]) === null || _registry$stores$redu === void 0 ? void 0 : (_registry$stores$redu2 = _registry$stores$redu.resolvers) === null || _registry$stores$redu2 === void 0 ? void 0 : _registry$stores$redu2[selectorName];
|
|
28
25
|
|
|
29
26
|
if (!resolver || !resolver.shouldInvalidate) {
|
|
30
27
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["coreDataStore","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","status","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,SAA1B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,GACnC,CAAEC,QAAF,EAAYC,UAAZ,KAA4B,MAAQC,IAAF,IAAcC,MAAF,IAAc;AAC3D,QAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MADgB,CACRP,aADQ,EAEhBQ,kBAFgB,CAEIL,UAFJ,CAAlB;AAGAM,EAAAA,MAAM,CAACC,OAAP,CAAgBJ,SAAhB,EAA4BK,OAA5B,CACC,QAAyC;AAAA;;AAAA,QAAvC,CAAEC,YAAF,EAAgBC,eAAhB,CAAuC;AACxC,UAAMC,QAAQ,uBACbZ,QAAQ,CAACa,MADI,8EACb,iBAAmBZ,UAAnB,CADa,oFACb,sBAAiCG,SADpB,2DACb,uBACCM,YADD,CADD;;AAIA,QAAK,CAAEE,QAAF,IAAc,CAAEA,QAAQ,CAACE,gBAA9B,EAAiD;AAChD;AACA;;AACDH,IAAAA,eAAe,CAACF,OAAhB,CAAyB,CAAEM,KAAF,EAASC,IAAT,KAAmB;AAC3C;AACA;AACA;AACA,UACG,CAAAD,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEE,MAAP,MAAkB,UAAlB,IACD,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEE,MAAP,MAAkB,OADnB,IAEA,CAAEL,QAAQ,CAACE,gBAAT,CAA2BX,MAA3B,EAAmC,GAAGa,IAAtC,CAHH,EAIE;AACD;AACA,OAV0C,CAY3C;;;AACAhB,MAAAA,QAAQ,CACNkB,QADF,CACYpB,aADZ,EAEEqB,oBAFF,CAEwBlB,UAFxB,EAEoCS,YAFpC,EAEkDM,IAFlD;AAGA,KAhBD;AAiBA,GA1BF;AA4BA,SAAOd,IAAI,CAAEC,MAAF,CAAX;AACA,CAlCF;;AAoCA,eAAeJ,8BAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport coreDataStore from './store';\n\n/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry The registry reference for which to create\n * the middleware.\n * @param {string} reducerKey The namespace for which to create the\n * middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, reducerKey ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getCachedResolvers( reducerKey );\n\t\tObject.entries( resolvers ).forEach(\n\t\t\t( [ selectorName, resolversByArgs ] ) => {\n\t\t\t\tconst resolver =\n\t\t\t\t\tregistry.stores?.[ reducerKey ]?.resolvers?.[\n\t\t\t\t\t\tselectorName\n\t\t\t\t\t];\n\t\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\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\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\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\t\tif (\n\t\t\t\t\t\t( value?.status !== 'finished' &&\n\t\t\t\t\t\t\tvalue?.status !== 'error' ) ||\n\t\t\t\t\t\t! resolver.shouldInvalidate( action, ...args )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Trigger cache invalidation\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreDataStore )\n\t\t\t\t\t\t.invalidateResolution( reducerKey, selectorName, args );\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dispatch-with-map.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch-with-map.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"use-dispatch-with-map.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch-with-map.js"],"names":[],"mappings":";AAWA;;;;;;;;;;;;;GAaG;AACH,yEAHY,MAAM,CAoCjB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default useDispatch;
|
|
2
|
-
export type StoreDescriptor<StoreConfig> = import('../../types').StoreDescriptor<StoreConfig>;
|
|
2
|
+
export type StoreDescriptor<StoreConfig extends import("../../types").AnyConfig> = import('../../types').StoreDescriptor<StoreConfig>;
|
|
3
3
|
export type UseDispatchReturn<StoreNameOrDescriptor> = import('../../types').UseDispatchReturn<StoreNameOrDescriptor>;
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
|
|
6
|
-
* @template StoreConfig
|
|
6
|
+
* @template {import('../../types').AnyConfig} StoreConfig
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
|
|
@@ -15,7 +15,7 @@ export type UseDispatchReturn<StoreNameOrDescriptor> = import('../../types').Use
|
|
|
15
15
|
* Note: The component using this hook must be within the context of a
|
|
16
16
|
* RegistryProvider.
|
|
17
17
|
*
|
|
18
|
-
* @template {undefined | string | StoreDescriptor<any>}
|
|
18
|
+
* @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor
|
|
19
19
|
* @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
|
|
20
20
|
* store or its descriptor from which to
|
|
21
21
|
* retrieve action creators. If not
|
|
@@ -55,5 +55,5 @@ export type UseDispatchReturn<StoreNameOrDescriptor> = import('../../types').Use
|
|
|
55
55
|
* ```
|
|
56
56
|
* @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.
|
|
57
57
|
*/
|
|
58
|
-
declare function useDispatch(storeNameOrDescriptor?:
|
|
58
|
+
declare function useDispatch<StoreNameOrDescriptor extends string | import("../../types").StoreDescriptor<any> | undefined>(storeNameOrDescriptor?: StoreNameOrDescriptor | undefined): import("../../types").UseDispatchReturn<StoreNameOrDescriptor>;
|
|
59
59
|
//# sourceMappingURL=use-dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dispatch.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"use-dispatch.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch.js"],"names":[],"mappings":";mFAMa,OAAO,aAAa,EAAE,eAAe,CAAC,WAAW,CAAC;uDAIlD,OAAO,aAAa,EAAE,iBAAiB,CAAC,qBAAqB,CAAC;AAL3E;;;GAGG;AACH;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,uPAKC"}
|
|
@@ -79,8 +79,8 @@ export default function useSelect<T extends import("../../types").MapSelect | im
|
|
|
79
79
|
* @return {Object} Data object returned by the `mapSelect` function.
|
|
80
80
|
*/
|
|
81
81
|
export function useSuspenseSelect(mapSelect: Function, deps: any[]): Object;
|
|
82
|
-
export type StoreDescriptor<C> = import('../../types').StoreDescriptor<C>;
|
|
83
|
-
export type ReduxStoreConfig<State, Actions, Selectors> = import('../../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
84
|
-
export type UseSelectReturn<T> = import('../../types').UseSelectReturn<T>;
|
|
82
|
+
export type StoreDescriptor<C extends import("../../types").AnyConfig> = import('../../types').StoreDescriptor<C>;
|
|
83
|
+
export type ReduxStoreConfig<State, Actions extends Record<string, import("../../types").ActionCreator>, Selectors> = import('../../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
85
84
|
export type MapSelect = import('../../types').MapSelect;
|
|
85
|
+
export type UseSelectReturn<T extends import("../../types").MapSelect | import("../../types").StoreDescriptor<any>> = import('../../types').UseSelectReturn<T>;
|
|
86
86
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-select/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-select/index.js"],"names":[],"mappings":"AA+JA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,8IAlDW,OAAO,EAAE,4CAuEnB;AAED;;;;;;;;;;;;;;GAcG;AACH,qEAFY,MAAM,CAIjB;yEAjPY,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;sHAIxC,OAAO,aAAa,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC;wBAK9D,OAAO,aAAa,EAAE,SAAS;sHAEhC,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a store descriptor, returns an object of the store's selectors.
|
|
3
|
+
* The selector functions are been pre-bound to pass the current state automatically.
|
|
4
|
+
* As a consumer, you need only pass arguments of the selector, if applicable.
|
|
5
|
+
*
|
|
6
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
7
|
+
* convention of passing the store name is
|
|
8
|
+
* also supported.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* import { select } from '@wordpress/data';
|
|
13
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
14
|
+
*
|
|
15
|
+
* select( myCustomStore ).getPrice( 'hammer' );
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @return {Object} Object containing the store's selectors.
|
|
19
|
+
*/
|
|
20
|
+
export function select(storeNameOrDescriptor: import("./types").StoreDescriptor<any> | string): Object;
|
|
21
|
+
/**
|
|
22
|
+
* Given a store descriptor, returns an object of the store's action creators.
|
|
23
|
+
* Calling an action creator will cause it to be dispatched, updating the state value accordingly.
|
|
24
|
+
*
|
|
25
|
+
* Note: Action creators returned by the dispatch will return a promise when
|
|
26
|
+
* they are called.
|
|
27
|
+
*
|
|
28
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
29
|
+
* convention of passing the store name is
|
|
30
|
+
* also supported.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* import { dispatch } from '@wordpress/data';
|
|
35
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
36
|
+
*
|
|
37
|
+
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
|
|
38
|
+
* ```
|
|
39
|
+
* @return {Object} Object containing the action creators.
|
|
40
|
+
*/
|
|
41
|
+
export function dispatch(storeNameOrDescriptor: import("./types").StoreDescriptor<any> | string): Object;
|
|
1
42
|
export { default as withSelect } from "./components/with-select";
|
|
2
43
|
export { default as withDispatch } from "./components/with-dispatch";
|
|
3
44
|
export { default as withRegistry } from "./components/with-registry";
|
|
@@ -47,26 +88,6 @@ export { plugins };
|
|
|
47
88
|
* object, and constructs a state object with the same shape.
|
|
48
89
|
*/
|
|
49
90
|
export const combineReducers: import('./types').combineReducers;
|
|
50
|
-
/**
|
|
51
|
-
* Given a store descriptor, returns an object of the store's selectors.
|
|
52
|
-
* The selector functions are been pre-bound to pass the current state automatically.
|
|
53
|
-
* As a consumer, you need only pass arguments of the selector, if applicable.
|
|
54
|
-
*
|
|
55
|
-
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
56
|
-
* convention of passing the store name is
|
|
57
|
-
* also supported.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```js
|
|
61
|
-
* import { select } from '@wordpress/data';
|
|
62
|
-
* import { store as myCustomStore } from 'my-custom-store';
|
|
63
|
-
*
|
|
64
|
-
* select( myCustomStore ).getPrice( 'hammer' );
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @return {Object} Object containing the store's selectors.
|
|
68
|
-
*/
|
|
69
|
-
export const select: Function;
|
|
70
91
|
/**
|
|
71
92
|
* Given a store descriptor, returns an object containing the store's selectors pre-bound to state
|
|
72
93
|
* so that you only need to supply additional arguments, and modified so that they return promises
|
|
@@ -99,27 +120,6 @@ export const resolveSelect: any;
|
|
|
99
120
|
* @return {Object} Object containing the store's suspense-wrapped selectors.
|
|
100
121
|
*/
|
|
101
122
|
export const suspendSelect: any;
|
|
102
|
-
/**
|
|
103
|
-
* Given a store descriptor, returns an object of the store's action creators.
|
|
104
|
-
* Calling an action creator will cause it to be dispatched, updating the state value accordingly.
|
|
105
|
-
*
|
|
106
|
-
* Note: Action creators returned by the dispatch will return a promise when
|
|
107
|
-
* they are called.
|
|
108
|
-
*
|
|
109
|
-
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
110
|
-
* convention of passing the store name is
|
|
111
|
-
* also supported.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```js
|
|
115
|
-
* import { dispatch } from '@wordpress/data';
|
|
116
|
-
* import { store as myCustomStore } from 'my-custom-store';
|
|
117
|
-
*
|
|
118
|
-
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
|
|
119
|
-
* ```
|
|
120
|
-
* @return {Object} Object containing the action creators.
|
|
121
|
-
*/
|
|
122
|
-
export const dispatch: Function;
|
|
123
123
|
/**
|
|
124
124
|
* Given a listener function, the function will be called any time the state value
|
|
125
125
|
* of one of the registered stores has changed. If you specify the optional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAkFA;;;;;;;;;;;;;;;;;;GAkBG;AACH,8CAdW,yCAAgB,MAAM,GAYrB,MAAM,CAIjB;AAoCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,gDAbW,yCAAgB,MAAM,GAWrB,MAAM,CAIjB;;;;;;;;;;AAxHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,8BAnCW,OAAO,SAAS,EAAE,eAAe,CAmCQ;AAyBpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,gCAA2D;AAE3D;;;;;;;;;;GAUG;AACH,gCAA2D;AA0B3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iCAAmD;AAEnD;;;;;;;GAOG;AACH,4CAAyE;AAEzE;;;;;;;;;GASG;AACH,qCAA2D;AAE3D;;;;;;GAMG;AACH,sBAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,2BAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/persistence/index.js"],"names":[],"mappings":"AAyDA;;;;;;;GAOG;AACH,oDAJW,8BAA8B,GAE7B,MAAM,CAiDjB;AA/DM,+DAMN;;6BA3Ca,OAAO,gBAAgB,EAAE,cAAc;2BAEvC,OAAO,gBAAgB,EAAE,YAAY;;;;;;;;;;aAKrC,OAAO;;;;gBAGP,MAAM;;AA4FpB;;;;;;;GAOG;AACH,6CALW,cAAc,iBACb,8BAA8B,UAE9B,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/persistence/index.js"],"names":[],"mappings":"AAyDA;;;;;;;GAOG;AACH,oDAJW,8BAA8B,GAE7B,MAAM,CAiDjB;AA/DM,+DAMN;;6BA3Ca,OAAO,gBAAgB,EAAE,cAAc;2BAEvC,OAAO,gBAAgB,EAAE,YAAY;;;;;;;;;;aAKrC,OAAO;;;;gBAGP,MAAM;;AA4FpB;;;;;;;GAOG;AACH,6CALW,cAAc,iBACb,8BAA8B,UAE9B,YAAY,CAuGvB;;IAED,mCAA8C"}
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* } );
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @template State
|
|
17
|
+
* @template State
|
|
18
|
+
* @template {Record<string,import('../../types').ActionCreator>} Actions
|
|
19
|
+
* @template Selectors
|
|
18
20
|
* @param {string} key Unique namespace identifier.
|
|
19
21
|
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
|
|
20
22
|
* describing reducer, actions, selectors,
|
|
@@ -22,8 +24,8 @@
|
|
|
22
24
|
*
|
|
23
25
|
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
|
|
24
26
|
*/
|
|
25
|
-
export default function createReduxStore<State, Actions, Selectors>(key: string, options: import("../types").ReduxStoreConfig<State, Actions, Selectors>): import("../types").StoreDescriptor<import("../types").ReduxStoreConfig<State, Actions, Selectors>>;
|
|
27
|
+
export default function createReduxStore<State, Actions extends Record<string, any>, Selectors>(key: string, options: import("../types").ReduxStoreConfig<State, Actions, Selectors>): import("../types").StoreDescriptor<import("../types").ReduxStoreConfig<State, Actions, Selectors>>;
|
|
26
28
|
export type DataRegistry = import('../types').DataRegistry;
|
|
27
|
-
export type StoreDescriptor<C> = import('../types').StoreDescriptor<C>;
|
|
28
|
-
export type ReduxStoreConfig<State, Actions, Selectors> = import('../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
29
|
+
export type StoreDescriptor<C extends import("../types").AnyConfig> = import('../types').StoreDescriptor<C>;
|
|
30
|
+
export type ReduxStoreConfig<State, Actions extends Record<string, any>, Selectors> = import('../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
29
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redux-store/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redux-store/index.js"],"names":[],"mappings":"AAwGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qGAPW,MAAM,+KAkLhB;2BApRa,OAAO,UAAU,EAAE,YAAY;sEAEhC,OAAO,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;sFAIrC,OAAO,UAAU,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC"}
|
|
@@ -17,8 +17,8 @@ export declare type State = EquivalentKeyMap<StateKey, StateValue>;
|
|
|
17
17
|
*
|
|
18
18
|
* selectorName -> EquivalentKeyMap<Array, boolean>
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
20
|
+
* @param state Current state.
|
|
21
|
+
* @param action Dispatched action.
|
|
22
22
|
*
|
|
23
23
|
* @return Next state.
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/selectors.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/selectors.js"],"names":[],"mappings":"AAKA,iEAAiE;AACjE,2DAA2D;AAC3D,mDAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,UAAU,GAAC,SAAS,CAS/B;AAED;;;;;;;;;;;GAWG;AACH,sCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,GAAG,SAAS,CAM9B;AAED;;;;;;;;;GASG;AACH,4CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,6CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAKlB;AAED;;;;;;;;;GASG;AACH,2CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;;GAUG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,KAAK,GAAC,OAAO,CAKxB;AAED;;;;;;;;;GASG;AACH,mCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAMlB;AAED;;;;;;GAMG;AACH,0CAJW,KAAK,GAEJ,KAAK,CAIhB;oBA/Ha,OAAO,MAAM,EAAE,OAAO,WAAW,EAAE,KAAK,CAAC;yBACzC,OAAO,WAAW,EAAE,UAAU;qBAC9B,OAAO,WAAW,EAAE,MAAM"}
|
|
@@ -6,7 +6,7 @@ import type { AnyAction, Reducer } from 'redux';
|
|
|
6
6
|
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
7
7
|
* by a property on the action object.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param actionProperty Action property by which to key object.
|
|
10
10
|
* @return Higher-order reducer.
|
|
11
11
|
*/
|
|
12
12
|
export declare const onSubKey: <TState extends unknown, TAction extends AnyAction>(actionProperty: string) => (reducer: Reducer<TState, TAction>) => Reducer<Record<string, TState>, TAction>;
|
|
@@ -14,7 +14,7 @@ export declare const onSubKey: <TState extends unknown, TAction extends AnyActio
|
|
|
14
14
|
* Normalize selector argument array by defaulting `undefined` value to an empty array
|
|
15
15
|
* and removing trailing `undefined` values.
|
|
16
16
|
*
|
|
17
|
-
* @param
|
|
17
|
+
* @param args Selector argument array
|
|
18
18
|
* @return Normalized state key array
|
|
19
19
|
*/
|
|
20
20
|
export declare function selectorArgsToStateKey(args: unknown[] | null | undefined): unknown[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.js"],"names":[],"mappings":"AA8CA;;;;;;;;GAQG;AACH,8CALW,MAAM,WACN,MAAM,UAEL,cAAc,CAgUzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers-cache-middleware.d.ts","sourceRoot":"","sources":["../src/resolvers-cache-middleware.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"resolvers-cache-middleware.d.ts","sourceRoot":"","sources":["../src/resolvers-cache-middleware.js"],"names":[],"mappings":";6BAKc,OAAO,YAAY,EAAE,cAAc;AAAjD,oEAAoE;AAEpE;;;;;;;;;GASG;AACH,0DAPW,cAAc,cAEd,MAAM,YAuCf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.0",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.16.0",
|
|
32
|
-
"@wordpress/compose": "^6.
|
|
33
|
-
"@wordpress/deprecated": "^3.
|
|
34
|
-
"@wordpress/element": "^5.
|
|
35
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
36
|
-
"@wordpress/priority-queue": "^2.
|
|
37
|
-
"@wordpress/private-apis": "^0.
|
|
38
|
-
"@wordpress/redux-routine": "^4.
|
|
32
|
+
"@wordpress/compose": "^6.5.0",
|
|
33
|
+
"@wordpress/deprecated": "^3.28.0",
|
|
34
|
+
"@wordpress/element": "^5.5.0",
|
|
35
|
+
"@wordpress/is-shallow-equal": "^4.28.0",
|
|
36
|
+
"@wordpress/priority-queue": "^2.28.0",
|
|
37
|
+
"@wordpress/private-apis": "^0.10.0",
|
|
38
|
+
"@wordpress/redux-routine": "^4.28.0",
|
|
39
|
+
"deepmerge": "^4.3.0",
|
|
39
40
|
"equivalent-key-map": "^0.2.2",
|
|
40
41
|
"is-plain-object": "^5.0.0",
|
|
41
42
|
"is-promise": "^4.0.0",
|
|
42
|
-
"lodash": "^4.17.21",
|
|
43
43
|
"redux": "^4.1.2",
|
|
44
44
|
"turbo-combine-reducers": "^1.0.2",
|
|
45
45
|
"use-memo-one": "^1.1.1"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "d5e03a74b79e3ca84afda24375474a103a063ee4"
|
|
54
54
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { mapValues } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -41,18 +36,25 @@ const useDispatchWithMap = ( dispatchMap, deps ) => {
|
|
|
41
36
|
registry.dispatch,
|
|
42
37
|
registry
|
|
43
38
|
);
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
return Object.fromEntries(
|
|
40
|
+
Object.entries( currentDispatchProps ).map(
|
|
41
|
+
( [ propName, dispatcher ] ) => {
|
|
42
|
+
if ( typeof dispatcher !== 'function' ) {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.warn(
|
|
45
|
+
`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return [
|
|
49
|
+
propName,
|
|
50
|
+
( ...args ) =>
|
|
51
|
+
currentDispatchMap
|
|
52
|
+
.current( registry.dispatch, registry )
|
|
53
|
+
[ propName ]( ...args ),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
);
|
|
56
58
|
}, [ registry, ...deps ] );
|
|
57
59
|
};
|
|
58
60
|
|