@wordpress/data 9.9.0 → 9.10.1

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 (148) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/async-mode-provider/context.js +2 -3
  3. package/build/components/async-mode-provider/context.js.map +1 -1
  4. package/build/components/async-mode-provider/index.js +0 -5
  5. package/build/components/async-mode-provider/index.js.map +1 -1
  6. package/build/components/async-mode-provider/use-async-mode.js +1 -3
  7. package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
  8. package/build/components/registry-provider/context.js +3 -6
  9. package/build/components/registry-provider/context.js.map +1 -1
  10. package/build/components/registry-provider/index.js +0 -5
  11. package/build/components/registry-provider/index.js.map +1 -1
  12. package/build/components/registry-provider/use-registry.js +0 -3
  13. package/build/components/registry-provider/use-registry.js.map +1 -1
  14. package/build/components/use-dispatch/index.js +0 -3
  15. package/build/components/use-dispatch/index.js.map +1 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.js +0 -7
  17. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  18. package/build/components/use-dispatch/use-dispatch.js +0 -5
  19. package/build/components/use-dispatch/use-dispatch.js.map +1 -1
  20. package/build/components/use-select/index.js +35 -53
  21. package/build/components/use-select/index.js.map +1 -1
  22. package/build/components/with-dispatch/index.js +2 -7
  23. package/build/components/with-dispatch/index.js.map +1 -1
  24. package/build/components/with-registry/index.js +2 -5
  25. package/build/components/with-registry/index.js.map +1 -1
  26. package/build/components/with-select/index.js +2 -8
  27. package/build/components/with-select/index.js.map +1 -1
  28. package/build/controls.js +4 -10
  29. package/build/controls.js.map +1 -1
  30. package/build/default-registry.js +0 -3
  31. package/build/default-registry.js.map +1 -1
  32. package/build/dispatch.js +0 -3
  33. package/build/dispatch.js.map +1 -1
  34. package/build/factory.js +2 -5
  35. package/build/factory.js.map +1 -1
  36. package/build/index.js +7 -28
  37. package/build/index.js.map +1 -1
  38. package/build/lock-unlock.js +1 -2
  39. package/build/lock-unlock.js.map +1 -1
  40. package/build/plugins/index.js +0 -2
  41. package/build/plugins/index.js.map +1 -1
  42. package/build/plugins/persistence/index.js +13 -37
  43. package/build/plugins/persistence/index.js.map +1 -1
  44. package/build/plugins/persistence/storage/default.js +1 -5
  45. package/build/plugins/persistence/storage/default.js.map +1 -1
  46. package/build/plugins/persistence/storage/object.js +0 -5
  47. package/build/plugins/persistence/storage/object.js.map +1 -1
  48. package/build/promise-middleware.js +0 -5
  49. package/build/promise-middleware.js.map +1 -1
  50. package/build/redux-store/index.js +36 -117
  51. package/build/redux-store/index.js.map +1 -1
  52. package/build/redux-store/metadata/actions.js +8 -17
  53. package/build/redux-store/metadata/actions.js.map +1 -1
  54. package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  55. package/build/redux-store/metadata/reducer.js +1 -23
  56. package/build/redux-store/metadata/reducer.js.map +1 -1
  57. package/build/redux-store/metadata/selectors.js +8 -22
  58. package/build/redux-store/metadata/selectors.js.map +1 -1
  59. package/build/redux-store/metadata/utils.js +6 -14
  60. package/build/redux-store/metadata/utils.js.map +1 -1
  61. package/build/redux-store/thunk-middleware.js +0 -2
  62. package/build/redux-store/thunk-middleware.js.map +1 -1
  63. package/build/registry.js +29 -73
  64. package/build/registry.js.map +1 -1
  65. package/build/resolvers-cache-middleware.js +2 -8
  66. package/build/resolvers-cache-middleware.js.map +1 -1
  67. package/build/select.js +0 -3
  68. package/build/select.js.map +1 -1
  69. package/build/store/index.js +0 -7
  70. package/build/store/index.js.map +1 -1
  71. package/build/types.js.map +1 -1
  72. package/build/utils/emitter.js +2 -11
  73. package/build/utils/emitter.js.map +1 -1
  74. package/build-module/components/async-mode-provider/context.js +1 -1
  75. package/build-module/components/async-mode-provider/context.js.map +1 -1
  76. package/build-module/components/async-mode-provider/index.js.map +1 -1
  77. package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
  78. package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
  79. package/build-module/components/registry-provider/context.js +3 -3
  80. package/build-module/components/registry-provider/context.js.map +1 -1
  81. package/build-module/components/registry-provider/index.js.map +1 -1
  82. package/build-module/components/registry-provider/use-registry.js +2 -2
  83. package/build-module/components/registry-provider/use-registry.js.map +1 -1
  84. package/build-module/components/use-dispatch/index.js.map +1 -1
  85. package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -4
  86. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  87. package/build-module/components/use-dispatch/use-dispatch.js +1 -3
  88. package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
  89. package/build-module/components/use-select/index.js +35 -46
  90. package/build-module/components/use-select/index.js.map +1 -1
  91. package/build-module/components/with-dispatch/index.js +4 -6
  92. package/build-module/components/with-dispatch/index.js.map +1 -1
  93. package/build-module/components/with-registry/index.js +4 -4
  94. package/build-module/components/with-registry/index.js.map +1 -1
  95. package/build-module/components/with-select/index.js +4 -6
  96. package/build-module/components/with-select/index.js.map +1 -1
  97. package/build-module/controls.js +4 -8
  98. package/build-module/controls.js.map +1 -1
  99. package/build-module/default-registry.js.map +1 -1
  100. package/build-module/dispatch.js +2 -1
  101. package/build-module/dispatch.js.map +1 -1
  102. package/build-module/factory.js +2 -3
  103. package/build-module/factory.js.map +1 -1
  104. package/build-module/index.js +11 -10
  105. package/build-module/index.js.map +1 -1
  106. package/build-module/lock-unlock.js.map +1 -1
  107. package/build-module/plugins/index.js.map +1 -1
  108. package/build-module/plugins/persistence/index.js +15 -30
  109. package/build-module/plugins/persistence/index.js.map +1 -1
  110. package/build-module/plugins/persistence/storage/default.js +0 -2
  111. package/build-module/plugins/persistence/storage/default.js.map +1 -1
  112. package/build-module/plugins/persistence/storage/object.js +0 -5
  113. package/build-module/plugins/persistence/storage/object.js.map +1 -1
  114. package/build-module/promise-middleware.js +1 -3
  115. package/build-module/promise-middleware.js.map +1 -1
  116. package/build-module/redux-store/index.js +38 -101
  117. package/build-module/redux-store/index.js.map +1 -1
  118. package/build-module/redux-store/metadata/actions.js +8 -8
  119. package/build-module/redux-store/metadata/actions.js.map +1 -1
  120. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  121. package/build-module/redux-store/metadata/reducer.js +1 -21
  122. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  123. package/build-module/redux-store/metadata/selectors.js +9 -13
  124. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  125. package/build-module/redux-store/metadata/utils.js +6 -11
  126. package/build-module/redux-store/metadata/utils.js.map +1 -1
  127. package/build-module/redux-store/thunk-middleware.js +0 -1
  128. package/build-module/redux-store/thunk-middleware.js.map +1 -1
  129. package/build-module/registry.js +30 -67
  130. package/build-module/registry.js.map +1 -1
  131. package/build-module/resolvers-cache-middleware.js +3 -6
  132. package/build-module/resolvers-cache-middleware.js.map +1 -1
  133. package/build-module/select.js +2 -1
  134. package/build-module/select.js.map +1 -1
  135. package/build-module/store/index.js +0 -7
  136. package/build-module/store/index.js.map +1 -1
  137. package/build-module/types.js.map +1 -1
  138. package/build-module/utils/emitter.js +2 -10
  139. package/build-module/utils/emitter.js.map +1 -1
  140. package/build-types/components/use-select/index.d.ts.map +1 -1
  141. package/build-types/index.d.ts +1 -1
  142. package/build-types/index.d.ts.map +1 -1
  143. package/build-types/plugins/persistence/index.d.ts.map +1 -1
  144. package/build-types/store/index.d.ts +1 -1
  145. package/package.json +9 -9
  146. package/src/components/use-select/index.js +14 -0
  147. package/src/plugins/persistence/index.js +0 -1
  148. package/tsconfig.tsbuildinfo +1 -1
