@wordpress/data 10.32.0 → 10.32.1-next.47f435fc9.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/build/components/async-mode-provider/context.js +35 -54
- package/build/components/async-mode-provider/context.js.map +7 -1
- package/build/components/async-mode-provider/index.js +40 -25
- package/build/components/async-mode-provider/index.js.map +7 -1
- package/build/components/async-mode-provider/use-async-mode.js +25 -16
- package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
- package/build/components/registry-provider/context.js +46 -64
- package/build/components/registry-provider/context.js.map +7 -1
- package/build/components/registry-provider/index.js +40 -25
- package/build/components/registry-provider/index.js.map +7 -1
- package/build/components/registry-provider/use-registry.js +25 -55
- package/build/components/registry-provider/use-registry.js.map +7 -1
- package/build/components/use-dispatch/index.js +38 -17
- package/build/components/use-dispatch/index.js.map +7 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
- package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
- package/build/components/use-dispatch/use-dispatch.js +36 -71
- package/build/components/use-dispatch/use-dispatch.js.map +7 -1
- package/build/components/use-select/index.js +79 -208
- package/build/components/use-select/index.js.map +7 -1
- package/build/components/with-dispatch/index.js +34 -107
- package/build/components/with-dispatch/index.js.map +7 -1
- package/build/components/with-registry/index.js +30 -30
- package/build/components/with-registry/index.js.map +7 -1
- package/build/components/with-select/index.js +44 -67
- package/build/components/with-select/index.js.map +7 -1
- package/build/controls.js +49 -110
- package/build/controls.js.map +7 -1
- package/build/create-selector.js +36 -11
- package/build/create-selector.js.map +7 -1
- package/build/default-registry.js +24 -10
- package/build/default-registry.js.map +7 -1
- package/build/dispatch.js +38 -31
- package/build/dispatch.js.map +7 -1
- package/build/factory.js +29 -85
- package/build/factory.js.map +7 -1
- package/build/index.js +114 -301
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/plugins/index.js +36 -11
- package/build/plugins/index.js.map +7 -1
- package/build/plugins/persistence/index.js +74 -139
- package/build/plugins/persistence/index.js.map +7 -1
- package/build/plugins/persistence/storage/default.js +37 -18
- package/build/plugins/persistence/storage/default.js.map +7 -1
- package/build/plugins/persistence/storage/object.js +24 -7
- package/build/plugins/persistence/storage/object.js.map +7 -1
- package/build/promise-middleware.js +37 -20
- package/build/promise-middleware.js.map +7 -1
- package/build/redux-store/combine-reducers.js +26 -5
- package/build/redux-store/combine-reducers.js.map +7 -1
- package/build/redux-store/index.js +221 -331
- package/build/redux-store/index.js.map +7 -1
- package/build/redux-store/metadata/actions.js +51 -112
- package/build/redux-store/metadata/actions.js.map +7 -1
- package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
- package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
- package/build/redux-store/metadata/reducer.js +111 -115
- package/build/redux-store/metadata/reducer.js.map +7 -1
- package/build/redux-store/metadata/selectors.js +109 -181
- package/build/redux-store/metadata/selectors.js.map +7 -1
- package/build/redux-store/metadata/utils.js +32 -35
- package/build/redux-store/metadata/utils.js.map +7 -1
- package/build/redux-store/thunk-middleware.js +24 -7
- package/build/redux-store/thunk-middleware.js.map +7 -1
- package/build/registry.js +94 -198
- package/build/registry.js.map +7 -1
- package/build/resolvers-cache-middleware.js +26 -27
- package/build/resolvers-cache-middleware.js.map +7 -1
- package/build/select.js +38 -31
- package/build/select.js.map +7 -1
- package/build/store/index.js +52 -16
- package/build/store/index.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/emitter.js +33 -16
- package/build/utils/emitter.js.map +7 -1
- package/build-module/components/async-mode-provider/context.js +12 -49
- package/build-module/components/async-mode-provider/context.js.map +7 -1
- package/build-module/components/async-mode-provider/index.js +8 -3
- package/build-module/components/async-mode-provider/index.js.map +7 -1
- package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
- package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
- package/build-module/components/registry-provider/context.js +13 -58
- package/build-module/components/registry-provider/context.js.map +7 -1
- package/build-module/components/registry-provider/index.js +8 -3
- package/build-module/components/registry-provider/index.js.map +7 -1
- package/build-module/components/registry-provider/use-registry.js +7 -51
- package/build-module/components/registry-provider/use-registry.js.map +7 -1
- package/build-module/components/use-dispatch/index.js +7 -3
- package/build-module/components/use-dispatch/index.js.map +7 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
- package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
- package/build-module/components/use-dispatch/use-dispatch.js +8 -66
- package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
- package/build-module/components/use-select/index.js +45 -193
- package/build-module/components/use-select/index.js.map +7 -1
- package/build-module/components/with-dispatch/index.js +16 -104
- package/build-module/components/with-dispatch/index.js.map +7 -1
- package/build-module/components/with-registry/index.js +12 -27
- package/build-module/components/with-registry/index.js.map +7 -1
- package/build-module/components/with-select/index.js +16 -63
- package/build-module/components/with-select/index.js.map +7 -1
- package/build-module/controls.js +25 -105
- package/build-module/controls.js.map +7 -1
- package/build-module/create-selector.js +5 -8
- package/build-module/create-selector.js.map +7 -1
- package/build-module/default-registry.js +6 -6
- package/build-module/default-registry.js.map +7 -1
- package/build-module/dispatch.js +6 -27
- package/build-module/dispatch.js.map +7 -1
- package/build-module/factory.js +8 -82
- package/build-module/factory.js.map +7 -1
- package/build-module/index.js +62 -185
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/plugins/index.js +5 -2
- package/build-module/plugins/index.js.map +7 -1
- package/build-module/plugins/persistence/index.js +38 -129
- package/build-module/plugins/persistence/index.js.map +7 -1
- package/build-module/plugins/persistence/storage/default.js +8 -11
- package/build-module/plugins/persistence/storage/default.js.map +7 -1
- package/build-module/plugins/persistence/storage/object.js +6 -3
- package/build-module/plugins/persistence/storage/object.js.map +7 -1
- package/build-module/promise-middleware.js +8 -14
- package/build-module/promise-middleware.js.map +7 -1
- package/build-module/redux-store/combine-reducers.js +5 -2
- package/build-module/redux-store/combine-reducers.js.map +7 -1
- package/build-module/redux-store/index.js +180 -310
- package/build-module/redux-store/index.js.map +7 -1
- package/build-module/redux-store/metadata/actions.js +30 -109
- package/build-module/redux-store/metadata/actions.js.map +7 -1
- package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
- package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
- package/build-module/redux-store/metadata/reducer.js +83 -108
- package/build-module/redux-store/metadata/reducer.js.map +7 -1
- package/build-module/redux-store/metadata/selectors.js +76 -175
- package/build-module/redux-store/metadata/selectors.js.map +7 -1
- package/build-module/redux-store/metadata/utils.js +10 -30
- package/build-module/redux-store/metadata/utils.js.map +7 -1
- package/build-module/redux-store/thunk-middleware.js +7 -4
- package/build-module/redux-store/thunk-middleware.js.map +7 -1
- package/build-module/registry.js +56 -187
- package/build-module/registry.js.map +7 -1
- package/build-module/resolvers-cache-middleware.js +8 -23
- package/build-module/resolvers-cache-middleware.js.map +7 -1
- package/build-module/select.js +6 -27
- package/build-module/select.js.map +7 -1
- package/build-module/store/index.js +34 -12
- package/build-module/store/index.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/emitter.js +12 -13
- package/build-module/utils/emitter.js.map +7 -1
- package/package.json +17 -10
|
@@ -1,134 +1,130 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var reducer_exports = {};
|
|
30
|
+
__export(reducer_exports, {
|
|
31
|
+
default: () => reducer_default
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Reducer function returning next state for selector resolution of
|
|
20
|
-
* subkeys, object form:
|
|
21
|
-
*
|
|
22
|
-
* selectorName -> EquivalentKeyMap<Array,boolean>
|
|
23
|
-
*/
|
|
24
|
-
const subKeysIsResolved = (0, _utils.onSubKey)('selectorName')((state = new _equivalentKeyMap.default(), action) => {
|
|
33
|
+
module.exports = __toCommonJS(reducer_exports);
|
|
34
|
+
var import_equivalent_key_map = __toESM(require("equivalent-key-map"));
|
|
35
|
+
var import_utils = require("./utils");
|
|
36
|
+
const subKeysIsResolved = (0, import_utils.onSubKey)("selectorName")((state = new import_equivalent_key_map.default(), action) => {
|
|
25
37
|
switch (action.type) {
|
|
26
|
-
case
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
case "START_RESOLUTION": {
|
|
39
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
40
|
+
nextState.set((0, import_utils.selectorArgsToStateKey)(action.args), {
|
|
41
|
+
status: "resolving"
|
|
42
|
+
});
|
|
43
|
+
return nextState;
|
|
44
|
+
}
|
|
45
|
+
case "FINISH_RESOLUTION": {
|
|
46
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
47
|
+
nextState.set((0, import_utils.selectorArgsToStateKey)(action.args), {
|
|
48
|
+
status: "finished"
|
|
49
|
+
});
|
|
50
|
+
return nextState;
|
|
51
|
+
}
|
|
52
|
+
case "FAIL_RESOLUTION": {
|
|
53
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
54
|
+
nextState.set((0, import_utils.selectorArgsToStateKey)(action.args), {
|
|
55
|
+
status: "error",
|
|
56
|
+
error: action.error
|
|
57
|
+
});
|
|
58
|
+
return nextState;
|
|
59
|
+
}
|
|
60
|
+
case "START_RESOLUTIONS": {
|
|
61
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
62
|
+
for (const resolutionArgs of action.args) {
|
|
63
|
+
nextState.set((0, import_utils.selectorArgsToStateKey)(resolutionArgs), {
|
|
64
|
+
status: "resolving"
|
|
31
65
|
});
|
|
32
|
-
return nextState;
|
|
33
66
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
return nextState;
|
|
68
|
+
}
|
|
69
|
+
case "FINISH_RESOLUTIONS": {
|
|
70
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
71
|
+
for (const resolutionArgs of action.args) {
|
|
72
|
+
nextState.set((0, import_utils.selectorArgsToStateKey)(resolutionArgs), {
|
|
73
|
+
status: "finished"
|
|
39
74
|
});
|
|
40
|
-
return nextState;
|
|
41
|
-
}
|
|
42
|
-
case 'FAIL_RESOLUTION':
|
|
43
|
-
{
|
|
44
|
-
const nextState = new _equivalentKeyMap.default(state);
|
|
45
|
-
nextState.set((0, _utils.selectorArgsToStateKey)(action.args), {
|
|
46
|
-
status: 'error',
|
|
47
|
-
error: action.error
|
|
48
|
-
});
|
|
49
|
-
return nextState;
|
|
50
|
-
}
|
|
51
|
-
case 'START_RESOLUTIONS':
|
|
52
|
-
{
|
|
53
|
-
const nextState = new _equivalentKeyMap.default(state);
|
|
54
|
-
for (const resolutionArgs of action.args) {
|
|
55
|
-
nextState.set((0, _utils.selectorArgsToStateKey)(resolutionArgs), {
|
|
56
|
-
status: 'resolving'
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return nextState;
|
|
60
75
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
return nextState;
|
|
77
|
+
}
|
|
78
|
+
case "FAIL_RESOLUTIONS": {
|
|
79
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
80
|
+
action.args.forEach((resolutionArgs, idx) => {
|
|
81
|
+
const resolutionState = {
|
|
82
|
+
status: "error",
|
|
83
|
+
error: void 0
|
|
84
|
+
};
|
|
85
|
+
const error = action.errors[idx];
|
|
86
|
+
if (error) {
|
|
87
|
+
resolutionState.error = error;
|
|
68
88
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
resolutionState.error = error;
|
|
82
|
-
}
|
|
83
|
-
nextState.set((0, _utils.selectorArgsToStateKey)(resolutionArgs), resolutionState);
|
|
84
|
-
});
|
|
85
|
-
return nextState;
|
|
86
|
-
}
|
|
87
|
-
case 'INVALIDATE_RESOLUTION':
|
|
88
|
-
{
|
|
89
|
-
const nextState = new _equivalentKeyMap.default(state);
|
|
90
|
-
nextState.delete((0, _utils.selectorArgsToStateKey)(action.args));
|
|
91
|
-
return nextState;
|
|
92
|
-
}
|
|
89
|
+
nextState.set(
|
|
90
|
+
(0, import_utils.selectorArgsToStateKey)(resolutionArgs),
|
|
91
|
+
resolutionState
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
return nextState;
|
|
95
|
+
}
|
|
96
|
+
case "INVALIDATE_RESOLUTION": {
|
|
97
|
+
const nextState = new import_equivalent_key_map.default(state);
|
|
98
|
+
nextState.delete((0, import_utils.selectorArgsToStateKey)(action.args));
|
|
99
|
+
return nextState;
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
102
|
return state;
|
|
95
103
|
});
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Reducer function returning next state for selector resolution, object form:
|
|
99
|
-
*
|
|
100
|
-
* selectorName -> EquivalentKeyMap<Array, boolean>
|
|
101
|
-
*
|
|
102
|
-
* @param state Current state.
|
|
103
|
-
* @param action Dispatched action.
|
|
104
|
-
*
|
|
105
|
-
* @return Next state.
|
|
106
|
-
*/
|
|
107
104
|
const isResolved = (state = {}, action) => {
|
|
108
105
|
switch (action.type) {
|
|
109
|
-
case
|
|
106
|
+
case "INVALIDATE_RESOLUTION_FOR_STORE":
|
|
110
107
|
return {};
|
|
111
|
-
case
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return restState;
|
|
119
|
-
}
|
|
120
|
-
return state;
|
|
108
|
+
case "INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR": {
|
|
109
|
+
if (action.selectorName in state) {
|
|
110
|
+
const {
|
|
111
|
+
[action.selectorName]: removedSelector,
|
|
112
|
+
...restState
|
|
113
|
+
} = state;
|
|
114
|
+
return restState;
|
|
121
115
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
case
|
|
125
|
-
case
|
|
126
|
-
case
|
|
127
|
-
case
|
|
128
|
-
case
|
|
116
|
+
return state;
|
|
117
|
+
}
|
|
118
|
+
case "START_RESOLUTION":
|
|
119
|
+
case "FINISH_RESOLUTION":
|
|
120
|
+
case "FAIL_RESOLUTION":
|
|
121
|
+
case "START_RESOLUTIONS":
|
|
122
|
+
case "FINISH_RESOLUTIONS":
|
|
123
|
+
case "FAIL_RESOLUTIONS":
|
|
124
|
+
case "INVALIDATE_RESOLUTION":
|
|
129
125
|
return subKeysIsResolved(state, action);
|
|
130
126
|
}
|
|
131
127
|
return state;
|
|
132
128
|
};
|
|
133
|
-
var
|
|
134
|
-
//# sourceMappingURL=reducer.js.map
|
|
129
|
+
var reducer_default = isResolved;
|
|
130
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/redux-store/metadata/reducer.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport type { Reducer } from 'redux';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey, onSubKey } from './utils';\n\ntype Action =\n\t| ReturnType< typeof import('./actions').startResolution >\n\t| ReturnType< typeof import('./actions').finishResolution >\n\t| ReturnType< typeof import('./actions').failResolution >\n\t| ReturnType< typeof import('./actions').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\n\t| ReturnType< typeof import('./actions').failResolutions >\n\t| ReturnType< typeof import('./actions').invalidateResolution >\n\t| ReturnType< typeof import('./actions').invalidateResolutionForStore >\n\t| ReturnType<\n\t\t\ttypeof import('./actions').invalidateResolutionForStoreSelector\n\t >;\n\ntype StateKey = unknown[] | unknown;\nexport type StateValue =\n\t| { status: 'resolving' | 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\nexport type Status = StateValue[ 'status' ];\nexport type State = EquivalentKeyMap< StateKey, StateValue >;\n\n/**\n * Reducer function returning next state for selector resolution of\n * subkeys, object form:\n *\n * selectorName -> EquivalentKeyMap<Array,boolean>\n */\nconst subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<\n\tState,\n\tAction\n>( 'selectorName' )( ( state = new EquivalentKeyMap(), action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'START_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'resolving',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'finished',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'error',\n\t\t\t\terror: action.error,\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'resolving',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'finished',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\taction.args.forEach( ( resolutionArgs, idx ) => {\n\t\t\t\tconst resolutionState: StateValue = {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\terror: undefined,\n\t\t\t\t};\n\n\t\t\t\tconst error = action.errors[ idx ];\n\t\t\t\tif ( error ) {\n\t\t\t\t\tresolutionState.error = error;\n\t\t\t\t}\n\n\t\t\t\tnextState.set(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs as unknown[] ),\n\t\t\t\t\tresolutionState\n\t\t\t\t);\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'INVALIDATE_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.delete( selectorArgsToStateKey( action.args ) );\n\t\t\treturn nextState;\n\t\t}\n\t}\n\treturn state;\n} );\n\n/**\n * Reducer function returning next state for selector resolution, object form:\n *\n * selectorName -> EquivalentKeyMap<Array, boolean>\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Next state.\n */\nconst isResolved = ( state: Record< string, State > = {}, action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE':\n\t\t\treturn {};\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': {\n\t\t\tif ( action.selectorName in state ) {\n\t\t\t\tconst {\n\t\t\t\t\t[ action.selectorName ]: removedSelector,\n\t\t\t\t\t...restState\n\t\t\t\t} = state;\n\t\t\t\treturn restState;\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'FAIL_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'FAIL_RESOLUTIONS':\n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
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var selectors_exports = {};
|
|
30
|
+
__export(selectors_exports, {
|
|
31
|
+
countSelectorsByStatus: () => countSelectorsByStatus,
|
|
32
|
+
getCachedResolvers: () => getCachedResolvers,
|
|
33
|
+
getIsResolving: () => getIsResolving,
|
|
34
|
+
getResolutionError: () => getResolutionError,
|
|
35
|
+
getResolutionState: () => getResolutionState,
|
|
36
|
+
hasFinishedResolution: () => hasFinishedResolution,
|
|
37
|
+
hasResolutionFailed: () => hasResolutionFailed,
|
|
38
|
+
hasResolvingSelectors: () => hasResolvingSelectors,
|
|
39
|
+
hasStartedResolution: () => hasStartedResolution,
|
|
40
|
+
isResolving: () => isResolving
|
|
6
41
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.getResolutionState = getResolutionState;
|
|
12
|
-
exports.hasFinishedResolution = hasFinishedResolution;
|
|
13
|
-
exports.hasResolutionFailed = hasResolutionFailed;
|
|
14
|
-
exports.hasResolvingSelectors = hasResolvingSelectors;
|
|
15
|
-
exports.hasStartedResolution = hasStartedResolution;
|
|
16
|
-
exports.isResolving = isResolving;
|
|
17
|
-
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
18
|
-
var _createSelector = require("../../create-selector");
|
|
19
|
-
var _utils = require("./utils");
|
|
20
|
-
/**
|
|
21
|
-
* WordPress dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/** @typedef {Record<string, import('./reducer').State>} State */
|
|
29
|
-
/** @typedef {import('./reducer').StateValue} StateValue */
|
|
30
|
-
/** @typedef {import('./reducer').Status} Status */
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns the raw resolution state value for a given selector name,
|
|
34
|
-
* and arguments set. May be undefined if the selector has never been resolved
|
|
35
|
-
* or not resolved for the given set of arguments, otherwise true or false for
|
|
36
|
-
* resolution started and completed respectively.
|
|
37
|
-
*
|
|
38
|
-
* @param {State} state Data state.
|
|
39
|
-
* @param {string} selectorName Selector name.
|
|
40
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
41
|
-
*
|
|
42
|
-
* @return {StateValue|undefined} isResolving value.
|
|
43
|
-
*/
|
|
42
|
+
module.exports = __toCommonJS(selectors_exports);
|
|
43
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
44
|
+
var import_create_selector = require("../../create-selector");
|
|
45
|
+
var import_utils = require("./utils");
|
|
44
46
|
function getResolutionState(state, selectorName, args) {
|
|
45
47
|
const map = state[selectorName];
|
|
46
48
|
if (!map) {
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
|
-
return map.get((0,
|
|
51
|
+
return map.get((0, import_utils.selectorArgsToStateKey)(args));
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns an `isResolving`-like value for a given selector name and arguments set.
|
|
54
|
-
* Its value is either `undefined` if the selector has never been resolved or has been
|
|
55
|
-
* invalidated, or a `true`/`false` boolean value if the resolution is in progress or
|
|
56
|
-
* has finished, respectively.
|
|
57
|
-
*
|
|
58
|
-
* This is a legacy selector that was implemented when the "raw" internal data had
|
|
59
|
-
* this `undefined | boolean` format. Nowadays the internal value is an object that
|
|
60
|
-
* can be retrieved with `getResolutionState`.
|
|
61
|
-
*
|
|
62
|
-
* @deprecated
|
|
63
|
-
*
|
|
64
|
-
* @param {State} state Data state.
|
|
65
|
-
* @param {string} selectorName Selector name.
|
|
66
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
67
|
-
*
|
|
68
|
-
* @return {boolean | undefined} isResolving value.
|
|
69
|
-
*/
|
|
70
53
|
function getIsResolving(state, selectorName, args) {
|
|
71
|
-
(0,
|
|
72
|
-
since:
|
|
73
|
-
version:
|
|
74
|
-
alternative:
|
|
54
|
+
(0, import_deprecated.default)("wp.data.select( store ).getIsResolving", {
|
|
55
|
+
since: "6.6",
|
|
56
|
+
version: "6.8",
|
|
57
|
+
alternative: "wp.data.select( store ).getResolutionState"
|
|
75
58
|
});
|
|
76
59
|
const resolutionState = getResolutionState(state, selectorName, args);
|
|
77
|
-
return resolutionState && resolutionState.status ===
|
|
60
|
+
return resolutionState && resolutionState.status === "resolving";
|
|
78
61
|
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Returns true if resolution has already been triggered for a given
|
|
82
|
-
* selector name, and arguments set.
|
|
83
|
-
*
|
|
84
|
-
* @param {State} state Data state.
|
|
85
|
-
* @param {string} selectorName Selector name.
|
|
86
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
87
|
-
*
|
|
88
|
-
* @return {boolean} Whether resolution has been triggered.
|
|
89
|
-
*/
|
|
90
62
|
function hasStartedResolution(state, selectorName, args) {
|
|
91
|
-
return getResolutionState(state, selectorName, args) !==
|
|
63
|
+
return getResolutionState(state, selectorName, args) !== void 0;
|
|
92
64
|
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Returns true if resolution has completed for a given selector
|
|
96
|
-
* name, and arguments set.
|
|
97
|
-
*
|
|
98
|
-
* @param {State} state Data state.
|
|
99
|
-
* @param {string} selectorName Selector name.
|
|
100
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
101
|
-
*
|
|
102
|
-
* @return {boolean} Whether resolution has completed.
|
|
103
|
-
*/
|
|
104
65
|
function hasFinishedResolution(state, selectorName, args) {
|
|
105
66
|
const status = getResolutionState(state, selectorName, args)?.status;
|
|
106
|
-
return status ===
|
|
67
|
+
return status === "finished" || status === "error";
|
|
107
68
|
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Returns true if resolution has failed for a given selector
|
|
111
|
-
* name, and arguments set.
|
|
112
|
-
*
|
|
113
|
-
* @param {State} state Data state.
|
|
114
|
-
* @param {string} selectorName Selector name.
|
|
115
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
116
|
-
*
|
|
117
|
-
* @return {boolean} Has resolution failed
|
|
118
|
-
*/
|
|
119
69
|
function hasResolutionFailed(state, selectorName, args) {
|
|
120
|
-
return getResolutionState(state, selectorName, args)?.status ===
|
|
70
|
+
return getResolutionState(state, selectorName, args)?.status === "error";
|
|
121
71
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Returns the resolution error for a given selector name, and arguments set.
|
|
125
|
-
* Note it may be of an Error type, but may also be null, undefined, or anything else
|
|
126
|
-
* that can be `throw`-n.
|
|
127
|
-
*
|
|
128
|
-
* @param {State} state Data state.
|
|
129
|
-
* @param {string} selectorName Selector name.
|
|
130
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
131
|
-
*
|
|
132
|
-
* @return {Error|unknown} Last resolution error
|
|
133
|
-
*/
|
|
134
72
|
function getResolutionError(state, selectorName, args) {
|
|
135
73
|
const resolutionState = getResolutionState(state, selectorName, args);
|
|
136
|
-
return resolutionState?.status ===
|
|
74
|
+
return resolutionState?.status === "error" ? resolutionState.error : null;
|
|
137
75
|
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Returns true if resolution has been triggered but has not yet completed for
|
|
141
|
-
* a given selector name, and arguments set.
|
|
142
|
-
*
|
|
143
|
-
* @param {State} state Data state.
|
|
144
|
-
* @param {string} selectorName Selector name.
|
|
145
|
-
* @param {unknown[]?} args Arguments passed to selector.
|
|
146
|
-
*
|
|
147
|
-
* @return {boolean} Whether resolution is in progress.
|
|
148
|
-
*/
|
|
149
76
|
function isResolving(state, selectorName, args) {
|
|
150
|
-
return getResolutionState(state, selectorName, args)?.status ===
|
|
77
|
+
return getResolutionState(state, selectorName, args)?.status === "resolving";
|
|
151
78
|
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Returns the list of the cached resolvers.
|
|
155
|
-
*
|
|
156
|
-
* @param {State} state Data state.
|
|
157
|
-
*
|
|
158
|
-
* @return {State} Resolvers mapped by args and selectorName.
|
|
159
|
-
*/
|
|
160
79
|
function getCachedResolvers(state) {
|
|
161
80
|
return state;
|
|
162
81
|
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Whether the store has any currently resolving selectors.
|
|
166
|
-
*
|
|
167
|
-
* @param {State} state Data state.
|
|
168
|
-
*
|
|
169
|
-
* @return {boolean} True if one or more selectors are resolving, false otherwise.
|
|
170
|
-
*/
|
|
171
82
|
function hasResolvingSelectors(state) {
|
|
172
|
-
return Object.values(state).some(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
83
|
+
return Object.values(state).some(
|
|
84
|
+
(selectorState) => (
|
|
85
|
+
/**
|
|
86
|
+
* This uses the internal `_map` property of `EquivalentKeyMap` for
|
|
87
|
+
* optimization purposes, since the `EquivalentKeyMap` implementation
|
|
88
|
+
* does not support a `.values()` implementation.
|
|
89
|
+
*
|
|
90
|
+
* @see https://github.com/aduth/equivalent-key-map
|
|
91
|
+
*/
|
|
92
|
+
Array.from(selectorState._map.values()).some(
|
|
93
|
+
(resolution) => resolution[1]?.status === "resolving"
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
);
|
|
181
97
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
98
|
+
const countSelectorsByStatus = (0, import_create_selector.createSelector)(
|
|
99
|
+
(state) => {
|
|
100
|
+
const selectorsByStatus = {};
|
|
101
|
+
Object.values(state).forEach(
|
|
102
|
+
(selectorState) => (
|
|
103
|
+
/**
|
|
104
|
+
* This uses the internal `_map` property of `EquivalentKeyMap` for
|
|
105
|
+
* optimization purposes, since the `EquivalentKeyMap` implementation
|
|
106
|
+
* does not support a `.values()` implementation.
|
|
107
|
+
*
|
|
108
|
+
* @see https://github.com/aduth/equivalent-key-map
|
|
109
|
+
*/
|
|
110
|
+
Array.from(selectorState._map.values()).forEach(
|
|
111
|
+
(resolution) => {
|
|
112
|
+
const currentStatus = resolution[1]?.status ?? "error";
|
|
113
|
+
if (!selectorsByStatus[currentStatus]) {
|
|
114
|
+
selectorsByStatus[currentStatus] = 0;
|
|
115
|
+
}
|
|
116
|
+
selectorsByStatus[currentStatus]++;
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
return selectorsByStatus;
|
|
122
|
+
},
|
|
123
|
+
(state) => [state]
|
|
124
|
+
);
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
countSelectorsByStatus,
|
|
128
|
+
getCachedResolvers,
|
|
129
|
+
getIsResolving,
|
|
130
|
+
getResolutionError,
|
|
131
|
+
getResolutionState,
|
|
132
|
+
hasFinishedResolution,
|
|
133
|
+
hasResolutionFailed,
|
|
134
|
+
hasResolvingSelectors,
|
|
135
|
+
hasStartedResolution,
|
|
136
|
+
isResolving
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=selectors.js.map
|