@wordpress/data 9.8.0 → 9.10.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 +17 -4
- package/README.md +101 -2
- package/build/components/async-mode-provider/context.js +2 -3
- package/build/components/async-mode-provider/context.js.map +1 -1
- package/build/components/async-mode-provider/index.js +0 -5
- package/build/components/async-mode-provider/index.js.map +1 -1
- package/build/components/async-mode-provider/use-async-mode.js +1 -3
- package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
- package/build/components/registry-provider/context.js +3 -6
- package/build/components/registry-provider/context.js.map +1 -1
- package/build/components/registry-provider/index.js +0 -5
- package/build/components/registry-provider/index.js.map +1 -1
- package/build/components/registry-provider/use-registry.js +0 -3
- package/build/components/registry-provider/use-registry.js.map +1 -1
- package/build/components/use-dispatch/index.js +0 -3
- package/build/components/use-dispatch/index.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js +0 -7
- package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch.js +0 -5
- package/build/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build/components/use-select/index.js +35 -53
- package/build/components/use-select/index.js.map +1 -1
- package/build/components/with-dispatch/index.js +2 -7
- package/build/components/with-dispatch/index.js.map +1 -1
- package/build/components/with-registry/index.js +2 -5
- package/build/components/with-registry/index.js.map +1 -1
- package/build/components/with-select/index.js +2 -8
- package/build/components/with-select/index.js.map +1 -1
- package/build/controls.js +4 -10
- package/build/controls.js.map +1 -1
- package/build/default-registry.js +0 -3
- package/build/default-registry.js.map +1 -1
- package/build/dispatch.js +0 -3
- package/build/dispatch.js.map +1 -1
- package/build/factory.js +2 -5
- package/build/factory.js.map +1 -1
- package/build/index.js +7 -28
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/plugins/index.js +0 -2
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/persistence/index.js +13 -37
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/plugins/persistence/storage/default.js +1 -5
- package/build/plugins/persistence/storage/default.js.map +1 -1
- package/build/plugins/persistence/storage/object.js +0 -5
- package/build/plugins/persistence/storage/object.js.map +1 -1
- package/build/promise-middleware.js +0 -5
- package/build/promise-middleware.js.map +1 -1
- package/build/redux-store/index.js +36 -117
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/actions.js +8 -17
- package/build/redux-store/metadata/actions.js.map +1 -1
- package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
- package/build/redux-store/metadata/reducer.js +1 -23
- package/build/redux-store/metadata/reducer.js.map +1 -1
- package/build/redux-store/metadata/selectors.js +8 -22
- package/build/redux-store/metadata/selectors.js.map +1 -1
- package/build/redux-store/metadata/utils.js +6 -14
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build/redux-store/thunk-middleware.js +0 -2
- package/build/redux-store/thunk-middleware.js.map +1 -1
- package/build/registry.js +29 -73
- package/build/registry.js.map +1 -1
- package/build/resolvers-cache-middleware.js +2 -8
- package/build/resolvers-cache-middleware.js.map +1 -1
- package/build/select.js +0 -3
- package/build/select.js.map +1 -1
- package/build/store/index.js +0 -7
- package/build/store/index.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/emitter.js +2 -11
- package/build/utils/emitter.js.map +1 -1
- package/build-module/components/async-mode-provider/context.js +1 -1
- package/build-module/components/async-mode-provider/context.js.map +1 -1
- package/build-module/components/async-mode-provider/index.js.map +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
- package/build-module/components/registry-provider/context.js +3 -3
- package/build-module/components/registry-provider/context.js.map +1 -1
- package/build-module/components/registry-provider/index.js.map +1 -1
- package/build-module/components/registry-provider/use-registry.js +2 -2
- package/build-module/components/registry-provider/use-registry.js.map +1 -1
- package/build-module/components/use-dispatch/index.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -4
- package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +1 -3
- package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build-module/components/use-select/index.js +35 -46
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/components/with-dispatch/index.js +4 -6
- package/build-module/components/with-dispatch/index.js.map +1 -1
- package/build-module/components/with-registry/index.js +4 -4
- package/build-module/components/with-registry/index.js.map +1 -1
- package/build-module/components/with-select/index.js +4 -6
- package/build-module/components/with-select/index.js.map +1 -1
- package/build-module/controls.js +4 -8
- package/build-module/controls.js.map +1 -1
- package/build-module/default-registry.js.map +1 -1
- package/build-module/dispatch.js +2 -1
- package/build-module/dispatch.js.map +1 -1
- package/build-module/factory.js +2 -3
- package/build-module/factory.js.map +1 -1
- package/build-module/index.js +11 -10
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/persistence/index.js +15 -30
- package/build-module/plugins/persistence/index.js.map +1 -1
- package/build-module/plugins/persistence/storage/default.js +0 -2
- package/build-module/plugins/persistence/storage/default.js.map +1 -1
- package/build-module/plugins/persistence/storage/object.js +0 -5
- package/build-module/plugins/persistence/storage/object.js.map +1 -1
- package/build-module/promise-middleware.js +1 -3
- package/build-module/promise-middleware.js.map +1 -1
- package/build-module/redux-store/index.js +38 -101
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/actions.js +8 -8
- package/build-module/redux-store/metadata/actions.js.map +1 -1
- package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
- package/build-module/redux-store/metadata/reducer.js +1 -21
- package/build-module/redux-store/metadata/reducer.js.map +1 -1
- package/build-module/redux-store/metadata/selectors.js +9 -13
- package/build-module/redux-store/metadata/selectors.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js +6 -11
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-module/redux-store/thunk-middleware.js +0 -1
- package/build-module/redux-store/thunk-middleware.js.map +1 -1
- package/build-module/registry.js +30 -67
- package/build-module/registry.js.map +1 -1
- package/build-module/resolvers-cache-middleware.js +3 -6
- package/build-module/resolvers-cache-middleware.js.map +1 -1
- package/build-module/select.js +2 -1
- package/build-module/select.js.map +1 -1
- package/build-module/store/index.js +0 -7
- package/build-module/store/index.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils/emitter.js +2 -10
- package/build-module/utils/emitter.js.map +1 -1
- package/build-types/components/use-select/index.d.ts.map +1 -1
- package/build-types/dispatch.d.ts +2 -2
- package/build-types/dispatch.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/index.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +3 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/store/index.d.ts +1 -1
- package/build-types/types.d.ts +9 -3
- package/build-types/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/components/use-select/index.js +14 -0
- package/src/dispatch.ts +6 -9
- package/src/plugins/persistence/index.js +0 -1
- package/src/types.ts +38 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = useSelect;
|
|
9
8
|
exports.useSuspenseSelect = useSuspenseSelect;
|
|
10
|
-
|
|
11
9
|
var _priorityQueue = require("@wordpress/priority-queue");
|
|
12
|
-
|
|
13
10
|
var _element = require("@wordpress/element");
|
|
14
|
-
|
|
15
11
|
var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
|
|
16
|
-
|
|
17
12
|
var _useRegistry = _interopRequireDefault(require("../registry-provider/use-registry"));
|
|
18
|
-
|
|
19
13
|
var _useAsyncMode = _interopRequireDefault(require("../async-mode-provider/use-async-mode"));
|
|
20
|
-
|
|
21
14
|
/**
|
|
22
15
|
* WordPress dependencies
|
|
23
16
|
*/
|
|
@@ -25,21 +18,20 @@ var _useAsyncMode = _interopRequireDefault(require("../async-mode-provider/use-a
|
|
|
25
18
|
/**
|
|
26
19
|
* Internal dependencies
|
|
27
20
|
*/
|
|
21
|
+
|
|
28
22
|
const renderQueue = (0, _priorityQueue.createQueue)();
|
|
23
|
+
|
|
29
24
|
/**
|
|
30
25
|
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
31
26
|
* @template {import('../../types').AnyConfig} C
|
|
32
27
|
*/
|
|
33
|
-
|
|
34
28
|
/**
|
|
35
29
|
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
36
30
|
* @template State
|
|
37
31
|
* @template {Record<string,import('../../types').ActionCreator>} Actions
|
|
38
32
|
* @template Selectors
|
|
39
33
|
*/
|
|
40
|
-
|
|
41
34
|
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
42
|
-
|
|
43
35
|
/**
|
|
44
36
|
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
45
37
|
* @template {MapSelect|StoreDescriptor<any>} T
|
|
@@ -53,16 +45,16 @@ function Store(registry, suspense) {
|
|
|
53
45
|
let lastMapResultValid = false;
|
|
54
46
|
let lastIsAsync;
|
|
55
47
|
let subscriber;
|
|
56
|
-
|
|
48
|
+
let didWarnUnstableReference;
|
|
57
49
|
const createSubscriber = stores => {
|
|
58
50
|
// The set of stores the `subscribe` function is supposed to subscribe to. Here it is
|
|
59
51
|
// initialized, and then the `updateStores` function can add new stores to it.
|
|
60
|
-
const activeStores = [...stores];
|
|
52
|
+
const activeStores = [...stores];
|
|
53
|
+
|
|
54
|
+
// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could
|
|
61
55
|
// be called multiple times to establish multiple subscriptions. That's why we need to
|
|
62
56
|
// keep a set of active subscriptions;
|
|
63
|
-
|
|
64
57
|
const activeSubscriptions = new Set();
|
|
65
|
-
|
|
66
58
|
function subscribe(listener) {
|
|
67
59
|
// Invalidate the value right after subscription was created. React will
|
|
68
60
|
// call `getValue` after subscribing, to detect store updates that happened
|
|
@@ -70,13 +62,11 @@ function Store(registry, suspense) {
|
|
|
70
62
|
// the subscription, which is slightly delayed. We need to ensure that this
|
|
71
63
|
// second `getValue` call will compute a fresh value.
|
|
72
64
|
lastMapResultValid = false;
|
|
73
|
-
|
|
74
65
|
const onStoreChange = () => {
|
|
75
66
|
// Invalidate the value on store update, so that a fresh value is computed.
|
|
76
67
|
lastMapResultValid = false;
|
|
77
68
|
listener();
|
|
78
69
|
};
|
|
79
|
-
|
|
80
70
|
const onChange = () => {
|
|
81
71
|
if (lastIsAsync) {
|
|
82
72
|
renderQueue.add(queueContext, onStoreChange);
|
|
@@ -84,53 +74,46 @@ function Store(registry, suspense) {
|
|
|
84
74
|
onStoreChange();
|
|
85
75
|
}
|
|
86
76
|
};
|
|
87
|
-
|
|
88
77
|
const unsubs = [];
|
|
89
|
-
|
|
90
78
|
function subscribeStore(storeName) {
|
|
91
79
|
unsubs.push(registry.subscribe(onChange, storeName));
|
|
92
80
|
}
|
|
93
|
-
|
|
94
81
|
for (const storeName of activeStores) {
|
|
95
82
|
subscribeStore(storeName);
|
|
96
83
|
}
|
|
97
|
-
|
|
98
84
|
activeSubscriptions.add(subscribeStore);
|
|
99
85
|
return () => {
|
|
100
86
|
activeSubscriptions.delete(subscribeStore);
|
|
101
|
-
|
|
102
87
|
for (const unsub of unsubs.values()) {
|
|
103
88
|
// The return value of the subscribe function could be undefined if the store is a custom generic store.
|
|
104
89
|
unsub?.();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
}
|
|
91
|
+
// Cancel existing store updates that were already scheduled.
|
|
108
92
|
renderQueue.cancel(queueContext);
|
|
109
93
|
};
|
|
110
|
-
}
|
|
111
|
-
|
|
94
|
+
}
|
|
112
95
|
|
|
96
|
+
// Check if `newStores` contains some stores we're not subscribed to yet, and add them.
|
|
113
97
|
function updateStores(newStores) {
|
|
114
98
|
for (const newStore of newStores) {
|
|
115
99
|
if (activeStores.includes(newStore)) {
|
|
116
100
|
continue;
|
|
117
|
-
}
|
|
118
|
-
|
|
101
|
+
}
|
|
119
102
|
|
|
120
|
-
|
|
103
|
+
// New `subscribe` calls will subscribe to `newStore`, too.
|
|
104
|
+
activeStores.push(newStore);
|
|
121
105
|
|
|
106
|
+
// Add `newStore` to existing subscriptions.
|
|
122
107
|
for (const subscription of activeSubscriptions) {
|
|
123
108
|
subscription(newStore);
|
|
124
109
|
}
|
|
125
110
|
}
|
|
126
111
|
}
|
|
127
|
-
|
|
128
112
|
return {
|
|
129
113
|
subscribe,
|
|
130
114
|
updateStores
|
|
131
115
|
};
|
|
132
116
|
};
|
|
133
|
-
|
|
134
117
|
return (mapSelect, isAsync) => {
|
|
135
118
|
function updateValue() {
|
|
136
119
|
// If the last value is valid, and the `mapSelect` callback hasn't changed,
|
|
@@ -139,57 +122,60 @@ function Store(registry, suspense) {
|
|
|
139
122
|
if (lastMapResultValid && mapSelect === lastMapSelect) {
|
|
140
123
|
return lastMapResult;
|
|
141
124
|
}
|
|
142
|
-
|
|
143
125
|
const listeningStores = {
|
|
144
126
|
current: null
|
|
145
127
|
};
|
|
146
|
-
|
|
147
128
|
const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores);
|
|
148
|
-
|
|
129
|
+
if (process.env.NODE_ENV === 'development') {
|
|
130
|
+
if (!didWarnUnstableReference) {
|
|
131
|
+
const secondMapResult = mapSelect(select, registry);
|
|
132
|
+
if (!(0, _isShallowEqual.default)(mapResult, secondMapResult)) {
|
|
133
|
+
// eslint-disable-next-line no-console
|
|
134
|
+
console.warn(`The 'useSelect' hook returns different values when called with the same state and parameters. This can lead to unnecessary rerenders.`);
|
|
135
|
+
didWarnUnstableReference = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
149
139
|
if (!subscriber) {
|
|
150
140
|
subscriber = createSubscriber(listeningStores.current);
|
|
151
141
|
} else {
|
|
152
142
|
subscriber.updateStores(listeningStores.current);
|
|
153
|
-
}
|
|
154
|
-
// that we don't trigger unwanted updates that do a `===` check.
|
|
155
|
-
|
|
143
|
+
}
|
|
156
144
|
|
|
145
|
+
// If the new value is shallow-equal to the old one, keep the old one so
|
|
146
|
+
// that we don't trigger unwanted updates that do a `===` check.
|
|
157
147
|
if (!(0, _isShallowEqual.default)(lastMapResult, mapResult)) {
|
|
158
148
|
lastMapResult = mapResult;
|
|
159
149
|
}
|
|
160
|
-
|
|
161
150
|
lastMapSelect = mapSelect;
|
|
162
151
|
lastMapResultValid = true;
|
|
163
152
|
}
|
|
164
|
-
|
|
165
153
|
function getValue() {
|
|
166
154
|
// Update the value in case it's been invalidated or `mapSelect` has changed.
|
|
167
155
|
updateValue();
|
|
168
156
|
return lastMapResult;
|
|
169
|
-
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// When transitioning from async to sync mode, cancel existing store updates
|
|
170
160
|
// that have been scheduled, and invalidate the value so that it's freshly
|
|
171
161
|
// computed. It might have been changed by the update we just cancelled.
|
|
172
|
-
|
|
173
|
-
|
|
174
162
|
if (lastIsAsync && !isAsync) {
|
|
175
163
|
lastMapResultValid = false;
|
|
176
164
|
renderQueue.cancel(queueContext);
|
|
177
165
|
}
|
|
178
|
-
|
|
179
166
|
updateValue();
|
|
180
|
-
lastIsAsync = isAsync;
|
|
167
|
+
lastIsAsync = isAsync;
|
|
181
168
|
|
|
169
|
+
// Return a pair of functions that can be passed to `useSyncExternalStore`.
|
|
182
170
|
return {
|
|
183
171
|
subscribe: subscriber.subscribe,
|
|
184
172
|
getValue
|
|
185
173
|
};
|
|
186
174
|
};
|
|
187
175
|
}
|
|
188
|
-
|
|
189
176
|
function useStaticSelect(storeName) {
|
|
190
177
|
return (0, _useRegistry.default)().select(storeName);
|
|
191
178
|
}
|
|
192
|
-
|
|
193
179
|
function useMappingSelect(suspense, mapSelect, deps) {
|
|
194
180
|
const registry = (0, _useRegistry.default)();
|
|
195
181
|
const isAsync = (0, _useAsyncMode.default)();
|
|
@@ -203,6 +189,7 @@ function useMappingSelect(suspense, mapSelect, deps) {
|
|
|
203
189
|
(0, _element.useDebugValue)(result);
|
|
204
190
|
return result;
|
|
205
191
|
}
|
|
192
|
+
|
|
206
193
|
/**
|
|
207
194
|
* Custom react hook for retrieving props from registered selectors.
|
|
208
195
|
*
|
|
@@ -267,27 +254,24 @@ function useMappingSelect(suspense, mapSelect, deps) {
|
|
|
267
254
|
* ```
|
|
268
255
|
* @return {UseSelectReturn<T>} A custom react hook.
|
|
269
256
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
257
|
function useSelect(mapSelect, deps) {
|
|
273
258
|
// On initial call, on mount, determine the mode of this `useSelect` call
|
|
274
259
|
// and then never allow it to change on subsequent updates.
|
|
275
260
|
const staticSelectMode = typeof mapSelect !== 'function';
|
|
276
261
|
const staticSelectModeRef = (0, _element.useRef)(staticSelectMode);
|
|
277
|
-
|
|
278
262
|
if (staticSelectMode !== staticSelectModeRef.current) {
|
|
279
263
|
const prevMode = staticSelectModeRef.current ? 'static' : 'mapping';
|
|
280
264
|
const nextMode = staticSelectMode ? 'static' : 'mapping';
|
|
281
265
|
throw new Error(`Switching useSelect from ${prevMode} to ${nextMode} is not allowed`);
|
|
282
266
|
}
|
|
267
|
+
|
|
283
268
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
284
269
|
// `staticSelectMode` is not allowed to change during the hook instance's,
|
|
285
270
|
// lifetime, so the rules of hooks are not really violated.
|
|
286
|
-
|
|
287
|
-
|
|
288
271
|
return staticSelectMode ? useStaticSelect(mapSelect) : useMappingSelect(false, mapSelect, deps);
|
|
289
272
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
290
273
|
}
|
|
274
|
+
|
|
291
275
|
/**
|
|
292
276
|
* A variant of the `useSelect` hook that has the same API, but will throw a
|
|
293
277
|
* suspense Promise if any of the called selectors is in an unresolved state.
|
|
@@ -303,8 +287,6 @@ function useSelect(mapSelect, deps) {
|
|
|
303
287
|
*
|
|
304
288
|
* @return {Object} Data object returned by the `mapSelect` function.
|
|
305
289
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
290
|
function useSuspenseSelect(mapSelect, deps) {
|
|
309
291
|
return useMappingSelect(true, mapSelect, deps);
|
|
310
292
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["renderQueue","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","createSubscriber","stores","activeStores","activeSubscriptions","Set","subscribe","listener","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","getValue","useStaticSelect","useMappingSelect","deps","store","selector","result","useSelect","staticSelectMode","staticSelectModeRef","prevMode","nextMode","Error","useSuspenseSelect"],"mappings":";;;;;;;;;;AAGA;;AACA;;AAOA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIA,MAAMA,WAAW,GAAG,iCAApB;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;AACA;AACA;AACA;;AAEA,SAASC,KAAT,CAAgBC,QAAhB,EAA0BC,QAA1B,EAAqC;AACpC,QAAMC,MAAM,GAAGD,QAAQ,GAAGD,QAAQ,CAACG,aAAZ,GAA4BH,QAAQ,CAACE,MAA5D;AACA,QAAME,YAAY,GAAG,EAArB;AACA,MAAIC,aAAJ;AACA,MAAIC,aAAJ;AACA,MAAIC,kBAAkB,GAAG,KAAz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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,SAAT,CAAoBd,SAApB,EAA+BU,IAA/B,EAAsC;AACpD;AACA;AACA,QAAMK,gBAAgB,GAAG,OAAOf,SAAP,KAAqB,UAA9C;AACA,QAAMgB,mBAAmB,GAAG,qBAAQD,gBAAR,CAA5B;;AAEA,MAAKA,gBAAgB,KAAKC,mBAAmB,CAACZ,OAA9C,EAAwD;AACvD,UAAMa,QAAQ,GAAGD,mBAAmB,CAACZ,OAApB,GAA8B,QAA9B,GAAyC,SAA1D;AACA,UAAMc,QAAQ,GAAGH,gBAAgB,GAAG,QAAH,GAAc,SAA/C;AACA,UAAM,IAAII,KAAJ,CACJ,4BAA4BF,QAAU,OAAOC,QAAU,iBADnD,CAAN;AAGA;AAED;AACA;AACA;;;AACA,SAAOH,gBAAgB,GACpBP,eAAe,CAAER,SAAF,CADK,GAEpBS,gBAAgB,CAAE,KAAF,EAAST,SAAT,EAAoBU,IAApB,CAFnB;AAGA;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASU,iBAAT,CAA4BpB,SAA5B,EAAuCU,IAAvC,EAA8C;AACpD,SAAOD,gBAAgB,CAAE,IAAF,EAAQT,SAAR,EAAmBU,IAAnB,CAAvB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Invalidate the value right after subscription was created. React will\n\t\t\t// call `getValue` after subscribing, to detect store updates that happened\n\t\t\t// in the interval between the `getValue` call during render and creating\n\t\t\t// the subscription, which is slightly delayed. We need to ensure that this\n\t\t\t// second `getValue` call will compute a fresh value.\n\t\t\tlastMapResultValid = false;\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo( () => Store( registry, suspense ), [ registry ] );\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t/* eslint-disable react-hooks/rules-of-hooks */\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? useStaticSelect( mapSelect )\n\t\t: useMappingSelect( false, mapSelect, deps );\n\t/* eslint-enable react-hooks/rules-of-hooks */\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param {Array} deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn useMappingSelect( true, mapSelect, deps );\n}\n"]}
|
|
1
|
+
{"version":3,"names":["_priorityQueue","require","_element","_isShallowEqual","_interopRequireDefault","_useRegistry","_useAsyncMode","renderQueue","createQueue","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","didWarnUnstableReference","createSubscriber","stores","activeStores","activeSubscriptions","Set","subscribe","listener","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","process","env","NODE_ENV","secondMapResult","isShallowEqual","console","warn","getValue","useStaticSelect","useRegistry","useMappingSelect","deps","useAsyncMode","store","useMemo","selector","useCallback","result","useSyncExternalStore","useDebugValue","useSelect","staticSelectMode","staticSelectModeRef","useRef","prevMode","nextMode","Error","useSuspenseSelect"],"sources":["@wordpress/data/src/components/use-select/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Invalidate the value right after subscription was created. React will\n\t\t\t// call `getValue` after subscribing, to detect store updates that happened\n\t\t\t// in the interval between the `getValue` call during render and creating\n\t\t\t// the subscription, which is slightly delayed. We need to ensure that this\n\t\t\t// second `getValue` call will compute a fresh value.\n\t\t\tlastMapResultValid = false;\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( process.env.NODE_ENV === 'development' ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`The 'useSelect' hook returns different values when called with the same state and parameters. This can lead to unnecessary rerenders.`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo( () => Store( registry, suspense ), [ registry ] );\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t/* eslint-disable react-hooks/rules-of-hooks */\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? useStaticSelect( mapSelect )\n\t\t: useMappingSelect( false, mapSelect, deps );\n\t/* eslint-enable react-hooks/rules-of-hooks */\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param {Array} deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn useMappingSelect( true, mapSelect, deps );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,cAAA,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ACnE,MAAM4B,QAAQ,GAAGJ,gBAAgB,GAAG,QAAQ,GAAG,SAAS;IACxD,MAAM,IAAIK,KAAK,CACb,4BAA4BF,QAAU,OAAOC,QAAU,iBACzD,CAAC;EACF;;EAEA;EACA;EACA;EACA,OAAOJ,gBAAgB,GACpBb,eAAe,CAAEf,SAAU,CAAC,GAC5BiB,gBAAgB,CAAE,KAAK,EAAEjB,SAAS,EAAEkB,IAAK,CAAC;EAC7C;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASgB,iBAAiBA,CAAElC,SAAS,EAAEkB,IAAI,EAAG;EACpD,OAAOD,gBAAgB,CAAE,IAAI,EAAEjB,SAAS,EAAEkB,IAAK,CAAC;AACjD"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _compose = require("@wordpress/compose");
|
|
11
|
-
|
|
12
9
|
var _useDispatch = require("../use-dispatch");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -104,13 +100,12 @@ var _useDispatch = require("../use-dispatch");
|
|
|
104
100
|
*/
|
|
105
101
|
const withDispatch = mapDispatchToProps => (0, _compose.createHigherOrderComponent)(WrappedComponent => ownProps => {
|
|
106
102
|
const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
|
|
107
|
-
|
|
108
103
|
const dispatchProps = (0, _useDispatch.useDispatchWithMap)(mapDispatch, []);
|
|
109
|
-
return (0, _element.createElement)(WrappedComponent, {
|
|
104
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
105
|
+
...ownProps,
|
|
110
106
|
...dispatchProps
|
|
111
107
|
});
|
|
112
108
|
}, 'withDispatch');
|
|
113
|
-
|
|
114
109
|
var _default = withDispatch;
|
|
115
110
|
exports.default = _default;
|
|
116
111
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_compose","require","_useDispatch","withDispatch","mapDispatchToProps","createHigherOrderComponent","WrappedComponent","ownProps","mapDispatch","dispatch","registry","dispatchProps","useDispatchWithMap","_element","createElement","_default","exports","default"],"sources":["@wordpress/data/src/components/with-dispatch/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDispatchWithMap } from '../use-dispatch';\n\n/** @typedef {import('@wordpress/element').WPComponent} WPComponent */\n\n/**\n * Higher-order component used to add dispatch props using registered action\n * creators.\n *\n * @param {Function} mapDispatchToProps A function of returning an object of\n * prop names where value is a\n * dispatch-bound action creator, or a\n * function to be called with the\n * component's props and returning an\n * action creator.\n *\n * @example\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps ) => {\n * const { startSale } = dispatch( myCustomStore );\n * const { discountPercent } = ownProps;\n *\n * return {\n * onClick() {\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton discountPercent=\"20\">Start Sale!</SaleButton>\n * ```\n *\n * @example\n * In the majority of cases, it will be sufficient to use only two first params\n * passed to `mapDispatchToProps` as illustrated in the previous example.\n * However, there might be some very advanced use cases where using the\n * `registry` object might be used as a tool to optimize the performance of\n * your component. Using `select` function from the registry might be useful\n * when you need to fetch some dynamic data from the store at the time when the\n * event is fired, but at the same time, you never use it to render your\n * component. In such scenario, you can avoid using the `withSelect` higher\n * order component to compute such prop, which might lead to unnecessary\n * re-renders of your component caused by its frequent value change.\n * Keep in mind, that `mapDispatchToProps` must return an object with functions\n * only.\n *\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {\n * // Stock number changes frequently.\n * const { getStockNumber } = select( myCustomStore );\n * const { startSale } = dispatch( myCustomStore );\n * return {\n * onClick() {\n * const discountPercent = getStockNumber() > 50 ? 10 : 20;\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n *\n * _Note:_ It is important that the `mapDispatchToProps` function always\n * returns an object with the same keys. For example, it should not contain\n * conditions under which a different value would be returned.\n *\n * @return {WPComponent} Enhanced component with merged dispatcher props.\n */\nconst withDispatch = ( mapDispatchToProps ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( ownProps ) => {\n\t\t\tconst mapDispatch = ( dispatch, registry ) =>\n\t\t\t\tmapDispatchToProps( dispatch, ownProps, registry );\n\t\t\tconst dispatchProps = useDispatchWithMap( mapDispatch, [] );\n\t\t\treturn <WrappedComponent { ...ownProps } { ...dispatchProps } />;\n\t\t},\n\t\t'withDispatch'\n\t);\n\nexport default withDispatch;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAAY,GAAKC,kBAAkB,IACxC,IAAAC,mCAA0B,EACvBC,gBAAgB,IAAQC,QAAQ,IAAM;EACvC,MAAMC,WAAW,GAAGA,CAAEC,QAAQ,EAAEC,QAAQ,KACvCN,kBAAkB,CAAEK,QAAQ,EAAEF,QAAQ,EAAEG,QAAS,CAAC;EACnD,MAAMC,aAAa,GAAG,IAAAC,+BAAkB,EAAEJ,WAAW,EAAE,EAAG,CAAC;EAC3D,OAAO,IAAAK,QAAA,CAAAC,aAAA,EAACR,gBAAgB;IAAA,GAAMC,QAAQ;IAAA,GAAQI;EAAa,CAAI,CAAC;AACjE,CAAC,EACD,cACD,CAAC;AAAC,IAAAI,QAAA,GAEYZ,YAAY;AAAAa,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _compose = require("@wordpress/compose");
|
|
11
|
-
|
|
12
9
|
var _registryProvider = require("../registry-provider");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -27,7 +23,8 @@ var _registryProvider = require("../registry-provider");
|
|
|
27
23
|
*
|
|
28
24
|
* @return {WPComponent} Enhanced component.
|
|
29
25
|
*/
|
|
30
|
-
const withRegistry = (0, _compose.createHigherOrderComponent)(OriginalComponent => props => (0, _element.createElement)(_registryProvider.RegistryConsumer, null, registry => (0, _element.createElement)(OriginalComponent, {
|
|
26
|
+
const withRegistry = (0, _compose.createHigherOrderComponent)(OriginalComponent => props => (0, _element.createElement)(_registryProvider.RegistryConsumer, null, registry => (0, _element.createElement)(OriginalComponent, {
|
|
27
|
+
...props,
|
|
31
28
|
registry: registry
|
|
32
29
|
})), 'withRegistry');
|
|
33
30
|
var _default = withRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_compose","require","_registryProvider","withRegistry","createHigherOrderComponent","OriginalComponent","props","_element","createElement","RegistryConsumer","registry","_default","exports","default"],"sources":["@wordpress/data/src/components/with-registry/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { RegistryConsumer } from '../registry-provider';\n\n/**\n * Higher-order component which renders the original component with the current\n * registry context passed as its `registry` prop.\n *\n * @param {WPComponent} OriginalComponent Original component.\n *\n * @return {WPComponent} Enhanced component.\n */\nconst withRegistry = createHigherOrderComponent(\n\t( OriginalComponent ) => ( props ) =>\n\t\t(\n\t\t\t<RegistryConsumer>\n\t\t\t\t{ ( registry ) => (\n\t\t\t\t\t<OriginalComponent { ...props } registry={ registry } />\n\t\t\t\t) }\n\t\t\t</RegistryConsumer>\n\t\t),\n\t'withRegistry'\n);\n\nexport default withRegistry;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAAY,GAAG,IAAAC,mCAA0B,EAC5CC,iBAAiB,IAAQC,KAAK,IAE9B,IAAAC,QAAA,CAAAC,aAAA,EAACN,iBAAA,CAAAO,gBAAgB,QACZC,QAAQ,IACX,IAAAH,QAAA,CAAAC,aAAA,EAACH,iBAAiB;EAAA,GAAMC,KAAK;EAAGI,QAAQ,EAAGA;AAAU,CAAE,CAEvC,CAClB,EACF,cACD,CAAC;AAAC,IAAAC,QAAA,GAEaR,YAAY;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _compose = require("@wordpress/compose");
|
|
13
|
-
|
|
14
10
|
var _useSelect = _interopRequireDefault(require("../use-select"));
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* WordPress dependencies
|
|
18
13
|
*/
|
|
@@ -65,13 +60,12 @@ var _useSelect = _interopRequireDefault(require("../use-select"));
|
|
|
65
60
|
*/
|
|
66
61
|
const withSelect = mapSelectToProps => (0, _compose.createHigherOrderComponent)(WrappedComponent => (0, _compose.pure)(ownProps => {
|
|
67
62
|
const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
|
|
68
|
-
|
|
69
63
|
const mergeProps = (0, _useSelect.default)(mapSelect);
|
|
70
|
-
return (0, _element.createElement)(WrappedComponent, {
|
|
64
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
65
|
+
...ownProps,
|
|
71
66
|
...mergeProps
|
|
72
67
|
});
|
|
73
68
|
}), 'withSelect');
|
|
74
|
-
|
|
75
69
|
var _default = withSelect;
|
|
76
70
|
exports.default = _default;
|
|
77
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_compose","require","_useSelect","_interopRequireDefault","withSelect","mapSelectToProps","createHigherOrderComponent","WrappedComponent","pure","ownProps","mapSelect","select","registry","mergeProps","useSelect","_element","createElement","_default","exports","default"],"sources":["@wordpress/data/src/components/with-select/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, pure } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useSelect from '../use-select';\n\n/** @typedef {import('@wordpress/element').WPComponent} WPComponent */\n\n/**\n * Higher-order component used to inject state-derived props using registered\n * selectors.\n *\n * @param {Function} mapSelectToProps Function called on every state change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @example\n * ```js\n * import { withSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function PriceDisplay( { price, currency } ) {\n * \treturn new Intl.NumberFormat( 'en-US', {\n * \t\tstyle: 'currency',\n * \t\tcurrency,\n * \t} ).format( price );\n * }\n *\n * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {\n * \tconst { getPrice } = select( myCustomStore );\n * \tconst { currency } = ownProps;\n *\n * \treturn {\n * \t\tprice: getPrice( 'hammer', currency ),\n * \t};\n * } )( PriceDisplay );\n *\n * // Rendered in the application:\n * //\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, it will pass the price into the underlying `PriceDisplay`\n * component and update automatically if the price of a hammer ever changes in\n * the store.\n *\n * @return {WPComponent} Enhanced component with merged state data props.\n */\nconst withSelect = ( mapSelectToProps ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) =>\n\t\t\tpure( ( ownProps ) => {\n\t\t\t\tconst mapSelect = ( select, registry ) =>\n\t\t\t\t\tmapSelectToProps( select, ownProps, registry );\n\t\t\t\tconst mergeProps = useSelect( mapSelect );\n\t\t\t\treturn <WrappedComponent { ...ownProps } { ...mergeProps } />;\n\t\t\t} ),\n\t\t'withSelect'\n\t);\n\nexport default withSelect;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,UAAU,GAAKC,gBAAgB,IACpC,IAAAC,mCAA0B,EACvBC,gBAAgB,IACjB,IAAAC,aAAI,EAAIC,QAAQ,IAAM;EACrB,MAAMC,SAAS,GAAGA,CAAEC,MAAM,EAAEC,QAAQ,KACnCP,gBAAgB,CAAEM,MAAM,EAAEF,QAAQ,EAAEG,QAAS,CAAC;EAC/C,MAAMC,UAAU,GAAG,IAAAC,kBAAS,EAAEJ,SAAU,CAAC;EACzC,OAAO,IAAAK,QAAA,CAAAC,aAAA,EAACT,gBAAgB;IAAA,GAAME,QAAQ;IAAA,GAAQI;EAAU,CAAI,CAAC;AAC9D,CAAE,CAAC,EACJ,YACD,CAAC;AAAC,IAAAI,QAAA,GAEYb,UAAU;AAAAc,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/build/controls.js
CHANGED
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.controls = exports.builtinControls = void 0;
|
|
7
|
-
|
|
8
7
|
var _factory = require("./factory");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Internal dependencies
|
|
12
10
|
*/
|
|
13
11
|
|
|
14
12
|
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
|
|
13
|
+
|
|
15
14
|
const SELECT = '@@data/SELECT';
|
|
16
15
|
const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
|
|
17
16
|
const DISPATCH = '@@data/DISPATCH';
|
|
18
|
-
|
|
19
17
|
function isObject(object) {
|
|
20
18
|
return object !== null && typeof object === 'object';
|
|
21
19
|
}
|
|
20
|
+
|
|
22
21
|
/**
|
|
23
22
|
* Dispatches a control action for triggering a synchronous registry select.
|
|
24
23
|
*
|
|
@@ -42,8 +41,6 @@ function isObject(object) {
|
|
|
42
41
|
*
|
|
43
42
|
* @return {Object} The control descriptor.
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
44
|
function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
48
45
|
return {
|
|
49
46
|
type: SELECT,
|
|
@@ -52,6 +49,7 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
|
52
49
|
args
|
|
53
50
|
};
|
|
54
51
|
}
|
|
52
|
+
|
|
55
53
|
/**
|
|
56
54
|
* Dispatches a control action for triggering and resolving a registry select.
|
|
57
55
|
*
|
|
@@ -76,8 +74,6 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
|
76
74
|
*
|
|
77
75
|
* @return {Object} The control descriptor.
|
|
78
76
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
77
|
function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
82
78
|
return {
|
|
83
79
|
type: RESOLVE_SELECT,
|
|
@@ -86,6 +82,7 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
|
86
82
|
args
|
|
87
83
|
};
|
|
88
84
|
}
|
|
85
|
+
|
|
89
86
|
/**
|
|
90
87
|
* Dispatches a control action for triggering a registry dispatch.
|
|
91
88
|
*
|
|
@@ -106,8 +103,6 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
|
106
103
|
*
|
|
107
104
|
* @return {Object} The control descriptor.
|
|
108
105
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
106
|
function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
|
112
107
|
return {
|
|
113
108
|
type: DISPATCH,
|
|
@@ -116,7 +111,6 @@ function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
|
|
116
111
|
args
|
|
117
112
|
};
|
|
118
113
|
}
|
|
119
|
-
|
|
120
114
|
const controls = {
|
|
121
115
|
select,
|
|
122
116
|
resolveSelect,
|
package/build/controls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_factory","require","SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","exports","builtinControls","createRegistryControl","registry","method","hasResolver"],"sources":["@wordpress/data/src/controls.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA,MAAMC,MAAM,GAAG,eAAe;AAC9B,MAAMC,cAAc,GAAG,uBAAuB;AAC9C,MAAMC,QAAQ,GAAG,iBAAiB;AAElC,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,MAAMA,CAAEC,qBAAqB,EAAEC,YAAY,EAAE,GAAGC,IAAI,EAAG;EAC/D,OAAO;IACNC,IAAI,EAAET,MAAM;IACZU,QAAQ,EAAEP,QAAQ,CAAEG,qBAAsB,CAAC,GACxCA,qBAAqB,CAACK,IAAI,GAC1BL,qBAAqB;IACxBC,YAAY;IACZC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,aAAaA,CAAEN,qBAAqB,EAAEC,YAAY,EAAE,GAAGC,IAAI,EAAG;EACtE,OAAO;IACNC,IAAI,EAAER,cAAc;IACpBS,QAAQ,EAAEP,QAAQ,CAAEG,qBAAsB,CAAC,GACxCA,qBAAqB,CAACK,IAAI,GAC1BL,qBAAqB;IACxBC,YAAY;IACZC;EACD,CAAC;AACF;;AAEA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N,IAAK,CACxD;AACD,CAAC;AAACQ,OAAA,CAAAC,eAAA,GAAAA,eAAA"}
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _registry = require("./registry");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Internal dependencies
|
|
12
10
|
*/
|
|
13
11
|
var _default = (0, _registry.createRegistry)();
|
|
14
|
-
|
|
15
12
|
exports.default = _default;
|
|
16
13
|
//# sourceMappingURL=default-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/default-registry.js"],"
|
|
1
|
+
{"version":3,"names":["_registry","require","_default","createRegistry","exports","default"],"sources":["@wordpress/data/src/default-registry.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAFA,IAAAC,QAAA,GAKe,IAAAC,wBAAc,EAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
package/build/dispatch.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.dispatch = dispatch;
|
|
9
|
-
|
|
10
8
|
var _defaultRegistry = _interopRequireDefault(require("./default-registry"));
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Internal dependencies
|
|
14
11
|
*/
|