@@ -2,14 +2,15 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import deprecated from '@wordpress/deprecated';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import createReduxStore from './redux-store';
10
10
  import coreDataStore from './store';
11
11
  import { createEmitter } from './utils/emitter';
12
12
  import { lock, unlock } from './lock-unlock';
13
+
13
14
  /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
14
15
 
15
16
  /**
@@ -50,19 +51,18 @@ function getStoreName(storeNameOrDescriptor) {
50
51
  *
51
52
  * @return {WPDataRegistry} Data registry.
52
53
  */
53
-
54
-
55
54
  export function createRegistry(storeConfigs = {}, parent = null) {
56
55
  const stores = {};
57
56
  const emitter = createEmitter();
58
57
  let listeningStores = null;
58
+
59
59
  /**
60
60
  * Global listener called for each store's update.
61
61
  */
62
-
63
62
  function globalListener() {
64
63
  emitter.emit();
65
64
  }
65
+
66
66
  /**
67
67
  * Subscribe to changes to any data, either in all stores in registry, or
68
68
  * in one specific store.
@@ -72,32 +72,29 @@ export function createRegistry(storeConfigs = {}, parent = null) {
72
72
  *
73
73
  * @return {Function} Unsubscribe function.
74
74
  */
75
-
76
-
77
75
  const subscribe = (listener, storeNameOrDescriptor) => {
78
76
  // subscribe to all stores
79
77
  if (!storeNameOrDescriptor) {
80
78
  return emitter.subscribe(listener);
81
- } // subscribe to one store
82
-
79
+ }
83
80
 
81
+ // subscribe to one store
84
82
  const storeName = getStoreName(storeNameOrDescriptor);
85
83
  const store = stores[storeName];
86
-
87
84
  if (store) {
88
85
  return store.subscribe(listener);
89
- } // Trying to access a store that hasn't been registered,
86
+ }
87
+
88
+ // Trying to access a store that hasn't been registered,
90
89
  // this is a pattern rarely used but seen in some places.
91
90
  // We fallback to global `subscribe` here for backward-compatibility for now.
92
91
  // See https://github.com/WordPress/gutenberg/pull/27466 for more info.
93
-
94
-
95
92
  if (!parent) {
96
93
  return emitter.subscribe(listener);
97
94
  }
98
-
99
95
  return parent.subscribe(listener, storeNameOrDescriptor);
100
96
  };
97
+
101
98
  /**
102
99
  * Calls a selector given the current state and extra arguments.
103
100
  *
@@ -106,23 +103,17 @@ export function createRegistry(storeConfigs = {}, parent = null) {
106
103
  *
107
104
  * @return {*} The selector's returned value.
108
105
  */
109
-
110
-
111
106
  function select(storeNameOrDescriptor) {
112
107
  const storeName = getStoreName(storeNameOrDescriptor);
113
108
  listeningStores?.add(storeName);
114
109
  const store = stores[storeName];
115
-
116
110
  if (store) {
117
111
  return store.getSelectors();
118
112
  }
119
-
120
113
  return parent?.select(storeName);
121
114
  }
