@wordpress/data 10.31.1-next.f56bd8138.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/async-mode-provider/context.js +35 -54
  3. package/build/components/async-mode-provider/context.js.map +7 -1
  4. package/build/components/async-mode-provider/index.js +40 -25
  5. package/build/components/async-mode-provider/index.js.map +7 -1
  6. package/build/components/async-mode-provider/use-async-mode.js +25 -16
  7. package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
  8. package/build/components/registry-provider/context.js +46 -64
  9. package/build/components/registry-provider/context.js.map +7 -1
  10. package/build/components/registry-provider/index.js +40 -25
  11. package/build/components/registry-provider/index.js.map +7 -1
  12. package/build/components/registry-provider/use-registry.js +25 -55
  13. package/build/components/registry-provider/use-registry.js.map +7 -1
  14. package/build/components/use-dispatch/index.js +38 -17
  15. package/build/components/use-dispatch/index.js.map +7 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
  17. package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  18. package/build/components/use-dispatch/use-dispatch.js +36 -71
  19. package/build/components/use-dispatch/use-dispatch.js.map +7 -1
  20. package/build/components/use-select/index.js +79 -208
  21. package/build/components/use-select/index.js.map +7 -1
  22. package/build/components/with-dispatch/index.js +34 -107
  23. package/build/components/with-dispatch/index.js.map +7 -1
  24. package/build/components/with-registry/index.js +30 -30
  25. package/build/components/with-registry/index.js.map +7 -1
  26. package/build/components/with-select/index.js +44 -67
  27. package/build/components/with-select/index.js.map +7 -1
  28. package/build/controls.js +49 -110
  29. package/build/controls.js.map +7 -1
  30. package/build/create-selector.js +36 -11
  31. package/build/create-selector.js.map +7 -1
  32. package/build/default-registry.js +24 -10
  33. package/build/default-registry.js.map +7 -1
  34. package/build/dispatch.js +38 -31
  35. package/build/dispatch.js.map +7 -1
  36. package/build/factory.js +29 -85
  37. package/build/factory.js.map +7 -1
  38. package/build/index.js +114 -301
  39. package/build/index.js.map +7 -1
  40. package/build/lock-unlock.js +31 -14
  41. package/build/lock-unlock.js.map +7 -1
  42. package/build/plugins/index.js +36 -11
  43. package/build/plugins/index.js.map +7 -1
  44. package/build/plugins/persistence/index.js +74 -139
  45. package/build/plugins/persistence/index.js.map +7 -1
  46. package/build/plugins/persistence/storage/default.js +37 -18
  47. package/build/plugins/persistence/storage/default.js.map +7 -1
  48. package/build/plugins/persistence/storage/object.js +24 -7
  49. package/build/plugins/persistence/storage/object.js.map +7 -1
  50. package/build/promise-middleware.js +37 -20
  51. package/build/promise-middleware.js.map +7 -1
  52. package/build/redux-store/combine-reducers.js +26 -5
  53. package/build/redux-store/combine-reducers.js.map +7 -1
  54. package/build/redux-store/index.js +221 -331
  55. package/build/redux-store/index.js.map +7 -1
  56. package/build/redux-store/metadata/actions.js +51 -112
  57. package/build/redux-store/metadata/actions.js.map +7 -1
  58. package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
  59. package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  60. package/build/redux-store/metadata/reducer.js +111 -115
  61. package/build/redux-store/metadata/reducer.js.map +7 -1
  62. package/build/redux-store/metadata/selectors.js +109 -181
  63. package/build/redux-store/metadata/selectors.js.map +7 -1
  64. package/build/redux-store/metadata/utils.js +32 -35
  65. package/build/redux-store/metadata/utils.js.map +7 -1
  66. package/build/redux-store/thunk-middleware.js +24 -7
  67. package/build/redux-store/thunk-middleware.js.map +7 -1
  68. package/build/registry.js +94 -198
  69. package/build/registry.js.map +7 -1
  70. package/build/resolvers-cache-middleware.js +26 -27
  71. package/build/resolvers-cache-middleware.js.map +7 -1
  72. package/build/select.js +38 -31
  73. package/build/select.js.map +7 -1
  74. package/build/store/index.js +52 -16
  75. package/build/store/index.js.map +7 -1
  76. package/build/types.js +16 -5
  77. package/build/types.js.map +7 -1
  78. package/build/utils/emitter.js +33 -16
  79. package/build/utils/emitter.js.map +7 -1
  80. package/build-module/components/async-mode-provider/context.js +12 -49
  81. package/build-module/components/async-mode-provider/context.js.map +7 -1
  82. package/build-module/components/async-mode-provider/index.js +8 -3
  83. package/build-module/components/async-mode-provider/index.js.map +7 -1
  84. package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
  85. package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
  86. package/build-module/components/registry-provider/context.js +13 -58
  87. package/build-module/components/registry-provider/context.js.map +7 -1
  88. package/build-module/components/registry-provider/index.js +8 -3
  89. package/build-module/components/registry-provider/index.js.map +7 -1
  90. package/build-module/components/registry-provider/use-registry.js +7 -51
  91. package/build-module/components/registry-provider/use-registry.js.map +7 -1
  92. package/build-module/components/use-dispatch/index.js +7 -3
  93. package/build-module/components/use-dispatch/index.js.map +7 -1
  94. package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
  95. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  96. package/build-module/components/use-dispatch/use-dispatch.js +8 -66
  97. package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
  98. package/build-module/components/use-select/index.js +45 -193
  99. package/build-module/components/use-select/index.js.map +7 -1
  100. package/build-module/components/with-dispatch/index.js +16 -104
  101. package/build-module/components/with-dispatch/index.js.map +7 -1
  102. package/build-module/components/with-registry/index.js +12 -27
  103. package/build-module/components/with-registry/index.js.map +7 -1
  104. package/build-module/components/with-select/index.js +16 -63
  105. package/build-module/components/with-select/index.js.map +7 -1
  106. package/build-module/controls.js +25 -105
  107. package/build-module/controls.js.map +7 -1
  108. package/build-module/create-selector.js +5 -8
  109. package/build-module/create-selector.js.map +7 -1
  110. package/build-module/default-registry.js +6 -6
  111. package/build-module/default-registry.js.map +7 -1
  112. package/build-module/dispatch.js +6 -27
  113. package/build-module/dispatch.js.map +7 -1
  114. package/build-module/factory.js +8 -82
  115. package/build-module/factory.js.map +7 -1
  116. package/build-module/index.js +62 -185
  117. package/build-module/index.js.map +7 -1
  118. package/build-module/lock-unlock.js +8 -7
  119. package/build-module/lock-unlock.js.map +7 -1
  120. package/build-module/plugins/index.js +5 -2
  121. package/build-module/plugins/index.js.map +7 -1
  122. package/build-module/plugins/persistence/index.js +38 -129
  123. package/build-module/plugins/persistence/index.js.map +7 -1
  124. package/build-module/plugins/persistence/storage/default.js +8 -11
  125. package/build-module/plugins/persistence/storage/default.js.map +7 -1
  126. package/build-module/plugins/persistence/storage/object.js +6 -3
  127. package/build-module/plugins/persistence/storage/object.js.map +7 -1
  128. package/build-module/promise-middleware.js +8 -14
  129. package/build-module/promise-middleware.js.map +7 -1
  130. package/build-module/redux-store/combine-reducers.js +5 -2
  131. package/build-module/redux-store/combine-reducers.js.map +7 -1
  132. package/build-module/redux-store/index.js +180 -310
  133. package/build-module/redux-store/index.js.map +7 -1
  134. package/build-module/redux-store/metadata/actions.js +30 -109
  135. package/build-module/redux-store/metadata/actions.js.map +7 -1
  136. package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
  137. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  138. package/build-module/redux-store/metadata/reducer.js +83 -108
  139. package/build-module/redux-store/metadata/reducer.js.map +7 -1
  140. package/build-module/redux-store/metadata/selectors.js +76 -175
  141. package/build-module/redux-store/metadata/selectors.js.map +7 -1
  142. package/build-module/redux-store/metadata/utils.js +10 -30
  143. package/build-module/redux-store/metadata/utils.js.map +7 -1
  144. package/build-module/redux-store/thunk-middleware.js +7 -4
  145. package/build-module/redux-store/thunk-middleware.js.map +7 -1
  146. package/build-module/registry.js +56 -187
  147. package/build-module/registry.js.map +7 -1
  148. package/build-module/resolvers-cache-middleware.js +8 -23
  149. package/build-module/resolvers-cache-middleware.js.map +7 -1
  150. package/build-module/select.js +6 -27
  151. package/build-module/select.js.map +7 -1
  152. package/build-module/store/index.js +34 -12
  153. package/build-module/store/index.js.map +7 -1
  154. package/build-module/types.js +1 -2
  155. package/build-module/types.js.map +7 -1
  156. package/build-module/utils/emitter.js +12 -13
  157. package/build-module/utils/emitter.js.map +7 -1
  158. package/package.json +17 -10
