9
|
1 |
this["wp"] = this["wp"] || {}; this["wp"]["data"] =
|
|
2 |
/******/ (function(modules) { // webpackBootstrap
|
|
3 |
/******/ // The module cache
|
|
4 |
/******/ var installedModules = {};
|
|
5 |
/******/
|
|
6 |
/******/ // The require function
|
|
7 |
/******/ function __webpack_require__(moduleId) {
|
|
8 |
/******/
|
|
9 |
/******/ // Check if module is in cache
|
|
10 |
/******/ if(installedModules[moduleId]) {
|
|
11 |
/******/ return installedModules[moduleId].exports;
|
|
12 |
/******/ }
|
|
13 |
/******/ // Create a new module (and put it into the cache)
|
|
14 |
/******/ var module = installedModules[moduleId] = {
|
|
15 |
/******/ i: moduleId,
|
|
16 |
/******/ l: false,
|
|
17 |
/******/ exports: {}
|
|
18 |
/******/ };
|
|
19 |
/******/
|
|
20 |
/******/ // Execute the module function
|
|
21 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22 |
/******/
|
|
23 |
/******/ // Flag the module as loaded
|
|
24 |
/******/ module.l = true;
|
|
25 |
/******/
|
|
26 |
/******/ // Return the exports of the module
|
|
27 |
/******/ return module.exports;
|
|
28 |
/******/ }
|
|
29 |
/******/
|
|
30 |
/******/
|
|
31 |
/******/ // expose the modules object (__webpack_modules__)
|
|
32 |
/******/ __webpack_require__.m = modules;
|
|
33 |
/******/
|
|
34 |
/******/ // expose the module cache
|
|
35 |
/******/ __webpack_require__.c = installedModules;
|
|
36 |
/******/
|
|
37 |
/******/ // define getter function for harmony exports
|
|
38 |
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39 |
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41 |
/******/ }
|
|
42 |
/******/ };
|
|
43 |
/******/
|
|
44 |
/******/ // define __esModule on exports
|
|
45 |
/******/ __webpack_require__.r = function(exports) {
|
|
46 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48 |
/******/ }
|
|
49 |
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50 |
/******/ };
|
|
51 |
/******/
|
|
52 |
/******/ // create a fake namespace object
|
|
53 |
/******/ // mode & 1: value is a module id, require it
|
|
54 |
/******/ // mode & 2: merge all properties of value into the ns
|
|
55 |
/******/ // mode & 4: return value when already ns object
|
|
56 |
/******/ // mode & 8|1: behave like require
|
|
57 |
/******/ __webpack_require__.t = function(value, mode) {
|
|
58 |
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59 |
/******/ if(mode & 8) return value;
|
|
60 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61 |
/******/ var ns = Object.create(null);
|
|
62 |
/******/ __webpack_require__.r(ns);
|
|
63 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
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));
|
|
65 |
/******/ return ns;
|
|
66 |
/******/ };
|
|
67 |
/******/
|
|
68 |
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69 |
/******/ __webpack_require__.n = function(module) {
|
|
70 |
/******/ var getter = module && module.__esModule ?
|
|
71 |
/******/ function getDefault() { return module['default']; } :
|
|
72 |
/******/ function getModuleExports() { return module; };
|
|
73 |
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74 |
/******/ return getter;
|
|
75 |
/******/ };
|
|
76 |
/******/
|
|
77 |
/******/ // Object.prototype.hasOwnProperty.call
|
|
78 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79 |
/******/
|
|
80 |
/******/ // __webpack_public_path__
|
|
81 |
/******/ __webpack_require__.p = "";
|
|
82 |
/******/
|
|
83 |
/******/
|
|
84 |
/******/ // Load entry module and return exports
|
16
|
85 |
/******/ return __webpack_require__(__webpack_require__.s = 442);
|
9
|
86 |
/******/ })
|
|
87 |
/************************************************************************/
|
|
88 |
/******/ ({
|
|
89 |
|
|
90 |
/***/ 0:
|
|
91 |
/***/ (function(module, exports) {
|
|
92 |
|
|
93 |
(function() { module.exports = this["wp"]["element"]; }());
|
|
94 |
|
|
95 |
/***/ }),
|
|
96 |
|
16
|
97 |
/***/ 126:
|
9
|
98 |
/***/ (function(module, exports, __webpack_require__) {
|
|
99 |
|
|
100 |
"use strict";
|
|
101 |
|
|
102 |
|
|
103 |
function _typeof(obj) {
|
|
104 |
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
105 |
_typeof = function (obj) {
|
|
106 |
return typeof obj;
|
|
107 |
};
|
|
108 |
} else {
|
|
109 |
_typeof = function (obj) {
|
|
110 |
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
111 |
};
|
|
112 |
}
|
|
113 |
|
|
114 |
return _typeof(obj);
|
|
115 |
}
|
|
116 |
|
|
117 |
function _classCallCheck(instance, Constructor) {
|
|
118 |
if (!(instance instanceof Constructor)) {
|
|
119 |
throw new TypeError("Cannot call a class as a function");
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
function _defineProperties(target, props) {
|
|
124 |
for (var i = 0; i < props.length; i++) {
|
|
125 |
var descriptor = props[i];
|
|
126 |
descriptor.enumerable = descriptor.enumerable || false;
|
|
127 |
descriptor.configurable = true;
|
|
128 |
if ("value" in descriptor) descriptor.writable = true;
|
|
129 |
Object.defineProperty(target, descriptor.key, descriptor);
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
|
133 |
function _createClass(Constructor, protoProps, staticProps) {
|
|
134 |
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
135 |
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
136 |
return Constructor;
|
|
137 |
}
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Given an instance of EquivalentKeyMap, returns its internal value pair tuple
|
|
141 |
* for a key, if one exists. The tuple members consist of the last reference
|
|
142 |
* value for the key (used in efficient subsequent lookups) and the value
|
|
143 |
* assigned for the key at the leaf node.
|
|
144 |
*
|
|
145 |
* @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
|
|
146 |
* @param {*} key The key for which to return value pair.
|
|
147 |
*
|
|
148 |
* @return {?Array} Value pair, if exists.
|
|
149 |
*/
|
|
150 |
function getValuePair(instance, key) {
|
|
151 |
var _map = instance._map,
|
|
152 |
_arrayTreeMap = instance._arrayTreeMap,
|
|
153 |
_objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
|
|
154 |
// value, which can be used to shortcut immediately to the value.
|
|
155 |
|
|
156 |
if (_map.has(key)) {
|
|
157 |
return _map.get(key);
|
|
158 |
} // Sort keys to ensure stable retrieval from tree.
|
|
159 |
|
|
160 |
|
|
161 |
var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
|
|
162 |
|
|
163 |
var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
|
|
164 |
|
|
165 |
for (var i = 0; i < properties.length; i++) {
|
|
166 |
var property = properties[i];
|
|
167 |
map = map.get(property);
|
|
168 |
|
|
169 |
if (map === undefined) {
|
|
170 |
return;
|
|
171 |
}
|
|
172 |
|
|
173 |
var propertyValue = key[property];
|
|
174 |
map = map.get(propertyValue);
|
|
175 |
|
|
176 |
if (map === undefined) {
|
|
177 |
return;
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
var valuePair = map.get('_ekm_value');
|
|
182 |
|
|
183 |
if (!valuePair) {
|
|
184 |
return;
|
|
185 |
} // If reached, it implies that an object-like key was set with another
|
|
186 |
// reference, so delete the reference and replace with the current.
|
|
187 |
|
|
188 |
|
|
189 |
_map.delete(valuePair[0]);
|
|
190 |
|
|
191 |
valuePair[0] = key;
|
|
192 |
map.set('_ekm_value', valuePair);
|
|
193 |
|
|
194 |
_map.set(key, valuePair);
|
|
195 |
|
|
196 |
return valuePair;
|
|
197 |
}
|
|
198 |
/**
|
|
199 |
* Variant of a Map object which enables lookup by equivalent (deeply equal)
|
|
200 |
* object and array keys.
|
|
201 |
*/
|
|
202 |
|
|
203 |
|
|
204 |
var EquivalentKeyMap =
|
|
205 |
/*#__PURE__*/
|
|
206 |
function () {
|
|
207 |
/**
|
|
208 |
* Constructs a new instance of EquivalentKeyMap.
|
|
209 |
*
|
|
210 |
* @param {Iterable.<*>} iterable Initial pair of key, value for map.
|
|
211 |
*/
|
|
212 |
function EquivalentKeyMap(iterable) {
|
|
213 |
_classCallCheck(this, EquivalentKeyMap);
|
|
214 |
|
|
215 |
this.clear();
|
|
216 |
|
|
217 |
if (iterable instanceof EquivalentKeyMap) {
|
|
218 |
// Map#forEach is only means of iterating with support for IE11.
|
|
219 |
var iterablePairs = [];
|
|
220 |
iterable.forEach(function (value, key) {
|
|
221 |
iterablePairs.push([key, value]);
|
|
222 |
});
|
|
223 |
iterable = iterablePairs;
|
|
224 |
}
|
|
225 |
|
|
226 |
if (iterable != null) {
|
|
227 |
for (var i = 0; i < iterable.length; i++) {
|
|
228 |
this.set(iterable[i][0], iterable[i][1]);
|
|
229 |
}
|
|
230 |
}
|
|
231 |
}
|
|
232 |
/**
|
|
233 |
* Accessor property returning the number of elements.
|
|
234 |
*
|
|
235 |
* @return {number} Number of elements.
|
|
236 |
*/
|
|
237 |
|
|
238 |
|
|
239 |
_createClass(EquivalentKeyMap, [{
|
|
240 |
key: "set",
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Add or update an element with a specified key and value.
|
|
244 |
*
|
|
245 |
* @param {*} key The key of the element to add.
|
|
246 |
* @param {*} value The value of the element to add.
|
|
247 |
*
|
|
248 |
* @return {EquivalentKeyMap} Map instance.
|
|
249 |
*/
|
|
250 |
value: function set(key, value) {
|
|
251 |
// Shortcut non-object-like to set on internal Map.
|
|
252 |
if (key === null || _typeof(key) !== 'object') {
|
|
253 |
this._map.set(key, value);
|
|
254 |
|
|
255 |
return this;
|
|
256 |
} // Sort keys to ensure stable assignment into tree.
|
|
257 |
|
|
258 |
|
|
259 |
var properties = Object.keys(key).sort();
|
|
260 |
var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
|
|
261 |
|
|
262 |
var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
|
|
263 |
|
|
264 |
for (var i = 0; i < properties.length; i++) {
|
|
265 |
var property = properties[i];
|
|
266 |
|
|
267 |
if (!map.has(property)) {
|
|
268 |
map.set(property, new EquivalentKeyMap());
|
|
269 |
}
|
|
270 |
|
|
271 |
map = map.get(property);
|
|
272 |
var propertyValue = key[property];
|
|
273 |
|
|
274 |
if (!map.has(propertyValue)) {
|
|
275 |
map.set(propertyValue, new EquivalentKeyMap());
|
|
276 |
}
|
|
277 |
|
|
278 |
map = map.get(propertyValue);
|
|
279 |
} // If an _ekm_value exists, there was already an equivalent key. Before
|
|
280 |
// overriding, ensure that the old key reference is removed from map to
|
|
281 |
// avoid memory leak of accumulating equivalent keys. This is, in a
|
|
282 |
// sense, a poor man's WeakMap, while still enabling iterability.
|
|
283 |
|
|
284 |
|
|
285 |
var previousValuePair = map.get('_ekm_value');
|
|
286 |
|
|
287 |
if (previousValuePair) {
|
|
288 |
this._map.delete(previousValuePair[0]);
|
|
289 |
}
|
|
290 |
|
|
291 |
map.set('_ekm_value', valuePair);
|
|
292 |
|
|
293 |
this._map.set(key, valuePair);
|
|
294 |
|
|
295 |
return this;
|
|
296 |
}
|
|
297 |
/**
|
|
298 |
* Returns a specified element.
|
|
299 |
*
|
|
300 |
* @param {*} key The key of the element to return.
|
|
301 |
*
|
|
302 |
* @return {?*} The element associated with the specified key or undefined
|
|
303 |
* if the key can't be found.
|
|
304 |
*/
|
|
305 |
|
|
306 |
}, {
|
|
307 |
key: "get",
|
|
308 |
value: function get(key) {
|
|
309 |
// Shortcut non-object-like to get from internal Map.
|
|
310 |
if (key === null || _typeof(key) !== 'object') {
|
|
311 |
return this._map.get(key);
|
|
312 |
}
|
|
313 |
|
|
314 |
var valuePair = getValuePair(this, key);
|
|
315 |
|
|
316 |
if (valuePair) {
|
|
317 |
return valuePair[1];
|
|
318 |
}
|
|
319 |
}
|
|
320 |
/**
|
|
321 |
* Returns a boolean indicating whether an element with the specified key
|
|
322 |
* exists or not.
|
|
323 |
*
|
|
324 |
* @param {*} key The key of the element to test for presence.
|
|
325 |
*
|
|
326 |
* @return {boolean} Whether an element with the specified key exists.
|
|
327 |
*/
|
|
328 |
|
|
329 |
}, {
|
|
330 |
key: "has",
|
|
331 |
value: function has(key) {
|
|
332 |
if (key === null || _typeof(key) !== 'object') {
|
|
333 |
return this._map.has(key);
|
|
334 |
} // Test on the _presence_ of the pair, not its value, as even undefined
|
|
335 |
// can be a valid member value for a key.
|
|
336 |
|
|
337 |
|
|
338 |
return getValuePair(this, key) !== undefined;
|
|
339 |
}
|
|
340 |
/**
|
|
341 |
* Removes the specified element.
|
|
342 |
*
|
|
343 |
* @param {*} key The key of the element to remove.
|
|
344 |
*
|
|
345 |
* @return {boolean} Returns true if an element existed and has been
|
|
346 |
* removed, or false if the element does not exist.
|
|
347 |
*/
|
|
348 |
|
|
349 |
}, {
|
|
350 |
key: "delete",
|
|
351 |
value: function _delete(key) {
|
|
352 |
if (!this.has(key)) {
|
|
353 |
return false;
|
|
354 |
} // This naive implementation will leave orphaned child trees. A better
|
|
355 |
// implementation should traverse and remove orphans.
|
|
356 |
|
|
357 |
|
|
358 |
this.set(key, undefined);
|
|
359 |
return true;
|
|
360 |
}
|
|
361 |
/**
|
|
362 |
* Executes a provided function once per each key/value pair, in insertion
|
|
363 |
* order.
|
|
364 |
*
|
|
365 |
* @param {Function} callback Function to execute for each element.
|
|
366 |
* @param {*} thisArg Value to use as `this` when executing
|
|
367 |
* `callback`.
|
|
368 |
*/
|
|
369 |
|
|
370 |
}, {
|
|
371 |
key: "forEach",
|
|
372 |
value: function forEach(callback) {
|
|
373 |
var _this = this;
|
|
374 |
|
|
375 |
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
|
|
376 |
|
|
377 |
this._map.forEach(function (value, key) {
|
|
378 |
// Unwrap value from object-like value pair.
|
|
379 |
if (key !== null && _typeof(key) === 'object') {
|
|
380 |
value = value[1];
|
|
381 |
}
|
|
382 |
|
|
383 |
callback.call(thisArg, value, key, _this);
|
|
384 |
});
|
|
385 |
}
|
|
386 |
/**
|
|
387 |
* Removes all elements.
|
|
388 |
*/
|
|
389 |
|
|
390 |
}, {
|
|
391 |
key: "clear",
|
|
392 |
value: function clear() {
|
|
393 |
this._map = new Map();
|
|
394 |
this._arrayTreeMap = new Map();
|
|
395 |
this._objectTreeMap = new Map();
|
|
396 |
}
|
|
397 |
}, {
|
|
398 |
key: "size",
|
|
399 |
get: function get() {
|
|
400 |
return this._map.size;
|
|
401 |
}
|
|
402 |
}]);
|
|
403 |
|
|
404 |
return EquivalentKeyMap;
|
|
405 |
}();
|
|
406 |
|
|
407 |
module.exports = EquivalentKeyMap;
|
|
408 |
|
|
409 |
|
|
410 |
/***/ }),
|
|
411 |
|
16
|
412 |
/***/ 127:
|
|
413 |
/***/ (function(module, exports) {
|
|
414 |
|
|
415 |
var g;
|
|
416 |
|
|
417 |
// This works in non-strict mode
|
|
418 |
g = (function() {
|
|
419 |
return this;
|
|
420 |
})();
|
|
421 |
|
|
422 |
try {
|
|
423 |
// This works if eval is allowed (see CSP)
|
|
424 |
g = g || new Function("return this")();
|
|
425 |
} catch (e) {
|
|
426 |
// This works if the window reference is available
|
|
427 |
if (typeof window === "object") g = window;
|
|
428 |
}
|
|
429 |
|
|
430 |
// g can still be undefined, but nothing to do about it...
|
|
431 |
// We return undefined, instead of nothing here, so it's
|
|
432 |
// easier to handle this case. if(!global) { ...}
|
|
433 |
|
|
434 |
module.exports = g;
|
|
435 |
|
|
436 |
|
|
437 |
/***/ }),
|
|
438 |
|
|
439 |
/***/ 13:
|
|
440 |
/***/ (function(module, exports) {
|
|
441 |
|
|
442 |
(function() { module.exports = this["React"]; }());
|
|
443 |
|
|
444 |
/***/ }),
|
|
445 |
|
|
446 |
/***/ 14:
|
9
|
447 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
448 |
|
|
449 |
"use strict";
|
16
|
450 |
|
|
451 |
// EXPORTS
|
|
452 |
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
|
|
453 |
|
|
454 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
455 |
var arrayWithHoles = __webpack_require__(38);
|
|
456 |
|
|
457 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
458 |
function _iterableToArrayLimit(arr, i) {
|
|
459 |
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
460 |
var _arr = [];
|
|
461 |
var _n = true;
|
|
462 |
var _d = false;
|
|
463 |
var _e = undefined;
|
|
464 |
|
|
465 |
try {
|
|
466 |
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
467 |
_arr.push(_s.value);
|
|
468 |
|
|
469 |
if (i && _arr.length === i) break;
|
|
470 |
}
|
|
471 |
} catch (err) {
|
|
472 |
_d = true;
|
|
473 |
_e = err;
|
|
474 |
} finally {
|
|
475 |
try {
|
|
476 |
if (!_n && _i["return"] != null) _i["return"]();
|
|
477 |
} finally {
|
|
478 |
if (_d) throw _e;
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
return _arr;
|
|
483 |
}
|
|
484 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
485 |
var unsupportedIterableToArray = __webpack_require__(29);
|
|
486 |
|
|
487 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
488 |
var nonIterableRest = __webpack_require__(39);
|
|
489 |
|
|
490 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
function _slicedToArray(arr, i) {
|
|
496 |
return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
|
|
497 |
}
|
|
498 |
|
|
499 |
/***/ }),
|
|
500 |
|
|
501 |
/***/ 150:
|
|
502 |
/***/ (function(module, exports) {
|
|
503 |
|
|
504 |
(function() { module.exports = this["wp"]["priorityQueue"]; }());
|
|
505 |
|
|
506 |
/***/ }),
|
|
507 |
|
|
508 |
/***/ 151:
|
|
509 |
/***/ (function(module, exports) {
|
|
510 |
|
|
511 |
module.exports = isPromise;
|
|
512 |
module.exports.default = isPromise;
|
|
513 |
|
|
514 |
function isPromise(obj) {
|
|
515 |
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
|
516 |
}
|
|
517 |
|
|
518 |
|
|
519 |
/***/ }),
|
|
520 |
|
|
521 |
/***/ 163:
|
|
522 |
/***/ (function(module, exports) {
|
|
523 |
|
|
524 |
function combineReducers( reducers ) {
|
|
525 |
var keys = Object.keys( reducers ),
|
|
526 |
getNextState;
|
|
527 |
|
|
528 |
getNextState = ( function() {
|
|
529 |
var fn, i, key;
|
|
530 |
|
|
531 |
fn = 'return {';
|
|
532 |
for ( i = 0; i < keys.length; i++ ) {
|
|
533 |
// Rely on Quoted escaping of JSON.stringify with guarantee that
|
|
534 |
// each member of Object.keys is a string.
|
|
535 |
//
|
|
536 |
// "If Type(value) is String, then return the result of calling the
|
|
537 |
// abstract operation Quote with argument value. [...] The abstract
|
|
538 |
// operation Quote(value) wraps a String value in double quotes and
|
|
539 |
// escapes characters within it."
|
|
540 |
//
|
|
541 |
// https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3
|
|
542 |
key = JSON.stringify( keys[ i ] );
|
|
543 |
|
|
544 |
fn += key + ':r[' + key + '](s[' + key + '],a),';
|
|
545 |
}
|
|
546 |
fn += '}';
|
|
547 |
|
|
548 |
return new Function( 'r,s,a', fn );
|
|
549 |
} )();
|
|
550 |
|
|
551 |
return function combinedReducer( state, action ) {
|
|
552 |
var nextState, i, key;
|
|
553 |
|
|
554 |
// Assumed changed if initial state.
|
|
555 |
if ( state === undefined ) {
|
|
556 |
return getNextState( reducers, {}, action );
|
|
557 |
}
|
|
558 |
|
|
559 |
nextState = getNextState( reducers, state, action );
|
|
560 |
|
|
561 |
// Determine whether state has changed.
|
|
562 |
i = keys.length;
|
|
563 |
while ( i-- ) {
|
|
564 |
key = keys[ i ];
|
|
565 |
if ( state[ key ] !== nextState[ key ] ) {
|
|
566 |
// Return immediately if a changed value is encountered.
|
|
567 |
return nextState;
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
return state;
|
|
572 |
};
|
|
573 |
}
|
|
574 |
|
|
575 |
module.exports = combineReducers;
|
|
576 |
|
|
577 |
|
|
578 |
/***/ }),
|
|
579 |
|
|
580 |
/***/ 18:
|
|
581 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
582 |
|
|
583 |
"use strict";
|
|
584 |
|
|
585 |
// EXPORTS
|
|
586 |
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
|
|
587 |
|
|
588 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
589 |
var arrayLikeToArray = __webpack_require__(26);
|
|
590 |
|
|
591 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
592 |
|
|
593 |
function _arrayWithoutHoles(arr) {
|
|
594 |
if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
|
|
595 |
}
|
|
596 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
|
597 |
var iterableToArray = __webpack_require__(35);
|
|
598 |
|
|
599 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
600 |
var unsupportedIterableToArray = __webpack_require__(29);
|
|
601 |
|
|
602 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
|
603 |
function _nonIterableSpread() {
|
|
604 |
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
605 |
}
|
|
606 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
function _toConsumableArray(arr) {
|
|
612 |
return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
|
|
613 |
}
|
|
614 |
|
|
615 |
/***/ }),
|
|
616 |
|
|
617 |
/***/ 196:
|
|
618 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
619 |
|
|
620 |
"use strict";
|
|
621 |
/* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var _ponyfill_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(275);
|
9
|
622 |
/* global window */
|
|
623 |
|
|
624 |
|
|
625 |
var root;
|
|
626 |
|
|
627 |
if (typeof self !== 'undefined') {
|
|
628 |
root = self;
|
|
629 |
} else if (typeof window !== 'undefined') {
|
|
630 |
root = window;
|
|
631 |
} else if (typeof global !== 'undefined') {
|
|
632 |
root = global;
|
|
633 |
} else if (true) {
|
|
634 |
root = module;
|
|
635 |
} else {}
|
|
636 |
|
|
637 |
var result = Object(_ponyfill_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(root);
|
|
638 |
/* harmony default export */ __webpack_exports__["a"] = (result);
|
|
639 |
|
16
|
640 |
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(127), __webpack_require__(412)(module)))
|
|
641 |
|
|
642 |
/***/ }),
|
|
643 |
|
|
644 |
/***/ 2:
|
|
645 |
/***/ (function(module, exports) {
|
|
646 |
|
|
647 |
(function() { module.exports = this["lodash"]; }());
|
9
|
648 |
|
|
649 |
/***/ }),
|
|
650 |
|
16
|
651 |
/***/ 24:
|
|
652 |
/***/ (function(module, exports) {
|
|
653 |
|
|
654 |
(function() { module.exports = this["regeneratorRuntime"]; }());
|
|
655 |
|
|
656 |
/***/ }),
|
|
657 |
|
|
658 |
/***/ 26:
|
9
|
659 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
660 |
|
|
661 |
"use strict";
|
16
|
662 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
|
|
663 |
function _arrayLikeToArray(arr, len) {
|
|
664 |
if (len == null || len > arr.length) len = arr.length;
|
|
665 |
|
|
666 |
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
667 |
arr2[i] = arr[i];
|
9
|
668 |
}
|
16
|
669 |
|
|
670 |
return arr2;
|
9
|
671 |
}
|
|
672 |
|
|
673 |
/***/ }),
|
|
674 |
|
16
|
675 |
/***/ 274:
|
|
676 |
/***/ (function(module, exports) {
|
|
677 |
|
|
678 |
(function() { module.exports = this["wp"]["reduxRoutine"]; }());
|
|
679 |
|
|
680 |
/***/ }),
|
|
681 |
|
|
682 |
/***/ 275:
|
9
|
683 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
684 |
|
|
685 |
"use strict";
|
|
686 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return symbolObservablePonyfill; });
|
|
687 |
function symbolObservablePonyfill(root) {
|
|
688 |
var result;
|
|
689 |
var Symbol = root.Symbol;
|
|
690 |
|
|
691 |
if (typeof Symbol === 'function') {
|
|
692 |
if (Symbol.observable) {
|
|
693 |
result = Symbol.observable;
|
|
694 |
} else {
|
|
695 |
result = Symbol('observable');
|
|
696 |
Symbol.observable = result;
|
|
697 |
}
|
|
698 |
} else {
|
|
699 |
result = '@@observable';
|
|
700 |
}
|
|
701 |
|
|
702 |
return result;
|
|
703 |
};
|
|
704 |
|
|
705 |
|
16
|
706 |
/***/ }),
|
|
707 |
|
|
708 |
/***/ 29:
|
|
709 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
710 |
|
|
711 |
"use strict";
|
|
712 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
|
|
713 |
/* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
|
|
714 |
|
|
715 |
function _unsupportedIterableToArray(o, minLen) {
|
|
716 |
if (!o) return;
|
|
717 |
if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
718 |
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
719 |
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
720 |
if (n === "Map" || n === "Set") return Array.from(o);
|
|
721 |
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
722 |
}
|
|
723 |
|
|
724 |
/***/ }),
|
|
725 |
|
|
726 |
/***/ 35:
|
|
727 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
728 |
|
|
729 |
"use strict";
|
|
730 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
|
|
731 |
function _iterableToArray(iter) {
|
|
732 |
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
733 |
}
|
|
734 |
|
|
735 |
/***/ }),
|
|
736 |
|
|
737 |
/***/ 37:
|
|
738 |
/***/ (function(module, exports) {
|
|
739 |
|
|
740 |
(function() { module.exports = this["wp"]["deprecated"]; }());
|
|
741 |
|
|
742 |
/***/ }),
|
|
743 |
|
|
744 |
/***/ 38:
|
|
745 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
746 |
|
|
747 |
"use strict";
|
|
748 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
|
|
749 |
function _arrayWithHoles(arr) {
|
|
750 |
if (Array.isArray(arr)) return arr;
|
|
751 |
}
|
|
752 |
|
|
753 |
/***/ }),
|
|
754 |
|
|
755 |
/***/ 39:
|
|
756 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
757 |
|
|
758 |
"use strict";
|
|
759 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
|
|
760 |
function _nonIterableRest() {
|
|
761 |
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
762 |
}
|
|
763 |
|
|
764 |
/***/ }),
|
|
765 |
|
|
766 |
/***/ 412:
|
|
767 |
/***/ (function(module, exports) {
|
|
768 |
|
|
769 |
module.exports = function(originalModule) {
|
|
770 |
if (!originalModule.webpackPolyfill) {
|
|
771 |
var module = Object.create(originalModule);
|
|
772 |
// module.parent = undefined by default
|
|
773 |
if (!module.children) module.children = [];
|
|
774 |
Object.defineProperty(module, "loaded", {
|
|
775 |
enumerable: true,
|
|
776 |
get: function() {
|
|
777 |
return module.l;
|
|
778 |
}
|
|
779 |
});
|
|
780 |
Object.defineProperty(module, "id", {
|
|
781 |
enumerable: true,
|
|
782 |
get: function() {
|
|
783 |
return module.i;
|
|
784 |
}
|
|
785 |
});
|
|
786 |
Object.defineProperty(module, "exports", {
|
|
787 |
enumerable: true
|
|
788 |
});
|
|
789 |
module.webpackPolyfill = 1;
|
|
790 |
}
|
|
791 |
return module;
|
|
792 |
};
|
|
793 |
|
|
794 |
|
|
795 |
/***/ }),
|
|
796 |
|
|
797 |
/***/ 442:
|
|
798 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
799 |
|
|
800 |
"use strict";
|
|
801 |
// ESM COMPAT FLAG
|
|
802 |
__webpack_require__.r(__webpack_exports__);
|
|
803 |
|
|
804 |
// EXPORTS
|
|
805 |
__webpack_require__.d(__webpack_exports__, "withSelect", function() { return /* reexport */ with_select; });
|
|
806 |
__webpack_require__.d(__webpack_exports__, "withDispatch", function() { return /* reexport */ with_dispatch; });
|
|
807 |
__webpack_require__.d(__webpack_exports__, "withRegistry", function() { return /* reexport */ with_registry; });
|
|
808 |
__webpack_require__.d(__webpack_exports__, "RegistryProvider", function() { return /* reexport */ context; });
|
|
809 |
__webpack_require__.d(__webpack_exports__, "RegistryConsumer", function() { return /* reexport */ RegistryConsumer; });
|
|
810 |
__webpack_require__.d(__webpack_exports__, "useRegistry", function() { return /* reexport */ useRegistry; });
|
|
811 |
__webpack_require__.d(__webpack_exports__, "useSelect", function() { return /* reexport */ useSelect; });
|
|
812 |
__webpack_require__.d(__webpack_exports__, "useDispatch", function() { return /* reexport */ use_dispatch; });
|
|
813 |
__webpack_require__.d(__webpack_exports__, "__unstableUseDispatchWithMap", function() { return /* reexport */ use_dispatch_with_map; });
|
|
814 |
__webpack_require__.d(__webpack_exports__, "AsyncModeProvider", function() { return /* reexport */ async_mode_provider_context; });
|
|
815 |
__webpack_require__.d(__webpack_exports__, "createRegistry", function() { return /* reexport */ createRegistry; });
|
|
816 |
__webpack_require__.d(__webpack_exports__, "createRegistrySelector", function() { return /* reexport */ createRegistrySelector; });
|
|
817 |
__webpack_require__.d(__webpack_exports__, "createRegistryControl", function() { return /* reexport */ createRegistryControl; });
|
|
818 |
__webpack_require__.d(__webpack_exports__, "plugins", function() { return /* reexport */ plugins_namespaceObject; });
|
|
819 |
__webpack_require__.d(__webpack_exports__, "combineReducers", function() { return /* reexport */ turbo_combine_reducers_default.a; });
|
|
820 |
__webpack_require__.d(__webpack_exports__, "select", function() { return /* binding */ build_module_select; });
|
|
821 |
__webpack_require__.d(__webpack_exports__, "__experimentalResolveSelect", function() { return /* binding */ build_module_experimentalResolveSelect; });
|
|
822 |
__webpack_require__.d(__webpack_exports__, "dispatch", function() { return /* binding */ build_module_dispatch; });
|
|
823 |
__webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* binding */ build_module_subscribe; });
|
|
824 |
__webpack_require__.d(__webpack_exports__, "registerGenericStore", function() { return /* binding */ build_module_registerGenericStore; });
|
|
825 |
__webpack_require__.d(__webpack_exports__, "registerStore", function() { return /* binding */ build_module_registerStore; });
|
|
826 |
__webpack_require__.d(__webpack_exports__, "use", function() { return /* binding */ build_module_use; });
|
|
827 |
|
|
828 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/selectors.js
|
|
829 |
var selectors_namespaceObject = {};
|
|
830 |
__webpack_require__.r(selectors_namespaceObject);
|
|
831 |
__webpack_require__.d(selectors_namespaceObject, "getIsResolving", function() { return getIsResolving; });
|
|
832 |
__webpack_require__.d(selectors_namespaceObject, "hasStartedResolution", function() { return hasStartedResolution; });
|
|
833 |
__webpack_require__.d(selectors_namespaceObject, "hasFinishedResolution", function() { return hasFinishedResolution; });
|
|
834 |
__webpack_require__.d(selectors_namespaceObject, "isResolving", function() { return isResolving; });
|
|
835 |
__webpack_require__.d(selectors_namespaceObject, "getCachedResolvers", function() { return getCachedResolvers; });
|
|
836 |
|
|
837 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/actions.js
|
|
838 |
var actions_namespaceObject = {};
|
|
839 |
__webpack_require__.r(actions_namespaceObject);
|
|
840 |
__webpack_require__.d(actions_namespaceObject, "startResolution", function() { return startResolution; });
|
|
841 |
__webpack_require__.d(actions_namespaceObject, "finishResolution", function() { return finishResolution; });
|
|
842 |
__webpack_require__.d(actions_namespaceObject, "invalidateResolution", function() { return invalidateResolution; });
|
|
843 |
__webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStore", function() { return invalidateResolutionForStore; });
|
|
844 |
__webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStoreSelector", function() { return invalidateResolutionForStoreSelector; });
|
|
845 |
|
|
846 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js
|
|
847 |
var plugins_namespaceObject = {};
|
|
848 |
__webpack_require__.r(plugins_namespaceObject);
|
|
849 |
__webpack_require__.d(plugins_namespaceObject, "controls", function() { return controls; });
|
|
850 |
__webpack_require__.d(plugins_namespaceObject, "persistence", function() { return plugins_persistence; });
|
|
851 |
|
|
852 |
// EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js
|
|
853 |
var turbo_combine_reducers = __webpack_require__(163);
|
|
854 |
var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers);
|
|
855 |
|
|
856 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
|
857 |
var slicedToArray = __webpack_require__(14);
|
|
858 |
|
|
859 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
860 |
var defineProperty = __webpack_require__(5);
|
|
861 |
|
|
862 |
// EXTERNAL MODULE: external {"this":"lodash"}
|
|
863 |
var external_this_lodash_ = __webpack_require__(2);
|
|
864 |
|
|
865 |
// EXTERNAL MODULE: ./node_modules/memize/index.js
|
|
866 |
var memize = __webpack_require__(60);
|
|
867 |
var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
|
|
868 |
|
|
869 |
// EXTERNAL MODULE: external {"this":"regeneratorRuntime"}
|
|
870 |
var external_this_regeneratorRuntime_ = __webpack_require__(24);
|
|
871 |
var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_);
|
|
872 |
|
|
873 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
|
|
874 |
var asyncToGenerator = __webpack_require__(50);
|
|
875 |
|
|
876 |
// EXTERNAL MODULE: ./node_modules/symbol-observable/es/index.js
|
|
877 |
var es = __webpack_require__(196);
|
|
878 |
|
|
879 |
// CONCATENATED MODULE: ./node_modules/redux/es/redux.js
|
|
880 |
|
|
881 |
|
|
882 |
/**
|
|
883 |
* These are private action types reserved by Redux.
|
|
884 |
* For any unknown actions, you must return the current state.
|
|
885 |
* If the current state is undefined, you must return the initial state.
|
|
886 |
* Do not reference these action types directly in your code.
|
|
887 |
*/
|
|
888 |
var randomString = function randomString() {
|
|
889 |
return Math.random().toString(36).substring(7).split('').join('.');
|
|
890 |
};
|
|
891 |
|
|
892 |
var ActionTypes = {
|
|
893 |
INIT: "@@redux/INIT" + randomString(),
|
|
894 |
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
895 |
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
896 |
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
897 |
}
|
|
898 |
};
|
|
899 |
|
|
900 |
/**
|
|
901 |
* @param {any} obj The object to inspect.
|
|
902 |
* @returns {boolean} True if the argument appears to be a plain object.
|
|
903 |
*/
|
|
904 |
function isPlainObject(obj) {
|
|
905 |
if (typeof obj !== 'object' || obj === null) return false;
|
|
906 |
var proto = obj;
|
|
907 |
|
|
908 |
while (Object.getPrototypeOf(proto) !== null) {
|
|
909 |
proto = Object.getPrototypeOf(proto);
|
|
910 |
}
|
|
911 |
|
|
912 |
return Object.getPrototypeOf(obj) === proto;
|
|
913 |
}
|
|
914 |
|
|
915 |
/**
|
|
916 |
* Creates a Redux store that holds the state tree.
|
|
917 |
* The only way to change the data in the store is to call `dispatch()` on it.
|
|
918 |
*
|
|
919 |
* There should only be a single store in your app. To specify how different
|
|
920 |
* parts of the state tree respond to actions, you may combine several reducers
|
|
921 |
* into a single reducer function by using `combineReducers`.
|
|
922 |
*
|
|
923 |
* @param {Function} reducer A function that returns the next state tree, given
|
|
924 |
* the current state tree and the action to handle.
|
|
925 |
*
|
|
926 |
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
|
927 |
* to hydrate the state from the server in universal apps, or to restore a
|
|
928 |
* previously serialized user session.
|
|
929 |
* If you use `combineReducers` to produce the root reducer function, this must be
|
|
930 |
* an object with the same shape as `combineReducers` keys.
|
|
931 |
*
|
|
932 |
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
|
933 |
* to enhance the store with third-party capabilities such as middleware,
|
|
934 |
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
|
935 |
* is `applyMiddleware()`.
|
|
936 |
*
|
|
937 |
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
|
938 |
* and subscribe to changes.
|
|
939 |
*/
|
|
940 |
|
|
941 |
function createStore(reducer, preloadedState, enhancer) {
|
|
942 |
var _ref2;
|
|
943 |
|
|
944 |
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
|
945 |
throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.');
|
|
946 |
}
|
|
947 |
|
|
948 |
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
|
949 |
enhancer = preloadedState;
|
|
950 |
preloadedState = undefined;
|
|
951 |
}
|
|
952 |
|
|
953 |
if (typeof enhancer !== 'undefined') {
|
|
954 |
if (typeof enhancer !== 'function') {
|
|
955 |
throw new Error('Expected the enhancer to be a function.');
|
|
956 |
}
|
|
957 |
|
|
958 |
return enhancer(createStore)(reducer, preloadedState);
|
|
959 |
}
|
|
960 |
|
|
961 |
if (typeof reducer !== 'function') {
|
|
962 |
throw new Error('Expected the reducer to be a function.');
|
|
963 |
}
|
|
964 |
|
|
965 |
var currentReducer = reducer;
|
|
966 |
var currentState = preloadedState;
|
|
967 |
var currentListeners = [];
|
|
968 |
var nextListeners = currentListeners;
|
|
969 |
var isDispatching = false;
|
|
970 |
/**
|
|
971 |
* This makes a shallow copy of currentListeners so we can use
|
|
972 |
* nextListeners as a temporary list while dispatching.
|
|
973 |
*
|
|
974 |
* This prevents any bugs around consumers calling
|
|
975 |
* subscribe/unsubscribe in the middle of a dispatch.
|
|
976 |
*/
|
|
977 |
|
|
978 |
function ensureCanMutateNextListeners() {
|
|
979 |
if (nextListeners === currentListeners) {
|
|
980 |
nextListeners = currentListeners.slice();
|
|
981 |
}
|
|
982 |
}
|
|
983 |
/**
|
|
984 |
* Reads the state tree managed by the store.
|
|
985 |
*
|
|
986 |
* @returns {any} The current state tree of your application.
|
|
987 |
*/
|
|
988 |
|
|
989 |
|
|
990 |
function getState() {
|
|
991 |
if (isDispatching) {
|
|
992 |
throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
|
993 |
}
|
|
994 |
|
|
995 |
return currentState;
|
|
996 |
}
|
|
997 |
/**
|
|
998 |
* Adds a change listener. It will be called any time an action is dispatched,
|
|
999 |
* and some part of the state tree may potentially have changed. You may then
|
|
1000 |
* call `getState()` to read the current state tree inside the callback.
|
|
1001 |
*
|
|
1002 |
* You may call `dispatch()` from a change listener, with the following
|
|
1003 |
* caveats:
|
|
1004 |
*
|
|
1005 |
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
|
1006 |
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
|
1007 |
* will not have any effect on the `dispatch()` that is currently in progress.
|
|
1008 |
* However, the next `dispatch()` call, whether nested or not, will use a more
|
|
1009 |
* recent snapshot of the subscription list.
|
|
1010 |
*
|
|
1011 |
* 2. The listener should not expect to see all state changes, as the state
|
|
1012 |
* might have been updated multiple times during a nested `dispatch()` before
|
|
1013 |
* the listener is called. It is, however, guaranteed that all subscribers
|
|
1014 |
* registered before the `dispatch()` started will be called with the latest
|
|
1015 |
* state by the time it exits.
|
|
1016 |
*
|
|
1017 |
* @param {Function} listener A callback to be invoked on every dispatch.
|
|
1018 |
* @returns {Function} A function to remove this change listener.
|
|
1019 |
*/
|
|
1020 |
|
|
1021 |
|
|
1022 |
function subscribe(listener) {
|
|
1023 |
if (typeof listener !== 'function') {
|
|
1024 |
throw new Error('Expected the listener to be a function.');
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
if (isDispatching) {
|
|
1028 |
throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
var isSubscribed = true;
|
|
1032 |
ensureCanMutateNextListeners();
|
|
1033 |
nextListeners.push(listener);
|
|
1034 |
return function unsubscribe() {
|
|
1035 |
if (!isSubscribed) {
|
|
1036 |
return;
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
if (isDispatching) {
|
|
1040 |
throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
isSubscribed = false;
|
|
1044 |
ensureCanMutateNextListeners();
|
|
1045 |
var index = nextListeners.indexOf(listener);
|
|
1046 |
nextListeners.splice(index, 1);
|
|
1047 |
currentListeners = null;
|
|
1048 |
};
|
|
1049 |
}
|
|
1050 |
/**
|
|
1051 |
* Dispatches an action. It is the only way to trigger a state change.
|
|
1052 |
*
|
|
1053 |
* The `reducer` function, used to create the store, will be called with the
|
|
1054 |
* current state tree and the given `action`. Its return value will
|
|
1055 |
* be considered the **next** state of the tree, and the change listeners
|
|
1056 |
* will be notified.
|
|
1057 |
*
|
|
1058 |
* The base implementation only supports plain object actions. If you want to
|
|
1059 |
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
|
1060 |
* wrap your store creating function into the corresponding middleware. For
|
|
1061 |
* example, see the documentation for the `redux-thunk` package. Even the
|
|
1062 |
* middleware will eventually dispatch plain object actions using this method.
|
|
1063 |
*
|
|
1064 |
* @param {Object} action A plain object representing “what changed”. It is
|
|
1065 |
* a good idea to keep actions serializable so you can record and replay user
|
|
1066 |
* sessions, or use the time travelling `redux-devtools`. An action must have
|
|
1067 |
* a `type` property which may not be `undefined`. It is a good idea to use
|
|
1068 |
* string constants for action types.
|
|
1069 |
*
|
|
1070 |
* @returns {Object} For convenience, the same action object you dispatched.
|
|
1071 |
*
|
|
1072 |
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
|
1073 |
* return something else (for example, a Promise you can await).
|
|
1074 |
*/
|
|
1075 |
|
|
1076 |
|
|
1077 |
function dispatch(action) {
|
|
1078 |
if (!isPlainObject(action)) {
|
|
1079 |
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
if (typeof action.type === 'undefined') {
|
|
1083 |
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
|
|
1084 |
}
|
|
1085 |
|
|
1086 |
if (isDispatching) {
|
|
1087 |
throw new Error('Reducers may not dispatch actions.');
|
|
1088 |
}
|
|
1089 |
|
|
1090 |
try {
|
|
1091 |
isDispatching = true;
|
|
1092 |
currentState = currentReducer(currentState, action);
|
|
1093 |
} finally {
|
|
1094 |
isDispatching = false;
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
var listeners = currentListeners = nextListeners;
|
|
1098 |
|
|
1099 |
for (var i = 0; i < listeners.length; i++) {
|
|
1100 |
var listener = listeners[i];
|
|
1101 |
listener();
|
|
1102 |
}
|
|
1103 |
|
|
1104 |
return action;
|
|
1105 |
}
|
|
1106 |
/**
|
|
1107 |
* Replaces the reducer currently used by the store to calculate the state.
|
|
1108 |
*
|
|
1109 |
* You might need this if your app implements code splitting and you want to
|
|
1110 |
* load some of the reducers dynamically. You might also need this if you
|
|
1111 |
* implement a hot reloading mechanism for Redux.
|
|
1112 |
*
|
|
1113 |
* @param {Function} nextReducer The reducer for the store to use instead.
|
|
1114 |
* @returns {void}
|
|
1115 |
*/
|
|
1116 |
|
|
1117 |
|
|
1118 |
function replaceReducer(nextReducer) {
|
|
1119 |
if (typeof nextReducer !== 'function') {
|
|
1120 |
throw new Error('Expected the nextReducer to be a function.');
|
|
1121 |
}
|
|
1122 |
|
|
1123 |
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
|
1124 |
// Any reducers that existed in both the new and old rootReducer
|
|
1125 |
// will receive the previous state. This effectively populates
|
|
1126 |
// the new state tree with any relevant data from the old one.
|
|
1127 |
|
|
1128 |
dispatch({
|
|
1129 |
type: ActionTypes.REPLACE
|
|
1130 |
});
|
|
1131 |
}
|
|
1132 |
/**
|
|
1133 |
* Interoperability point for observable/reactive libraries.
|
|
1134 |
* @returns {observable} A minimal observable of state changes.
|
|
1135 |
* For more information, see the observable proposal:
|
|
1136 |
* https://github.com/tc39/proposal-observable
|
|
1137 |
*/
|
|
1138 |
|
|
1139 |
|
|
1140 |
function observable() {
|
|
1141 |
var _ref;
|
|
1142 |
|
|
1143 |
var outerSubscribe = subscribe;
|
|
1144 |
return _ref = {
|
|
1145 |
/**
|
|
1146 |
* The minimal observable subscription method.
|
|
1147 |
* @param {Object} observer Any object that can be used as an observer.
|
|
1148 |
* The observer object should have a `next` method.
|
|
1149 |
* @returns {subscription} An object with an `unsubscribe` method that can
|
|
1150 |
* be used to unsubscribe the observable from the store, and prevent further
|
|
1151 |
* emission of values from the observable.
|
|
1152 |
*/
|
|
1153 |
subscribe: function subscribe(observer) {
|
|
1154 |
if (typeof observer !== 'object' || observer === null) {
|
|
1155 |
throw new TypeError('Expected the observer to be an object.');
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
function observeState() {
|
|
1159 |
if (observer.next) {
|
|
1160 |
observer.next(getState());
|
|
1161 |
}
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
observeState();
|
|
1165 |
var unsubscribe = outerSubscribe(observeState);
|
|
1166 |
return {
|
|
1167 |
unsubscribe: unsubscribe
|
|
1168 |
};
|
|
1169 |
}
|
|
1170 |
}, _ref[es["a" /* default */]] = function () {
|
|
1171 |
return this;
|
|
1172 |
}, _ref;
|
|
1173 |
} // When a store is created, an "INIT" action is dispatched so that every
|
|
1174 |
// reducer returns their initial state. This effectively populates
|
|
1175 |
// the initial state tree.
|
|
1176 |
|
|
1177 |
|
|
1178 |
dispatch({
|
|
1179 |
type: ActionTypes.INIT
|
|
1180 |
});
|
|
1181 |
return _ref2 = {
|
|
1182 |
dispatch: dispatch,
|
|
1183 |
subscribe: subscribe,
|
|
1184 |
getState: getState,
|
|
1185 |
replaceReducer: replaceReducer
|
|
1186 |
}, _ref2[es["a" /* default */]] = observable, _ref2;
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
/**
|
|
1190 |
* Prints a warning in the console if it exists.
|
|
1191 |
*
|
|
1192 |
* @param {String} message The warning message.
|
|
1193 |
* @returns {void}
|
|
1194 |
*/
|
|
1195 |
function warning(message) {
|
|
1196 |
/* eslint-disable no-console */
|
|
1197 |
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
1198 |
console.error(message);
|
|
1199 |
}
|
|
1200 |
/* eslint-enable no-console */
|
|
1201 |
|
|
1202 |
|
|
1203 |
try {
|
|
1204 |
// This error was thrown as a convenience so that if you enable
|
|
1205 |
// "break on all exceptions" in your console,
|
|
1206 |
// it would pause the execution at this line.
|
|
1207 |
throw new Error(message);
|
|
1208 |
} catch (e) {} // eslint-disable-line no-empty
|
|
1209 |
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
function getUndefinedStateErrorMessage(key, action) {
|
|
1213 |
var actionType = action && action.type;
|
|
1214 |
var actionDescription = actionType && "action \"" + String(actionType) + "\"" || 'an action';
|
|
1215 |
return "Given " + actionDescription + ", reducer \"" + key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.";
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
1219 |
var reducerKeys = Object.keys(reducers);
|
|
1220 |
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
|
1221 |
|
|
1222 |
if (reducerKeys.length === 0) {
|
|
1223 |
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
if (!isPlainObject(inputState)) {
|
|
1227 |
return "The " + argumentName + " has unexpected type of \"" + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
|
1231 |
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
|
1232 |
});
|
|
1233 |
unexpectedKeys.forEach(function (key) {
|
|
1234 |
unexpectedKeyCache[key] = true;
|
|
1235 |
});
|
|
1236 |
if (action && action.type === ActionTypes.REPLACE) return;
|
|
1237 |
|
|
1238 |
if (unexpectedKeys.length > 0) {
|
|
1239 |
return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
|
|
1240 |
}
|
|
1241 |
}
|
|
1242 |
|
|
1243 |
function assertReducerShape(reducers) {
|
|
1244 |
Object.keys(reducers).forEach(function (key) {
|
|
1245 |
var reducer = reducers[key];
|
|
1246 |
var initialState = reducer(undefined, {
|
|
1247 |
type: ActionTypes.INIT
|
|
1248 |
});
|
|
1249 |
|
|
1250 |
if (typeof initialState === 'undefined') {
|
|
1251 |
throw new Error("Reducer \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
|
|
1252 |
}
|
|
1253 |
|
|
1254 |
if (typeof reducer(undefined, {
|
|
1255 |
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
|
1256 |
}) === 'undefined') {
|
|
1257 |
throw new Error("Reducer \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle " + ActionTypes.INIT + " or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
|
|
1258 |
}
|
|
1259 |
});
|
|
1260 |
}
|
|
1261 |
/**
|
|
1262 |
* Turns an object whose values are different reducer functions, into a single
|
|
1263 |
* reducer function. It will call every child reducer, and gather their results
|
|
1264 |
* into a single state object, whose keys correspond to the keys of the passed
|
|
1265 |
* reducer functions.
|
|
1266 |
*
|
|
1267 |
* @param {Object} reducers An object whose values correspond to different
|
|
1268 |
* reducer functions that need to be combined into one. One handy way to obtain
|
|
1269 |
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
|
1270 |
* undefined for any action. Instead, they should return their initial state
|
|
1271 |
* if the state passed to them was undefined, and the current state for any
|
|
1272 |
* unrecognized action.
|
|
1273 |
*
|
|
1274 |
* @returns {Function} A reducer function that invokes every reducer inside the
|
|
1275 |
* passed object, and builds a state object with the same shape.
|
|
1276 |
*/
|
|
1277 |
|
|
1278 |
|
|
1279 |
function combineReducers(reducers) {
|
|
1280 |
var reducerKeys = Object.keys(reducers);
|
|
1281 |
var finalReducers = {};
|
|
1282 |
|
|
1283 |
for (var i = 0; i < reducerKeys.length; i++) {
|
|
1284 |
var key = reducerKeys[i];
|
|
1285 |
|
|
1286 |
if (false) {}
|
|
1287 |
|
|
1288 |
if (typeof reducers[key] === 'function') {
|
|
1289 |
finalReducers[key] = reducers[key];
|
|
1290 |
}
|
|
1291 |
}
|
|
1292 |
|
|
1293 |
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
|
1294 |
// keys multiple times.
|
|
1295 |
|
|
1296 |
var unexpectedKeyCache;
|
|
1297 |
|
|
1298 |
if (false) {}
|
|
1299 |
|
|
1300 |
var shapeAssertionError;
|
|
1301 |
|
|
1302 |
try {
|
|
1303 |
assertReducerShape(finalReducers);
|
|
1304 |
} catch (e) {
|
|
1305 |
shapeAssertionError = e;
|
|
1306 |
}
|
|
1307 |
|
|
1308 |
return function combination(state, action) {
|
|
1309 |
if (state === void 0) {
|
|
1310 |
state = {};
|
|
1311 |
}
|
|
1312 |
|
|
1313 |
if (shapeAssertionError) {
|
|
1314 |
throw shapeAssertionError;
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
if (false) { var warningMessage; }
|
|
1318 |
|
|
1319 |
var hasChanged = false;
|
|
1320 |
var nextState = {};
|
|
1321 |
|
|
1322 |
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
|
1323 |
var _key = finalReducerKeys[_i];
|
|
1324 |
var reducer = finalReducers[_key];
|
|
1325 |
var previousStateForKey = state[_key];
|
|
1326 |
var nextStateForKey = reducer(previousStateForKey, action);
|
|
1327 |
|
|
1328 |
if (typeof nextStateForKey === 'undefined') {
|
|
1329 |
var errorMessage = getUndefinedStateErrorMessage(_key, action);
|
|
1330 |
throw new Error(errorMessage);
|
|
1331 |
}
|
|
1332 |
|
|
1333 |
nextState[_key] = nextStateForKey;
|
|
1334 |
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
1335 |
}
|
|
1336 |
|
|
1337 |
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
1338 |
return hasChanged ? nextState : state;
|
|
1339 |
};
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
function bindActionCreator(actionCreator, dispatch) {
|
|
1343 |
return function () {
|
|
1344 |
return dispatch(actionCreator.apply(this, arguments));
|
|
1345 |
};
|
|
1346 |
}
|
|
1347 |
/**
|
|
1348 |
* Turns an object whose values are action creators, into an object with the
|
|
1349 |
* same keys, but with every function wrapped into a `dispatch` call so they
|
|
1350 |
* may be invoked directly. This is just a convenience method, as you can call
|
|
1351 |
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
|
1352 |
*
|
|
1353 |
* For convenience, you can also pass an action creator as the first argument,
|
|
1354 |
* and get a dispatch wrapped function in return.
|
|
1355 |
*
|
|
1356 |
* @param {Function|Object} actionCreators An object whose values are action
|
|
1357 |
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
|
1358 |
* syntax. You may also pass a single function.
|
|
1359 |
*
|
|
1360 |
* @param {Function} dispatch The `dispatch` function available on your Redux
|
|
1361 |
* store.
|
|
1362 |
*
|
|
1363 |
* @returns {Function|Object} The object mimicking the original object, but with
|
|
1364 |
* every action creator wrapped into the `dispatch` call. If you passed a
|
|
1365 |
* function as `actionCreators`, the return value will also be a single
|
|
1366 |
* function.
|
|
1367 |
*/
|
|
1368 |
|
|
1369 |
|
|
1370 |
function bindActionCreators(actionCreators, dispatch) {
|
|
1371 |
if (typeof actionCreators === 'function') {
|
|
1372 |
return bindActionCreator(actionCreators, dispatch);
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
|
1376 |
throw new Error("bindActionCreators expected an object or a function, instead received " + (actionCreators === null ? 'null' : typeof actionCreators) + ". " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
|
|
1377 |
}
|
|
1378 |
|
|
1379 |
var boundActionCreators = {};
|
|
1380 |
|
|
1381 |
for (var key in actionCreators) {
|
|
1382 |
var actionCreator = actionCreators[key];
|
|
1383 |
|
|
1384 |
if (typeof actionCreator === 'function') {
|
|
1385 |
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
|
1386 |
}
|
|
1387 |
}
|
|
1388 |
|
|
1389 |
return boundActionCreators;
|
|
1390 |
}
|
|
1391 |
|
|
1392 |
function _defineProperty(obj, key, value) {
|
|
1393 |
if (key in obj) {
|
|
1394 |
Object.defineProperty(obj, key, {
|
|
1395 |
value: value,
|
|
1396 |
enumerable: true,
|
|
1397 |
configurable: true,
|
|
1398 |
writable: true
|
|
1399 |
});
|
|
1400 |
} else {
|
|
1401 |
obj[key] = value;
|
|
1402 |
}
|
|
1403 |
|
|
1404 |
return obj;
|
|
1405 |
}
|
|
1406 |
|
|
1407 |
function ownKeys(object, enumerableOnly) {
|
|
1408 |
var keys = Object.keys(object);
|
|
1409 |
|
|
1410 |
if (Object.getOwnPropertySymbols) {
|
|
1411 |
keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
if (enumerableOnly) keys = keys.filter(function (sym) {
|
|
1415 |
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1416 |
});
|
|
1417 |
return keys;
|
|
1418 |
}
|
|
1419 |
|
|
1420 |
function _objectSpread2(target) {
|
|
1421 |
for (var i = 1; i < arguments.length; i++) {
|
|
1422 |
var source = arguments[i] != null ? arguments[i] : {};
|
|
1423 |
|
|
1424 |
if (i % 2) {
|
|
1425 |
ownKeys(source, true).forEach(function (key) {
|
|
1426 |
_defineProperty(target, key, source[key]);
|
|
1427 |
});
|
|
1428 |
} else if (Object.getOwnPropertyDescriptors) {
|
|
1429 |
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1430 |
} else {
|
|
1431 |
ownKeys(source).forEach(function (key) {
|
|
1432 |
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1433 |
});
|
|
1434 |
}
|
|
1435 |
}
|
|
1436 |
|
|
1437 |
return target;
|
|
1438 |
}
|
|
1439 |
|
|
1440 |
/**
|
|
1441 |
* Composes single-argument functions from right to left. The rightmost
|
|
1442 |
* function can take multiple arguments as it provides the signature for
|
|
1443 |
* the resulting composite function.
|
|
1444 |
*
|
|
1445 |
* @param {...Function} funcs The functions to compose.
|
|
1446 |
* @returns {Function} A function obtained by composing the argument functions
|
|
1447 |
* from right to left. For example, compose(f, g, h) is identical to doing
|
|
1448 |
* (...args) => f(g(h(...args))).
|
|
1449 |
*/
|
|
1450 |
function compose() {
|
|
1451 |
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1452 |
funcs[_key] = arguments[_key];
|
|
1453 |
}
|
|
1454 |
|
|
1455 |
if (funcs.length === 0) {
|
|
1456 |
return function (arg) {
|
|
1457 |
return arg;
|
|
1458 |
};
|
|
1459 |
}
|
|
1460 |
|
|
1461 |
if (funcs.length === 1) {
|
|
1462 |
return funcs[0];
|
|
1463 |
}
|
|
1464 |
|
|
1465 |
return funcs.reduce(function (a, b) {
|
|
1466 |
return function () {
|
|
1467 |
return a(b.apply(void 0, arguments));
|
|
1468 |
};
|
|
1469 |
});
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
/**
|
|
1473 |
* Creates a store enhancer that applies middleware to the dispatch method
|
|
1474 |
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
|
1475 |
* asynchronous actions in a concise manner, or logging every action payload.
|
|
1476 |
*
|
|
1477 |
* See `redux-thunk` package as an example of the Redux middleware.
|
|
1478 |
*
|
|
1479 |
* Because middleware is potentially asynchronous, this should be the first
|
|
1480 |
* store enhancer in the composition chain.
|
|
1481 |
*
|
|
1482 |
* Note that each middleware will be given the `dispatch` and `getState` functions
|
|
1483 |
* as named arguments.
|
|
1484 |
*
|
|
1485 |
* @param {...Function} middlewares The middleware chain to be applied.
|
|
1486 |
* @returns {Function} A store enhancer applying the middleware.
|
|
1487 |
*/
|
|
1488 |
|
|
1489 |
function applyMiddleware() {
|
|
1490 |
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1491 |
middlewares[_key] = arguments[_key];
|
|
1492 |
}
|
|
1493 |
|
|
1494 |
return function (createStore) {
|
|
1495 |
return function () {
|
|
1496 |
var store = createStore.apply(void 0, arguments);
|
|
1497 |
|
|
1498 |
var _dispatch = function dispatch() {
|
|
1499 |
throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
|
1500 |
};
|
|
1501 |
|
|
1502 |
var middlewareAPI = {
|
|
1503 |
getState: store.getState,
|
|
1504 |
dispatch: function dispatch() {
|
|
1505 |
return _dispatch.apply(void 0, arguments);
|
|
1506 |
}
|
|
1507 |
};
|
|
1508 |
var chain = middlewares.map(function (middleware) {
|
|
1509 |
return middleware(middlewareAPI);
|
|
1510 |
});
|
|
1511 |
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
|
1512 |
return _objectSpread2({}, store, {
|
|
1513 |
dispatch: _dispatch
|
|
1514 |
});
|
|
1515 |
};
|
|
1516 |
};
|
|
1517 |
}
|
|
1518 |
|
|
1519 |
/*
|
|
1520 |
* This is a dummy function to check if the function name has been altered by minification.
|
|
1521 |
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
|
1522 |
*/
|
|
1523 |
|
|
1524 |
function isCrushed() {}
|
|
1525 |
|
|
1526 |
if (false) {}
|
|
1527 |
|
|
1528 |
|
|
1529 |
|
|
1530 |
// EXTERNAL MODULE: external {"this":["wp","reduxRoutine"]}
|
|
1531 |
var external_this_wp_reduxRoutine_ = __webpack_require__(274);
|
|
1532 |
var external_this_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_reduxRoutine_);
|
|
1533 |
|
|
1534 |
// EXTERNAL MODULE: ./node_modules/is-promise/index.js
|
|
1535 |
var is_promise = __webpack_require__(151);
|
|
1536 |
var is_promise_default = /*#__PURE__*/__webpack_require__.n(is_promise);
|
|
1537 |
|
|
1538 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js
|
|
1539 |
/**
|
|
1540 |
* External dependencies
|
|
1541 |
*/
|
|
1542 |
|
|
1543 |
/**
|
|
1544 |
* Simplest possible promise redux middleware.
|
|
1545 |
*
|
|
1546 |
* @return {Function} middleware.
|
|
1547 |
*/
|
|
1548 |
|
|
1549 |
var promise_middleware_promiseMiddleware = function promiseMiddleware() {
|
|
1550 |
return function (next) {
|
|
1551 |
return function (action) {
|
|
1552 |
if (is_promise_default()(action)) {
|
|
1553 |
return action.then(function (resolvedAction) {
|
|
1554 |
if (resolvedAction) {
|
|
1555 |
return next(resolvedAction);
|
|
1556 |
}
|
|
1557 |
});
|
|
1558 |
}
|
|
1559 |
|
|
1560 |
return next(action);
|
|
1561 |
};
|
|
1562 |
};
|
|
1563 |
};
|
|
1564 |
|
|
1565 |
/* harmony default export */ var promise_middleware = (promise_middleware_promiseMiddleware);
|
|
1566 |
|
|
1567 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
|
|
1568 |
var toConsumableArray = __webpack_require__(18);
|
|
1569 |
|
|
1570 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js
|
|
1571 |
|
|
1572 |
|
|
1573 |
|
|
1574 |
/**
|
|
1575 |
* External dependencies
|
|
1576 |
*/
|
|
1577 |
|
|
1578 |
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
|
|
1579 |
|
|
1580 |
/**
|
|
1581 |
* Creates a middleware handling resolvers cache invalidation.
|
|
1582 |
*
|
|
1583 |
* @param {WPDataRegistry} registry The registry reference for which to create
|
|
1584 |
* the middleware.
|
|
1585 |
* @param {string} reducerKey The namespace for which to create the
|
|
1586 |
* middleware.
|
|
1587 |
*
|
|
1588 |
* @return {Function} Middleware function.
|
|
1589 |
*/
|
|
1590 |
|
|
1591 |
var resolvers_cache_middleware_createResolversCacheMiddleware = function createResolversCacheMiddleware(registry, reducerKey) {
|
|
1592 |
return function () {
|
|
1593 |
return function (next) {
|
|
1594 |
return function (action) {
|
|
1595 |
var resolvers = registry.select('core/data').getCachedResolvers(reducerKey);
|
|
1596 |
Object.entries(resolvers).forEach(function (_ref) {
|
|
1597 |
var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
|
|
1598 |
selectorName = _ref2[0],
|
|
1599 |
resolversByArgs = _ref2[1];
|
|
1600 |
|
|
1601 |
var resolver = Object(external_this_lodash_["get"])(registry.stores, [reducerKey, 'resolvers', selectorName]);
|
|
1602 |
|
|
1603 |
if (!resolver || !resolver.shouldInvalidate) {
|
|
1604 |
return;
|
|
1605 |
}
|
|
1606 |
|
|
1607 |
resolversByArgs.forEach(function (value, args) {
|
|
1608 |
// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
|
|
1609 |
// If the value is false it means this resolver has finished its resolution which means we need to invalidate it,
|
|
1610 |
// if it's true it means it's inflight and the invalidation is not necessary.
|
|
1611 |
if (value !== false || !resolver.shouldInvalidate.apply(resolver, [action].concat(Object(toConsumableArray["a" /* default */])(args)))) {
|
|
1612 |
return;
|
|
1613 |
} // Trigger cache invalidation
|
|
1614 |
|
|
1615 |
|
|
1616 |
registry.dispatch('core/data').invalidateResolution(reducerKey, selectorName, args);
|
|
1617 |
});
|
|
1618 |
});
|
|
1619 |
return next(action);
|
|
1620 |
};
|
|
1621 |
};
|
|
1622 |
};
|
|
1623 |
};
|
|
1624 |
|
|
1625 |
/* harmony default export */ var resolvers_cache_middleware = (resolvers_cache_middleware_createResolversCacheMiddleware);
|
|
1626 |
|
|
1627 |
// EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
|
|
1628 |
var equivalent_key_map = __webpack_require__(126);
|
|
1629 |
var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
|
|
1630 |
|
|
1631 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/utils.js
|
|
1632 |
|
|
1633 |
|
|
1634 |
function utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1635 |
|
|
1636 |
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { utils_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1637 |
|
|
1638 |
/**
|
|
1639 |
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
1640 |
* by a property on the action object.
|
|
1641 |
*
|
|
1642 |
* @param {string} actionProperty Action property by which to key object.
|
|
1643 |
*
|
|
1644 |
* @return {Function} Higher-order reducer.
|
|
1645 |
*/
|
|
1646 |
var utils_onSubKey = function onSubKey(actionProperty) {
|
|
1647 |
return function (reducer) {
|
|
1648 |
return function () {
|
|
1649 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1650 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1651 |
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
|
1652 |
// where reducer is scoped by action shape.
|
|
1653 |
var key = action[actionProperty];
|
|
1654 |
|
|
1655 |
if (key === undefined) {
|
|
1656 |
return state;
|
|
1657 |
} // Avoid updating state if unchanged. Note that this also accounts for a
|
|
1658 |
// reducer which returns undefined on a key which is not yet tracked.
|
|
1659 |
|
|
1660 |
|
|
1661 |
var nextKeyState = reducer(state[key], action);
|
|
1662 |
|
|
1663 |
if (nextKeyState === state[key]) {
|
|
1664 |
return state;
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
|
|
1668 |
};
|
|
1669 |
};
|
|
1670 |
};
|
|
1671 |
|
|
1672 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/reducer.js
|
|
1673 |
/**
|
|
1674 |
* External dependencies
|
|
1675 |
*/
|
|
1676 |
|
|
1677 |
|
|
1678 |
/**
|
|
1679 |
* Internal dependencies
|
|
1680 |
*/
|
|
1681 |
|
|
1682 |
|
|
1683 |
/**
|
|
1684 |
* Reducer function returning next state for selector resolution of
|
|
1685 |
* subkeys, object form:
|
|
1686 |
*
|
|
1687 |
* selectorName -> EquivalentKeyMap<Array,boolean>
|
|
1688 |
*
|
|
1689 |
* @param {Object} state Current state.
|
|
1690 |
* @param {Object} action Dispatched action.
|
|
1691 |
*
|
|
1692 |
* @return {Object} Next state.
|
|
1693 |
*/
|
|
1694 |
|
|
1695 |
var subKeysIsResolved = Object(external_this_lodash_["flowRight"])([utils_onSubKey('selectorName')])(function () {
|
|
1696 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new equivalent_key_map_default.a();
|
|
1697 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1698 |
|
|
1699 |
switch (action.type) {
|
|
1700 |
case 'START_RESOLUTION':
|
|
1701 |
case 'FINISH_RESOLUTION':
|
|
1702 |
{
|
|
1703 |
var isStarting = action.type === 'START_RESOLUTION';
|
|
1704 |
var nextState = new equivalent_key_map_default.a(state);
|
|
1705 |
nextState.set(action.args, isStarting);
|
|
1706 |
return nextState;
|
|
1707 |
}
|
|
1708 |
|
|
1709 |
case 'INVALIDATE_RESOLUTION':
|
|
1710 |
{
|
|
1711 |
var _nextState = new equivalent_key_map_default.a(state);
|
|
1712 |
|
|
1713 |
_nextState.delete(action.args);
|
|
1714 |
|
|
1715 |
return _nextState;
|
|
1716 |
}
|
|
1717 |
}
|
|
1718 |
|
|
1719 |
return state;
|
|
1720 |
});
|
|
1721 |
/**
|
|
1722 |
* Reducer function returning next state for selector resolution, object form:
|
|
1723 |
*
|
|
1724 |
* selectorName -> EquivalentKeyMap<Array, boolean>
|
|
1725 |
*
|
|
1726 |
* @param {Object} state Current state.
|
|
1727 |
* @param {Object} action Dispatched action.
|
|
1728 |
*
|
|
1729 |
* @return {Object} Next state.
|
|
1730 |
*/
|
|
1731 |
|
|
1732 |
var reducer_isResolved = function isResolved() {
|
|
1733 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1734 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1735 |
|
|
1736 |
switch (action.type) {
|
|
1737 |
case 'INVALIDATE_RESOLUTION_FOR_STORE':
|
|
1738 |
return {};
|
|
1739 |
|
|
1740 |
case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR':
|
|
1741 |
return Object(external_this_lodash_["has"])(state, [action.selectorName]) ? Object(external_this_lodash_["omit"])(state, [action.selectorName]) : state;
|
|
1742 |
|
|
1743 |
case 'START_RESOLUTION':
|
|
1744 |
case 'FINISH_RESOLUTION':
|
|
1745 |
case 'INVALIDATE_RESOLUTION':
|
|
1746 |
return subKeysIsResolved(state, action);
|
|
1747 |
}
|
|
1748 |
|
|
1749 |
return state;
|
|
1750 |
};
|
|
1751 |
|
|
1752 |
/* harmony default export */ var metadata_reducer = (reducer_isResolved);
|
|
1753 |
|
|
1754 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/selectors.js
|
|
1755 |
/**
|
|
1756 |
* External dependencies
|
|
1757 |
*/
|
|
1758 |
|
|
1759 |
/**
|
|
1760 |
* Returns the raw `isResolving` value for a given selector name,
|
|
1761 |
* and arguments set. May be undefined if the selector has never been resolved
|
|
1762 |
* or not resolved for the given set of arguments, otherwise true or false for
|
|
1763 |
* resolution started and completed respectively.
|
|
1764 |
*
|
|
1765 |
* @param {Object} state Data state.
|
|
1766 |
* @param {string} selectorName Selector name.
|
|
1767 |
* @param {Array} args Arguments passed to selector.
|
|
1768 |
*
|
|
1769 |
* @return {?boolean} isResolving value.
|
|
1770 |
*/
|
|
1771 |
|
|
1772 |
function getIsResolving(state, selectorName, args) {
|
|
1773 |
var map = Object(external_this_lodash_["get"])(state, [selectorName]);
|
|
1774 |
|
|
1775 |
if (!map) {
|
|
1776 |
return;
|
|
1777 |
}
|
|
1778 |
|
|
1779 |
return map.get(args);
|
|
1780 |
}
|
|
1781 |
/**
|
|
1782 |
* Returns true if resolution has already been triggered for a given
|
|
1783 |
* selector name, and arguments set.
|
|
1784 |
*
|
|
1785 |
* @param {Object} state Data state.
|
|
1786 |
* @param {string} selectorName Selector name.
|
|
1787 |
* @param {?Array} args Arguments passed to selector (default `[]`).
|
|
1788 |
*
|
|
1789 |
* @return {boolean} Whether resolution has been triggered.
|
|
1790 |
*/
|
|
1791 |
|
|
1792 |
function hasStartedResolution(state, selectorName) {
|
|
1793 |
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
1794 |
return getIsResolving(state, selectorName, args) !== undefined;
|
|
1795 |
}
|
|
1796 |
/**
|
|
1797 |
* Returns true if resolution has completed for a given selector
|
|
1798 |
* name, and arguments set.
|
|
1799 |
*
|
|
1800 |
* @param {Object} state Data state.
|
|
1801 |
* @param {string} selectorName Selector name.
|
|
1802 |
* @param {?Array} args Arguments passed to selector.
|
|
1803 |
*
|
|
1804 |
* @return {boolean} Whether resolution has completed.
|
|
1805 |
*/
|
|
1806 |
|
|
1807 |
function hasFinishedResolution(state, selectorName) {
|
|
1808 |
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
1809 |
return getIsResolving(state, selectorName, args) === false;
|
|
1810 |
}
|
|
1811 |
/**
|
|
1812 |
* Returns true if resolution has been triggered but has not yet completed for
|
|
1813 |
* a given selector name, and arguments set.
|
|
1814 |
*
|
|
1815 |
* @param {Object} state Data state.
|
|
1816 |
* @param {string} selectorName Selector name.
|
|
1817 |
* @param {?Array} args Arguments passed to selector.
|
|
1818 |
*
|
|
1819 |
* @return {boolean} Whether resolution is in progress.
|
|
1820 |
*/
|
|
1821 |
|
|
1822 |
function isResolving(state, selectorName) {
|
|
1823 |
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
1824 |
return getIsResolving(state, selectorName, args) === true;
|
|
1825 |
}
|
|
1826 |
/**
|
|
1827 |
* Returns the list of the cached resolvers.
|
|
1828 |
*
|
|
1829 |
* @param {Object} state Data state.
|
|
1830 |
*
|
|
1831 |
* @return {Object} Resolvers mapped by args and selectorName.
|
|
1832 |
*/
|
|
1833 |
|
|
1834 |
function getCachedResolvers(state) {
|
|
1835 |
return state;
|
|
1836 |
}
|
|
1837 |
|
|
1838 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/namespace-store/metadata/actions.js
|
|
1839 |
/**
|
|
1840 |
* Returns an action object used in signalling that selector resolution has
|
|
1841 |
* started.
|
|
1842 |
*
|
|
1843 |
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
1844 |
* @param {...*} args Arguments to associate for uniqueness.
|
|
1845 |
*
|
|
1846 |
* @return {Object} Action object.
|
|
1847 |
*/
|
|
1848 |
function startResolution(selectorName, args) {
|
|
1849 |
return {
|
|
1850 |
type: 'START_RESOLUTION',
|
|
1851 |
selectorName: selectorName,
|
|
1852 |
args: args
|
|
1853 |
};
|
|
1854 |
}
|
|
1855 |
/**
|
|
1856 |
* Returns an action object used in signalling that selector resolution has
|
|
1857 |
* completed.
|
|
1858 |
*
|
|
1859 |
* @param {string} selectorName Name of selector for which resolver triggered.
|
|
1860 |
* @param {...*} args Arguments to associate for uniqueness.
|
|
1861 |
*
|
|
1862 |
* @return {Object} Action object.
|
|
1863 |
*/
|
|
1864 |
|
|
1865 |
function finishResolution(selectorName, args) {
|
|
1866 |
return {
|
|
1867 |
type: 'FINISH_RESOLUTION',
|
|
1868 |
selectorName: selectorName,
|
|
1869 |
args: args
|
|
1870 |
};
|
|
1871 |
}
|
|
1872 |
/**
|
|
1873 |
* Returns an action object used in signalling that we should invalidate the resolution cache.
|
|
1874 |
*
|
|
1875 |
* @param {string} selectorName Name of selector for which resolver should be invalidated.
|
|
1876 |
* @param {Array} args Arguments to associate for uniqueness.
|
|
1877 |
*
|
|
1878 |
* @return {Object} Action object.
|
|
1879 |
*/
|
|
1880 |
|
|
1881 |
function invalidateResolution(selectorName, args) {
|
|
1882 |
return {
|
|
1883 |
type: 'INVALIDATE_RESOLUTION',
|
|
1884 |
selectorName: selectorName,
|
|
1885 |
args: args
|
|
1886 |
};
|
|
1887 |
}
|
|
1888 |
/**
|
|
1889 |
* Returns an action object used in signalling that the resolution
|
|
1890 |
* should be invalidated.
|
|
1891 |
*
|
|
1892 |
* @return {Object} Action object.
|
|
1893 |
*/
|
|
1894 |
|
|
1895 |
function invalidateResolutionForStore() {
|
|
1896 |
return {
|
|
1897 |
type: 'INVALIDATE_RESOLUTION_FOR_STORE'
|
|
1898 |
};
|
|
1899 |
}
|
|
1900 |
/**
|
|
1901 |
* Returns an action object used in signalling that the resolution cache for a
|
|
1902 |
* given selectorName should be invalidated.
|
|
1903 |
*
|
|
1904 |
* @param {string} selectorName Name of selector for which all resolvers should
|
|
1905 |
* be invalidated.
|
|
1906 |
*
|
|
1907 |
* @return {Object} Action object.
|
|
1908 |
*/
|
|
1909 |
|
|
1910 |
function invalidateResolutionForStoreSelector(selectorName) {
|
|
1911 |
return {
|
|
1912 |
type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',
|
|
1913 |
selectorName: selectorName
|
|
1914 |
};
|
|
1915 |
}
|
|
1916 |
|
|
1917 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/namespace-store/index.js
|
|
1918 |
|
|
1919 |
|
|
1920 |
|
|
1921 |
|
|
1922 |
function namespace_store_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1923 |
|
|
1924 |
function namespace_store_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { namespace_store_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { namespace_store_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1925 |
|
|
1926 |
/**
|
|
1927 |
* External dependencies
|
|
1928 |
*/
|
|
1929 |
|
|
1930 |
|
|
1931 |
|
|
1932 |
/**
|
|
1933 |
* WordPress dependencies
|
|
1934 |
*/
|
|
1935 |
|
|
1936 |
|
|
1937 |
/**
|
|
1938 |
* Internal dependencies
|
|
1939 |
*/
|
|
1940 |
|
|
1941 |
|
|
1942 |
|
|
1943 |
|
|
1944 |
|
|
1945 |
|
|
1946 |
/**
|
|
1947 |
* @typedef {WPDataRegistry} WPDataRegistry
|
|
1948 |
*/
|
|
1949 |
|
|
1950 |
/**
|
|
1951 |
* Creates a namespace object with a store derived from the reducer given.
|
|
1952 |
*
|
|
1953 |
* @param {string} key Unique namespace identifier.
|
|
1954 |
* @param {Object} options Registered store options, with properties
|
|
1955 |
* describing reducer, actions, selectors, and
|
|
1956 |
* resolvers.
|
|
1957 |
* @param {WPDataRegistry} registry Registry reference.
|
|
1958 |
*
|
|
1959 |
* @return {Object} Store Object.
|
|
1960 |
*/
|
|
1961 |
|
|
1962 |
function createNamespace(key, options, registry) {
|
|
1963 |
var reducer = options.reducer;
|
|
1964 |
var store = createReduxStore(key, options, registry);
|
|
1965 |
var resolvers;
|
|
1966 |
var actions = mapActions(namespace_store_objectSpread({}, actions_namespaceObject, {}, options.actions), store);
|
|
1967 |
var selectors = mapSelectors(namespace_store_objectSpread({}, Object(external_this_lodash_["mapValues"])(selectors_namespaceObject, function (selector) {
|
|
1968 |
return function (state) {
|
|
1969 |
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1970 |
args[_key - 1] = arguments[_key];
|
|
1971 |
}
|
|
1972 |
|
|
1973 |
return selector.apply(void 0, [state.metadata].concat(args));
|
|
1974 |
};
|
|
1975 |
}), {}, Object(external_this_lodash_["mapValues"])(options.selectors, function (selector) {
|
|
1976 |
if (selector.isRegistrySelector) {
|
|
1977 |
selector.registry = registry;
|
|
1978 |
}
|
|
1979 |
|
|
1980 |
return function (state) {
|
|
1981 |
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1982 |
args[_key2 - 1] = arguments[_key2];
|
|
1983 |
}
|
|
1984 |
|
|
1985 |
return selector.apply(void 0, [state.root].concat(args));
|
|
1986 |
};
|
|
1987 |
})), store);
|
|
1988 |
|
|
1989 |
if (options.resolvers) {
|
|
1990 |
var result = mapResolvers(options.resolvers, selectors, store);
|
|
1991 |
resolvers = result.resolvers;
|
|
1992 |
selectors = result.selectors;
|
|
1993 |
}
|
|
1994 |
|
|
1995 |
var getSelectors = function getSelectors() {
|
|
1996 |
return selectors;
|
|
1997 |
};
|
|
1998 |
|
|
1999 |
var getActions = function getActions() {
|
|
2000 |
return actions;
|
|
2001 |
}; // We have some modules monkey-patching the store object
|
|
2002 |
// It's wrong to do so but until we refactor all of our effects to controls
|
|
2003 |
// We need to keep the same "store" instance here.
|
|
2004 |
|
|
2005 |
|
|
2006 |
store.__unstableOriginalGetState = store.getState;
|
|
2007 |
|
|
2008 |
store.getState = function () {
|
|
2009 |
return store.__unstableOriginalGetState().root;
|
|
2010 |
}; // Customize subscribe behavior to call listeners only on effective change,
|
|
2011 |
// not on every dispatch.
|
|
2012 |
|
|
2013 |
|
|
2014 |
var subscribe = store && function (listener) {
|
|
2015 |
var lastState = store.__unstableOriginalGetState();
|
|
2016 |
|
|
2017 |
store.subscribe(function () {
|
|
2018 |
var state = store.__unstableOriginalGetState();
|
|
2019 |
|
|
2020 |
var hasChanged = state !== lastState;
|
|
2021 |
lastState = state;
|
|
2022 |
|
|
2023 |
if (hasChanged) {
|
|
2024 |
listener();
|
|
2025 |
}
|
|
2026 |
});
|
|
2027 |
}; // This can be simplified to just { subscribe, getSelectors, getActions }
|
|
2028 |
// Once we remove the use function.
|
|
2029 |
|
|
2030 |
|
|
2031 |
return {
|
|
2032 |
reducer: reducer,
|
|
2033 |
store: store,
|
|
2034 |
actions: actions,
|
|
2035 |
selectors: selectors,
|
|
2036 |
resolvers: resolvers,
|
|
2037 |
getSelectors: getSelectors,
|
|
2038 |
getActions: getActions,
|
|
2039 |
subscribe: subscribe
|
|
2040 |
};
|
|
2041 |
}
|
|
2042 |
/**
|
|
2043 |
* Creates a redux store for a namespace.
|
|
2044 |
*
|
|
2045 |
* @param {string} key Unique namespace identifier.
|
|
2046 |
* @param {Object} options Registered store options, with properties
|
|
2047 |
* describing reducer, actions, selectors, and
|
|
2048 |
* resolvers.
|
|
2049 |
* @param {WPDataRegistry} registry Registry reference.
|
|
2050 |
*
|
|
2051 |
* @return {Object} Newly created redux store.
|
|
2052 |
*/
|
|
2053 |
|
|
2054 |
function createReduxStore(key, options, registry) {
|
|
2055 |
var middlewares = [resolvers_cache_middleware(registry, key), promise_middleware];
|
|
2056 |
|
|
2057 |
if (options.controls) {
|
|
2058 |
var normalizedControls = Object(external_this_lodash_["mapValues"])(options.controls, function (control) {
|
|
2059 |
return control.isRegistryControl ? control(registry) : control;
|
|
2060 |
});
|
|
2061 |
middlewares.push(external_this_wp_reduxRoutine_default()(normalizedControls));
|
|
2062 |
}
|
|
2063 |
|
|
2064 |
var enhancers = [applyMiddleware.apply(void 0, middlewares)];
|
|
2065 |
|
|
2066 |
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
|
|
2067 |
enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({
|
|
2068 |
name: key,
|
|
2069 |
instanceId: key
|
|
2070 |
}));
|
|
2071 |
}
|
|
2072 |
|
|
2073 |
var reducer = options.reducer,
|
|
2074 |
initialState = options.initialState;
|
|
2075 |
var enhancedReducer = turbo_combine_reducers_default()({
|
|
2076 |
metadata: metadata_reducer,
|
|
2077 |
root: reducer
|
|
2078 |
});
|
|
2079 |
return createStore(enhancedReducer, {
|
|
2080 |
root: initialState
|
|
2081 |
}, Object(external_this_lodash_["flowRight"])(enhancers));
|
|
2082 |
}
|
|
2083 |
/**
|
|
2084 |
* Maps selectors to a store.
|
|
2085 |
*
|
|
2086 |
* @param {Object} selectors Selectors to register. Keys will be used as the
|
|
2087 |
* public facing API. Selectors will get passed the
|
|
2088 |
* state as first argument.
|
|
2089 |
* @param {Object} store The store to which the selectors should be mapped.
|
|
2090 |
*
|
|
2091 |
* @return {Object} Selectors mapped to the provided store.
|
|
2092 |
*/
|
|
2093 |
|
|
2094 |
|
|
2095 |
function mapSelectors(selectors, store) {
|
|
2096 |
var createStateSelector = function createStateSelector(registrySelector) {
|
|
2097 |
var selector = function runSelector() {
|
|
2098 |
// This function is an optimized implementation of:
|
|
2099 |
//
|
|
2100 |
// selector( store.getState(), ...arguments )
|
|
2101 |
//
|
|
2102 |
// Where the above would incur an `Array#concat` in its application,
|
|
2103 |
// the logic here instead efficiently constructs an arguments array via
|
|
2104 |
// direct assignment.
|
|
2105 |
var argsLength = arguments.length;
|
|
2106 |
var args = new Array(argsLength + 1);
|
|
2107 |
args[0] = store.__unstableOriginalGetState();
|
|
2108 |
|
|
2109 |
for (var i = 0; i < argsLength; i++) {
|
|
2110 |
args[i + 1] = arguments[i];
|
|
2111 |
}
|
|
2112 |
|
|
2113 |
return registrySelector.apply(void 0, args);
|
|
2114 |
};
|
|
2115 |
|
|
2116 |
selector.hasResolver = false;
|
|
2117 |
return selector;
|
|
2118 |
};
|
|
2119 |
|
|
2120 |
return Object(external_this_lodash_["mapValues"])(selectors, createStateSelector);
|
|
2121 |
}
|
|
2122 |
/**
|
|
2123 |
* Maps actions to dispatch from a given store.
|
|
2124 |
*
|
|
2125 |
* @param {Object} actions Actions to register.
|
|
2126 |
* @param {Object} store The redux store to which the actions should be mapped.
|
|
2127 |
* @return {Object} Actions mapped to the redux store provided.
|
|
2128 |
*/
|
|
2129 |
|
|
2130 |
|
|
2131 |
function mapActions(actions, store) {
|
|
2132 |
var createBoundAction = function createBoundAction(action) {
|
|
2133 |
return function () {
|
|
2134 |
return Promise.resolve(store.dispatch(action.apply(void 0, arguments)));
|
|
2135 |
};
|
|
2136 |
};
|
|
2137 |
|
|
2138 |
return Object(external_this_lodash_["mapValues"])(actions, createBoundAction);
|
|
2139 |
}
|
|
2140 |
/**
|
|
2141 |
* Returns resolvers with matched selectors for a given namespace.
|
|
2142 |
* Resolvers are side effects invoked once per argument set of a given selector call,
|
|
2143 |
* used in ensuring that the data needs for the selector are satisfied.
|
|
2144 |
*
|
|
2145 |
* @param {Object} resolvers Resolvers to register.
|
|
2146 |
* @param {Object} selectors The current selectors to be modified.
|
|
2147 |
* @param {Object} store The redux store to which the resolvers should be mapped.
|
|
2148 |
* @return {Object} An object containing updated selectors and resolvers.
|
|
2149 |
*/
|
|
2150 |
|
|
2151 |
|
|
2152 |
function mapResolvers(resolvers, selectors, store) {
|
|
2153 |
var mappedResolvers = Object(external_this_lodash_["mapValues"])(resolvers, function (resolver) {
|
|
2154 |
var _resolver$fulfill = resolver.fulfill,
|
|
2155 |
resolverFulfill = _resolver$fulfill === void 0 ? resolver : _resolver$fulfill;
|
|
2156 |
return namespace_store_objectSpread({}, resolver, {
|
|
2157 |
fulfill: resolverFulfill
|
|
2158 |
});
|
|
2159 |
});
|
|
2160 |
|
|
2161 |
var mapSelector = function mapSelector(selector, selectorName) {
|
|
2162 |
var resolver = resolvers[selectorName];
|
|
2163 |
|
|
2164 |
if (!resolver) {
|
|
2165 |
selector.hasResolver = false;
|
|
2166 |
return selector;
|
|
2167 |
}
|
|
2168 |
|
|
2169 |
var selectorResolver = function selectorResolver() {
|
|
2170 |
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2171 |
args[_key3] = arguments[_key3];
|
|
2172 |
}
|
|
2173 |
|
|
2174 |
function fulfillSelector() {
|
|
2175 |
return _fulfillSelector.apply(this, arguments);
|
|
2176 |
}
|
|
2177 |
|
|
2178 |
function _fulfillSelector() {
|
|
2179 |
_fulfillSelector = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee() {
|
|
2180 |
var state, _store$__unstableOrig, metadata;
|
|
2181 |
|
|
2182 |
return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
|
|
2183 |
while (1) {
|
|
2184 |
switch (_context.prev = _context.next) {
|
|
2185 |
case 0:
|
|
2186 |
state = store.getState();
|
|
2187 |
|
|
2188 |
if (!(typeof resolver.isFulfilled === 'function' && resolver.isFulfilled.apply(resolver, [state].concat(args)))) {
|
|
2189 |
_context.next = 3;
|
|
2190 |
break;
|
|
2191 |
}
|
|
2192 |
|
|
2193 |
return _context.abrupt("return");
|
|
2194 |
|
|
2195 |
case 3:
|
|
2196 |
_store$__unstableOrig = store.__unstableOriginalGetState(), metadata = _store$__unstableOrig.metadata;
|
|
2197 |
|
|
2198 |
if (!hasStartedResolution(metadata, selectorName, args)) {
|
|
2199 |
_context.next = 6;
|
|
2200 |
break;
|
|
2201 |
}
|
|
2202 |
|
|
2203 |
return _context.abrupt("return");
|
|
2204 |
|
|
2205 |
case 6:
|
|
2206 |
store.dispatch(startResolution(selectorName, args));
|
|
2207 |
_context.next = 9;
|
|
2208 |
return fulfillResolver.apply(void 0, [store, mappedResolvers, selectorName].concat(args));
|
|
2209 |
|
|
2210 |
case 9:
|
|
2211 |
store.dispatch(finishResolution(selectorName, args));
|
|
2212 |
|
|
2213 |
case 10:
|
|
2214 |
case "end":
|
|
2215 |
return _context.stop();
|
|
2216 |
}
|
|
2217 |
}
|
|
2218 |
}, _callee);
|
|
2219 |
}));
|
|
2220 |
return _fulfillSelector.apply(this, arguments);
|
|
2221 |
}
|
|
2222 |
|
|
2223 |
fulfillSelector.apply(void 0, args);
|
|
2224 |
return selector.apply(void 0, args);
|
|
2225 |
};
|
|
2226 |
|
|
2227 |
selectorResolver.hasResolver = true;
|
|
2228 |
return selectorResolver;
|
|
2229 |
};
|
|
2230 |
|
|
2231 |
return {
|
|
2232 |
resolvers: mappedResolvers,
|
|
2233 |
selectors: Object(external_this_lodash_["mapValues"])(selectors, mapSelector)
|
|
2234 |
};
|
|
2235 |
}
|
|
2236 |
/**
|
|
2237 |
* Calls a resolver given arguments
|
|
2238 |
*
|
|
2239 |
* @param {Object} store Store reference, for fulfilling via resolvers
|
|
2240 |
* @param {Object} resolvers Store Resolvers
|
|
2241 |
* @param {string} selectorName Selector name to fulfill.
|
|
2242 |
* @param {Array} args Selector Arguments.
|
|
2243 |
*/
|
|
2244 |
|
|
2245 |
|
|
2246 |
function fulfillResolver(_x, _x2, _x3) {
|
|
2247 |
return _fulfillResolver.apply(this, arguments);
|
|
2248 |
}
|
|
2249 |
|
|
2250 |
function _fulfillResolver() {
|
|
2251 |
_fulfillResolver = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee2(store, resolvers, selectorName) {
|
|
2252 |
var resolver,
|
|
2253 |
_len4,
|
|
2254 |
args,
|
|
2255 |
_key4,
|
|
2256 |
action,
|
|
2257 |
_args2 = arguments;
|
|
2258 |
|
|
2259 |
return external_this_regeneratorRuntime_default.a.wrap(function _callee2$(_context2) {
|
|
2260 |
while (1) {
|
|
2261 |
switch (_context2.prev = _context2.next) {
|
|
2262 |
case 0:
|
|
2263 |
resolver = Object(external_this_lodash_["get"])(resolvers, [selectorName]);
|
|
2264 |
|
|
2265 |
if (resolver) {
|
|
2266 |
_context2.next = 3;
|
|
2267 |
break;
|
|
2268 |
}
|
|
2269 |
|
|
2270 |
return _context2.abrupt("return");
|
|
2271 |
|
|
2272 |
case 3:
|
|
2273 |
for (_len4 = _args2.length, args = new Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) {
|
|
2274 |
args[_key4 - 3] = _args2[_key4];
|
|
2275 |
}
|
|
2276 |
|
|
2277 |
action = resolver.fulfill.apply(resolver, args);
|
|
2278 |
|
|
2279 |
if (!action) {
|
|
2280 |
_context2.next = 8;
|
|
2281 |
break;
|
|
2282 |
}
|
|
2283 |
|
|
2284 |
_context2.next = 8;
|
|
2285 |
return store.dispatch(action);
|
|
2286 |
|
|
2287 |
case 8:
|
|
2288 |
case "end":
|
|
2289 |
return _context2.stop();
|
|
2290 |
}
|
|
2291 |
}
|
|
2292 |
}, _callee2);
|
|
2293 |
}));
|
|
2294 |
return _fulfillResolver.apply(this, arguments);
|
|
2295 |
}
|
|
2296 |
|
|
2297 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js
|
|
2298 |
|
|
2299 |
|
|
2300 |
function store_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2301 |
|
|
2302 |
function store_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { store_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { store_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2303 |
|
|
2304 |
function createCoreDataStore(registry) {
|
|
2305 |
var getCoreDataSelector = function getCoreDataSelector(selectorName) {
|
|
2306 |
return function (reducerKey) {
|
|
2307 |
var _registry$select;
|
|
2308 |
|
|
2309 |
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2310 |
args[_key - 1] = arguments[_key];
|
|
2311 |
}
|
|
2312 |
|
|
2313 |
return (_registry$select = registry.select(reducerKey))[selectorName].apply(_registry$select, args);
|
|
2314 |
};
|
|
2315 |
};
|
|
2316 |
|
|
2317 |
var getCoreDataAction = function getCoreDataAction(actionName) {
|
|
2318 |
return function (reducerKey) {
|
|
2319 |
var _registry$dispatch;
|
|
2320 |
|
|
2321 |
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2322 |
args[_key2 - 1] = arguments[_key2];
|
|
2323 |
}
|
|
2324 |
|
|
2325 |
return (_registry$dispatch = registry.dispatch(reducerKey))[actionName].apply(_registry$dispatch, args);
|
|
2326 |
};
|
|
2327 |
};
|
|
2328 |
|
|
2329 |
return {
|
|
2330 |
getSelectors: function getSelectors() {
|
|
2331 |
return ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].reduce(function (memo, selectorName) {
|
|
2332 |
return store_objectSpread({}, memo, Object(defineProperty["a" /* default */])({}, selectorName, getCoreDataSelector(selectorName)));
|
|
2333 |
}, {});
|
|
2334 |
},
|
|
2335 |
getActions: function getActions() {
|
|
2336 |
return ['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].reduce(function (memo, actionName) {
|
|
2337 |
return store_objectSpread({}, memo, Object(defineProperty["a" /* default */])({}, actionName, getCoreDataAction(actionName)));
|
|
2338 |
}, {});
|
|
2339 |
},
|
|
2340 |
subscribe: function subscribe() {
|
|
2341 |
// There's no reasons to trigger any listener when we subscribe to this store
|
|
2342 |
// because there's no state stored in this store that need to retrigger selectors
|
|
2343 |
// if a change happens, the corresponding store where the tracking stated live
|
|
2344 |
// would have already triggered a "subscribe" call.
|
|
2345 |
return function () {};
|
|
2346 |
}
|
|
2347 |
};
|
|
2348 |
}
|
|
2349 |
|
|
2350 |
/* harmony default export */ var build_module_store = (createCoreDataStore);
|
|
2351 |
|
|
2352 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
|
|
2353 |
|
|
2354 |
|
|
2355 |
|
|
2356 |
function registry_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2357 |
|
|
2358 |
function registry_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { registry_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { registry_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2359 |
|
|
2360 |
/**
|
|
2361 |
* External dependencies
|
|
2362 |
*/
|
|
2363 |
|
|
2364 |
|
|
2365 |
/**
|
|
2366 |
* Internal dependencies
|
|
2367 |
*/
|
|
2368 |
|
|
2369 |
|
|
2370 |
|
|
2371 |
/**
|
|
2372 |
* @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.
|
|
2373 |
*
|
|
2374 |
* @property {Function} registerGenericStore Given a namespace key and settings
|
|
2375 |
* object, registers a new generic
|
|
2376 |
* store.
|
|
2377 |
* @property {Function} registerStore Given a namespace key and settings
|
|
2378 |
* object, registers a new namespace
|
|
2379 |
* store.
|
|
2380 |
* @property {Function} subscribe Given a function callback, invokes
|
|
2381 |
* the callback on any change to state
|
|
2382 |
* within any registered store.
|
|
2383 |
* @property {Function} select Given a namespace key, returns an
|
|
2384 |
* object of the store's registered
|
|
2385 |
* selectors.
|
|
2386 |
* @property {Function} dispatch Given a namespace key, returns an
|
|
2387 |
* object of the store's registered
|
|
2388 |
* action dispatchers.
|
|
2389 |
*/
|
|
2390 |
|
|
2391 |
/**
|
|
2392 |
* @typedef {Object} WPDataPlugin An object of registry function overrides.
|
|
2393 |
*
|
|
2394 |
* @property {Function} registerStore registers store.
|
|
2395 |
*/
|
|
2396 |
|
|
2397 |
/**
|
|
2398 |
* Creates a new store registry, given an optional object of initial store
|
|
2399 |
* configurations.
|
|
2400 |
*
|
|
2401 |
* @param {Object} storeConfigs Initial store configurations.
|
|
2402 |
* @param {Object?} parent Parent registry.
|
|
2403 |
*
|
|
2404 |
* @return {WPDataRegistry} Data registry.
|
|
2405 |
*/
|
|
2406 |
|
|
2407 |
function createRegistry() {
|
|
2408 |
var storeConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2409 |
var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2410 |
var stores = {};
|
|
2411 |
var listeners = [];
|
|
2412 |
/**
|
|
2413 |
* Global listener called for each store's update.
|
|
2414 |
*/
|
|
2415 |
|
|
2416 |
function globalListener() {
|
|
2417 |
listeners.forEach(function (listener) {
|
|
2418 |
return listener();
|
|
2419 |
});
|
|
2420 |
}
|
|
2421 |
/**
|
|
2422 |
* Subscribe to changes to any data.
|
|
2423 |
*
|
|
2424 |
* @param {Function} listener Listener function.
|
|
2425 |
*
|
|
2426 |
* @return {Function} Unsubscribe function.
|
|
2427 |
*/
|
|
2428 |
|
|
2429 |
|
|
2430 |
var subscribe = function subscribe(listener) {
|
|
2431 |
listeners.push(listener);
|
|
2432 |
return function () {
|
|
2433 |
listeners = Object(external_this_lodash_["without"])(listeners, listener);
|
|
2434 |
};
|
|
2435 |
};
|
|
2436 |
/**
|
|
2437 |
* Calls a selector given the current state and extra arguments.
|
|
2438 |
*
|
|
2439 |
* @param {string} reducerKey Part of the state shape to register the
|
|
2440 |
* selectors for.
|
|
2441 |
*
|
|
2442 |
* @return {*} The selector's returned value.
|
|
2443 |
*/
|
|
2444 |
|
|
2445 |
|
|
2446 |
function select(reducerKey) {
|
|
2447 |
var store = stores[reducerKey];
|
|
2448 |
|
|
2449 |
if (store) {
|
|
2450 |
return store.getSelectors();
|
|
2451 |
}
|
|
2452 |
|
|
2453 |
return parent && parent.select(reducerKey);
|
|
2454 |
}
|
|
2455 |
|
|
2456 |
var getResolveSelectors = memize_default()(function (selectors) {
|
|
2457 |
return Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["omit"])(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers']), function (selector, selectorName) {
|
|
2458 |
return function () {
|
|
2459 |
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2460 |
args[_key] = arguments[_key];
|
|
2461 |
}
|
|
2462 |
|
|
2463 |
return new Promise(function (resolve) {
|
|
2464 |
var hasFinished = function hasFinished() {
|
|
2465 |
return selectors.hasFinishedResolution(selectorName, args);
|
|
2466 |
};
|
|
2467 |
|
|
2468 |
var getResult = function getResult() {
|
|
2469 |
return selector.apply(null, args);
|
|
2470 |
}; // trigger the selector (to trigger the resolver)
|
|
2471 |
|
|
2472 |
|
|
2473 |
var result = getResult();
|
|
2474 |
|
|
2475 |
if (hasFinished()) {
|
|
2476 |
return resolve(result);
|
|
2477 |
}
|
|
2478 |
|
|
2479 |
var unsubscribe = subscribe(function () {
|
|
2480 |
if (hasFinished()) {
|
|
2481 |
unsubscribe();
|
|
2482 |
resolve(getResult());
|
|
2483 |
}
|
|
2484 |
});
|
|
2485 |
});
|
|
2486 |
};
|
|
2487 |
});
|
|
2488 |
}, {
|
|
2489 |
maxSize: 1
|
|
2490 |
});
|
|
2491 |
/**
|
|
2492 |
* Given the name of a registered store, returns an object containing the store's
|
|
2493 |
* selectors pre-bound to state so that you only need to supply additional arguments,
|
|
2494 |
* and modified so that they return promises that resolve to their eventual values,
|
|
2495 |
* after any resolvers have ran.
|
|
2496 |
*
|
|
2497 |
* @param {string} reducerKey Part of the state shape to register the
|
|
2498 |
* selectors for.
|
|
2499 |
*
|
|
2500 |
* @return {Object} Each key of the object matches the name of a selector.
|
|
2501 |
*/
|
|
2502 |
|
|
2503 |
function __experimentalResolveSelect(reducerKey) {
|
|
2504 |
return getResolveSelectors(select(reducerKey));
|
|
2505 |
}
|
|
2506 |
/**
|
|
2507 |
* Returns the available actions for a part of the state.
|
|
2508 |
*
|
|
2509 |
* @param {string} reducerKey Part of the state shape to dispatch the
|
|
2510 |
* action for.
|
|
2511 |
*
|
|
2512 |
* @return {*} The action's returned value.
|
|
2513 |
*/
|
|
2514 |
|
|
2515 |
|
|
2516 |
function dispatch(reducerKey) {
|
|
2517 |
var store = stores[reducerKey];
|
|
2518 |
|
|
2519 |
if (store) {
|
|
2520 |
return store.getActions();
|
|
2521 |
}
|
|
2522 |
|
|
2523 |
return parent && parent.dispatch(reducerKey);
|
|
2524 |
} //
|
|
2525 |
// Deprecated
|
|
2526 |
// TODO: Remove this after `use()` is removed.
|
|
2527 |
//
|
|
2528 |
|
|
2529 |
|
|
2530 |
function withPlugins(attributes) {
|
|
2531 |
return Object(external_this_lodash_["mapValues"])(attributes, function (attribute, key) {
|
|
2532 |
if (typeof attribute !== 'function') {
|
|
2533 |
return attribute;
|
|
2534 |
}
|
|
2535 |
|
|
2536 |
return function () {
|
|
2537 |
return registry[key].apply(null, arguments);
|
|
2538 |
};
|
|
2539 |
});
|
|
2540 |
}
|
|
2541 |
/**
|
|
2542 |
* Registers a generic store.
|
|
2543 |
*
|
|
2544 |
* @param {string} key Store registry key.
|
|
2545 |
* @param {Object} config Configuration (getSelectors, getActions, subscribe).
|
|
2546 |
*/
|
|
2547 |
|
|
2548 |
|
|
2549 |
function registerGenericStore(key, config) {
|
|
2550 |
if (typeof config.getSelectors !== 'function') {
|
|
2551 |
throw new TypeError('config.getSelectors must be a function');
|
|
2552 |
}
|
|
2553 |
|
|
2554 |
if (typeof config.getActions !== 'function') {
|
|
2555 |
throw new TypeError('config.getActions must be a function');
|
|
2556 |
}
|
|
2557 |
|
|
2558 |
if (typeof config.subscribe !== 'function') {
|
|
2559 |
throw new TypeError('config.subscribe must be a function');
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
stores[key] = config;
|
|
2563 |
config.subscribe(globalListener);
|
|
2564 |
}
|
|
2565 |
|
|
2566 |
var registry = {
|
|
2567 |
registerGenericStore: registerGenericStore,
|
|
2568 |
stores: stores,
|
|
2569 |
namespaces: stores,
|
|
2570 |
// TODO: Deprecate/remove this.
|
|
2571 |
subscribe: subscribe,
|
|
2572 |
select: select,
|
|
2573 |
__experimentalResolveSelect: __experimentalResolveSelect,
|
|
2574 |
dispatch: dispatch,
|
|
2575 |
use: use
|
|
2576 |
};
|
|
2577 |
/**
|
|
2578 |
* Registers a standard `@wordpress/data` store.
|
|
2579 |
*
|
|
2580 |
* @param {string} reducerKey Reducer key.
|
|
2581 |
* @param {Object} options Store description (reducer, actions, selectors, resolvers).
|
|
2582 |
*
|
|
2583 |
* @return {Object} Registered store object.
|
|
2584 |
*/
|
|
2585 |
|
|
2586 |
registry.registerStore = function (reducerKey, options) {
|
|
2587 |
if (!options.reducer) {
|
|
2588 |
throw new TypeError('Must specify store reducer');
|
|
2589 |
}
|
|
2590 |
|
|
2591 |
var namespace = createNamespace(reducerKey, options, registry);
|
|
2592 |
registerGenericStore(reducerKey, namespace);
|
|
2593 |
return namespace.store;
|
|
2594 |
}; //
|
|
2595 |
// TODO:
|
|
2596 |
// This function will be deprecated as soon as it is no longer internally referenced.
|
|
2597 |
//
|
|
2598 |
|
|
2599 |
|
|
2600 |
function use(plugin, options) {
|
|
2601 |
registry = registry_objectSpread({}, registry, {}, plugin(registry, options));
|
|
2602 |
return registry;
|
|
2603 |
}
|
|
2604 |
|
|
2605 |
registerGenericStore('core/data', build_module_store(registry));
|
|
2606 |
Object.entries(storeConfigs).forEach(function (_ref) {
|
|
2607 |
var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
|
|
2608 |
name = _ref2[0],
|
|
2609 |
config = _ref2[1];
|
|
2610 |
|
|
2611 |
return registry.registerStore(name, config);
|
|
2612 |
});
|
|
2613 |
|
|
2614 |
if (parent) {
|
|
2615 |
parent.subscribe(globalListener);
|
|
2616 |
}
|
|
2617 |
|
|
2618 |
return withPlugins(registry);
|
|
2619 |
}
|
|
2620 |
|
|
2621 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js
|
|
2622 |
/**
|
|
2623 |
* Internal dependencies
|
|
2624 |
*/
|
|
2625 |
|
|
2626 |
/* harmony default export */ var default_registry = (createRegistry());
|
|
2627 |
|
|
2628 |
// EXTERNAL MODULE: external {"this":["wp","deprecated"]}
|
|
2629 |
var external_this_wp_deprecated_ = __webpack_require__(37);
|
|
2630 |
var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_);
|
|
2631 |
|
|
2632 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/controls/index.js
|
|
2633 |
/**
|
|
2634 |
* WordPress dependencies
|
|
2635 |
*/
|
|
2636 |
|
|
2637 |
/* harmony default export */ var controls = (function (registry) {
|
|
2638 |
external_this_wp_deprecated_default()('wp.data.plugins.controls', {
|
|
2639 |
hint: 'The controls plugins is now baked-in.'
|
|
2640 |
});
|
|
2641 |
return registry;
|
|
2642 |
});
|
|
2643 |
|
|
2644 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js
|
|
2645 |
var objectStorage;
|
|
2646 |
var object_storage = {
|
|
2647 |
getItem: function getItem(key) {
|
|
2648 |
if (!objectStorage || !objectStorage[key]) {
|
|
2649 |
return null;
|
|
2650 |
}
|
|
2651 |
|
|
2652 |
return objectStorage[key];
|
|
2653 |
},
|
|
2654 |
setItem: function setItem(key, value) {
|
|
2655 |
if (!objectStorage) {
|
|
2656 |
object_storage.clear();
|
|
2657 |
}
|
|
2658 |
|
|
2659 |
objectStorage[key] = String(value);
|
|
2660 |
},
|
|
2661 |
clear: function clear() {
|
|
2662 |
objectStorage = Object.create(null);
|
|
2663 |
}
|
|
2664 |
};
|
|
2665 |
/* harmony default export */ var object = (object_storage);
|
|
2666 |
|
|
2667 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js
|
|
2668 |
/**
|
|
2669 |
* Internal dependencies
|
|
2670 |
*/
|
|
2671 |
|
|
2672 |
var default_storage;
|
|
2673 |
|
|
2674 |
try {
|
|
2675 |
// Private Browsing in Safari 10 and earlier will throw an error when
|
|
2676 |
// attempting to set into localStorage. The test here is intentional in
|
|
2677 |
// causing a thrown error as condition for using fallback object storage.
|
|
2678 |
default_storage = window.localStorage;
|
|
2679 |
default_storage.setItem('__wpDataTestLocalStorage', '');
|
|
2680 |
default_storage.removeItem('__wpDataTestLocalStorage');
|
|
2681 |
} catch (error) {
|
|
2682 |
default_storage = object;
|
|
2683 |
}
|
|
2684 |
|
|
2685 |
/* harmony default export */ var storage_default = (default_storage);
|
|
2686 |
|
|
2687 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js
|
|
2688 |
|
|
2689 |
|
|
2690 |
function persistence_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2691 |
|
|
2692 |
function persistence_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { persistence_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { persistence_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2693 |
|
|
2694 |
/**
|
|
2695 |
* External dependencies
|
|
2696 |
*/
|
|
2697 |
|
|
2698 |
/**
|
|
2699 |
* Internal dependencies
|
|
2700 |
*/
|
|
2701 |
|
|
2702 |
|
|
2703 |
|
|
2704 |
/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */
|
|
2705 |
|
|
2706 |
/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */
|
|
2707 |
|
|
2708 |
/**
|
|
2709 |
* @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.
|
|
2710 |
*
|
|
2711 |
* @property {Storage} storage Persistent storage implementation. This must
|
|
2712 |
* at least implement `getItem` and `setItem` of
|
|
2713 |
* the Web Storage API.
|
|
2714 |
* @property {string} storageKey Key on which to set in persistent storage.
|
|
2715 |
*
|
|
2716 |
*/
|
|
2717 |
|
|
2718 |
/**
|
|
2719 |
* Default plugin storage.
|
|
2720 |
*
|
|
2721 |
* @type {Storage}
|
|
2722 |
*/
|
|
2723 |
|
|
2724 |
var DEFAULT_STORAGE = storage_default;
|
|
2725 |
/**
|
|
2726 |
* Default plugin storage key.
|
|
2727 |
*
|
|
2728 |
* @type {string}
|
|
2729 |
*/
|
|
2730 |
|
|
2731 |
var DEFAULT_STORAGE_KEY = 'WP_DATA';
|
|
2732 |
/**
|
|
2733 |
* Higher-order reducer which invokes the original reducer only if state is
|
|
2734 |
* inequal from that of the action's `nextState` property, otherwise returning
|
|
2735 |
* the original state reference.
|
|
2736 |
*
|
|
2737 |
* @param {Function} reducer Original reducer.
|
|
2738 |
*
|
|
2739 |
* @return {Function} Enhanced reducer.
|
|
2740 |
*/
|
|
2741 |
|
|
2742 |
var withLazySameState = function withLazySameState(reducer) {
|
|
2743 |
return function (state, action) {
|
|
2744 |
if (action.nextState === state) {
|
|
2745 |
return state;
|
|
2746 |
}
|
|
2747 |
|
|
2748 |
return reducer(state, action);
|
|
2749 |
};
|
|
2750 |
};
|
|
2751 |
/**
|
|
2752 |
* Creates a persistence interface, exposing getter and setter methods (`get`
|
|
2753 |
* and `set` respectively).
|
|
2754 |
*
|
|
2755 |
* @param {WPDataPersistencePluginOptions} options Plugin options.
|
|
2756 |
*
|
|
2757 |
* @return {Object} Persistence interface.
|
|
2758 |
*/
|
|
2759 |
|
|
2760 |
function createPersistenceInterface(options) {
|
|
2761 |
var _options$storage = options.storage,
|
|
2762 |
storage = _options$storage === void 0 ? DEFAULT_STORAGE : _options$storage,
|
|
2763 |
_options$storageKey = options.storageKey,
|
|
2764 |
storageKey = _options$storageKey === void 0 ? DEFAULT_STORAGE_KEY : _options$storageKey;
|
|
2765 |
var data;
|
|
2766 |
/**
|
|
2767 |
* Returns the persisted data as an object, defaulting to an empty object.
|
|
2768 |
*
|
|
2769 |
* @return {Object} Persisted data.
|
|
2770 |
*/
|
|
2771 |
|
|
2772 |
function getData() {
|
|
2773 |
if (data === undefined) {
|
|
2774 |
// If unset, getItem is expected to return null. Fall back to
|
|
2775 |
// empty object.
|
|
2776 |
var persisted = storage.getItem(storageKey);
|
|
2777 |
|
|
2778 |
if (persisted === null) {
|
|
2779 |
data = {};
|
|
2780 |
} else {
|
|
2781 |
try {
|
|
2782 |
data = JSON.parse(persisted);
|
|
2783 |
} catch (error) {
|
|
2784 |
// Similarly, should any error be thrown during parse of
|
|
2785 |
// the string (malformed JSON), fall back to empty object.
|
|
2786 |
data = {};
|
|
2787 |
}
|
|
2788 |
}
|
|
2789 |
}
|
|
2790 |
|
|
2791 |
return data;
|
|
2792 |
}
|
|
2793 |
/**
|
|
2794 |
* Merges an updated reducer state into the persisted data.
|
|
2795 |
*
|
|
2796 |
* @param {string} key Key to update.
|
|
2797 |
* @param {*} value Updated value.
|
|
2798 |
*/
|
|
2799 |
|
|
2800 |
|
|
2801 |
function setData(key, value) {
|
|
2802 |
data = persistence_objectSpread({}, data, Object(defineProperty["a" /* default */])({}, key, value));
|
|
2803 |
storage.setItem(storageKey, JSON.stringify(data));
|
|
2804 |
}
|
|
2805 |
|
|
2806 |
return {
|
|
2807 |
get: getData,
|
|
2808 |
set: setData
|
|
2809 |
};
|
|
2810 |
}
|
|
2811 |
/**
|
|
2812 |
* Data plugin to persist store state into a single storage key.
|
|
2813 |
*
|
|
2814 |
* @param {WPDataRegistry} registry Data registry.
|
|
2815 |
* @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.
|
|
2816 |
*
|
|
2817 |
* @return {WPDataPlugin} Data plugin.
|
|
2818 |
*/
|
|
2819 |
|
|
2820 |
function persistencePlugin(registry, pluginOptions) {
|
|
2821 |
var persistence = createPersistenceInterface(pluginOptions);
|
|
2822 |
/**
|
|
2823 |
* Creates an enhanced store dispatch function, triggering the state of the
|
|
2824 |
* given reducer key to be persisted when changed.
|
|
2825 |
*
|
|
2826 |
* @param {Function} getState Function which returns current state.
|
|
2827 |
* @param {string} reducerKey Reducer key.
|
|
2828 |
* @param {?Array<string>} keys Optional subset of keys to save.
|
|
2829 |
*
|
|
2830 |
* @return {Function} Enhanced dispatch function.
|
|
2831 |
*/
|
|
2832 |
|
|
2833 |
function createPersistOnChange(getState, reducerKey, keys) {
|
|
2834 |
var getPersistedState;
|
|
2835 |
|
|
2836 |
if (Array.isArray(keys)) {
|
|
2837 |
// Given keys, the persisted state should by produced as an object
|
|
2838 |
// of the subset of keys. This implementation uses combineReducers
|
|
2839 |
// to leverage its behavior of returning the same object when none
|
|
2840 |
// of the property values changes. This allows a strict reference
|
|
2841 |
// equality to bypass a persistence set on an unchanging state.
|
|
2842 |
var reducers = keys.reduce(function (accumulator, key) {
|
|
2843 |
return Object.assign(accumulator, Object(defineProperty["a" /* default */])({}, key, function (state, action) {
|
|
2844 |
return action.nextState[key];
|
|
2845 |
}));
|
|
2846 |
}, {});
|
|
2847 |
getPersistedState = withLazySameState(turbo_combine_reducers_default()(reducers));
|
|
2848 |
} else {
|
|
2849 |
getPersistedState = function getPersistedState(state, action) {
|
|
2850 |
return action.nextState;
|
|
2851 |
};
|
|
2852 |
}
|
|
2853 |
|
|
2854 |
var lastState = getPersistedState(undefined, {
|
|
2855 |
nextState: getState()
|
|
2856 |
});
|
|
2857 |
return function () {
|
|
2858 |
var state = getPersistedState(lastState, {
|
|
2859 |
nextState: getState()
|
|
2860 |
});
|
|
2861 |
|
|
2862 |
if (state !== lastState) {
|
|
2863 |
persistence.set(reducerKey, state);
|
|
2864 |
lastState = state;
|
|
2865 |
}
|
|
2866 |
};
|
|
2867 |
}
|
|
2868 |
|
|
2869 |
return {
|
|
2870 |
registerStore: function registerStore(reducerKey, options) {
|
|
2871 |
if (!options.persist) {
|
|
2872 |
return registry.registerStore(reducerKey, options);
|
|
2873 |
} // Load from persistence to use as initial state.
|
|
2874 |
|
|
2875 |
|
|
2876 |
var persistedState = persistence.get()[reducerKey];
|
|
2877 |
|
|
2878 |
if (persistedState !== undefined) {
|
|
2879 |
var initialState = options.reducer(options.initialState, {
|
|
2880 |
type: '@@WP/PERSISTENCE_RESTORE'
|
|
2881 |
});
|
|
2882 |
|
|
2883 |
if (Object(external_this_lodash_["isPlainObject"])(initialState) && Object(external_this_lodash_["isPlainObject"])(persistedState)) {
|
|
2884 |
// If state is an object, ensure that:
|
|
2885 |
// - Other keys are left intact when persisting only a
|
|
2886 |
// subset of keys.
|
|
2887 |
// - New keys in what would otherwise be used as initial
|
|
2888 |
// state are deeply merged as base for persisted value.
|
|
2889 |
initialState = Object(external_this_lodash_["merge"])({}, initialState, persistedState);
|
|
2890 |
} else {
|
|
2891 |
// If there is a mismatch in object-likeness of default
|
|
2892 |
// initial or persisted state, defer to persisted value.
|
|
2893 |
initialState = persistedState;
|
|
2894 |
}
|
|
2895 |
|
|
2896 |
options = persistence_objectSpread({}, options, {
|
|
2897 |
initialState: initialState
|
|
2898 |
});
|
|
2899 |
}
|
|
2900 |
|
|
2901 |
var store = registry.registerStore(reducerKey, options);
|
|
2902 |
store.subscribe(createPersistOnChange(store.getState, reducerKey, options.persist));
|
|
2903 |
return store;
|
|
2904 |
}
|
|
2905 |
};
|
|
2906 |
}
|
|
2907 |
/**
|
|
2908 |
* Deprecated: Remove this function and the code in WordPress Core that calls
|
|
2909 |
* it once WordPress 5.4 is released.
|
|
2910 |
*/
|
|
2911 |
|
|
2912 |
|
|
2913 |
persistencePlugin.__unstableMigrate = function (pluginOptions) {
|
|
2914 |
var persistence = createPersistenceInterface(pluginOptions);
|
|
2915 |
var state = persistence.get(); // Migrate 'insertUsage' from 'core/editor' to 'core/block-editor'
|
|
2916 |
|
|
2917 |
var insertUsage = Object(external_this_lodash_["get"])(state, ['core/editor', 'preferences', 'insertUsage']);
|
|
2918 |
|
|
2919 |
if (insertUsage) {
|
|
2920 |
persistence.set('core/block-editor', {
|
|
2921 |
preferences: {
|
|
2922 |
insertUsage: insertUsage
|
|
2923 |
}
|
|
2924 |
});
|
|
2925 |
}
|
|
2926 |
|
|
2927 |
var editPostState = state['core/edit-post']; // Default `fullscreenMode` to `false` if any persisted state had existed
|
|
2928 |
// and the user hadn't made an explicit choice about fullscreen mode. This
|
|
2929 |
// is needed since `fullscreenMode` previously did not have a default value
|
|
2930 |
// and was implicitly false by its absence. It is now `true` by default, but
|
|
2931 |
// this change is not intended to affect upgrades from earlier versions.
|
|
2932 |
|
|
2933 |
var hadPersistedState = Object.keys(state).length > 0;
|
|
2934 |
var hadFullscreenModePreference = Object(external_this_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'fullscreenMode']);
|
|
2935 |
|
|
2936 |
if (hadPersistedState && !hadFullscreenModePreference) {
|
|
2937 |
editPostState = Object(external_this_lodash_["merge"])({}, editPostState, {
|
|
2938 |
preferences: {
|
|
2939 |
features: {
|
|
2940 |
fullscreenMode: false
|
|
2941 |
}
|
|
2942 |
}
|
|
2943 |
});
|
|
2944 |
} // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post'
|
|
2945 |
|
|
2946 |
|
|
2947 |
var areTipsEnabled = Object(external_this_lodash_["get"])(state, ['core/nux', 'preferences', 'areTipsEnabled']);
|
|
2948 |
var hasWelcomeGuide = Object(external_this_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'welcomeGuide']);
|
|
2949 |
|
|
2950 |
if (areTipsEnabled !== undefined && !hasWelcomeGuide) {
|
|
2951 |
editPostState = Object(external_this_lodash_["merge"])({}, editPostState, {
|
|
2952 |
preferences: {
|
|
2953 |
features: {
|
|
2954 |
welcomeGuide: areTipsEnabled
|
|
2955 |
}
|
|
2956 |
}
|
|
2957 |
});
|
|
2958 |
}
|
|
2959 |
|
|
2960 |
if (editPostState !== state['core/edit-post']) {
|
|
2961 |
persistence.set('core/edit-post', editPostState);
|
|
2962 |
}
|
|
2963 |
};
|
|
2964 |
|
|
2965 |
/* harmony default export */ var plugins_persistence = (persistencePlugin);
|
|
2966 |
|
|
2967 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js
|
|
2968 |
|
|
2969 |
|
|
2970 |
|
|
2971 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
|
|
2972 |
var esm_extends = __webpack_require__(8);
|
|
2973 |
|
|
2974 |
// EXTERNAL MODULE: external {"this":["wp","element"]}
|
|
2975 |
var external_this_wp_element_ = __webpack_require__(0);
|
|
2976 |
|
|
2977 |
// EXTERNAL MODULE: external {"this":["wp","compose"]}
|
|
2978 |
var external_this_wp_compose_ = __webpack_require__(9);
|
|
2979 |
|
|
2980 |
// EXTERNAL MODULE: external {"this":"React"}
|
|
2981 |
var external_this_React_ = __webpack_require__(13);
|
|
2982 |
|
|
2983 |
// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
|
|
2984 |
|
|
2985 |
|
|
2986 |
function areInputsEqual(newInputs, lastInputs) {
|
|
2987 |
if (newInputs.length !== lastInputs.length) {
|
|
2988 |
return false;
|
|
2989 |
}
|
|
2990 |
|
|
2991 |
for (var i = 0; i < newInputs.length; i++) {
|
|
2992 |
if (newInputs[i] !== lastInputs[i]) {
|
|
2993 |
return false;
|
|
2994 |
}
|
|
2995 |
}
|
|
2996 |
|
|
2997 |
return true;
|
|
2998 |
}
|
|
2999 |
|
|
3000 |
function useMemoOne(getResult, inputs) {
|
|
3001 |
var initial = Object(external_this_React_["useState"])(function () {
|
|
3002 |
return {
|
|
3003 |
inputs: inputs,
|
|
3004 |
result: getResult()
|
|
3005 |
};
|
|
3006 |
})[0];
|
|
3007 |
var committed = Object(external_this_React_["useRef"])(initial);
|
|
3008 |
var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
|
|
3009 |
var cache = isInputMatch ? committed.current : {
|
|
3010 |
inputs: inputs,
|
|
3011 |
result: getResult()
|
|
3012 |
};
|
|
3013 |
Object(external_this_React_["useEffect"])(function () {
|
|
3014 |
committed.current = cache;
|
|
3015 |
}, [cache]);
|
|
3016 |
return cache.result;
|
|
3017 |
}
|
|
3018 |
function useCallbackOne(callback, inputs) {
|
|
3019 |
return useMemoOne(function () {
|
|
3020 |
return callback;
|
|
3021 |
}, inputs);
|
|
3022 |
}
|
|
3023 |
var useMemo = useMemoOne;
|
|
3024 |
var useCallback = useCallbackOne;
|
|
3025 |
|
|
3026 |
|
|
3027 |
|
|
3028 |
// EXTERNAL MODULE: external {"this":["wp","priorityQueue"]}
|
|
3029 |
var external_this_wp_priorityQueue_ = __webpack_require__(150);
|
|
3030 |
|
|
3031 |
// EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]}
|
|
3032 |
var external_this_wp_isShallowEqual_ = __webpack_require__(64);
|
|
3033 |
var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_);
|
|
3034 |
|
|
3035 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js
|
|
3036 |
/**
|
|
3037 |
* WordPress dependencies
|
|
3038 |
*/
|
|
3039 |
|
|
3040 |
/**
|
|
3041 |
* Internal dependencies
|
|
3042 |
*/
|
|
3043 |
|
|
3044 |
|
|
3045 |
var Context = Object(external_this_wp_element_["createContext"])(default_registry);
|
|
3046 |
var Consumer = Context.Consumer,
|
|
3047 |
Provider = Context.Provider;
|
|
3048 |
/**
|
|
3049 |
* A custom react Context consumer exposing the provided `registry` to
|
|
3050 |
* children components. Used along with the RegistryProvider.
|
|
3051 |
*
|
|
3052 |
* You can read more about the react context api here:
|
|
3053 |
* https://reactjs.org/docs/context.html#contextprovider
|
|
3054 |
*
|
|
3055 |
* @example
|
|
3056 |
* ```js
|
|
3057 |
* const {
|
|
3058 |
* RegistryProvider,
|
|
3059 |
* RegistryConsumer,
|
|
3060 |
* createRegistry
|
|
3061 |
* } = wp.data;
|
|
3062 |
*
|
|
3063 |
* const registry = createRegistry( {} );
|
|
3064 |
*
|
|
3065 |
* const App = ( { props } ) => {
|
|
3066 |
* return <RegistryProvider value={ registry }>
|
|
3067 |
* <div>Hello There</div>
|
|
3068 |
* <RegistryConsumer>
|
|
3069 |
* { ( registry ) => (
|
|
3070 |
* <ComponentUsingRegistry
|
|
3071 |
* { ...props }
|
|
3072 |
* registry={ registry }
|
|
3073 |
* ) }
|
|
3074 |
* </RegistryConsumer>
|
|
3075 |
* </RegistryProvider>
|
|
3076 |
* }
|
|
3077 |
* ```
|
|
3078 |
*/
|
|
3079 |
|
|
3080 |
var RegistryConsumer = Consumer;
|
|
3081 |
/**
|
|
3082 |
* A custom Context provider for exposing the provided `registry` to children
|
|
3083 |
* components via a consumer.
|
|
3084 |
*
|
|
3085 |
* See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
|
|
3086 |
* example.
|
|
3087 |
*/
|
|
3088 |
|
|
3089 |
/* harmony default export */ var context = (Provider);
|
|
3090 |
|
|
3091 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js
|
|
3092 |
/**
|
|
3093 |
* WordPress dependencies
|
|
3094 |
*/
|
|
3095 |
|
|
3096 |
/**
|
|
3097 |
* Internal dependencies
|
|
3098 |
*/
|
|
3099 |
|
|
3100 |
|
|
3101 |
/**
|
|
3102 |
* A custom react hook exposing the registry context for use.
|
|
3103 |
*
|
|
3104 |
* This exposes the `registry` value provided via the
|
|
3105 |
* <a href="#RegistryProvider">Registry Provider</a> to a component implementing
|
|
3106 |
* this hook.
|
|
3107 |
*
|
|
3108 |
* It acts similarly to the `useContext` react hook.
|
|
3109 |
*
|
|
3110 |
* Note: Generally speaking, `useRegistry` is a low level hook that in most cases
|
|
3111 |
* won't be needed for implementation. Most interactions with the wp.data api
|
|
3112 |
* can be performed via the `useSelect` hook, or the `withSelect` and
|
|
3113 |
* `withDispatch` higher order components.
|
|
3114 |
*
|
|
3115 |
* @example
|
|
3116 |
* ```js
|
|
3117 |
* const {
|
|
3118 |
* RegistryProvider,
|
|
3119 |
* createRegistry,
|
|
3120 |
* useRegistry,
|
|
3121 |
* } = wp.data
|
|
3122 |
*
|
|
3123 |
* const registry = createRegistry( {} );
|
|
3124 |
*
|
|
3125 |
* const SomeChildUsingRegistry = ( props ) => {
|
|
3126 |
* const registry = useRegistry( registry );
|
|
3127 |
* // ...logic implementing the registry in other react hooks.
|
|
3128 |
* };
|
|
3129 |
*
|
|
3130 |
*
|
|
3131 |
* const ParentProvidingRegistry = ( props ) => {
|
|
3132 |
* return <RegistryProvider value={ registry }>
|
|
3133 |
* <SomeChildUsingRegistry { ...props } />
|
|
3134 |
* </RegistryProvider>
|
|
3135 |
* };
|
|
3136 |
* ```
|
|
3137 |
*
|
|
3138 |
* @return {Function} A custom react hook exposing the registry context value.
|
|
3139 |
*/
|
|
3140 |
|
|
3141 |
function useRegistry() {
|
|
3142 |
return Object(external_this_wp_element_["useContext"])(Context);
|
|
3143 |
}
|
|
3144 |
|
|
3145 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js
|
|
3146 |
/**
|
|
3147 |
* WordPress dependencies
|
|
3148 |
*/
|
|
3149 |
|
|
3150 |
var context_Context = Object(external_this_wp_element_["createContext"])(false);
|
|
3151 |
var context_Consumer = context_Context.Consumer,
|
|
3152 |
context_Provider = context_Context.Provider;
|
|
3153 |
var AsyncModeConsumer = context_Consumer;
|
|
3154 |
/**
|
|
3155 |
* Context Provider Component used to switch the data module component rerendering
|
|
3156 |
* between Sync and Async modes.
|
|
3157 |
*
|
|
3158 |
* @example
|
|
3159 |
*
|
|
3160 |
* ```js
|
|
3161 |
* import { useSelect, AsyncModeProvider } from '@wordpress/data';
|
|
3162 |
*
|
|
3163 |
* function BlockCount() {
|
|
3164 |
* const count = useSelect( ( select ) => {
|
|
3165 |
* return select( 'core/block-editor' ).getBlockCount()
|
|
3166 |
* }, [] );
|
|
3167 |
*
|
|
3168 |
* return count;
|
|
3169 |
* }
|
|
3170 |
*
|
|
3171 |
* function App() {
|
|
3172 |
* return (
|
|
3173 |
* <AsyncModeProvider value={ true }>
|
|
3174 |
* <BlockCount />
|
|
3175 |
* </AsyncModeProvider>
|
|
3176 |
* );
|
|
3177 |
* }
|
|
3178 |
* ```
|
|
3179 |
*
|
|
3180 |
* In this example, the BlockCount component is rerendered asynchronously.
|
|
3181 |
* It means if a more critical task is being performed (like typing in an input),
|
|
3182 |
* the rerendering is delayed until the browser becomes IDLE.
|
|
3183 |
* It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.
|
|
3184 |
*
|
|
3185 |
* @param {boolean} props.value Enable Async Mode.
|
|
3186 |
* @return {WPComponent} The component to be rendered.
|
|
3187 |
*/
|
|
3188 |
|
|
3189 |
/* harmony default export */ var async_mode_provider_context = (context_Provider);
|
|
3190 |
|
|
3191 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js
|
|
3192 |
/**
|
|
3193 |
* WordPress dependencies
|
|
3194 |
*/
|
|
3195 |
|
|
3196 |
/**
|
|
3197 |
* Internal dependencies
|
|
3198 |
*/
|
|
3199 |
|
|
3200 |
|
|
3201 |
function useAsyncMode() {
|
|
3202 |
return Object(external_this_wp_element_["useContext"])(context_Context);
|
|
3203 |
}
|
|
3204 |
|
|
3205 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js
|
|
3206 |
|
|
3207 |
|
|
3208 |
/**
|
|
3209 |
* External dependencies
|
|
3210 |
*/
|
|
3211 |
|
|
3212 |
/**
|
|
3213 |
* WordPress dependencies
|
|
3214 |
*/
|
|
3215 |
|
|
3216 |
|
|
3217 |
|
|
3218 |
|
|
3219 |
/**
|
|
3220 |
* Internal dependencies
|
|
3221 |
*/
|
|
3222 |
|
|
3223 |
|
|
3224 |
|
|
3225 |
/**
|
|
3226 |
* Favor useLayoutEffect to ensure the store subscription callback always has
|
|
3227 |
* the selector from the latest render. If a store update happens between render
|
|
3228 |
* and the effect, this could cause missed/stale updates or inconsistent state.
|
|
3229 |
*
|
|
3230 |
* Fallback to useEffect for server rendered components because currently React
|
|
3231 |
* throws a warning when using useLayoutEffect in that environment.
|
|
3232 |
*/
|
|
3233 |
|
|
3234 |
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_this_wp_element_["useLayoutEffect"] : external_this_wp_element_["useEffect"];
|
|
3235 |
var renderQueue = Object(external_this_wp_priorityQueue_["createQueue"])();
|
|
3236 |
/**
|
|
3237 |
* Custom react hook for retrieving props from registered selectors.
|
|
3238 |
*
|
|
3239 |
* In general, this custom React hook follows the
|
|
3240 |
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
3241 |
*
|
|
3242 |
* @param {Function} _mapSelect Function called on every state change. The
|
|
3243 |
* returned value is exposed to the component
|
|
3244 |
* implementing this hook. The function receives
|
|
3245 |
* the `registry.select` method on the first
|
|
3246 |
* argument and the `registry` on the second
|
|
3247 |
* argument.
|
|
3248 |
* @param {Array} deps If provided, this memoizes the mapSelect so the
|
|
3249 |
* same `mapSelect` is invoked on every state
|
|
3250 |
* change unless the dependencies change.
|
|
3251 |
*
|
|
3252 |
* @example
|
|
3253 |
* ```js
|
|
3254 |
* const { useSelect } = wp.data;
|
|
3255 |
*
|
|
3256 |
* function HammerPriceDisplay( { currency } ) {
|
|
3257 |
* const price = useSelect( ( select ) => {
|
|
3258 |
* return select( 'my-shop' ).getPrice( 'hammer', currency )
|
|
3259 |
* }, [ currency ] );
|
|
3260 |
* return new Intl.NumberFormat( 'en-US', {
|
|
3261 |
* style: 'currency',
|
|
3262 |
* currency,
|
|
3263 |
* } ).format( price );
|
|
3264 |
* }
|
|
3265 |
*
|
|
3266 |
* // Rendered in the application:
|
|
3267 |
* // <HammerPriceDisplay currency="USD" />
|
|
3268 |
* ```
|
|
3269 |
*
|
|
3270 |
* In the above example, when `HammerPriceDisplay` is rendered into an
|
|
3271 |
* application, the price will be retrieved from the store state using the
|
|
3272 |
* `mapSelect` callback on `useSelect`. If the currency prop changes then
|
|
3273 |
* any price in the state for that currency is retrieved. If the currency prop
|
|
3274 |
* doesn't change and other props are passed in that do change, the price will
|
|
3275 |
* not change because the dependency is just the currency.
|
|
3276 |
*
|
|
3277 |
* @return {Function} A custom react hook.
|
|
3278 |
*/
|
|
3279 |
|
|
3280 |
function useSelect(_mapSelect, deps) {
|
|
3281 |
var mapSelect = Object(external_this_wp_element_["useCallback"])(_mapSelect, deps);
|
|
3282 |
var registry = useRegistry();
|
|
3283 |
var isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache.
|
|
3284 |
// We use the cache-stable `useMemoOne` to avoid
|
|
3285 |
// losing queues.
|
|
3286 |
|
|
3287 |
var queueContext = useMemoOne(function () {
|
|
3288 |
return {
|
|
3289 |
queue: true
|
|
3290 |
};
|
|
3291 |
}, [registry]);
|
|
3292 |
|
|
3293 |
var _useReducer = Object(external_this_wp_element_["useReducer"])(function (s) {
|
|
3294 |
return s + 1;
|
|
3295 |
}, 0),
|
|
3296 |
_useReducer2 = Object(slicedToArray["a" /* default */])(_useReducer, 2),
|
|
3297 |
forceRender = _useReducer2[1];
|
|
3298 |
|
|
3299 |
var latestMapSelect = Object(external_this_wp_element_["useRef"])();
|
|
3300 |
var latestIsAsync = Object(external_this_wp_element_["useRef"])(isAsync);
|
|
3301 |
var latestMapOutput = Object(external_this_wp_element_["useRef"])();
|
|
3302 |
var latestMapOutputError = Object(external_this_wp_element_["useRef"])();
|
|
3303 |
var isMountedAndNotUnsubscribing = Object(external_this_wp_element_["useRef"])();
|
|
3304 |
var mapOutput;
|
|
3305 |
|
|
3306 |
try {
|
|
3307 |
if (latestMapSelect.current !== mapSelect || latestMapOutputError.current) {
|
|
3308 |
mapOutput = mapSelect(registry.select, registry);
|
|
3309 |
} else {
|
|
3310 |
mapOutput = latestMapOutput.current;
|
|
3311 |
}
|
|
3312 |
} catch (error) {
|
|
3313 |
var errorMessage = "An error occurred while running 'mapSelect': ".concat(error.message);
|
|
3314 |
|
|
3315 |
if (latestMapOutputError.current) {
|
|
3316 |
errorMessage += "\nThe error may be correlated with this previous error:\n";
|
|
3317 |
errorMessage += "".concat(latestMapOutputError.current.stack, "\n\n");
|
|
3318 |
errorMessage += 'Original stack trace:';
|
|
3319 |
throw new Error(errorMessage);
|
|
3320 |
} else {
|
|
3321 |
// eslint-disable-next-line no-console
|
|
3322 |
console.error(errorMessage);
|
|
3323 |
}
|
|
3324 |
}
|
|
3325 |
|
|
3326 |
useIsomorphicLayoutEffect(function () {
|
|
3327 |
latestMapSelect.current = mapSelect;
|
|
3328 |
latestMapOutput.current = mapOutput;
|
|
3329 |
latestMapOutputError.current = undefined;
|
|
3330 |
isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates
|
|
3331 |
// to avoid using stale values in the flushed
|
|
3332 |
// callbacks or potentially overwriting a
|
|
3333 |
// changed `latestMapOutput.current`.
|
|
3334 |
|
|
3335 |
if (latestIsAsync.current !== isAsync) {
|
|
3336 |
latestIsAsync.current = isAsync;
|
|
3337 |
renderQueue.flush(queueContext);
|
|
3338 |
}
|
|
3339 |
});
|
|
3340 |
useIsomorphicLayoutEffect(function () {
|
|
3341 |
var onStoreChange = function onStoreChange() {
|
|
3342 |
if (isMountedAndNotUnsubscribing.current) {
|
|
3343 |
try {
|
|
3344 |
var newMapOutput = latestMapSelect.current(registry.select, registry);
|
|
3345 |
|
|
3346 |
if (external_this_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) {
|
|
3347 |
return;
|
|
3348 |
}
|
|
3349 |
|
|
3350 |
latestMapOutput.current = newMapOutput;
|
|
3351 |
} catch (error) {
|
|
3352 |
latestMapOutputError.current = error;
|
|
3353 |
}
|
|
3354 |
|
|
3355 |
forceRender();
|
|
3356 |
}
|
|
3357 |
}; // catch any possible state changes during mount before the subscription
|
|
3358 |
// could be set.
|
|
3359 |
|
|
3360 |
|
|
3361 |
if (latestIsAsync.current) {
|
|
3362 |
renderQueue.add(queueContext, onStoreChange);
|
|
3363 |
} else {
|
|
3364 |
onStoreChange();
|
|
3365 |
}
|
|
3366 |
|
|
3367 |
var unsubscribe = registry.subscribe(function () {
|
|
3368 |
if (latestIsAsync.current) {
|
|
3369 |
renderQueue.add(queueContext, onStoreChange);
|
|
3370 |
} else {
|
|
3371 |
onStoreChange();
|
|
3372 |
}
|
|
3373 |
});
|
|
3374 |
return function () {
|
|
3375 |
isMountedAndNotUnsubscribing.current = false;
|
|
3376 |
unsubscribe();
|
|
3377 |
renderQueue.flush(queueContext);
|
|
3378 |
};
|
|
3379 |
}, [registry]);
|
|
3380 |
return mapOutput;
|
|
3381 |
}
|
|
3382 |
|
|
3383 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
|
|
3384 |
|
|
3385 |
|
|
3386 |
|
|
3387 |
/**
|
|
3388 |
* WordPress dependencies
|
|
3389 |
*/
|
|
3390 |
|
|
3391 |
/**
|
|
3392 |
* Internal dependencies
|
|
3393 |
*/
|
|
3394 |
|
|
3395 |
|
|
3396 |
/**
|
|
3397 |
* Higher-order component used to inject state-derived props using registered
|
|
3398 |
* selectors.
|
|
3399 |
*
|
|
3400 |
* @param {Function} mapSelectToProps Function called on every state change,
|
|
3401 |
* expected to return object of props to
|
|
3402 |
* merge with the component's own props.
|
|
3403 |
*
|
|
3404 |
* @example
|
|
3405 |
* ```js
|
|
3406 |
* function PriceDisplay( { price, currency } ) {
|
|
3407 |
* return new Intl.NumberFormat( 'en-US', {
|
|
3408 |
* style: 'currency',
|
|
3409 |
* currency,
|
|
3410 |
* } ).format( price );
|
|
3411 |
* }
|
|
3412 |
*
|
|
3413 |
* const { withSelect } = wp.data;
|
|
3414 |
*
|
|
3415 |
* const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
|
|
3416 |
* const { getPrice } = select( 'my-shop' );
|
|
3417 |
* const { currency } = ownProps;
|
|
3418 |
*
|
|
3419 |
* return {
|
|
3420 |
* price: getPrice( 'hammer', currency ),
|
|
3421 |
* };
|
|
3422 |
* } )( PriceDisplay );
|
|
3423 |
*
|
|
3424 |
* // Rendered in the application:
|
|
3425 |
* //
|
|
3426 |
* // <HammerPriceDisplay currency="USD" />
|
|
3427 |
* ```
|
|
3428 |
* In the above example, when `HammerPriceDisplay` is rendered into an
|
|
3429 |
* application, it will pass the price into the underlying `PriceDisplay`
|
|
3430 |
* component and update automatically if the price of a hammer ever changes in
|
|
3431 |
* the store.
|
|
3432 |
*
|
|
3433 |
* @return {WPComponent} Enhanced component with merged state data props.
|
|
3434 |
*/
|
|
3435 |
|
|
3436 |
var with_select_withSelect = function withSelect(mapSelectToProps) {
|
|
3437 |
return Object(external_this_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
|
|
3438 |
return Object(external_this_wp_compose_["pure"])(function (ownProps) {
|
|
3439 |
var mapSelect = function mapSelect(select, registry) {
|
|
3440 |
return mapSelectToProps(select, ownProps, registry);
|
|
3441 |
};
|
|
3442 |
|
|
3443 |
var mergeProps = useSelect(mapSelect);
|
|
3444 |
return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, mergeProps));
|
|
3445 |
});
|
|
3446 |
}, 'withSelect');
|
|
3447 |
};
|
|
3448 |
|
|
3449 |
/* harmony default export */ var with_select = (with_select_withSelect);
|
|
3450 |
|
|
3451 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
|
|
3452 |
|
|
3453 |
|
|
3454 |
/**
|
|
3455 |
* External dependencies
|
|
3456 |
*/
|
|
3457 |
|
|
3458 |
/**
|
|
3459 |
* WordPress dependencies
|
|
3460 |
*/
|
|
3461 |
|
|
3462 |
|
|
3463 |
/**
|
|
3464 |
* Internal dependencies
|
|
3465 |
*/
|
|
3466 |
|
|
3467 |
|
|
3468 |
/**
|
|
3469 |
* Favor useLayoutEffect to ensure the store subscription callback always has
|
|
3470 |
* the dispatchMap from the latest render. If a store update happens between
|
|
3471 |
* render and the effect, this could cause missed/stale updates or
|
|
3472 |
* inconsistent state.
|
|
3473 |
*
|
|
3474 |
* Fallback to useEffect for server rendered components because currently React
|
|
3475 |
* throws a warning when using useLayoutEffect in that environment.
|
|
3476 |
*/
|
|
3477 |
|
|
3478 |
var use_dispatch_with_map_useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_this_wp_element_["useLayoutEffect"] : external_this_wp_element_["useEffect"];
|
|
3479 |
/**
|
|
3480 |
* Custom react hook for returning aggregate dispatch actions using the provided
|
|
3481 |
* dispatchMap.
|
|
3482 |
*
|
|
3483 |
* Currently this is an internal api only and is implemented by `withDispatch`
|
|
3484 |
*
|
|
3485 |
* @param {Function} dispatchMap Receives the `registry.dispatch` function as
|
|
3486 |
* the first argument and the `registry` object
|
|
3487 |
* as the second argument. Should return an
|
|
3488 |
* object mapping props to functions.
|
|
3489 |
* @param {Array} deps An array of dependencies for the hook.
|
|
3490 |
* @return {Object} An object mapping props to functions created by the passed
|
|
3491 |
* in dispatchMap.
|
|
3492 |
*/
|
|
3493 |
|
|
3494 |
var use_dispatch_with_map_useDispatchWithMap = function useDispatchWithMap(dispatchMap, deps) {
|
|
3495 |
var registry = useRegistry();
|
|
3496 |
var currentDispatchMap = Object(external_this_wp_element_["useRef"])(dispatchMap);
|
|
3497 |
use_dispatch_with_map_useIsomorphicLayoutEffect(function () {
|
|
3498 |
currentDispatchMap.current = dispatchMap;
|
|
3499 |
});
|
|
3500 |
return Object(external_this_wp_element_["useMemo"])(function () {
|
|
3501 |
var currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry);
|
|
3502 |
return Object(external_this_lodash_["mapValues"])(currentDispatchProps, function (dispatcher, propName) {
|
|
3503 |
if (typeof dispatcher !== 'function') {
|
|
3504 |
// eslint-disable-next-line no-console
|
|
3505 |
console.warn("Property ".concat(propName, " returned from dispatchMap in useDispatchWithMap must be a function."));
|
|
3506 |
}
|
|
3507 |
|
|
3508 |
return function () {
|
|
3509 |
var _currentDispatchMap$c;
|
|
3510 |
|
|
3511 |
return (_currentDispatchMap$c = currentDispatchMap.current(registry.dispatch, registry))[propName].apply(_currentDispatchMap$c, arguments);
|
|
3512 |
};
|
|
3513 |
});
|
|
3514 |
}, [registry].concat(Object(toConsumableArray["a" /* default */])(deps)));
|
|
3515 |
};
|
|
3516 |
|
|
3517 |
/* harmony default export */ var use_dispatch_with_map = (use_dispatch_with_map_useDispatchWithMap);
|
|
3518 |
|
|
3519 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
|
|
3520 |
|
|
3521 |
|
|
3522 |
|
|
3523 |
/**
|
|
3524 |
* WordPress dependencies
|
|
3525 |
*/
|
|
3526 |
|
|
3527 |
/**
|
|
3528 |
* Internal dependencies
|
|
3529 |
*/
|
|
3530 |
|
|
3531 |
|
|
3532 |
/**
|
|
3533 |
* Higher-order component used to add dispatch props using registered action
|
|
3534 |
* creators.
|
|
3535 |
*
|
|
3536 |
* @param {Function} mapDispatchToProps A function of returning an object of
|
|
3537 |
* prop names where value is a
|
|
3538 |
* dispatch-bound action creator, or a
|
|
3539 |
* function to be called with the
|
|
3540 |
* component's props and returning an
|
|
3541 |
* action creator.
|
|
3542 |
*
|
|
3543 |
* @example
|
|
3544 |
* ```jsx
|
|
3545 |
* function Button( { onClick, children } ) {
|
|
3546 |
* return <button type="button" onClick={ onClick }>{ children }</button>;
|
|
3547 |
* }
|
|
3548 |
*
|
|
3549 |
* const { withDispatch } = wp.data;
|
|
3550 |
*
|
|
3551 |
* const SaleButton = withDispatch( ( dispatch, ownProps ) => {
|
|
3552 |
* const { startSale } = dispatch( 'my-shop' );
|
|
3553 |
* const { discountPercent } = ownProps;
|
|
3554 |
*
|
|
3555 |
* return {
|
|
3556 |
* onClick() {
|
|
3557 |
* startSale( discountPercent );
|
|
3558 |
* },
|
|
3559 |
* };
|
|
3560 |
* } )( Button );
|
|
3561 |
*
|
|
3562 |
* // Rendered in the application:
|
|
3563 |
* //
|
|
3564 |
* // <SaleButton discountPercent="20">Start Sale!</SaleButton>
|
|
3565 |
* ```
|
|
3566 |
*
|
|
3567 |
* @example
|
|
3568 |
* In the majority of cases, it will be sufficient to use only two first params
|
|
3569 |
* passed to `mapDispatchToProps` as illustrated in the previous example.
|
|
3570 |
* However, there might be some very advanced use cases where using the
|
|
3571 |
* `registry` object might be used as a tool to optimize the performance of
|
|
3572 |
* your component. Using `select` function from the registry might be useful
|
|
3573 |
* when you need to fetch some dynamic data from the store at the time when the
|
|
3574 |
* event is fired, but at the same time, you never use it to render your
|
|
3575 |
* component. In such scenario, you can avoid using the `withSelect` higher
|
|
3576 |
* order component to compute such prop, which might lead to unnecessary
|
|
3577 |
* re-renders of your component caused by its frequent value change.
|
|
3578 |
* Keep in mind, that `mapDispatchToProps` must return an object with functions
|
|
3579 |
* only.
|
|
3580 |
*
|
|
3581 |
* ```jsx
|
|
3582 |
* function Button( { onClick, children } ) {
|
|
3583 |
* return <button type="button" onClick={ onClick }>{ children }</button>;
|
|
3584 |
* }
|
|
3585 |
*
|
|
3586 |
* const { withDispatch } = wp.data;
|
|
3587 |
*
|
|
3588 |
* const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
3589 |
* // Stock number changes frequently.
|
|
3590 |
* const { getStockNumber } = select( 'my-shop' );
|
|
3591 |
* const { startSale } = dispatch( 'my-shop' );
|
|
3592 |
* return {
|
|
3593 |
* onClick() {
|
|
3594 |
* const discountPercent = getStockNumber() > 50 ? 10 : 20;
|
|
3595 |
* startSale( discountPercent );
|
|
3596 |
* },
|
|
3597 |
* };
|
|
3598 |
* } )( Button );
|
|
3599 |
*
|
|
3600 |
* // Rendered in the application:
|
|
3601 |
* //
|
|
3602 |
* // <SaleButton>Start Sale!</SaleButton>
|
|
3603 |
* ```
|
|
3604 |
*
|
|
3605 |
* _Note:_ It is important that the `mapDispatchToProps` function always
|
|
3606 |
* returns an object with the same keys. For example, it should not contain
|
|
3607 |
* conditions under which a different value would be returned.
|
|
3608 |
*
|
|
3609 |
* @return {WPComponent} Enhanced component with merged dispatcher props.
|
|
3610 |
*/
|
|
3611 |
|
|
3612 |
var with_dispatch_withDispatch = function withDispatch(mapDispatchToProps) {
|
|
3613 |
return Object(external_this_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
|
|
3614 |
return function (ownProps) {
|
|
3615 |
var mapDispatch = function mapDispatch(dispatch, registry) {
|
|
3616 |
return mapDispatchToProps(dispatch, ownProps, registry);
|
|
3617 |
};
|
|
3618 |
|
|
3619 |
var dispatchProps = use_dispatch_with_map(mapDispatch, []);
|
|
3620 |
return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, dispatchProps));
|
|
3621 |
};
|
|
3622 |
}, 'withDispatch');
|
|
3623 |
};
|
|
3624 |
|
|
3625 |
/* harmony default export */ var with_dispatch = (with_dispatch_withDispatch);
|
|
3626 |
|
|
3627 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
|
|
3628 |
|
|
3629 |
|
|
3630 |
|
|
3631 |
/**
|
|
3632 |
* WordPress dependencies
|
|
3633 |
*/
|
|
3634 |
|
|
3635 |
/**
|
|
3636 |
* Internal dependencies
|
|
3637 |
*/
|
|
3638 |
|
|
3639 |
|
|
3640 |
/**
|
|
3641 |
* Higher-order component which renders the original component with the current
|
|
3642 |
* registry context passed as its `registry` prop.
|
|
3643 |
*
|
|
3644 |
* @param {WPComponent} OriginalComponent Original component.
|
|
3645 |
*
|
|
3646 |
* @return {WPComponent} Enhanced component.
|
|
3647 |
*/
|
|
3648 |
|
|
3649 |
var withRegistry = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) {
|
|
3650 |
return function (props) {
|
|
3651 |
return Object(external_this_wp_element_["createElement"])(RegistryConsumer, null, function (registry) {
|
|
3652 |
return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, {
|
|
3653 |
registry: registry
|
|
3654 |
}));
|
|
3655 |
});
|
|
3656 |
};
|
|
3657 |
}, 'withRegistry');
|
|
3658 |
/* harmony default export */ var with_registry = (withRegistry);
|
|
3659 |
|
|
3660 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js
|
|
3661 |
/**
|
|
3662 |
* Internal dependencies
|
|
3663 |
*/
|
|
3664 |
|
|
3665 |
/**
|
|
3666 |
* A custom react hook returning the current registry dispatch actions creators.
|
|
3667 |
*
|
|
3668 |
* Note: The component using this hook must be within the context of a
|
|
3669 |
* RegistryProvider.
|
|
3670 |
*
|
|
3671 |
* @param {string} [storeName] Optionally provide the name of the store from
|
|
3672 |
* which to retrieve action creators. If not
|
|
3673 |
* provided, the registry.dispatch function is
|
|
3674 |
* returned instead.
|
|
3675 |
*
|
|
3676 |
* @example
|
|
3677 |
* This illustrates a pattern where you may need to retrieve dynamic data from
|
|
3678 |
* the server via the `useSelect` hook to use in combination with the dispatch
|
|
3679 |
* action.
|
|
3680 |
*
|
|
3681 |
* ```jsx
|
|
3682 |
* const { useDispatch, useSelect } = wp.data;
|
|
3683 |
* const { useCallback } = wp.element;
|
|
3684 |
*
|
|
3685 |
* function Button( { onClick, children } ) {
|
|
3686 |
* return <button type="button" onClick={ onClick }>{ children }</button>
|
|
3687 |
* }
|
|
3688 |
*
|
|
3689 |
* const SaleButton = ( { children } ) => {
|
|
3690 |
* const { stockNumber } = useSelect(
|
|
3691 |
* ( select ) => select( 'my-shop' ).getStockNumber(),
|
|
3692 |
* []
|
|
3693 |
* );
|
|
3694 |
* const { startSale } = useDispatch( 'my-shop' );
|
|
3695 |
* const onClick = useCallback( () => {
|
|
3696 |
* const discountPercent = stockNumber > 50 ? 10: 20;
|
|
3697 |
* startSale( discountPercent );
|
|
3698 |
* }, [ stockNumber ] );
|
|
3699 |
* return <Button onClick={ onClick }>{ children }</Button>
|
|
3700 |
* }
|
|
3701 |
*
|
|
3702 |
* // Rendered somewhere in the application:
|
|
3703 |
* //
|
|
3704 |
* // <SaleButton>Start Sale!</SaleButton>
|
|
3705 |
* ```
|
|
3706 |
* @return {Function} A custom react hook.
|
|
3707 |
*/
|
|
3708 |
|
|
3709 |
var use_dispatch_useDispatch = function useDispatch(storeName) {
|
|
3710 |
var _useRegistry = useRegistry(),
|
|
3711 |
dispatch = _useRegistry.dispatch;
|
|
3712 |
|
|
3713 |
return storeName === void 0 ? dispatch : dispatch(storeName);
|
|
3714 |
};
|
|
3715 |
|
|
3716 |
/* harmony default export */ var use_dispatch = (use_dispatch_useDispatch);
|
|
3717 |
|
|
3718 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js
|
|
3719 |
/**
|
|
3720 |
* Internal dependencies
|
|
3721 |
*/
|
|
3722 |
|
|
3723 |
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
|
|
3724 |
|
|
3725 |
/**
|
|
3726 |
* Mark a selector as a registry selector.
|
|
3727 |
*
|
|
3728 |
* @param {Function} registrySelector Function receiving a registry object and returning a state selector.
|
|
3729 |
*
|
|
3730 |
* @return {Function} marked registry selector.
|
|
3731 |
*/
|
|
3732 |
|
|
3733 |
function createRegistrySelector(registrySelector) {
|
|
3734 |
var selector = function selector() {
|
|
3735 |
return registrySelector(selector.registry.select).apply(void 0, arguments);
|
|
3736 |
};
|
|
3737 |
/**
|
|
3738 |
* Flag indicating to selector registration mapping that the selector should
|
|
3739 |
* be mapped as a registry selector.
|
|
3740 |
*
|
|
3741 |
* @type {boolean}
|
|
3742 |
*/
|
|
3743 |
|
|
3744 |
|
|
3745 |
selector.isRegistrySelector = true;
|
|
3746 |
/**
|
|
3747 |
* Registry on which to call `select`, stubbed for non-standard usage to
|
|
3748 |
* use the default registry.
|
|
3749 |
*
|
|
3750 |
* @type {WPDataRegistry}
|
|
3751 |
*/
|
|
3752 |
|
|
3753 |
selector.registry = default_registry;
|
|
3754 |
return selector;
|
|
3755 |
}
|
|
3756 |
/**
|
|
3757 |
* Mark a control as a registry control.
|
|
3758 |
*
|
|
3759 |
* @param {Function} registryControl Function receiving a registry object and returning a control.
|
|
3760 |
*
|
|
3761 |
* @return {Function} marked registry control.
|
|
3762 |
*/
|
|
3763 |
|
|
3764 |
function createRegistryControl(registryControl) {
|
|
3765 |
registryControl.isRegistryControl = true;
|
|
3766 |
return registryControl;
|
|
3767 |
}
|
|
3768 |
|
|
3769 |
// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js
|
|
3770 |
/**
|
|
3771 |
* External dependencies
|
|
3772 |
*/
|
|
3773 |
|
|
3774 |
/**
|
|
3775 |
* Internal dependencies
|
|
3776 |
*/
|
|
3777 |
|
|
3778 |
|
|
3779 |
|
|
3780 |
|
|
3781 |
|
|
3782 |
|
|
3783 |
|
|
3784 |
|
|
3785 |
|
|
3786 |
|
|
3787 |
|
|
3788 |
|
|
3789 |
/**
|
|
3790 |
* Object of available plugins to use with a registry.
|
|
3791 |
*
|
|
3792 |
* @see [use](#use)
|
|
3793 |
*
|
|
3794 |
* @type {Object}
|
|
3795 |
*/
|
|
3796 |
|
|
3797 |
|
|
3798 |
/**
|
|
3799 |
* The combineReducers helper function turns an object whose values are different
|
|
3800 |
* reducing functions into a single reducing function you can pass to registerReducer.
|
|
3801 |
*
|
|
3802 |
* @param {Object} reducers An object whose values correspond to different reducing
|
|
3803 |
* functions that need to be combined into one.
|
|
3804 |
*
|
|
3805 |
* @example
|
|
3806 |
* ```js
|
|
3807 |
* const { combineReducers, registerStore } = wp.data;
|
|
3808 |
*
|
|
3809 |
* const prices = ( state = {}, action ) => {
|
|
3810 |
* return action.type === 'SET_PRICE' ?
|
|
3811 |
* {
|
|
3812 |
* ...state,
|
|
3813 |
* [ action.item ]: action.price,
|
|
3814 |
* } :
|
|
3815 |
* state;
|
|
3816 |
* };
|
|
3817 |
*
|
|
3818 |
* const discountPercent = ( state = 0, action ) => {
|
|
3819 |
* return action.type === 'START_SALE' ?
|
|
3820 |
* action.discountPercent :
|
|
3821 |
* state;
|
|
3822 |
* };
|
|
3823 |
*
|
|
3824 |
* registerStore( 'my-shop', {
|
|
3825 |
* reducer: combineReducers( {
|
|
3826 |
* prices,
|
|
3827 |
* discountPercent,
|
|
3828 |
* } ),
|
|
3829 |
* } );
|
|
3830 |
* ```
|
|
3831 |
*
|
|
3832 |
* @return {Function} A reducer that invokes every reducer inside the reducers
|
|
3833 |
* object, and constructs a state object with the same shape.
|
|
3834 |
*/
|
|
3835 |
|
|
3836 |
|
|
3837 |
/**
|
|
3838 |
* Given the name of a registered store, returns an object of the store's selectors.
|
|
3839 |
* The selector functions are been pre-bound to pass the current state automatically.
|
|
3840 |
* As a consumer, you need only pass arguments of the selector, if applicable.
|
|
3841 |
*
|
|
3842 |
* @param {string} name Store name.
|
|
3843 |
*
|
|
3844 |
* @example
|
|
3845 |
* ```js
|
|
3846 |
* const { select } = wp.data;
|
|
3847 |
*
|
|
3848 |
* select( 'my-shop' ).getPrice( 'hammer' );
|
|
3849 |
* ```
|
|
3850 |
*
|
|
3851 |
* @return {Object} Object containing the store's selectors.
|
|
3852 |
*/
|
|
3853 |
|
|
3854 |
var build_module_select = default_registry.select;
|
|
3855 |
/**
|
|
3856 |
* Given the name of a registered store, returns an object containing the store's
|
|
3857 |
* selectors pre-bound to state so that you only need to supply additional arguments,
|
|
3858 |
* and modified so that they return promises that resolve to their eventual values,
|
|
3859 |
* after any resolvers have ran.
|
|
3860 |
*
|
|
3861 |
* @param {string} name Store name.
|
|
3862 |
*
|
|
3863 |
* @example
|
|
3864 |
* ```js
|
|
3865 |
* const { __experimentalResolveSelect } = wp.data;
|
|
3866 |
*
|
|
3867 |
* __experimentalResolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log)
|
|
3868 |
* ```
|
|
3869 |
*
|
|
3870 |
* @return {Object} Object containing the store's promise-wrapped selectors.
|
|
3871 |
*/
|
|
3872 |
|
|
3873 |
var build_module_experimentalResolveSelect = default_registry.__experimentalResolveSelect;
|
|
3874 |
/**
|
|
3875 |
* Given the name of a registered store, returns an object of the store's action creators.
|
|
3876 |
* Calling an action creator will cause it to be dispatched, updating the state value accordingly.
|
|
3877 |
*
|
|
3878 |
* Note: Action creators returned by the dispatch will return a promise when
|
|
3879 |
* they are called.
|
|
3880 |
*
|
|
3881 |
* @param {string} name Store name.
|
|
3882 |
*
|
|
3883 |
* @example
|
|
3884 |
* ```js
|
|
3885 |
* const { dispatch } = wp.data;
|
|
3886 |
*
|
|
3887 |
* dispatch( 'my-shop' ).setPrice( 'hammer', 9.75 );
|
|
3888 |
* ```
|
|
3889 |
* @return {Object} Object containing the action creators.
|
|
3890 |
*/
|
|
3891 |
|
|
3892 |
var build_module_dispatch = default_registry.dispatch;
|
|
3893 |
/**
|
|
3894 |
* Given a listener function, the function will be called any time the state value
|
|
3895 |
* of one of the registered stores has changed. This function returns a `unsubscribe`
|
|
3896 |
* function used to stop the subscription.
|
|
3897 |
*
|
|
3898 |
* @param {Function} listener Callback function.
|
|
3899 |
*
|
|
3900 |
* @example
|
|
3901 |
* ```js
|
|
3902 |
* const { subscribe } = wp.data;
|
|
3903 |
*
|
|
3904 |
* const unsubscribe = subscribe( () => {
|
|
3905 |
* // You could use this opportunity to test whether the derived result of a
|
|
3906 |
* // selector has subsequently changed as the result of a state update.
|
|
3907 |
* } );
|
|
3908 |
*
|
|
3909 |
* // Later, if necessary...
|
|
3910 |
* unsubscribe();
|
|
3911 |
* ```
|
|
3912 |
*/
|
|
3913 |
|
|
3914 |
var build_module_subscribe = default_registry.subscribe;
|
|
3915 |
/**
|
|
3916 |
* Registers a generic store.
|
|
3917 |
*
|
|
3918 |
* @param {string} key Store registry key.
|
|
3919 |
* @param {Object} config Configuration (getSelectors, getActions, subscribe).
|
|
3920 |
*/
|
|
3921 |
|
|
3922 |
var build_module_registerGenericStore = default_registry.registerGenericStore;
|
|
3923 |
/**
|
|
3924 |
* Registers a standard `@wordpress/data` store.
|
|
3925 |
*
|
|
3926 |
* @param {string} reducerKey Reducer key.
|
|
3927 |
* @param {Object} options Store description (reducer, actions, selectors, resolvers).
|
|
3928 |
*
|
|
3929 |
* @return {Object} Registered store object.
|
|
3930 |
*/
|
|
3931 |
|
|
3932 |
var build_module_registerStore = default_registry.registerStore;
|
|
3933 |
/**
|
|
3934 |
* Extends a registry to inherit functionality provided by a given plugin. A
|
|
3935 |
* plugin is an object with properties aligning to that of a registry, merged
|
|
3936 |
* to extend the default registry behavior.
|
|
3937 |
*
|
|
3938 |
* @param {Object} plugin Plugin object.
|
|
3939 |
*/
|
|
3940 |
|
|
3941 |
var build_module_use = default_registry.use;
|
|
3942 |
|
|
3943 |
|
|
3944 |
/***/ }),
|
|
3945 |
|
|
3946 |
/***/ 5:
|
|
3947 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3948 |
|
|
3949 |
"use strict";
|
|
3950 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
|
|
3951 |
function _defineProperty(obj, key, value) {
|
|
3952 |
if (key in obj) {
|
|
3953 |
Object.defineProperty(obj, key, {
|
|
3954 |
value: value,
|
|
3955 |
enumerable: true,
|
|
3956 |
configurable: true,
|
|
3957 |
writable: true
|
|
3958 |
});
|
|
3959 |
} else {
|
|
3960 |
obj[key] = value;
|
|
3961 |
}
|
|
3962 |
|
|
3963 |
return obj;
|
|
3964 |
}
|
|
3965 |
|
|
3966 |
/***/ }),
|
|
3967 |
|
|
3968 |
/***/ 50:
|
|
3969 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3970 |
|
|
3971 |
"use strict";
|
|
3972 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
|
|
3973 |
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3974 |
try {
|
|
3975 |
var info = gen[key](arg);
|
|
3976 |
var value = info.value;
|
|
3977 |
} catch (error) {
|
|
3978 |
reject(error);
|
|
3979 |
return;
|
|
3980 |
}
|
|
3981 |
|
|
3982 |
if (info.done) {
|
|
3983 |
resolve(value);
|
|
3984 |
} else {
|
|
3985 |
Promise.resolve(value).then(_next, _throw);
|
|
3986 |
}
|
|
3987 |
}
|
|
3988 |
|
|
3989 |
function _asyncToGenerator(fn) {
|
|
3990 |
return function () {
|
|
3991 |
var self = this,
|
|
3992 |
args = arguments;
|
|
3993 |
return new Promise(function (resolve, reject) {
|
|
3994 |
var gen = fn.apply(self, args);
|
|
3995 |
|
|
3996 |
function _next(value) {
|
|
3997 |
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
3998 |
}
|
|
3999 |
|
|
4000 |
function _throw(err) {
|
|
4001 |
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
4002 |
}
|
|
4003 |
|
|
4004 |
_next(undefined);
|
|
4005 |
});
|
|
4006 |
};
|
|
4007 |
}
|
|
4008 |
|
|
4009 |
/***/ }),
|
|
4010 |
|
|
4011 |
/***/ 60:
|
|
4012 |
/***/ (function(module, exports, __webpack_require__) {
|
|
4013 |
|
|
4014 |
/**
|
|
4015 |
* Memize options object.
|
|
4016 |
*
|
|
4017 |
* @typedef MemizeOptions
|
|
4018 |
*
|
|
4019 |
* @property {number} [maxSize] Maximum size of the cache.
|
|
4020 |
*/
|
|
4021 |
|
|
4022 |
/**
|
|
4023 |
* Internal cache entry.
|
|
4024 |
*
|
|
4025 |
* @typedef MemizeCacheNode
|
|
4026 |
*
|
|
4027 |
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
|
|
4028 |
* @property {?MemizeCacheNode|undefined} [next] Next node.
|
|
4029 |
* @property {Array<*>} args Function arguments for cache
|
|
4030 |
* entry.
|
|
4031 |
* @property {*} val Function result.
|
|
4032 |
*/
|
|
4033 |
|
|
4034 |
/**
|
|
4035 |
* Properties of the enhanced function for controlling cache.
|
|
4036 |
*
|
|
4037 |
* @typedef MemizeMemoizedFunction
|
|
4038 |
*
|
|
4039 |
* @property {()=>void} clear Clear the cache.
|
|
4040 |
*/
|
|
4041 |
|
|
4042 |
/**
|
|
4043 |
* Accepts a function to be memoized, and returns a new memoized function, with
|
|
4044 |
* optional options.
|
|
4045 |
*
|
|
4046 |
* @template {Function} F
|
|
4047 |
*
|
|
4048 |
* @param {F} fn Function to memoize.
|
|
4049 |
* @param {MemizeOptions} [options] Options object.
|
|
4050 |
*
|
|
4051 |
* @return {F & MemizeMemoizedFunction} Memoized function.
|
|
4052 |
*/
|
|
4053 |
function memize( fn, options ) {
|
|
4054 |
var size = 0;
|
|
4055 |
|
|
4056 |
/** @type {?MemizeCacheNode|undefined} */
|
|
4057 |
var head;
|
|
4058 |
|
|
4059 |
/** @type {?MemizeCacheNode|undefined} */
|
|
4060 |
var tail;
|
|
4061 |
|
|
4062 |
options = options || {};
|
|
4063 |
|
|
4064 |
function memoized( /* ...args */ ) {
|
|
4065 |
var node = head,
|
|
4066 |
len = arguments.length,
|
|
4067 |
args, i;
|
|
4068 |
|
|
4069 |
searchCache: while ( node ) {
|
|
4070 |
// Perform a shallow equality test to confirm that whether the node
|
|
4071 |
// under test is a candidate for the arguments passed. Two arrays
|
|
4072 |
// are shallowly equal if their length matches and each entry is
|
|
4073 |
// strictly equal between the two sets. Avoid abstracting to a
|
|
4074 |
// function which could incur an arguments leaking deoptimization.
|
|
4075 |
|
|
4076 |
// Check whether node arguments match arguments length
|
|
4077 |
if ( node.args.length !== arguments.length ) {
|
|
4078 |
node = node.next;
|
|
4079 |
continue;
|
|
4080 |
}
|
|
4081 |
|
|
4082 |
// Check whether node arguments match arguments values
|
|
4083 |
for ( i = 0; i < len; i++ ) {
|
|
4084 |
if ( node.args[ i ] !== arguments[ i ] ) {
|
|
4085 |
node = node.next;
|
|
4086 |
continue searchCache;
|
|
4087 |
}
|
|
4088 |
}
|
|
4089 |
|
|
4090 |
// At this point we can assume we've found a match
|
|
4091 |
|
|
4092 |
// Surface matched node to head if not already
|
|
4093 |
if ( node !== head ) {
|
|
4094 |
// As tail, shift to previous. Must only shift if not also
|
|
4095 |
// head, since if both head and tail, there is no previous.
|
|
4096 |
if ( node === tail ) {
|
|
4097 |
tail = node.prev;
|
|
4098 |
}
|
|
4099 |
|
|
4100 |
// Adjust siblings to point to each other. If node was tail,
|
|
4101 |
// this also handles new tail's empty `next` assignment.
|
|
4102 |
/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
|
|
4103 |
if ( node.next ) {
|
|
4104 |
node.next.prev = node.prev;
|
|
4105 |
}
|
|
4106 |
|
|
4107 |
node.next = head;
|
|
4108 |
node.prev = null;
|
|
4109 |
/** @type {MemizeCacheNode} */ ( head ).prev = node;
|
|
4110 |
head = node;
|
|
4111 |
}
|
|
4112 |
|
|
4113 |
// Return immediately
|
|
4114 |
return node.val;
|
|
4115 |
}
|
|
4116 |
|
|
4117 |
// No cached value found. Continue to insertion phase:
|
|
4118 |
|
|
4119 |
// Create a copy of arguments (avoid leaking deoptimization)
|
|
4120 |
args = new Array( len );
|
|
4121 |
for ( i = 0; i < len; i++ ) {
|
|
4122 |
args[ i ] = arguments[ i ];
|
|
4123 |
}
|
|
4124 |
|
|
4125 |
node = {
|
|
4126 |
args: args,
|
|
4127 |
|
|
4128 |
// Generate the result from original function
|
|
4129 |
val: fn.apply( null, args ),
|
|
4130 |
};
|
|
4131 |
|
|
4132 |
// Don't need to check whether node is already head, since it would
|
|
4133 |
// have been returned above already if it was
|
|
4134 |
|
|
4135 |
// Shift existing head down list
|
|
4136 |
if ( head ) {
|
|
4137 |
head.prev = node;
|
|
4138 |
node.next = head;
|
|
4139 |
} else {
|
|
4140 |
// If no head, follows that there's no tail (at initial or reset)
|
|
4141 |
tail = node;
|
|
4142 |
}
|
|
4143 |
|
|
4144 |
// Trim tail if we're reached max size and are pending cache insertion
|
|
4145 |
if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
|
|
4146 |
tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
|
|
4147 |
/** @type {MemizeCacheNode} */ ( tail ).next = null;
|
|
4148 |
} else {
|
|
4149 |
size++;
|
|
4150 |
}
|
|
4151 |
|
|
4152 |
head = node;
|
|
4153 |
|
|
4154 |
return node.val;
|
|
4155 |
}
|
|
4156 |
|
|
4157 |
memoized.clear = function() {
|
|
4158 |
head = null;
|
|
4159 |
tail = null;
|
|
4160 |
size = 0;
|
|
4161 |
};
|
|
4162 |
|
|
4163 |
if ( false ) {}
|
|
4164 |
|
|
4165 |
// Ignore reason: There's not a clear solution to create an intersection of
|
|
4166 |
// the function with additional properties, where the goal is to retain the
|
|
4167 |
// function signature of the incoming argument and add control properties
|
|
4168 |
// on the return value.
|
|
4169 |
|
|
4170 |
// @ts-ignore
|
|
4171 |
return memoized;
|
|
4172 |
}
|
|
4173 |
|
|
4174 |
module.exports = memize;
|
|
4175 |
|
|
4176 |
|
|
4177 |
/***/ }),
|
|
4178 |
|
|
4179 |
/***/ 64:
|
|
4180 |
/***/ (function(module, exports) {
|
|
4181 |
|
|
4182 |
(function() { module.exports = this["wp"]["isShallowEqual"]; }());
|
|
4183 |
|
|
4184 |
/***/ }),
|
|
4185 |
|
|
4186 |
/***/ 8:
|
|
4187 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4188 |
|
|
4189 |
"use strict";
|
|
4190 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
|
|
4191 |
function _extends() {
|
|
4192 |
_extends = Object.assign || function (target) {
|
|
4193 |
for (var i = 1; i < arguments.length; i++) {
|
|
4194 |
var source = arguments[i];
|
|
4195 |
|
|
4196 |
for (var key in source) {
|
|
4197 |
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4198 |
target[key] = source[key];
|
|
4199 |
}
|
|
4200 |
}
|
|
4201 |
}
|
|
4202 |
|
|
4203 |
return target;
|
|
4204 |
};
|
|
4205 |
|
|
4206 |
return _extends.apply(this, arguments);
|
|
4207 |
}
|
|
4208 |
|
|
4209 |
/***/ }),
|
|
4210 |
|
|
4211 |
/***/ 9:
|
|
4212 |
/***/ (function(module, exports) {
|
|
4213 |
|
|
4214 |
(function() { module.exports = this["wp"]["compose"]; }());
|
|
4215 |
|
9
|
4216 |
/***/ })
|
|
4217 |
|
|
4218 |
/******/ }); |