122
-
123
115
  function __unstableMarkListeningStores(callback, ref) {
124
116
  listeningStores = new Set();
125
-
126
117
  try {
127
118
  return callback.call(this);
128
119
  } finally {
@@ -130,6 +121,7 @@ export function createRegistry(storeConfigs = {}, parent = null) {
130
121
  listeningStores = null;
131
122
  }
132
123
  }
124
+
133
125
  /**
134
126
  * Given a store descriptor, returns an object containing the store's selectors pre-bound to
135
127
  * state so that you only need to supply additional arguments, and modified so that they return
@@ -141,19 +133,16 @@ export function createRegistry(storeConfigs = {}, parent = null) {
141
133
  *
142
134
  * @return {Object} Each key of the object matches the name of a selector.
143
135
  */
144
-
145
-
146
136
  function resolveSelect(storeNameOrDescriptor) {
147
137
  const storeName = getStoreName(storeNameOrDescriptor);
148
138
  listeningStores?.add(storeName);
149
139
  const store = stores[storeName];
150
-
151
140
  if (store) {
152
141
  return store.getResolveSelectors();
153
142
  }
154
-
155
143
  return parent && parent.resolveSelect(storeName);
156
144
  }
145
+
157
146
  /**
158
147
  * Given a store descriptor, returns an object containing the store's selectors pre-bound to
159
148
  * state so that you only need to supply additional arguments, and modified so that they throw
@@ -165,19 +154,16 @@ export function createRegistry(storeConfigs = {}, parent = null) {
165
154
  *
166
155
  * @return {Object} Object containing the store's suspense-wrapped selectors.
167
156
  */
168
-
169
-
170
157
  function suspendSelect(storeNameOrDescriptor) {
171
158
  const storeName = getStoreName(storeNameOrDescriptor);
172
159
  listeningStores?.add(storeName);
173
160
  const store = stores[storeName];
174
-
175
161
  if (store) {
176
162
  return store.getSuspendSelectors();
177
163
  }
178
-
179
164
  return parent && parent.suspendSelect(storeName);
180
165
  }
166
+
181
167
  /**
182
168
  * Returns the available actions for a part of the state.
183
169
  *
@@ -186,68 +172,56 @@ export function createRegistry(storeConfigs = {}, parent = null) {
186
172
  *
187
173
  * @return {*} The action's returned value.
188
174
  */
189
-
190
-
191
175
  function dispatch(storeNameOrDescriptor) {
192
176
  const storeName = getStoreName(storeNameOrDescriptor);
193
177
  const store = stores[storeName];
194
-
195
178
  if (store) {
196
179
  return store.getActions();
197
180
  }
198
-
199
181
  return parent && parent.dispatch(storeName);
200
- } //
182
+ }
183
+
184
+ //
201
185
  // Deprecated
202
186
  // TODO: Remove this after `use()` is removed.
203
-
204
-
205
187
  function withPlugins(attributes) {
206
188
  return Object.fromEntries(Object.entries(attributes).map(([key, attribute]) => {
207
189
  if (typeof attribute !== 'function') {
208
190
  return [key, attribute];
209
191
  }
210
-
211
192
  return [key, function () {
212
193
  return registry[key].apply(null, arguments);
213
194
  }];
214
195
  }));
215
196
  }
197
+
216
198
  /**
217
199
  * Registers a store instance.
218
200
  *
219
201
  * @param {string} name Store registry name.
220
202
  * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).
221
203
  */
222
-
223
-
224
204
  function registerStoreInstance(name, createStore) {
225
205
  if (stores[name]) {
226
206
  // eslint-disable-next-line no-console
227
207
  console.error('Store "' + name + '" is already registered.');
228
208
  return stores[name];
229
209
  }
230
-
231
210
  const store = createStore();
232
-
233
211
  if (typeof store.getSelectors !== 'function') {
234
212
  throw new TypeError('store.getSelectors must be a function');
235
213
  }
236
-
237
214
  if (typeof store.getActions !== 'function') {
238
215
  throw new TypeError('store.getActions must be a function');
239
216
  }
240
-
241
217
  if (typeof store.subscribe !== 'function') {
242
218
  throw new TypeError('store.subscribe must be a function');
243
- } // The emitter is used to keep track of active listeners when the registry
219
+ }
220
+ // The emitter is used to keep track of active listeners when the registry
244
221
  // get paused, that way, when resumed we should be able to call all these
245
222
  // pending listeners.
246
-
247
-
248
223
  store.emitter = createEmitter();
249
224
  const currentSubscribe = store.subscribe;
250
-
251
225
  store.subscribe = listener => {
252
226
  const unsubscribeFromEmitter = store.emitter.subscribe(listener);
253
227
  const unsubscribeFromStore = currentSubscribe(() => {
@@ -255,7 +229,6 @@ export function createRegistry(storeConfigs = {}, parent = null) {
255
229
  store.emitter.emit();
256
230
  return;
257
231
  }
258
-
259
232
  listener();
260
233
  });
261
234
  return () => {
@@ -263,33 +236,31 @@ export function createRegistry(storeConfigs = {}, parent = null) {
263
236
  unsubscribeFromEmitter?.();
264
237
  };
265
238
  };
266
-
267
239
  stores[name] = store;
268
- store.subscribe(globalListener); // Copy private actions and selectors from the parent store.
240
+ store.subscribe(globalListener);
269
241
 
242
+ // Copy private actions and selectors from the parent store.
270
243
  if (parent) {
271
244
  try {
272
245
  unlock(store.store).registerPrivateActions(unlock(parent).privateActionsOf(name));
273
246
  unlock(store.store).registerPrivateSelectors(unlock(parent).privateSelectorsOf(name));
274
- } catch (e) {// unlock() throws if store.store was not locked.
247
+ } catch (e) {
248
+ // unlock() throws if store.store was not locked.
275
249
  // The error indicates there's nothing to do here so let's
276
250
  // ignore it.
277
251
  }
278
252
  }
279
-
280
253
  return store;
281
254
  }
255
+
282
256
  /**
283
257
  * Registers a new store given a store descriptor.
284
258
  *
285
259
  * @param {StoreDescriptor} store Store descriptor.
286
260
  */
