@wordpress/data 6.2.2-next.f435e9e01b.0 → 6.3.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 +7 -1
- package/build/redux-store/index.js +1 -6
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/actions.js +4 -4
- package/build/redux-store/metadata/actions.js.map +1 -1
- package/build/redux-store/metadata/reducer.js +3 -3
- package/build/redux-store/metadata/reducer.js.map +1 -1
- package/build/redux-store/metadata/selectors.js +22 -19
- package/build/redux-store/metadata/selectors.js.map +1 -1
- package/build/redux-store/metadata/utils.js +31 -13
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build-module/redux-store/index.js +1 -6
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/actions.js +4 -4
- package/build-module/redux-store/metadata/actions.js.map +1 -1
- package/build-module/redux-store/metadata/reducer.js +4 -4
- package/build-module/redux-store/metadata/reducer.js.map +1 -1
- package/build-module/redux-store/metadata/selectors.js +21 -19
- package/build-module/redux-store/metadata/selectors.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js +29 -13
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-types/redux-store/metadata/actions.d.ts +8 -8
- package/build-types/redux-store/metadata/actions.d.ts.map +1 -1
- package/build-types/redux-store/metadata/reducer.d.ts.map +1 -1
- package/build-types/redux-store/metadata/selectors.d.ts +16 -16
- package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
- package/build-types/redux-store/metadata/utils.d.ts +20 -1
- package/build-types/redux-store/metadata/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/redux-store/index.js +1 -4
- package/src/redux-store/metadata/actions.js +4 -4
- package/src/redux-store/metadata/reducer.ts +7 -4
- package/src/redux-store/metadata/selectors.js +21 -16
- package/src/redux-store/metadata/test/reducer.js +40 -0
- package/src/redux-store/metadata/test/selectors.js +11 -0
- package/src/redux-store/metadata/test/utils.js +28 -1
- package/src/redux-store/metadata/utils.ts +59 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/redux-store/metadata/utils.js +0 -37
|
@@ -36,10 +36,10 @@ export function finishResolution(selectorName, args) {
|
|
|
36
36
|
* started.
|
|
37
37
|
*
|
|
38
38
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
39
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
39
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
40
40
|
* is associated to a resolution.
|
|
41
41
|
*
|
|
42
|
-
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
42
|
+
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
export function startResolutions(selectorName, args) {
|
|
@@ -54,10 +54,10 @@ export function startResolutions(selectorName, args) {
|
|
|
54
54
|
* completed.
|
|
55
55
|
*
|
|
56
56
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
57
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
57
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
58
58
|
* is associated to a resolution.
|
|
59
59
|
*
|
|
60
|
-
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
60
|
+
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
63
|
export function finishResolutions(selectorName, args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/actions.js"],"names":["startResolution","selectorName","args","type","finishResolution","startResolutions","finishResolutions","invalidateResolution","invalidateResolutionForStore","invalidateResolutionForStoreSelector"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,YAA1B,EAAwCC,IAAxC,EAA+C;AACrD,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,gBAAT,CAA2BH,YAA3B,EAAyCC,IAAzC,EAAgD;AACtD,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,gBAAT,CAA2BJ,YAA3B,EAAyCC,IAAzC,EAAgD;AACtD,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,iBAAT,CAA4BL,YAA5B,EAA0CC,IAA1C,EAAiD;AACvD,SAAO;AACNC,IAAAA,IAAI,EAAE,oBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,oBAAT,CAA+BN,YAA/B,EAA6CC,IAA7C,EAAoD;AAC1D,SAAO;AACNC,IAAAA,IAAI,EAAE,uBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,4BAAT,GAAwC;AAC9C,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,oCAAT,CAA+CR,YAA/C,EAA8D;AACpE,SAAO;AACNE,IAAAA,IAAI,EAAE,0CADA;AAENF,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used in signalling that selector resolution has\n * started.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.\n */\nexport function startResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'START_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that selector resolution has\n * completed.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.\n */\nexport function finishResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'FINISH_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a batch of selector resolutions has\n * started.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Array of arguments to associate for uniqueness, each item\n * is associated to a resolution.\n *\n * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.\n */\nexport function startResolutions( selectorName, args ) {\n\treturn {\n\t\ttype: 'START_RESOLUTIONS',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a batch of selector resolutions has\n * completed.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Array of arguments to associate for uniqueness, each item\n * is associated to a resolution.\n *\n * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.\n */\nexport function finishResolutions( selectorName, args ) {\n\treturn {\n\t\ttype: 'FINISH_RESOLUTIONS',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that we should invalidate the resolution cache.\n *\n * @param {string} selectorName Name of selector for which resolver should be invalidated.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.\n */\nexport function invalidateResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the resolution\n * should be invalidated.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.\n */\nexport function invalidateResolutionForStore() {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION_FOR_STORE',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the resolution cache for a\n * given selectorName should be invalidated.\n *\n * @param {string} selectorName Name of selector for which all resolvers should\n * be invalidated.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.\n */\nexport function invalidateResolutionForStoreSelector( selectorName ) {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',\n\t\tselectorName,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/actions.js"],"names":["startResolution","selectorName","args","type","finishResolution","startResolutions","finishResolutions","invalidateResolution","invalidateResolutionForStore","invalidateResolutionForStoreSelector"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,YAA1B,EAAwCC,IAAxC,EAA+C;AACrD,SAAO;AACNC,IAAAA,IAAI,EAAE,kBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,gBAAT,CAA2BH,YAA3B,EAAyCC,IAAzC,EAAgD;AACtD,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,gBAAT,CAA2BJ,YAA3B,EAAyCC,IAAzC,EAAgD;AACtD,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,iBAAT,CAA4BL,YAA5B,EAA0CC,IAA1C,EAAiD;AACvD,SAAO;AACNC,IAAAA,IAAI,EAAE,oBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,oBAAT,CAA+BN,YAA/B,EAA6CC,IAA7C,EAAoD;AAC1D,SAAO;AACNC,IAAAA,IAAI,EAAE,uBADA;AAENF,IAAAA,YAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,4BAAT,GAAwC;AAC9C,SAAO;AACNL,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,oCAAT,CAA+CR,YAA/C,EAA8D;AACpE,SAAO;AACNE,IAAAA,IAAI,EAAE,0CADA;AAENF,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used in signalling that selector resolution has\n * started.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.\n */\nexport function startResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'START_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that selector resolution has\n * completed.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.\n */\nexport function finishResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'FINISH_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a batch of selector resolutions has\n * started.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item\n * is associated to a resolution.\n *\n * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.\n */\nexport function startResolutions( selectorName, args ) {\n\treturn {\n\t\ttype: 'START_RESOLUTIONS',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a batch of selector resolutions has\n * completed.\n *\n * @param {string} selectorName Name of selector for which resolver triggered.\n * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item\n * is associated to a resolution.\n *\n * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.\n */\nexport function finishResolutions( selectorName, args ) {\n\treturn {\n\t\ttype: 'FINISH_RESOLUTIONS',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that we should invalidate the resolution cache.\n *\n * @param {string} selectorName Name of selector for which resolver should be invalidated.\n * @param {unknown[]} args Arguments to associate for uniqueness.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.\n */\nexport function invalidateResolution( selectorName, args ) {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION',\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the resolution\n * should be invalidated.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.\n */\nexport function invalidateResolutionForStore() {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION_FOR_STORE',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the resolution cache for a\n * given selectorName should be invalidated.\n *\n * @param {string} selectorName Name of selector for which all resolvers should\n * be invalidated.\n *\n * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.\n */\nexport function invalidateResolutionForStoreSelector( selectorName ) {\n\treturn {\n\t\ttype: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',\n\t\tselectorName,\n\t};\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import EquivalentKeyMap from 'equivalent-key-map';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { onSubKey } from './utils';
|
|
10
|
+
import { selectorArgsToStateKey, onSubKey } from './utils';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Reducer function returning next state for selector resolution of
|
|
@@ -25,7 +25,7 @@ const subKeysIsResolved = onSubKey('selectorName')(function () {
|
|
|
25
25
|
{
|
|
26
26
|
const isStarting = action.type === 'START_RESOLUTION';
|
|
27
27
|
const nextState = new EquivalentKeyMap(state);
|
|
28
|
-
nextState.set(action.args, isStarting);
|
|
28
|
+
nextState.set(selectorArgsToStateKey(action.args), isStarting);
|
|
29
29
|
return nextState;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -36,7 +36,7 @@ const subKeysIsResolved = onSubKey('selectorName')(function () {
|
|
|
36
36
|
const nextState = new EquivalentKeyMap(state);
|
|
37
37
|
|
|
38
38
|
for (const resolutionArgs of action.args) {
|
|
39
|
-
nextState.set(resolutionArgs, isStarting);
|
|
39
|
+
nextState.set(selectorArgsToStateKey(resolutionArgs), isStarting);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return nextState;
|
|
@@ -45,7 +45,7 @@ const subKeysIsResolved = onSubKey('selectorName')(function () {
|
|
|
45
45
|
case 'INVALIDATE_RESOLUTION':
|
|
46
46
|
{
|
|
47
47
|
const nextState = new EquivalentKeyMap(state);
|
|
48
|
-
nextState.delete(action.args);
|
|
48
|
+
nextState.delete(selectorArgsToStateKey(action.args));
|
|
49
49
|
return nextState;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/reducer.ts"],"names":["omit","has","EquivalentKeyMap","onSubKey","subKeysIsResolved","state","action","type","isStarting","nextState","set","args","resolutionArgs","delete","isResolved","selectorName"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,GAAf,QAA0B,QAA1B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAGA;AACA;AACA;AACA,SAASC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/reducer.ts"],"names":["omit","has","EquivalentKeyMap","selectorArgsToStateKey","onSubKey","subKeysIsResolved","state","action","type","isStarting","nextState","set","args","resolutionArgs","delete","isResolved","selectorName"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,GAAf,QAA0B,QAA1B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAGA;AACA;AACA;AACA,SAASC,sBAAT,EAAiCC,QAAjC,QAAiD,SAAjD;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAA6D,GAAGD,QAAQ,CAG3E,cAH2E,CAAR,CAGjD,YAAsD;AAAA,MAApDE,KAAoD,uEAA5C,IAAIJ,gBAAJ,EAA4C;AAAA,MAApBK,MAAoB;;AAC1E,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACA,SAAK,mBAAL;AAA0B;AACzB,cAAMC,UAAU,GAAGF,MAAM,CAACC,IAAP,KAAgB,kBAAnC;AACA,cAAME,SAAS,GAAG,IAAIR,gBAAJ,CAAsBI,KAAtB,CAAlB;AACAI,QAAAA,SAAS,CAACC,GAAV,CAAeR,sBAAsB,CAAEI,MAAM,CAACK,IAAT,CAArC,EAAsDH,UAAtD;AACA,eAAOC,SAAP;AACA;;AACD,SAAK,mBAAL;AACA,SAAK,oBAAL;AAA2B;AAC1B,cAAMD,UAAU,GAAGF,MAAM,CAACC,IAAP,KAAgB,mBAAnC;AACA,cAAME,SAAS,GAAG,IAAIR,gBAAJ,CAAsBI,KAAtB,CAAlB;;AACA,aAAM,MAAMO,cAAZ,IAA8BN,MAAM,CAACK,IAArC,EAA4C;AAC3CF,UAAAA,SAAS,CAACC,GAAV,CACCR,sBAAsB,CAAEU,cAAF,CADvB,EAECJ,UAFD;AAIA;;AACD,eAAOC,SAAP;AACA;;AACD,SAAK,uBAAL;AAA8B;AAC7B,cAAMA,SAAS,GAAG,IAAIR,gBAAJ,CAAsBI,KAAtB,CAAlB;AACAI,QAAAA,SAAS,CAACI,MAAV,CAAkBX,sBAAsB,CAAEI,MAAM,CAACK,IAAT,CAAxC;AACA,eAAOF,SAAP;AACA;AAxBF;;AA0BA,SAAOJ,KAAP;AACA,CA/BqE,CAAtE;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMS,UAAU,GAAG,YAA2D;AAAA,MAAzDT,KAAyD,uEAAxB,EAAwB;AAAA,MAApBC,MAAoB;;AAC7E,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,iCAAL;AACC,aAAO,EAAP;;AACD,SAAK,0CAAL;AACC,aAAOP,GAAG,CAAEK,KAAF,EAAS,CAAEC,MAAM,CAACS,YAAT,CAAT,CAAH,GACJhB,IAAI,CAAEM,KAAF,EAAS,CAAEC,MAAM,CAACS,YAAT,CAAT,CADA,GAEJV,KAFH;;AAGD,SAAK,kBAAL;AACA,SAAK,mBAAL;AACA,SAAK,mBAAL;AACA,SAAK,oBAAL;AACA,SAAK,uBAAL;AACC,aAAOD,iBAAiB,CAAEC,KAAF,EAASC,MAAT,CAAxB;AAZF;;AAcA,SAAOD,KAAP;AACA,CAhBD;;AAkBA,eAAeS,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { omit, has } from 'lodash';\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').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\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\nexport type State = EquivalentKeyMap< unknown[] | unknown, boolean >;\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\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst isStarting = action.type === 'START_RESOLUTION';\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), isStarting );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst isStarting = action.type === '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(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs ),\n\t\t\t\t\tisStarting\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\treturn has( state, [ action.selectorName ] )\n\t\t\t\t? omit( state, [ action.selectorName ] )\n\t\t\t\t: state;\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'INVALIDATE_RESOLUTION':\n\t\t\treturn subKeysIsResolved( state, action );\n\t}\n\treturn state;\n};\n\nexport default isResolved;\n"]}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { get } from 'lodash';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { selectorArgsToStateKey } from './utils';
|
|
5
10
|
/** @typedef {Record<string, import('./reducer').State>} State */
|
|
6
11
|
|
|
7
12
|
/**
|
|
@@ -10,9 +15,9 @@ import { get } from 'lodash';
|
|
|
10
15
|
* or not resolved for the given set of arguments, otherwise true or false for
|
|
11
16
|
* resolution started and completed respectively.
|
|
12
17
|
*
|
|
13
|
-
* @param {State}
|
|
14
|
-
* @param {string}
|
|
15
|
-
* @param {unknown[]} args Arguments passed to selector.
|
|
18
|
+
* @param {State} state Data state.
|
|
19
|
+
* @param {string} selectorName Selector name.
|
|
20
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
16
21
|
*
|
|
17
22
|
* @return {boolean | undefined} isResolving value.
|
|
18
23
|
*/
|
|
@@ -24,51 +29,48 @@ export function getIsResolving(state, selectorName, args) {
|
|
|
24
29
|
return undefined;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
return map.get(args);
|
|
32
|
+
return map.get(selectorArgsToStateKey(args));
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Returns true if resolution has already been triggered for a given
|
|
31
36
|
* selector name, and arguments set.
|
|
32
37
|
*
|
|
33
|
-
* @param {State}
|
|
34
|
-
* @param {string}
|
|
35
|
-
* @param {unknown[]}
|
|
38
|
+
* @param {State} state Data state.
|
|
39
|
+
* @param {string} selectorName Selector name.
|
|
40
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
36
41
|
*
|
|
37
42
|
* @return {boolean} Whether resolution has been triggered.
|
|
38
43
|
*/
|
|
39
44
|
|
|
40
|
-
export function hasStartedResolution(state, selectorName) {
|
|
41
|
-
let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
45
|
+
export function hasStartedResolution(state, selectorName, args) {
|
|
42
46
|
return getIsResolving(state, selectorName, args) !== undefined;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
49
|
* Returns true if resolution has completed for a given selector
|
|
46
50
|
* name, and arguments set.
|
|
47
51
|
*
|
|
48
|
-
* @param {State}
|
|
49
|
-
* @param {string}
|
|
50
|
-
* @param {unknown[]}
|
|
52
|
+
* @param {State} state Data state.
|
|
53
|
+
* @param {string} selectorName Selector name.
|
|
54
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
51
55
|
*
|
|
52
56
|
* @return {boolean} Whether resolution has completed.
|
|
53
57
|
*/
|
|
54
58
|
|
|
55
|
-
export function hasFinishedResolution(state, selectorName) {
|
|
56
|
-
let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
59
|
+
export function hasFinishedResolution(state, selectorName, args) {
|
|
57
60
|
return getIsResolving(state, selectorName, args) === false;
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Returns true if resolution has been triggered but has not yet completed for
|
|
61
64
|
* a given selector name, and arguments set.
|
|
62
65
|
*
|
|
63
|
-
* @param {State}
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @param {unknown[]}
|
|
66
|
+
* @param {State} state Data state.
|
|
67
|
+
* @param {string} selectorName Selector name.
|
|
68
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
66
69
|
*
|
|
67
70
|
* @return {boolean} Whether resolution is in progress.
|
|
68
71
|
*/
|
|
69
72
|
|
|
70
|
-
export function isResolving(state, selectorName) {
|
|
71
|
-
let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
73
|
+
export function isResolving(state, selectorName, args) {
|
|
72
74
|
return getIsResolving(state, selectorName, args) === true;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/selectors.js"],"names":["get","getIsResolving","state","selectorName","args","map","undefined","hasStartedResolution","hasFinishedResolution","isResolving","getCachedResolvers"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8CC,IAA9C,EAAqD;AAC3D,QAAMC,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/selectors.js"],"names":["get","selectorArgsToStateKey","getIsResolving","state","selectorName","args","map","undefined","hasStartedResolution","hasFinishedResolution","isResolving","getCachedResolvers"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,SAAvC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8CC,IAA9C,EAAqD;AAC3D,QAAMC,GAAG,GAAGN,GAAG,CAAEG,KAAF,EAAS,CAAEC,YAAF,CAAT,CAAf;;AACA,MAAK,CAAEE,GAAP,EAAa;AACZ,WAAOC,SAAP;AACA;;AAED,SAAOD,GAAG,CAACN,GAAJ,CAASC,sBAAsB,CAAEI,IAAF,CAA/B,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,oBAAT,CAA+BL,KAA/B,EAAsCC,YAAtC,EAAoDC,IAApD,EAA2D;AACjE,SAAOH,cAAc,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAd,KAAgDE,SAAvD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,qBAAT,CAAgCN,KAAhC,EAAuCC,YAAvC,EAAqDC,IAArD,EAA4D;AAClE,SAAOH,cAAc,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAd,KAAgD,KAAvD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,WAAT,CAAsBP,KAAtB,EAA6BC,YAA7B,EAA2CC,IAA3C,EAAkD;AACxD,SAAOH,cAAc,CAAEC,KAAF,EAASC,YAAT,EAAuBC,IAAvB,CAAd,KAAgD,IAAvD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,kBAAT,CAA6BR,KAA7B,EAAqC;AAC3C,SAAOA,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey } from './utils';\n\n/** @typedef {Record<string, import('./reducer').State>} State */\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 map = get( state, [ selectorName ] );\n\tif ( ! map ) {\n\t\treturn undefined;\n\t}\n\n\treturn map.get( selectorArgsToStateKey( args ) );\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 getIsResolving( 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\treturn getIsResolving( state, selectorName, args ) === false;\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 getIsResolving( state, selectorName, args ) === true;\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"]}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
3
7
|
* by a property on the action object.
|
|
4
8
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* @param {string} actionProperty Action property by which to key object.
|
|
9
|
-
*
|
|
10
|
-
* @return {(reducer: import('redux').Reducer<TState, TAction>) => import('redux').Reducer<Record<string, TState>, TAction>} Higher-order reducer.
|
|
9
|
+
* @param actionProperty Action property by which to key object.
|
|
10
|
+
* @return Higher-order reducer.
|
|
11
11
|
*/
|
|
12
12
|
export const onSubKey = actionProperty => reducer => function () {
|
|
13
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
14
|
-
/** @type {Record<string, TState>} */
|
|
15
|
-
{};
|
|
13
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
14
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
17
15
|
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
|
18
16
|
// where reducer is scoped by action shape.
|
|
19
|
-
|
|
20
|
-
/** @type {keyof state} */
|
|
21
|
-
|
|
22
|
-
/* eslint-enable jsdoc/no-undefined-types */
|
|
23
17
|
const key = action[actionProperty];
|
|
24
18
|
|
|
25
19
|
if (key === undefined) {
|
|
@@ -38,4 +32,26 @@ export const onSubKey = actionProperty => reducer => function () {
|
|
|
38
32
|
[key]: nextKeyState
|
|
39
33
|
};
|
|
40
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Normalize selector argument array by defaulting `undefined` value to an empty array
|
|
37
|
+
* and removing trailing `undefined` values.
|
|
38
|
+
*
|
|
39
|
+
* @param args Selector argument array
|
|
40
|
+
* @return Normalized state key array
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export function selectorArgsToStateKey(args) {
|
|
44
|
+
if (args === undefined || args === null) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const len = args.length;
|
|
49
|
+
let idx = len;
|
|
50
|
+
|
|
51
|
+
while (idx > 0 && args[idx - 1] === undefined) {
|
|
52
|
+
idx--;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return idx === len ? args : args.slice(0, idx);
|
|
56
|
+
}
|
|
41
57
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/metadata/utils.
|
|
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,GACpBC,cADuB,IAGvBC,OADI,IAE8C,YAG9C;AAAA,MAFJC,KAEI,uEAF8B,EAE9B;AAAA,MADJC,MACI;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;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,CA1BM;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 = < TState extends unknown, TAction extends AnyAction >(\n\tactionProperty: string\n) => (\n\treducer: Reducer< TState, TAction >\n): Reducer< Record< string, TState >, TAction > => (\n\tstate: Record< string, TState > = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\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"]}
|
|
@@ -31,30 +31,30 @@ export function finishResolution(selectorName: string, args: unknown[]): {
|
|
|
31
31
|
* started.
|
|
32
32
|
*
|
|
33
33
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
34
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
34
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
35
35
|
* is associated to a resolution.
|
|
36
36
|
*
|
|
37
|
-
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
37
|
+
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
38
38
|
*/
|
|
39
|
-
export function startResolutions(selectorName: string, args: unknown[]): {
|
|
39
|
+
export function startResolutions(selectorName: string, args: unknown[][]): {
|
|
40
40
|
type: 'START_RESOLUTIONS';
|
|
41
41
|
selectorName: string;
|
|
42
|
-
args: unknown[];
|
|
42
|
+
args: unknown[][];
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* Returns an action object used in signalling that a batch of selector resolutions has
|
|
46
46
|
* completed.
|
|
47
47
|
*
|
|
48
48
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
49
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
49
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
50
50
|
* is associated to a resolution.
|
|
51
51
|
*
|
|
52
|
-
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
52
|
+
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
53
53
|
*/
|
|
54
|
-
export function finishResolutions(selectorName: string, args: unknown[]): {
|
|
54
|
+
export function finishResolutions(selectorName: string, args: unknown[][]): {
|
|
55
55
|
type: 'FINISH_RESOLUTIONS';
|
|
56
56
|
selectorName: string;
|
|
57
|
-
args: unknown[];
|
|
57
|
+
args: unknown[][];
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* Returns an action object used in signalling that we should invalidate the resolution cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/actions.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,8CALW,MAAM,QACN,OAAO,EAAE,GAER;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAQ9E;AAED;;;;;;;;GAQG;AACH,+CALW,MAAM,QACN,OAAO,EAAE,GAER;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAQ/E;AAED;;;;;;;;;GASG;AACH,+CANW,MAAM,QACN,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/actions.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,8CALW,MAAM,QACN,OAAO,EAAE,GAER;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAQ9E;AAED;;;;;;;;GAQG;AACH,+CALW,MAAM,QACN,OAAO,EAAE,GAER;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAQ/E;AAED;;;;;;;;;GASG;AACH,+CANW,MAAM,QACN,OAAO,EAAE,EAAE,GAGV;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAA;CAAE,CAQjF;AAED;;;;;;;;;GASG;AACH,gDANW,MAAM,QACN,OAAO,EAAE,EAAE,GAGV;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAA;CAAE,CAQlF;AAED;;;;;;;GAOG;AACH,mDALW,MAAM,QACN,OAAO,EAAE,GAER;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAQ/E;AAED;;;;;GAKG;AACH,gDAFY;IAAE,IAAI,EAAE,iCAAiC,CAAA;CAAE,CAMtD;AAED;;;;;;;;GAQG;AACH,mEALW,MAAM,GAGJ;IAAE,IAAI,EAAE,0CAA0C,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAOtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/reducer.ts"],"names":[],"mappings":"AAIA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAQlD,aAAK,MAAM,GACR,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,iBAAiB,CAAE,GAC1D,UAAU,CAAE,cAAc,WAAW,EAAE,oBAAoB,CAAE,GAC7D,UAAU,CAAE,cAAc,WAAW,EAAE,4BAA4B,CAAE,GACrE,UAAU,CACV,cAAc,WAAW,EAAE,oCAAoC,CAC9D,CAAC;AAEL,oBAAY,KAAK,GAAG,gBAAgB,CAAE,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/reducer.ts"],"names":[],"mappings":"AAIA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAQlD,aAAK,MAAM,GACR,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,iBAAiB,CAAE,GAC1D,UAAU,CAAE,cAAc,WAAW,EAAE,oBAAoB,CAAE,GAC7D,UAAU,CAAE,cAAc,WAAW,EAAE,4BAA4B,CAAE,GACrE,UAAU,CACV,cAAc,WAAW,EAAE,oCAAoC,CAC9D,CAAC;AAEL,oBAAY,KAAK,GAAG,gBAAgB,CAAE,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,CAAE,CAAC;AAyCrE;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,qDAAkD,MAAM,0BAgBvE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -5,46 +5,46 @@
|
|
|
5
5
|
* or not resolved for the given set of arguments, otherwise true or false for
|
|
6
6
|
* resolution started and completed respectively.
|
|
7
7
|
*
|
|
8
|
-
* @param {State}
|
|
9
|
-
* @param {string}
|
|
10
|
-
* @param {unknown[]} args Arguments passed to selector.
|
|
8
|
+
* @param {State} state Data state.
|
|
9
|
+
* @param {string} selectorName Selector name.
|
|
10
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
11
11
|
*
|
|
12
12
|
* @return {boolean | undefined} isResolving value.
|
|
13
13
|
*/
|
|
14
|
-
export function getIsResolving(state: State, selectorName: string, args: unknown[]): boolean | undefined;
|
|
14
|
+
export function getIsResolving(state: State, selectorName: string, args: unknown[] | null): boolean | undefined;
|
|
15
15
|
/**
|
|
16
16
|
* Returns true if resolution has already been triggered for a given
|
|
17
17
|
* selector name, and arguments set.
|
|
18
18
|
*
|
|
19
|
-
* @param {State}
|
|
20
|
-
* @param {string}
|
|
21
|
-
* @param {unknown[]}
|
|
19
|
+
* @param {State} state Data state.
|
|
20
|
+
* @param {string} selectorName Selector name.
|
|
21
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
22
22
|
*
|
|
23
23
|
* @return {boolean} Whether resolution has been triggered.
|
|
24
24
|
*/
|
|
25
|
-
export function hasStartedResolution(state: State, selectorName: string, args
|
|
25
|
+
export function hasStartedResolution(state: State, selectorName: string, args: unknown[] | null): boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Returns true if resolution has completed for a given selector
|
|
28
28
|
* name, and arguments set.
|
|
29
29
|
*
|
|
30
|
-
* @param {State}
|
|
31
|
-
* @param {string}
|
|
32
|
-
* @param {unknown[]}
|
|
30
|
+
* @param {State} state Data state.
|
|
31
|
+
* @param {string} selectorName Selector name.
|
|
32
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
33
33
|
*
|
|
34
34
|
* @return {boolean} Whether resolution has completed.
|
|
35
35
|
*/
|
|
36
|
-
export function hasFinishedResolution(state: State, selectorName: string, args
|
|
36
|
+
export function hasFinishedResolution(state: State, selectorName: string, args: unknown[] | null): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* Returns true if resolution has been triggered but has not yet completed for
|
|
39
39
|
* a given selector name, and arguments set.
|
|
40
40
|
*
|
|
41
|
-
* @param {State}
|
|
42
|
-
* @param {string}
|
|
43
|
-
* @param {unknown[]}
|
|
41
|
+
* @param {State} state Data state.
|
|
42
|
+
* @param {string} selectorName Selector name.
|
|
43
|
+
* @param {unknown[]?} args Arguments passed to selector.
|
|
44
44
|
*
|
|
45
45
|
* @return {boolean} Whether resolution is in progress.
|
|
46
46
|
*/
|
|
47
|
-
export function isResolving(state: State, selectorName: string, args
|
|
47
|
+
export function isResolving(state: State, selectorName: string, args: unknown[] | null): boolean;
|
|
48
48
|
/**
|
|
49
49
|
* Returns the list of the cached resolvers.
|
|
50
50
|
*
|
|
@@ -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":"AAUA,iEAAiE;AAEjE;;;;;;;;;;;GAWG;AACH,sCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,GAAG,SAAS,CAS9B;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,CAIlB;AAED;;;;;;;;;GASG;AACH,mCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;GAMG;AACH,0CAJW,KAAK,GAEJ,KAAK,CAIhB;oBA1Ea,OAAO,MAAM,EAAE,OAAO,WAAW,EAAE,KAAK,CAAC"}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { AnyAction, Reducer } from 'redux';
|
|
5
|
+
/**
|
|
6
|
+
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
7
|
+
* by a property on the action object.
|
|
8
|
+
*
|
|
9
|
+
* @param actionProperty Action property by which to key object.
|
|
10
|
+
* @return Higher-order reducer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const onSubKey: <TState extends unknown, TAction extends AnyAction>(actionProperty: string) => (reducer: Reducer<TState, TAction>) => Reducer<Record<string, TState>, TAction>;
|
|
13
|
+
/**
|
|
14
|
+
* Normalize selector argument array by defaulting `undefined` value to an empty array
|
|
15
|
+
* and removing trailing `undefined` values.
|
|
16
|
+
*
|
|
17
|
+
* @param args Selector argument array
|
|
18
|
+
* @return Normalized state key array
|
|
19
|
+
*/
|
|
20
|
+
export declare function selectorArgsToStateKey(args: unknown[] | null | undefined): unknown[];
|
|
2
21
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/utils.
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,sEACJ,MAAM,oFAyBtB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,aAWzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.16.0",
|
|
31
|
-
"@wordpress/compose": "^5.1.
|
|
32
|
-
"@wordpress/deprecated": "^3.3.1
|
|
33
|
-
"@wordpress/element": "^4.1.1
|
|
34
|
-
"@wordpress/is-shallow-equal": "^4.3.1
|
|
35
|
-
"@wordpress/priority-queue": "^2.3.1
|
|
36
|
-
"@wordpress/redux-routine": "^4.3.1
|
|
31
|
+
"@wordpress/compose": "^5.1.2",
|
|
32
|
+
"@wordpress/deprecated": "^3.3.1",
|
|
33
|
+
"@wordpress/element": "^4.1.1",
|
|
34
|
+
"@wordpress/is-shallow-equal": "^4.3.1",
|
|
35
|
+
"@wordpress/priority-queue": "^2.3.1",
|
|
36
|
+
"@wordpress/redux-routine": "^4.3.1",
|
|
37
37
|
"equivalent-key-map": "^0.2.2",
|
|
38
38
|
"is-promise": "^4.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4566ac290359553d04de4eb574545309343f790b"
|
|
51
51
|
}
|
package/src/redux-store/index.js
CHANGED
|
@@ -232,12 +232,9 @@ function instantiateReduxStore( key, options, registry, thunkArgs ) {
|
|
|
232
232
|
createResolversCacheMiddleware( registry, key ),
|
|
233
233
|
promise,
|
|
234
234
|
createReduxRoutineMiddleware( normalizedControls ),
|
|
235
|
+
createThunkMiddleware( thunkArgs ),
|
|
235
236
|
];
|
|
236
237
|
|
|
237
|
-
if ( options.__experimentalUseThunks ) {
|
|
238
|
-
middlewares.push( createThunkMiddleware( thunkArgs ) );
|
|
239
|
-
}
|
|
240
|
-
|
|
241
238
|
const enhancers = [ applyMiddleware( ...middlewares ) ];
|
|
242
239
|
if (
|
|
243
240
|
typeof window !== 'undefined' &&
|
|
@@ -37,10 +37,10 @@ export function finishResolution( selectorName, args ) {
|
|
|
37
37
|
* started.
|
|
38
38
|
*
|
|
39
39
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
40
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
40
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
41
41
|
* is associated to a resolution.
|
|
42
42
|
*
|
|
43
|
-
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
43
|
+
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
44
44
|
*/
|
|
45
45
|
export function startResolutions( selectorName, args ) {
|
|
46
46
|
return {
|
|
@@ -55,10 +55,10 @@ export function startResolutions( selectorName, args ) {
|
|
|
55
55
|
* completed.
|
|
56
56
|
*
|
|
57
57
|
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
58
|
-
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
|
|
58
|
+
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
|
|
59
59
|
* is associated to a resolution.
|
|
60
60
|
*
|
|
61
|
-
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[] }} Action object.
|
|
61
|
+
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
|
|
62
62
|
*/
|
|
63
63
|
export function finishResolutions( selectorName, args ) {
|
|
64
64
|
return {
|
|
@@ -8,7 +8,7 @@ import type { Reducer } from 'redux';
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import { onSubKey } from './utils';
|
|
11
|
+
import { selectorArgsToStateKey, onSubKey } from './utils';
|
|
12
12
|
|
|
13
13
|
type Action =
|
|
14
14
|
| ReturnType< typeof import('./actions').startResolution >
|
|
@@ -38,7 +38,7 @@ const subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<
|
|
|
38
38
|
case 'FINISH_RESOLUTION': {
|
|
39
39
|
const isStarting = action.type === 'START_RESOLUTION';
|
|
40
40
|
const nextState = new EquivalentKeyMap( state );
|
|
41
|
-
nextState.set( action.args, isStarting );
|
|
41
|
+
nextState.set( selectorArgsToStateKey( action.args ), isStarting );
|
|
42
42
|
return nextState;
|
|
43
43
|
}
|
|
44
44
|
case 'START_RESOLUTIONS':
|
|
@@ -46,13 +46,16 @@ const subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<
|
|
|
46
46
|
const isStarting = action.type === 'START_RESOLUTIONS';
|
|
47
47
|
const nextState = new EquivalentKeyMap( state );
|
|
48
48
|
for ( const resolutionArgs of action.args ) {
|
|
49
|
-
nextState.set(
|
|
49
|
+
nextState.set(
|
|
50
|
+
selectorArgsToStateKey( resolutionArgs ),
|
|
51
|
+
isStarting
|
|
52
|
+
);
|
|
50
53
|
}
|
|
51
54
|
return nextState;
|
|
52
55
|
}
|
|
53
56
|
case 'INVALIDATE_RESOLUTION': {
|
|
54
57
|
const nextState = new EquivalentKeyMap( state );
|
|
55
|
-
nextState.delete( action.args );
|
|
58
|
+
nextState.delete( selectorArgsToStateKey( action.args ) );
|
|
56
59
|
return nextState;
|
|
57
60
|
}
|
|
58
61
|
}
|