@@ -1,134 +1,130 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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.default = void 0;
8
- var _equivalentKeyMap = _interopRequireDefault(require("equivalent-key-map"));
9
- var _utils = require("./utils");
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 'START_RESOLUTION':
27
- {
28
- const nextState = new _equivalentKeyMap.default(state);
29
- nextState.set((0, _utils.selectorArgsToStateKey)(action.args), {
30
- status: 'resolving'
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
- case 'FINISH_RESOLUTION':
35
- {
36
- const nextState = new _equivalentKeyMap.default(state);
37
- nextState.set((0, _utils.selectorArgsToStateKey)(action.args), {
38
- status: 'finished'
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
- case 'FINISH_RESOLUTIONS':
62
- {
63
- const nextState = new _equivalentKeyMap.default(state);
64
- for (const resolutionArgs of action.args) {
65
- nextState.set((0, _utils.selectorArgsToStateKey)(resolutionArgs), {
66
- status: 'finished'
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
- return nextState;
70
- }
71
- case 'FAIL_RESOLUTIONS':
72
- {
73
- const nextState = new _equivalentKeyMap.default(state);
74
- action.args.forEach((resolutionArgs, idx) => {
75
- const resolutionState = {
76
- status: 'error',
77
- error: undefined
78
- };
79
- const error = action.errors[idx];
80
- if (error) {
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 'INVALIDATE_RESOLUTION_FOR_STORE':
106
+ case "INVALIDATE_RESOLUTION_FOR_STORE":
110
107
  return {};
111
- case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR':
112
- {
113
- if (action.selectorName in state) {
114
- const {
115
- [action.selectorName]: removedSelector,
116
- ...restState
117
- } = state;
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
- case 'START_RESOLUTION':
123
- case 'FINISH_RESOLUTION':
124
- case 'FAIL_RESOLUTION':
125
- case 'START_RESOLUTIONS':
126
- case 'FINISH_RESOLUTIONS':
127
- case 'FAIL_RESOLUTIONS':
128
- case 'INVALIDATE_RESOLUTION':
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 _default = exports.default = isResolved;
134
- //# sourceMappingURL=reducer.js.map
129
+ var reducer_default = isResolved;
130
+ //# sourceMappingURL=reducer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_equivalentKeyMap","_interopRequireDefault","require","_utils","subKeysIsResolved","onSubKey","state","EquivalentKeyMap","action","type","nextState","set","selectorArgsToStateKey","args","status","error","resolutionArgs","forEach","idx","resolutionState","undefined","errors","delete","isResolved","selectorName","removedSelector","restState","_default","exports","default"],"sources":["@wordpress/data/src/redux-store/metadata/reducer.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport type { Reducer } from 'redux';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey, onSubKey } from './utils';\n\ntype Action =\n\t| ReturnType< typeof import('./actions').startResolution >\n\t| ReturnType< typeof import('./actions').finishResolution >\n\t| ReturnType< typeof import('./actions').failResolution >\n\t| ReturnType< typeof import('./actions').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\n\t| ReturnType< typeof import('./actions').failResolutions >\n\t| ReturnType< typeof import('./actions').invalidateResolution >\n\t| ReturnType< typeof import('./actions').invalidateResolutionForStore >\n\t| ReturnType<\n\t\t\ttypeof import('./actions').invalidateResolutionForStoreSelector\n\t >;\n\ntype StateKey = unknown[] | unknown;\nexport type StateValue =\n\t| { status: 'resolving' | 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\nexport type Status = StateValue[ 'status' ];\nexport type State = EquivalentKeyMap< StateKey, StateValue >;\n\n/**\n * Reducer function returning next state for selector resolution of\n * subkeys, object form:\n *\n * selectorName -> EquivalentKeyMap<Array,boolean>\n */\nconst subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<\n\tState,\n\tAction\n>( 'selectorName' )( ( state = new EquivalentKeyMap(), action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'START_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'resolving',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'finished',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'error',\n\t\t\t\terror: action.error,\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'resolving',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'finished',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\taction.args.forEach( ( resolutionArgs, idx ) => {\n\t\t\t\tconst resolutionState: StateValue = {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\terror: undefined,\n\t\t\t\t};\n\n\t\t\t\tconst error = action.errors[ idx ];\n\t\t\t\tif ( error ) {\n\t\t\t\t\tresolutionState.error = error;\n\t\t\t\t}\n\n\t\t\t\tnextState.set(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs as unknown[] ),\n\t\t\t\t\tresolutionState\n\t\t\t\t);\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'INVALIDATE_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.delete( selectorArgsToStateKey( action.args ) );\n\t\t\treturn nextState;\n\t\t}\n\t}\n\treturn state;\n} );\n\n/**\n * Reducer function returning next state for selector resolution, object form:\n *\n * selectorName -> EquivalentKeyMap<Array, boolean>\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Next state.\n */\nconst isResolved = ( state: Record< string, State > = {}, action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE':\n\t\t\treturn {};\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': {\n\t\t\tif ( action.selectorName in state ) {\n\t\t\t\tconst {\n\t\t\t\t\t[ action.selectorName ]: removedSelector,\n\t\t\t\t\t...restState\n\t\t\t\t} = state;\n\t\t\t\treturn restState;\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'FAIL_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'FAIL_RESOLUTIONS':\n\t\tcase 'INVALIDATE_RESOLUTION':\n\t\t\treturn subKeysIsResolved( state, action );\n\t}\n\treturn state;\n};\n\nexport default isResolved;\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,iBAA6D,GAAG,IAAAC,eAAQ,EAG3E,cAAe,CAAC,CAAE,CAAEC,KAAK,GAAG,IAAIC,yBAAgB,CAAC,CAAC,EAAEC,MAAc,KAAM;EAC1E,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kBAAkB;MAAE;QACxB,MAAMC,SAAS,GAAG,IAAIH,yBAAgB,CAAED,KAAM,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BAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC3B,OAAOF,iBAAiB,CAAEE,KAAK,EAAEE,MAAO,CAAC;EAC3C;EACA,OAAOF,KAAK;AACb,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaN,UAAU","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/redux-store/metadata/reducer.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport type { Reducer } from 'redux';\n\n/**\n * Internal dependencies\n */\nimport { selectorArgsToStateKey, onSubKey } from './utils';\n\ntype Action =\n\t| ReturnType< typeof import('./actions').startResolution >\n\t| ReturnType< typeof import('./actions').finishResolution >\n\t| ReturnType< typeof import('./actions').failResolution >\n\t| ReturnType< typeof import('./actions').startResolutions >\n\t| ReturnType< typeof import('./actions').finishResolutions >\n\t| ReturnType< typeof import('./actions').failResolutions >\n\t| ReturnType< typeof import('./actions').invalidateResolution >\n\t| ReturnType< typeof import('./actions').invalidateResolutionForStore >\n\t| ReturnType<\n\t\t\ttypeof import('./actions').invalidateResolutionForStoreSelector\n\t >;\n\ntype StateKey = unknown[] | unknown;\nexport type StateValue =\n\t| { status: 'resolving' | 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\nexport type Status = StateValue[ 'status' ];\nexport type State = EquivalentKeyMap< StateKey, StateValue >;\n\n/**\n * Reducer function returning next state for selector resolution of\n * subkeys, object form:\n *\n * selectorName -> EquivalentKeyMap<Array,boolean>\n */\nconst subKeysIsResolved: Reducer< Record< string, State >, Action > = onSubKey<\n\tState,\n\tAction\n>( 'selectorName' )( ( state = new EquivalentKeyMap(), action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'START_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'resolving',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'finished',\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.set( selectorArgsToStateKey( action.args ), {\n\t\t\t\tstatus: 'error',\n\t\t\t\terror: action.error,\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'START_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'resolving',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FINISH_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tfor ( const resolutionArgs of action.args ) {\n\t\t\t\tnextState.set( selectorArgsToStateKey( resolutionArgs ), {\n\t\t\t\t\tstatus: 'finished',\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'FAIL_RESOLUTIONS': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\taction.args.forEach( ( resolutionArgs, idx ) => {\n\t\t\t\tconst resolutionState: StateValue = {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\terror: undefined,\n\t\t\t\t};\n\n\t\t\t\tconst error = action.errors[ idx ];\n\t\t\t\tif ( error ) {\n\t\t\t\t\tresolutionState.error = error;\n\t\t\t\t}\n\n\t\t\t\tnextState.set(\n\t\t\t\t\tselectorArgsToStateKey( resolutionArgs as unknown[] ),\n\t\t\t\t\tresolutionState\n\t\t\t\t);\n\t\t\t} );\n\t\t\treturn nextState;\n\t\t}\n\t\tcase 'INVALIDATE_RESOLUTION': {\n\t\t\tconst nextState = new EquivalentKeyMap( state );\n\t\t\tnextState.delete( selectorArgsToStateKey( action.args ) );\n\t\t\treturn nextState;\n\t\t}\n\t}\n\treturn state;\n} );\n\n/**\n * Reducer function returning next state for selector resolution, object form:\n *\n * selectorName -> EquivalentKeyMap<Array, boolean>\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Next state.\n */\nconst isResolved = ( state: Record< string, State > = {}, action: Action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE':\n\t\t\treturn {};\n\t\tcase 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': {\n\t\t\tif ( action.selectorName in state ) {\n\t\t\t\tconst {\n\t\t\t\t\t[ action.selectorName ]: removedSelector,\n\t\t\t\t\t...restState\n\t\t\t\t} = state;\n\t\t\t\treturn restState;\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t\tcase 'START_RESOLUTION':\n\t\tcase 'FINISH_RESOLUTION':\n\t\tcase 'FAIL_RESOLUTION':\n\t\tcase 'START_RESOLUTIONS':\n\t\tcase 'FINISH_RESOLUTIONS':\n\t\tcase 'FAIL_RESOLUTIONS':\n\t\tcase 'INVALIDATE_RESOLUTION':\n\t\t\treturn subKeysIsResolved( state, action );\n\t}\n\treturn state;\n};\n\nexport default isResolved;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA6B;AAM7B,mBAAiD;AA6BjD,MAAM,wBAAgE,uBAGnE,cAAe,EAAG,CAAE,QAAQ,IAAI,0BAAAA,QAAiB,GAAG,WAAoB;AAC1E,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,oBAAoB;AACxB,YAAM,YAAY,IAAI,0BAAAA,QAAkB,KAAM;AAC9C,gBAAU,QAAK,qCAAwB,OAAO,IAAK,GAAG;AAAA,QACrD,QAA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IACA,KAAK,yBAAyB;AAC7B,YAAM,YAAY,IAAI,0BAAAA,QAAkB,KAAM;AAC9C,gBAAU,WAAQ,qCAAwB,OAAO,IAAK,CAAE;AACxD,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR,CAAE;AAYF,MAAM,aAAa,CAAE,QAAiC,CAAC,GAAG,WAAoB;AAC7E,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,CAAC;AAAA,IACT,KAAK,4CAA4C;AAChD,UAAK,OAAO,gBAAgB,OAAQ;AACnC,cAAM;AAAA,UACL,CAAE,OAAO,YAAa,GAAG;AAAA,UACzB,GAAG;AAAA,QACJ,IAAI;AACJ,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,kBAAmB,OAAO,MAAO;AAAA,EAC1C;AACA,SAAO;AACR;AAEA,IAAO,kBAAQ;",
6
+ "names": ["EquivalentKeyMap"]
7
+ }
@@ -1,210 +1,138 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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.countSelectorsByStatus = void 0;
8
- exports.getCachedResolvers = getCachedResolvers;
9
- exports.getIsResolving = getIsResolving;
10
- exports.getResolutionError = getResolutionError;
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, _utils.selectorArgsToStateKey)(args));
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, _deprecated.default)('wp.data.select( store ).getIsResolving', {
72
- since: '6.6',
73
- version: '6.8',
74
- alternative: 'wp.data.select( store ).getResolutionState'
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 === 'resolving';
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) !== undefined;
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 === 'finished' || status === 'error';
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 === 'error';
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 === 'error' ? resolutionState.error : null;
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 === 'resolving';
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(selectorState =>
173
- /**
174
- * This uses the internal `_map` property of `EquivalentKeyMap` for
175
- * optimization purposes, since the `EquivalentKeyMap` implementation
176
- * does not support a `.values()` implementation.
177
- *
178
- * @see https://github.com/aduth/equivalent-key-map
179
- */
180
- Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving'));
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
- * Retrieves the total number of selectors, grouped per status.
185
- *
186
- * @param {State} state Data state.
187
- *
188
- * @return {Object} Object, containing selector totals by status.
189
- */
190
- const countSelectorsByStatus = exports.countSelectorsByStatus = (0, _createSelector.createSelector)(state => {
191
- const selectorsByStatus = {};
192
- Object.values(state).forEach(selectorState =>
193
- /**
194
- * This uses the internal `_map` property of `EquivalentKeyMap` for
195
- * optimization purposes, since the `EquivalentKeyMap` implementation
196
- * does not support a `.values()` implementation.
197
- *
198
- * @see https://github.com/aduth/equivalent-key-map
199
- */
200
- Array.from(selectorState._map.values()).forEach(resolution => {
201
- var _resolution$1$status;
202
- const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error';
203
- if (!selectorsByStatus[currentStatus]) {
204
- selectorsByStatus[currentStatus] = 0;
205
- }
206
- selectorsByStatus[currentStatus]++;
207
- }));
208
- return selectorsByStatus;
209
- }, state => [state]);
210
- //# sourceMappingURL=selectors.js.map
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