287
-
288
-
289
261
  function register(store) {
290
262
  registerStoreInstance(store.name, () => store.instantiate(registry));
291
263
  }
292
-
293
264
  function registerGenericStore(name, store) {
294
265
  deprecated('wp.data.registerGenericStore', {
295
266
  since: '5.9',
@@ -297,6 +268,7 @@ export function createRegistry(storeConfigs = {}, parent = null) {
297
268
  });
298
269
  registerStoreInstance(name, () => store);
299
270
  }
271
+
300
272
  /**
301
273
  * Registers a standard `@wordpress/data` store.
302
274
  *
@@ -305,31 +277,25 @@ export function createRegistry(storeConfigs = {}, parent = null) {
305
277
  *
306
278
  * @return {Object} Registered store object.
307
279
  */
308
-
309
-
310
280
  function registerStore(storeName, options) {
311
281
  if (!options.reducer) {
312
282
  throw new TypeError('Must specify store reducer');
313
283
  }
314
-
315
284
  const store = registerStoreInstance(storeName, () => createReduxStore(storeName, options).instantiate(registry));
316
285
  return store.store;
317
286
  }
318
-
319
287
  function batch(callback) {
320
288
  // If we're already batching, just call the callback.
321
289
  if (emitter.isPaused) {
322
290
  callback();
323
291
  return;
324
292
  }
325
-
326
293
  emitter.pause();
327
294
  Object.values(stores).forEach(store => store.emitter.pause());
328
295
  callback();
329
296
  emitter.resume();
330
297
  Object.values(stores).forEach(store => store.emitter.resume());
331
298
  }
332
-
333
299
  let registry = {
334
300
  batch,
335
301
  stores,
@@ -345,31 +311,28 @@ export function createRegistry(storeConfigs = {}, parent = null) {
345
311
  registerGenericStore,
346
312
  registerStore,
347
313
  __unstableMarkListeningStores
348
- }; //
314
+ };
315
+
316
+ //
349
317
  // TODO:
350
318
  // This function will be deprecated as soon as it is no longer internally referenced.
351
-
352
319
  function use(plugin, options) {
353
320
  if (!plugin) {
354
321
  return;
355
322
  }
356
-
357
- registry = { ...registry,
323
+ registry = {
324
+ ...registry,
358
325
  ...plugin(registry, options)
359
326
  };
360
327
  return registry;
361
328
  }
362
-
363
329
  registry.register(coreDataStore);
364
-
365
330
  for (const [name, config] of Object.entries(storeConfigs)) {
366
331
  registry.register(createReduxStore(name, config));
367
332
  }
368
-
369
333
  if (parent) {
370
334
  parent.subscribe(globalListener);
371
335
  }
372
-
373
336
  const registryWithPlugins = withPlugins(registry);
374
337
  lock(registryWithPlugins, {
375
338
  privateActionsOf: name => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","values","forEach","resume","namespaces","use","plugin","config","registryWithPlugins","privateActions","privateSelectors"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,IAAT,EAAeC,MAAf,QAA6B,eAA7B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,SAASC,YAAT,CAAuBC,qBAAvB,EAA+C;AAC9C,SAAO,OAAOA,qBAAP,KAAiC,QAAjC,GACJA,qBADI,GAEJA,qBAAqB,CAACC,IAFzB;AAGA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,cAAT,CAAyBC,YAAY,GAAG,EAAxC,EAA4CC,MAAM,GAAG,IAArD,EAA4D;AAClE,QAAMC,MAAM,GAAG,EAAf;AACA,QAAMC,OAAO,GAAGV,aAAa,EAA7B;AACA,MAAIW,eAAe,GAAG,IAAtB;AAEA;AACD;AACA;;AACC,WAASC,cAAT,GAA0B;AACzBF,IAAAA,OAAO,CAACG,IAAR;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMC,SAAS,GAAG,CAAEC,QAAF,EAAYX,qBAAZ,KAAuC;AACxD;AACA,QAAK,CAAEA,qBAAP,EAA+B;AAC9B,aAAOM,OAAO,CAACI,SAAR,CAAmBC,QAAnB,CAAP;AACA,KAJuD,CAMxD;;;AACA,UAAMC,SAAS,GAAGb,YAAY,CAAEC,qBAAF,CAA9B;AACA,UAAMa,KAAK,GAAGR,MAAM,CAAEO,SAAF,CAApB;;AACA,QAAKC,KAAL,EAAa;AACZ,aAAOA,KAAK,CAACH,SAAN,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AT,CAAmB7D,aAAnB;;AAEA,OAAM,MAAM,CAAEM,IAAF,EAAQuE,MAAR,CAAZ,IAAgCvC,MAAM,CAACE,OAAP,CAAgBhC,YAAhB,CAAhC,EAAiE;AAChEoC,IAAAA,QAAQ,CAACiB,QAAT,CAAmB9D,gBAAgB,CAAEO,IAAF,EAAQuE,MAAR,CAAnC;AACA;;AAED,MAAKpE,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACM,SAAP,CAAkBF,cAAlB;AACA;;AAED,QAAMiE,mBAAmB,GAAG1C,WAAW,CAAEQ,QAAF,CAAvC;AACA1C,EAAAA,IAAI,CAAE4E,mBAAF,EAAuB;AAC1BrB,IAAAA,gBAAgB,EAAInD,IAAF,IAAY;AAC7B,UAAI;AACH,eAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAF,CAAN,CAAeY,KAAjB,CAAN,CAA+B6D,cAAtC;AACA,OAFD,CAEE,OAAQnB,CAAR,EAAY;AACb;AACA;AACA,eAAO,EAAP;AACA;AACD,KATyB;AAU1BD,IAAAA,kBAAkB,EAAIrD,IAAF,IAAY;AAC/B,UAAI;AACH,eAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAF,CAAN,CAAeY,KAAjB,CAAN,CAA+B8D,gBAAtC;AACA,OAFD,CAEE,OAAQpB,CAAR,EAAY;AACb,eAAO,EAAP;AACA;AACD;AAhByB,GAAvB,CAAJ;AAkBA,SAAOkB,mBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins( attributes ) {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store = createStore();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"]}
1
+ {"version":3,"names":["deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","values","forEach","resume","namespaces","use","plugin","config","registryWithPlugins","privateActions","privateSelectors"],"sources":["@wordpress/data/src/registry.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins( attributes ) {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store = createStore();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,eAAe;AAC5C,OAAOC,aAAa,MAAM,SAAS;AACnC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,IAAI,EAAEC,MAAM,QAAQ,eAAe;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,SAASC,YAAYA,CAAEC,qBAAqB,EAAG;EAC9C,OAAO,OAAOA,qBAAqB,KAAK,QAAQ,GAC7CA,qBAAqB,GACrBA,qBAAqB,CAACC,IAAI;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,YAAY,GAAG,CAAC,CAAC,EAAEC,MAAM,GAAG,IAAI,EAAG;EAClE,MAAMC,MAAM,GAAG,CAAC,CAAC;EACjB,MAAMC,OAAO,GAAGV,aAAa,CAAC,CAAC;EAC/B,IAAIW,eAAe,GAAG,IAAI;;EAE1B;AACD;AACA;EACC,SAASC,cAAcA,C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ES,MAAM,EAAG;MACf;IACD;IAEAhC,QAAQ,GAAG;MACV,GAAGA,QAAQ;MACX,GAAGgC,MAAM,CAAEhC,QAAQ,EAAEuB,OAAQ;IAC9B,CAAC;IAED,OAAOvB,QAAQ;EAChB;EAEAA,QAAQ,CAACiB,QAAQ,CAAE7D,aAAc,CAAC;EAElC,KAAM,MAAM,CAAEM,IAAI,EAAEuE,MAAM,CAAE,IAAIvC,MAAM,CAACE,OAAO,CAAEhC,YAAa,CAAC,EAAG;IAChEoC,QAAQ,CAACiB,QAAQ,CAAE9D,gBAAgB,CAAEO,IAAI,EAAEuE,MAAO,CAAE,CAAC;EACtD;EAEA,IAAKpE,MAAM,EAAG;IACbA,MAAM,CAACM,SAAS,CAAEF,cAAe,CAAC;EACnC;EAEA,MAAMiE,mBAAmB,GAAG1C,WAAW,CAAEQ,QAAS,CAAC;EACnD1C,IAAI,CAAE4E,mBAAmB,EAAE;IAC1BrB,gBAAgB,EAAInD,IAAI,IAAM;MAC7B,IAAI;QACH,OAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC6D,cAAc;MACrD,CAAC,CAAC,OAAQnB,CAAC,EAAG;QACb;QACA;QACA,OAAO,CAAC,CAAC;MACV;IACD,CAAC;IACDD,kBAAkB,EAAIrD,IAAI,IAAM;MAC/B,IAAI;QACH,OAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC8D,gBAAgB;MACvD,CAAC,CAAC,OAAQpB,CAAC,EAAG;QACb,OAAO,CAAC,CAAC;MACV;IACD;EACD,CAAE,CAAC;EACH,OAAOkB,mBAAmB;AAC3B"}
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import coreDataStore from './store';
5
+
5
6
  /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
6
7
 
7
8
  /**
@@ -14,30 +15,26 @@ import coreDataStore from './store';
14
15
  *
15
16
  * @return {Function} Middleware function.
16
17
  */
17
-
18
18
  const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
19
19
  const resolvers = registry.select(coreDataStore).getCachedResolvers(reducerKey);
20
20
  Object.entries(resolvers).forEach(([selectorName, resolversByArgs]) => {
21
21
  const resolver = registry.stores?.[reducerKey]?.resolvers?.[selectorName];
22
-
23
22
  if (!resolver || !resolver.shouldInvalidate) {
24
23
  return;
25
24
  }
26
-
27
25
  resolversByArgs.forEach((value, args) => {
28
26
  // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
29
27
  // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need
30
28
  // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.
31
29
  if (value?.status !== 'finished' && value?.status !== 'error' || !resolver.shouldInvalidate(action, ...args)) {
32
30
  return;
33
- } // Trigger cache invalidation
34
-
31
+ }
35
32
 
33
+ // Trigger cache invalidation
36
34
  registry.dispatch(coreDataStore).invalidateResolution(reducerKey, selectorName, args);
37
35
  });
38
36
  });
39
37
  return next(action);
40
38
  };
41
-
42
39
  export default createResolversCacheMiddleware;
43
40
  //# sourceMappingURL=resolvers-cache-middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["coreDataStore","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","status","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,SAA1B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,GACnC,CAAEC,QAAF,EAAYC,UAAZ,KAA4B,MAAQC,IAAF,IAAcC,MAAF,IAAc;AAC3D,QAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MADgB,CACRP,aADQ,EAEhBQ,kBAFgB,CAEIL,UAFJ,CAAlB;AAGAM,EAAAA,MAAM,CAACC,OAAP,CAAgBJ,SAAhB,EAA4BK,OAA5B,CACC,CAAE,CAAEC,YAAF,EAAgBC,eAAhB,CAAF,KAAyC;AACxC,UAAMC,QAAQ,GACbZ,QAAQ,CAACa,MAAT,GAAmBZ,UAAnB,GAAiCG,SAAjC,GACCM,YADD,CADD;;AAIA,QAAK,CAAEE,QAAF,IAAc,CAAEA,QAAQ,CAACE,gBAA9B,EAAiD;AAChD;AACA;;AACDH,IAAAA,eAAe,CAACF,OAAhB,CAAyB,CAAEM,KAAF,EAASC,IAAT,KAAmB;AAC3C;AACA;AACA;AACA,UACGD,KAAK,EAAEE,MAAP,KAAkB,UAAlB,IACDF,KAAK,EAAEE,MAAP,KAAkB,OADnB,IAEA,CAAEL,QAAQ,CAACE,gBAAT,CAA2BX,MAA3B,EAAmC,GAAGa,IAAtC,CAHH,EAIE;AACD;AACA,OAV0C,CAY3C;;;AACAhB,MAAAA,QAAQ,CACNkB,QADF,CACYpB,aADZ,EAEEqB,oBAFF,CAEwBlB,UAFxB,EAEoCS,YAFpC,EAEkDM,IAFlD;AAGA,KAhBD;AAiBA,GA1BF;AA4BA,SAAOd,IAAI,CAAEC,MAAF,CAAX;AACA,CAlCF;;AAoCA,eAAeJ,8BAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport coreDataStore from './store';\n\n/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry The registry reference for which to create\n * the middleware.\n * @param {string} reducerKey The namespace for which to create the\n * middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, reducerKey ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getCachedResolvers( reducerKey );\n\t\tObject.entries( resolvers ).forEach(\n\t\t\t( [ selectorName, resolversByArgs ] ) => {\n\t\t\t\tconst resolver =\n\t\t\t\t\tregistry.stores?.[ reducerKey ]?.resolvers?.[\n\t\t\t\t\t\tselectorName\n\t\t\t\t\t];\n\t\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\t\tif (\n\t\t\t\t\t\t( value?.status !== 'finished' &&\n\t\t\t\t\t\t\tvalue?.status !== 'error' ) ||\n\t\t\t\t\t\t! resolver.shouldInvalidate( action, ...args )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Trigger cache invalidation\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreDataStore )\n\t\t\t\t\t\t.invalidateResolution( reducerKey, selectorName, args );\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"]}
1
+ {"version":3,"names":["coreDataStore","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","status","dispatch","invalidateResolution"],"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport coreDataStore from './store';\n\n/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry The registry reference for which to create\n * the middleware.\n * @param {string} reducerKey The namespace for which to create the\n * middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, reducerKey ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getCachedResolvers( reducerKey );\n\t\tObject.entries( resolvers ).forEach(\n\t\t\t( [ selectorName, resolversByArgs ] ) => {\n\t\t\t\tconst resolver =\n\t\t\t\t\tregistry.stores?.[ reducerKey ]?.resolvers?.[\n\t\t\t\t\t\tselectorName\n\t\t\t\t\t];\n\t\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\t\tif (\n\t\t\t\t\t\t( value?.status !== 'finished' &&\n\t\t\t\t\t\t\tvalue?.status !== 'error' ) ||\n\t\t\t\t\t\t! resolver.shouldInvalidate( action, ...args )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Trigger cache invalidation\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreDataStore )\n\t\t\t\t\t\t.invalidateResolution( reducerKey, selectorName, args );\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,SAAS;;AAEnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,8BAA8B,GACnCA,CAAEC,QAAQ,EAAEC,UAAU,KAAM,MAAQC,IAAI,IAAQC,MAAM,IAAM;EAC3D,MAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MAAM,CAAEP,aAAc,CAAC,CACvBQ,kBAAkB,CAAEL,UAAW,CAAC;EAClCM,MAAM,CAACC,OAAO,CAAEJ,SAAU,CAAC,CAACK,OAAO,CAClC,CAAE,CAAEC,YAAY,EAAEC,eAAe,CAAE,KAAM;IACxC,MAAMC,QAAQ,GACbZ,QAAQ,CAACa,MAAM,GAAIZ,UAAU,CAAE,EAAEG,SAAS,GACzCM,YAAY,CACZ;IACF,IAAK,CAAEE,QAAQ,IAAI,CAAEA,QAAQ,CAACE,gBAAgB,EAAG;MAChD;IACD;IACAH,eAAe,CAACF,OAAO,CAAE,CAAEM,KAAK,EAAEC,IAAI,KAAM;MAC3C;MACA;MACA;MACA,IACGD,KAAK,EAAEE,MAAM,KAAK,UAAU,IAC7BF,KAAK,EAAEE,MAAM,KAAK,OAAO,IAC1B,CAAEL,QAAQ,CAACE,gBAAgB,CAAEX,MAAM,EAAE,GAAGa,IAAK,CAAC,EAC7C;QACD;MACD;;MAEA;MACAhB,QAAQ,CACNkB,QAAQ,CAAEpB,aAAc,CAAC,CACzBqB,oBAAoB,CAAElB,UAAU,EAAES,YAAY,EAAEM,IAAK,CAAC;IACzD,CAAE,CAAC;EACJ,CACD,CAAC;EACD,OAAOd,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAEF,eAAeJ,8BAA8B"}
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
+
4
5
  import defaultRegistry from './default-registry';
6
+
5
7
  /**
6
8
  * Given a store descriptor, returns an object of the store's selectors.
7
9
  * The selector functions are been pre-bound to pass the current state automatically.
@@ -21,7 +23,6 @@ import defaultRegistry from './default-registry';
21
23
  *
22
24
  * @return Object containing the store's selectors.
23
25
  */
24
-
25
26
  export function select(storeNameOrDescriptor) {
26
27
  return defaultRegistry.select(storeNameOrDescriptor);
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/select.ts"],"names":["defaultRegistry","select","storeNameOrDescriptor"],"mappings":"AAAA;AACA;AACA;AAEA,OAAOA,eAAP,MAA4B,oBAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,MAAT,CACNC,qBADM,EAEoB;AAC1B,SAAOF,eAAe,CAACC,MAAhB,CAAwBC,qBAAxB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, CurriedSelectorsOf, StoreDescriptor } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's selectors.\n * The selector functions are been pre-bound to pass the current state automatically.\n * As a consumer, you need only pass arguments of the selector, if applicable.\n *\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention\n * of passing the store name is also supported.\n *\n * @example\n * ```js\n * import { select } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * select( myCustomStore ).getPrice( 'hammer' );\n * ```\n *\n * @return Object containing the store's selectors.\n */\nexport function select< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: string | T\n): CurriedSelectorsOf< T > {\n\treturn defaultRegistry.select( storeNameOrDescriptor );\n}\n"]}
1
+ {"version":3,"names":["defaultRegistry","select","storeNameOrDescriptor"],"sources":["@wordpress/data/src/select.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, CurriedSelectorsOf, StoreDescriptor } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's selectors.\n * The selector functions are been pre-bound to pass the current state automatically.\n * As a consumer, you need only pass arguments of the selector, if applicable.\n *\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention\n * of passing the store name is also supported.\n *\n * @example\n * ```js\n * import { select } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * select( myCustomStore ).getPrice( 'hammer' );\n * ```\n *\n * @return Object containing the store's selectors.\n */\nexport function select< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: string | T\n): CurriedSelectorsOf< T > {\n\treturn defaultRegistry.select( storeNameOrDescriptor );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,eAAe,MAAM,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CACrBC,qBAAiC,EACP;EAC1B,OAAOF,eAAe,CAACC,MAAM,CAAEC,qBAAsB,CAAC;AACvD"}
@@ -1,24 +1,19 @@
1
1
  const coreDataStore = {
2
2
  name: 'core/data',
3
-
4
3
  instantiate(registry) {
5
4
  const getCoreDataSelector = selectorName => (key, ...args) => {
6
5
  return registry.select(key)[selectorName](...args);
7
6
  };
8
-
9
7
  const getCoreDataAction = actionName => (key, ...args) => {
10
8
  return registry.dispatch(key)[actionName](...args);
11
9
  };
12
-
13
10
  return {
14
11
  getSelectors() {
15
12
  return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)]));
16
13
  },
