changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
18:be944660c56a | 19:3d72ae0968f4 |
---|---|
1 this["wp"] = this["wp"] || {}; this["wp"]["data"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ var __webpack_modules__ = ({ |
3 /******/ // The module cache |
3 |
4 /******/ var installedModules = {}; |
4 /***/ 2167: |
5 /******/ |
5 /***/ (function(module) { |
6 /******/ // The require function |
6 |
7 /******/ function __webpack_require__(moduleId) { |
7 "use strict"; |
8 /******/ |
8 |
9 /******/ // Check if module is in cache |
9 |
10 /******/ if(installedModules[moduleId]) { |
10 function _typeof(obj) { |
11 /******/ return installedModules[moduleId].exports; |
11 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
12 /******/ } |
12 _typeof = function (obj) { |
13 /******/ // Create a new module (and put it into the cache) |
13 return typeof obj; |
14 /******/ var module = installedModules[moduleId] = { |
14 }; |
15 /******/ i: moduleId, |
15 } else { |
16 /******/ l: false, |
16 _typeof = function (obj) { |
17 /******/ exports: {} |
17 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
18 /******/ }; |
18 }; |
19 /******/ |
19 } |
20 /******/ // Execute the module function |
20 |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
21 return _typeof(obj); |
22 /******/ |
22 } |
23 /******/ // Flag the module as loaded |
23 |
24 /******/ module.l = true; |
24 function _classCallCheck(instance, Constructor) { |
25 /******/ |
25 if (!(instance instanceof Constructor)) { |
26 /******/ // Return the exports of the module |
26 throw new TypeError("Cannot call a class as a function"); |
27 /******/ return module.exports; |
27 } |
28 /******/ } |
28 } |
29 /******/ |
29 |
30 /******/ |
30 function _defineProperties(target, props) { |
31 /******/ // expose the modules object (__webpack_modules__) |
31 for (var i = 0; i < props.length; i++) { |
32 /******/ __webpack_require__.m = modules; |
32 var descriptor = props[i]; |
33 /******/ |
33 descriptor.enumerable = descriptor.enumerable || false; |
34 /******/ // expose the module cache |
34 descriptor.configurable = true; |
35 /******/ __webpack_require__.c = installedModules; |
35 if ("value" in descriptor) descriptor.writable = true; |
36 /******/ |
36 Object.defineProperty(target, descriptor.key, descriptor); |
37 /******/ // define getter function for harmony exports |
37 } |
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
38 } |
39 /******/ if(!__webpack_require__.o(exports, name)) { |
39 |
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
40 function _createClass(Constructor, protoProps, staticProps) { |
41 /******/ } |
41 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
42 /******/ }; |
42 if (staticProps) _defineProperties(Constructor, staticProps); |
43 /******/ |
43 return Constructor; |
44 /******/ // define __esModule on exports |
44 } |
45 /******/ __webpack_require__.r = function(exports) { |
45 |
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
46 /** |
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
47 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple |
48 /******/ } |
48 * for a key, if one exists. The tuple members consist of the last reference |
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
49 * value for the key (used in efficient subsequent lookups) and the value |
50 /******/ }; |
50 * assigned for the key at the leaf node. |
51 /******/ |
51 * |
52 /******/ // create a fake namespace object |
52 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. |
53 /******/ // mode & 1: value is a module id, require it |
53 * @param {*} key The key for which to return value pair. |
54 /******/ // mode & 2: merge all properties of value into the ns |
54 * |
55 /******/ // mode & 4: return value when already ns object |
55 * @return {?Array} Value pair, if exists. |
56 /******/ // mode & 8|1: behave like require |
56 */ |
57 /******/ __webpack_require__.t = function(value, mode) { |
57 function getValuePair(instance, key) { |
58 /******/ if(mode & 1) value = __webpack_require__(value); |
58 var _map = instance._map, |
59 /******/ if(mode & 8) return value; |
59 _arrayTreeMap = instance._arrayTreeMap, |
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
60 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the |
61 /******/ var ns = Object.create(null); |
61 // value, which can be used to shortcut immediately to the value. |
62 /******/ __webpack_require__.r(ns); |
62 |
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
63 if (_map.has(key)) { |
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
64 return _map.get(key); |
65 /******/ return ns; |
65 } // Sort keys to ensure stable retrieval from tree. |
66 /******/ }; |
66 |
67 /******/ |
67 |
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
68 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. |
69 /******/ __webpack_require__.n = function(module) { |
69 |
70 /******/ var getter = module && module.__esModule ? |
70 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; |
71 /******/ function getDefault() { return module['default']; } : |
71 |
72 /******/ function getModuleExports() { return module; }; |
72 for (var i = 0; i < properties.length; i++) { |
73 /******/ __webpack_require__.d(getter, 'a', getter); |
73 var property = properties[i]; |
74 /******/ return getter; |
74 map = map.get(property); |
75 /******/ }; |
75 |
76 /******/ |
76 if (map === undefined) { |
77 /******/ // Object.prototype.hasOwnProperty.call |
77 return; |
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
78 } |
79 /******/ |
79 |
80 /******/ // __webpack_public_path__ |
80 var propertyValue = key[property]; |
81 /******/ __webpack_require__.p = ""; |
81 map = map.get(propertyValue); |
82 /******/ |
82 |
83 /******/ |
83 if (map === undefined) { |
84 /******/ // Load entry module and return exports |
84 return; |
85 /******/ return __webpack_require__(__webpack_require__.s = "pfJ3"); |
85 } |
86 /******/ }) |
86 } |
87 /************************************************************************/ |
87 |
88 /******/ ({ |
88 var valuePair = map.get('_ekm_value'); |
89 |
89 |
90 /***/ "8mpt": |
90 if (!valuePair) { |
91 /***/ (function(module, exports) { |
91 return; |
92 } // If reached, it implies that an object-like key was set with another |
|
93 // reference, so delete the reference and replace with the current. |
|
94 |
|
95 |
|
96 _map.delete(valuePair[0]); |
|
97 |
|
98 valuePair[0] = key; |
|
99 map.set('_ekm_value', valuePair); |
|
100 |
|
101 _map.set(key, valuePair); |
|
102 |
|
103 return valuePair; |
|
104 } |
|
105 /** |
|
106 * Variant of a Map object which enables lookup by equivalent (deeply equal) |
|
107 * object and array keys. |
|
108 */ |
|
109 |
|
110 |
|
111 var EquivalentKeyMap = |
|
112 /*#__PURE__*/ |
|
113 function () { |
|
114 /** |
|
115 * Constructs a new instance of EquivalentKeyMap. |
|
116 * |
|
117 * @param {Iterable.<*>} iterable Initial pair of key, value for map. |
|
118 */ |
|
119 function EquivalentKeyMap(iterable) { |
|
120 _classCallCheck(this, EquivalentKeyMap); |
|
121 |
|
122 this.clear(); |
|
123 |
|
124 if (iterable instanceof EquivalentKeyMap) { |
|
125 // Map#forEach is only means of iterating with support for IE11. |
|
126 var iterablePairs = []; |
|
127 iterable.forEach(function (value, key) { |
|
128 iterablePairs.push([key, value]); |
|
129 }); |
|
130 iterable = iterablePairs; |
|
131 } |
|
132 |
|
133 if (iterable != null) { |
|
134 for (var i = 0; i < iterable.length; i++) { |
|
135 this.set(iterable[i][0], iterable[i][1]); |
|
136 } |
|
137 } |
|
138 } |
|
139 /** |
|
140 * Accessor property returning the number of elements. |
|
141 * |
|
142 * @return {number} Number of elements. |
|
143 */ |
|
144 |
|
145 |
|
146 _createClass(EquivalentKeyMap, [{ |
|
147 key: "set", |
|
148 |
|
149 /** |
|
150 * Add or update an element with a specified key and value. |
|
151 * |
|
152 * @param {*} key The key of the element to add. |
|
153 * @param {*} value The value of the element to add. |
|
154 * |
|
155 * @return {EquivalentKeyMap} Map instance. |
|
156 */ |
|
157 value: function set(key, value) { |
|
158 // Shortcut non-object-like to set on internal Map. |
|
159 if (key === null || _typeof(key) !== 'object') { |
|
160 this._map.set(key, value); |
|
161 |
|
162 return this; |
|
163 } // Sort keys to ensure stable assignment into tree. |
|
164 |
|
165 |
|
166 var properties = Object.keys(key).sort(); |
|
167 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
168 |
|
169 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; |
|
170 |
|
171 for (var i = 0; i < properties.length; i++) { |
|
172 var property = properties[i]; |
|
173 |
|
174 if (!map.has(property)) { |
|
175 map.set(property, new EquivalentKeyMap()); |
|
176 } |
|
177 |
|
178 map = map.get(property); |
|
179 var propertyValue = key[property]; |
|
180 |
|
181 if (!map.has(propertyValue)) { |
|
182 map.set(propertyValue, new EquivalentKeyMap()); |
|
183 } |
|
184 |
|
185 map = map.get(propertyValue); |
|
186 } // If an _ekm_value exists, there was already an equivalent key. Before |
|
187 // overriding, ensure that the old key reference is removed from map to |
|
188 // avoid memory leak of accumulating equivalent keys. This is, in a |
|
189 // sense, a poor man's WeakMap, while still enabling iterability. |
|
190 |
|
191 |
|
192 var previousValuePair = map.get('_ekm_value'); |
|
193 |
|
194 if (previousValuePair) { |
|
195 this._map.delete(previousValuePair[0]); |
|
196 } |
|
197 |
|
198 map.set('_ekm_value', valuePair); |
|
199 |
|
200 this._map.set(key, valuePair); |
|
201 |
|
202 return this; |
|
203 } |
|
204 /** |
|
205 * Returns a specified element. |
|
206 * |
|
207 * @param {*} key The key of the element to return. |
|
208 * |
|
209 * @return {?*} The element associated with the specified key or undefined |
|
210 * if the key can't be found. |
|
211 */ |
|
212 |
|
213 }, { |
|
214 key: "get", |
|
215 value: function get(key) { |
|
216 // Shortcut non-object-like to get from internal Map. |
|
217 if (key === null || _typeof(key) !== 'object') { |
|
218 return this._map.get(key); |
|
219 } |
|
220 |
|
221 var valuePair = getValuePair(this, key); |
|
222 |
|
223 if (valuePair) { |
|
224 return valuePair[1]; |
|
225 } |
|
226 } |
|
227 /** |
|
228 * Returns a boolean indicating whether an element with the specified key |
|
229 * exists or not. |
|
230 * |
|
231 * @param {*} key The key of the element to test for presence. |
|
232 * |
|
233 * @return {boolean} Whether an element with the specified key exists. |
|
234 */ |
|
235 |
|
236 }, { |
|
237 key: "has", |
|
238 value: function has(key) { |
|
239 if (key === null || _typeof(key) !== 'object') { |
|
240 return this._map.has(key); |
|
241 } // Test on the _presence_ of the pair, not its value, as even undefined |
|
242 // can be a valid member value for a key. |
|
243 |
|
244 |
|
245 return getValuePair(this, key) !== undefined; |
|
246 } |
|
247 /** |
|
248 * Removes the specified element. |
|
249 * |
|
250 * @param {*} key The key of the element to remove. |
|
251 * |
|
252 * @return {boolean} Returns true if an element existed and has been |
|
253 * removed, or false if the element does not exist. |
|
254 */ |
|
255 |
|
256 }, { |
|
257 key: "delete", |
|
258 value: function _delete(key) { |
|
259 if (!this.has(key)) { |
|
260 return false; |
|
261 } // This naive implementation will leave orphaned child trees. A better |
|
262 // implementation should traverse and remove orphans. |
|
263 |
|
264 |
|
265 this.set(key, undefined); |
|
266 return true; |
|
267 } |
|
268 /** |
|
269 * Executes a provided function once per each key/value pair, in insertion |
|
270 * order. |
|
271 * |
|
272 * @param {Function} callback Function to execute for each element. |
|
273 * @param {*} thisArg Value to use as `this` when executing |
|
274 * `callback`. |
|
275 */ |
|
276 |
|
277 }, { |
|
278 key: "forEach", |
|
279 value: function forEach(callback) { |
|
280 var _this = this; |
|
281 |
|
282 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; |
|
283 |
|
284 this._map.forEach(function (value, key) { |
|
285 // Unwrap value from object-like value pair. |
|
286 if (key !== null && _typeof(key) === 'object') { |
|
287 value = value[1]; |
|
288 } |
|
289 |
|
290 callback.call(thisArg, value, key, _this); |
|
291 }); |
|
292 } |
|
293 /** |
|
294 * Removes all elements. |
|
295 */ |
|
296 |
|
297 }, { |
|
298 key: "clear", |
|
299 value: function clear() { |
|
300 this._map = new Map(); |
|
301 this._arrayTreeMap = new Map(); |
|
302 this._objectTreeMap = new Map(); |
|
303 } |
|
304 }, { |
|
305 key: "size", |
|
306 get: function get() { |
|
307 return this._map.size; |
|
308 } |
|
309 }]); |
|
310 |
|
311 return EquivalentKeyMap; |
|
312 }(); |
|
313 |
|
314 module.exports = EquivalentKeyMap; |
|
315 |
|
316 |
|
317 /***/ }), |
|
318 |
|
319 /***/ 9125: |
|
320 /***/ (function(module) { |
|
92 |
321 |
93 function combineReducers( reducers ) { |
322 function combineReducers( reducers ) { |
94 var keys = Object.keys( reducers ), |
323 var keys = Object.keys( reducers ), |
95 getNextState; |
324 getNextState; |
96 |
325 |
142 } |
371 } |
143 |
372 |
144 module.exports = combineReducers; |
373 module.exports = combineReducers; |
145 |
374 |
146 |
375 |
147 /***/ }), |
376 /***/ }) |
148 |
377 |
149 /***/ "FtRg": |
378 /******/ }); |
150 /***/ (function(module, exports, __webpack_require__) { |
379 /************************************************************************/ |
151 |
380 /******/ // The module cache |
152 "use strict"; |
381 /******/ var __webpack_module_cache__ = {}; |
153 |
382 /******/ |
154 |
383 /******/ // The require function |
155 function _typeof(obj) { |
384 /******/ function __webpack_require__(moduleId) { |
156 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
385 /******/ // Check if module is in cache |
157 _typeof = function (obj) { |
386 /******/ var cachedModule = __webpack_module_cache__[moduleId]; |
158 return typeof obj; |
387 /******/ if (cachedModule !== undefined) { |
159 }; |
388 /******/ return cachedModule.exports; |
160 } else { |
389 /******/ } |
161 _typeof = function (obj) { |
390 /******/ // Create a new module (and put it into the cache) |
162 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
391 /******/ var module = __webpack_module_cache__[moduleId] = { |
163 }; |
392 /******/ // no module.id needed |
164 } |
393 /******/ // no module.loaded needed |
165 |
394 /******/ exports: {} |
166 return _typeof(obj); |
395 /******/ }; |
167 } |
396 /******/ |
168 |
397 /******/ // Execute the module function |
169 function _classCallCheck(instance, Constructor) { |
398 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
170 if (!(instance instanceof Constructor)) { |
399 /******/ |
171 throw new TypeError("Cannot call a class as a function"); |
400 /******/ // Return the exports of the module |
172 } |
401 /******/ return module.exports; |
173 } |
402 /******/ } |
174 |
403 /******/ |
175 function _defineProperties(target, props) { |
404 /************************************************************************/ |
176 for (var i = 0; i < props.length; i++) { |
405 /******/ /* webpack/runtime/compat get default export */ |
177 var descriptor = props[i]; |
406 /******/ !function() { |
178 descriptor.enumerable = descriptor.enumerable || false; |
407 /******/ // getDefaultExport function for compatibility with non-harmony modules |
179 descriptor.configurable = true; |
408 /******/ __webpack_require__.n = function(module) { |
180 if ("value" in descriptor) descriptor.writable = true; |
409 /******/ var getter = module && module.__esModule ? |
181 Object.defineProperty(target, descriptor.key, descriptor); |
410 /******/ function() { return module['default']; } : |
182 } |
411 /******/ function() { return module; }; |
183 } |
412 /******/ __webpack_require__.d(getter, { a: getter }); |
184 |
413 /******/ return getter; |
185 function _createClass(Constructor, protoProps, staticProps) { |
414 /******/ }; |
186 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
415 /******/ }(); |
187 if (staticProps) _defineProperties(Constructor, staticProps); |
416 /******/ |
188 return Constructor; |
417 /******/ /* webpack/runtime/define property getters */ |
189 } |
418 /******/ !function() { |
190 |
419 /******/ // define getter functions for harmony exports |
191 /** |
420 /******/ __webpack_require__.d = function(exports, definition) { |
192 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple |
421 /******/ for(var key in definition) { |
193 * for a key, if one exists. The tuple members consist of the last reference |
422 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
194 * value for the key (used in efficient subsequent lookups) and the value |
423 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
195 * assigned for the key at the leaf node. |
424 /******/ } |
196 * |
425 /******/ } |
197 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. |
426 /******/ }; |
198 * @param {*} key The key for which to return value pair. |
427 /******/ }(); |
199 * |
428 /******/ |
200 * @return {?Array} Value pair, if exists. |
429 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
201 */ |
430 /******/ !function() { |
202 function getValuePair(instance, key) { |
431 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
203 var _map = instance._map, |
432 /******/ }(); |
204 _arrayTreeMap = instance._arrayTreeMap, |
433 /******/ |
205 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the |
434 /******/ /* webpack/runtime/make namespace object */ |
206 // value, which can be used to shortcut immediately to the value. |
435 /******/ !function() { |
207 |
436 /******/ // define __esModule on exports |
208 if (_map.has(key)) { |
437 /******/ __webpack_require__.r = function(exports) { |
209 return _map.get(key); |
438 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
210 } // Sort keys to ensure stable retrieval from tree. |
439 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
211 |
440 /******/ } |
212 |
441 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
213 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. |
442 /******/ }; |
214 |
443 /******/ }(); |
215 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; |
444 /******/ |
216 |
445 /************************************************************************/ |
217 for (var i = 0; i < properties.length; i++) { |
446 var __webpack_exports__ = {}; |
218 var property = properties[i]; |
447 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
219 map = map.get(property); |
448 !function() { |
220 |
|
221 if (map === undefined) { |
|
222 return; |
|
223 } |
|
224 |
|
225 var propertyValue = key[property]; |
|
226 map = map.get(propertyValue); |
|
227 |
|
228 if (map === undefined) { |
|
229 return; |
|
230 } |
|
231 } |
|
232 |
|
233 var valuePair = map.get('_ekm_value'); |
|
234 |
|
235 if (!valuePair) { |
|
236 return; |
|
237 } // If reached, it implies that an object-like key was set with another |
|
238 // reference, so delete the reference and replace with the current. |
|
239 |
|
240 |
|
241 _map.delete(valuePair[0]); |
|
242 |
|
243 valuePair[0] = key; |
|
244 map.set('_ekm_value', valuePair); |
|
245 |
|
246 _map.set(key, valuePair); |
|
247 |
|
248 return valuePair; |
|
249 } |
|
250 /** |
|
251 * Variant of a Map object which enables lookup by equivalent (deeply equal) |
|
252 * object and array keys. |
|
253 */ |
|
254 |
|
255 |
|
256 var EquivalentKeyMap = |
|
257 /*#__PURE__*/ |
|
258 function () { |
|
259 /** |
|
260 * Constructs a new instance of EquivalentKeyMap. |
|
261 * |
|
262 * @param {Iterable.<*>} iterable Initial pair of key, value for map. |
|
263 */ |
|
264 function EquivalentKeyMap(iterable) { |
|
265 _classCallCheck(this, EquivalentKeyMap); |
|
266 |
|
267 this.clear(); |
|
268 |
|
269 if (iterable instanceof EquivalentKeyMap) { |
|
270 // Map#forEach is only means of iterating with support for IE11. |
|
271 var iterablePairs = []; |
|
272 iterable.forEach(function (value, key) { |
|
273 iterablePairs.push([key, value]); |
|
274 }); |
|
275 iterable = iterablePairs; |
|
276 } |
|
277 |
|
278 if (iterable != null) { |
|
279 for (var i = 0; i < iterable.length; i++) { |
|
280 this.set(iterable[i][0], iterable[i][1]); |
|
281 } |
|
282 } |
|
283 } |
|
284 /** |
|
285 * Accessor property returning the number of elements. |
|
286 * |
|
287 * @return {number} Number of elements. |
|
288 */ |
|
289 |
|
290 |
|
291 _createClass(EquivalentKeyMap, [{ |
|
292 key: "set", |
|
293 |
|
294 /** |
|
295 * Add or update an element with a specified key and value. |
|
296 * |
|
297 * @param {*} key The key of the element to add. |
|
298 * @param {*} value The value of the element to add. |
|
299 * |
|
300 * @return {EquivalentKeyMap} Map instance. |
|
301 */ |
|
302 value: function set(key, value) { |
|
303 // Shortcut non-object-like to set on internal Map. |
|
304 if (key === null || _typeof(key) !== 'object') { |
|
305 this._map.set(key, value); |
|
306 |
|
307 return this; |
|
308 } // Sort keys to ensure stable assignment into tree. |
|
309 |
|
310 |
|
311 var properties = Object.keys(key).sort(); |
|
312 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
313 |
|
314 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; |
|
315 |
|
316 for (var i = 0; i < properties.length; i++) { |
|
317 var property = properties[i]; |
|
318 |
|
319 if (!map.has(property)) { |
|
320 map.set(property, new EquivalentKeyMap()); |
|
321 } |
|
322 |
|
323 map = map.get(property); |
|
324 var propertyValue = key[property]; |
|
325 |
|
326 if (!map.has(propertyValue)) { |
|
327 map.set(propertyValue, new EquivalentKeyMap()); |
|
328 } |
|
329 |
|
330 map = map.get(propertyValue); |
|
331 } // If an _ekm_value exists, there was already an equivalent key. Before |
|
332 // overriding, ensure that the old key reference is removed from map to |
|
333 // avoid memory leak of accumulating equivalent keys. This is, in a |
|
334 // sense, a poor man's WeakMap, while still enabling iterability. |
|
335 |
|
336 |
|
337 var previousValuePair = map.get('_ekm_value'); |
|
338 |
|
339 if (previousValuePair) { |
|
340 this._map.delete(previousValuePair[0]); |
|
341 } |
|
342 |
|
343 map.set('_ekm_value', valuePair); |
|
344 |
|
345 this._map.set(key, valuePair); |
|
346 |
|
347 return this; |
|
348 } |
|
349 /** |
|
350 * Returns a specified element. |
|
351 * |
|
352 * @param {*} key The key of the element to return. |
|
353 * |
|
354 * @return {?*} The element associated with the specified key or undefined |
|
355 * if the key can't be found. |
|
356 */ |
|
357 |
|
358 }, { |
|
359 key: "get", |
|
360 value: function get(key) { |
|
361 // Shortcut non-object-like to get from internal Map. |
|
362 if (key === null || _typeof(key) !== 'object') { |
|
363 return this._map.get(key); |
|
364 } |
|
365 |
|
366 var valuePair = getValuePair(this, key); |
|
367 |
|
368 if (valuePair) { |
|
369 return valuePair[1]; |
|
370 } |
|
371 } |
|
372 /** |
|
373 * Returns a boolean indicating whether an element with the specified key |
|
374 * exists or not. |
|
375 * |
|
376 * @param {*} key The key of the element to test for presence. |
|
377 * |
|
378 * @return {boolean} Whether an element with the specified key exists. |
|
379 */ |
|
380 |
|
381 }, { |
|
382 key: "has", |
|
383 value: function has(key) { |
|
384 if (key === null || _typeof(key) !== 'object') { |
|
385 return this._map.has(key); |
|
386 } // Test on the _presence_ of the pair, not its value, as even undefined |
|
387 // can be a valid member value for a key. |
|
388 |
|
389 |
|
390 return getValuePair(this, key) !== undefined; |
|
391 } |
|
392 /** |
|
393 * Removes the specified element. |
|
394 * |
|
395 * @param {*} key The key of the element to remove. |
|
396 * |
|
397 * @return {boolean} Returns true if an element existed and has been |
|
398 * removed, or false if the element does not exist. |
|
399 */ |
|
400 |
|
401 }, { |
|
402 key: "delete", |
|
403 value: function _delete(key) { |
|
404 if (!this.has(key)) { |
|
405 return false; |
|
406 } // This naive implementation will leave orphaned child trees. A better |
|
407 // implementation should traverse and remove orphans. |
|
408 |
|
409 |
|
410 this.set(key, undefined); |
|
411 return true; |
|
412 } |
|
413 /** |
|
414 * Executes a provided function once per each key/value pair, in insertion |
|
415 * order. |
|
416 * |
|
417 * @param {Function} callback Function to execute for each element. |
|
418 * @param {*} thisArg Value to use as `this` when executing |
|
419 * `callback`. |
|
420 */ |
|
421 |
|
422 }, { |
|
423 key: "forEach", |
|
424 value: function forEach(callback) { |
|
425 var _this = this; |
|
426 |
|
427 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; |
|
428 |
|
429 this._map.forEach(function (value, key) { |
|
430 // Unwrap value from object-like value pair. |
|
431 if (key !== null && _typeof(key) === 'object') { |
|
432 value = value[1]; |
|
433 } |
|
434 |
|
435 callback.call(thisArg, value, key, _this); |
|
436 }); |
|
437 } |
|
438 /** |
|
439 * Removes all elements. |
|
440 */ |
|
441 |
|
442 }, { |
|
443 key: "clear", |
|
444 value: function clear() { |
|
445 this._map = new Map(); |
|
446 this._arrayTreeMap = new Map(); |
|
447 this._objectTreeMap = new Map(); |
|
448 } |
|
449 }, { |
|
450 key: "size", |
|
451 get: function get() { |
|
452 return this._map.size; |
|
453 } |
|
454 }]); |
|
455 |
|
456 return EquivalentKeyMap; |
|
457 }(); |
|
458 |
|
459 module.exports = EquivalentKeyMap; |
|
460 |
|
461 |
|
462 /***/ }), |
|
463 |
|
464 /***/ "GRId": |
|
465 /***/ (function(module, exports) { |
|
466 |
|
467 (function() { module.exports = window["wp"]["element"]; }()); |
|
468 |
|
469 /***/ }), |
|
470 |
|
471 /***/ "JlUD": |
|
472 /***/ (function(module, exports) { |
|
473 |
|
474 module.exports = isPromise; |
|
475 module.exports.default = isPromise; |
|
476 |
|
477 function isPromise(obj) { |
|
478 return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; |
|
479 } |
|
480 |
|
481 |
|
482 /***/ }), |
|
483 |
|
484 /***/ "K9lf": |
|
485 /***/ (function(module, exports) { |
|
486 |
|
487 (function() { module.exports = window["wp"]["compose"]; }()); |
|
488 |
|
489 /***/ }), |
|
490 |
|
491 /***/ "NMb1": |
|
492 /***/ (function(module, exports) { |
|
493 |
|
494 (function() { module.exports = window["wp"]["deprecated"]; }()); |
|
495 |
|
496 /***/ }), |
|
497 |
|
498 /***/ "XI5e": |
|
499 /***/ (function(module, exports) { |
|
500 |
|
501 (function() { module.exports = window["wp"]["priorityQueue"]; }()); |
|
502 |
|
503 /***/ }), |
|
504 |
|
505 /***/ "XIDh": |
|
506 /***/ (function(module, exports) { |
|
507 |
|
508 (function() { module.exports = window["wp"]["reduxRoutine"]; }()); |
|
509 |
|
510 /***/ }), |
|
511 |
|
512 /***/ "YLtl": |
|
513 /***/ (function(module, exports) { |
|
514 |
|
515 (function() { module.exports = window["lodash"]; }()); |
|
516 |
|
517 /***/ }), |
|
518 |
|
519 /***/ "cDcd": |
|
520 /***/ (function(module, exports) { |
|
521 |
|
522 (function() { module.exports = window["React"]; }()); |
|
523 |
|
524 /***/ }), |
|
525 |
|
526 /***/ "mHlH": |
|
527 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
528 |
|
529 "use strict"; |
|
530 /* unused harmony export useCallback */ |
|
531 /* unused harmony export useCallbackOne */ |
|
532 /* unused harmony export useMemo */ |
|
533 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMemoOne; }); |
|
534 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("cDcd"); |
|
535 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); |
|
536 |
|
537 |
|
538 function areInputsEqual(newInputs, lastInputs) { |
|
539 if (newInputs.length !== lastInputs.length) { |
|
540 return false; |
|
541 } |
|
542 |
|
543 for (var i = 0; i < newInputs.length; i++) { |
|
544 if (newInputs[i] !== lastInputs[i]) { |
|
545 return false; |
|
546 } |
|
547 } |
|
548 |
|
549 return true; |
|
550 } |
|
551 |
|
552 function useMemoOne(getResult, inputs) { |
|
553 var initial = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(function () { |
|
554 return { |
|
555 inputs: inputs, |
|
556 result: getResult() |
|
557 }; |
|
558 })[0]; |
|
559 var isFirstRun = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(true); |
|
560 var committed = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(initial); |
|
561 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); |
|
562 var cache = useCache ? committed.current : { |
|
563 inputs: inputs, |
|
564 result: getResult() |
|
565 }; |
|
566 Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { |
|
567 isFirstRun.current = false; |
|
568 committed.current = cache; |
|
569 }, [cache]); |
|
570 return cache.result; |
|
571 } |
|
572 function useCallbackOne(callback, inputs) { |
|
573 return useMemoOne(function () { |
|
574 return callback; |
|
575 }, inputs); |
|
576 } |
|
577 var useMemo = useMemoOne; |
|
578 var useCallback = useCallbackOne; |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 /***/ }), |
|
584 |
|
585 /***/ "pfJ3": |
|
586 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
587 |
|
588 "use strict"; |
449 "use strict"; |
589 // ESM COMPAT FLAG |
450 // ESM COMPAT FLAG |
590 __webpack_require__.r(__webpack_exports__); |
451 __webpack_require__.r(__webpack_exports__); |
591 |
452 |
592 // EXPORTS |
453 // EXPORTS |
593 __webpack_require__.d(__webpack_exports__, "withSelect", function() { return /* reexport */ with_select; }); |
454 __webpack_require__.d(__webpack_exports__, { |
594 __webpack_require__.d(__webpack_exports__, "withDispatch", function() { return /* reexport */ with_dispatch; }); |
455 "AsyncModeProvider": function() { return /* reexport */ async_mode_provider_context; }, |
595 __webpack_require__.d(__webpack_exports__, "withRegistry", function() { return /* reexport */ with_registry; }); |
456 "RegistryConsumer": function() { return /* reexport */ RegistryConsumer; }, |
596 __webpack_require__.d(__webpack_exports__, "RegistryProvider", function() { return /* reexport */ context; }); |
457 "RegistryProvider": function() { return /* reexport */ context; }, |
597 __webpack_require__.d(__webpack_exports__, "RegistryConsumer", function() { return /* reexport */ RegistryConsumer; }); |
458 "combineReducers": function() { return /* reexport */ (turbo_combine_reducers_default()); }, |
598 __webpack_require__.d(__webpack_exports__, "useRegistry", function() { return /* reexport */ useRegistry; }); |
459 "controls": function() { return /* reexport */ controls; }, |
599 __webpack_require__.d(__webpack_exports__, "useSelect", function() { return /* reexport */ useSelect; }); |
460 "createReduxStore": function() { return /* reexport */ createReduxStore; }, |
600 __webpack_require__.d(__webpack_exports__, "useDispatch", function() { return /* reexport */ use_dispatch; }); |
461 "createRegistry": function() { return /* reexport */ createRegistry; }, |
601 __webpack_require__.d(__webpack_exports__, "AsyncModeProvider", function() { return /* reexport */ async_mode_provider_context; }); |
462 "createRegistryControl": function() { return /* reexport */ createRegistryControl; }, |
602 __webpack_require__.d(__webpack_exports__, "createRegistry", function() { return /* reexport */ createRegistry; }); |
463 "createRegistrySelector": function() { return /* reexport */ createRegistrySelector; }, |
603 __webpack_require__.d(__webpack_exports__, "createRegistrySelector", function() { return /* reexport */ createRegistrySelector; }); |
464 "dispatch": function() { return /* binding */ build_module_dispatch; }, |
604 __webpack_require__.d(__webpack_exports__, "createRegistryControl", function() { return /* reexport */ createRegistryControl; }); |
465 "plugins": function() { return /* reexport */ plugins_namespaceObject; }, |
605 __webpack_require__.d(__webpack_exports__, "controls", function() { return /* reexport */ controls_controls; }); |
466 "register": function() { return /* binding */ register; }, |
606 __webpack_require__.d(__webpack_exports__, "createReduxStore", function() { return /* reexport */ createReduxStore; }); |
467 "registerGenericStore": function() { return /* binding */ registerGenericStore; }, |
607 __webpack_require__.d(__webpack_exports__, "plugins", function() { return /* reexport */ plugins_namespaceObject; }); |
468 "registerStore": function() { return /* binding */ registerStore; }, |
608 __webpack_require__.d(__webpack_exports__, "combineReducers", function() { return /* reexport */ turbo_combine_reducers_default.a; }); |
469 "resolveSelect": function() { return /* binding */ build_module_resolveSelect; }, |
609 __webpack_require__.d(__webpack_exports__, "select", function() { return /* binding */ build_module_select; }); |
470 "select": function() { return /* binding */ build_module_select; }, |
610 __webpack_require__.d(__webpack_exports__, "resolveSelect", function() { return /* binding */ build_module_resolveSelect; }); |
471 "subscribe": function() { return /* binding */ subscribe; }, |
611 __webpack_require__.d(__webpack_exports__, "dispatch", function() { return /* binding */ build_module_dispatch; }); |
472 "use": function() { return /* binding */ use; }, |
612 __webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* binding */ build_module_subscribe; }); |
473 "useDispatch": function() { return /* reexport */ use_dispatch; }, |
613 __webpack_require__.d(__webpack_exports__, "registerGenericStore", function() { return /* binding */ build_module_registerGenericStore; }); |
474 "useRegistry": function() { return /* reexport */ useRegistry; }, |
614 __webpack_require__.d(__webpack_exports__, "registerStore", function() { return /* binding */ registerStore; }); |
475 "useSelect": function() { return /* reexport */ useSelect; }, |
615 __webpack_require__.d(__webpack_exports__, "use", function() { return /* binding */ build_module_use; }); |
476 "withDispatch": function() { return /* reexport */ with_dispatch; }, |
616 __webpack_require__.d(__webpack_exports__, "register", function() { return /* binding */ build_module_register; }); |
477 "withRegistry": function() { return /* reexport */ with_registry; }, |
478 "withSelect": function() { return /* reexport */ with_select; } |
|
479 }); |
|
617 |
480 |
618 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
481 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
619 var selectors_namespaceObject = {}; |
482 var selectors_namespaceObject = {}; |
620 __webpack_require__.r(selectors_namespaceObject); |
483 __webpack_require__.r(selectors_namespaceObject); |
621 __webpack_require__.d(selectors_namespaceObject, "getIsResolving", function() { return getIsResolving; }); |
484 __webpack_require__.d(selectors_namespaceObject, { |
622 __webpack_require__.d(selectors_namespaceObject, "hasStartedResolution", function() { return hasStartedResolution; }); |
485 "getCachedResolvers": function() { return getCachedResolvers; }, |
623 __webpack_require__.d(selectors_namespaceObject, "hasFinishedResolution", function() { return hasFinishedResolution; }); |
486 "getIsResolving": function() { return getIsResolving; }, |
624 __webpack_require__.d(selectors_namespaceObject, "isResolving", function() { return isResolving; }); |
487 "getResolutionError": function() { return getResolutionError; }, |
625 __webpack_require__.d(selectors_namespaceObject, "getCachedResolvers", function() { return getCachedResolvers; }); |
488 "getResolutionState": function() { return getResolutionState; }, |
489 "hasFinishedResolution": function() { return hasFinishedResolution; }, |
|
490 "hasResolutionFailed": function() { return hasResolutionFailed; }, |
|
491 "hasStartedResolution": function() { return hasStartedResolution; }, |
|
492 "isResolving": function() { return isResolving; } |
|
493 }); |
|
626 |
494 |
627 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
495 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
628 var actions_namespaceObject = {}; |
496 var actions_namespaceObject = {}; |
629 __webpack_require__.r(actions_namespaceObject); |
497 __webpack_require__.r(actions_namespaceObject); |
630 __webpack_require__.d(actions_namespaceObject, "startResolution", function() { return startResolution; }); |
498 __webpack_require__.d(actions_namespaceObject, { |
631 __webpack_require__.d(actions_namespaceObject, "finishResolution", function() { return finishResolution; }); |
499 "failResolution": function() { return failResolution; }, |
632 __webpack_require__.d(actions_namespaceObject, "startResolutions", function() { return startResolutions; }); |
500 "failResolutions": function() { return failResolutions; }, |
633 __webpack_require__.d(actions_namespaceObject, "finishResolutions", function() { return finishResolutions; }); |
501 "finishResolution": function() { return finishResolution; }, |
634 __webpack_require__.d(actions_namespaceObject, "invalidateResolution", function() { return invalidateResolution; }); |
502 "finishResolutions": function() { return finishResolutions; }, |
635 __webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStore", function() { return invalidateResolutionForStore; }); |
503 "invalidateResolution": function() { return invalidateResolution; }, |
636 __webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStoreSelector", function() { return invalidateResolutionForStoreSelector; }); |
504 "invalidateResolutionForStore": function() { return invalidateResolutionForStore; }, |
505 "invalidateResolutionForStoreSelector": function() { return invalidateResolutionForStoreSelector; }, |
|
506 "startResolution": function() { return startResolution; }, |
|
507 "startResolutions": function() { return startResolutions; } |
|
508 }); |
|
637 |
509 |
638 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js |
510 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js |
639 var plugins_namespaceObject = {}; |
511 var plugins_namespaceObject = {}; |
640 __webpack_require__.r(plugins_namespaceObject); |
512 __webpack_require__.r(plugins_namespaceObject); |
641 __webpack_require__.d(plugins_namespaceObject, "controls", function() { return plugins_controls; }); |
513 __webpack_require__.d(plugins_namespaceObject, { |
642 __webpack_require__.d(plugins_namespaceObject, "persistence", function() { return plugins_persistence; }); |
514 "persistence": function() { return persistence; } |
515 }); |
|
643 |
516 |
644 // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js |
517 // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js |
645 var turbo_combine_reducers = __webpack_require__("8mpt"); |
518 var turbo_combine_reducers = __webpack_require__(9125); |
646 var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers); |
519 var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers); |
647 |
520 ;// CONCATENATED MODULE: external "lodash" |
648 // EXTERNAL MODULE: external "lodash" |
521 var external_lodash_namespaceObject = window["lodash"]; |
649 var external_lodash_ = __webpack_require__("YLtl"); |
522 ;// CONCATENATED MODULE: external ["wp","deprecated"] |
650 |
523 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
651 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
524 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
525 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
652 function _defineProperty(obj, key, value) { |
526 function _defineProperty(obj, key, value) { |
653 if (key in obj) { |
527 if (key in obj) { |
654 Object.defineProperty(obj, key, { |
528 Object.defineProperty(obj, key, { |
655 value: value, |
529 value: value, |
656 enumerable: true, |
530 enumerable: true, |
661 obj[key] = value; |
535 obj[key] = value; |
662 } |
536 } |
663 |
537 |
664 return obj; |
538 return obj; |
665 } |
539 } |
666 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js |
540 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js |
667 |
541 |
668 |
542 |
669 function ownKeys(object, enumerableOnly) { |
543 function ownKeys(object, enumerableOnly) { |
670 var keys = Object.keys(object); |
544 var keys = Object.keys(object); |
671 |
545 |
672 if (Object.getOwnPropertySymbols) { |
546 if (Object.getOwnPropertySymbols) { |
673 var symbols = Object.getOwnPropertySymbols(object); |
547 var symbols = Object.getOwnPropertySymbols(object); |
674 |
548 enumerableOnly && (symbols = symbols.filter(function (sym) { |
675 if (enumerableOnly) { |
549 return Object.getOwnPropertyDescriptor(object, sym).enumerable; |
676 symbols = symbols.filter(function (sym) { |
550 })), keys.push.apply(keys, symbols); |
677 return Object.getOwnPropertyDescriptor(object, sym).enumerable; |
|
678 }); |
|
679 } |
|
680 |
|
681 keys.push.apply(keys, symbols); |
|
682 } |
551 } |
683 |
552 |
684 return keys; |
553 return keys; |
685 } |
554 } |
686 |
555 |
687 function _objectSpread2(target) { |
556 function _objectSpread2(target) { |
688 for (var i = 1; i < arguments.length; i++) { |
557 for (var i = 1; i < arguments.length; i++) { |
689 var source = arguments[i] != null ? arguments[i] : {}; |
558 var source = null != arguments[i] ? arguments[i] : {}; |
690 |
559 i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { |
691 if (i % 2) { |
560 _defineProperty(target, key, source[key]); |
692 ownKeys(Object(source), true).forEach(function (key) { |
561 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { |
693 _defineProperty(target, key, source[key]); |
562 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); |
694 }); |
563 }); |
695 } else if (Object.getOwnPropertyDescriptors) { |
|
696 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); |
|
697 } else { |
|
698 ownKeys(Object(source)).forEach(function (key) { |
|
699 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); |
|
700 }); |
|
701 } |
|
702 } |
564 } |
703 |
565 |
704 return target; |
566 return target; |
705 } |
567 } |
706 // CONCATENATED MODULE: ./node_modules/redux/es/redux.js |
568 ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js |
707 |
569 |
708 |
570 |
709 /** |
571 /** |
710 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js |
572 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js |
711 * |
573 * |
811 |
673 |
812 return typeOfVal; |
674 return typeOfVal; |
813 } |
675 } |
814 |
676 |
815 /** |
677 /** |
816 * Creates a Redux store that holds the state tree. |
678 * @deprecated |
817 * The only way to change the data in the store is to call `dispatch()` on it. |
679 * |
818 * |
680 * **We recommend using the `configureStore` method |
819 * There should only be a single store in your app. To specify how different |
681 * of the `@reduxjs/toolkit` package**, which replaces `createStore`. |
820 * parts of the state tree respond to actions, you may combine several reducers |
682 * |
821 * into a single reducer function by using `combineReducers`. |
683 * Redux Toolkit is our recommended approach for writing Redux logic today, |
822 * |
684 * including store setup, reducers, data fetching, and more. |
823 * @param {Function} reducer A function that returns the next state tree, given |
685 * |
824 * the current state tree and the action to handle. |
686 * **For more details, please read this Redux docs page:** |
825 * |
687 * **https://redux.js.org/introduction/why-rtk-is-redux-today** |
826 * @param {any} [preloadedState] The initial state. You may optionally specify it |
688 * |
827 * to hydrate the state from the server in universal apps, or to restore a |
689 * `configureStore` from Redux Toolkit is an improved version of `createStore` that |
828 * previously serialized user session. |
690 * simplifies setup and helps avoid common bugs. |
829 * If you use `combineReducers` to produce the root reducer function, this must be |
691 * |
830 * an object with the same shape as `combineReducers` keys. |
692 * You should not be using the `redux` core package by itself today, except for learning purposes. |
831 * |
693 * The `createStore` method from the core `redux` package will not be removed, but we encourage |
832 * @param {Function} [enhancer] The store enhancer. You may optionally specify it |
694 * all users to migrate to using Redux Toolkit for all Redux code. |
833 * to enhance the store with third-party capabilities such as middleware, |
695 * |
834 * time travel, persistence, etc. The only store enhancer that ships with Redux |
696 * If you want to use `createStore` without this visual deprecation warning, use |
835 * is `applyMiddleware()`. |
697 * the `legacy_createStore` import instead: |
836 * |
698 * |
837 * @returns {Store} A Redux store that lets you read the state, dispatch actions |
699 * `import { legacy_createStore as createStore} from 'redux'` |
838 * and subscribe to changes. |
700 * |
839 */ |
701 */ |
840 |
702 |
841 function redux_createStore(reducer, preloadedState, enhancer) { |
703 function createStore(reducer, preloadedState, enhancer) { |
842 var _ref2; |
704 var _ref2; |
843 |
705 |
844 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { |
706 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { |
845 throw new Error( true ? formatProdErrorMessage(0) : undefined); |
707 throw new Error( true ? formatProdErrorMessage(0) : 0); |
846 } |
708 } |
847 |
709 |
848 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { |
710 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { |
849 enhancer = preloadedState; |
711 enhancer = preloadedState; |
850 preloadedState = undefined; |
712 preloadedState = undefined; |
851 } |
713 } |
852 |
714 |
853 if (typeof enhancer !== 'undefined') { |
715 if (typeof enhancer !== 'undefined') { |
854 if (typeof enhancer !== 'function') { |
716 if (typeof enhancer !== 'function') { |
855 throw new Error( true ? formatProdErrorMessage(1) : undefined); |
717 throw new Error( true ? formatProdErrorMessage(1) : 0); |
856 } |
718 } |
857 |
719 |
858 return enhancer(redux_createStore)(reducer, preloadedState); |
720 return enhancer(createStore)(reducer, preloadedState); |
859 } |
721 } |
860 |
722 |
861 if (typeof reducer !== 'function') { |
723 if (typeof reducer !== 'function') { |
862 throw new Error( true ? formatProdErrorMessage(2) : undefined); |
724 throw new Error( true ? formatProdErrorMessage(2) : 0); |
863 } |
725 } |
864 |
726 |
865 var currentReducer = reducer; |
727 var currentReducer = reducer; |
866 var currentState = preloadedState; |
728 var currentState = preloadedState; |
867 var currentListeners = []; |
729 var currentListeners = []; |
887 */ |
749 */ |
888 |
750 |
889 |
751 |
890 function getState() { |
752 function getState() { |
891 if (isDispatching) { |
753 if (isDispatching) { |
892 throw new Error( true ? formatProdErrorMessage(3) : undefined); |
754 throw new Error( true ? formatProdErrorMessage(3) : 0); |
893 } |
755 } |
894 |
756 |
895 return currentState; |
757 return currentState; |
896 } |
758 } |
897 /** |
759 /** |
919 */ |
781 */ |
920 |
782 |
921 |
783 |
922 function subscribe(listener) { |
784 function subscribe(listener) { |
923 if (typeof listener !== 'function') { |
785 if (typeof listener !== 'function') { |
924 throw new Error( true ? formatProdErrorMessage(4) : undefined); |
786 throw new Error( true ? formatProdErrorMessage(4) : 0); |
925 } |
787 } |
926 |
788 |
927 if (isDispatching) { |
789 if (isDispatching) { |
928 throw new Error( true ? formatProdErrorMessage(5) : undefined); |
790 throw new Error( true ? formatProdErrorMessage(5) : 0); |
929 } |
791 } |
930 |
792 |
931 var isSubscribed = true; |
793 var isSubscribed = true; |
932 ensureCanMutateNextListeners(); |
794 ensureCanMutateNextListeners(); |
933 nextListeners.push(listener); |
795 nextListeners.push(listener); |
935 if (!isSubscribed) { |
797 if (!isSubscribed) { |
936 return; |
798 return; |
937 } |
799 } |
938 |
800 |
939 if (isDispatching) { |
801 if (isDispatching) { |
940 throw new Error( true ? formatProdErrorMessage(6) : undefined); |
802 throw new Error( true ? formatProdErrorMessage(6) : 0); |
941 } |
803 } |
942 |
804 |
943 isSubscribed = false; |
805 isSubscribed = false; |
944 ensureCanMutateNextListeners(); |
806 ensureCanMutateNextListeners(); |
945 var index = nextListeners.indexOf(listener); |
807 var index = nextListeners.indexOf(listener); |
974 */ |
836 */ |
975 |
837 |
976 |
838 |
977 function dispatch(action) { |
839 function dispatch(action) { |
978 if (!isPlainObject(action)) { |
840 if (!isPlainObject(action)) { |
979 throw new Error( true ? formatProdErrorMessage(7) : undefined); |
841 throw new Error( true ? formatProdErrorMessage(7) : 0); |
980 } |
842 } |
981 |
843 |
982 if (typeof action.type === 'undefined') { |
844 if (typeof action.type === 'undefined') { |
983 throw new Error( true ? formatProdErrorMessage(8) : undefined); |
845 throw new Error( true ? formatProdErrorMessage(8) : 0); |
984 } |
846 } |
985 |
847 |
986 if (isDispatching) { |
848 if (isDispatching) { |
987 throw new Error( true ? formatProdErrorMessage(9) : undefined); |
849 throw new Error( true ? formatProdErrorMessage(9) : 0); |
988 } |
850 } |
989 |
851 |
990 try { |
852 try { |
991 isDispatching = true; |
853 isDispatching = true; |
992 currentState = currentReducer(currentState, action); |
854 currentState = currentReducer(currentState, action); |
1015 */ |
877 */ |
1016 |
878 |
1017 |
879 |
1018 function replaceReducer(nextReducer) { |
880 function replaceReducer(nextReducer) { |
1019 if (typeof nextReducer !== 'function') { |
881 if (typeof nextReducer !== 'function') { |
1020 throw new Error( true ? formatProdErrorMessage(10) : undefined); |
882 throw new Error( true ? formatProdErrorMessage(10) : 0); |
1021 } |
883 } |
1022 |
884 |
1023 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. |
885 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. |
1024 // Any reducers that existed in both the new and old rootReducer |
886 // Any reducers that existed in both the new and old rootReducer |
1025 // will receive the previous state. This effectively populates |
887 // will receive the previous state. This effectively populates |
1050 * be used to unsubscribe the observable from the store, and prevent further |
912 * be used to unsubscribe the observable from the store, and prevent further |
1051 * emission of values from the observable. |
913 * emission of values from the observable. |
1052 */ |
914 */ |
1053 subscribe: function subscribe(observer) { |
915 subscribe: function subscribe(observer) { |
1054 if (typeof observer !== 'object' || observer === null) { |
916 if (typeof observer !== 'object' || observer === null) { |
1055 throw new Error( true ? formatProdErrorMessage(11) : undefined); |
917 throw new Error( true ? formatProdErrorMessage(11) : 0); |
1056 } |
918 } |
1057 |
919 |
1058 function observeState() { |
920 function observeState() { |
1059 if (observer.next) { |
921 if (observer.next) { |
1060 observer.next(getState()); |
922 observer.next(getState()); |
1083 subscribe: subscribe, |
945 subscribe: subscribe, |
1084 getState: getState, |
946 getState: getState, |
1085 replaceReducer: replaceReducer |
947 replaceReducer: replaceReducer |
1086 }, _ref2[$$observable] = observable, _ref2; |
948 }, _ref2[$$observable] = observable, _ref2; |
1087 } |
949 } |
950 /** |
|
951 * Creates a Redux store that holds the state tree. |
|
952 * |
|
953 * **We recommend using `configureStore` from the |
|
954 * `@reduxjs/toolkit` package**, which replaces `createStore`: |
|
955 * **https://redux.js.org/introduction/why-rtk-is-redux-today** |
|
956 * |
|
957 * The only way to change the data in the store is to call `dispatch()` on it. |
|
958 * |
|
959 * There should only be a single store in your app. To specify how different |
|
960 * parts of the state tree respond to actions, you may combine several reducers |
|
961 * into a single reducer function by using `combineReducers`. |
|
962 * |
|
963 * @param {Function} reducer A function that returns the next state tree, given |
|
964 * the current state tree and the action to handle. |
|
965 * |
|
966 * @param {any} [preloadedState] The initial state. You may optionally specify it |
|
967 * to hydrate the state from the server in universal apps, or to restore a |
|
968 * previously serialized user session. |
|
969 * If you use `combineReducers` to produce the root reducer function, this must be |
|
970 * an object with the same shape as `combineReducers` keys. |
|
971 * |
|
972 * @param {Function} [enhancer] The store enhancer. You may optionally specify it |
|
973 * to enhance the store with third-party capabilities such as middleware, |
|
974 * time travel, persistence, etc. The only store enhancer that ships with Redux |
|
975 * is `applyMiddleware()`. |
|
976 * |
|
977 * @returns {Store} A Redux store that lets you read the state, dispatch actions |
|
978 * and subscribe to changes. |
|
979 */ |
|
980 |
|
981 var legacy_createStore = (/* unused pure expression or super */ null && (createStore)); |
|
1088 |
982 |
1089 /** |
983 /** |
1090 * Prints a warning in the console if it exists. |
984 * Prints a warning in the console if it exists. |
1091 * |
985 * |
1092 * @param {String} message The warning message. |
986 * @param {String} message The warning message. |
1140 var initialState = reducer(undefined, { |
1034 var initialState = reducer(undefined, { |
1141 type: ActionTypes.INIT |
1035 type: ActionTypes.INIT |
1142 }); |
1036 }); |
1143 |
1037 |
1144 if (typeof initialState === 'undefined') { |
1038 if (typeof initialState === 'undefined') { |
1145 throw new Error( true ? formatProdErrorMessage(12) : undefined); |
1039 throw new Error( true ? formatProdErrorMessage(12) : 0); |
1146 } |
1040 } |
1147 |
1041 |
1148 if (typeof reducer(undefined, { |
1042 if (typeof reducer(undefined, { |
1149 type: ActionTypes.PROBE_UNKNOWN_ACTION() |
1043 type: ActionTypes.PROBE_UNKNOWN_ACTION() |
1150 }) === 'undefined') { |
1044 }) === 'undefined') { |
1151 throw new Error( true ? formatProdErrorMessage(13) : undefined); |
1045 throw new Error( true ? formatProdErrorMessage(13) : 0); |
1152 } |
1046 } |
1153 }); |
1047 }); |
1154 } |
1048 } |
1155 /** |
1049 /** |
1156 * Turns an object whose values are different reducer functions, into a single |
1050 * Turns an object whose values are different reducer functions, into a single |
1219 var previousStateForKey = state[_key]; |
1113 var previousStateForKey = state[_key]; |
1220 var nextStateForKey = reducer(previousStateForKey, action); |
1114 var nextStateForKey = reducer(previousStateForKey, action); |
1221 |
1115 |
1222 if (typeof nextStateForKey === 'undefined') { |
1116 if (typeof nextStateForKey === 'undefined') { |
1223 var actionType = action && action.type; |
1117 var actionType = action && action.type; |
1224 throw new Error( true ? formatProdErrorMessage(14) : undefined); |
1118 throw new Error( true ? formatProdErrorMessage(14) : 0); |
1225 } |
1119 } |
1226 |
1120 |
1227 nextState[_key] = nextStateForKey; |
1121 nextState[_key] = nextStateForKey; |
1228 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; |
1122 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; |
1229 } |
1123 } |
1265 if (typeof actionCreators === 'function') { |
1159 if (typeof actionCreators === 'function') { |
1266 return bindActionCreator(actionCreators, dispatch); |
1160 return bindActionCreator(actionCreators, dispatch); |
1267 } |
1161 } |
1268 |
1162 |
1269 if (typeof actionCreators !== 'object' || actionCreators === null) { |
1163 if (typeof actionCreators !== 'object' || actionCreators === null) { |
1270 throw new Error( true ? formatProdErrorMessage(16) : undefined); |
1164 throw new Error( true ? formatProdErrorMessage(16) : 0); |
1271 } |
1165 } |
1272 |
1166 |
1273 var boundActionCreators = {}; |
1167 var boundActionCreators = {}; |
1274 |
1168 |
1275 for (var key in actionCreators) { |
1169 for (var key in actionCreators) { |
1340 return function (createStore) { |
1234 return function (createStore) { |
1341 return function () { |
1235 return function () { |
1342 var store = createStore.apply(void 0, arguments); |
1236 var store = createStore.apply(void 0, arguments); |
1343 |
1237 |
1344 var _dispatch = function dispatch() { |
1238 var _dispatch = function dispatch() { |
1345 throw new Error( true ? formatProdErrorMessage(15) : undefined); |
1239 throw new Error( true ? formatProdErrorMessage(15) : 0); |
1346 }; |
1240 }; |
1347 |
1241 |
1348 var middlewareAPI = { |
1242 var middlewareAPI = { |
1349 getState: store.getState, |
1243 getState: store.getState, |
1350 dispatch: function dispatch() { |
1244 dispatch: function dispatch() { |
1372 if (false) {} |
1266 if (false) {} |
1373 |
1267 |
1374 |
1268 |
1375 |
1269 |
1376 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js |
1270 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js |
1377 var equivalent_key_map = __webpack_require__("FtRg"); |
1271 var equivalent_key_map = __webpack_require__(2167); |
1378 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); |
1272 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); |
1379 |
1273 ;// CONCATENATED MODULE: external ["wp","reduxRoutine"] |
1380 // EXTERNAL MODULE: external ["wp","reduxRoutine"] |
1274 var external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"]; |
1381 var external_wp_reduxRoutine_ = __webpack_require__("XIDh"); |
1275 var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject); |
1382 var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_); |
1276 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js |
1383 |
|
1384 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js |
|
1385 /** |
1277 /** |
1386 * Creates a selector function that takes additional curried argument with the |
1278 * Creates a selector function that takes additional curried argument with the |
1387 * registry `select` function. While a regular selector has signature |
1279 * registry `select` function. While a regular selector has signature |
1388 * ```js |
1280 * ```js |
1389 * ( state, ...selectorArgs ) => ( result ) |
1281 * ( state, ...selectorArgs ) => ( result ) |
1413 * (it works even inside a regular non-registry selector) and we don't need to pass the |
1305 * (it works even inside a regular non-registry selector) and we don't need to pass the |
1414 * registry as argument. The registry binding happens automatically when registering the selector |
1306 * registry as argument. The registry binding happens automatically when registering the selector |
1415 * with a store. |
1307 * with a store. |
1416 * |
1308 * |
1417 * @param {Function} registrySelector Function receiving a registry `select` |
1309 * @param {Function} registrySelector Function receiving a registry `select` |
1418 * function and returning a state selector. |
1310 * function and returning a state selector. |
1419 * |
1311 * |
1420 * @return {Function} Registry selector that can be registered with a store. |
1312 * @return {Function} Registry selector that can be registered with a store. |
1421 */ |
1313 */ |
1422 function createRegistrySelector(registrySelector) { |
1314 function createRegistrySelector(registrySelector) { |
1423 // create a selector function that is bound to the registry referenced by `selector.registry` |
1315 // Create a selector function that is bound to the registry referenced by `selector.registry` |
1424 // and that has the same API as a regular selector. Binding it in such a way makes it |
1316 // and that has the same API as a regular selector. Binding it in such a way makes it |
1425 // possible to call the selector directly from another selector. |
1317 // possible to call the selector directly from another selector. |
1426 const selector = (...args) => registrySelector(selector.registry.select)(...args); |
1318 const selector = function () { |
1319 return registrySelector(selector.registry.select)(...arguments); |
|
1320 }; |
|
1427 /** |
1321 /** |
1428 * Flag indicating that the selector is a registry selector that needs the correct registry |
1322 * Flag indicating that the selector is a registry selector that needs the correct registry |
1429 * reference to be assigned to `selecto.registry` to make it work correctly. |
1323 * reference to be assigned to `selecto.registry` to make it work correctly. |
1430 * be mapped as a registry selector. |
1324 * be mapped as a registry selector. |
1431 * |
1325 * |
1460 function createRegistryControl(registryControl) { |
1354 function createRegistryControl(registryControl) { |
1461 registryControl.isRegistryControl = true; |
1355 registryControl.isRegistryControl = true; |
1462 return registryControl; |
1356 return registryControl; |
1463 } |
1357 } |
1464 |
1358 |
1465 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js |
1359 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js |
1360 /** |
|
1361 * External dependencies |
|
1362 */ |
|
1363 |
|
1466 /** |
1364 /** |
1467 * Internal dependencies |
1365 * Internal dependencies |
1468 */ |
1366 */ |
1367 |
|
1368 |
|
1369 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
|
1469 |
1370 |
1470 const SELECT = '@@data/SELECT'; |
1371 const SELECT = '@@data/SELECT'; |
1471 const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; |
1372 const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; |
1472 const DISPATCH = '@@data/DISPATCH'; |
1373 const DISPATCH = '@@data/DISPATCH'; |
1473 /** |
1374 /** |
1474 * Dispatches a control action for triggering a synchronous registry select. |
1375 * Dispatches a control action for triggering a synchronous registry select. |
1475 * |
1376 * |
1476 * Note: This control synchronously returns the current selector value, triggering the |
1377 * Note: This control synchronously returns the current selector value, triggering the |
1477 * resolution, but not waiting for it. |
1378 * resolution, but not waiting for it. |
1478 * |
1379 * |
1479 * @param {string} storeKey The key for the store the selector belongs to. |
1380 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1480 * @param {string} selectorName The name of the selector. |
1381 * @param {string} selectorName The name of the selector. |
1481 * @param {Array} args Arguments for the selector. |
1382 * @param {Array} args Arguments for the selector. |
1482 * |
1383 * |
1483 * @example |
1384 * @example |
1484 * ```js |
1385 * ```js |
1485 * import { controls } from '@wordpress/data'; |
1386 * import { controls } from '@wordpress/data'; |
1486 * |
1387 * |
1492 * ``` |
1393 * ``` |
1493 * |
1394 * |
1494 * @return {Object} The control descriptor. |
1395 * @return {Object} The control descriptor. |
1495 */ |
1396 */ |
1496 |
1397 |
1497 function controls_select(storeKey, selectorName, ...args) { |
1398 function controls_select(storeNameOrDescriptor, selectorName) { |
1399 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { |
|
1400 args[_key - 2] = arguments[_key]; |
|
1401 } |
|
1402 |
|
1498 return { |
1403 return { |
1499 type: SELECT, |
1404 type: SELECT, |
1500 storeKey, |
1405 storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
1501 selectorName, |
1406 selectorName, |
1502 args |
1407 args |
1503 }; |
1408 }; |
1504 } |
1409 } |
1505 /** |
1410 /** |
1507 * |
1412 * |
1508 * Note: when this control action is handled, it automatically considers |
1413 * Note: when this control action is handled, it automatically considers |
1509 * selectors that may have a resolver. In such case, it will return a `Promise` that resolves |
1414 * selectors that may have a resolver. In such case, it will return a `Promise` that resolves |
1510 * after the selector finishes resolving, with the final result value. |
1415 * after the selector finishes resolving, with the final result value. |
1511 * |
1416 * |
1512 * @param {string} storeKey The key for the store the selector belongs to |
1417 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1513 * @param {string} selectorName The name of the selector |
1418 * @param {string} selectorName The name of the selector |
1514 * @param {Array} args Arguments for the selector. |
1419 * @param {Array} args Arguments for the selector. |
1515 * |
1420 * |
1516 * @example |
1421 * @example |
1517 * ```js |
1422 * ```js |
1518 * import { controls } from '@wordpress/data'; |
1423 * import { controls } from '@wordpress/data'; |
1519 * |
1424 * |
1526 * |
1431 * |
1527 * @return {Object} The control descriptor. |
1432 * @return {Object} The control descriptor. |
1528 */ |
1433 */ |
1529 |
1434 |
1530 |
1435 |
1531 function controls_resolveSelect(storeKey, selectorName, ...args) { |
1436 function resolveSelect(storeNameOrDescriptor, selectorName) { |
1437 for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { |
|
1438 args[_key2 - 2] = arguments[_key2]; |
|
1439 } |
|
1440 |
|
1532 return { |
1441 return { |
1533 type: RESOLVE_SELECT, |
1442 type: RESOLVE_SELECT, |
1534 storeKey, |
1443 storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
1535 selectorName, |
1444 selectorName, |
1536 args |
1445 args |
1537 }; |
1446 }; |
1538 } |
1447 } |
1539 /** |
1448 /** |
1540 * Dispatches a control action for triggering a registry dispatch. |
1449 * Dispatches a control action for triggering a registry dispatch. |
1541 * |
1450 * |
1542 * @param {string} storeKey The key for the store the action belongs to |
1451 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1543 * @param {string} actionName The name of the action to dispatch |
1452 * @param {string} actionName The name of the action to dispatch |
1544 * @param {Array} args Arguments for the dispatch action. |
1453 * @param {Array} args Arguments for the dispatch action. |
1545 * |
1454 * |
1546 * @example |
1455 * @example |
1547 * ```js |
1456 * ```js |
1548 * import { controls } from '@wordpress/data-controls'; |
1457 * import { controls } from '@wordpress/data-controls'; |
1549 * |
1458 * |
1556 * |
1465 * |
1557 * @return {Object} The control descriptor. |
1466 * @return {Object} The control descriptor. |
1558 */ |
1467 */ |
1559 |
1468 |
1560 |
1469 |
1561 function controls_dispatch(storeKey, actionName, ...args) { |
1470 function dispatch(storeNameOrDescriptor, actionName) { |
1471 for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { |
|
1472 args[_key3 - 2] = arguments[_key3]; |
|
1473 } |
|
1474 |
|
1562 return { |
1475 return { |
1563 type: DISPATCH, |
1476 type: DISPATCH, |
1564 storeKey, |
1477 storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
1565 actionName, |
1478 actionName, |
1566 args |
1479 args |
1567 }; |
1480 }; |
1568 } |
1481 } |
1569 |
1482 |
1570 const controls_controls = { |
1483 const controls = { |
1571 select: controls_select, |
1484 select: controls_select, |
1572 resolveSelect: controls_resolveSelect, |
1485 resolveSelect, |
1573 dispatch: controls_dispatch |
1486 dispatch |
1574 }; |
1487 }; |
1575 const builtinControls = { |
1488 const builtinControls = { |
1576 [SELECT]: createRegistryControl(registry => ({ |
1489 [SELECT]: createRegistryControl(registry => _ref => { |
1577 storeKey, |
1490 let { |
1578 selectorName, |
1491 storeKey, |
1579 args |
1492 selectorName, |
1580 }) => registry.select(storeKey)[selectorName](...args)), |
1493 args |
1581 [RESOLVE_SELECT]: createRegistryControl(registry => ({ |
1494 } = _ref; |
1582 storeKey, |
1495 return registry.select(storeKey)[selectorName](...args); |
1583 selectorName, |
1496 }), |
1584 args |
1497 [RESOLVE_SELECT]: createRegistryControl(registry => _ref2 => { |
1585 }) => { |
1498 let { |
1499 storeKey, |
|
1500 selectorName, |
|
1501 args |
|
1502 } = _ref2; |
|
1586 const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; |
1503 const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; |
1587 return registry[method](storeKey)[selectorName](...args); |
1504 return registry[method](storeKey)[selectorName](...args); |
1588 }), |
1505 }), |
1589 [DISPATCH]: createRegistryControl(registry => ({ |
1506 [DISPATCH]: createRegistryControl(registry => _ref3 => { |
1590 storeKey, |
1507 let { |
1591 actionName, |
1508 storeKey, |
1592 args |
1509 actionName, |
1593 }) => registry.dispatch(storeKey)[actionName](...args)) |
1510 args |
1511 } = _ref3; |
|
1512 return registry.dispatch(storeKey)[actionName](...args); |
|
1513 }) |
|
1594 }; |
1514 }; |
1595 |
1515 |
1596 // EXTERNAL MODULE: ./node_modules/is-promise/index.js |
1516 ;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs |
1597 var is_promise = __webpack_require__("JlUD"); |
1517 function isPromise(obj) { |
1598 var is_promise_default = /*#__PURE__*/__webpack_require__.n(is_promise); |
1518 return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; |
1599 |
1519 } |
1600 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js |
1520 |
1521 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js |
|
1601 /** |
1522 /** |
1602 * External dependencies |
1523 * External dependencies |
1603 */ |
1524 */ |
1604 |
1525 |
1605 /** |
1526 /** |
1606 * Simplest possible promise redux middleware. |
1527 * Simplest possible promise redux middleware. |
1607 * |
1528 * |
1608 * @return {Function} middleware. |
1529 * @type {import('redux').Middleware} |
1609 */ |
1530 */ |
1610 |
1531 |
1611 const promiseMiddleware = () => next => action => { |
1532 const promiseMiddleware = () => next => action => { |
1612 if (is_promise_default()(action)) { |
1533 if (isPromise(action)) { |
1613 return action.then(resolvedAction => { |
1534 return action.then(resolvedAction => { |
1614 if (resolvedAction) { |
1535 if (resolvedAction) { |
1615 return next(resolvedAction); |
1536 return next(resolvedAction); |
1616 } |
1537 } |
1617 }); |
1538 }); |
1620 return next(action); |
1541 return next(action); |
1621 }; |
1542 }; |
1622 |
1543 |
1623 /* harmony default export */ var promise_middleware = (promiseMiddleware); |
1544 /* harmony default export */ var promise_middleware = (promiseMiddleware); |
1624 |
1545 |
1625 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js |
1546 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js |
1547 const coreDataStore = { |
|
1548 name: 'core/data', |
|
1549 |
|
1550 instantiate(registry) { |
|
1551 const getCoreDataSelector = selectorName => function (key) { |
|
1552 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
1553 args[_key - 1] = arguments[_key]; |
|
1554 } |
|
1555 |
|
1556 return registry.select(key)[selectorName](...args); |
|
1557 }; |
|
1558 |
|
1559 const getCoreDataAction = actionName => function (key) { |
|
1560 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
|
1561 args[_key2 - 1] = arguments[_key2]; |
|
1562 } |
|
1563 |
|
1564 return registry.dispatch(key)[actionName](...args); |
|
1565 }; |
|
1566 |
|
1567 return { |
|
1568 getSelectors() { |
|
1569 return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)])); |
|
1570 }, |
|
1571 |
|
1572 getActions() { |
|
1573 return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)])); |
|
1574 }, |
|
1575 |
|
1576 subscribe() { |
|
1577 // There's no reasons to trigger any listener when we subscribe to this store |
|
1578 // because there's no state stored in this store that need to retrigger selectors |
|
1579 // if a change happens, the corresponding store where the tracking stated live |
|
1580 // would have already triggered a "subscribe" call. |
|
1581 return () => () => {}; |
|
1582 } |
|
1583 |
|
1584 }; |
|
1585 } |
|
1586 |
|
1587 }; |
|
1588 /* harmony default export */ var store = (coreDataStore); |
|
1589 |
|
1590 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js |
|
1626 /** |
1591 /** |
1627 * External dependencies |
1592 * External dependencies |
1628 */ |
1593 */ |
1594 |
|
1595 /** |
|
1596 * Internal dependencies |
|
1597 */ |
|
1598 |
|
1629 |
1599 |
1630 /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ |
1600 /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ |
1631 |
1601 |
1632 /** |
1602 /** |
1633 * Creates a middleware handling resolvers cache invalidation. |
1603 * Creates a middleware handling resolvers cache invalidation. |
1639 * |
1609 * |
1640 * @return {Function} Middleware function. |
1610 * @return {Function} Middleware function. |
1641 */ |
1611 */ |
1642 |
1612 |
1643 const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => { |
1613 const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => { |
1644 const resolvers = registry.select('core/data').getCachedResolvers(reducerKey); |
1614 const resolvers = registry.select(store).getCachedResolvers(reducerKey); |
1645 Object.entries(resolvers).forEach(([selectorName, resolversByArgs]) => { |
1615 Object.entries(resolvers).forEach(_ref => { |
1646 const resolver = Object(external_lodash_["get"])(registry.stores, [reducerKey, 'resolvers', selectorName]); |
1616 let [selectorName, resolversByArgs] = _ref; |
1617 const resolver = (0,external_lodash_namespaceObject.get)(registry.stores, [reducerKey, 'resolvers', selectorName]); |
|
1647 |
1618 |
1648 if (!resolver || !resolver.shouldInvalidate) { |
1619 if (!resolver || !resolver.shouldInvalidate) { |
1649 return; |
1620 return; |
1650 } |
1621 } |
1651 |
1622 |
1652 resolversByArgs.forEach((value, args) => { |
1623 resolversByArgs.forEach((value, args) => { |
1653 // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. |
1624 // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. |
1654 // If the value is false it means this resolver has finished its resolution which means we need to invalidate it, |
1625 // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need |
1655 // if it's true it means it's inflight and the invalidation is not necessary. |
1626 // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary. |
1656 if (value !== false || !resolver.shouldInvalidate(action, ...args)) { |
1627 if ((value === null || value === void 0 ? void 0 : value.status) !== 'finished' && (value === null || value === void 0 ? void 0 : value.status) !== 'error' || !resolver.shouldInvalidate(action, ...args)) { |
1657 return; |
1628 return; |
1658 } // Trigger cache invalidation |
1629 } // Trigger cache invalidation |
1659 |
1630 |
1660 |
1631 |
1661 registry.dispatch('core/data').invalidateResolution(reducerKey, selectorName, args); |
1632 registry.dispatch(store).invalidateResolution(reducerKey, selectorName, args); |
1662 }); |
1633 }); |
1663 }); |
1634 }); |
1664 return next(action); |
1635 return next(action); |
1665 }; |
1636 }; |
1666 |
1637 |
1667 /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware); |
1638 /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware); |
1668 |
1639 |
1669 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js |
1640 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js |
1670 function createThunkMiddleware(args) { |
1641 function createThunkMiddleware(args) { |
1671 return () => next => action => { |
1642 return () => next => action => { |
1672 if (typeof action === 'function') { |
1643 if (typeof action === 'function') { |
1673 return action(args); |
1644 return action(args); |
1674 } |
1645 } |
1675 |
1646 |
1676 return next(action); |
1647 return next(action); |
1677 }; |
1648 }; |
1678 } |
1649 } |
1679 |
1650 |
1680 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js |
1651 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js |
1652 /** |
|
1653 * External dependencies |
|
1654 */ |
|
1655 |
|
1681 /** |
1656 /** |
1682 * Higher-order reducer creator which creates a combined reducer object, keyed |
1657 * Higher-order reducer creator which creates a combined reducer object, keyed |
1683 * by a property on the action object. |
1658 * by a property on the action object. |
1684 * |
1659 * |
1685 * @param {string} actionProperty Action property by which to key object. |
1660 * @param actionProperty Action property by which to key object. |
1686 * |
1661 * @return Higher-order reducer. |
1687 * @return {Function} Higher-order reducer. |
1662 */ |
1688 */ |
1663 const onSubKey = actionProperty => reducer => function () { |
1689 const onSubKey = actionProperty => reducer => (state = {}, action) => { |
1664 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
1665 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
1690 // Retrieve subkey from action. Do not track if undefined; useful for cases |
1666 // Retrieve subkey from action. Do not track if undefined; useful for cases |
1691 // where reducer is scoped by action shape. |
1667 // where reducer is scoped by action shape. |
1692 const key = action[actionProperty]; |
1668 const key = action[actionProperty]; |
1693 |
1669 |
1694 if (key === undefined) { |
1670 if (key === undefined) { |
1705 |
1681 |
1706 return { ...state, |
1682 return { ...state, |
1707 [key]: nextKeyState |
1683 [key]: nextKeyState |
1708 }; |
1684 }; |
1709 }; |
1685 }; |
1710 |
1686 /** |
1711 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js |
1687 * Normalize selector argument array by defaulting `undefined` value to an empty array |
1688 * and removing trailing `undefined` values. |
|
1689 * |
|
1690 * @param args Selector argument array |
|
1691 * @return Normalized state key array |
|
1692 */ |
|
1693 |
|
1694 function selectorArgsToStateKey(args) { |
|
1695 if (args === undefined || args === null) { |
|
1696 return []; |
|
1697 } |
|
1698 |
|
1699 const len = args.length; |
|
1700 let idx = len; |
|
1701 |
|
1702 while (idx > 0 && args[idx - 1] === undefined) { |
|
1703 idx--; |
|
1704 } |
|
1705 |
|
1706 return idx === len ? args : args.slice(0, idx); |
|
1707 } |
|
1708 |
|
1709 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js |
|
1712 /** |
1710 /** |
1713 * External dependencies |
1711 * External dependencies |
1714 */ |
1712 */ |
1713 |
|
1715 |
1714 |
1716 |
1715 |
1717 /** |
1716 /** |
1718 * Internal dependencies |
1717 * Internal dependencies |
1719 */ |
1718 */ |
1722 /** |
1721 /** |
1723 * Reducer function returning next state for selector resolution of |
1722 * Reducer function returning next state for selector resolution of |
1724 * subkeys, object form: |
1723 * subkeys, object form: |
1725 * |
1724 * |
1726 * selectorName -> EquivalentKeyMap<Array,boolean> |
1725 * selectorName -> EquivalentKeyMap<Array,boolean> |
1727 * |
1726 */ |
1728 * @param {Object} state Current state. |
1727 const subKeysIsResolved = onSubKey('selectorName')(function () { |
1729 * @param {Object} action Dispatched action. |
1728 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new (equivalent_key_map_default())(); |
1730 * |
1729 let action = arguments.length > 1 ? arguments[1] : undefined; |
1731 * @return {Object} Next state. |
1730 |
1732 */ |
|
1733 |
|
1734 const subKeysIsResolved = onSubKey('selectorName')((state = new equivalent_key_map_default.a(), action) => { |
|
1735 switch (action.type) { |
1731 switch (action.type) { |
1736 case 'START_RESOLUTION': |
1732 case 'START_RESOLUTION': |
1733 { |
|
1734 const nextState = new (equivalent_key_map_default())(state); |
|
1735 nextState.set(selectorArgsToStateKey(action.args), { |
|
1736 status: 'resolving' |
|
1737 }); |
|
1738 return nextState; |
|
1739 } |
|
1740 |
|
1737 case 'FINISH_RESOLUTION': |
1741 case 'FINISH_RESOLUTION': |
1738 { |
1742 { |
1739 const isStarting = action.type === 'START_RESOLUTION'; |
1743 const nextState = new (equivalent_key_map_default())(state); |
1740 const nextState = new equivalent_key_map_default.a(state); |
1744 nextState.set(selectorArgsToStateKey(action.args), { |
1741 nextState.set(action.args, isStarting); |
1745 status: 'finished' |
1746 }); |
|
1742 return nextState; |
1747 return nextState; |
1743 } |
1748 } |
1744 |
1749 |
1750 case 'FAIL_RESOLUTION': |
|
1751 { |
|
1752 const nextState = new (equivalent_key_map_default())(state); |
|
1753 nextState.set(selectorArgsToStateKey(action.args), { |
|
1754 status: 'error', |
|
1755 error: action.error |
|
1756 }); |
|
1757 return nextState; |
|
1758 } |
|
1759 |
|
1745 case 'START_RESOLUTIONS': |
1760 case 'START_RESOLUTIONS': |
1761 { |
|
1762 const nextState = new (equivalent_key_map_default())(state); |
|
1763 |
|
1764 for (const resolutionArgs of action.args) { |
|
1765 nextState.set(selectorArgsToStateKey(resolutionArgs), { |
|
1766 status: 'resolving' |
|
1767 }); |
|
1768 } |
|
1769 |
|
1770 return nextState; |
|
1771 } |
|
1772 |
|
1746 case 'FINISH_RESOLUTIONS': |
1773 case 'FINISH_RESOLUTIONS': |
1747 { |
1774 { |
1748 const isStarting = action.type === 'START_RESOLUTIONS'; |
1775 const nextState = new (equivalent_key_map_default())(state); |
1749 const nextState = new equivalent_key_map_default.a(state); |
|
1750 |
1776 |
1751 for (const resolutionArgs of action.args) { |
1777 for (const resolutionArgs of action.args) { |
1752 nextState.set(resolutionArgs, isStarting); |
1778 nextState.set(selectorArgsToStateKey(resolutionArgs), { |
1779 status: 'finished' |
|
1780 }); |
|
1753 } |
1781 } |
1754 |
1782 |
1755 return nextState; |
1783 return nextState; |
1756 } |
1784 } |
1757 |
1785 |
1786 case 'FAIL_RESOLUTIONS': |
|
1787 { |
|
1788 const nextState = new (equivalent_key_map_default())(state); |
|
1789 action.args.forEach((resolutionArgs, idx) => { |
|
1790 const resolutionState = { |
|
1791 status: 'error', |
|
1792 error: undefined |
|
1793 }; |
|
1794 const error = action.errors[idx]; |
|
1795 |
|
1796 if (error) { |
|
1797 resolutionState.error = error; |
|
1798 } |
|
1799 |
|
1800 nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState); |
|
1801 }); |
|
1802 return nextState; |
|
1803 } |
|
1804 |
|
1758 case 'INVALIDATE_RESOLUTION': |
1805 case 'INVALIDATE_RESOLUTION': |
1759 { |
1806 { |
1760 const nextState = new equivalent_key_map_default.a(state); |
1807 const nextState = new (equivalent_key_map_default())(state); |
1761 nextState.delete(action.args); |
1808 nextState.delete(selectorArgsToStateKey(action.args)); |
1762 return nextState; |
1809 return nextState; |
1763 } |
1810 } |
1764 } |
1811 } |
1765 |
1812 |
1766 return state; |
1813 return state; |
1768 /** |
1815 /** |
1769 * Reducer function returning next state for selector resolution, object form: |
1816 * Reducer function returning next state for selector resolution, object form: |
1770 * |
1817 * |
1771 * selectorName -> EquivalentKeyMap<Array, boolean> |
1818 * selectorName -> EquivalentKeyMap<Array, boolean> |
1772 * |
1819 * |
1773 * @param {Object} state Current state. |
1820 * @param state Current state. |
1774 * @param {Object} action Dispatched action. |
1821 * @param action Dispatched action. |
1775 * |
1822 * |
1776 * @return {Object} Next state. |
1823 * @return Next state. |
1777 */ |
1824 */ |
1778 |
1825 |
1779 const isResolved = (state = {}, action) => { |
1826 const isResolved = function () { |
1827 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
1828 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
1829 |
|
1780 switch (action.type) { |
1830 switch (action.type) { |
1781 case 'INVALIDATE_RESOLUTION_FOR_STORE': |
1831 case 'INVALIDATE_RESOLUTION_FOR_STORE': |
1782 return {}; |
1832 return {}; |
1783 |
1833 |
1784 case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': |
1834 case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': |
1785 return Object(external_lodash_["has"])(state, [action.selectorName]) ? Object(external_lodash_["omit"])(state, [action.selectorName]) : state; |
1835 return (0,external_lodash_namespaceObject.has)(state, [action.selectorName]) ? (0,external_lodash_namespaceObject.omit)(state, [action.selectorName]) : state; |
1786 |
1836 |
1787 case 'START_RESOLUTION': |
1837 case 'START_RESOLUTION': |
1788 case 'FINISH_RESOLUTION': |
1838 case 'FINISH_RESOLUTION': |
1839 case 'FAIL_RESOLUTION': |
|
1789 case 'START_RESOLUTIONS': |
1840 case 'START_RESOLUTIONS': |
1790 case 'FINISH_RESOLUTIONS': |
1841 case 'FINISH_RESOLUTIONS': |
1842 case 'FAIL_RESOLUTIONS': |
|
1791 case 'INVALIDATE_RESOLUTION': |
1843 case 'INVALIDATE_RESOLUTION': |
1792 return subKeysIsResolved(state, action); |
1844 return subKeysIsResolved(state, action); |
1793 } |
1845 } |
1794 |
1846 |
1795 return state; |
1847 return state; |
1796 }; |
1848 }; |
1797 |
1849 |
1798 /* harmony default export */ var metadata_reducer = (isResolved); |
1850 /* harmony default export */ var metadata_reducer = (isResolved); |
1799 |
1851 |
1800 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
1852 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
1801 /** |
1853 /** |
1802 * External dependencies |
1854 * External dependencies |
1803 */ |
1855 */ |
1804 |
1856 |
1857 /** |
|
1858 * Internal dependencies |
|
1859 */ |
|
1860 |
|
1861 |
|
1862 /** @typedef {Record<string, import('./reducer').State>} State */ |
|
1863 |
|
1864 /** @typedef {import('./reducer').StateValue} StateValue */ |
|
1865 |
|
1866 /** @typedef {import('./reducer').Status} Status */ |
|
1867 |
|
1868 /** |
|
1869 * Returns the raw resolution state value for a given selector name, |
|
1870 * and arguments set. May be undefined if the selector has never been resolved |
|
1871 * or not resolved for the given set of arguments, otherwise true or false for |
|
1872 * resolution started and completed respectively. |
|
1873 * |
|
1874 * @param {State} state Data state. |
|
1875 * @param {string} selectorName Selector name. |
|
1876 * @param {unknown[]?} args Arguments passed to selector. |
|
1877 * |
|
1878 * @return {StateValue|undefined} isResolving value. |
|
1879 */ |
|
1880 |
|
1881 function getResolutionState(state, selectorName, args) { |
|
1882 const map = (0,external_lodash_namespaceObject.get)(state, [selectorName]); |
|
1883 |
|
1884 if (!map) { |
|
1885 return; |
|
1886 } |
|
1887 |
|
1888 return map.get(selectorArgsToStateKey(args)); |
|
1889 } |
|
1805 /** |
1890 /** |
1806 * Returns the raw `isResolving` value for a given selector name, |
1891 * Returns the raw `isResolving` value for a given selector name, |
1807 * and arguments set. May be undefined if the selector has never been resolved |
1892 * and arguments set. May be undefined if the selector has never been resolved |
1808 * or not resolved for the given set of arguments, otherwise true or false for |
1893 * or not resolved for the given set of arguments, otherwise true or false for |
1809 * resolution started and completed respectively. |
1894 * resolution started and completed respectively. |
1810 * |
1895 * |
1811 * @param {Object} state Data state. |
1896 * @param {State} state Data state. |
1812 * @param {string} selectorName Selector name. |
1897 * @param {string} selectorName Selector name. |
1813 * @param {Array} args Arguments passed to selector. |
1898 * @param {unknown[]?} args Arguments passed to selector. |
1814 * |
1899 * |
1815 * @return {?boolean} isResolving value. |
1900 * @return {boolean | undefined} isResolving value. |
1816 */ |
1901 */ |
1817 |
1902 |
1818 function getIsResolving(state, selectorName, args) { |
1903 function getIsResolving(state, selectorName, args) { |
1819 const map = Object(external_lodash_["get"])(state, [selectorName]); |
1904 const resolutionState = getResolutionState(state, selectorName, args); |
1820 |
1905 return resolutionState && resolutionState.status === 'resolving'; |
1821 if (!map) { |
|
1822 return; |
|
1823 } |
|
1824 |
|
1825 return map.get(args); |
|
1826 } |
1906 } |
1827 /** |
1907 /** |
1828 * Returns true if resolution has already been triggered for a given |
1908 * Returns true if resolution has already been triggered for a given |
1829 * selector name, and arguments set. |
1909 * selector name, and arguments set. |
1830 * |
1910 * |
1831 * @param {Object} state Data state. |
1911 * @param {State} state Data state. |
1832 * @param {string} selectorName Selector name. |
1912 * @param {string} selectorName Selector name. |
1833 * @param {?Array} args Arguments passed to selector (default `[]`). |
1913 * @param {unknown[]?} args Arguments passed to selector. |
1834 * |
1914 * |
1835 * @return {boolean} Whether resolution has been triggered. |
1915 * @return {boolean} Whether resolution has been triggered. |
1836 */ |
1916 */ |
1837 |
1917 |
1838 function hasStartedResolution(state, selectorName, args = []) { |
1918 function hasStartedResolution(state, selectorName, args) { |
1839 return getIsResolving(state, selectorName, args) !== undefined; |
1919 return getResolutionState(state, selectorName, args) !== undefined; |
1840 } |
1920 } |
1841 /** |
1921 /** |
1842 * Returns true if resolution has completed for a given selector |
1922 * Returns true if resolution has completed for a given selector |
1843 * name, and arguments set. |
1923 * name, and arguments set. |
1844 * |
1924 * |
1845 * @param {Object} state Data state. |
1925 * @param {State} state Data state. |
1846 * @param {string} selectorName Selector name. |
1926 * @param {string} selectorName Selector name. |
1847 * @param {?Array} args Arguments passed to selector. |
1927 * @param {unknown[]?} args Arguments passed to selector. |
1848 * |
1928 * |
1849 * @return {boolean} Whether resolution has completed. |
1929 * @return {boolean} Whether resolution has completed. |
1850 */ |
1930 */ |
1851 |
1931 |
1852 function hasFinishedResolution(state, selectorName, args = []) { |
1932 function hasFinishedResolution(state, selectorName, args) { |
1853 return getIsResolving(state, selectorName, args) === false; |
1933 var _getResolutionState; |
1934 |
|
1935 const status = (_getResolutionState = getResolutionState(state, selectorName, args)) === null || _getResolutionState === void 0 ? void 0 : _getResolutionState.status; |
|
1936 return status === 'finished' || status === 'error'; |
|
1937 } |
|
1938 /** |
|
1939 * Returns true if resolution has failed for a given selector |
|
1940 * name, and arguments set. |
|
1941 * |
|
1942 * @param {State} state Data state. |
|
1943 * @param {string} selectorName Selector name. |
|
1944 * @param {unknown[]?} args Arguments passed to selector. |
|
1945 * |
|
1946 * @return {boolean} Has resolution failed |
|
1947 */ |
|
1948 |
|
1949 function hasResolutionFailed(state, selectorName, args) { |
|
1950 var _getResolutionState2; |
|
1951 |
|
1952 return ((_getResolutionState2 = getResolutionState(state, selectorName, args)) === null || _getResolutionState2 === void 0 ? void 0 : _getResolutionState2.status) === 'error'; |
|
1953 } |
|
1954 /** |
|
1955 * Returns the resolution error for a given selector name, and arguments set. |
|
1956 * Note it may be of an Error type, but may also be null, undefined, or anything else |
|
1957 * that can be `throw`-n. |
|
1958 * |
|
1959 * @param {State} state Data state. |
|
1960 * @param {string} selectorName Selector name. |
|
1961 * @param {unknown[]?} args Arguments passed to selector. |
|
1962 * |
|
1963 * @return {Error|unknown} Last resolution error |
|
1964 */ |
|
1965 |
|
1966 function getResolutionError(state, selectorName, args) { |
|
1967 const resolutionState = getResolutionState(state, selectorName, args); |
|
1968 return (resolutionState === null || resolutionState === void 0 ? void 0 : resolutionState.status) === 'error' ? resolutionState.error : null; |
|
1854 } |
1969 } |
1855 /** |
1970 /** |
1856 * Returns true if resolution has been triggered but has not yet completed for |
1971 * Returns true if resolution has been triggered but has not yet completed for |
1857 * a given selector name, and arguments set. |
1972 * a given selector name, and arguments set. |
1858 * |
1973 * |
1859 * @param {Object} state Data state. |
1974 * @param {State} state Data state. |
1860 * @param {string} selectorName Selector name. |
1975 * @param {string} selectorName Selector name. |
1861 * @param {?Array} args Arguments passed to selector. |
1976 * @param {unknown[]?} args Arguments passed to selector. |
1862 * |
1977 * |
1863 * @return {boolean} Whether resolution is in progress. |
1978 * @return {boolean} Whether resolution is in progress. |
1864 */ |
1979 */ |
1865 |
1980 |
1866 function isResolving(state, selectorName, args = []) { |
1981 function isResolving(state, selectorName, args) { |
1867 return getIsResolving(state, selectorName, args) === true; |
1982 var _getResolutionState3; |
1983 |
|
1984 return ((_getResolutionState3 = getResolutionState(state, selectorName, args)) === null || _getResolutionState3 === void 0 ? void 0 : _getResolutionState3.status) === 'resolving'; |
|
1868 } |
1985 } |
1869 /** |
1986 /** |
1870 * Returns the list of the cached resolvers. |
1987 * Returns the list of the cached resolvers. |
1871 * |
1988 * |
1872 * @param {Object} state Data state. |
1989 * @param {State} state Data state. |
1873 * |
1990 * |
1874 * @return {Object} Resolvers mapped by args and selectorName. |
1991 * @return {State} Resolvers mapped by args and selectorName. |
1875 */ |
1992 */ |
1876 |
1993 |
1877 function getCachedResolvers(state) { |
1994 function getCachedResolvers(state) { |
1878 return state; |
1995 return state; |
1879 } |
1996 } |
1880 |
1997 |
1881 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
1998 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
1882 /** |
1999 /** |
1883 * Returns an action object used in signalling that selector resolution has |
2000 * Returns an action object used in signalling that selector resolution has |
1884 * started. |
2001 * started. |
1885 * |
2002 * |
1886 * @param {string} selectorName Name of selector for which resolver triggered. |
2003 * @param {string} selectorName Name of selector for which resolver triggered. |
1887 * @param {...*} args Arguments to associate for uniqueness. |
2004 * @param {unknown[]} args Arguments to associate for uniqueness. |
1888 * |
2005 * |
1889 * @return {Object} Action object. |
2006 * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object. |
1890 */ |
2007 */ |
1891 function startResolution(selectorName, args) { |
2008 function startResolution(selectorName, args) { |
1892 return { |
2009 return { |
1893 type: 'START_RESOLUTION', |
2010 type: 'START_RESOLUTION', |
1894 selectorName, |
2011 selectorName, |
1897 } |
2014 } |
1898 /** |
2015 /** |
1899 * Returns an action object used in signalling that selector resolution has |
2016 * Returns an action object used in signalling that selector resolution has |
1900 * completed. |
2017 * completed. |
1901 * |
2018 * |
1902 * @param {string} selectorName Name of selector for which resolver triggered. |
2019 * @param {string} selectorName Name of selector for which resolver triggered. |
1903 * @param {...*} args Arguments to associate for uniqueness. |
2020 * @param {unknown[]} args Arguments to associate for uniqueness. |
1904 * |
2021 * |
1905 * @return {Object} Action object. |
2022 * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object. |
1906 */ |
2023 */ |
1907 |
2024 |
1908 function finishResolution(selectorName, args) { |
2025 function finishResolution(selectorName, args) { |
1909 return { |
2026 return { |
1910 type: 'FINISH_RESOLUTION', |
2027 type: 'FINISH_RESOLUTION', |
1911 selectorName, |
2028 selectorName, |
1912 args |
2029 args |
1913 }; |
2030 }; |
1914 } |
2031 } |
1915 /** |
2032 /** |
2033 * Returns an action object used in signalling that selector resolution has |
|
2034 * failed. |
|
2035 * |
|
2036 * @param {string} selectorName Name of selector for which resolver triggered. |
|
2037 * @param {unknown[]} args Arguments to associate for uniqueness. |
|
2038 * @param {Error|unknown} error The error that caused the failure. |
|
2039 * |
|
2040 * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object. |
|
2041 */ |
|
2042 |
|
2043 function failResolution(selectorName, args, error) { |
|
2044 return { |
|
2045 type: 'FAIL_RESOLUTION', |
|
2046 selectorName, |
|
2047 args, |
|
2048 error |
|
2049 }; |
|
2050 } |
|
2051 /** |
|
1916 * Returns an action object used in signalling that a batch of selector resolutions has |
2052 * Returns an action object used in signalling that a batch of selector resolutions has |
1917 * started. |
2053 * started. |
1918 * |
2054 * |
1919 * @param {string} selectorName Name of selector for which resolver triggered. |
2055 * @param {string} selectorName Name of selector for which resolver triggered. |
1920 * @param {...*} args Array of arguments to associate for uniqueness, each item |
2056 * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item |
1921 * is associated to a resolution. |
2057 * is associated to a resolution. |
1922 * |
2058 * |
1923 * @return {Object} Action object. |
2059 * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. |
1924 */ |
2060 */ |
1925 |
2061 |
1926 function startResolutions(selectorName, args) { |
2062 function startResolutions(selectorName, args) { |
1927 return { |
2063 return { |
1928 type: 'START_RESOLUTIONS', |
2064 type: 'START_RESOLUTIONS', |
1932 } |
2068 } |
1933 /** |
2069 /** |
1934 * Returns an action object used in signalling that a batch of selector resolutions has |
2070 * Returns an action object used in signalling that a batch of selector resolutions has |
1935 * completed. |
2071 * completed. |
1936 * |
2072 * |
1937 * @param {string} selectorName Name of selector for which resolver triggered. |
2073 * @param {string} selectorName Name of selector for which resolver triggered. |
1938 * @param {...*} args Array of arguments to associate for uniqueness, each item |
2074 * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item |
1939 * is associated to a resolution. |
2075 * is associated to a resolution. |
1940 * |
2076 * |
1941 * @return {Object} Action object. |
2077 * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. |
1942 */ |
2078 */ |
1943 |
2079 |
1944 function finishResolutions(selectorName, args) { |
2080 function finishResolutions(selectorName, args) { |
1945 return { |
2081 return { |
1946 type: 'FINISH_RESOLUTIONS', |
2082 type: 'FINISH_RESOLUTIONS', |
1947 selectorName, |
2083 selectorName, |
1948 args |
2084 args |
1949 }; |
2085 }; |
1950 } |
2086 } |
1951 /** |
2087 /** |
2088 * Returns an action object used in signalling that a batch of selector resolutions has |
|
2089 * completed and at least one of them has failed. |
|
2090 * |
|
2091 * @param {string} selectorName Name of selector for which resolver triggered. |
|
2092 * @param {unknown[]} args Array of arguments to associate for uniqueness, each item |
|
2093 * is associated to a resolution. |
|
2094 * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item |
|
2095 * is associated to a resolution. |
|
2096 * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object. |
|
2097 */ |
|
2098 |
|
2099 function failResolutions(selectorName, args, errors) { |
|
2100 return { |
|
2101 type: 'FAIL_RESOLUTIONS', |
|
2102 selectorName, |
|
2103 args, |
|
2104 errors |
|
2105 }; |
|
2106 } |
|
2107 /** |
|
1952 * Returns an action object used in signalling that we should invalidate the resolution cache. |
2108 * Returns an action object used in signalling that we should invalidate the resolution cache. |
1953 * |
2109 * |
1954 * @param {string} selectorName Name of selector for which resolver should be invalidated. |
2110 * @param {string} selectorName Name of selector for which resolver should be invalidated. |
1955 * @param {Array} args Arguments to associate for uniqueness. |
2111 * @param {unknown[]} args Arguments to associate for uniqueness. |
1956 * |
2112 * |
1957 * @return {Object} Action object. |
2113 * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object. |
1958 */ |
2114 */ |
1959 |
2115 |
1960 function invalidateResolution(selectorName, args) { |
2116 function invalidateResolution(selectorName, args) { |
1961 return { |
2117 return { |
1962 type: 'INVALIDATE_RESOLUTION', |
2118 type: 'INVALIDATE_RESOLUTION', |
1966 } |
2122 } |
1967 /** |
2123 /** |
1968 * Returns an action object used in signalling that the resolution |
2124 * Returns an action object used in signalling that the resolution |
1969 * should be invalidated. |
2125 * should be invalidated. |
1970 * |
2126 * |
1971 * @return {Object} Action object. |
2127 * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object. |
1972 */ |
2128 */ |
1973 |
2129 |
1974 function invalidateResolutionForStore() { |
2130 function invalidateResolutionForStore() { |
1975 return { |
2131 return { |
1976 type: 'INVALIDATE_RESOLUTION_FOR_STORE' |
2132 type: 'INVALIDATE_RESOLUTION_FOR_STORE' |
1981 * given selectorName should be invalidated. |
2137 * given selectorName should be invalidated. |
1982 * |
2138 * |
1983 * @param {string} selectorName Name of selector for which all resolvers should |
2139 * @param {string} selectorName Name of selector for which all resolvers should |
1984 * be invalidated. |
2140 * be invalidated. |
1985 * |
2141 * |
1986 * @return {Object} Action object. |
2142 * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object. |
1987 */ |
2143 */ |
1988 |
2144 |
1989 function invalidateResolutionForStoreSelector(selectorName) { |
2145 function invalidateResolutionForStoreSelector(selectorName) { |
1990 return { |
2146 return { |
1991 type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', |
2147 type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', |
1992 selectorName |
2148 selectorName |
1993 }; |
2149 }; |
1994 } |
2150 } |
1995 |
2151 |
1996 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js |
2152 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js |
1997 /** |
2153 /** |
1998 * External dependencies |
2154 * External dependencies |
1999 */ |
2155 */ |
2000 |
2156 |
2001 |
2157 |
2015 |
2171 |
2016 |
2172 |
2017 |
2173 |
2018 |
2174 |
2019 |
2175 |
2020 /** @typedef {import('../types').WPDataRegistry} WPDataRegistry */ |
2176 /** @typedef {import('../types').DataRegistry} DataRegistry */ |
2021 |
2177 |
2022 /** @typedef {import('../types').WPDataStore} WPDataStore */ |
2178 /** @typedef {import('../types').StoreDescriptor} StoreDescriptor */ |
2023 |
2179 |
2024 /** @typedef {import('../types').WPDataReduxStoreConfig} WPDataReduxStoreConfig */ |
2180 /** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */ |
2025 |
2181 |
2182 const trimUndefinedValues = array => { |
|
2183 const result = [...array]; |
|
2184 |
|
2185 for (let i = result.length - 1; i >= 0; i--) { |
|
2186 if (result[i] === undefined) { |
|
2187 result.splice(i, 1); |
|
2188 } |
|
2189 } |
|
2190 |
|
2191 return result; |
|
2192 }; |
|
2026 /** |
2193 /** |
2027 * Create a cache to track whether resolvers started running or not. |
2194 * Create a cache to track whether resolvers started running or not. |
2028 * |
2195 * |
2029 * @return {Object} Resolvers Cache. |
2196 * @return {Object} Resolvers Cache. |
2030 */ |
2197 */ |
2198 |
|
2031 |
2199 |
2032 function createResolversCache() { |
2200 function createResolversCache() { |
2033 const cache = {}; |
2201 const cache = {}; |
2034 return { |
2202 return { |
2035 isRunning(selectorName, args) { |
2203 isRunning(selectorName, args) { |
2036 return cache[selectorName] && cache[selectorName].get(args); |
2204 return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args)); |
2037 }, |
2205 }, |
2038 |
2206 |
2039 clear(selectorName, args) { |
2207 clear(selectorName, args) { |
2040 if (cache[selectorName]) { |
2208 if (cache[selectorName]) { |
2041 cache[selectorName].delete(args); |
2209 cache[selectorName].delete(trimUndefinedValues(args)); |
2042 } |
2210 } |
2043 }, |
2211 }, |
2044 |
2212 |
2045 markAsRunning(selectorName, args) { |
2213 markAsRunning(selectorName, args) { |
2046 if (!cache[selectorName]) { |
2214 if (!cache[selectorName]) { |
2047 cache[selectorName] = new equivalent_key_map_default.a(); |
2215 cache[selectorName] = new (equivalent_key_map_default())(); |
2048 } |
2216 } |
2049 |
2217 |
2050 cache[selectorName].set(args, true); |
2218 cache[selectorName].set(trimUndefinedValues(args), true); |
2051 } |
2219 } |
2052 |
2220 |
2053 }; |
2221 }; |
2054 } |
2222 } |
2055 /** |
2223 /** |
2056 * Creates a data store definition for the provided Redux store options containing |
2224 * Creates a data store descriptor for the provided Redux store configuration containing |
2057 * properties describing reducer, actions, selectors, controls and resolvers. |
2225 * properties describing reducer, actions, selectors, controls and resolvers. |
2058 * |
2226 * |
2059 * @example |
2227 * @example |
2060 * ```js |
2228 * ```js |
2061 * import { createReduxStore } from '@wordpress/data'; |
2229 * import { createReduxStore } from '@wordpress/data'; |
2066 * getValue: ( state ) => state, |
2234 * getValue: ( state ) => state, |
2067 * }, |
2235 * }, |
2068 * } ); |
2236 * } ); |
2069 * ``` |
2237 * ``` |
2070 * |
2238 * |
2071 * @param {string} key Unique namespace identifier. |
2239 * @param {string} key Unique namespace identifier. |
2072 * @param {WPDataReduxStoreConfig} options Registered store options, with properties |
2240 * @param {ReduxStoreConfig} options Registered store options, with properties |
2073 * describing reducer, actions, selectors, |
2241 * describing reducer, actions, selectors, |
2074 * and resolvers. |
2242 * and resolvers. |
2075 * |
2243 * |
2076 * @return {WPDataStore} Store Object. |
2244 * @return {StoreDescriptor} Store Object. |
2077 */ |
2245 */ |
2078 |
2246 |
2079 |
2247 |
2080 function createReduxStore(key, options) { |
2248 function createReduxStore(key, options) { |
2081 return { |
2249 return { |
2102 const resolversCache = createResolversCache(); |
2270 const resolversCache = createResolversCache(); |
2103 let resolvers; |
2271 let resolvers; |
2104 const actions = mapActions({ ...actions_namespaceObject, |
2272 const actions = mapActions({ ...actions_namespaceObject, |
2105 ...options.actions |
2273 ...options.actions |
2106 }, store); |
2274 }, store); |
2107 let selectors = mapSelectors({ ...Object(external_lodash_["mapValues"])(selectors_namespaceObject, selector => (state, ...args) => selector(state.metadata, ...args)), |
2275 let selectors = mapSelectors({ ...(0,external_lodash_namespaceObject.mapValues)(selectors_namespaceObject, selector => function (state) { |
2108 ...Object(external_lodash_["mapValues"])(options.selectors, selector => { |
2276 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
2277 args[_key - 1] = arguments[_key]; |
|
2278 } |
|
2279 |
|
2280 return selector(state.metadata, ...args); |
|
2281 }), |
|
2282 ...(0,external_lodash_namespaceObject.mapValues)(options.selectors, selector => { |
|
2109 if (selector.isRegistrySelector) { |
2283 if (selector.isRegistrySelector) { |
2110 selector.registry = registry; |
2284 selector.registry = registry; |
2111 } |
2285 } |
2112 |
2286 |
2113 return (state, ...args) => selector(state.root, ...args); |
2287 return function (state) { |
2288 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
|
2289 args[_key2 - 1] = arguments[_key2]; |
|
2290 } |
|
2291 |
|
2292 return selector(state.root, ...args); |
|
2293 }; |
|
2114 }) |
2294 }) |
2115 }, store); |
2295 }, store); |
2116 |
2296 |
2117 if (options.resolvers) { |
2297 if (options.resolvers) { |
2118 const result = mapResolvers(options.resolvers, selectors, store, resolversCache); |
2298 const result = mapResolvers(options.resolvers, selectors, store, resolversCache); |
2169 }; |
2349 }; |
2170 } |
2350 } |
2171 /** |
2351 /** |
2172 * Creates a redux store for a namespace. |
2352 * Creates a redux store for a namespace. |
2173 * |
2353 * |
2174 * @param {string} key Unique namespace identifier. |
2354 * @param {string} key Unique namespace identifier. |
2175 * @param {Object} options Registered store options, with properties |
2355 * @param {Object} options Registered store options, with properties |
2176 * describing reducer, actions, selectors, |
2356 * describing reducer, actions, selectors, |
2177 * and resolvers. |
2357 * and resolvers. |
2178 * @param {WPDataRegistry} registry Registry reference. |
2358 * @param {DataRegistry} registry Registry reference. |
2179 * @param {Object} thunkArgs Argument object for the thunk middleware. |
2359 * @param {Object} thunkArgs Argument object for the thunk middleware. |
2180 * @return {Object} Newly created redux store. |
2360 * @return {Object} Newly created redux store. |
2181 */ |
2361 */ |
2182 |
2362 |
2183 function instantiateReduxStore(key, options, registry, thunkArgs) { |
2363 function instantiateReduxStore(key, options, registry, thunkArgs) { |
2184 const controls = { ...options.controls, |
2364 const controls = { ...options.controls, |
2185 ...builtinControls |
2365 ...builtinControls |
2186 }; |
2366 }; |
2187 const normalizedControls = Object(external_lodash_["mapValues"])(controls, control => control.isRegistryControl ? control(registry) : control); |
2367 const normalizedControls = (0,external_lodash_namespaceObject.mapValues)(controls, control => control.isRegistryControl ? control(registry) : control); |
2188 const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls)]; |
2368 const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)]; |
2189 |
|
2190 if (options.__experimentalUseThunks) { |
|
2191 middlewares.push(createThunkMiddleware(thunkArgs)); |
|
2192 } |
|
2193 |
|
2194 const enhancers = [applyMiddleware(...middlewares)]; |
2369 const enhancers = [applyMiddleware(...middlewares)]; |
2195 |
2370 |
2196 if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { |
2371 if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { |
2197 enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({ |
2372 enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({ |
2198 name: key, |
2373 name: key, |
2206 } = options; |
2381 } = options; |
2207 const enhancedReducer = turbo_combine_reducers_default()({ |
2382 const enhancedReducer = turbo_combine_reducers_default()({ |
2208 metadata: metadata_reducer, |
2383 metadata: metadata_reducer, |
2209 root: reducer |
2384 root: reducer |
2210 }); |
2385 }); |
2211 return redux_createStore(enhancedReducer, { |
2386 return createStore(enhancedReducer, { |
2212 root: initialState |
2387 root: initialState |
2213 }, Object(external_lodash_["flowRight"])(enhancers)); |
2388 }, (0,external_lodash_namespaceObject.flowRight)(enhancers)); |
2214 } |
2389 } |
2215 /** |
2390 /** |
2216 * Maps selectors to a store. |
2391 * Maps selectors to a store. |
2217 * |
2392 * |
2218 * @param {Object} selectors Selectors to register. Keys will be used as the |
2393 * @param {Object} selectors Selectors to register. Keys will be used as the |
2246 |
2421 |
2247 selector.hasResolver = false; |
2422 selector.hasResolver = false; |
2248 return selector; |
2423 return selector; |
2249 }; |
2424 }; |
2250 |
2425 |
2251 return Object(external_lodash_["mapValues"])(selectors, createStateSelector); |
2426 return (0,external_lodash_namespaceObject.mapValues)(selectors, createStateSelector); |
2252 } |
2427 } |
2253 /** |
2428 /** |
2254 * Maps actions to dispatch from a given store. |
2429 * Maps actions to dispatch from a given store. |
2255 * |
2430 * |
2256 * @param {Object} actions Actions to register. |
2431 * @param {Object} actions Actions to register. |
2257 * @param {Object} store The redux store to which the actions should be mapped. |
2432 * @param {Object} store The redux store to which the actions should be mapped. |
2258 * @return {Object} Actions mapped to the redux store provided. |
2433 * |
2434 * @return {Object} Actions mapped to the redux store provided. |
|
2259 */ |
2435 */ |
2260 |
2436 |
2261 |
2437 |
2262 function mapActions(actions, store) { |
2438 function mapActions(actions, store) { |
2263 const createBoundAction = action => (...args) => { |
2439 const createBoundAction = action => function () { |
2264 return Promise.resolve(store.dispatch(action(...args))); |
2440 return Promise.resolve(store.dispatch(action(...arguments))); |
2265 }; |
2441 }; |
2266 |
2442 |
2267 return Object(external_lodash_["mapValues"])(actions, createBoundAction); |
2443 return (0,external_lodash_namespaceObject.mapValues)(actions, createBoundAction); |
2268 } |
2444 } |
2269 /** |
2445 /** |
2270 * Maps selectors to functions that return a resolution promise for them |
2446 * Maps selectors to functions that return a resolution promise for them |
2271 * |
2447 * |
2272 * @param {Object} selectors Selectors to map. |
2448 * @param {Object} selectors Selectors to map. |
2273 * @param {Object} store The redux store the selectors select from. |
2449 * @param {Object} store The redux store the selectors select from. |
2274 * @return {Object} Selectors mapped to their resolution functions. |
2450 * |
2451 * @return {Object} Selectors mapped to their resolution functions. |
|
2275 */ |
2452 */ |
2276 |
2453 |
2277 |
2454 |
2278 function mapResolveSelectors(selectors, store) { |
2455 function mapResolveSelectors(selectors, store) { |
2279 return Object(external_lodash_["mapValues"])(Object(external_lodash_["omit"])(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers']), (selector, selectorName) => (...args) => new Promise(resolve => { |
2456 const storeSelectors = (0,external_lodash_namespaceObject.omit)(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'hasResolutionFailed', 'isResolving', 'getCachedResolvers', 'getResolutionState', 'getResolutionError']); |
2280 const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); |
2457 return (0,external_lodash_namespaceObject.mapValues)(storeSelectors, (selector, selectorName) => { |
2281 |
2458 // If the selector doesn't have a resolver, just convert the return value |
2282 const getResult = () => selector.apply(null, args); // trigger the selector (to trigger the resolver) |
2459 // (including exceptions) to a Promise, no additional extra behavior is needed. |
2283 |
2460 if (!selector.hasResolver) { |
2284 |
2461 return async function () { |
2285 const result = getResult(); |
2462 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
2286 |
2463 args[_key3] = arguments[_key3]; |
2287 if (hasFinished()) { |
2464 } |
2288 return resolve(result); |
2465 |
2289 } |
2466 return selector.apply(null, args); |
2290 |
2467 }; |
2291 const unsubscribe = store.subscribe(() => { |
2468 } |
2292 if (hasFinished()) { |
2469 |
2293 unsubscribe(); |
2470 return function () { |
2294 resolve(getResult()); |
2471 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { |
2472 args[_key4] = arguments[_key4]; |
|
2295 } |
2473 } |
2296 }); |
2474 |
2297 })); |
2475 return new Promise((resolve, reject) => { |
2476 const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); |
|
2477 |
|
2478 const finalize = result => { |
|
2479 const hasFailed = selectors.hasResolutionFailed(selectorName, args); |
|
2480 |
|
2481 if (hasFailed) { |
|
2482 const error = selectors.getResolutionError(selectorName, args); |
|
2483 reject(error); |
|
2484 } else { |
|
2485 resolve(result); |
|
2486 } |
|
2487 }; |
|
2488 |
|
2489 const getResult = () => selector.apply(null, args); // Trigger the selector (to trigger the resolver) |
|
2490 |
|
2491 |
|
2492 const result = getResult(); |
|
2493 |
|
2494 if (hasFinished()) { |
|
2495 return finalize(result); |
|
2496 } |
|
2497 |
|
2498 const unsubscribe = store.subscribe(() => { |
|
2499 if (hasFinished()) { |
|
2500 unsubscribe(); |
|
2501 finalize(getResult()); |
|
2502 } |
|
2503 }); |
|
2504 }); |
|
2505 }; |
|
2506 }); |
|
2298 } |
2507 } |
2299 /** |
2508 /** |
2300 * Returns resolvers with matched selectors for a given namespace. |
2509 * Returns resolvers with matched selectors for a given namespace. |
2301 * Resolvers are side effects invoked once per argument set of a given selector call, |
2510 * Resolvers are side effects invoked once per argument set of a given selector call, |
2302 * used in ensuring that the data needs for the selector are satisfied. |
2511 * used in ensuring that the data needs for the selector are satisfied. |
2310 |
2519 |
2311 function mapResolvers(resolvers, selectors, store, resolversCache) { |
2520 function mapResolvers(resolvers, selectors, store, resolversCache) { |
2312 // The `resolver` can be either a function that does the resolution, or, in more advanced |
2521 // The `resolver` can be either a function that does the resolution, or, in more advanced |
2313 // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`. |
2522 // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`. |
2314 // Here we normalize the `resolver` function to an object with `fulfill` method. |
2523 // Here we normalize the `resolver` function to an object with `fulfill` method. |
2315 const mappedResolvers = Object(external_lodash_["mapValues"])(resolvers, resolver => { |
2524 const mappedResolvers = (0,external_lodash_namespaceObject.mapValues)(resolvers, resolver => { |
2316 if (resolver.fulfill) { |
2525 if (resolver.fulfill) { |
2317 return resolver; |
2526 return resolver; |
2318 } |
2527 } |
2319 |
2528 |
2320 return { ...resolver, |
2529 return { ...resolver, |
2321 // copy the enumerable properties of the resolver function |
2530 // Copy the enumerable properties of the resolver function. |
2322 fulfill: resolver // add the fulfill method |
2531 fulfill: resolver // Add the fulfill method. |
2323 |
2532 |
2324 }; |
2533 }; |
2325 }); |
2534 }); |
2326 |
2535 |
2327 const mapSelector = (selector, selectorName) => { |
2536 const mapSelector = (selector, selectorName) => { |
2330 if (!resolver) { |
2539 if (!resolver) { |
2331 selector.hasResolver = false; |
2540 selector.hasResolver = false; |
2332 return selector; |
2541 return selector; |
2333 } |
2542 } |
2334 |
2543 |
2335 const selectorResolver = (...args) => { |
2544 const selectorResolver = function () { |
2545 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { |
|
2546 args[_key5] = arguments[_key5]; |
|
2547 } |
|
2548 |
|
2336 async function fulfillSelector() { |
2549 async function fulfillSelector() { |
2337 const state = store.getState(); |
2550 const state = store.getState(); |
2338 |
2551 |
2339 if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) { |
2552 if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) { |
2340 return; |
2553 return; |
2350 |
2563 |
2351 resolversCache.markAsRunning(selectorName, args); |
2564 resolversCache.markAsRunning(selectorName, args); |
2352 setTimeout(async () => { |
2565 setTimeout(async () => { |
2353 resolversCache.clear(selectorName, args); |
2566 resolversCache.clear(selectorName, args); |
2354 store.dispatch(startResolution(selectorName, args)); |
2567 store.dispatch(startResolution(selectorName, args)); |
2355 await fulfillResolver(store, mappedResolvers, selectorName, ...args); |
2568 |
2356 store.dispatch(finishResolution(selectorName, args)); |
2569 try { |
2570 await fulfillResolver(store, mappedResolvers, selectorName, ...args); |
|
2571 store.dispatch(finishResolution(selectorName, args)); |
|
2572 } catch (error) { |
|
2573 store.dispatch(failResolution(selectorName, args, error)); |
|
2574 } |
|
2357 }); |
2575 }); |
2358 } |
2576 } |
2359 |
2577 |
2360 fulfillSelector(...args); |
2578 fulfillSelector(...args); |
2361 return selector(...args); |
2579 return selector(...args); |
2365 return selectorResolver; |
2583 return selectorResolver; |
2366 }; |
2584 }; |
2367 |
2585 |
2368 return { |
2586 return { |
2369 resolvers: mappedResolvers, |
2587 resolvers: mappedResolvers, |
2370 selectors: Object(external_lodash_["mapValues"])(selectors, mapSelector) |
2588 selectors: (0,external_lodash_namespaceObject.mapValues)(selectors, mapSelector) |
2371 }; |
2589 }; |
2372 } |
2590 } |
2373 /** |
2591 /** |
2374 * Calls a resolver given arguments |
2592 * Calls a resolver given arguments |
2375 * |
2593 * |
2376 * @param {Object} store Store reference, for fulfilling via resolvers |
2594 * @param {Object} store Store reference, for fulfilling via resolvers |
2377 * @param {Object} resolvers Store Resolvers |
2595 * @param {Object} resolvers Store Resolvers |
2378 * @param {string} selectorName Selector name to fulfill. |
2596 * @param {string} selectorName Selector name to fulfill. |
2379 * @param {Array} args Selector Arguments. |
2597 * @param {Array} args Selector Arguments. |
2380 */ |
2598 */ |
2381 |
2599 |
2382 |
2600 |
2383 async function fulfillResolver(store, resolvers, selectorName, ...args) { |
2601 async function fulfillResolver(store, resolvers, selectorName) { |
2384 const resolver = Object(external_lodash_["get"])(resolvers, [selectorName]); |
2602 const resolver = (0,external_lodash_namespaceObject.get)(resolvers, [selectorName]); |
2385 |
2603 |
2386 if (!resolver) { |
2604 if (!resolver) { |
2387 return; |
2605 return; |
2388 } |
2606 } |
2389 |
2607 |
2608 for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) { |
|
2609 args[_key6 - 3] = arguments[_key6]; |
|
2610 } |
|
2611 |
|
2390 const action = resolver.fulfill(...args); |
2612 const action = resolver.fulfill(...args); |
2391 |
2613 |
2392 if (action) { |
2614 if (action) { |
2393 await store.dispatch(action); |
2615 await store.dispatch(action); |
2394 } |
2616 } |
2395 } |
2617 } |
2396 |
2618 |
2397 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js |
2619 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js |
2398 function createCoreDataStore(registry) { |
2620 /** |
2399 const getCoreDataSelector = selectorName => (key, ...args) => { |
2621 * Create an event emitter. |
2400 return registry.select(key)[selectorName](...args); |
2622 * |
2623 * @return {import("../types").DataEmitter} Emitter. |
|
2624 */ |
|
2625 function createEmitter() { |
|
2626 let isPaused = false; |
|
2627 let isPending = false; |
|
2628 const listeners = new Set(); |
|
2629 |
|
2630 const notifyListeners = () => // We use Array.from to clone the listeners Set |
|
2631 // This ensures that we don't run a listener |
|
2632 // that was added as a response to another listener. |
|
2633 Array.from(listeners).forEach(listener => listener()); |
|
2634 |
|
2635 return { |
|
2636 get isPaused() { |
|
2637 return isPaused; |
|
2638 }, |
|
2639 |
|
2640 subscribe(listener) { |
|
2641 listeners.add(listener); |
|
2642 return () => listeners.delete(listener); |
|
2643 }, |
|
2644 |
|
2645 pause() { |
|
2646 isPaused = true; |
|
2647 }, |
|
2648 |
|
2649 resume() { |
|
2650 isPaused = false; |
|
2651 |
|
2652 if (isPending) { |
|
2653 isPending = false; |
|
2654 notifyListeners(); |
|
2655 } |
|
2656 }, |
|
2657 |
|
2658 emit() { |
|
2659 if (isPaused) { |
|
2660 isPending = true; |
|
2661 return; |
|
2662 } |
|
2663 |
|
2664 notifyListeners(); |
|
2665 } |
|
2666 |
|
2401 }; |
2667 }; |
2402 |
2668 } |
2403 const getCoreDataAction = actionName => (key, ...args) => { |
2669 |
2404 return registry.dispatch(key)[actionName](...args); |
2670 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js |
2405 }; |
|
2406 |
|
2407 return { |
|
2408 getSelectors() { |
|
2409 return ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].reduce((memo, selectorName) => ({ ...memo, |
|
2410 [selectorName]: getCoreDataSelector(selectorName) |
|
2411 }), {}); |
|
2412 }, |
|
2413 |
|
2414 getActions() { |
|
2415 return ['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].reduce((memo, actionName) => ({ ...memo, |
|
2416 [actionName]: getCoreDataAction(actionName) |
|
2417 }), {}); |
|
2418 }, |
|
2419 |
|
2420 subscribe() { |
|
2421 // There's no reasons to trigger any listener when we subscribe to this store |
|
2422 // because there's no state stored in this store that need to retrigger selectors |
|
2423 // if a change happens, the corresponding store where the tracking stated live |
|
2424 // would have already triggered a "subscribe" call. |
|
2425 return () => {}; |
|
2426 } |
|
2427 |
|
2428 }; |
|
2429 } |
|
2430 |
|
2431 /* harmony default export */ var build_module_store = (createCoreDataStore); |
|
2432 |
|
2433 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js |
|
2434 /** |
2671 /** |
2435 * External dependencies |
2672 * External dependencies |
2436 */ |
2673 */ |
2437 |
2674 |
2438 /** |
2675 /** |
2676 * WordPress dependencies |
|
2677 */ |
|
2678 |
|
2679 |
|
2680 /** |
|
2439 * Internal dependencies |
2681 * Internal dependencies |
2440 */ |
2682 */ |
2441 |
2683 |
2442 |
2684 |
2443 |
2685 |
2444 /** @typedef {import('./types').WPDataStore} WPDataStore */ |
2686 |
2687 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
|
2445 |
2688 |
2446 /** |
2689 /** |
2447 * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. |
2690 * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. |
2448 * |
2691 * |
2449 * @property {Function} registerGenericStore Given a namespace key and settings |
2692 * @property {Function} registerGenericStore Given a namespace key and settings |
2477 * @param {Object?} parent Parent registry. |
2720 * @param {Object?} parent Parent registry. |
2478 * |
2721 * |
2479 * @return {WPDataRegistry} Data registry. |
2722 * @return {WPDataRegistry} Data registry. |
2480 */ |
2723 */ |
2481 |
2724 |
2482 function createRegistry(storeConfigs = {}, parent = null) { |
2725 function createRegistry() { |
2726 let storeConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
2727 let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
|
2483 const stores = {}; |
2728 const stores = {}; |
2484 let listeners = []; |
2729 const emitter = createEmitter(); |
2485 |
2730 const listeningStores = new Set(); |
2486 const __experimentalListeningStores = new Set(); |
|
2487 /** |
2731 /** |
2488 * Global listener called for each store's update. |
2732 * Global listener called for each store's update. |
2489 */ |
2733 */ |
2490 |
2734 |
2491 |
|
2492 function globalListener() { |
2735 function globalListener() { |
2493 listeners.forEach(listener => listener()); |
2736 emitter.emit(); |
2494 } |
2737 } |
2495 /** |
2738 /** |
2496 * Subscribe to changes to any data. |
2739 * Subscribe to changes to any data. |
2497 * |
2740 * |
2498 * @param {Function} listener Listener function. |
2741 * @param {Function} listener Listener function. |
2499 * |
2742 * |
2500 * @return {Function} Unsubscribe function. |
2743 * @return {Function} Unsubscribe function. |
2501 */ |
2744 */ |
2502 |
2745 |
2503 |
2746 |
2504 const subscribe = listener => { |
2747 const subscribe = listener => { |
2505 listeners.push(listener); |
2748 return emitter.subscribe(listener); |
2506 return () => { |
|
2507 listeners = Object(external_lodash_["without"])(listeners, listener); |
|
2508 }; |
|
2509 }; |
2749 }; |
2510 /** |
2750 /** |
2511 * Calls a selector given the current state and extra arguments. |
2751 * Calls a selector given the current state and extra arguments. |
2512 * |
2752 * |
2513 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
2753 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
2514 * or the store definition. |
2754 * or the store descriptor. |
2515 * |
2755 * |
2516 * @return {*} The selector's returned value. |
2756 * @return {*} The selector's returned value. |
2517 */ |
2757 */ |
2518 |
2758 |
2519 |
2759 |
2520 function select(storeNameOrDefinition) { |
2760 function select(storeNameOrDescriptor) { |
2521 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; |
2761 const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; |
2522 |
2762 listeningStores.add(storeName); |
2523 __experimentalListeningStores.add(storeName); |
|
2524 |
|
2525 const store = stores[storeName]; |
2763 const store = stores[storeName]; |
2526 |
2764 |
2527 if (store) { |
2765 if (store) { |
2528 return store.getSelectors(); |
2766 return store.getSelectors(); |
2529 } |
2767 } |
2530 |
2768 |
2531 return parent && parent.select(storeName); |
2769 return parent && parent.select(storeName); |
2532 } |
2770 } |
2533 |
2771 |
2534 function __experimentalMarkListeningStores(callback, ref) { |
2772 function __unstableMarkListeningStores(callback, ref) { |
2535 __experimentalListeningStores.clear(); |
2773 listeningStores.clear(); |
2536 |
|
2537 const result = callback.call(this); |
2774 const result = callback.call(this); |
2538 ref.current = Array.from(__experimentalListeningStores); |
2775 ref.current = Array.from(listeningStores); |
2539 return result; |
2776 return result; |
2540 } |
2777 } |
2541 /** |
2778 /** |
2542 * Given the name of a registered store, returns an object containing the store's |
2779 * Given the name of a registered store, returns an object containing the store's |
2543 * selectors pre-bound to state so that you only need to supply additional arguments, |
2780 * selectors pre-bound to state so that you only need to supply additional arguments, |
2544 * and modified so that they return promises that resolve to their eventual values, |
2781 * and modified so that they return promises that resolve to their eventual values, |
2545 * after any resolvers have ran. |
2782 * after any resolvers have ran. |
2546 * |
2783 * |
2547 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
2784 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
2548 * or the store definition. |
2785 * or the store descriptor. |
2549 * |
2786 * |
2550 * @return {Object} Each key of the object matches the name of a selector. |
2787 * @return {Object} Each key of the object matches the name of a selector. |
2551 */ |
2788 */ |
2552 |
2789 |
2553 |
2790 |
2554 function resolveSelect(storeNameOrDefinition) { |
2791 function resolveSelect(storeNameOrDescriptor) { |
2555 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; |
2792 const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; |
2556 |
2793 listeningStores.add(storeName); |
2557 __experimentalListeningStores.add(storeName); |
|
2558 |
|
2559 const store = stores[storeName]; |
2794 const store = stores[storeName]; |
2560 |
2795 |
2561 if (store) { |
2796 if (store) { |
2562 return store.getResolveSelectors(); |
2797 return store.getResolveSelectors(); |
2563 } |
2798 } |
2565 return parent && parent.resolveSelect(storeName); |
2800 return parent && parent.resolveSelect(storeName); |
2566 } |
2801 } |
2567 /** |
2802 /** |
2568 * Returns the available actions for a part of the state. |
2803 * Returns the available actions for a part of the state. |
2569 * |
2804 * |
2570 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
2805 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
2571 * or the store definition. |
2806 * or the store descriptor. |
2572 * |
2807 * |
2573 * @return {*} The action's returned value. |
2808 * @return {*} The action's returned value. |
2574 */ |
2809 */ |
2575 |
2810 |
2576 |
2811 |
2577 function dispatch(storeNameOrDefinition) { |
2812 function dispatch(storeNameOrDescriptor) { |
2578 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; |
2813 const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; |
2579 const store = stores[storeName]; |
2814 const store = stores[storeName]; |
2580 |
2815 |
2581 if (store) { |
2816 if (store) { |
2582 return store.getActions(); |
2817 return store.getActions(); |
2583 } |
2818 } |
2584 |
2819 |
2585 return parent && parent.dispatch(storeName); |
2820 return parent && parent.dispatch(storeName); |
2586 } // |
2821 } // |
2587 // Deprecated |
2822 // Deprecated |
2588 // TODO: Remove this after `use()` is removed. |
2823 // TODO: Remove this after `use()` is removed. |
2589 // |
|
2590 |
2824 |
2591 |
2825 |
2592 function withPlugins(attributes) { |
2826 function withPlugins(attributes) { |
2593 return Object(external_lodash_["mapValues"])(attributes, (attribute, key) => { |
2827 return (0,external_lodash_namespaceObject.mapValues)(attributes, (attribute, key) => { |
2594 if (typeof attribute !== 'function') { |
2828 if (typeof attribute !== 'function') { |
2595 return attribute; |
2829 return attribute; |
2596 } |
2830 } |
2597 |
2831 |
2598 return function () { |
2832 return function () { |
2599 return registry[key].apply(null, arguments); |
2833 return registry[key].apply(null, arguments); |
2600 }; |
2834 }; |
2601 }); |
2835 }); |
2602 } |
2836 } |
2603 /** |
2837 /** |
2604 * Registers a generic store. |
2838 * Registers a store instance. |
2605 * |
2839 * |
2606 * @param {string} key Store registry key. |
2840 * @param {string} name Store registry name. |
2607 * @param {Object} config Configuration (getSelectors, getActions, subscribe). |
2841 * @param {Object} store Store instance object (getSelectors, getActions, subscribe). |
2608 */ |
2842 */ |
2609 |
2843 |
2610 |
2844 |
2611 function registerGenericStore(key, config) { |
2845 function registerStoreInstance(name, store) { |
2612 if (typeof config.getSelectors !== 'function') { |
2846 if (typeof store.getSelectors !== 'function') { |
2613 throw new TypeError('config.getSelectors must be a function'); |
2847 throw new TypeError('store.getSelectors must be a function'); |
2614 } |
2848 } |
2615 |
2849 |
2616 if (typeof config.getActions !== 'function') { |
2850 if (typeof store.getActions !== 'function') { |
2617 throw new TypeError('config.getActions must be a function'); |
2851 throw new TypeError('store.getActions must be a function'); |
2618 } |
2852 } |
2619 |
2853 |
2620 if (typeof config.subscribe !== 'function') { |
2854 if (typeof store.subscribe !== 'function') { |
2621 throw new TypeError('config.subscribe must be a function'); |
2855 throw new TypeError('store.subscribe must be a function'); |
2622 } |
2856 } // The emitter is used to keep track of active listeners when the registry |
2623 |
2857 // get paused, that way, when resumed we should be able to call all these |
2624 stores[key] = config; |
2858 // pending listeners. |
2625 config.subscribe(globalListener); |
2859 |
2860 |
|
2861 store.emitter = createEmitter(); |
|
2862 const currentSubscribe = store.subscribe; |
|
2863 |
|
2864 store.subscribe = listener => { |
|
2865 const unsubscribeFromEmitter = store.emitter.subscribe(listener); |
|
2866 const unsubscribeFromStore = currentSubscribe(() => { |
|
2867 if (store.emitter.isPaused) { |
|
2868 store.emitter.emit(); |
|
2869 return; |
|
2870 } |
|
2871 |
|
2872 listener(); |
|
2873 }); |
|
2874 return () => { |
|
2875 unsubscribeFromStore === null || unsubscribeFromStore === void 0 ? void 0 : unsubscribeFromStore(); |
|
2876 unsubscribeFromEmitter === null || unsubscribeFromEmitter === void 0 ? void 0 : unsubscribeFromEmitter(); |
|
2877 }; |
|
2878 }; |
|
2879 |
|
2880 stores[name] = store; |
|
2881 store.subscribe(globalListener); |
|
2626 } |
2882 } |
2627 /** |
2883 /** |
2628 * Registers a new store definition. |
2884 * Registers a new store given a store descriptor. |
2629 * |
2885 * |
2630 * @param {WPDataStore} store Store definition. |
2886 * @param {StoreDescriptor} store Store descriptor. |
2631 */ |
2887 */ |
2632 |
2888 |
2633 |
2889 |
2634 function register(store) { |
2890 function register(store) { |
2635 registerGenericStore(store.name, store.instantiate(registry)); |
2891 registerStoreInstance(store.name, store.instantiate(registry)); |
2892 } |
|
2893 |
|
2894 function registerGenericStore(name, store) { |
|
2895 external_wp_deprecated_default()('wp.data.registerGenericStore', { |
|
2896 since: '5.9', |
|
2897 alternative: 'wp.data.register( storeDescriptor )' |
|
2898 }); |
|
2899 registerStoreInstance(name, store); |
|
2900 } |
|
2901 /** |
|
2902 * Registers a standard `@wordpress/data` store. |
|
2903 * |
|
2904 * @param {string} storeName Unique namespace identifier. |
|
2905 * @param {Object} options Store description (reducer, actions, selectors, resolvers). |
|
2906 * |
|
2907 * @return {Object} Registered store object. |
|
2908 */ |
|
2909 |
|
2910 |
|
2911 function registerStore(storeName, options) { |
|
2912 if (!options.reducer) { |
|
2913 throw new TypeError('Must specify store reducer'); |
|
2914 } |
|
2915 |
|
2916 const store = createReduxStore(storeName, options).instantiate(registry); |
|
2917 registerStoreInstance(storeName, store); |
|
2918 return store.store; |
|
2636 } |
2919 } |
2637 /** |
2920 /** |
2638 * Subscribe handler to a store. |
2921 * Subscribe handler to a store. |
2639 * |
2922 * |
2640 * @param {string[]} storeName The store name. |
2923 * @param {string[]} storeName The store name. |
2641 * @param {Function} handler The function subscribed to the store. |
2924 * @param {Function} handler The function subscribed to the store. |
2642 * @return {Function} A function to unsubscribe the handler. |
2925 * @return {Function} A function to unsubscribe the handler. |
2643 */ |
2926 */ |
2644 |
2927 |
2645 |
2928 |
2646 function __experimentalSubscribeStore(storeName, handler) { |
2929 function __unstableSubscribeStore(storeName, handler) { |
2647 if (storeName in stores) { |
2930 if (storeName in stores) { |
2648 return stores[storeName].subscribe(handler); |
2931 return stores[storeName].subscribe(handler); |
2649 } // Trying to access a store that hasn't been registered, |
2932 } // Trying to access a store that hasn't been registered, |
2650 // this is a pattern rarely used but seen in some places. |
2933 // this is a pattern rarely used but seen in some places. |
2651 // We fallback to regular `subscribe` here for backward-compatibility for now. |
2934 // We fallback to regular `subscribe` here for backward-compatibility for now. |
2654 |
2937 |
2655 if (!parent) { |
2938 if (!parent) { |
2656 return subscribe(handler); |
2939 return subscribe(handler); |
2657 } |
2940 } |
2658 |
2941 |
2659 return parent.__experimentalSubscribeStore(storeName, handler); |
2942 return parent.__unstableSubscribeStore(storeName, handler); |
2943 } |
|
2944 |
|
2945 function batch(callback) { |
|
2946 emitter.pause(); |
|
2947 (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.pause()); |
|
2948 callback(); |
|
2949 emitter.resume(); |
|
2950 (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.resume()); |
|
2660 } |
2951 } |
2661 |
2952 |
2662 let registry = { |
2953 let registry = { |
2663 registerGenericStore, |
2954 batch, |
2664 stores, |
2955 stores, |
2665 namespaces: stores, |
2956 namespaces: stores, |
2666 // TODO: Deprecate/remove this. |
2957 // TODO: Deprecate/remove this. |
2667 subscribe, |
2958 subscribe, |
2668 select, |
2959 select, |
2669 resolveSelect, |
2960 resolveSelect, |
2670 dispatch, |
2961 dispatch, |
2671 use, |
2962 use, |
2672 register, |
2963 register, |
2673 __experimentalMarkListeningStores, |
2964 registerGenericStore, |
2674 __experimentalSubscribeStore |
2965 registerStore, |
2675 }; |
2966 __unstableMarkListeningStores, |
2676 /** |
2967 __unstableSubscribeStore |
2677 * Registers a standard `@wordpress/data` store. |
|
2678 * |
|
2679 * @param {string} storeName Unique namespace identifier. |
|
2680 * @param {Object} options Store description (reducer, actions, selectors, resolvers). |
|
2681 * |
|
2682 * @return {Object} Registered store object. |
|
2683 */ |
|
2684 |
|
2685 registry.registerStore = (storeName, options) => { |
|
2686 if (!options.reducer) { |
|
2687 throw new TypeError('Must specify store reducer'); |
|
2688 } |
|
2689 |
|
2690 const store = createReduxStore(storeName, options).instantiate(registry); |
|
2691 registerGenericStore(storeName, store); |
|
2692 return store.store; |
|
2693 }; // |
2968 }; // |
2694 // TODO: |
2969 // TODO: |
2695 // This function will be deprecated as soon as it is no longer internally referenced. |
2970 // This function will be deprecated as soon as it is no longer internally referenced. |
2696 // |
|
2697 |
|
2698 |
2971 |
2699 function use(plugin, options) { |
2972 function use(plugin, options) { |
2973 if (!plugin) { |
|
2974 return; |
|
2975 } |
|
2976 |
|
2700 registry = { ...registry, |
2977 registry = { ...registry, |
2701 ...plugin(registry, options) |
2978 ...plugin(registry, options) |
2702 }; |
2979 }; |
2703 return registry; |
2980 return registry; |
2704 } |
2981 } |
2705 |
2982 |
2706 registerGenericStore('core/data', build_module_store(registry)); |
2983 registry.register(store); |
2707 Object.entries(storeConfigs).forEach(([name, config]) => registry.registerStore(name, config)); |
2984 |
2985 for (const [name, config] of Object.entries(storeConfigs)) { |
|
2986 registry.register(createReduxStore(name, config)); |
|
2987 } |
|
2708 |
2988 |
2709 if (parent) { |
2989 if (parent) { |
2710 parent.subscribe(globalListener); |
2990 parent.subscribe(globalListener); |
2711 } |
2991 } |
2712 |
2992 |
2713 return withPlugins(registry); |
2993 return withPlugins(registry); |
2714 } |
2994 } |
2715 |
2995 |
2716 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js |
2996 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js |
2717 /** |
2997 /** |
2718 * Internal dependencies |
2998 * Internal dependencies |
2719 */ |
2999 */ |
2720 |
3000 |
2721 /* harmony default export */ var default_registry = (createRegistry()); |
3001 /* harmony default export */ var default_registry = (createRegistry()); |
2722 |
3002 |
2723 // EXTERNAL MODULE: external ["wp","deprecated"] |
3003 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js |
2724 var external_wp_deprecated_ = __webpack_require__("NMb1"); |
|
2725 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); |
|
2726 |
|
2727 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/controls/index.js |
|
2728 /** |
|
2729 * WordPress dependencies |
|
2730 */ |
|
2731 |
|
2732 /* harmony default export */ var plugins_controls = (registry => { |
|
2733 external_wp_deprecated_default()('wp.data.plugins.controls', { |
|
2734 since: '5.4', |
|
2735 hint: 'The controls plugins is now baked-in.' |
|
2736 }); |
|
2737 return registry; |
|
2738 }); |
|
2739 |
|
2740 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js |
|
2741 let objectStorage; |
3004 let objectStorage; |
2742 const storage = { |
3005 const storage = { |
2743 getItem(key) { |
3006 getItem(key) { |
2744 if (!objectStorage || !objectStorage[key]) { |
3007 if (!objectStorage || !objectStorage[key]) { |
2745 return null; |
3008 return null; |
2761 } |
3024 } |
2762 |
3025 |
2763 }; |
3026 }; |
2764 /* harmony default export */ var object = (storage); |
3027 /* harmony default export */ var object = (storage); |
2765 |
3028 |
2766 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js |
3029 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js |
2767 /** |
3030 /** |
2768 * Internal dependencies |
3031 * Internal dependencies |
2769 */ |
3032 */ |
2770 |
3033 |
2771 let default_storage; |
3034 let default_storage; |
2781 default_storage = object; |
3044 default_storage = object; |
2782 } |
3045 } |
2783 |
3046 |
2784 /* harmony default export */ var storage_default = (default_storage); |
3047 /* harmony default export */ var storage_default = (default_storage); |
2785 |
3048 |
2786 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js |
3049 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js |
2787 /** |
3050 /** |
2788 * External dependencies |
3051 * External dependencies |
2789 */ |
3052 */ |
2790 |
3053 |
2791 /** |
3054 /** |
2967 if (persistedState !== undefined) { |
3230 if (persistedState !== undefined) { |
2968 let initialState = options.reducer(options.initialState, { |
3231 let initialState = options.reducer(options.initialState, { |
2969 type: '@@WP/PERSISTENCE_RESTORE' |
3232 type: '@@WP/PERSISTENCE_RESTORE' |
2970 }); |
3233 }); |
2971 |
3234 |
2972 if (Object(external_lodash_["isPlainObject"])(initialState) && Object(external_lodash_["isPlainObject"])(persistedState)) { |
3235 if ((0,external_lodash_namespaceObject.isPlainObject)(initialState) && (0,external_lodash_namespaceObject.isPlainObject)(persistedState)) { |
2973 // If state is an object, ensure that: |
3236 // If state is an object, ensure that: |
2974 // - Other keys are left intact when persisting only a |
3237 // - Other keys are left intact when persisting only a |
2975 // subset of keys. |
3238 // subset of keys. |
2976 // - New keys in what would otherwise be used as initial |
3239 // - New keys in what would otherwise be used as initial |
2977 // state are deeply merged as base for persisted value. |
3240 // state are deeply merged as base for persisted value. |
2978 initialState = Object(external_lodash_["merge"])({}, initialState, persistedState); |
3241 initialState = (0,external_lodash_namespaceObject.merge)({}, initialState, persistedState); |
2979 } else { |
3242 } else { |
2980 // If there is a mismatch in object-likeness of default |
3243 // If there is a mismatch in object-likeness of default |
2981 // initial or persisted state, defer to persisted value. |
3244 // initial or persisted state, defer to persisted value. |
2982 initialState = persistedState; |
3245 initialState = persistedState; |
2983 } |
3246 } |
2993 } |
3256 } |
2994 |
3257 |
2995 }; |
3258 }; |
2996 } |
3259 } |
2997 /** |
3260 /** |
2998 * Deprecated: Remove this function and the code in WordPress Core that calls |
3261 * Move the 'features' object in local storage from the sourceStoreName to the |
2999 * it once WordPress 5.4 is released. |
3262 * preferences store. |
3000 */ |
3263 * |
3001 |
3264 * @param {Object} persistence The persistence interface. |
3002 |
3265 * @param {string} sourceStoreName The name of the store that has persisted |
3003 persistencePlugin.__unstableMigrate = pluginOptions => { |
3266 * preferences to migrate to the preferences |
3004 var _state$coreEditor, _state$coreEditor$pre; |
3267 * package. |
3005 |
3268 */ |
3006 const persistence = createPersistenceInterface(pluginOptions); |
3269 |
3007 const state = persistence.get(); // Migrate 'insertUsage' from 'core/editor' to 'core/block-editor' |
3270 |
3008 |
3271 function migrateFeaturePreferencesToPreferencesStore(persistence, sourceStoreName) { |
3009 const editorInsertUsage = (_state$coreEditor = state['core/editor']) === null || _state$coreEditor === void 0 ? void 0 : (_state$coreEditor$pre = _state$coreEditor.preferences) === null || _state$coreEditor$pre === void 0 ? void 0 : _state$coreEditor$pre.insertUsage; |
3272 var _state$interfaceStore, _state$interfaceStore2, _state$interfaceStore3, _state$sourceStoreNam, _state$sourceStoreNam2; |
3010 |
3273 |
3011 if (editorInsertUsage) { |
3274 const preferencesStoreName = 'core/preferences'; |
3012 var _state$coreBlockEdi, _state$coreBlockEdi$p; |
3275 const interfaceStoreName = 'core/interface'; |
3013 |
3276 const state = persistence.get(); // Features most recently (and briefly) lived in the interface package. |
3014 const blockEditorInsertUsage = (_state$coreBlockEdi = state['core/block-editor']) === null || _state$coreBlockEdi === void 0 ? void 0 : (_state$coreBlockEdi$p = _state$coreBlockEdi.preferences) === null || _state$coreBlockEdi$p === void 0 ? void 0 : _state$coreBlockEdi$p.insertUsage; |
3277 // If data exists there, prioritize using that for the migration. If not |
3015 persistence.set('core/block-editor', { |
3278 // also check the original package as the user may have updated from an |
3279 // older block editor version. |
|
3280 |
|
3281 const interfaceFeatures = (_state$interfaceStore = state[interfaceStoreName]) === null || _state$interfaceStore === void 0 ? void 0 : (_state$interfaceStore2 = _state$interfaceStore.preferences) === null || _state$interfaceStore2 === void 0 ? void 0 : (_state$interfaceStore3 = _state$interfaceStore2.features) === null || _state$interfaceStore3 === void 0 ? void 0 : _state$interfaceStore3[sourceStoreName]; |
|
3282 const sourceFeatures = (_state$sourceStoreNam = state[sourceStoreName]) === null || _state$sourceStoreNam === void 0 ? void 0 : (_state$sourceStoreNam2 = _state$sourceStoreNam.preferences) === null || _state$sourceStoreNam2 === void 0 ? void 0 : _state$sourceStoreNam2.features; |
|
3283 const featuresToMigrate = interfaceFeatures ? interfaceFeatures : sourceFeatures; |
|
3284 |
|
3285 if (featuresToMigrate) { |
|
3286 var _state$preferencesSto; |
|
3287 |
|
3288 const existingPreferences = (_state$preferencesSto = state[preferencesStoreName]) === null || _state$preferencesSto === void 0 ? void 0 : _state$preferencesSto.preferences; // Avoid migrating features again if they've previously been migrated. |
|
3289 |
|
3290 if (!(existingPreferences !== null && existingPreferences !== void 0 && existingPreferences[sourceStoreName])) { |
|
3291 // Set the feature values in the interface store, the features |
|
3292 // object is keyed by 'scope', which matches the store name for |
|
3293 // the source. |
|
3294 persistence.set(preferencesStoreName, { |
|
3295 preferences: { ...existingPreferences, |
|
3296 [sourceStoreName]: featuresToMigrate |
|
3297 } |
|
3298 }); // Remove migrated feature preferences from `interface`. |
|
3299 |
|
3300 if (interfaceFeatures) { |
|
3301 var _state$interfaceStore4, _state$interfaceStore5; |
|
3302 |
|
3303 const otherInterfaceState = state[interfaceStoreName]; |
|
3304 const otherInterfaceScopes = (_state$interfaceStore4 = state[interfaceStoreName]) === null || _state$interfaceStore4 === void 0 ? void 0 : (_state$interfaceStore5 = _state$interfaceStore4.preferences) === null || _state$interfaceStore5 === void 0 ? void 0 : _state$interfaceStore5.features; |
|
3305 persistence.set(interfaceStoreName, { ...otherInterfaceState, |
|
3306 preferences: { |
|
3307 features: { ...otherInterfaceScopes, |
|
3308 [sourceStoreName]: undefined |
|
3309 } |
|
3310 } |
|
3311 }); |
|
3312 } // Remove migrated feature preferences from the source. |
|
3313 |
|
3314 |
|
3315 if (sourceFeatures) { |
|
3316 var _state$sourceStoreNam3; |
|
3317 |
|
3318 const otherSourceState = state[sourceStoreName]; |
|
3319 const sourcePreferences = (_state$sourceStoreNam3 = state[sourceStoreName]) === null || _state$sourceStoreNam3 === void 0 ? void 0 : _state$sourceStoreNam3.preferences; |
|
3320 persistence.set(sourceStoreName, { ...otherSourceState, |
|
3321 preferences: { ...sourcePreferences, |
|
3322 features: undefined |
|
3323 } |
|
3324 }); |
|
3325 } |
|
3326 } |
|
3327 } |
|
3328 } |
|
3329 /** |
|
3330 * Migrates an individual item inside the `preferences` object for a store. |
|
3331 * |
|
3332 * @param {Object} persistence The persistence interface. |
|
3333 * @param {Object} migrate An options object that contains details of the migration. |
|
3334 * @param {string} migrate.from The name of the store to migrate from. |
|
3335 * @param {string} migrate.scope The scope in the preferences store to migrate to. |
|
3336 * @param {string} key The key in the preferences object to migrate. |
|
3337 * @param {?Function} convert A function that converts preferences from one format to another. |
|
3338 */ |
|
3339 |
|
3340 function migrateIndividualPreferenceToPreferencesStore(persistence, _ref, key) { |
|
3341 var _state$sourceStoreNam4, _state$sourceStoreNam5, _state$preferencesSto2, _state$preferencesSto3, _state$preferencesSto4, _state$preferencesSto5, _state$preferencesSto6, _state$preferencesSto7, _state$sourceStoreNam6; |
|
3342 |
|
3343 let { |
|
3344 from: sourceStoreName, |
|
3345 scope |
|
3346 } = _ref; |
|
3347 let convert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : external_lodash_namespaceObject.identity; |
|
3348 const preferencesStoreName = 'core/preferences'; |
|
3349 const state = persistence.get(); |
|
3350 const sourcePreference = (_state$sourceStoreNam4 = state[sourceStoreName]) === null || _state$sourceStoreNam4 === void 0 ? void 0 : (_state$sourceStoreNam5 = _state$sourceStoreNam4.preferences) === null || _state$sourceStoreNam5 === void 0 ? void 0 : _state$sourceStoreNam5[key]; // There's nothing to migrate, exit early. |
|
3351 |
|
3352 if (sourcePreference === undefined) { |
|
3353 return; |
|
3354 } |
|
3355 |
|
3356 const targetPreference = (_state$preferencesSto2 = state[preferencesStoreName]) === null || _state$preferencesSto2 === void 0 ? void 0 : (_state$preferencesSto3 = _state$preferencesSto2.preferences) === null || _state$preferencesSto3 === void 0 ? void 0 : (_state$preferencesSto4 = _state$preferencesSto3[scope]) === null || _state$preferencesSto4 === void 0 ? void 0 : _state$preferencesSto4[key]; // There's existing data at the target, so don't overwrite it, exit early. |
|
3357 |
|
3358 if (targetPreference) { |
|
3359 return; |
|
3360 } |
|
3361 |
|
3362 const otherScopes = (_state$preferencesSto5 = state[preferencesStoreName]) === null || _state$preferencesSto5 === void 0 ? void 0 : _state$preferencesSto5.preferences; |
|
3363 const otherPreferences = (_state$preferencesSto6 = state[preferencesStoreName]) === null || _state$preferencesSto6 === void 0 ? void 0 : (_state$preferencesSto7 = _state$preferencesSto6.preferences) === null || _state$preferencesSto7 === void 0 ? void 0 : _state$preferencesSto7[scope]; // Pass an object with the key and value as this allows the convert |
|
3364 // function to convert to a data structure that has different keys. |
|
3365 |
|
3366 const convertedPreferences = convert({ |
|
3367 [key]: sourcePreference |
|
3368 }); |
|
3369 persistence.set(preferencesStoreName, { |
|
3370 preferences: { ...otherScopes, |
|
3371 [scope]: { ...otherPreferences, |
|
3372 ...convertedPreferences |
|
3373 } |
|
3374 } |
|
3375 }); // Remove migrated feature preferences from the source. |
|
3376 |
|
3377 const otherSourceState = state[sourceStoreName]; |
|
3378 const allSourcePreferences = (_state$sourceStoreNam6 = state[sourceStoreName]) === null || _state$sourceStoreNam6 === void 0 ? void 0 : _state$sourceStoreNam6.preferences; |
|
3379 persistence.set(sourceStoreName, { ...otherSourceState, |
|
3380 preferences: { ...allSourcePreferences, |
|
3381 [key]: undefined |
|
3382 } |
|
3383 }); |
|
3384 } |
|
3385 /** |
|
3386 * Convert from: |
|
3387 * ``` |
|
3388 * { |
|
3389 * panels: { |
|
3390 * tags: { |
|
3391 * enabled: true, |
|
3392 * opened: true, |
|
3393 * }, |
|
3394 * permalinks: { |
|
3395 * enabled: false, |
|
3396 * opened: false, |
|
3397 * }, |
|
3398 * }, |
|
3399 * } |
|
3400 * ``` |
|
3401 * |
|
3402 * to: |
|
3403 * { |
|
3404 * inactivePanels: [ |
|
3405 * 'permalinks', |
|
3406 * ], |
|
3407 * openPanels: [ |
|
3408 * 'tags', |
|
3409 * ], |
|
3410 * } |
|
3411 * |
|
3412 * @param {Object} preferences A preferences object. |
|
3413 * |
|
3414 * @return {Object} The converted data. |
|
3415 */ |
|
3416 |
|
3417 function convertEditPostPanels(preferences) { |
|
3418 var _preferences$panels; |
|
3419 |
|
3420 const panels = (_preferences$panels = preferences === null || preferences === void 0 ? void 0 : preferences.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {}; |
|
3421 return Object.keys(panels).reduce((convertedData, panelName) => { |
|
3422 const panel = panels[panelName]; |
|
3423 |
|
3424 if ((panel === null || panel === void 0 ? void 0 : panel.enabled) === false) { |
|
3425 convertedData.inactivePanels.push(panelName); |
|
3426 } |
|
3427 |
|
3428 if ((panel === null || panel === void 0 ? void 0 : panel.opened) === true) { |
|
3429 convertedData.openPanels.push(panelName); |
|
3430 } |
|
3431 |
|
3432 return convertedData; |
|
3433 }, { |
|
3434 inactivePanels: [], |
|
3435 openPanels: [] |
|
3436 }); |
|
3437 } |
|
3438 function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) { |
|
3439 var _state$interfaceStore6, _state$interfaceStore7; |
|
3440 |
|
3441 const interfaceStoreName = 'core/interface'; |
|
3442 const preferencesStoreName = 'core/preferences'; |
|
3443 let state = persistence.get(); |
|
3444 const interfaceScopes = (_state$interfaceStore6 = state[interfaceStoreName]) === null || _state$interfaceStore6 === void 0 ? void 0 : (_state$interfaceStore7 = _state$interfaceStore6.preferences) === null || _state$interfaceStore7 === void 0 ? void 0 : _state$interfaceStore7.features; |
|
3445 |
|
3446 for (const scope in interfaceScopes) { |
|
3447 var _state$preferencesSto8, _state$interfaceStore8, _state$interfaceStore9; |
|
3448 |
|
3449 // Don't migrate any core 'scopes'. |
|
3450 if (scope.startsWith('core')) { |
|
3451 continue; |
|
3452 } // Skip this scope if there are no features to migrate. |
|
3453 |
|
3454 |
|
3455 const featuresToMigrate = interfaceScopes[scope]; |
|
3456 |
|
3457 if (!featuresToMigrate) { |
|
3458 continue; |
|
3459 } |
|
3460 |
|
3461 const existingPreferences = (_state$preferencesSto8 = state[preferencesStoreName]) === null || _state$preferencesSto8 === void 0 ? void 0 : _state$preferencesSto8.preferences; // Add the data to the preferences store structure. |
|
3462 |
|
3463 persistence.set(preferencesStoreName, { |
|
3464 preferences: { ...existingPreferences, |
|
3465 [scope]: featuresToMigrate |
|
3466 } |
|
3467 }); // Remove the data from the interface store structure. |
|
3468 // Call `persistence.get` again to make sure `state` is up-to-date with |
|
3469 // any changes from the previous iteration of this loop. |
|
3470 |
|
3471 state = persistence.get(); |
|
3472 const otherInterfaceState = state[interfaceStoreName]; |
|
3473 const otherInterfaceScopes = (_state$interfaceStore8 = state[interfaceStoreName]) === null || _state$interfaceStore8 === void 0 ? void 0 : (_state$interfaceStore9 = _state$interfaceStore8.preferences) === null || _state$interfaceStore9 === void 0 ? void 0 : _state$interfaceStore9.features; |
|
3474 persistence.set(interfaceStoreName, { ...otherInterfaceState, |
|
3016 preferences: { |
3475 preferences: { |
3017 insertUsage: { ...editorInsertUsage, |
3476 features: { ...otherInterfaceScopes, |
3018 ...blockEditorInsertUsage |
3477 [scope]: undefined |
3019 } |
3478 } |
3020 } |
3479 } |
3021 }); |
3480 }); |
3022 } |
3481 } |
3023 |
3482 } |
3024 let editPostState = state['core/edit-post']; // Default `fullscreenMode` to `false` if any persisted state had existed |
3483 /** |
3025 // and the user hadn't made an explicit choice about fullscreen mode. This |
3484 * Migrates interface 'enableItems' data to the preferences store. |
3026 // is needed since `fullscreenMode` previously did not have a default value |
3485 * |
3027 // and was implicitly false by its absence. It is now `true` by default, but |
3486 * The interface package stores this data in this format: |
3028 // this change is not intended to affect upgrades from earlier versions. |
3487 * ```js |
3029 |
3488 * { |
3030 const hadPersistedState = Object.keys(state).length > 0; |
3489 * enableItems: { |
3031 const hadFullscreenModePreference = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'fullscreenMode']); |
3490 * singleEnableItems: { |
3032 |
3491 * complementaryArea: { |
3033 if (hadPersistedState && !hadFullscreenModePreference) { |
3492 * 'core/edit-post': 'edit-post/document', |
3034 editPostState = Object(external_lodash_["merge"])({}, editPostState, { |
3493 * 'core/edit-site': 'edit-site/global-styles', |
3035 preferences: { |
3494 * } |
3036 features: { |
3495 * }, |
3037 fullscreenMode: false |
3496 * multipleEnableItems: { |
3497 * pinnedItems: { |
|
3498 * 'core/edit-post': { |
|
3499 * 'plugin-1': true, |
|
3500 * }, |
|
3501 * 'core/edit-site': { |
|
3502 * 'plugin-2': true, |
|
3503 * }, |
|
3504 * }, |
|
3505 * } |
|
3506 * } |
|
3507 * } |
|
3508 * ``` |
|
3509 * and it should be migrated it to: |
|
3510 * ```js |
|
3511 * { |
|
3512 * 'core/edit-post': { |
|
3513 * complementaryArea: 'edit-post/document', |
|
3514 * pinnedItems: { |
|
3515 * 'plugin-1': true, |
|
3516 * }, |
|
3517 * }, |
|
3518 * 'core/edit-site': { |
|
3519 * complementaryArea: 'edit-site/global-styles', |
|
3520 * pinnedItems: { |
|
3521 * 'plugin-2': true, |
|
3522 * }, |
|
3523 * }, |
|
3524 * } |
|
3525 * ``` |
|
3526 * |
|
3527 * @param {Object} persistence The persistence interface. |
|
3528 */ |
|
3529 |
|
3530 function migrateInterfaceEnableItemsToPreferencesStore(persistence) { |
|
3531 var _state$interfaceStore10, _state$preferencesSto9, _state$preferencesSto10, _sourceEnableItems$si, _sourceEnableItems$si2, _sourceEnableItems$mu, _sourceEnableItems$mu2; |
|
3532 |
|
3533 const interfaceStoreName = 'core/interface'; |
|
3534 const preferencesStoreName = 'core/preferences'; |
|
3535 const state = persistence.get(); |
|
3536 const sourceEnableItems = (_state$interfaceStore10 = state[interfaceStoreName]) === null || _state$interfaceStore10 === void 0 ? void 0 : _state$interfaceStore10.enableItems; // There's nothing to migrate, exit early. |
|
3537 |
|
3538 if (!sourceEnableItems) { |
|
3539 return; |
|
3540 } |
|
3541 |
|
3542 const allPreferences = (_state$preferencesSto9 = (_state$preferencesSto10 = state[preferencesStoreName]) === null || _state$preferencesSto10 === void 0 ? void 0 : _state$preferencesSto10.preferences) !== null && _state$preferencesSto9 !== void 0 ? _state$preferencesSto9 : {}; // First convert complementaryAreas into the right format. |
|
3543 // Use the existing preferences as the accumulator so that the data is |
|
3544 // merged. |
|
3545 |
|
3546 const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$si2 = sourceEnableItems.singleEnableItems) === null || _sourceEnableItems$si2 === void 0 ? void 0 : _sourceEnableItems$si2.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {}; |
|
3547 const convertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => { |
|
3548 var _accumulator$scope; |
|
3549 |
|
3550 const data = sourceComplementaryAreas[scope]; // Don't overwrite any existing data in the preferences store. |
|
3551 |
|
3552 if ((_accumulator$scope = accumulator[scope]) !== null && _accumulator$scope !== void 0 && _accumulator$scope.complementaryArea) { |
|
3553 return accumulator; |
|
3554 } |
|
3555 |
|
3556 return { ...accumulator, |
|
3557 [scope]: { ...accumulator[scope], |
|
3558 complementaryArea: data |
|
3559 } |
|
3560 }; |
|
3561 }, allPreferences); // Next feed the converted complementary areas back into a reducer that |
|
3562 // converts the pinned items, resulting in the fully migrated data. |
|
3563 |
|
3564 const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$mu2 = sourceEnableItems.multipleEnableItems) === null || _sourceEnableItems$mu2 === void 0 ? void 0 : _sourceEnableItems$mu2.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {}; |
|
3565 const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => { |
|
3566 var _accumulator$scope2; |
|
3567 |
|
3568 const data = sourcePinnedItems[scope]; // Don't overwrite any existing data in the preferences store. |
|
3569 |
|
3570 if ((_accumulator$scope2 = accumulator[scope]) !== null && _accumulator$scope2 !== void 0 && _accumulator$scope2.pinnedItems) { |
|
3571 return accumulator; |
|
3572 } |
|
3573 |
|
3574 return { ...accumulator, |
|
3575 [scope]: { ...accumulator[scope], |
|
3576 pinnedItems: data |
|
3577 } |
|
3578 }; |
|
3579 }, convertedComplementaryAreas); |
|
3580 persistence.set(preferencesStoreName, { |
|
3581 preferences: allConvertedData |
|
3582 }); // Remove migrated preferences. |
|
3583 |
|
3584 const otherInterfaceItems = state[interfaceStoreName]; |
|
3585 persistence.set(interfaceStoreName, { ...otherInterfaceItems, |
|
3586 enableItems: undefined |
|
3587 }); |
|
3588 } |
|
3589 |
|
3590 persistencePlugin.__unstableMigrate = pluginOptions => { |
|
3591 const persistence = createPersistenceInterface(pluginOptions); // Boolean feature preferences. |
|
3592 |
|
3593 migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-widgets'); |
|
3594 migrateFeaturePreferencesToPreferencesStore(persistence, 'core/customize-widgets'); |
|
3595 migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-post'); |
|
3596 migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-site'); |
|
3597 migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence); // Other ad-hoc preferences. |
|
3598 |
|
3599 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3600 from: 'core/edit-post', |
|
3601 scope: 'core/edit-post' |
|
3602 }, 'hiddenBlockTypes'); |
|
3603 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3604 from: 'core/edit-post', |
|
3605 scope: 'core/edit-post' |
|
3606 }, 'editorMode'); |
|
3607 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3608 from: 'core/edit-post', |
|
3609 scope: 'core/edit-post' |
|
3610 }, 'preferredStyleVariations'); |
|
3611 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3612 from: 'core/edit-post', |
|
3613 scope: 'core/edit-post' |
|
3614 }, 'panels', convertEditPostPanels); |
|
3615 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3616 from: 'core/editor', |
|
3617 scope: 'core/edit-post' |
|
3618 }, 'isPublishSidebarEnabled'); |
|
3619 migrateIndividualPreferenceToPreferencesStore(persistence, { |
|
3620 from: 'core/edit-site', |
|
3621 scope: 'core/edit-site' |
|
3622 }, 'editorMode'); |
|
3623 migrateInterfaceEnableItemsToPreferencesStore(persistence); |
|
3624 }; |
|
3625 |
|
3626 /* harmony default export */ var persistence = (persistencePlugin); |
|
3627 |
|
3628 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js |
|
3629 |
|
3630 |
|
3631 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
3632 function _extends() { |
|
3633 _extends = Object.assign ? Object.assign.bind() : function (target) { |
|
3634 for (var i = 1; i < arguments.length; i++) { |
|
3635 var source = arguments[i]; |
|
3636 |
|
3637 for (var key in source) { |
|
3638 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
3639 target[key] = source[key]; |
|
3038 } |
3640 } |
3039 } |
3641 } |
3040 }); |
3642 } |
3041 } // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post' |
3643 |
3042 |
3644 return target; |
3043 |
3645 }; |
3044 const areTipsEnabled = Object(external_lodash_["get"])(state, ['core/nux', 'preferences', 'areTipsEnabled']); |
3646 return _extends.apply(this, arguments); |
3045 const hasWelcomeGuide = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'welcomeGuide']); |
3647 } |
3046 |
3648 ;// CONCATENATED MODULE: external ["wp","element"] |
3047 if (areTipsEnabled !== undefined && !hasWelcomeGuide) { |
3649 var external_wp_element_namespaceObject = window["wp"]["element"]; |
3048 editPostState = Object(external_lodash_["merge"])({}, editPostState, { |
3650 ;// CONCATENATED MODULE: external ["wp","compose"] |
3049 preferences: { |
3651 var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
3050 features: { |
3652 ;// CONCATENATED MODULE: external "React" |
3051 welcomeGuide: areTipsEnabled |
3653 var external_React_namespaceObject = window["React"]; |
3052 } |
3654 ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js |
3053 } |
3655 |
3054 }); |
3656 |
3055 } |
3657 function areInputsEqual(newInputs, lastInputs) { |
3056 |
3658 if (newInputs.length !== lastInputs.length) { |
3057 if (editPostState !== state['core/edit-post']) { |
3659 return false; |
3058 persistence.set('core/edit-post', editPostState); |
3660 } |
3059 } |
3661 |
3060 }; |
3662 for (var i = 0; i < newInputs.length; i++) { |
3061 |
3663 if (newInputs[i] !== lastInputs[i]) { |
3062 /* harmony default export */ var plugins_persistence = (persistencePlugin); |
3664 return false; |
3063 |
3665 } |
3064 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js |
3666 } |
3065 |
3667 |
3066 |
3668 return true; |
3067 |
3669 } |
3068 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
3670 |
3069 var esm_extends = __webpack_require__("wx14"); |
3671 function useMemoOne(getResult, inputs) { |
3070 |
3672 var initial = (0,external_React_namespaceObject.useState)(function () { |
3071 // EXTERNAL MODULE: external ["wp","element"] |
3673 return { |
3072 var external_wp_element_ = __webpack_require__("GRId"); |
3674 inputs: inputs, |
3073 |
3675 result: getResult() |
3074 // EXTERNAL MODULE: external ["wp","compose"] |
3676 }; |
3075 var external_wp_compose_ = __webpack_require__("K9lf"); |
3677 })[0]; |
3076 |
3678 var isFirstRun = (0,external_React_namespaceObject.useRef)(true); |
3077 // EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js |
3679 var committed = (0,external_React_namespaceObject.useRef)(initial); |
3078 var use_memo_one_esm = __webpack_require__("mHlH"); |
3680 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); |
3079 |
3681 var cache = useCache ? committed.current : { |
3080 // EXTERNAL MODULE: external ["wp","priorityQueue"] |
3682 inputs: inputs, |
3081 var external_wp_priorityQueue_ = __webpack_require__("XI5e"); |
3683 result: getResult() |
3082 |
3684 }; |
3083 // EXTERNAL MODULE: external ["wp","isShallowEqual"] |
3685 (0,external_React_namespaceObject.useEffect)(function () { |
3084 var external_wp_isShallowEqual_ = __webpack_require__("rl8x"); |
3686 isFirstRun.current = false; |
3085 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); |
3687 committed.current = cache; |
3086 |
3688 }, [cache]); |
3087 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js |
3689 return cache.result; |
3690 } |
|
3691 function useCallbackOne(callback, inputs) { |
|
3692 return useMemoOne(function () { |
|
3693 return callback; |
|
3694 }, inputs); |
|
3695 } |
|
3696 var useMemo = (/* unused pure expression or super */ null && (useMemoOne)); |
|
3697 var useCallback = (/* unused pure expression or super */ null && (useCallbackOne)); |
|
3698 |
|
3699 |
|
3700 |
|
3701 ;// CONCATENATED MODULE: external ["wp","priorityQueue"] |
|
3702 var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; |
|
3703 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] |
|
3704 var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; |
|
3705 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); |
|
3706 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js |
|
3088 /** |
3707 /** |
3089 * WordPress dependencies |
3708 * WordPress dependencies |
3090 */ |
3709 */ |
3091 |
3710 |
3092 /** |
3711 /** |
3093 * Internal dependencies |
3712 * Internal dependencies |
3094 */ |
3713 */ |
3095 |
3714 |
3096 |
3715 |
3097 const Context = Object(external_wp_element_["createContext"])(default_registry); |
3716 const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry); |
3098 const { |
3717 const { |
3099 Consumer, |
3718 Consumer, |
3100 Provider |
3719 Provider |
3101 } = Context; |
3720 } = Context; |
3102 /** |
3721 /** |
3140 * example. |
3759 * example. |
3141 */ |
3760 */ |
3142 |
3761 |
3143 /* harmony default export */ var context = (Provider); |
3762 /* harmony default export */ var context = (Provider); |
3144 |
3763 |
3145 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js |
3764 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js |
3146 /** |
3765 /** |
3147 * WordPress dependencies |
3766 * WordPress dependencies |
3148 */ |
3767 */ |
3149 |
3768 |
3150 /** |
3769 /** |
3175 * } from '@wordpress/data'; |
3794 * } from '@wordpress/data'; |
3176 * |
3795 * |
3177 * const registry = createRegistry( {} ); |
3796 * const registry = createRegistry( {} ); |
3178 * |
3797 * |
3179 * const SomeChildUsingRegistry = ( props ) => { |
3798 * const SomeChildUsingRegistry = ( props ) => { |
3180 * const registry = useRegistry( registry ); |
3799 * const registry = useRegistry(); |
3181 * // ...logic implementing the registry in other react hooks. |
3800 * // ...logic implementing the registry in other react hooks. |
3182 * }; |
3801 * }; |
3183 * |
3802 * |
3184 * |
3803 * |
3185 * const ParentProvidingRegistry = ( props ) => { |
3804 * const ParentProvidingRegistry = ( props ) => { |
3191 * |
3810 * |
3192 * @return {Function} A custom react hook exposing the registry context value. |
3811 * @return {Function} A custom react hook exposing the registry context value. |
3193 */ |
3812 */ |
3194 |
3813 |
3195 function useRegistry() { |
3814 function useRegistry() { |
3196 return Object(external_wp_element_["useContext"])(Context); |
3815 return (0,external_wp_element_namespaceObject.useContext)(Context); |
3197 } |
3816 } |
3198 |
3817 |
3199 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js |
3818 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js |
3200 /** |
3819 /** |
3201 * WordPress dependencies |
3820 * WordPress dependencies |
3202 */ |
3821 */ |
3203 |
3822 |
3204 const context_Context = Object(external_wp_element_["createContext"])(false); |
3823 const context_Context = (0,external_wp_element_namespaceObject.createContext)(false); |
3205 const { |
3824 const { |
3206 Consumer: context_Consumer, |
3825 Consumer: context_Consumer, |
3207 Provider: context_Provider |
3826 Provider: context_Provider |
3208 } = context_Context; |
3827 } = context_Context; |
3209 const AsyncModeConsumer = context_Consumer; |
3828 const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer)); |
3210 /** |
3829 /** |
3211 * Context Provider Component used to switch the data module component rerendering |
3830 * Context Provider Component used to switch the data module component rerendering |
3212 * between Sync and Async modes. |
3831 * between Sync and Async modes. |
3213 * |
3832 * |
3214 * @example |
3833 * @example |
3236 * In this example, the BlockCount component is rerendered asynchronously. |
3855 * In this example, the BlockCount component is rerendered asynchronously. |
3237 * It means if a more critical task is being performed (like typing in an input), |
3856 * It means if a more critical task is being performed (like typing in an input), |
3238 * the rerendering is delayed until the browser becomes IDLE. |
3857 * the rerendering is delayed until the browser becomes IDLE. |
3239 * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. |
3858 * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. |
3240 * |
3859 * |
3241 * @param {boolean} props.value Enable Async Mode. |
3860 * @param {boolean} props.value Enable Async Mode. |
3242 * @return {WPComponent} The component to be rendered. |
3861 * @return {WPComponent} The component to be rendered. |
3243 */ |
3862 */ |
3244 |
3863 |
3245 /* harmony default export */ var async_mode_provider_context = (context_Provider); |
3864 /* harmony default export */ var async_mode_provider_context = (context_Provider); |
3246 |
3865 |
3247 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js |
3866 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js |
3248 /** |
3867 /** |
3249 * WordPress dependencies |
3868 * WordPress dependencies |
3250 */ |
3869 */ |
3251 |
3870 |
3252 /** |
3871 /** |
3253 * Internal dependencies |
3872 * Internal dependencies |
3254 */ |
3873 */ |
3255 |
3874 |
3256 |
3875 |
3257 function useAsyncMode() { |
3876 function useAsyncMode() { |
3258 return Object(external_wp_element_["useContext"])(context_Context); |
3877 return (0,external_wp_element_namespaceObject.useContext)(context_Context); |
3259 } |
3878 } |
3260 |
3879 |
3261 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js |
3880 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js |
3262 /** |
3881 /** |
3263 * External dependencies |
3882 * External dependencies |
3264 */ |
3883 */ |
3265 |
3884 |
3266 /** |
3885 /** |
3275 * Internal dependencies |
3894 * Internal dependencies |
3276 */ |
3895 */ |
3277 |
3896 |
3278 |
3897 |
3279 |
3898 |
3280 const renderQueue = Object(external_wp_priorityQueue_["createQueue"])(); |
3899 |
3281 /** @typedef {import('./types').WPDataStore} WPDataStore */ |
3900 const noop = () => {}; |
3901 |
|
3902 const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); |
|
3903 /** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */ |
|
3282 |
3904 |
3283 /** |
3905 /** |
3284 * Custom react hook for retrieving props from registered selectors. |
3906 * Custom react hook for retrieving props from registered selectors. |
3285 * |
3907 * |
3286 * In general, this custom React hook follows the |
3908 * In general, this custom React hook follows the |
3287 * [rules of hooks](https://reactjs.org/docs/hooks-rules.html). |
3909 * [rules of hooks](https://reactjs.org/docs/hooks-rules.html). |
3288 * |
3910 * |
3289 * @param {Function|WPDataStore|string} _mapSelect Function called on every state change. The |
3911 * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The |
3290 * returned value is exposed to the component |
3912 * returned value is exposed to the component |
3291 * implementing this hook. The function receives |
3913 * implementing this hook. The function receives |
3292 * the `registry.select` method on the first |
3914 * the `registry.select` method on the first |
3293 * argument and the `registry` on the second |
3915 * argument and the `registry` on the second |
3294 * argument. |
3916 * argument. |
3295 * When a store key is passed, all selectors for |
3917 * When a store key is passed, all selectors for |
3296 * the store will be returned. This is only meant |
3918 * the store will be returned. This is only meant |
3297 * for usage of these selectors in event |
3919 * for usage of these selectors in event |
3298 * callbacks, not for data needed to create the |
3920 * callbacks, not for data needed to create the |
3299 * element tree. |
3921 * element tree. |
3300 * @param {Array} deps If provided, this memoizes the mapSelect so the |
3922 * @param {Array} deps If provided, this memoizes the mapSelect so the |
3301 * same `mapSelect` is invoked on every state |
3923 * same `mapSelect` is invoked on every state |
3302 * change unless the dependencies change. |
3924 * change unless the dependencies change. |
3303 * |
3925 * |
3304 * @example |
3926 * @example |
3305 * ```js |
3927 * ```js |
3306 * import { useSelect } from '@wordpress/data'; |
3928 * import { useSelect } from '@wordpress/data'; |
3307 * |
3929 * |
3346 * ``` |
3968 * ``` |
3347 * |
3969 * |
3348 * @return {Function} A custom react hook. |
3970 * @return {Function} A custom react hook. |
3349 */ |
3971 */ |
3350 |
3972 |
3351 function useSelect(_mapSelect, deps) { |
3973 function useSelect(mapSelect, deps) { |
3352 const isWithoutMapping = typeof _mapSelect !== 'function'; |
3974 const hasMappingFunction = 'function' === typeof mapSelect; // If we're recalling a store by its name or by |
3353 |
3975 // its descriptor then we won't be caching the |
3354 if (isWithoutMapping) { |
3976 // calls to `mapSelect` because we won't be calling it. |
3977 |
|
3978 if (!hasMappingFunction) { |
|
3355 deps = []; |
3979 deps = []; |
3356 } |
3980 } // Because of the "rule of hooks" we have to call `useCallback` |
3357 |
3981 // on every invocation whether or not we have a real function |
3358 const mapSelect = Object(external_wp_element_["useCallback"])(_mapSelect, deps); |
3982 // for `mapSelect`. we'll create this intermediate variable to |
3983 // fulfill that need and then reference it with our "real" |
|
3984 // `_mapSelect` if we can. |
|
3985 |
|
3986 |
|
3987 const callbackMapper = (0,external_wp_element_namespaceObject.useCallback)(hasMappingFunction ? mapSelect : noop, deps); |
|
3988 |
|
3989 const _mapSelect = hasMappingFunction ? callbackMapper : null; |
|
3990 |
|
3359 const registry = useRegistry(); |
3991 const registry = useRegistry(); |
3360 const isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache. |
3992 const isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache. |
3361 // We use the cache-stable `useMemoOne` to avoid |
3993 // We use the cache-stable `useMemoOne` to avoid |
3362 // losing queues. |
3994 // losing queues. |
3363 |
3995 |
3364 const queueContext = Object(use_memo_one_esm["a" /* useMemoOne */])(() => ({ |
3996 const queueContext = useMemoOne(() => ({ |
3365 queue: true |
3997 queue: true |
3366 }), [registry]); |
3998 }), [registry]); |
3367 const [, forceRender] = Object(external_wp_element_["useReducer"])(s => s + 1, 0); |
3999 const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(s => s + 1, 0); |
3368 const latestMapSelect = Object(external_wp_element_["useRef"])(); |
4000 const latestMapSelect = (0,external_wp_element_namespaceObject.useRef)(); |
3369 const latestIsAsync = Object(external_wp_element_["useRef"])(isAsync); |
4001 const latestIsAsync = (0,external_wp_element_namespaceObject.useRef)(isAsync); |
3370 const latestMapOutput = Object(external_wp_element_["useRef"])(); |
4002 const latestMapOutput = (0,external_wp_element_namespaceObject.useRef)(); |
3371 const latestMapOutputError = Object(external_wp_element_["useRef"])(); |
4003 const latestMapOutputError = (0,external_wp_element_namespaceObject.useRef)(); |
3372 const isMountedAndNotUnsubscribing = Object(external_wp_element_["useRef"])(); // Keep track of the stores being selected in the mapSelect function, |
4004 const isMountedAndNotUnsubscribing = (0,external_wp_element_namespaceObject.useRef)(); // Keep track of the stores being selected in the _mapSelect function, |
3373 // and only subscribe to those stores later. |
4005 // and only subscribe to those stores later. |
3374 |
4006 |
3375 const listeningStores = Object(external_wp_element_["useRef"])([]); |
4007 const listeningStores = (0,external_wp_element_namespaceObject.useRef)([]); |
3376 const trapSelect = Object(external_wp_element_["useCallback"])(callback => registry.__experimentalMarkListeningStores(callback, listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array. |
4008 const wrapSelect = (0,external_wp_element_namespaceObject.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.select, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array. |
3377 // It's different than just using `mapSelect` since deps could be undefined, |
4009 // It's different than just using `mapSelect` since deps could be undefined, |
3378 // in that case, we would still want to memoize it. |
4010 // in that case, we would still want to memoize it. |
3379 |
4011 |
3380 const depsChangedFlag = Object(external_wp_element_["useMemo"])(() => ({}), deps || []); |
4012 const depsChangedFlag = (0,external_wp_element_namespaceObject.useMemo)(() => ({}), deps || []); |
3381 let mapOutput; |
4013 let mapOutput; |
3382 |
4014 |
3383 if (!isWithoutMapping) { |
4015 if (_mapSelect) { |
3384 try { |
4016 mapOutput = latestMapOutput.current; |
3385 if (latestMapSelect.current !== mapSelect || latestMapOutputError.current) { |
4017 const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect; |
3386 mapOutput = trapSelect(() => mapSelect(registry.select, registry)); |
4018 const lastMapSelectFailed = !!latestMapOutputError.current; |
3387 } else { |
4019 |
3388 mapOutput = latestMapOutput.current; |
4020 if (hasReplacedMapSelect || lastMapSelectFailed) { |
4021 try { |
|
4022 mapOutput = wrapSelect(_mapSelect); |
|
4023 } catch (error) { |
|
4024 let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`; |
|
4025 |
|
4026 if (latestMapOutputError.current) { |
|
4027 errorMessage += `\nThe error may be correlated with this previous error:\n`; |
|
4028 errorMessage += `${latestMapOutputError.current.stack}\n\n`; |
|
4029 errorMessage += 'Original stack trace:'; |
|
4030 } // eslint-disable-next-line no-console |
|
4031 |
|
4032 |
|
4033 console.error(errorMessage); |
|
3389 } |
4034 } |
3390 } catch (error) { |
4035 } |
3391 let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`; |
4036 } |
3392 |
4037 |
3393 if (latestMapOutputError.current) { |
4038 (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { |
3394 errorMessage += `\nThe error may be correlated with this previous error:\n`; |
4039 if (!hasMappingFunction) { |
3395 errorMessage += `${latestMapOutputError.current.stack}\n\n`; |
|
3396 errorMessage += 'Original stack trace:'; |
|
3397 } // eslint-disable-next-line no-console |
|
3398 |
|
3399 |
|
3400 console.error(errorMessage); |
|
3401 mapOutput = latestMapOutput.current; |
|
3402 } |
|
3403 } |
|
3404 |
|
3405 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { |
|
3406 if (isWithoutMapping) { |
|
3407 return; |
4040 return; |
3408 } |
4041 } |
3409 |
4042 |
3410 latestMapSelect.current = mapSelect; |
4043 latestMapSelect.current = _mapSelect; |
3411 latestMapOutput.current = mapOutput; |
4044 latestMapOutput.current = mapOutput; |
3412 latestMapOutputError.current = undefined; |
4045 latestMapOutputError.current = undefined; |
3413 isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates |
4046 isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates |
3414 // to avoid using stale values in the flushed |
4047 // to avoid using stale values in the flushed |
3415 // callbacks or potentially overwriting a |
4048 // callbacks or potentially overwriting a |
3418 if (latestIsAsync.current !== isAsync) { |
4051 if (latestIsAsync.current !== isAsync) { |
3419 latestIsAsync.current = isAsync; |
4052 latestIsAsync.current = isAsync; |
3420 renderQueue.flush(queueContext); |
4053 renderQueue.flush(queueContext); |
3421 } |
4054 } |
3422 }); |
4055 }); |
3423 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { |
4056 (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { |
3424 if (isWithoutMapping) { |
4057 if (!hasMappingFunction) { |
3425 return; |
4058 return; |
3426 } |
4059 } |
3427 |
4060 |
3428 const onStoreChange = () => { |
4061 const onStoreChange = () => { |
3429 if (isMountedAndNotUnsubscribing.current) { |
4062 if (isMountedAndNotUnsubscribing.current) { |
3430 try { |
4063 try { |
3431 const newMapOutput = trapSelect(() => latestMapSelect.current(registry.select, registry)); |
4064 const newMapOutput = wrapSelect(latestMapSelect.current); |
3432 |
4065 |
3433 if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) { |
4066 if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) { |
3434 return; |
4067 return; |
3435 } |
4068 } |
3436 |
4069 |
3439 latestMapOutputError.current = error; |
4072 latestMapOutputError.current = error; |
3440 } |
4073 } |
3441 |
4074 |
3442 forceRender(); |
4075 forceRender(); |
3443 } |
4076 } |
3444 }; // catch any possible state changes during mount before the subscription |
4077 }; |
3445 // could be set. |
|
3446 |
|
3447 |
|
3448 if (latestIsAsync.current) { |
|
3449 renderQueue.add(queueContext, onStoreChange); |
|
3450 } else { |
|
3451 onStoreChange(); |
|
3452 } |
|
3453 |
4078 |
3454 const onChange = () => { |
4079 const onChange = () => { |
3455 if (latestIsAsync.current) { |
4080 if (latestIsAsync.current) { |
3456 renderQueue.add(queueContext, onStoreChange); |
4081 renderQueue.add(queueContext, onStoreChange); |
3457 } else { |
4082 } else { |
3458 onStoreChange(); |
4083 onStoreChange(); |
3459 } |
4084 } |
3460 }; |
4085 }; // Catch any possible state changes during mount before the subscription |
3461 |
4086 // could be set. |
3462 const unsubscribers = listeningStores.current.map(storeName => registry.__experimentalSubscribeStore(storeName, onChange)); |
4087 |
4088 |
|
4089 onChange(); |
|
4090 const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange)); |
|
3463 return () => { |
4091 return () => { |
3464 isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store. |
4092 isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store. |
3465 |
4093 |
3466 unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe()); |
4094 unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe()); |
3467 renderQueue.flush(queueContext); |
4095 renderQueue.flush(queueContext); |
3468 }; |
4096 }; // If you're tempted to eliminate the spread dependencies below don't do it! |
3469 }, [registry, trapSelect, depsChangedFlag, isWithoutMapping]); |
4097 // We're passing these in from the calling function and want to make sure we're |
3470 return isWithoutMapping ? registry.select(_mapSelect) : mapOutput; |
4098 // examining every individual value inside the `deps` array. |
3471 } |
4099 }, [registry, wrapSelect, hasMappingFunction, depsChangedFlag]); |
3472 |
4100 return hasMappingFunction ? mapOutput : registry.select(mapSelect); |
3473 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js |
4101 } |
4102 |
|
4103 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js |
|
3474 |
4104 |
3475 |
4105 |
3476 |
4106 |
3477 /** |
4107 /** |
3478 * WordPress dependencies |
4108 * WordPress dependencies |
3486 /** |
4116 /** |
3487 * Higher-order component used to inject state-derived props using registered |
4117 * Higher-order component used to inject state-derived props using registered |
3488 * selectors. |
4118 * selectors. |
3489 * |
4119 * |
3490 * @param {Function} mapSelectToProps Function called on every state change, |
4120 * @param {Function} mapSelectToProps Function called on every state change, |
3491 * expected to return object of props to |
4121 * expected to return object of props to |
3492 * merge with the component's own props. |
4122 * merge with the component's own props. |
3493 * |
4123 * |
3494 * @example |
4124 * @example |
3495 * ```js |
4125 * ```js |
3496 * import { withSelect } from '@wordpress/data'; |
4126 * import { withSelect } from '@wordpress/data'; |
3497 * |
4127 * |
3521 * the store. |
4151 * the store. |
3522 * |
4152 * |
3523 * @return {WPComponent} Enhanced component with merged state data props. |
4153 * @return {WPComponent} Enhanced component with merged state data props. |
3524 */ |
4154 */ |
3525 |
4155 |
3526 const withSelect = mapSelectToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => Object(external_wp_compose_["pure"])(ownProps => { |
4156 const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => { |
3527 const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); |
4157 const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); |
3528 |
4158 |
3529 const mergeProps = useSelect(mapSelect); |
4159 const mergeProps = useSelect(mapSelect); |
3530 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, mergeProps)); |
4160 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, mergeProps)); |
3531 }), 'withSelect'); |
4161 }), 'withSelect'); |
3532 |
4162 |
3533 /* harmony default export */ var with_select = (withSelect); |
4163 /* harmony default export */ var with_select = (withSelect); |
3534 |
4164 |
3535 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js |
4165 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js |
3536 /** |
4166 /** |
3537 * External dependencies |
4167 * External dependencies |
3538 */ |
4168 */ |
3539 |
4169 |
3540 /** |
4170 /** |
3552 * Custom react hook for returning aggregate dispatch actions using the provided |
4182 * Custom react hook for returning aggregate dispatch actions using the provided |
3553 * dispatchMap. |
4183 * dispatchMap. |
3554 * |
4184 * |
3555 * Currently this is an internal api only and is implemented by `withDispatch` |
4185 * Currently this is an internal api only and is implemented by `withDispatch` |
3556 * |
4186 * |
3557 * @param {Function} dispatchMap Receives the `registry.dispatch` function as |
4187 * @param {Function} dispatchMap Receives the `registry.dispatch` function as |
3558 * the first argument and the `registry` object |
4188 * the first argument and the `registry` object |
3559 * as the second argument. Should return an |
4189 * as the second argument. Should return an |
3560 * object mapping props to functions. |
4190 * object mapping props to functions. |
3561 * @param {Array} deps An array of dependencies for the hook. |
4191 * @param {Array} deps An array of dependencies for the hook. |
3562 * @return {Object} An object mapping props to functions created by the passed |
4192 * @return {Object} An object mapping props to functions created by the passed |
3563 * in dispatchMap. |
4193 * in dispatchMap. |
3564 */ |
4194 */ |
3565 |
4195 |
3566 const useDispatchWithMap = (dispatchMap, deps) => { |
4196 const useDispatchWithMap = (dispatchMap, deps) => { |
3567 const registry = useRegistry(); |
4197 const registry = useRegistry(); |
3568 const currentDispatchMap = Object(external_wp_element_["useRef"])(dispatchMap); |
4198 const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap); |
3569 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { |
4199 (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { |
3570 currentDispatchMap.current = dispatchMap; |
4200 currentDispatchMap.current = dispatchMap; |
3571 }); |
4201 }); |
3572 return Object(external_wp_element_["useMemo"])(() => { |
4202 return (0,external_wp_element_namespaceObject.useMemo)(() => { |
3573 const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry); |
4203 const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry); |
3574 return Object(external_lodash_["mapValues"])(currentDispatchProps, (dispatcher, propName) => { |
4204 return (0,external_lodash_namespaceObject.mapValues)(currentDispatchProps, (dispatcher, propName) => { |
3575 if (typeof dispatcher !== 'function') { |
4205 if (typeof dispatcher !== 'function') { |
3576 // eslint-disable-next-line no-console |
4206 // eslint-disable-next-line no-console |
3577 console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`); |
4207 console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`); |
3578 } |
4208 } |
3579 |
4209 |
3580 return (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args); |
4210 return function () { |
4211 return currentDispatchMap.current(registry.dispatch, registry)[propName](...arguments); |
|
4212 }; |
|
3581 }); |
4213 }); |
3582 }, [registry, ...deps]); |
4214 }, [registry, ...deps]); |
3583 }; |
4215 }; |
3584 |
4216 |
3585 /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap); |
4217 /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap); |
3586 |
4218 |
3587 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js |
4219 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js |
3588 |
4220 |
3589 |
4221 |
3590 |
4222 |
3591 /** |
4223 /** |
3592 * WordPress dependencies |
4224 * WordPress dependencies |
3675 * conditions under which a different value would be returned. |
4307 * conditions under which a different value would be returned. |
3676 * |
4308 * |
3677 * @return {WPComponent} Enhanced component with merged dispatcher props. |
4309 * @return {WPComponent} Enhanced component with merged dispatcher props. |
3678 */ |
4310 */ |
3679 |
4311 |
3680 const withDispatch = mapDispatchToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => ownProps => { |
4312 const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => { |
3681 const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); |
4313 const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); |
3682 |
4314 |
3683 const dispatchProps = use_dispatch_with_map(mapDispatch, []); |
4315 const dispatchProps = use_dispatch_with_map(mapDispatch, []); |
3684 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, dispatchProps)); |
4316 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, dispatchProps)); |
3685 }, 'withDispatch'); |
4317 }, 'withDispatch'); |
3686 |
4318 |
3687 /* harmony default export */ var with_dispatch = (withDispatch); |
4319 /* harmony default export */ var with_dispatch = (withDispatch); |
3688 |
4320 |
3689 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js |
4321 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js |
3690 |
4322 |
3691 |
4323 |
3692 |
4324 |
3693 /** |
4325 /** |
3694 * WordPress dependencies |
4326 * WordPress dependencies |
3706 * @param {WPComponent} OriginalComponent Original component. |
4338 * @param {WPComponent} OriginalComponent Original component. |
3707 * |
4339 * |
3708 * @return {WPComponent} Enhanced component. |
4340 * @return {WPComponent} Enhanced component. |
3709 */ |
4341 */ |
3710 |
4342 |
3711 const withRegistry = Object(external_wp_compose_["createHigherOrderComponent"])(OriginalComponent => props => Object(external_wp_element_["createElement"])(RegistryConsumer, null, registry => Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, { |
4343 const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => (0,external_wp_element_namespaceObject.createElement)(RegistryConsumer, null, registry => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, { |
3712 registry: registry |
4344 registry: registry |
3713 }))), 'withRegistry'); |
4345 }))), 'withRegistry'); |
3714 /* harmony default export */ var with_registry = (withRegistry); |
4346 /* harmony default export */ var with_registry = (withRegistry); |
3715 |
4347 |
3716 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js |
4348 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js |
3717 /** |
4349 /** |
3718 * Internal dependencies |
4350 * Internal dependencies |
3719 */ |
4351 */ |
3720 |
4352 |
3721 /** @typedef {import('./types').WPDataStore} WPDataStore */ |
4353 /** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */ |
3722 |
4354 |
3723 /** |
4355 /** |
3724 * A custom react hook returning the current registry dispatch actions creators. |
4356 * A custom react hook returning the current registry dispatch actions creators. |
3725 * |
4357 * |
3726 * Note: The component using this hook must be within the context of a |
4358 * Note: The component using this hook must be within the context of a |
3727 * RegistryProvider. |
4359 * RegistryProvider. |
3728 * |
4360 * |
3729 * @param {string|WPDataStore} [storeNameOrDefinition] Optionally provide the name of the |
4361 * @param {string|StoreDescriptor} [storeNameOrDescriptor] Optionally provide the name of the |
3730 * store or its definition from which to |
4362 * store or its descriptor from which to |
3731 * retrieve action creators. If not |
4363 * retrieve action creators. If not |
3732 * provided, the registry.dispatch |
4364 * provided, the registry.dispatch |
3733 * function is returned instead. |
4365 * function is returned instead. |
3734 * |
4366 * |
3735 * @example |
4367 * @example |
3736 * This illustrates a pattern where you may need to retrieve dynamic data from |
4368 * This illustrates a pattern where you may need to retrieve dynamic data from |
3737 * the server via the `useSelect` hook to use in combination with the dispatch |
4369 * the server via the `useSelect` hook to use in combination with the dispatch |
3738 * action. |
4370 * action. |
3763 * // <SaleButton>Start Sale!</SaleButton> |
4395 * // <SaleButton>Start Sale!</SaleButton> |
3764 * ``` |
4396 * ``` |
3765 * @return {Function} A custom react hook. |
4397 * @return {Function} A custom react hook. |
3766 */ |
4398 */ |
3767 |
4399 |
3768 const useDispatch = storeNameOrDefinition => { |
4400 const useDispatch = storeNameOrDescriptor => { |
3769 const { |
4401 const { |
3770 dispatch |
4402 dispatch |
3771 } = useRegistry(); |
4403 } = useRegistry(); |
3772 return storeNameOrDefinition === void 0 ? dispatch : dispatch(storeNameOrDefinition); |
4404 return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor); |
3773 }; |
4405 }; |
3774 |
4406 |
3775 /* harmony default export */ var use_dispatch = (useDispatch); |
4407 /* harmony default export */ var use_dispatch = (useDispatch); |
3776 |
4408 |
3777 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js |
4409 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js |
3778 /** |
4410 /** |
3779 * External dependencies |
4411 * External dependencies |
3780 */ |
4412 */ |
3781 |
4413 |
3782 /** |
4414 /** |
3783 * Internal dependencies |
4415 * Internal dependencies |
3784 */ |
4416 */ |
3785 |
4417 |
3786 |
4418 |
3787 |
4419 |
3788 /** @typedef {import('./types').WPDataStore} WPDataStore */ |
4420 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
3789 |
4421 |
3790 |
4422 |
3791 |
4423 |
3792 |
4424 |
3793 |
4425 |
3840 * } ), |
4472 * } ), |
3841 * } ); |
4473 * } ); |
3842 * register( store ); |
4474 * register( store ); |
3843 * ``` |
4475 * ``` |
3844 * |
4476 * |
3845 * @return {Function} A reducer that invokes every reducer inside the reducers |
4477 * @return {Function} A reducer that invokes every reducer inside the reducers |
3846 * object, and constructs a state object with the same shape. |
4478 * object, and constructs a state object with the same shape. |
3847 */ |
4479 */ |
3848 |
4480 |
3849 |
4481 |
3850 /** |
4482 /** |
3851 * Given the name or definition of a registered store, returns an object of the store's selectors. |
4483 * Given the name or descriptor of a registered store, returns an object of the store's selectors. |
3852 * The selector functions are been pre-bound to pass the current state automatically. |
4484 * The selector functions are been pre-bound to pass the current state automatically. |
3853 * As a consumer, you need only pass arguments of the selector, if applicable. |
4485 * As a consumer, you need only pass arguments of the selector, if applicable. |
3854 * |
4486 * |
3855 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
4487 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
3856 * or the store definition. |
4488 * or the store descriptor. |
3857 * |
4489 * |
3858 * @example |
4490 * @example |
3859 * ```js |
4491 * ```js |
3860 * import { select } from '@wordpress/data'; |
4492 * import { select } from '@wordpress/data'; |
3861 * |
4493 * |
3870 * Given the name of a registered store, returns an object containing the store's |
4502 * Given the name of a registered store, returns an object containing the store's |
3871 * selectors pre-bound to state so that you only need to supply additional arguments, |
4503 * selectors pre-bound to state so that you only need to supply additional arguments, |
3872 * and modified so that they return promises that resolve to their eventual values, |
4504 * and modified so that they return promises that resolve to their eventual values, |
3873 * after any resolvers have ran. |
4505 * after any resolvers have ran. |
3874 * |
4506 * |
3875 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
4507 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
3876 * or the store definition. |
4508 * or the store descriptor. |
3877 * |
4509 * |
3878 * @example |
4510 * @example |
3879 * ```js |
4511 * ```js |
3880 * import { resolveSelect } from '@wordpress/data'; |
4512 * import { resolveSelect } from '@wordpress/data'; |
3881 * |
4513 * |
3891 * Calling an action creator will cause it to be dispatched, updating the state value accordingly. |
4523 * Calling an action creator will cause it to be dispatched, updating the state value accordingly. |
3892 * |
4524 * |
3893 * Note: Action creators returned by the dispatch will return a promise when |
4525 * Note: Action creators returned by the dispatch will return a promise when |
3894 * they are called. |
4526 * they are called. |
3895 * |
4527 * |
3896 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store |
4528 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
3897 * or the store definition. |
4529 * or the store descriptor. |
3898 * |
4530 * |
3899 * @example |
4531 * @example |
3900 * ```js |
4532 * ```js |
3901 * import { dispatch } from '@wordpress/data'; |
4533 * import { dispatch } from '@wordpress/data'; |
3902 * |
4534 * |
3925 * // Later, if necessary... |
4557 * // Later, if necessary... |
3926 * unsubscribe(); |
4558 * unsubscribe(); |
3927 * ``` |
4559 * ``` |
3928 */ |
4560 */ |
3929 |
4561 |
3930 const build_module_subscribe = default_registry.subscribe; |
4562 const subscribe = default_registry.subscribe; |
3931 /** |
4563 /** |
3932 * Registers a generic store. |
4564 * Registers a generic store instance. |
3933 * |
4565 * |
3934 * @deprecated Use `register` instead. |
4566 * @deprecated Use `register( storeDescriptor )` instead. |
3935 * |
4567 * |
3936 * @param {string} key Store registry key. |
4568 * @param {string} name Store registry name. |
3937 * @param {Object} config Configuration (getSelectors, getActions, subscribe). |
4569 * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`). |
3938 */ |
4570 */ |
3939 |
4571 |
3940 const build_module_registerGenericStore = default_registry.registerGenericStore; |
4572 const registerGenericStore = default_registry.registerGenericStore; |
3941 /** |
4573 /** |
3942 * Registers a standard `@wordpress/data` store. |
4574 * Registers a standard `@wordpress/data` store. |
3943 * |
4575 * |
3944 * @deprecated Use `register` instead. |
4576 * @deprecated Use `register` instead. |
3945 * |
4577 * |
3956 * to extend the default registry behavior. |
4588 * to extend the default registry behavior. |
3957 * |
4589 * |
3958 * @param {Object} plugin Plugin object. |
4590 * @param {Object} plugin Plugin object. |
3959 */ |
4591 */ |
3960 |
4592 |
3961 const build_module_use = default_registry.use; |
4593 const use = default_registry.use; |
3962 /** |
4594 /** |
3963 * Registers a standard `@wordpress/data` store definition. |
4595 * Registers a standard `@wordpress/data` store descriptor. |
3964 * |
4596 * |
3965 * @example |
4597 * @example |
3966 * ```js |
4598 * ```js |
3967 * import { createReduxStore, register } from '@wordpress/data'; |
4599 * import { createReduxStore, register } from '@wordpress/data'; |
3968 * |
4600 * |
3973 * }, |
4605 * }, |
3974 * } ); |
4606 * } ); |
3975 * register( store ); |
4607 * register( store ); |
3976 * ``` |
4608 * ``` |
3977 * |
4609 * |
3978 * @param {WPDataStore} store Store definition. |
4610 * @param {StoreDescriptor} store Store descriptor. |
3979 */ |
4611 */ |
3980 |
4612 |
3981 const build_module_register = default_registry.register; |
4613 const register = default_registry.register; |
3982 |
4614 |
3983 |
4615 }(); |
3984 /***/ }), |
4616 (window.wp = window.wp || {}).data = __webpack_exports__; |
3985 |
4617 /******/ })() |
3986 /***/ "rl8x": |
4618 ; |
3987 /***/ (function(module, exports) { |
|
3988 |
|
3989 (function() { module.exports = window["wp"]["isShallowEqual"]; }()); |
|
3990 |
|
3991 /***/ }), |
|
3992 |
|
3993 /***/ "wx14": |
|
3994 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3995 |
|
3996 "use strict"; |
|
3997 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
3998 function _extends() { |
|
3999 _extends = Object.assign || function (target) { |
|
4000 for (var i = 1; i < arguments.length; i++) { |
|
4001 var source = arguments[i]; |
|
4002 |
|
4003 for (var key in source) { |
|
4004 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
4005 target[key] = source[key]; |
|
4006 } |
|
4007 } |
|
4008 } |
|
4009 |
|
4010 return target; |
|
4011 }; |
|
4012 |
|
4013 return _extends.apply(this, arguments); |
|
4014 } |
|
4015 |
|
4016 /***/ }) |
|
4017 |
|
4018 /******/ }); |