17
-
18
14
  getActions() {
19
15
  return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)]));
20
16
  },
21
-
22
17
  subscribe() {
23
18
  // There's no reasons to trigger any listener when we subscribe to this store
24
19
  // because there's no state stored in this store that need to retrigger selectors
@@ -26,10 +21,8 @@ const coreDataStore = {
26
21
  // would have already triggered a "subscribe" call.
27
22
  return () => () => {};
28
23
  }
29
-
30
24
  };
31
25
  }
32
-
33
26
  };
34
27
  export default coreDataStore;
35
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/store/index.js"],"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"mappings":"AAAA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,WADe;;AAErBC,EAAAA,WAAW,CAAEC,QAAF,EAAa;AACvB,UAAMC,mBAAmB,GACtBC,YAAF,IACA,CAAEC,GAAF,EAAO,GAAGC,IAAV,KAAoB;AACnB,aAAOJ,QAAQ,CAACK,MAAT,CAAiBF,GAAjB,EAAwBD,YAAxB,EAAwC,GAAGE,IAA3C,CAAP;AACA,KAJF;;AAMA,UAAME,iBAAiB,GACpBC,UAAF,IACA,CAAEJ,GAAF,EAAO,GAAGC,IAAV,KAAoB;AACnB,aAAOJ,QAAQ,CAACQ,QAAT,CAAmBL,GAAnB,EAA0BI,UAA1B,EAAwC,GAAGH,IAA3C,CAAP;AACA,KAJF;;AAMA,WAAO;AACNK,MAAAA,YAAY,GAAG;AACd,eAAOC,MAAM,CAACC,WAAP,CACN,CACC,gBADD,EAEC,sBAFD,EAGC,uBAHD,EAIC,aAJD,EAKC,oBALD,EAMEC,GANF,CAMSV,YAAF,IAAoB,CAC1BA,YAD0B,EAE1BD,mBAAmB,CAAEC,YAAF,CAFO,CAN3B,CADM,CAAP;AAYA,OAdK;;AAgBNW,MAAAA,UAAU,GAAG;AACZ,eAAOH,MAAM,CAACC,WAAP,CACN,CACC,iBADD,EAEC,kBAFD,EAGC,sBAHD,EAIC,8BAJD,EAKC,sCALD,EAMEC,GANF,CAMSL,UAAF,IAAkB,CACxBA,UADwB,EAExBD,iBAAiB,CAAEC,UAAF,CAFO,CANzB,CADM,CAAP;AAYA,OA7BK;;AA+BNO,MAAAA,SAAS,GAAG;AACX;AACA;AACA;AACA;AACA,eAAO,MAAM,MAAM,CAAE,CAArB;AACA;;AArCK,KAAP;AAuCA;;AAtDoB,CAAtB;AAyDA,eAAejB,aAAf","sourcesContent":["const coreDataStore = {\n\tname: 'core/data',\n\tinstantiate( registry ) {\n\t\tconst getCoreDataSelector =\n\t\t\t( selectorName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t\t\t};\n\n\t\tconst getCoreDataAction =\n\t\t\t( actionName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t\t\t};\n\n\t\treturn {\n\t\t\tgetSelectors() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'getIsResolving',\n\t\t\t\t\t\t'hasStartedResolution',\n\t\t\t\t\t\t'hasFinishedResolution',\n\t\t\t\t\t\t'isResolving',\n\t\t\t\t\t\t'getCachedResolvers',\n\t\t\t\t\t].map( ( selectorName ) => [\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tgetCoreDataSelector( selectorName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tgetActions() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'startResolution',\n\t\t\t\t\t\t'finishResolution',\n\t\t\t\t\t\t'invalidateResolution',\n\t\t\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t\t\t].map( ( actionName ) => [\n\t\t\t\t\t\tactionName,\n\t\t\t\t\t\tgetCoreDataAction( actionName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tsubscribe() {\n\t\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\t\treturn () => () => {};\n\t\t\t},\n\t\t};\n\t},\n};\n\nexport default coreDataStore;\n"]}
1
+ {"version":3,"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"sources":["@wordpress/data/src/store/index.js"],"sourcesContent":["const coreDataStore = {\n\tname: 'core/data',\n\tinstantiate( registry ) {\n\t\tconst getCoreDataSelector =\n\t\t\t( selectorName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t\t\t};\n\n\t\tconst getCoreDataAction =\n\t\t\t( actionName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t\t\t};\n\n\t\treturn {\n\t\t\tgetSelectors() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'getIsResolving',\n\t\t\t\t\t\t'hasStartedResolution',\n\t\t\t\t\t\t'hasFinishedResolution',\n\t\t\t\t\t\t'isResolving',\n\t\t\t\t\t\t'getCachedResolvers',\n\t\t\t\t\t].map( ( selectorName ) => [\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tgetCoreDataSelector( selectorName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tgetActions() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'startResolution',\n\t\t\t\t\t\t'finishResolution',\n\t\t\t\t\t\t'invalidateResolution',\n\t\t\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t\t\t].map( ( actionName ) => [\n\t\t\t\t\t\tactionName,\n\t\t\t\t\t\tgetCoreDataAction( actionName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tsubscribe() {\n\t\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\t\treturn () => () => {};\n\t\t\t},\n\t\t};\n\t},\n};\n\nexport default coreDataStore;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAG;EACrBC,IAAI,EAAE,WAAW;EACjBC,WAAWA,CAAEC,QAAQ,EAAG;IACvB,MAAMC,mBAAmB,GACtBC,YAAY,IACd,CAAEC,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACK,MAAM,CAAEF,GAAI,CAAC,CAAED,YAAY,CAAE,CAAE,GAAGE,IAAK,CAAC;IACzD,CAAC;IAEF,MAAME,iBAAiB,GACpBC,UAAU,IACZ,CAAEJ,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACQ,QAAQ,CAAEL,GAAI,CAAC,CAAEI,UAAU,CAAE,CAAE,GAAGH,IAAK,CAAC;IACzD,CAAC;IAEF,OAAO;MACNK,YAAYA,CAAA,EAAG;QACd,OAAOC,MAAM,CAACC,WAAW,CACxB,CACC,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,CACpB,CAACC,GAAG,CAAIV,YAAY,IAAM,CAC1BA,YAAY,EACZD,mBAAmB,CAAEC,YAAa,CAAC,CAClC,CACH,CAAC;MACF,CAAC;MAEDW,UAAUA,CAAA,EAAG;QACZ,OAAOH,MAAM,CAACC,WAAW,CACxB,CACC,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,sCAAsC,CACtC,CAACC,GAAG,CAAIL,UAAU,IAAM,CACxBA,UAAU,EACVD,iBAAiB,CAAEC,UAAW,CAAC,CAC9B,CACH,CAAC;MACF,CAAC;MAEDO,SAASA,CAAA,EAAG;QACX;QACA;QACA;QACA;QACA,OAAO,MAAM,MAAM,CAAC,CAAC;MACtB;IACD,CAAC;EACF;AACD,CAAC;AAED,eAAejB,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/data/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { combineReducers as reduxCombineReducers } from 'redux';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig<\n\tState,\n\tActionCreators extends MapOf< ActionCreator >,\n\tSelectors\n> {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }\n\t: never;\n\n/**\n * Removes the first argument from a function.\n *\n * By default, it removes the `state` parameter from\n * registered selectors since that argument is supplied\n * by the editor when calling `select(…)`.\n *\n * For functions with no arguments, which some selectors\n * are free to define, returns the original function.\n *\n * It is possible to manually provide a custom curried signature\n * and avoid the automatic inference. When the\n * F generic argument passed to this helper extends the\n * SelectorWithCustomCurrySignature type, the F['CurriedSignature']\n * property is used verbatim.\n *\n * This is useful because TypeScript does not correctly remove\n * arguments from complex function signatures constrained by\n * interdependent generic parameters.\n * For more context, see https://github.com/WordPress/gutenberg/pull/41578\n */\ntype CurriedState< F > = F extends SelectorWithCustomCurrySignature\n\t? F[ 'CurriedSignature' ]\n\t: F extends ( state: any, ...args: infer P ) => infer R\n\t? ( ...args: P ) => R\n\t: F;\n\n/**\n * Utility to manually specify curried selector signatures.\n *\n * It comes handy when TypeScript can't automatically produce the\n * correct curried function signature. For example:\n *\n * ```ts\n * type BadlyInferredSignature = CurriedState<\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ) => K\n * >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false \"one value\") => string number\n * ```\n *\n * With SelectorWithCustomCurrySignature, we can provide a custom\n * signature and avoid relying on TypeScript inference:\n * ```ts\n * interface MySelectorSignature extends SelectorWithCustomCurrySignature {\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n *\n * CurriedSignature: <K extends string | number>(\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n * }\n * type CorrectlyInferredSignature = CurriedState<MySelectorSignature>\n * // <K extends string | number>(kind: K, key: K extends string ? 'one value' : false): K;\n *\n * For even more context, see https://github.com/WordPress/gutenberg/pull/41578\n * ```\n */\nexport interface SelectorWithCustomCurrySignature {\n\tCurriedSignature: Function;\n}\n\nexport interface DataRegistry {\n\tregister: ( store: StoreDescriptor< any > ) => void;\n}\n\nexport interface DataEmitter {\n\temit: () => void;\n\tsubscribe: ( listener: () => void ) => () => void;\n\tpause: () => void;\n\tresume: () => void;\n\tisPaused: boolean;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< Config extends AnyConfig > =\n\tConfig extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t\t? PromisifiedActionCreators< ActionCreators >\n\t\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators<\n\tActionCreators extends MapOf< ActionCreator >\n> = {\n\t[ Action in keyof ActionCreators ]: PromisifyActionCreator<\n\t\tActionCreators[ Action ]\n\t>;\n};\n\n// Wraps action creator return types with a Promise and handles thunks.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],"mappings":""}