author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1 |
/******/ (() => { // webpackBootstrap |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2 |
/******/ "use strict"; |
19 | 3 |
/******/ var __webpack_modules__ = ({ |
4 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5 |
/***/ 66: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
6 |
/***/ ((module) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
7 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
8 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
9 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
var isMergeableObject = function isMergeableObject(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
11 |
return isNonNullObject(value) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
12 |
&& !isSpecial(value) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
13 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
14 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
15 |
function isNonNullObject(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
16 |
return !!value && typeof value === 'object' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
18 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
19 |
function isSpecial(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
20 |
var stringValue = Object.prototype.toString.call(value); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
21 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
return stringValue === '[object RegExp]' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
23 |
|| stringValue === '[object Date]' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
24 |
|| isReactElement(value) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
26 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
28 |
var canUseSymbol = typeof Symbol === 'function' && Symbol.for; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
29 |
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
30 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
function isReactElement(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
return value.$$typeof === REACT_ELEMENT_TYPE |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
34 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
35 |
function emptyTarget(val) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
36 |
return Array.isArray(val) ? [] : {} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
37 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
38 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
39 |
function cloneUnlessOtherwiseSpecified(value, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
40 |
return (options.clone !== false && options.isMergeableObject(value)) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
41 |
? deepmerge(emptyTarget(value), value, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
: value |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
43 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
44 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
function defaultArrayMerge(target, source, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
return target.concat(source).map(function(element) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
return cloneUnlessOtherwiseSpecified(element, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
48 |
}) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
49 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
51 |
function getMergeFunction(key, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
if (!options.customMerge) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
53 |
return deepmerge |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
55 |
var customMerge = options.customMerge(key); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
56 |
return typeof customMerge === 'function' ? customMerge : deepmerge |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
58 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
function getEnumerableOwnPropertySymbols(target) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
return Object.getOwnPropertySymbols |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
? Object.getOwnPropertySymbols(target).filter(function(symbol) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
return Object.propertyIsEnumerable.call(target, symbol) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
}) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
64 |
: [] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
65 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
function getKeys(target) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
69 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
70 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
71 |
function propertyIsOnObject(object, property) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
72 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
73 |
return property in object |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
74 |
} catch(_) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
75 |
return false |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
76 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
77 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
79 |
// Protects from prototype poisoning and unexpected merging up the prototype chain. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
80 |
function propertyIsUnsafe(target, key) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
81 |
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
82 |
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
83 |
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
84 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
85 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
86 |
function mergeObject(target, source, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
87 |
var destination = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
88 |
if (options.isMergeableObject(target)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
89 |
getKeys(target).forEach(function(key) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
90 |
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
91 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
92 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
93 |
getKeys(source).forEach(function(key) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
94 |
if (propertyIsUnsafe(target, key)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
return |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
97 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
98 |
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
99 |
destination[key] = getMergeFunction(key, options)(target[key], source[key], options); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
100 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
101 |
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
102 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
103 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
104 |
return destination |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
105 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
106 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
107 |
function deepmerge(target, source, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
108 |
options = options || {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
options.arrayMerge = options.arrayMerge || defaultArrayMerge; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
110 |
options.isMergeableObject = options.isMergeableObject || isMergeableObject; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
111 |
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
112 |
// implementations can use it. The caller may not replace it. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
113 |
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
114 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
115 |
var sourceIsArray = Array.isArray(source); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
var targetIsArray = Array.isArray(target); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
117 |
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
119 |
if (!sourceAndTargetTypesMatch) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
120 |
return cloneUnlessOtherwiseSpecified(source, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
} else if (sourceIsArray) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
122 |
return options.arrayMerge(target, source, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
return mergeObject(target, source, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
125 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
126 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
127 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
128 |
deepmerge.all = function deepmergeAll(array, options) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
129 |
if (!Array.isArray(array)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
130 |
throw new Error('first argument should be an array') |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
return array.reduce(function(prev, next) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
134 |
return deepmerge(prev, next, options) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
135 |
}, {}) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
136 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
137 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
138 |
var deepmerge_1 = deepmerge; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
139 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
140 |
module.exports = deepmerge_1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
141 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
142 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
143 |
/***/ }), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
144 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
145 |
/***/ 3249: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
146 |
/***/ ((module) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
147 |
|
9 | 148 |
|
149 |
||
150 |
function _typeof(obj) { |
|
151 |
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
|
152 |
_typeof = function (obj) { |
|
153 |
return typeof obj; |
|
154 |
}; |
|
155 |
} else { |
|
156 |
_typeof = function (obj) { |
|
157 |
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
158 |
}; |
|
159 |
} |
|
160 |
||
161 |
return _typeof(obj); |
|
162 |
} |
|
163 |
||
164 |
function _classCallCheck(instance, Constructor) { |
|
165 |
if (!(instance instanceof Constructor)) { |
|
166 |
throw new TypeError("Cannot call a class as a function"); |
|
167 |
} |
|
168 |
} |
|
169 |
||
170 |
function _defineProperties(target, props) { |
|
171 |
for (var i = 0; i < props.length; i++) { |
|
172 |
var descriptor = props[i]; |
|
173 |
descriptor.enumerable = descriptor.enumerable || false; |
|
174 |
descriptor.configurable = true; |
|
175 |
if ("value" in descriptor) descriptor.writable = true; |
|
176 |
Object.defineProperty(target, descriptor.key, descriptor); |
|
177 |
} |
|
178 |
} |
|
179 |
||
180 |
function _createClass(Constructor, protoProps, staticProps) { |
|
181 |
if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
182 |
if (staticProps) _defineProperties(Constructor, staticProps); |
|
183 |
return Constructor; |
|
184 |
} |
|
185 |
||
186 |
/** |
|
187 |
* Given an instance of EquivalentKeyMap, returns its internal value pair tuple |
|
188 |
* for a key, if one exists. The tuple members consist of the last reference |
|
189 |
* value for the key (used in efficient subsequent lookups) and the value |
|
190 |
* assigned for the key at the leaf node. |
|
191 |
* |
|
192 |
* @param {EquivalentKeyMap} instance EquivalentKeyMap instance. |
|
193 |
* @param {*} key The key for which to return value pair. |
|
194 |
* |
|
195 |
* @return {?Array} Value pair, if exists. |
|
196 |
*/ |
|
197 |
function getValuePair(instance, key) { |
|
198 |
var _map = instance._map, |
|
199 |
_arrayTreeMap = instance._arrayTreeMap, |
|
200 |
_objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the |
|
201 |
// value, which can be used to shortcut immediately to the value. |
|
202 |
||
203 |
if (_map.has(key)) { |
|
204 |
return _map.get(key); |
|
205 |
} // Sort keys to ensure stable retrieval from tree. |
|
206 |
||
207 |
||
208 |
var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
209 |
||
210 |
var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; |
|
211 |
||
212 |
for (var i = 0; i < properties.length; i++) { |
|
213 |
var property = properties[i]; |
|
214 |
map = map.get(property); |
|
215 |
||
216 |
if (map === undefined) { |
|
217 |
return; |
|
218 |
} |
|
219 |
||
220 |
var propertyValue = key[property]; |
|
221 |
map = map.get(propertyValue); |
|
222 |
||
223 |
if (map === undefined) { |
|
224 |
return; |
|
225 |
} |
|
226 |
} |
|
227 |
||
228 |
var valuePair = map.get('_ekm_value'); |
|
229 |
||
230 |
if (!valuePair) { |
|
231 |
return; |
|
232 |
} // If reached, it implies that an object-like key was set with another |
|
233 |
// reference, so delete the reference and replace with the current. |
|
234 |
||
235 |
||
236 |
_map.delete(valuePair[0]); |
|
237 |
||
238 |
valuePair[0] = key; |
|
239 |
map.set('_ekm_value', valuePair); |
|
240 |
||
241 |
_map.set(key, valuePair); |
|
242 |
||
243 |
return valuePair; |
|
244 |
} |
|
245 |
/** |
|
246 |
* Variant of a Map object which enables lookup by equivalent (deeply equal) |
|
247 |
* object and array keys. |
|
248 |
*/ |
|
249 |
||
250 |
||
251 |
var EquivalentKeyMap = |
|
252 |
/*#__PURE__*/ |
|
253 |
function () { |
|
254 |
/** |
|
255 |
* Constructs a new instance of EquivalentKeyMap. |
|
256 |
* |
|
257 |
* @param {Iterable.<*>} iterable Initial pair of key, value for map. |
|
258 |
*/ |
|
259 |
function EquivalentKeyMap(iterable) { |
|
260 |
_classCallCheck(this, EquivalentKeyMap); |
|
261 |
||
262 |
this.clear(); |
|
263 |
||
264 |
if (iterable instanceof EquivalentKeyMap) { |
|
265 |
// Map#forEach is only means of iterating with support for IE11. |
|
266 |
var iterablePairs = []; |
|
267 |
iterable.forEach(function (value, key) { |
|
268 |
iterablePairs.push([key, value]); |
|
269 |
}); |
|
270 |
iterable = iterablePairs; |
|
271 |
} |
|
272 |
||
273 |
if (iterable != null) { |
|
274 |
for (var i = 0; i < iterable.length; i++) { |
|
275 |
this.set(iterable[i][0], iterable[i][1]); |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
/** |
|
280 |
* Accessor property returning the number of elements. |
|
281 |
* |
|
282 |
* @return {number} Number of elements. |
|
283 |
*/ |
|
284 |
||
285 |
||
286 |
_createClass(EquivalentKeyMap, [{ |
|
287 |
key: "set", |
|
288 |
||
289 |
/** |
|
290 |
* Add or update an element with a specified key and value. |
|
291 |
* |
|
292 |
* @param {*} key The key of the element to add. |
|
293 |
* @param {*} value The value of the element to add. |
|
294 |
* |
|
295 |
* @return {EquivalentKeyMap} Map instance. |
|
296 |
*/ |
|
297 |
value: function set(key, value) { |
|
298 |
// Shortcut non-object-like to set on internal Map. |
|
299 |
if (key === null || _typeof(key) !== 'object') { |
|
300 |
this._map.set(key, value); |
|
301 |
||
302 |
return this; |
|
303 |
} // Sort keys to ensure stable assignment into tree. |
|
304 |
||
305 |
||
306 |
var properties = Object.keys(key).sort(); |
|
307 |
var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
308 |
||
309 |
var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; |
|
310 |
||
311 |
for (var i = 0; i < properties.length; i++) { |
|
312 |
var property = properties[i]; |
|
313 |
||
314 |
if (!map.has(property)) { |
|
315 |
map.set(property, new EquivalentKeyMap()); |
|
316 |
} |
|
317 |
||
318 |
map = map.get(property); |
|
319 |
var propertyValue = key[property]; |
|
320 |
||
321 |
if (!map.has(propertyValue)) { |
|
322 |
map.set(propertyValue, new EquivalentKeyMap()); |
|
323 |
} |
|
324 |
||
325 |
map = map.get(propertyValue); |
|
326 |
} // If an _ekm_value exists, there was already an equivalent key. Before |
|
327 |
// overriding, ensure that the old key reference is removed from map to |
|
328 |
// avoid memory leak of accumulating equivalent keys. This is, in a |
|
329 |
// sense, a poor man's WeakMap, while still enabling iterability. |
|
330 |
||
331 |
||
332 |
var previousValuePair = map.get('_ekm_value'); |
|
333 |
||
334 |
if (previousValuePair) { |
|
335 |
this._map.delete(previousValuePair[0]); |
|
336 |
} |
|
337 |
||
338 |
map.set('_ekm_value', valuePair); |
|
339 |
||
340 |
this._map.set(key, valuePair); |
|
341 |
||
342 |
return this; |
|
343 |
} |
|
344 |
/** |
|
345 |
* Returns a specified element. |
|
346 |
* |
|
347 |
* @param {*} key The key of the element to return. |
|
348 |
* |
|
349 |
* @return {?*} The element associated with the specified key or undefined |
|
350 |
* if the key can't be found. |
|
351 |
*/ |
|
352 |
||
353 |
}, { |
|
354 |
key: "get", |
|
355 |
value: function get(key) { |
|
356 |
// Shortcut non-object-like to get from internal Map. |
|
357 |
if (key === null || _typeof(key) !== 'object') { |
|
358 |
return this._map.get(key); |
|
359 |
} |
|
360 |
||
361 |
var valuePair = getValuePair(this, key); |
|
362 |
||
363 |
if (valuePair) { |
|
364 |
return valuePair[1]; |
|
365 |
} |
|
366 |
} |
|
367 |
/** |
|
368 |
* Returns a boolean indicating whether an element with the specified key |
|
369 |
* exists or not. |
|
370 |
* |
|
371 |
* @param {*} key The key of the element to test for presence. |
|
372 |
* |
|
373 |
* @return {boolean} Whether an element with the specified key exists. |
|
374 |
*/ |
|
375 |
||
376 |
}, { |
|
377 |
key: "has", |
|
378 |
value: function has(key) { |
|
379 |
if (key === null || _typeof(key) !== 'object') { |
|
380 |
return this._map.has(key); |
|
381 |
} // Test on the _presence_ of the pair, not its value, as even undefined |
|
382 |
// can be a valid member value for a key. |
|
383 |
||
384 |
||
385 |
return getValuePair(this, key) !== undefined; |
|
386 |
} |
|
387 |
/** |
|
388 |
* Removes the specified element. |
|
389 |
* |
|
390 |
* @param {*} key The key of the element to remove. |
|
391 |
* |
|
392 |
* @return {boolean} Returns true if an element existed and has been |
|
393 |
* removed, or false if the element does not exist. |
|
394 |
*/ |
|
395 |
||
396 |
}, { |
|
397 |
key: "delete", |
|
398 |
value: function _delete(key) { |
|
399 |
if (!this.has(key)) { |
|
400 |
return false; |
|
401 |
} // This naive implementation will leave orphaned child trees. A better |
|
402 |
// implementation should traverse and remove orphans. |
|
403 |
||
404 |
||
405 |
this.set(key, undefined); |
|
406 |
return true; |
|
407 |
} |
|
408 |
/** |
|
409 |
* Executes a provided function once per each key/value pair, in insertion |
|
410 |
* order. |
|
411 |
* |
|
412 |
* @param {Function} callback Function to execute for each element. |
|
413 |
* @param {*} thisArg Value to use as `this` when executing |
|
414 |
* `callback`. |
|
415 |
*/ |
|
416 |
||
417 |
}, { |
|
418 |
key: "forEach", |
|
419 |
value: function forEach(callback) { |
|
420 |
var _this = this; |
|
421 |
||
422 |
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; |
|
423 |
||
424 |
this._map.forEach(function (value, key) { |
|
425 |
// Unwrap value from object-like value pair. |
|
426 |
if (key !== null && _typeof(key) === 'object') { |
|
427 |
value = value[1]; |
|
428 |
} |
|
429 |
||
430 |
callback.call(thisArg, value, key, _this); |
|
431 |
}); |
|
432 |
} |
|
433 |
/** |
|
434 |
* Removes all elements. |
|
435 |
*/ |
|
436 |
||
437 |
}, { |
|
438 |
key: "clear", |
|
439 |
value: function clear() { |
|
440 |
this._map = new Map(); |
|
441 |
this._arrayTreeMap = new Map(); |
|
442 |
this._objectTreeMap = new Map(); |
|
443 |
} |
|
444 |
}, { |
|
445 |
key: "size", |
|
446 |
get: function get() { |
|
447 |
return this._map.size; |
|
448 |
} |
|
449 |
}]); |
|
450 |
||
451 |
return EquivalentKeyMap; |
|
452 |
}(); |
|
453 |
||
454 |
module.exports = EquivalentKeyMap; |
|
455 |
||
456 |
||
19 | 457 |
/***/ }) |
458 |
||
459 |
/******/ }); |
|
460 |
/************************************************************************/ |
|
461 |
/******/ // The module cache |
|
462 |
/******/ var __webpack_module_cache__ = {}; |
|
463 |
/******/ |
|
464 |
/******/ // The require function |
|
465 |
/******/ function __webpack_require__(moduleId) { |
|
466 |
/******/ // Check if module is in cache |
|
467 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
|
468 |
/******/ if (cachedModule !== undefined) { |
|
469 |
/******/ return cachedModule.exports; |
|
470 |
/******/ } |
|
471 |
/******/ // Create a new module (and put it into the cache) |
|
472 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
|
473 |
/******/ // no module.id needed |
|
474 |
/******/ // no module.loaded needed |
|
475 |
/******/ exports: {} |
|
476 |
/******/ }; |
|
477 |
/******/ |
|
478 |
/******/ // Execute the module function |
|
479 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
|
480 |
/******/ |
|
481 |
/******/ // Return the exports of the module |
|
482 |
/******/ return module.exports; |
|
483 |
/******/ } |
|
484 |
/******/ |
|
485 |
/************************************************************************/ |
|
486 |
/******/ /* webpack/runtime/compat get default export */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
/******/ (() => { |
19 | 488 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
/******/ __webpack_require__.n = (module) => { |
19 | 490 |
/******/ var getter = module && module.__esModule ? |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
491 |
/******/ () => (module['default']) : |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
492 |
/******/ () => (module); |
19 | 493 |
/******/ __webpack_require__.d(getter, { a: getter }); |
494 |
/******/ return getter; |
|
495 |
/******/ }; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
496 |
/******/ })(); |
19 | 497 |
/******/ |
498 |
/******/ /* webpack/runtime/define property getters */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
499 |
/******/ (() => { |
19 | 500 |
/******/ // define getter functions for harmony exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
501 |
/******/ __webpack_require__.d = (exports, definition) => { |
19 | 502 |
/******/ for(var key in definition) { |
503 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
504 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
505 |
/******/ } |
|
506 |
/******/ } |
|
507 |
/******/ }; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
/******/ })(); |
19 | 509 |
/******/ |
510 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
511 |
/******/ (() => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
/******/ })(); |
19 | 514 |
/******/ |
515 |
/******/ /* webpack/runtime/make namespace object */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
516 |
/******/ (() => { |
19 | 517 |
/******/ // define __esModule on exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
/******/ __webpack_require__.r = (exports) => { |
19 | 519 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
520 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
521 |
/******/ } |
|
522 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
523 |
/******/ }; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
524 |
/******/ })(); |
19 | 525 |
/******/ |
526 |
/************************************************************************/ |
|
527 |
var __webpack_exports__ = {}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
528 |
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
(() => { |
16 | 530 |
// ESM COMPAT FLAG |
531 |
__webpack_require__.r(__webpack_exports__); |
|
532 |
||
533 |
// EXPORTS |
|
19 | 534 |
__webpack_require__.d(__webpack_exports__, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
535 |
AsyncModeProvider: () => (/* reexport */ async_mode_provider_context), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
536 |
RegistryConsumer: () => (/* reexport */ RegistryConsumer), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
537 |
RegistryProvider: () => (/* reexport */ context), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
538 |
combineReducers: () => (/* binding */ build_module_combineReducers), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
539 |
controls: () => (/* reexport */ controls), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
540 |
createReduxStore: () => (/* reexport */ createReduxStore), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
createRegistry: () => (/* reexport */ createRegistry), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
createRegistryControl: () => (/* reexport */ createRegistryControl), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
createRegistrySelector: () => (/* reexport */ createRegistrySelector), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
544 |
createSelector: () => (/* reexport */ rememo), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
545 |
dispatch: () => (/* reexport */ dispatch_dispatch), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
546 |
plugins: () => (/* reexport */ plugins_namespaceObject), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
547 |
register: () => (/* binding */ register), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
548 |
registerGenericStore: () => (/* binding */ registerGenericStore), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
549 |
registerStore: () => (/* binding */ registerStore), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
550 |
resolveSelect: () => (/* binding */ build_module_resolveSelect), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
551 |
select: () => (/* reexport */ select_select), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
552 |
subscribe: () => (/* binding */ subscribe), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
553 |
suspendSelect: () => (/* binding */ suspendSelect), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
554 |
use: () => (/* binding */ use), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
555 |
useDispatch: () => (/* reexport */ use_dispatch), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
556 |
useRegistry: () => (/* reexport */ useRegistry), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
557 |
useSelect: () => (/* reexport */ useSelect), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
558 |
useSuspenseSelect: () => (/* reexport */ useSuspenseSelect), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
559 |
withDispatch: () => (/* reexport */ with_dispatch), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
560 |
withRegistry: () => (/* reexport */ with_registry), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
561 |
withSelect: () => (/* reexport */ with_select) |
19 | 562 |
}); |
18 | 563 |
|
564 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
|
16 | 565 |
var selectors_namespaceObject = {}; |
566 |
__webpack_require__.r(selectors_namespaceObject); |
|
19 | 567 |
__webpack_require__.d(selectors_namespaceObject, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
568 |
countSelectorsByStatus: () => (countSelectorsByStatus), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
569 |
getCachedResolvers: () => (getCachedResolvers), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
570 |
getIsResolving: () => (getIsResolving), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
571 |
getResolutionError: () => (getResolutionError), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
572 |
getResolutionState: () => (getResolutionState), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
573 |
hasFinishedResolution: () => (hasFinishedResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
574 |
hasResolutionFailed: () => (hasResolutionFailed), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
575 |
hasResolvingSelectors: () => (hasResolvingSelectors), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
576 |
hasStartedResolution: () => (hasStartedResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
577 |
isResolving: () => (isResolving) |
19 | 578 |
}); |
16 | 579 |
|
18 | 580 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
16 | 581 |
var actions_namespaceObject = {}; |
582 |
__webpack_require__.r(actions_namespaceObject); |
|
19 | 583 |
__webpack_require__.d(actions_namespaceObject, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
584 |
failResolution: () => (failResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
585 |
failResolutions: () => (failResolutions), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
586 |
finishResolution: () => (finishResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
587 |
finishResolutions: () => (finishResolutions), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
588 |
invalidateResolution: () => (invalidateResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
589 |
invalidateResolutionForStore: () => (invalidateResolutionForStore), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
590 |
invalidateResolutionForStoreSelector: () => (invalidateResolutionForStoreSelector), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
591 |
startResolution: () => (startResolution), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
592 |
startResolutions: () => (startResolutions) |
19 | 593 |
}); |
16 | 594 |
|
595 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js |
|
596 |
var plugins_namespaceObject = {}; |
|
597 |
__webpack_require__.r(plugins_namespaceObject); |
|
19 | 598 |
__webpack_require__.d(plugins_namespaceObject, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
599 |
persistence: () => (persistence) |
19 | 600 |
}); |
16 | 601 |
|
19 | 602 |
;// CONCATENATED MODULE: external ["wp","deprecated"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
603 |
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
19 | 604 |
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
605 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
function _typeof(o) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
607 |
"@babel/helpers - typeof"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
608 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
609 |
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
610 |
return typeof o; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
611 |
} : function (o) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
612 |
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
613 |
}, _typeof(o); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
614 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
615 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
616 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
617 |
function _toPrimitive(input, hint) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
618 |
if (_typeof(input) !== "object" || input === null) return input; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
619 |
var prim = input[Symbol.toPrimitive]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
620 |
if (prim !== undefined) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
621 |
var res = prim.call(input, hint || "default"); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
622 |
if (_typeof(res) !== "object") return res; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
623 |
throw new TypeError("@@toPrimitive must return a primitive value."); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
624 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
625 |
return (hint === "string" ? String : Number)(input); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
626 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
627 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
628 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
629 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
630 |
function _toPropertyKey(arg) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
631 |
var key = _toPrimitive(arg, "string"); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
632 |
return _typeof(key) === "symbol" ? key : String(key); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
633 |
} |
19 | 634 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
635 |
|
18 | 636 |
function _defineProperty(obj, key, value) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
637 |
key = _toPropertyKey(key); |
18 | 638 |
if (key in obj) { |
639 |
Object.defineProperty(obj, key, { |
|
640 |
value: value, |
|
641 |
enumerable: true, |
|
642 |
configurable: true, |
|
643 |
writable: true |
|
644 |
}); |
|
645 |
} else { |
|
646 |
obj[key] = value; |
|
647 |
} |
|
648 |
return obj; |
|
649 |
} |
|
19 | 650 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js |
18 | 651 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
652 |
function ownKeys(e, r) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
653 |
var t = Object.keys(e); |
18 | 654 |
if (Object.getOwnPropertySymbols) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
655 |
var o = Object.getOwnPropertySymbols(e); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
656 |
r && (o = o.filter(function (r) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
657 |
return Object.getOwnPropertyDescriptor(e, r).enumerable; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
658 |
})), t.push.apply(t, o); |
18 | 659 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
660 |
return t; |
18 | 661 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
662 |
function _objectSpread2(e) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
663 |
for (var r = 1; r < arguments.length; r++) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
664 |
var t = null != arguments[r] ? arguments[r] : {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
665 |
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
666 |
_defineProperty(e, r, t[r]); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
667 |
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
668 |
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); |
19 | 669 |
}); |
18 | 670 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
671 |
return e; |
18 | 672 |
} |
19 | 673 |
;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js |
16 | 674 |
|
675 |
||
676 |
/** |
|
18 | 677 |
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js |
678 |
* |
|
679 |
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes |
|
680 |
* during build. |
|
681 |
* @param {number} code |
|
682 |
*/ |
|
683 |
function formatProdErrorMessage(code) { |
|
684 |
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. '; |
|
685 |
} |
|
686 |
||
687 |
// Inlined version of the `symbol-observable` polyfill |
|
688 |
var $$observable = (function () { |
|
689 |
return typeof Symbol === 'function' && Symbol.observable || '@@observable'; |
|
690 |
})(); |
|
691 |
||
692 |
/** |
|
16 | 693 |
* These are private action types reserved by Redux. |
694 |
* For any unknown actions, you must return the current state. |
|
695 |
* If the current state is undefined, you must return the initial state. |
|
696 |
* Do not reference these action types directly in your code. |
|
697 |
*/ |
|
698 |
var randomString = function randomString() { |
|
699 |
return Math.random().toString(36).substring(7).split('').join('.'); |
|
700 |
}; |
|
701 |
||
702 |
var ActionTypes = { |
|
703 |
INIT: "@@redux/INIT" + randomString(), |
|
704 |
REPLACE: "@@redux/REPLACE" + randomString(), |
|
705 |
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() { |
|
706 |
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString(); |
|
707 |
} |
|
708 |
}; |
|
709 |
||
710 |
/** |
|
711 |
* @param {any} obj The object to inspect. |
|
712 |
* @returns {boolean} True if the argument appears to be a plain object. |
|
713 |
*/ |
|
714 |
function isPlainObject(obj) { |
|
715 |
if (typeof obj !== 'object' || obj === null) return false; |
|
716 |
var proto = obj; |
|
717 |
||
718 |
while (Object.getPrototypeOf(proto) !== null) { |
|
719 |
proto = Object.getPrototypeOf(proto); |
|
720 |
} |
|
721 |
||
722 |
return Object.getPrototypeOf(obj) === proto; |
|
723 |
} |
|
724 |
||
18 | 725 |
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of |
726 |
function miniKindOf(val) { |
|
727 |
if (val === void 0) return 'undefined'; |
|
728 |
if (val === null) return 'null'; |
|
729 |
var type = typeof val; |
|
730 |
||
731 |
switch (type) { |
|
732 |
case 'boolean': |
|
733 |
case 'string': |
|
734 |
case 'number': |
|
735 |
case 'symbol': |
|
736 |
case 'function': |
|
737 |
{ |
|
738 |
return type; |
|
739 |
} |
|
740 |
} |
|
741 |
||
742 |
if (Array.isArray(val)) return 'array'; |
|
743 |
if (isDate(val)) return 'date'; |
|
744 |
if (isError(val)) return 'error'; |
|
745 |
var constructorName = ctorName(val); |
|
746 |
||
747 |
switch (constructorName) { |
|
748 |
case 'Symbol': |
|
749 |
case 'Promise': |
|
750 |
case 'WeakMap': |
|
751 |
case 'WeakSet': |
|
752 |
case 'Map': |
|
753 |
case 'Set': |
|
754 |
return constructorName; |
|
755 |
} // other |
|
756 |
||
757 |
||
758 |
return type.slice(8, -1).toLowerCase().replace(/\s/g, ''); |
|
759 |
} |
|
760 |
||
761 |
function ctorName(val) { |
|
762 |
return typeof val.constructor === 'function' ? val.constructor.name : null; |
|
763 |
} |
|
764 |
||
765 |
function isError(val) { |
|
766 |
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number'; |
|
767 |
} |
|
768 |
||
769 |
function isDate(val) { |
|
770 |
if (val instanceof Date) return true; |
|
771 |
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function'; |
|
772 |
} |
|
773 |
||
774 |
function kindOf(val) { |
|
775 |
var typeOfVal = typeof val; |
|
776 |
||
777 |
if (false) {} |
|
778 |
||
779 |
return typeOfVal; |
|
780 |
} |
|
781 |
||
16 | 782 |
/** |
19 | 783 |
* @deprecated |
784 |
* |
|
785 |
* **We recommend using the `configureStore` method |
|
786 |
* of the `@reduxjs/toolkit` package**, which replaces `createStore`. |
|
787 |
* |
|
788 |
* Redux Toolkit is our recommended approach for writing Redux logic today, |
|
789 |
* including store setup, reducers, data fetching, and more. |
|
790 |
* |
|
791 |
* **For more details, please read this Redux docs page:** |
|
792 |
* **https://redux.js.org/introduction/why-rtk-is-redux-today** |
|
793 |
* |
|
794 |
* `configureStore` from Redux Toolkit is an improved version of `createStore` that |
|
795 |
* simplifies setup and helps avoid common bugs. |
|
796 |
* |
|
797 |
* You should not be using the `redux` core package by itself today, except for learning purposes. |
|
798 |
* The `createStore` method from the core `redux` package will not be removed, but we encourage |
|
799 |
* all users to migrate to using Redux Toolkit for all Redux code. |
|
800 |
* |
|
801 |
* If you want to use `createStore` without this visual deprecation warning, use |
|
802 |
* the `legacy_createStore` import instead: |
|
803 |
* |
|
804 |
* `import { legacy_createStore as createStore} from 'redux'` |
|
805 |
* |
|
16 | 806 |
*/ |
807 |
||
19 | 808 |
function createStore(reducer, preloadedState, enhancer) { |
16 | 809 |
var _ref2; |
810 |
||
811 |
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { |
|
19 | 812 |
throw new Error( true ? formatProdErrorMessage(0) : 0); |
16 | 813 |
} |
814 |
||
815 |
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { |
|
816 |
enhancer = preloadedState; |
|
817 |
preloadedState = undefined; |
|
818 |
} |
|
819 |
||
820 |
if (typeof enhancer !== 'undefined') { |
|
821 |
if (typeof enhancer !== 'function') { |
|
19 | 822 |
throw new Error( true ? formatProdErrorMessage(1) : 0); |
16 | 823 |
} |
824 |
||
19 | 825 |
return enhancer(createStore)(reducer, preloadedState); |
16 | 826 |
} |
827 |
||
828 |
if (typeof reducer !== 'function') { |
|
19 | 829 |
throw new Error( true ? formatProdErrorMessage(2) : 0); |
16 | 830 |
} |
831 |
||
832 |
var currentReducer = reducer; |
|
833 |
var currentState = preloadedState; |
|
834 |
var currentListeners = []; |
|
835 |
var nextListeners = currentListeners; |
|
836 |
var isDispatching = false; |
|
837 |
/** |
|
838 |
* This makes a shallow copy of currentListeners so we can use |
|
839 |
* nextListeners as a temporary list while dispatching. |
|
840 |
* |
|
841 |
* This prevents any bugs around consumers calling |
|
842 |
* subscribe/unsubscribe in the middle of a dispatch. |
|
843 |
*/ |
|
844 |
||
845 |
function ensureCanMutateNextListeners() { |
|
846 |
if (nextListeners === currentListeners) { |
|
847 |
nextListeners = currentListeners.slice(); |
|
848 |
} |
|
849 |
} |
|
850 |
/** |
|
851 |
* Reads the state tree managed by the store. |
|
852 |
* |
|
853 |
* @returns {any} The current state tree of your application. |
|
854 |
*/ |
|
855 |
||
856 |
||
857 |
function getState() { |
|
858 |
if (isDispatching) { |
|
19 | 859 |
throw new Error( true ? formatProdErrorMessage(3) : 0); |
16 | 860 |
} |
861 |
||
862 |
return currentState; |
|
863 |
} |
|
864 |
/** |
|
865 |
* Adds a change listener. It will be called any time an action is dispatched, |
|
866 |
* and some part of the state tree may potentially have changed. You may then |
|
867 |
* call `getState()` to read the current state tree inside the callback. |
|
868 |
* |
|
869 |
* You may call `dispatch()` from a change listener, with the following |
|
870 |
* caveats: |
|
871 |
* |
|
872 |
* 1. The subscriptions are snapshotted just before every `dispatch()` call. |
|
873 |
* If you subscribe or unsubscribe while the listeners are being invoked, this |
|
874 |
* will not have any effect on the `dispatch()` that is currently in progress. |
|
875 |
* However, the next `dispatch()` call, whether nested or not, will use a more |
|
876 |
* recent snapshot of the subscription list. |
|
877 |
* |
|
878 |
* 2. The listener should not expect to see all state changes, as the state |
|
879 |
* might have been updated multiple times during a nested `dispatch()` before |
|
880 |
* the listener is called. It is, however, guaranteed that all subscribers |
|
881 |
* registered before the `dispatch()` started will be called with the latest |
|
882 |
* state by the time it exits. |
|
883 |
* |
|
884 |
* @param {Function} listener A callback to be invoked on every dispatch. |
|
885 |
* @returns {Function} A function to remove this change listener. |
|
886 |
*/ |
|
887 |
||
888 |
||
889 |
function subscribe(listener) { |
|
890 |
if (typeof listener !== 'function') { |
|
19 | 891 |
throw new Error( true ? formatProdErrorMessage(4) : 0); |
16 | 892 |
} |
893 |
||
894 |
if (isDispatching) { |
|
19 | 895 |
throw new Error( true ? formatProdErrorMessage(5) : 0); |
16 | 896 |
} |
897 |
||
898 |
var isSubscribed = true; |
|
899 |
ensureCanMutateNextListeners(); |
|
900 |
nextListeners.push(listener); |
|
901 |
return function unsubscribe() { |
|
902 |
if (!isSubscribed) { |
|
903 |
return; |
|
904 |
} |
|
905 |
||
906 |
if (isDispatching) { |
|
19 | 907 |
throw new Error( true ? formatProdErrorMessage(6) : 0); |
16 | 908 |
} |
909 |
||
910 |
isSubscribed = false; |
|
911 |
ensureCanMutateNextListeners(); |
|
912 |
var index = nextListeners.indexOf(listener); |
|
913 |
nextListeners.splice(index, 1); |
|
914 |
currentListeners = null; |
|
915 |
}; |
|
916 |
} |
|
917 |
/** |
|
918 |
* Dispatches an action. It is the only way to trigger a state change. |
|
919 |
* |
|
920 |
* The `reducer` function, used to create the store, will be called with the |
|
921 |
* current state tree and the given `action`. Its return value will |
|
922 |
* be considered the **next** state of the tree, and the change listeners |
|
923 |
* will be notified. |
|
924 |
* |
|
925 |
* The base implementation only supports plain object actions. If you want to |
|
926 |
* dispatch a Promise, an Observable, a thunk, or something else, you need to |
|
927 |
* wrap your store creating function into the corresponding middleware. For |
|
928 |
* example, see the documentation for the `redux-thunk` package. Even the |
|
929 |
* middleware will eventually dispatch plain object actions using this method. |
|
930 |
* |
|
931 |
* @param {Object} action A plain object representing “what changed”. It is |
|
932 |
* a good idea to keep actions serializable so you can record and replay user |
|
933 |
* sessions, or use the time travelling `redux-devtools`. An action must have |
|
934 |
* a `type` property which may not be `undefined`. It is a good idea to use |
|
935 |
* string constants for action types. |
|
936 |
* |
|
937 |
* @returns {Object} For convenience, the same action object you dispatched. |
|
938 |
* |
|
939 |
* Note that, if you use a custom middleware, it may wrap `dispatch()` to |
|
940 |
* return something else (for example, a Promise you can await). |
|
941 |
*/ |
|
942 |
||
943 |
||
944 |
function dispatch(action) { |
|
945 |
if (!isPlainObject(action)) { |
|
19 | 946 |
throw new Error( true ? formatProdErrorMessage(7) : 0); |
16 | 947 |
} |
948 |
||
949 |
if (typeof action.type === 'undefined') { |
|
19 | 950 |
throw new Error( true ? formatProdErrorMessage(8) : 0); |
16 | 951 |
} |
952 |
||
953 |
if (isDispatching) { |
|
19 | 954 |
throw new Error( true ? formatProdErrorMessage(9) : 0); |
16 | 955 |
} |
956 |
||
957 |
try { |
|
958 |
isDispatching = true; |
|
959 |
currentState = currentReducer(currentState, action); |
|
960 |
} finally { |
|
961 |
isDispatching = false; |
|
962 |
} |
|
963 |
||
964 |
var listeners = currentListeners = nextListeners; |
|
965 |
||
966 |
for (var i = 0; i < listeners.length; i++) { |
|
967 |
var listener = listeners[i]; |
|
968 |
listener(); |
|
969 |
} |
|
970 |
||
971 |
return action; |
|
972 |
} |
|
973 |
/** |
|
974 |
* Replaces the reducer currently used by the store to calculate the state. |
|
975 |
* |
|
976 |
* You might need this if your app implements code splitting and you want to |
|
977 |
* load some of the reducers dynamically. You might also need this if you |
|
978 |
* implement a hot reloading mechanism for Redux. |
|
979 |
* |
|
980 |
* @param {Function} nextReducer The reducer for the store to use instead. |
|
981 |
* @returns {void} |
|
982 |
*/ |
|
983 |
||
984 |
||
985 |
function replaceReducer(nextReducer) { |
|
986 |
if (typeof nextReducer !== 'function') { |
|
19 | 987 |
throw new Error( true ? formatProdErrorMessage(10) : 0); |
16 | 988 |
} |
989 |
||
990 |
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. |
|
991 |
// Any reducers that existed in both the new and old rootReducer |
|
992 |
// will receive the previous state. This effectively populates |
|
993 |
// the new state tree with any relevant data from the old one. |
|
994 |
||
995 |
dispatch({ |
|
996 |
type: ActionTypes.REPLACE |
|
997 |
}); |
|
998 |
} |
|
999 |
/** |
|
1000 |
* Interoperability point for observable/reactive libraries. |
|
1001 |
* @returns {observable} A minimal observable of state changes. |
|
1002 |
* For more information, see the observable proposal: |
|
1003 |
* https://github.com/tc39/proposal-observable |
|
1004 |
*/ |
|
1005 |
||
1006 |
||
1007 |
function observable() { |
|
1008 |
var _ref; |
|
1009 |
||
1010 |
var outerSubscribe = subscribe; |
|
1011 |
return _ref = { |
|
1012 |
/** |
|
1013 |
* The minimal observable subscription method. |
|
1014 |
* @param {Object} observer Any object that can be used as an observer. |
|
1015 |
* The observer object should have a `next` method. |
|
1016 |
* @returns {subscription} An object with an `unsubscribe` method that can |
|
1017 |
* be used to unsubscribe the observable from the store, and prevent further |
|
1018 |
* emission of values from the observable. |
|
1019 |
*/ |
|
1020 |
subscribe: function subscribe(observer) { |
|
1021 |
if (typeof observer !== 'object' || observer === null) { |
|
19 | 1022 |
throw new Error( true ? formatProdErrorMessage(11) : 0); |
16 | 1023 |
} |
1024 |
||
1025 |
function observeState() { |
|
1026 |
if (observer.next) { |
|
1027 |
observer.next(getState()); |
|
1028 |
} |
|
1029 |
} |
|
1030 |
||
1031 |
observeState(); |
|
1032 |
var unsubscribe = outerSubscribe(observeState); |
|
1033 |
return { |
|
1034 |
unsubscribe: unsubscribe |
|
1035 |
}; |
|
1036 |
} |
|
18 | 1037 |
}, _ref[$$observable] = function () { |
16 | 1038 |
return this; |
1039 |
}, _ref; |
|
1040 |
} // When a store is created, an "INIT" action is dispatched so that every |
|
1041 |
// reducer returns their initial state. This effectively populates |
|
1042 |
// the initial state tree. |
|
1043 |
||
1044 |
||
1045 |
dispatch({ |
|
1046 |
type: ActionTypes.INIT |
|
1047 |
}); |
|
1048 |
return _ref2 = { |
|
1049 |
dispatch: dispatch, |
|
1050 |
subscribe: subscribe, |
|
1051 |
getState: getState, |
|
1052 |
replaceReducer: replaceReducer |
|
18 | 1053 |
}, _ref2[$$observable] = observable, _ref2; |
16 | 1054 |
} |
19 | 1055 |
/** |
1056 |
* Creates a Redux store that holds the state tree. |
|
1057 |
* |
|
1058 |
* **We recommend using `configureStore` from the |
|
1059 |
* `@reduxjs/toolkit` package**, which replaces `createStore`: |
|
1060 |
* **https://redux.js.org/introduction/why-rtk-is-redux-today** |
|
1061 |
* |
|
1062 |
* The only way to change the data in the store is to call `dispatch()` on it. |
|
1063 |
* |
|
1064 |
* There should only be a single store in your app. To specify how different |
|
1065 |
* parts of the state tree respond to actions, you may combine several reducers |
|
1066 |
* into a single reducer function by using `combineReducers`. |
|
1067 |
* |
|
1068 |
* @param {Function} reducer A function that returns the next state tree, given |
|
1069 |
* the current state tree and the action to handle. |
|
1070 |
* |
|
1071 |
* @param {any} [preloadedState] The initial state. You may optionally specify it |
|
1072 |
* to hydrate the state from the server in universal apps, or to restore a |
|
1073 |
* previously serialized user session. |
|
1074 |
* If you use `combineReducers` to produce the root reducer function, this must be |
|
1075 |
* an object with the same shape as `combineReducers` keys. |
|
1076 |
* |
|
1077 |
* @param {Function} [enhancer] The store enhancer. You may optionally specify it |
|
1078 |
* to enhance the store with third-party capabilities such as middleware, |
|
1079 |
* time travel, persistence, etc. The only store enhancer that ships with Redux |
|
1080 |
* is `applyMiddleware()`. |
|
1081 |
* |
|
1082 |
* @returns {Store} A Redux store that lets you read the state, dispatch actions |
|
1083 |
* and subscribe to changes. |
|
1084 |
*/ |
|
1085 |
||
1086 |
var legacy_createStore = (/* unused pure expression or super */ null && (createStore)); |
|
16 | 1087 |
|
1088 |
/** |
|
1089 |
* Prints a warning in the console if it exists. |
|
1090 |
* |
|
1091 |
* @param {String} message The warning message. |
|
1092 |
* @returns {void} |
|
1093 |
*/ |
|
1094 |
function warning(message) { |
|
1095 |
/* eslint-disable no-console */ |
|
1096 |
if (typeof console !== 'undefined' && typeof console.error === 'function') { |
|
1097 |
console.error(message); |
|
1098 |
} |
|
1099 |
/* eslint-enable no-console */ |
|
1100 |
||
1101 |
||
1102 |
try { |
|
1103 |
// This error was thrown as a convenience so that if you enable |
|
1104 |
// "break on all exceptions" in your console, |
|
1105 |
// it would pause the execution at this line. |
|
1106 |
throw new Error(message); |
|
1107 |
} catch (e) {} // eslint-disable-line no-empty |
|
1108 |
||
1109 |
} |
|
1110 |
||
1111 |
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { |
|
1112 |
var reducerKeys = Object.keys(reducers); |
|
1113 |
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; |
|
1114 |
||
1115 |
if (reducerKeys.length === 0) { |
|
1116 |
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; |
|
1117 |
} |
|
1118 |
||
1119 |
if (!isPlainObject(inputState)) { |
|
18 | 1120 |
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); |
16 | 1121 |
} |
1122 |
||
1123 |
var unexpectedKeys = Object.keys(inputState).filter(function (key) { |
|
1124 |
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; |
|
1125 |
}); |
|
1126 |
unexpectedKeys.forEach(function (key) { |
|
1127 |
unexpectedKeyCache[key] = true; |
|
1128 |
}); |
|
1129 |
if (action && action.type === ActionTypes.REPLACE) return; |
|
1130 |
||
1131 |
if (unexpectedKeys.length > 0) { |
|
1132 |
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."); |
|
1133 |
} |
|
1134 |
} |
|
1135 |
||
1136 |
function assertReducerShape(reducers) { |
|
1137 |
Object.keys(reducers).forEach(function (key) { |
|
1138 |
var reducer = reducers[key]; |
|
1139 |
var initialState = reducer(undefined, { |
|
1140 |
type: ActionTypes.INIT |
|
1141 |
}); |
|
1142 |
||
1143 |
if (typeof initialState === 'undefined') { |
|
19 | 1144 |
throw new Error( true ? formatProdErrorMessage(12) : 0); |
16 | 1145 |
} |
1146 |
||
1147 |
if (typeof reducer(undefined, { |
|
1148 |
type: ActionTypes.PROBE_UNKNOWN_ACTION() |
|
1149 |
}) === 'undefined') { |
|
19 | 1150 |
throw new Error( true ? formatProdErrorMessage(13) : 0); |
16 | 1151 |
} |
1152 |
}); |
|
1153 |
} |
|
1154 |
/** |
|
1155 |
* Turns an object whose values are different reducer functions, into a single |
|
1156 |
* reducer function. It will call every child reducer, and gather their results |
|
1157 |
* into a single state object, whose keys correspond to the keys of the passed |
|
1158 |
* reducer functions. |
|
1159 |
* |
|
1160 |
* @param {Object} reducers An object whose values correspond to different |
|
1161 |
* reducer functions that need to be combined into one. One handy way to obtain |
|
1162 |
* it is to use ES6 `import * as reducers` syntax. The reducers may never return |
|
1163 |
* undefined for any action. Instead, they should return their initial state |
|
1164 |
* if the state passed to them was undefined, and the current state for any |
|
1165 |
* unrecognized action. |
|
1166 |
* |
|
1167 |
* @returns {Function} A reducer function that invokes every reducer inside the |
|
1168 |
* passed object, and builds a state object with the same shape. |
|
1169 |
*/ |
|
1170 |
||
1171 |
||
1172 |
function combineReducers(reducers) { |
|
1173 |
var reducerKeys = Object.keys(reducers); |
|
1174 |
var finalReducers = {}; |
|
1175 |
||
1176 |
for (var i = 0; i < reducerKeys.length; i++) { |
|
1177 |
var key = reducerKeys[i]; |
|
1178 |
||
1179 |
if (false) {} |
|
1180 |
||
1181 |
if (typeof reducers[key] === 'function') { |
|
1182 |
finalReducers[key] = reducers[key]; |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same |
|
1187 |
// keys multiple times. |
|
1188 |
||
1189 |
var unexpectedKeyCache; |
|
1190 |
||
1191 |
if (false) {} |
|
1192 |
||
1193 |
var shapeAssertionError; |
|
1194 |
||
1195 |
try { |
|
1196 |
assertReducerShape(finalReducers); |
|
1197 |
} catch (e) { |
|
1198 |
shapeAssertionError = e; |
|
1199 |
} |
|
1200 |
||
1201 |
return function combination(state, action) { |
|
1202 |
if (state === void 0) { |
|
1203 |
state = {}; |
|
1204 |
} |
|
1205 |
||
1206 |
if (shapeAssertionError) { |
|
1207 |
throw shapeAssertionError; |
|
1208 |
} |
|
1209 |
||
1210 |
if (false) { var warningMessage; } |
|
1211 |
||
1212 |
var hasChanged = false; |
|
1213 |
var nextState = {}; |
|
1214 |
||
1215 |
for (var _i = 0; _i < finalReducerKeys.length; _i++) { |
|
1216 |
var _key = finalReducerKeys[_i]; |
|
1217 |
var reducer = finalReducers[_key]; |
|
1218 |
var previousStateForKey = state[_key]; |
|
1219 |
var nextStateForKey = reducer(previousStateForKey, action); |
|
1220 |
||
1221 |
if (typeof nextStateForKey === 'undefined') { |
|
18 | 1222 |
var actionType = action && action.type; |
19 | 1223 |
throw new Error( true ? formatProdErrorMessage(14) : 0); |
16 | 1224 |
} |
1225 |
||
1226 |
nextState[_key] = nextStateForKey; |
|
1227 |
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; |
|
1228 |
} |
|
1229 |
||
1230 |
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length; |
|
1231 |
return hasChanged ? nextState : state; |
|
1232 |
}; |
|
1233 |
} |
|
1234 |
||
1235 |
function bindActionCreator(actionCreator, dispatch) { |
|
1236 |
return function () { |
|
1237 |
return dispatch(actionCreator.apply(this, arguments)); |
|
1238 |
}; |
|
1239 |
} |
|
1240 |
/** |
|
1241 |
* Turns an object whose values are action creators, into an object with the |
|
1242 |
* same keys, but with every function wrapped into a `dispatch` call so they |
|
1243 |
* may be invoked directly. This is just a convenience method, as you can call |
|
1244 |
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine. |
|
1245 |
* |
|
1246 |
* For convenience, you can also pass an action creator as the first argument, |
|
1247 |
* and get a dispatch wrapped function in return. |
|
1248 |
* |
|
1249 |
* @param {Function|Object} actionCreators An object whose values are action |
|
1250 |
* creator functions. One handy way to obtain it is to use ES6 `import * as` |
|
1251 |
* syntax. You may also pass a single function. |
|
1252 |
* |
|
1253 |
* @param {Function} dispatch The `dispatch` function available on your Redux |
|
1254 |
* store. |
|
1255 |
* |
|
1256 |
* @returns {Function|Object} The object mimicking the original object, but with |
|
1257 |
* every action creator wrapped into the `dispatch` call. If you passed a |
|
1258 |
* function as `actionCreators`, the return value will also be a single |
|
1259 |
* function. |
|
1260 |
*/ |
|
1261 |
||
1262 |
||
1263 |
function bindActionCreators(actionCreators, dispatch) { |
|
1264 |
if (typeof actionCreators === 'function') { |
|
1265 |
return bindActionCreator(actionCreators, dispatch); |
|
1266 |
} |
|
1267 |
||
1268 |
if (typeof actionCreators !== 'object' || actionCreators === null) { |
|
19 | 1269 |
throw new Error( true ? formatProdErrorMessage(16) : 0); |
16 | 1270 |
} |
1271 |
||
1272 |
var boundActionCreators = {}; |
|
1273 |
||
1274 |
for (var key in actionCreators) { |
|
1275 |
var actionCreator = actionCreators[key]; |
|
1276 |
||
1277 |
if (typeof actionCreator === 'function') { |
|
1278 |
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); |
|
1279 |
} |
|
1280 |
} |
|
1281 |
||
1282 |
return boundActionCreators; |
|
1283 |
} |
|
1284 |
||
1285 |
/** |
|
1286 |
* Composes single-argument functions from right to left. The rightmost |
|
1287 |
* function can take multiple arguments as it provides the signature for |
|
1288 |
* the resulting composite function. |
|
1289 |
* |
|
1290 |
* @param {...Function} funcs The functions to compose. |
|
1291 |
* @returns {Function} A function obtained by composing the argument functions |
|
1292 |
* from right to left. For example, compose(f, g, h) is identical to doing |
|
1293 |
* (...args) => f(g(h(...args))). |
|
1294 |
*/ |
|
1295 |
function compose() { |
|
1296 |
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) { |
|
1297 |
funcs[_key] = arguments[_key]; |
|
1298 |
} |
|
1299 |
||
1300 |
if (funcs.length === 0) { |
|
1301 |
return function (arg) { |
|
1302 |
return arg; |
|
1303 |
}; |
|
1304 |
} |
|
1305 |
||
1306 |
if (funcs.length === 1) { |
|
1307 |
return funcs[0]; |
|
1308 |
} |
|
1309 |
||
1310 |
return funcs.reduce(function (a, b) { |
|
1311 |
return function () { |
|
1312 |
return a(b.apply(void 0, arguments)); |
|
1313 |
}; |
|
1314 |
}); |
|
1315 |
} |
|
1316 |
||
1317 |
/** |
|
1318 |
* Creates a store enhancer that applies middleware to the dispatch method |
|
1319 |
* of the Redux store. This is handy for a variety of tasks, such as expressing |
|
1320 |
* asynchronous actions in a concise manner, or logging every action payload. |
|
1321 |
* |
|
1322 |
* See `redux-thunk` package as an example of the Redux middleware. |
|
1323 |
* |
|
1324 |
* Because middleware is potentially asynchronous, this should be the first |
|
1325 |
* store enhancer in the composition chain. |
|
1326 |
* |
|
1327 |
* Note that each middleware will be given the `dispatch` and `getState` functions |
|
1328 |
* as named arguments. |
|
1329 |
* |
|
1330 |
* @param {...Function} middlewares The middleware chain to be applied. |
|
1331 |
* @returns {Function} A store enhancer applying the middleware. |
|
1332 |
*/ |
|
1333 |
||
1334 |
function applyMiddleware() { |
|
1335 |
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) { |
|
1336 |
middlewares[_key] = arguments[_key]; |
|
1337 |
} |
|
1338 |
||
1339 |
return function (createStore) { |
|
1340 |
return function () { |
|
1341 |
var store = createStore.apply(void 0, arguments); |
|
1342 |
||
1343 |
var _dispatch = function dispatch() { |
|
19 | 1344 |
throw new Error( true ? formatProdErrorMessage(15) : 0); |
16 | 1345 |
}; |
1346 |
||
1347 |
var middlewareAPI = { |
|
1348 |
getState: store.getState, |
|
1349 |
dispatch: function dispatch() { |
|
1350 |
return _dispatch.apply(void 0, arguments); |
|
1351 |
} |
|
1352 |
}; |
|
1353 |
var chain = middlewares.map(function (middleware) { |
|
1354 |
return middleware(middlewareAPI); |
|
1355 |
}); |
|
1356 |
_dispatch = compose.apply(void 0, chain)(store.dispatch); |
|
18 | 1357 |
return _objectSpread2(_objectSpread2({}, store), {}, { |
16 | 1358 |
dispatch: _dispatch |
1359 |
}); |
|
1360 |
}; |
|
1361 |
}; |
|
1362 |
} |
|
1363 |
||
1364 |
||
1365 |
||
18 | 1366 |
// EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1367 |
var equivalent_key_map = __webpack_require__(3249); |
18 | 1368 |
var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); |
19 | 1369 |
;// CONCATENATED MODULE: external ["wp","reduxRoutine"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1370 |
const external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"]; |
19 | 1371 |
var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1372 |
;// CONCATENATED MODULE: external ["wp","compose"] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1373 |
const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1374 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/combine-reducers.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1375 |
function combine_reducers_combineReducers(reducers) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1376 |
const keys = Object.keys(reducers); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1377 |
return function combinedReducer(state = {}, action) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1378 |
const nextState = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1379 |
let hasChanged = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1380 |
for (const key of keys) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1381 |
const reducer = reducers[key]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1382 |
const prevStateForKey = state[key]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1383 |
const nextStateForKey = reducer(prevStateForKey, action); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1384 |
nextState[key] = nextStateForKey; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1385 |
hasChanged = hasChanged || nextStateForKey !== prevStateForKey; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1386 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1387 |
return hasChanged ? nextState : state; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1388 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1389 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1390 |
|
19 | 1391 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js |
18 | 1392 |
/** |
1393 |
* Creates a selector function that takes additional curried argument with the |
|
1394 |
* registry `select` function. While a regular selector has signature |
|
1395 |
* ```js |
|
1396 |
* ( state, ...selectorArgs ) => ( result ) |
|
1397 |
* ``` |
|
1398 |
* that allows to select data from the store's `state`, a registry selector |
|
1399 |
* has signature: |
|
1400 |
* ```js |
|
1401 |
* ( select ) => ( state, ...selectorArgs ) => ( result ) |
|
1402 |
* ``` |
|
1403 |
* that supports also selecting from other registered stores. |
|
1404 |
* |
|
1405 |
* @example |
|
1406 |
* ```js |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1407 |
* import { store as coreStore } from '@wordpress/core-data'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1408 |
* import { store as editorStore } from '@wordpress/editor'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1409 |
* |
18 | 1410 |
* const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1411 |
* return select( editorStore ).getCurrentPostId(); |
18 | 1412 |
* } ); |
1413 |
* |
|
1414 |
* const getPostEdits = createRegistrySelector( ( select ) => ( state ) => { |
|
1415 |
* // calling another registry selector just like any other function |
|
1416 |
* const postType = getCurrentPostType( state ); |
|
1417 |
* const postId = getCurrentPostId( state ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1418 |
* return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId ); |
18 | 1419 |
* } ); |
1420 |
* ``` |
|
1421 |
* |
|
1422 |
* Note how the `getCurrentPostId` selector can be called just like any other function, |
|
1423 |
* (it works even inside a regular non-registry selector) and we don't need to pass the |
|
1424 |
* registry as argument. The registry binding happens automatically when registering the selector |
|
1425 |
* with a store. |
|
1426 |
* |
|
1427 |
* @param {Function} registrySelector Function receiving a registry `select` |
|
19 | 1428 |
* function and returning a state selector. |
18 | 1429 |
* |
1430 |
* @return {Function} Registry selector that can be registered with a store. |
|
1431 |
*/ |
|
1432 |
function createRegistrySelector(registrySelector) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1433 |
const selectorsByRegistry = new WeakMap(); |
19 | 1434 |
// Create a selector function that is bound to the registry referenced by `selector.registry` |
18 | 1435 |
// and that has the same API as a regular selector. Binding it in such a way makes it |
1436 |
// possible to call the selector directly from another selector. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1437 |
const wrappedSelector = (...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1438 |
let selector = selectorsByRegistry.get(wrappedSelector.registry); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1439 |
// We want to make sure the cache persists even when new registry |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1440 |
// instances are created. For example patterns create their own editors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1441 |
// with their own core/block-editor stores, so we should keep track of |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1442 |
// the cache for each registry instance. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1443 |
if (!selector) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1444 |
selector = registrySelector(wrappedSelector.registry.select); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1445 |
selectorsByRegistry.set(wrappedSelector.registry, selector); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1446 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1447 |
return selector(...args); |
19 | 1448 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1449 |
|
18 | 1450 |
/** |
1451 |
* Flag indicating that the selector is a registry selector that needs the correct registry |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1452 |
* reference to be assigned to `selector.registry` to make it work correctly. |
18 | 1453 |
* be mapped as a registry selector. |
1454 |
* |
|
1455 |
* @type {boolean} |
|
1456 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1457 |
wrappedSelector.isRegistrySelector = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1458 |
return wrappedSelector; |
18 | 1459 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1460 |
|
18 | 1461 |
/** |
1462 |
* Creates a control function that takes additional curried argument with the `registry` object. |
|
1463 |
* While a regular control has signature |
|
1464 |
* ```js |
|
1465 |
* ( action ) => ( iteratorOrPromise ) |
|
1466 |
* ``` |
|
1467 |
* where the control works with the `action` that it's bound to, a registry control has signature: |
|
1468 |
* ```js |
|
1469 |
* ( registry ) => ( action ) => ( iteratorOrPromise ) |
|
1470 |
* ``` |
|
1471 |
* A registry control is typically used to select data or dispatch an action to a registered |
|
1472 |
* store. |
|
1473 |
* |
|
1474 |
* When registering a control created with `createRegistryControl` with a store, the store |
|
1475 |
* knows which calling convention to use when executing the control. |
|
1476 |
* |
|
1477 |
* @param {Function} registryControl Function receiving a registry object and returning a control. |
|
1478 |
* |
|
1479 |
* @return {Function} Registry control that can be registered with a store. |
|
1480 |
*/ |
|
1481 |
function createRegistryControl(registryControl) { |
|
1482 |
registryControl.isRegistryControl = true; |
|
1483 |
return registryControl; |
|
1484 |
} |
|
1485 |
||
19 | 1486 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js |
1487 |
/** |
|
18 | 1488 |
* Internal dependencies |
1489 |
*/ |
|
1490 |
||
19 | 1491 |
|
1492 |
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
|
1493 |
||
18 | 1494 |
const SELECT = '@@data/SELECT'; |
1495 |
const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; |
|
1496 |
const DISPATCH = '@@data/DISPATCH'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1497 |
function isObject(object) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1498 |
return object !== null && typeof object === 'object'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1499 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1500 |
|
18 | 1501 |
/** |
1502 |
* Dispatches a control action for triggering a synchronous registry select. |
|
1503 |
* |
|
1504 |
* Note: This control synchronously returns the current selector value, triggering the |
|
1505 |
* resolution, but not waiting for it. |
|
1506 |
* |
|
19 | 1507 |
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1508 |
* @param {string} selectorName The name of the selector. |
|
1509 |
* @param {Array} args Arguments for the selector. |
|
18 | 1510 |
* |
1511 |
* @example |
|
1512 |
* ```js |
|
1513 |
* import { controls } from '@wordpress/data'; |
|
1514 |
* |
|
1515 |
* // Action generator using `select`. |
|
1516 |
* export function* myAction() { |
|
1517 |
* const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' ); |
|
1518 |
* // Do stuff with the result from the `select`. |
|
1519 |
* } |
|
1520 |
* ``` |
|
1521 |
* |
|
1522 |
* @return {Object} The control descriptor. |
|
1523 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1524 |
function controls_select(storeNameOrDescriptor, selectorName, ...args) { |
18 | 1525 |
return { |
1526 |
type: SELECT, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1527 |
storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
18 | 1528 |
selectorName, |
1529 |
args |
|
1530 |
}; |
|
1531 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1532 |
|
18 | 1533 |
/** |
1534 |
* Dispatches a control action for triggering and resolving a registry select. |
|
1535 |
* |
|
1536 |
* Note: when this control action is handled, it automatically considers |
|
1537 |
* selectors that may have a resolver. In such case, it will return a `Promise` that resolves |
|
1538 |
* after the selector finishes resolving, with the final result value. |
|
1539 |
* |
|
19 | 1540 |
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1541 |
* @param {string} selectorName The name of the selector |
|
1542 |
* @param {Array} args Arguments for the selector. |
|
18 | 1543 |
* |
1544 |
* @example |
|
1545 |
* ```js |
|
1546 |
* import { controls } from '@wordpress/data'; |
|
1547 |
* |
|
1548 |
* // Action generator using resolveSelect |
|
1549 |
* export function* myAction() { |
|
1550 |
* const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' ); |
|
1551 |
* // do stuff with the result from the select. |
|
1552 |
* } |
|
1553 |
* ``` |
|
1554 |
* |
|
1555 |
* @return {Object} The control descriptor. |
|
1556 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1557 |
function resolveSelect(storeNameOrDescriptor, selectorName, ...args) { |
18 | 1558 |
return { |
1559 |
type: RESOLVE_SELECT, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1560 |
storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
18 | 1561 |
selectorName, |
1562 |
args |
|
1563 |
}; |
|
1564 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1565 |
|
18 | 1566 |
/** |
1567 |
* Dispatches a control action for triggering a registry dispatch. |
|
1568 |
* |
|
19 | 1569 |
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
1570 |
* @param {string} actionName The name of the action to dispatch |
|
1571 |
* @param {Array} args Arguments for the dispatch action. |
|
18 | 1572 |
* |
1573 |
* @example |
|
1574 |
* ```js |
|
1575 |
* import { controls } from '@wordpress/data-controls'; |
|
1576 |
* |
|
1577 |
* // Action generator using dispatch |
|
1578 |
* export function* myAction() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1579 |
* yield controls.dispatch( 'core/editor', 'togglePublishSidebar' ); |
18 | 1580 |
* // do some other things. |
1581 |
* } |
|
1582 |
* ``` |
|
1583 |
* |
|
1584 |
* @return {Object} The control descriptor. |
|
1585 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1586 |
function dispatch(storeNameOrDescriptor, actionName, ...args) { |
18 | 1587 |
return { |
1588 |
type: DISPATCH, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1589 |
storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, |
18 | 1590 |
actionName, |
1591 |
args |
|
1592 |
}; |
|
1593 |
} |
|
19 | 1594 |
const controls = { |
18 | 1595 |
select: controls_select, |
19 | 1596 |
resolveSelect, |
1597 |
dispatch |
|
18 | 1598 |
}; |
1599 |
const builtinControls = { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1600 |
[SELECT]: createRegistryControl(registry => ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1601 |
storeKey, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1602 |
selectorName, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1603 |
args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1604 |
}) => registry.select(storeKey)[selectorName](...args)), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1605 |
[RESOLVE_SELECT]: createRegistryControl(registry => ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1606 |
storeKey, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1607 |
selectorName, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1608 |
args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1609 |
}) => { |
18 | 1610 |
const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; |
1611 |
return registry[method](storeKey)[selectorName](...args); |
|
1612 |
}), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1613 |
[DISPATCH]: createRegistryControl(registry => ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1614 |
storeKey, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1615 |
actionName, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1616 |
args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1617 |
}) => registry.dispatch(storeKey)[actionName](...args)) |
18 | 1618 |
}; |
16 | 1619 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1620 |
;// CONCATENATED MODULE: external ["wp","privateApis"] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1621 |
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1622 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/lock-unlock.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1623 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1624 |
* WordPress dependencies |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1625 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1626 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1627 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1628 |
lock, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1629 |
unlock |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1630 |
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/data'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1631 |
|
19 | 1632 |
;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs |
1633 |
function isPromise(obj) { |
|
1634 |
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; |
|
1635 |
} |
|
1636 |
||
1637 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js |
|
16 | 1638 |
/** |
1639 |
* External dependencies |
|
1640 |
*/ |
|
1641 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1642 |
|
16 | 1643 |
/** |
1644 |
* Simplest possible promise redux middleware. |
|
1645 |
* |
|
19 | 1646 |
* @type {import('redux').Middleware} |
16 | 1647 |
*/ |
18 | 1648 |
const promiseMiddleware = () => next => action => { |
19 | 1649 |
if (isPromise(action)) { |
18 | 1650 |
return action.then(resolvedAction => { |
1651 |
if (resolvedAction) { |
|
1652 |
return next(resolvedAction); |
|
16 | 1653 |
} |
18 | 1654 |
}); |
1655 |
} |
|
1656 |
return next(action); |
|
16 | 1657 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1658 |
/* harmony default export */ const promise_middleware = (promiseMiddleware); |
19 | 1659 |
|
1660 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js |
|
16 | 1661 |
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ |
1662 |
||
1663 |
/** |
|
1664 |
* Creates a middleware handling resolvers cache invalidation. |
|
1665 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1666 |
* @param {WPDataRegistry} registry Registry for which to create the middleware. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1667 |
* @param {string} storeName Name of the store for which to create the middleware. |
16 | 1668 |
* |
1669 |
* @return {Function} Middleware function. |
|
1670 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1671 |
const createResolversCacheMiddleware = (registry, storeName) => () => next => action => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1672 |
const resolvers = registry.select(storeName).getCachedResolvers(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1673 |
const resolverEntries = Object.entries(resolvers); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1674 |
resolverEntries.forEach(([selectorName, resolversByArgs]) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1675 |
const resolver = registry.stores[storeName]?.resolvers?.[selectorName]; |
18 | 1676 |
if (!resolver || !resolver.shouldInvalidate) { |
1677 |
return; |
|
1678 |
} |
|
1679 |
resolversByArgs.forEach((value, args) => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1680 |
// Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1681 |
// to `undefined` and `map.forEach` then iterates also over these orphaned entries. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1682 |
if (value === undefined) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1683 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1684 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1685 |
|
18 | 1686 |
// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. |
19 | 1687 |
// If the value is "finished" or "error" it means this resolver has finished its resolution which means we need |
1688 |
// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1689 |
if (value.status !== 'finished' && value.status !== 'error') { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1690 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1691 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1692 |
if (!resolver.shouldInvalidate(action, ...args)) { |
18 | 1693 |
return; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1694 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1695 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1696 |
// Trigger cache invalidation |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1697 |
registry.dispatch(storeName).invalidateResolution(selectorName, args); |
18 | 1698 |
}); |
1699 |
}); |
|
1700 |
return next(action); |
|
1701 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1702 |
/* harmony default export */ const resolvers_cache_middleware = (createResolversCacheMiddleware); |
18 | 1703 |
|
19 | 1704 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js |
18 | 1705 |
function createThunkMiddleware(args) { |
1706 |
return () => next => action => { |
|
1707 |
if (typeof action === 'function') { |
|
1708 |
return action(args); |
|
1709 |
} |
|
1710 |
return next(action); |
|
16 | 1711 |
}; |
18 | 1712 |
} |
1713 |
||
19 | 1714 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js |
1715 |
/** |
|
1716 |
* External dependencies |
|
1717 |
*/ |
|
1718 |
||
16 | 1719 |
/** |
1720 |
* Higher-order reducer creator which creates a combined reducer object, keyed |
|
1721 |
* by a property on the action object. |
|
1722 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1723 |
* @param actionProperty Action property by which to key object. |
19 | 1724 |
* @return Higher-order reducer. |
16 | 1725 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1726 |
const onSubKey = actionProperty => reducer => (state = {}, action) => { |
18 | 1727 |
// Retrieve subkey from action. Do not track if undefined; useful for cases |
1728 |
// where reducer is scoped by action shape. |
|
1729 |
const key = action[actionProperty]; |
|
1730 |
if (key === undefined) { |
|
1731 |
return state; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1732 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1733 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1734 |
// Avoid updating state if unchanged. Note that this also accounts for a |
18 | 1735 |
// reducer which returns undefined on a key which is not yet tracked. |
1736 |
const nextKeyState = reducer(state[key], action); |
|
1737 |
if (nextKeyState === state[key]) { |
|
1738 |
return state; |
|
1739 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1740 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1741 |
...state, |
18 | 1742 |
[key]: nextKeyState |
16 | 1743 |
}; |
1744 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1745 |
|
19 | 1746 |
/** |
1747 |
* Normalize selector argument array by defaulting `undefined` value to an empty array |
|
1748 |
* and removing trailing `undefined` values. |
|
1749 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1750 |
* @param args Selector argument array |
19 | 1751 |
* @return Normalized state key array |
1752 |
*/ |
|
1753 |
function selectorArgsToStateKey(args) { |
|
1754 |
if (args === undefined || args === null) { |
|
1755 |
return []; |
|
1756 |
} |
|
1757 |
const len = args.length; |
|
1758 |
let idx = len; |
|
1759 |
while (idx > 0 && args[idx - 1] === undefined) { |
|
1760 |
idx--; |
|
1761 |
} |
|
1762 |
return idx === len ? args : args.slice(0, idx); |
|
1763 |
} |
|
1764 |
||
1765 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js |
|
16 | 1766 |
/** |
1767 |
* External dependencies |
|
1768 |
*/ |
|
1769 |
||
1770 |
/** |
|
1771 |
* Internal dependencies |
|
1772 |
*/ |
|
1773 |
||
1774 |
/** |
|
1775 |
* Reducer function returning next state for selector resolution of |
|
1776 |
* subkeys, object form: |
|
1777 |
* |
|
1778 |
* selectorName -> EquivalentKeyMap<Array,boolean> |
|
1779 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1780 |
const subKeysIsResolved = onSubKey('selectorName')((state = new (equivalent_key_map_default())(), action) => { |
16 | 1781 |
switch (action.type) { |
1782 |
case 'START_RESOLUTION': |
|
19 | 1783 |
{ |
1784 |
const nextState = new (equivalent_key_map_default())(state); |
|
1785 |
nextState.set(selectorArgsToStateKey(action.args), { |
|
1786 |
status: 'resolving' |
|
1787 |
}); |
|
1788 |
return nextState; |
|
1789 |
} |
|
16 | 1790 |
case 'FINISH_RESOLUTION': |
1791 |
{ |
|
19 | 1792 |
const nextState = new (equivalent_key_map_default())(state); |
1793 |
nextState.set(selectorArgsToStateKey(action.args), { |
|
1794 |
status: 'finished' |
|
1795 |
}); |
|
1796 |
return nextState; |
|
1797 |
} |
|
1798 |
case 'FAIL_RESOLUTION': |
|
1799 |
{ |
|
1800 |
const nextState = new (equivalent_key_map_default())(state); |
|
1801 |
nextState.set(selectorArgsToStateKey(action.args), { |
|
1802 |
status: 'error', |
|
1803 |
error: action.error |
|
1804 |
}); |
|
16 | 1805 |
return nextState; |
1806 |
} |
|
18 | 1807 |
case 'START_RESOLUTIONS': |
19 | 1808 |
{ |
1809 |
const nextState = new (equivalent_key_map_default())(state); |
|
1810 |
for (const resolutionArgs of action.args) { |
|
1811 |
nextState.set(selectorArgsToStateKey(resolutionArgs), { |
|
1812 |
status: 'resolving' |
|
1813 |
}); |
|
1814 |
} |
|
1815 |
return nextState; |
|
1816 |
} |
|
18 | 1817 |
case 'FINISH_RESOLUTIONS': |
1818 |
{ |
|
19 | 1819 |
const nextState = new (equivalent_key_map_default())(state); |
18 | 1820 |
for (const resolutionArgs of action.args) { |
19 | 1821 |
nextState.set(selectorArgsToStateKey(resolutionArgs), { |
1822 |
status: 'finished' |
|
1823 |
}); |
|
18 | 1824 |
} |
1825 |
return nextState; |
|
1826 |
} |
|
19 | 1827 |
case 'FAIL_RESOLUTIONS': |
1828 |
{ |
|
1829 |
const nextState = new (equivalent_key_map_default())(state); |
|
1830 |
action.args.forEach((resolutionArgs, idx) => { |
|
1831 |
const resolutionState = { |
|
1832 |
status: 'error', |
|
1833 |
error: undefined |
|
1834 |
}; |
|
1835 |
const error = action.errors[idx]; |
|
1836 |
if (error) { |
|
1837 |
resolutionState.error = error; |
|
1838 |
} |
|
1839 |
nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState); |
|
1840 |
}); |
|
1841 |
return nextState; |
|
1842 |
} |
|
16 | 1843 |
case 'INVALIDATE_RESOLUTION': |
1844 |
{ |
|
19 | 1845 |
const nextState = new (equivalent_key_map_default())(state); |
1846 |
nextState.delete(selectorArgsToStateKey(action.args)); |
|
18 | 1847 |
return nextState; |
16 | 1848 |
} |
1849 |
} |
|
1850 |
return state; |
|
1851 |
}); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1852 |
|
16 | 1853 |
/** |
1854 |
* Reducer function returning next state for selector resolution, object form: |
|
1855 |
* |
|
1856 |
* selectorName -> EquivalentKeyMap<Array, boolean> |
|
1857 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1858 |
* @param state Current state. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1859 |
* @param action Dispatched action. |
19 | 1860 |
* |
1861 |
* @return Next state. |
|
16 | 1862 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1863 |
const isResolved = (state = {}, action) => { |
16 | 1864 |
switch (action.type) { |
1865 |
case 'INVALIDATE_RESOLUTION_FOR_STORE': |
|
1866 |
return {}; |
|
1867 |
case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1868 |
{ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1869 |
if (action.selectorName in state) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1870 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1871 |
[action.selectorName]: removedSelector, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1872 |
...restState |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1873 |
} = state; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1874 |
return restState; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1875 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1876 |
return state; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1877 |
} |
16 | 1878 |
case 'START_RESOLUTION': |
1879 |
case 'FINISH_RESOLUTION': |
|
19 | 1880 |
case 'FAIL_RESOLUTION': |
18 | 1881 |
case 'START_RESOLUTIONS': |
1882 |
case 'FINISH_RESOLUTIONS': |
|
19 | 1883 |
case 'FAIL_RESOLUTIONS': |
16 | 1884 |
case 'INVALIDATE_RESOLUTION': |
1885 |
return subKeysIsResolved(state, action); |
|
1886 |
} |
|
1887 |
return state; |
|
1888 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1889 |
/* harmony default export */ const metadata_reducer = (isResolved); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1890 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1891 |
;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1892 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1893 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1894 |
/** @typedef {(...args: any[]) => *[]} GetDependants */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1895 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1896 |
/** @typedef {() => void} Clear */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1897 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1898 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1899 |
* @typedef {{ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1900 |
* getDependants: GetDependants, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1901 |
* clear: Clear |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1902 |
* }} EnhancedSelector |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1903 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1904 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1905 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1906 |
* Internal cache entry. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1907 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1908 |
* @typedef CacheNode |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1909 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1910 |
* @property {?CacheNode|undefined} [prev] Previous node. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1911 |
* @property {?CacheNode|undefined} [next] Next node. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1912 |
* @property {*[]} args Function arguments for cache entry. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1913 |
* @property {*} val Function result. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1914 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1915 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1916 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1917 |
* @typedef Cache |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1918 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1919 |
* @property {Clear} clear Function to clear cache. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1920 |
* @property {boolean} [isUniqueByDependants] Whether dependants are valid in |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1921 |
* considering cache uniqueness. A cache is unique if dependents are all arrays |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1922 |
* or objects. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1923 |
* @property {CacheNode?} [head] Cache head. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1924 |
* @property {*[]} [lastDependants] Dependants from previous invocation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1925 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1926 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1927 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1928 |
* Arbitrary value used as key for referencing cache object in WeakMap tree. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1929 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1930 |
* @type {{}} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1931 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1932 |
var LEAF_KEY = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1933 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1934 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1935 |
* Returns the first argument as the sole entry in an array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1936 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1937 |
* @template T |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1938 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1939 |
* @param {T} value Value to return. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1940 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1941 |
* @return {[T]} Value returned as entry in array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1942 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1943 |
function arrayOf(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1944 |
return [value]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1945 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1946 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1947 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1948 |
* Returns true if the value passed is object-like, or false otherwise. A value |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1949 |
* is object-like if it can support property assignment, e.g. object or array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1950 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1951 |
* @param {*} value Value to test. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1952 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1953 |
* @return {boolean} Whether value is object-like. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1954 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1955 |
function isObjectLike(value) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1956 |
return !!value && 'object' === typeof value; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1957 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1958 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1959 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1960 |
* Creates and returns a new cache object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1961 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1962 |
* @return {Cache} Cache object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1963 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1964 |
function createCache() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1965 |
/** @type {Cache} */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1966 |
var cache = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1967 |
clear: function () { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1968 |
cache.head = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1969 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1970 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1971 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1972 |
return cache; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1973 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1974 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1975 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1976 |
* Returns true if entries within the two arrays are strictly equal by |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1977 |
* reference from a starting index. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1978 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1979 |
* @param {*[]} a First array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1980 |
* @param {*[]} b Second array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1981 |
* @param {number} fromIndex Index from which to start comparison. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1982 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1983 |
* @return {boolean} Whether arrays are shallowly equal. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1984 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1985 |
function isShallowEqual(a, b, fromIndex) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1986 |
var i; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1987 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1988 |
if (a.length !== b.length) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1989 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1990 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1991 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1992 |
for (i = fromIndex; i < a.length; i++) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1993 |
if (a[i] !== b[i]) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1994 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1995 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1996 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1997 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1998 |
return true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1999 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2000 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2001 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2002 |
* Returns a memoized selector function. The getDependants function argument is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2003 |
* called before the memoized selector and is expected to return an immutable |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2004 |
* reference or array of references on which the selector depends for computing |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2005 |
* its own return value. The memoize cache is preserved only as long as those |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2006 |
* dependant references remain the same. If getDependants returns a different |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2007 |
* reference(s), the cache is cleared and the selector value regenerated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2008 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2009 |
* @template {(...args: *[]) => *} S |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2010 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2011 |
* @param {S} selector Selector function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2012 |
* @param {GetDependants=} getDependants Dependant getter returning an array of |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2013 |
* references used in cache bust consideration. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2014 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2015 |
/* harmony default export */ function rememo(selector, getDependants) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2016 |
/** @type {WeakMap<*,*>} */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2017 |
var rootCache; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2018 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2019 |
/** @type {GetDependants} */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2020 |
var normalizedGetDependants = getDependants ? getDependants : arrayOf; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2021 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2022 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2023 |
* Returns the cache for a given dependants array. When possible, a WeakMap |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2024 |
* will be used to create a unique cache for each set of dependants. This |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2025 |
* is feasible due to the nature of WeakMap in allowing garbage collection |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2026 |
* to occur on entries where the key object is no longer referenced. Since |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2027 |
* WeakMap requires the key to be an object, this is only possible when the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2028 |
* dependant is object-like. The root cache is created as a hierarchy where |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2029 |
* each top-level key is the first entry in a dependants set, the value a |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2030 |
* WeakMap where each key is the next dependant, and so on. This continues |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2031 |
* so long as the dependants are object-like. If no dependants are object- |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2032 |
* like, then the cache is shared across all invocations. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2033 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2034 |
* @see isObjectLike |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2035 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2036 |
* @param {*[]} dependants Selector dependants. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2037 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2038 |
* @return {Cache} Cache object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2039 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2040 |
function getCache(dependants) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2041 |
var caches = rootCache, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2042 |
isUniqueByDependants = true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2043 |
i, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2044 |
dependant, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2045 |
map, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2046 |
cache; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2047 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2048 |
for (i = 0; i < dependants.length; i++) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2049 |
dependant = dependants[i]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2050 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2051 |
// Can only compose WeakMap from object-like key. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2052 |
if (!isObjectLike(dependant)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2053 |
isUniqueByDependants = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2054 |
break; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2055 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2056 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2057 |
// Does current segment of cache already have a WeakMap? |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2058 |
if (caches.has(dependant)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2059 |
// Traverse into nested WeakMap. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2060 |
caches = caches.get(dependant); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2061 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2062 |
// Create, set, and traverse into a new one. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2063 |
map = new WeakMap(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2064 |
caches.set(dependant, map); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2065 |
caches = map; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2066 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2067 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2068 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2069 |
// We use an arbitrary (but consistent) object as key for the last item |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2070 |
// in the WeakMap to serve as our running cache. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2071 |
if (!caches.has(LEAF_KEY)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2072 |
cache = createCache(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2073 |
cache.isUniqueByDependants = isUniqueByDependants; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2074 |
caches.set(LEAF_KEY, cache); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2075 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2076 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2077 |
return caches.get(LEAF_KEY); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2078 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2079 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2080 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2081 |
* Resets root memoization cache. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2082 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2083 |
function clear() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2084 |
rootCache = new WeakMap(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2085 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2086 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2087 |
/* eslint-disable jsdoc/check-param-names */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2088 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2089 |
* The augmented selector call, considering first whether dependants have |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2090 |
* changed before passing it to underlying memoize function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2091 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2092 |
* @param {*} source Source object for derivation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2093 |
* @param {...*} extraArgs Additional arguments to pass to selector. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2094 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2095 |
* @return {*} Selector result. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2096 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2097 |
/* eslint-enable jsdoc/check-param-names */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2098 |
function callSelector(/* source, ...extraArgs */) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2099 |
var len = arguments.length, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2100 |
cache, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2101 |
node, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2102 |
i, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2103 |
args, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2104 |
dependants; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2105 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2106 |
// Create copy of arguments (avoid leaking deoptimization). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2107 |
args = new Array(len); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2108 |
for (i = 0; i < len; i++) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2109 |
args[i] = arguments[i]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2110 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2111 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2112 |
dependants = normalizedGetDependants.apply(null, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2113 |
cache = getCache(dependants); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2114 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2115 |
// If not guaranteed uniqueness by dependants (primitive type), shallow |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2116 |
// compare against last dependants and, if references have changed, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2117 |
// destroy cache to recalculate result. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2118 |
if (!cache.isUniqueByDependants) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2119 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2120 |
cache.lastDependants && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2121 |
!isShallowEqual(dependants, cache.lastDependants, 0) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2122 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2123 |
cache.clear(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2124 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2125 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2126 |
cache.lastDependants = dependants; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2127 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2128 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2129 |
node = cache.head; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2130 |
while (node) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2131 |
// Check whether node arguments match arguments |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2132 |
if (!isShallowEqual(node.args, args, 1)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2133 |
node = node.next; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2134 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2135 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2136 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2137 |
// At this point we can assume we've found a match |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2138 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2139 |
// Surface matched node to head if not already |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2140 |
if (node !== cache.head) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2141 |
// Adjust siblings to point to each other. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2142 |
/** @type {CacheNode} */ (node.prev).next = node.next; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2143 |
if (node.next) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2144 |
node.next.prev = node.prev; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2145 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2146 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2147 |
node.next = cache.head; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2148 |
node.prev = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2149 |
/** @type {CacheNode} */ (cache.head).prev = node; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2150 |
cache.head = node; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2151 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2152 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2153 |
// Return immediately |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2154 |
return node.val; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2155 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2156 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2157 |
// No cached value found. Continue to insertion phase: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2158 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2159 |
node = /** @type {CacheNode} */ ({ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2160 |
// Generate the result from original function |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2161 |
val: selector.apply(null, args), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2162 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2163 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2164 |
// Avoid including the source object in the cache. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2165 |
args[0] = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2166 |
node.args = args; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2167 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2168 |
// Don't need to check whether node is already head, since it would |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2169 |
// have been returned above already if it was |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2170 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2171 |
// Shift existing head down list |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2172 |
if (cache.head) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2173 |
cache.head.prev = node; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2174 |
node.next = cache.head; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2175 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2176 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2177 |
cache.head = node; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2178 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2179 |
return node.val; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2180 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2181 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2182 |
callSelector.getDependants = normalizedGetDependants; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2183 |
callSelector.clear = clear; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2184 |
clear(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2185 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2186 |
return /** @type {S & EnhancedSelector} */ (callSelector); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2187 |
} |
18 | 2188 |
|
19 | 2189 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js |
16 | 2190 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2191 |
* WordPress dependencies |
16 | 2192 |
*/ |
2193 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2194 |
|
16 | 2195 |
/** |
19 | 2196 |
* Internal dependencies |
2197 |
*/ |
|
2198 |
||
2199 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2200 |
|
19 | 2201 |
/** @typedef {Record<string, import('./reducer').State>} State */ |
2202 |
/** @typedef {import('./reducer').StateValue} StateValue */ |
|
2203 |
/** @typedef {import('./reducer').Status} Status */ |
|
2204 |
||
2205 |
/** |
|
2206 |
* Returns the raw resolution state value for a given selector name, |
|
2207 |
* and arguments set. May be undefined if the selector has never been resolved |
|
2208 |
* or not resolved for the given set of arguments, otherwise true or false for |
|
2209 |
* resolution started and completed respectively. |
|
2210 |
* |
|
2211 |
* @param {State} state Data state. |
|
2212 |
* @param {string} selectorName Selector name. |
|
2213 |
* @param {unknown[]?} args Arguments passed to selector. |
|
2214 |
* |
|
2215 |
* @return {StateValue|undefined} isResolving value. |
|
2216 |
*/ |
|
2217 |
function getResolutionState(state, selectorName, args) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2218 |
const map = state[selectorName]; |
19 | 2219 |
if (!map) { |
2220 |
return; |
|
2221 |
} |
|
2222 |
return map.get(selectorArgsToStateKey(args)); |
|
2223 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2224 |
|
19 | 2225 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2226 |
* Returns an `isResolving`-like value for a given selector name and arguments set. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2227 |
* Its value is either `undefined` if the selector has never been resolved or has been |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2228 |
* invalidated, or a `true`/`false` boolean value if the resolution is in progress or |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2229 |
* has finished, respectively. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2230 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2231 |
* This is a legacy selector that was implemented when the "raw" internal data had |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2232 |
* this `undefined | boolean` format. Nowadays the internal value is an object that |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2233 |
* can be retrieved with `getResolutionState`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2234 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2235 |
* @deprecated |
16 | 2236 |
* |
19 | 2237 |
* @param {State} state Data state. |
2238 |
* @param {string} selectorName Selector name. |
|
2239 |
* @param {unknown[]?} args Arguments passed to selector. |
|
2240 |
* |
|
2241 |
* @return {boolean | undefined} isResolving value. |
|
16 | 2242 |
*/ |
2243 |
function getIsResolving(state, selectorName, args) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2244 |
external_wp_deprecated_default()('wp.data.select( store ).getIsResolving', { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2245 |
since: '6.6', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2246 |
version: '6.8', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2247 |
alternative: 'wp.data.select( store ).getResolutionState' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2248 |
}); |
19 | 2249 |
const resolutionState = getResolutionState(state, selectorName, args); |
2250 |
return resolutionState && resolutionState.status === 'resolving'; |
|
16 | 2251 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2252 |
|
16 | 2253 |
/** |
2254 |
* Returns true if resolution has already been triggered for a given |
|
2255 |
* selector name, and arguments set. |
|
2256 |
* |
|
19 | 2257 |
* @param {State} state Data state. |
2258 |
* @param {string} selectorName Selector name. |
|
2259 |
* @param {unknown[]?} args Arguments passed to selector. |
|
16 | 2260 |
* |
2261 |
* @return {boolean} Whether resolution has been triggered. |
|
2262 |
*/ |
|
19 | 2263 |
function hasStartedResolution(state, selectorName, args) { |
2264 |
return getResolutionState(state, selectorName, args) !== undefined; |
|
16 | 2265 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2266 |
|
16 | 2267 |
/** |
2268 |
* Returns true if resolution has completed for a given selector |
|
2269 |
* name, and arguments set. |
|
2270 |
* |
|
19 | 2271 |
* @param {State} state Data state. |
2272 |
* @param {string} selectorName Selector name. |
|
2273 |
* @param {unknown[]?} args Arguments passed to selector. |
|
16 | 2274 |
* |
2275 |
* @return {boolean} Whether resolution has completed. |
|
2276 |
*/ |
|
19 | 2277 |
function hasFinishedResolution(state, selectorName, args) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2278 |
const status = getResolutionState(state, selectorName, args)?.status; |
19 | 2279 |
return status === 'finished' || status === 'error'; |
2280 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2281 |
|
19 | 2282 |
/** |
2283 |
* Returns true if resolution has failed for a given selector |
|
2284 |
* name, and arguments set. |
|
2285 |
* |
|
2286 |
* @param {State} state Data state. |
|
2287 |
* @param {string} selectorName Selector name. |
|
2288 |
* @param {unknown[]?} args Arguments passed to selector. |
|
2289 |
* |
|
2290 |
* @return {boolean} Has resolution failed |
|
2291 |
*/ |
|
2292 |
function hasResolutionFailed(state, selectorName, args) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2293 |
return getResolutionState(state, selectorName, args)?.status === 'error'; |
19 | 2294 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2295 |
|
19 | 2296 |
/** |
2297 |
* Returns the resolution error for a given selector name, and arguments set. |
|
2298 |
* Note it may be of an Error type, but may also be null, undefined, or anything else |
|
2299 |
* that can be `throw`-n. |
|
2300 |
* |
|
2301 |
* @param {State} state Data state. |
|
2302 |
* @param {string} selectorName Selector name. |
|
2303 |
* @param {unknown[]?} args Arguments passed to selector. |
|
2304 |
* |
|
2305 |
* @return {Error|unknown} Last resolution error |
|
2306 |
*/ |
|
2307 |
function getResolutionError(state, selectorName, args) { |
|
2308 |
const resolutionState = getResolutionState(state, selectorName, args); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2309 |
return resolutionState?.status === 'error' ? resolutionState.error : null; |
16 | 2310 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2311 |
|
16 | 2312 |
/** |
2313 |
* Returns true if resolution has been triggered but has not yet completed for |
|
2314 |
* a given selector name, and arguments set. |
|
2315 |
* |
|
19 | 2316 |
* @param {State} state Data state. |
2317 |
* @param {string} selectorName Selector name. |
|
2318 |
* @param {unknown[]?} args Arguments passed to selector. |
|
16 | 2319 |
* |
2320 |
* @return {boolean} Whether resolution is in progress. |
|
2321 |
*/ |
|
19 | 2322 |
function isResolving(state, selectorName, args) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2323 |
return getResolutionState(state, selectorName, args)?.status === 'resolving'; |
16 | 2324 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2325 |
|
16 | 2326 |
/** |
2327 |
* Returns the list of the cached resolvers. |
|
2328 |
* |
|
19 | 2329 |
* @param {State} state Data state. |
2330 |
* |
|
2331 |
* @return {State} Resolvers mapped by args and selectorName. |
|
16 | 2332 |
*/ |
2333 |
function getCachedResolvers(state) { |
|
2334 |
return state; |
|
2335 |
} |
|
2336 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2337 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2338 |
* Whether the store has any currently resolving selectors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2339 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2340 |
* @param {State} state Data state. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2341 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2342 |
* @return {boolean} True if one or more selectors are resolving, false otherwise. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2343 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2344 |
function hasResolvingSelectors(state) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2345 |
return Object.values(state).some(selectorState => |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2346 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2347 |
* This uses the internal `_map` property of `EquivalentKeyMap` for |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2348 |
* optimization purposes, since the `EquivalentKeyMap` implementation |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2349 |
* does not support a `.values()` implementation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2350 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2351 |
* @see https://github.com/aduth/equivalent-key-map |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2352 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2353 |
Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving')); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2354 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2355 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2356 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2357 |
* Retrieves the total number of selectors, grouped per status. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2358 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2359 |
* @param {State} state Data state. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2360 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2361 |
* @return {Object} Object, containing selector totals by status. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2362 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2363 |
const countSelectorsByStatus = rememo(state => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2364 |
const selectorsByStatus = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2365 |
Object.values(state).forEach(selectorState => |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2366 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2367 |
* This uses the internal `_map` property of `EquivalentKeyMap` for |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2368 |
* optimization purposes, since the `EquivalentKeyMap` implementation |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2369 |
* does not support a `.values()` implementation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2370 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2371 |
* @see https://github.com/aduth/equivalent-key-map |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2372 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2373 |
Array.from(selectorState._map.values()).forEach(resolution => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2374 |
var _resolution$1$status; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2375 |
const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2376 |
if (!selectorsByStatus[currentStatus]) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2377 |
selectorsByStatus[currentStatus] = 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2378 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2379 |
selectorsByStatus[currentStatus]++; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2380 |
})); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2381 |
return selectorsByStatus; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2382 |
}, state => [state]); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2383 |
|
19 | 2384 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js |
16 | 2385 |
/** |
2386 |
* Returns an action object used in signalling that selector resolution has |
|
2387 |
* started. |
|
2388 |
* |
|
19 | 2389 |
* @param {string} selectorName Name of selector for which resolver triggered. |
2390 |
* @param {unknown[]} args Arguments to associate for uniqueness. |
|
2391 |
* |
|
2392 |
* @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object. |
|
16 | 2393 |
*/ |
2394 |
function startResolution(selectorName, args) { |
|
2395 |
return { |
|
2396 |
type: 'START_RESOLUTION', |
|
18 | 2397 |
selectorName, |
2398 |
args |
|
16 | 2399 |
}; |
2400 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2401 |
|
16 | 2402 |
/** |
2403 |
* Returns an action object used in signalling that selector resolution has |
|
2404 |
* completed. |
|
2405 |
* |
|
19 | 2406 |
* @param {string} selectorName Name of selector for which resolver triggered. |
2407 |
* @param {unknown[]} args Arguments to associate for uniqueness. |
|
2408 |
* |
|
2409 |
* @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object. |
|
16 | 2410 |
*/ |
2411 |
function finishResolution(selectorName, args) { |
|
2412 |
return { |
|
2413 |
type: 'FINISH_RESOLUTION', |
|
18 | 2414 |
selectorName, |
2415 |
args |
|
2416 |
}; |
|
2417 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2418 |
|
18 | 2419 |
/** |
19 | 2420 |
* Returns an action object used in signalling that selector resolution has |
2421 |
* failed. |
|
2422 |
* |
|
2423 |
* @param {string} selectorName Name of selector for which resolver triggered. |
|
2424 |
* @param {unknown[]} args Arguments to associate for uniqueness. |
|
2425 |
* @param {Error|unknown} error The error that caused the failure. |
|
2426 |
* |
|
2427 |
* @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object. |
|
2428 |
*/ |
|
2429 |
function failResolution(selectorName, args, error) { |
|
2430 |
return { |
|
2431 |
type: 'FAIL_RESOLUTION', |
|
2432 |
selectorName, |
|
2433 |
args, |
|
2434 |
error |
|
2435 |
}; |
|
2436 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2437 |
|
19 | 2438 |
/** |
18 | 2439 |
* Returns an action object used in signalling that a batch of selector resolutions has |
2440 |
* started. |
|
2441 |
* |
|
19 | 2442 |
* @param {string} selectorName Name of selector for which resolver triggered. |
2443 |
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item |
|
2444 |
* is associated to a resolution. |
|
2445 |
* |
|
2446 |
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. |
|
18 | 2447 |
*/ |
2448 |
function startResolutions(selectorName, args) { |
|
2449 |
return { |
|
2450 |
type: 'START_RESOLUTIONS', |
|
2451 |
selectorName, |
|
2452 |
args |
|
2453 |
}; |
|
2454 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2455 |
|
18 | 2456 |
/** |
2457 |
* Returns an action object used in signalling that a batch of selector resolutions has |
|
2458 |
* completed. |
|
2459 |
* |
|
19 | 2460 |
* @param {string} selectorName Name of selector for which resolver triggered. |
2461 |
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item |
|
2462 |
* is associated to a resolution. |
|
2463 |
* |
|
2464 |
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. |
|
18 | 2465 |
*/ |
2466 |
function finishResolutions(selectorName, args) { |
|
2467 |
return { |
|
2468 |
type: 'FINISH_RESOLUTIONS', |
|
2469 |
selectorName, |
|
2470 |
args |
|
16 | 2471 |
}; |
2472 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2473 |
|
16 | 2474 |
/** |
19 | 2475 |
* Returns an action object used in signalling that a batch of selector resolutions has |
2476 |
* completed and at least one of them has failed. |
|
2477 |
* |
|
2478 |
* @param {string} selectorName Name of selector for which resolver triggered. |
|
2479 |
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item |
|
2480 |
* is associated to a resolution. |
|
2481 |
* @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item |
|
2482 |
* is associated to a resolution. |
|
2483 |
* @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object. |
|
2484 |
*/ |
|
2485 |
function failResolutions(selectorName, args, errors) { |
|
2486 |
return { |
|
2487 |
type: 'FAIL_RESOLUTIONS', |
|
2488 |
selectorName, |
|
2489 |
args, |
|
2490 |
errors |
|
2491 |
}; |
|
2492 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2493 |
|
19 | 2494 |
/** |
16 | 2495 |
* Returns an action object used in signalling that we should invalidate the resolution cache. |
2496 |
* |
|
19 | 2497 |
* @param {string} selectorName Name of selector for which resolver should be invalidated. |
2498 |
* @param {unknown[]} args Arguments to associate for uniqueness. |
|
2499 |
* |
|
2500 |
* @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object. |
|
16 | 2501 |
*/ |
2502 |
function invalidateResolution(selectorName, args) { |
|
2503 |
return { |
|
2504 |
type: 'INVALIDATE_RESOLUTION', |
|
18 | 2505 |
selectorName, |
2506 |
args |
|
16 | 2507 |
}; |
2508 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2509 |
|
16 | 2510 |
/** |
2511 |
* Returns an action object used in signalling that the resolution |
|
2512 |
* should be invalidated. |
|
2513 |
* |
|
19 | 2514 |
* @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object. |
16 | 2515 |
*/ |
2516 |
function invalidateResolutionForStore() { |
|
2517 |
return { |
|
2518 |
type: 'INVALIDATE_RESOLUTION_FOR_STORE' |
|
2519 |
}; |
|
2520 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2521 |
|
16 | 2522 |
/** |
2523 |
* Returns an action object used in signalling that the resolution cache for a |
|
2524 |
* given selectorName should be invalidated. |
|
2525 |
* |
|
2526 |
* @param {string} selectorName Name of selector for which all resolvers should |
|
2527 |
* be invalidated. |
|
2528 |
* |
|
19 | 2529 |
* @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object. |
16 | 2530 |
*/ |
2531 |
function invalidateResolutionForStoreSelector(selectorName) { |
|
2532 |
return { |
|
2533 |
type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', |
|
18 | 2534 |
selectorName |
16 | 2535 |
}; |
2536 |
} |
|
2537 |
||
19 | 2538 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js |
16 | 2539 |
/** |
2540 |
* External dependencies |
|
2541 |
*/ |
|
2542 |
||
2543 |
||
2544 |
||
2545 |
/** |
|
2546 |
* WordPress dependencies |
|
2547 |
*/ |
|
2548 |
||
2549 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2550 |
|
16 | 2551 |
/** |
2552 |
* Internal dependencies |
|
2553 |
*/ |
|
2554 |
||
2555 |
||
2556 |
||
2557 |
||
2558 |
||
2559 |
||
18 | 2560 |
|
2561 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2562 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2563 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2564 |
|
19 | 2565 |
/** @typedef {import('../types').DataRegistry} DataRegistry */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2566 |
/** @typedef {import('../types').ListenerFunction} ListenerFunction */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2567 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2568 |
* @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2569 |
* @template {import('../types').AnyConfig} C |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2570 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2571 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2572 |
* @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2573 |
* @template State |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2574 |
* @template {Record<string,import('../types').ActionCreator>} Actions |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2575 |
* @template Selectors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2576 |
*/ |
19 | 2577 |
|
2578 |
const trimUndefinedValues = array => { |
|
2579 |
const result = [...array]; |
|
2580 |
for (let i = result.length - 1; i >= 0; i--) { |
|
2581 |
if (result[i] === undefined) { |
|
2582 |
result.splice(i, 1); |
|
2583 |
} |
|
2584 |
} |
|
2585 |
return result; |
|
2586 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2587 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2588 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2589 |
* Creates a new object with the same keys, but with `callback()` called as |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2590 |
* a transformer function on each of the values. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2591 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2592 |
* @param {Object} obj The object to transform. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2593 |
* @param {Function} callback The function to transform each object value. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2594 |
* @return {Array} Transformed object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2595 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2596 |
const mapValues = (obj, callback) => Object.fromEntries(Object.entries(obj !== null && obj !== void 0 ? obj : {}).map(([key, value]) => [key, callback(value, key)])); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2597 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2598 |
// Convert non serializable types to plain objects |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2599 |
const devToolsReplacer = (key, state) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2600 |
if (state instanceof Map) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2601 |
return Object.fromEntries(state); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2602 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2603 |
if (state instanceof window.HTMLElement) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2604 |
return null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2605 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2606 |
return state; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2607 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2608 |
|
16 | 2609 |
/** |
18 | 2610 |
* Create a cache to track whether resolvers started running or not. |
16 | 2611 |
* |
18 | 2612 |
* @return {Object} Resolvers Cache. |
16 | 2613 |
*/ |
18 | 2614 |
function createResolversCache() { |
2615 |
const cache = {}; |
|
2616 |
return { |
|
2617 |
isRunning(selectorName, args) { |
|
19 | 2618 |
return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args)); |
18 | 2619 |
}, |
2620 |
clear(selectorName, args) { |
|
2621 |
if (cache[selectorName]) { |
|
19 | 2622 |
cache[selectorName].delete(trimUndefinedValues(args)); |
16 | 2623 |
} |
18 | 2624 |
}, |
2625 |
markAsRunning(selectorName, args) { |
|
2626 |
if (!cache[selectorName]) { |
|
19 | 2627 |
cache[selectorName] = new (equivalent_key_map_default())(); |
16 | 2628 |
} |
19 | 2629 |
cache[selectorName].set(trimUndefinedValues(args), true); |
18 | 2630 |
} |
16 | 2631 |
}; |
18 | 2632 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2633 |
function createBindingCache(bind) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2634 |
const cache = new WeakMap(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2635 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2636 |
get(item, itemName) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2637 |
let boundItem = cache.get(item); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2638 |
if (!boundItem) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2639 |
boundItem = bind(item, itemName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2640 |
cache.set(item, boundItem); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2641 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2642 |
return boundItem; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2643 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2644 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2645 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2646 |
|
18 | 2647 |
/** |
19 | 2648 |
* Creates a data store descriptor for the provided Redux store configuration containing |
18 | 2649 |
* properties describing reducer, actions, selectors, controls and resolvers. |
2650 |
* |
|
2651 |
* @example |
|
2652 |
* ```js |
|
2653 |
* import { createReduxStore } from '@wordpress/data'; |
|
2654 |
* |
|
2655 |
* const store = createReduxStore( 'demo', { |
|
2656 |
* reducer: ( state = 'OK' ) => state, |
|
2657 |
* selectors: { |
|
2658 |
* getValue: ( state ) => state, |
|
2659 |
* }, |
|
2660 |
* } ); |
|
2661 |
* ``` |
|
2662 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2663 |
* @template State |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2664 |
* @template {Record<string,import('../types').ActionCreator>} Actions |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2665 |
* @template Selectors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2666 |
* @param {string} key Unique namespace identifier. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2667 |
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2668 |
* describing reducer, actions, selectors, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2669 |
* and resolvers. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2670 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2671 |
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object. |
18 | 2672 |
*/ |
2673 |
function createReduxStore(key, options) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2674 |
const privateActions = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2675 |
const privateSelectors = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2676 |
const privateRegistrationFunctions = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2677 |
privateActions, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2678 |
registerPrivateActions: actions => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2679 |
Object.assign(privateActions, actions); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2680 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2681 |
privateSelectors, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2682 |
registerPrivateSelectors: selectors => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2683 |
Object.assign(privateSelectors, selectors); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2684 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2685 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2686 |
const storeDescriptor = { |
18 | 2687 |
name: key, |
2688 |
instantiate: registry => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2689 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2690 |
* Stores listener functions registered with `subscribe()`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2691 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2692 |
* When functions register to listen to store changes with |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2693 |
* `subscribe()` they get added here. Although Redux offers |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2694 |
* its own `subscribe()` function directly, by wrapping the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2695 |
* subscription in this store instance it's possible to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2696 |
* optimize checking if the state has changed before calling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2697 |
* each listener. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2698 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2699 |
* @type {Set<ListenerFunction>} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2700 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2701 |
const listeners = new Set(); |
18 | 2702 |
const reducer = options.reducer; |
2703 |
const thunkArgs = { |
|
2704 |
registry, |
|
2705 |
get dispatch() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2706 |
return thunkActions; |
18 | 2707 |
}, |
2708 |
get select() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2709 |
return thunkSelectors; |
18 | 2710 |
}, |
2711 |
get resolveSelect() { |
|
2712 |
return getResolveSelectors(); |
|
2713 |
} |
|
2714 |
}; |
|
2715 |
const store = instantiateReduxStore(key, options, registry, thunkArgs); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2716 |
// Expose the private registration functions on the store |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2717 |
// so they can be copied to a sub registry in registry.js. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2718 |
lock(store, privateRegistrationFunctions); |
18 | 2719 |
const resolversCache = createResolversCache(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2720 |
function bindAction(action) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2721 |
return (...args) => Promise.resolve(store.dispatch(action(...args))); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2722 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2723 |
const actions = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2724 |
...mapValues(actions_namespaceObject, bindAction), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2725 |
...mapValues(options.actions, bindAction) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2726 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2727 |
const boundPrivateActions = createBindingCache(bindAction); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2728 |
const allActions = new Proxy(() => {}, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2729 |
get: (target, prop) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2730 |
const privateAction = privateActions[prop]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2731 |
return privateAction ? boundPrivateActions.get(privateAction, prop) : actions[prop]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2732 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2733 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2734 |
const thunkActions = new Proxy(allActions, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2735 |
apply: (target, thisArg, [action]) => store.dispatch(action) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2736 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2737 |
lock(actions, allActions); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2738 |
const resolvers = options.resolvers ? mapResolvers(options.resolvers) : {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2739 |
function bindSelector(selector, selectorName) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2740 |
if (selector.isRegistrySelector) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2741 |
selector.registry = registry; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2742 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2743 |
const boundSelector = (...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2744 |
args = normalize(selector, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2745 |
const state = store.__unstableOriginalGetState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2746 |
// Before calling the selector, switch to the correct |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2747 |
// registry. |
18 | 2748 |
if (selector.isRegistrySelector) { |
2749 |
selector.registry = registry; |
|
2750 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2751 |
return selector(state.root, ...args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2752 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2753 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2754 |
// Expose normalization method on the bound selector |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2755 |
// in order that it can be called when fullfilling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2756 |
// the resolver. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2757 |
boundSelector.__unstableNormalizeArgs = selector.__unstableNormalizeArgs; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2758 |
const resolver = resolvers[selectorName]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2759 |
if (!resolver) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2760 |
boundSelector.hasResolver = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2761 |
return boundSelector; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2762 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2763 |
return mapSelectorWithResolver(boundSelector, selectorName, resolver, store, resolversCache); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2764 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2765 |
function bindMetadataSelector(metaDataSelector) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2766 |
const boundSelector = (...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2767 |
const state = store.__unstableOriginalGetState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2768 |
const originalSelectorName = args && args[0]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2769 |
const originalSelectorArgs = args && args[1]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2770 |
const targetSelector = options?.selectors?.[originalSelectorName]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2771 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2772 |
// Normalize the arguments passed to the target selector. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2773 |
if (originalSelectorName && targetSelector) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2774 |
args[1] = normalize(targetSelector, originalSelectorArgs); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2775 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2776 |
return metaDataSelector(state.metadata, ...args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2777 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2778 |
boundSelector.hasResolver = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2779 |
return boundSelector; |
16 | 2780 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2781 |
const selectors = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2782 |
...mapValues(selectors_namespaceObject, bindMetadataSelector), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2783 |
...mapValues(options.selectors, bindSelector) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2784 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2785 |
const boundPrivateSelectors = createBindingCache(bindSelector); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2786 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2787 |
// Pre-bind the private selectors that have been registered by the time of |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2788 |
// instantiation, so that registry selectors are bound to the registry. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2789 |
for (const [selectorName, selector] of Object.entries(privateSelectors)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2790 |
boundPrivateSelectors.get(selector, selectorName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2791 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2792 |
const allSelectors = new Proxy(() => {}, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2793 |
get: (target, prop) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2794 |
const privateSelector = privateSelectors[prop]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2795 |
return privateSelector ? boundPrivateSelectors.get(privateSelector, prop) : selectors[prop]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2796 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2797 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2798 |
const thunkSelectors = new Proxy(allSelectors, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2799 |
apply: (target, thisArg, [selector]) => selector(store.__unstableOriginalGetState()) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2800 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2801 |
lock(selectors, allSelectors); |
18 | 2802 |
const resolveSelectors = mapResolveSelectors(selectors, store); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2803 |
const suspendSelectors = mapSuspendSelectors(selectors, store); |
18 | 2804 |
const getSelectors = () => selectors; |
2805 |
const getActions = () => actions; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2806 |
const getResolveSelectors = () => resolveSelectors; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2807 |
const getSuspendSelectors = () => suspendSelectors; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2808 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2809 |
// We have some modules monkey-patching the store object |
18 | 2810 |
// It's wrong to do so but until we refactor all of our effects to controls |
2811 |
// We need to keep the same "store" instance here. |
|
2812 |
store.__unstableOriginalGetState = store.getState; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2813 |
store.getState = () => store.__unstableOriginalGetState().root; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2814 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2815 |
// Customize subscribe behavior to call listeners only on effective change, |
18 | 2816 |
// not on every dispatch. |
2817 |
const subscribe = store && (listener => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2818 |
listeners.add(listener); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2819 |
return () => listeners.delete(listener); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2820 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2821 |
let lastState = store.__unstableOriginalGetState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2822 |
store.subscribe(() => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2823 |
const state = store.__unstableOriginalGetState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2824 |
const hasChanged = state !== lastState; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2825 |
lastState = state; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2826 |
if (hasChanged) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2827 |
for (const listener of listeners) { |
18 | 2828 |
listener(); |
2829 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2830 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2831 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2832 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2833 |
// This can be simplified to just { subscribe, getSelectors, getActions } |
18 | 2834 |
// Once we remove the use function. |
2835 |
return { |
|
2836 |
reducer, |
|
2837 |
store, |
|
2838 |
actions, |
|
2839 |
selectors, |
|
2840 |
resolvers, |
|
2841 |
getSelectors, |
|
2842 |
getResolveSelectors, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2843 |
getSuspendSelectors, |
18 | 2844 |
getActions, |
2845 |
subscribe |
|
2846 |
}; |
|
2847 |
} |
|
16 | 2848 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2849 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2850 |
// Expose the private registration functions on the store |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2851 |
// descriptor. That's a natural choice since that's where the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2852 |
// public actions and selectors are stored . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2853 |
lock(storeDescriptor, privateRegistrationFunctions); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2854 |
return storeDescriptor; |
16 | 2855 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2856 |
|
16 | 2857 |
/** |
2858 |
* Creates a redux store for a namespace. |
|
2859 |
* |
|
19 | 2860 |
* @param {string} key Unique namespace identifier. |
2861 |
* @param {Object} options Registered store options, with properties |
|
2862 |
* describing reducer, actions, selectors, |
|
2863 |
* and resolvers. |
|
2864 |
* @param {DataRegistry} registry Registry reference. |
|
2865 |
* @param {Object} thunkArgs Argument object for the thunk middleware. |
|
16 | 2866 |
* @return {Object} Newly created redux store. |
2867 |
*/ |
|
18 | 2868 |
function instantiateReduxStore(key, options, registry, thunkArgs) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2869 |
const controls = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2870 |
...options.controls, |
18 | 2871 |
...builtinControls |
2872 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2873 |
const normalizedControls = mapValues(controls, control => control.isRegistryControl ? control(registry) : control); |
19 | 2874 |
const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)]; |
18 | 2875 |
const enhancers = [applyMiddleware(...middlewares)]; |
16 | 2876 |
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { |
2877 |
enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({ |
|
2878 |
name: key, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2879 |
instanceId: key, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2880 |
serialize: { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2881 |
replacer: devToolsReplacer |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2882 |
} |
16 | 2883 |
})); |
2884 |
} |
|
18 | 2885 |
const { |
2886 |
reducer, |
|
2887 |
initialState |
|
2888 |
} = options; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2889 |
const enhancedReducer = combine_reducers_combineReducers({ |
16 | 2890 |
metadata: metadata_reducer, |
2891 |
root: reducer |
|
2892 |
}); |
|
19 | 2893 |
return createStore(enhancedReducer, { |
16 | 2894 |
root: initialState |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2895 |
}, (0,external_wp_compose_namespaceObject.compose)(enhancers)); |
16 | 2896 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2897 |
|
18 | 2898 |
/** |
2899 |
* Maps selectors to functions that return a resolution promise for them |
|
2900 |
* |
|
2901 |
* @param {Object} selectors Selectors to map. |
|
2902 |
* @param {Object} store The redux store the selectors select from. |
|
19 | 2903 |
* |
2904 |
* @return {Object} Selectors mapped to their resolution functions. |
|
18 | 2905 |
*/ |
2906 |
function mapResolveSelectors(selectors, store) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2907 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2908 |
getIsResolving, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2909 |
hasStartedResolution, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2910 |
hasFinishedResolution, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2911 |
hasResolutionFailed, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2912 |
isResolving, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2913 |
getCachedResolvers, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2914 |
getResolutionState, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2915 |
getResolutionError, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2916 |
hasResolvingSelectors, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2917 |
countSelectorsByStatus, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2918 |
...storeSelectors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2919 |
} = selectors; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2920 |
return mapValues(storeSelectors, (selector, selectorName) => { |
19 | 2921 |
// If the selector doesn't have a resolver, just convert the return value |
2922 |
// (including exceptions) to a Promise, no additional extra behavior is needed. |
|
2923 |
if (!selector.hasResolver) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2924 |
return async (...args) => selector.apply(null, args); |
18 | 2925 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2926 |
return (...args) => { |
19 | 2927 |
return new Promise((resolve, reject) => { |
2928 |
const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); |
|
2929 |
const finalize = result => { |
|
2930 |
const hasFailed = selectors.hasResolutionFailed(selectorName, args); |
|
2931 |
if (hasFailed) { |
|
2932 |
const error = selectors.getResolutionError(selectorName, args); |
|
2933 |
reject(error); |
|
2934 |
} else { |
|
2935 |
resolve(result); |
|
2936 |
} |
|
2937 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2938 |
const getResult = () => selector.apply(null, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2939 |
// Trigger the selector (to trigger the resolver) |
19 | 2940 |
const result = getResult(); |
2941 |
if (hasFinished()) { |
|
2942 |
return finalize(result); |
|
2943 |
} |
|
2944 |
const unsubscribe = store.subscribe(() => { |
|
2945 |
if (hasFinished()) { |
|
2946 |
unsubscribe(); |
|
2947 |
finalize(getResult()); |
|
2948 |
} |
|
2949 |
}); |
|
2950 |
}); |
|
2951 |
}; |
|
2952 |
}); |
|
16 | 2953 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2954 |
|
16 | 2955 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2956 |
* Maps selectors to functions that throw a suspense promise if not yet resolved. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2957 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2958 |
* @param {Object} selectors Selectors to map. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2959 |
* @param {Object} store The redux store the selectors select from. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2960 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2961 |
* @return {Object} Selectors mapped to their suspense functions. |
16 | 2962 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2963 |
function mapSuspendSelectors(selectors, store) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2964 |
return mapValues(selectors, (selector, selectorName) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2965 |
// Selector without a resolver doesn't have any extra suspense behavior. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2966 |
if (!selector.hasResolver) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2967 |
return selector; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2968 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2969 |
return (...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2970 |
const result = selector.apply(null, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2971 |
if (selectors.hasFinishedResolution(selectorName, args)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2972 |
if (selectors.hasResolutionFailed(selectorName, args)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2973 |
throw selectors.getResolutionError(selectorName, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2974 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2975 |
return result; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2976 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2977 |
throw new Promise(resolve => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2978 |
const unsubscribe = store.subscribe(() => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2979 |
if (selectors.hasFinishedResolution(selectorName, args)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2980 |
resolve(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2981 |
unsubscribe(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2982 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2983 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2984 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2985 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2986 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2987 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2988 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2989 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2990 |
* Convert resolvers to a normalized form, an object with `fulfill` method and |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2991 |
* optional methods like `isFulfilled`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2992 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2993 |
* @param {Object} resolvers Resolver to convert |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2994 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2995 |
function mapResolvers(resolvers) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2996 |
return mapValues(resolvers, resolver => { |
18 | 2997 |
if (resolver.fulfill) { |
2998 |
return resolver; |
|
2999 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3000 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3001 |
...resolver, |
19 | 3002 |
// Copy the enumerable properties of the resolver function. |
3003 |
fulfill: resolver // Add the fulfill method. |
|
18 | 3004 |
}; |
16 | 3005 |
}); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3006 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3007 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3008 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3009 |
* Returns a selector with a matched resolver. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3010 |
* Resolvers are side effects invoked once per argument set of a given selector call, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3011 |
* used in ensuring that the data needs for the selector are satisfied. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3012 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3013 |
* @param {Object} selector The selector function to be bound. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3014 |
* @param {string} selectorName The selector name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3015 |
* @param {Object} resolver Resolver to call. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3016 |
* @param {Object} store The redux store to which the resolvers should be mapped. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3017 |
* @param {Object} resolversCache Resolvers Cache. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3018 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3019 |
function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3020 |
function fulfillSelector(args) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3021 |
const state = store.getState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3022 |
if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3023 |
return; |
16 | 3024 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3025 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3026 |
metadata |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3027 |
} = store.__unstableOriginalGetState(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3028 |
if (hasStartedResolution(metadata, selectorName, args)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3029 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3030 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3031 |
resolversCache.markAsRunning(selectorName, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3032 |
setTimeout(async () => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3033 |
resolversCache.clear(selectorName, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3034 |
store.dispatch(startResolution(selectorName, args)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3035 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3036 |
const action = resolver.fulfill(...args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3037 |
if (action) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3038 |
await store.dispatch(action); |
18 | 3039 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3040 |
store.dispatch(finishResolution(selectorName, args)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3041 |
} catch (error) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3042 |
store.dispatch(failResolution(selectorName, args, error)); |
16 | 3043 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3044 |
}, 0); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3045 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3046 |
const selectorResolver = (...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3047 |
args = normalize(selector, args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3048 |
fulfillSelector(args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3049 |
return selector(...args); |
16 | 3050 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3051 |
selectorResolver.hasResolver = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3052 |
return selectorResolver; |
16 | 3053 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3054 |
|
16 | 3055 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3056 |
* Applies selector's normalization function to the given arguments |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3057 |
* if it exists. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3058 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3059 |
* @param {Object} selector The selector potentially with a normalization method property. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3060 |
* @param {Array} args selector arguments to normalize. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3061 |
* @return {Array} Potentially normalized arguments. |
16 | 3062 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3063 |
function normalize(selector, args) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3064 |
if (selector.__unstableNormalizeArgs && typeof selector.__unstableNormalizeArgs === 'function' && args?.length) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3065 |
return selector.__unstableNormalizeArgs(args); |
18 | 3066 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3067 |
return args; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3068 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3069 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3070 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3071 |
const coreDataStore = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3072 |
name: 'core/data', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3073 |
instantiate(registry) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3074 |
const getCoreDataSelector = selectorName => (key, ...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3075 |
return registry.select(key)[selectorName](...args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3076 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3077 |
const getCoreDataAction = actionName => (key, ...args) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3078 |
return registry.dispatch(key)[actionName](...args); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3079 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3080 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3081 |
getSelectors() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3082 |
return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)])); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3083 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3084 |
getActions() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3085 |
return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)])); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3086 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3087 |
subscribe() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3088 |
// There's no reasons to trigger any listener when we subscribe to this store |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3089 |
// because there's no state stored in this store that need to retrigger selectors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3090 |
// if a change happens, the corresponding store where the tracking stated live |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3091 |
// would have already triggered a "subscribe" call. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3092 |
return () => () => {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3093 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3094 |
}; |
19 | 3095 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3096 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3097 |
/* harmony default export */ const store = (coreDataStore); |
16 | 3098 |
|
19 | 3099 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js |
3100 |
/** |
|
3101 |
* Create an event emitter. |
|
3102 |
* |
|
3103 |
* @return {import("../types").DataEmitter} Emitter. |
|
3104 |
*/ |
|
3105 |
function createEmitter() { |
|
3106 |
let isPaused = false; |
|
3107 |
let isPending = false; |
|
3108 |
const listeners = new Set(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3109 |
const notifyListeners = () => |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3110 |
// We use Array.from to clone the listeners Set |
19 | 3111 |
// This ensures that we don't run a listener |
3112 |
// that was added as a response to another listener. |
|
3113 |
Array.from(listeners).forEach(listener => listener()); |
|
16 | 3114 |
return { |
19 | 3115 |
get isPaused() { |
3116 |
return isPaused; |
|
3117 |
}, |
|
3118 |
subscribe(listener) { |
|
3119 |
listeners.add(listener); |
|
3120 |
return () => listeners.delete(listener); |
|
3121 |
}, |
|
3122 |
pause() { |
|
3123 |
isPaused = true; |
|
16 | 3124 |
}, |
19 | 3125 |
resume() { |
3126 |
isPaused = false; |
|
3127 |
if (isPending) { |
|
3128 |
isPending = false; |
|
3129 |
notifyListeners(); |
|
3130 |
} |
|
16 | 3131 |
}, |
19 | 3132 |
emit() { |
3133 |
if (isPaused) { |
|
3134 |
isPending = true; |
|
3135 |
return; |
|
3136 |
} |
|
3137 |
notifyListeners(); |
|
16 | 3138 |
} |
3139 |
}; |
|
3140 |
} |
|
3141 |
||
19 | 3142 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js |
16 | 3143 |
/** |
19 | 3144 |
* WordPress dependencies |
3145 |
*/ |
|
3146 |
||
3147 |
||
3148 |
/** |
|
16 | 3149 |
* Internal dependencies |
3150 |
*/ |
|
3151 |
||
3152 |
||
3153 |
||
19 | 3154 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3155 |
|
19 | 3156 |
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
18 | 3157 |
|
16 | 3158 |
/** |
3159 |
* @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. |
|
3160 |
* |
|
3161 |
* @property {Function} registerGenericStore Given a namespace key and settings |
|
3162 |
* object, registers a new generic |
|
3163 |
* store. |
|
3164 |
* @property {Function} registerStore Given a namespace key and settings |
|
3165 |
* object, registers a new namespace |
|
3166 |
* store. |
|
3167 |
* @property {Function} subscribe Given a function callback, invokes |
|
3168 |
* the callback on any change to state |
|
3169 |
* within any registered store. |
|
3170 |
* @property {Function} select Given a namespace key, returns an |
|
3171 |
* object of the store's registered |
|
3172 |
* selectors. |
|
3173 |
* @property {Function} dispatch Given a namespace key, returns an |
|
3174 |
* object of the store's registered |
|
3175 |
* action dispatchers. |
|
3176 |
*/ |
|
3177 |
||
3178 |
/** |
|
3179 |
* @typedef {Object} WPDataPlugin An object of registry function overrides. |
|
3180 |
* |
|
3181 |
* @property {Function} registerStore registers store. |
|
3182 |
*/ |
|
3183 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3184 |
function getStoreName(storeNameOrDescriptor) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3185 |
return typeof storeNameOrDescriptor === 'string' ? storeNameOrDescriptor : storeNameOrDescriptor.name; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3186 |
} |
16 | 3187 |
/** |
3188 |
* Creates a new store registry, given an optional object of initial store |
|
3189 |
* configurations. |
|
3190 |
* |
|
3191 |
* @param {Object} storeConfigs Initial store configurations. |
|
3192 |
* @param {Object?} parent Parent registry. |
|
3193 |
* |
|
3194 |
* @return {WPDataRegistry} Data registry. |
|
3195 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3196 |
function createRegistry(storeConfigs = {}, parent = null) { |
18 | 3197 |
const stores = {}; |
19 | 3198 |
const emitter = createEmitter(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3199 |
let listeningStores = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3200 |
|
16 | 3201 |
/** |
3202 |
* Global listener called for each store's update. |
|
3203 |
*/ |
|
3204 |
function globalListener() { |
|
19 | 3205 |
emitter.emit(); |
16 | 3206 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3207 |
|
16 | 3208 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3209 |
* Subscribe to changes to any data, either in all stores in registry, or |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3210 |
* in one specific store. |
16 | 3211 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3212 |
* @param {Function} listener Listener function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3213 |
* @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name. |
16 | 3214 |
* |
19 | 3215 |
* @return {Function} Unsubscribe function. |
16 | 3216 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3217 |
const subscribe = (listener, storeNameOrDescriptor) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3218 |
// subscribe to all stores |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3219 |
if (!storeNameOrDescriptor) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3220 |
return emitter.subscribe(listener); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3221 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3222 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3223 |
// subscribe to one store |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3224 |
const storeName = getStoreName(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3225 |
const store = stores[storeName]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3226 |
if (store) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3227 |
return store.subscribe(listener); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3228 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3229 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3230 |
// Trying to access a store that hasn't been registered, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3231 |
// this is a pattern rarely used but seen in some places. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3232 |
// We fallback to global `subscribe` here for backward-compatibility for now. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3233 |
// See https://github.com/WordPress/gutenberg/pull/27466 for more info. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3234 |
if (!parent) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3235 |
return emitter.subscribe(listener); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3236 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3237 |
return parent.subscribe(listener, storeNameOrDescriptor); |
16 | 3238 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3239 |
|
16 | 3240 |
/** |
3241 |
* Calls a selector given the current state and extra arguments. |
|
3242 |
* |
|
19 | 3243 |
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
3244 |
* or the store descriptor. |
|
16 | 3245 |
* |
3246 |
* @return {*} The selector's returned value. |
|
3247 |
*/ |
|
19 | 3248 |
function select(storeNameOrDescriptor) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3249 |
const storeName = getStoreName(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3250 |
listeningStores?.add(storeName); |
18 | 3251 |
const store = stores[storeName]; |
16 | 3252 |
if (store) { |
3253 |
return store.getSelectors(); |
|
3254 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3255 |
return parent?.select(storeName); |
16 | 3256 |
} |
19 | 3257 |
function __unstableMarkListeningStores(callback, ref) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3258 |
listeningStores = new Set(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3259 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3260 |
return callback.call(this); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3261 |
} finally { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3262 |
ref.current = Array.from(listeningStores); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3263 |
listeningStores = null; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3264 |
} |
18 | 3265 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3266 |
|
16 | 3267 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3268 |
* Given a store descriptor, returns an object containing the store's selectors pre-bound to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3269 |
* state so that you only need to supply additional arguments, and modified so that they return |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3270 |
* promises that resolve to their eventual values, after any resolvers have ran. |
16 | 3271 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3272 |
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3273 |
* convention of passing the store name is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3274 |
* also supported. |
16 | 3275 |
* |
3276 |
* @return {Object} Each key of the object matches the name of a selector. |
|
3277 |
*/ |
|
19 | 3278 |
function resolveSelect(storeNameOrDescriptor) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3279 |
const storeName = getStoreName(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3280 |
listeningStores?.add(storeName); |
18 | 3281 |
const store = stores[storeName]; |
3282 |
if (store) { |
|
3283 |
return store.getResolveSelectors(); |
|
3284 |
} |
|
3285 |
return parent && parent.resolveSelect(storeName); |
|
16 | 3286 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3287 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3288 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3289 |
* Given a store descriptor, returns an object containing the store's selectors pre-bound to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3290 |
* state so that you only need to supply additional arguments, and modified so that they throw |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3291 |
* promises in case the selector is not resolved yet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3292 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3293 |
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3294 |
* convention of passing the store name is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3295 |
* also supported. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3296 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3297 |
* @return {Object} Object containing the store's suspense-wrapped selectors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3298 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3299 |
function suspendSelect(storeNameOrDescriptor) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3300 |
const storeName = getStoreName(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3301 |
listeningStores?.add(storeName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3302 |
const store = stores[storeName]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3303 |
if (store) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3304 |
return store.getSuspendSelectors(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3305 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3306 |
return parent && parent.suspendSelect(storeName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3307 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3308 |
|
16 | 3309 |
/** |
3310 |
* Returns the available actions for a part of the state. |
|
3311 |
* |
|
19 | 3312 |
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store |
3313 |
* or the store descriptor. |
|
16 | 3314 |
* |
3315 |
* @return {*} The action's returned value. |
|
3316 |
*/ |
|
19 | 3317 |
function dispatch(storeNameOrDescriptor) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3318 |
const storeName = getStoreName(storeNameOrDescriptor); |
18 | 3319 |
const store = stores[storeName]; |
16 | 3320 |
if (store) { |
3321 |
return store.getActions(); |
|
3322 |
} |
|
18 | 3323 |
return parent && parent.dispatch(storeName); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3324 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3325 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3326 |
// |
16 | 3327 |
// Deprecated |
3328 |
// TODO: Remove this after `use()` is removed. |
|
3329 |
function withPlugins(attributes) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3330 |
return Object.fromEntries(Object.entries(attributes).map(([key, attribute]) => { |
16 | 3331 |
if (typeof attribute !== 'function') { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3332 |
return [key, attribute]; |
16 | 3333 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3334 |
return [key, function () { |
16 | 3335 |
return registry[key].apply(null, arguments); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3336 |
}]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3337 |
})); |
16 | 3338 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3339 |
|
16 | 3340 |
/** |
19 | 3341 |
* Registers a store instance. |
16 | 3342 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3343 |
* @param {string} name Store registry name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3344 |
* @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe). |
16 | 3345 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3346 |
function registerStoreInstance(name, createStore) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3347 |
if (stores[name]) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3348 |
// eslint-disable-next-line no-console |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3349 |
console.error('Store "' + name + '" is already registered.'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3350 |
return stores[name]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3351 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3352 |
const store = createStore(); |
19 | 3353 |
if (typeof store.getSelectors !== 'function') { |
3354 |
throw new TypeError('store.getSelectors must be a function'); |
|
3355 |
} |
|
3356 |
if (typeof store.getActions !== 'function') { |
|
3357 |
throw new TypeError('store.getActions must be a function'); |
|
16 | 3358 |
} |
19 | 3359 |
if (typeof store.subscribe !== 'function') { |
3360 |
throw new TypeError('store.subscribe must be a function'); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3361 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3362 |
// The emitter is used to keep track of active listeners when the registry |
19 | 3363 |
// get paused, that way, when resumed we should be able to call all these |
3364 |
// pending listeners. |
|
3365 |
store.emitter = createEmitter(); |
|
3366 |
const currentSubscribe = store.subscribe; |
|
3367 |
store.subscribe = listener => { |
|
3368 |
const unsubscribeFromEmitter = store.emitter.subscribe(listener); |
|
3369 |
const unsubscribeFromStore = currentSubscribe(() => { |
|
3370 |
if (store.emitter.isPaused) { |
|
3371 |
store.emitter.emit(); |
|
3372 |
return; |
|
3373 |
} |
|
3374 |
listener(); |
|
3375 |
}); |
|
3376 |
return () => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3377 |
unsubscribeFromStore?.(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3378 |
unsubscribeFromEmitter?.(); |
19 | 3379 |
}; |
3380 |
}; |
|
3381 |
stores[name] = store; |
|
3382 |
store.subscribe(globalListener); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3383 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3384 |
// Copy private actions and selectors from the parent store. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3385 |
if (parent) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3386 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3387 |
unlock(store.store).registerPrivateActions(unlock(parent).privateActionsOf(name)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3388 |
unlock(store.store).registerPrivateSelectors(unlock(parent).privateSelectorsOf(name)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3389 |
} catch (e) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3390 |
// unlock() throws if store.store was not locked. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3391 |
// The error indicates there's nothing to do here so let's |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3392 |
// ignore it. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3393 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3394 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3395 |
return store; |
16 | 3396 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3397 |
|
18 | 3398 |
/** |
19 | 3399 |
* Registers a new store given a store descriptor. |
18 | 3400 |
* |
19 | 3401 |
* @param {StoreDescriptor} store Store descriptor. |
18 | 3402 |
*/ |
3403 |
function register(store) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3404 |
registerStoreInstance(store.name, () => store.instantiate(registry)); |
19 | 3405 |
} |
3406 |
function registerGenericStore(name, store) { |
|
3407 |
external_wp_deprecated_default()('wp.data.registerGenericStore', { |
|
3408 |
since: '5.9', |
|
3409 |
alternative: 'wp.data.register( storeDescriptor )' |
|
3410 |
}); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3411 |
registerStoreInstance(name, () => store); |
19 | 3412 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3413 |
|
19 | 3414 |
/** |
3415 |
* Registers a standard `@wordpress/data` store. |
|
3416 |
* |
|
3417 |
* @param {string} storeName Unique namespace identifier. |
|
3418 |
* @param {Object} options Store description (reducer, actions, selectors, resolvers). |
|
3419 |
* |
|
3420 |
* @return {Object} Registered store object. |
|
3421 |
*/ |
|
3422 |
function registerStore(storeName, options) { |
|
3423 |
if (!options.reducer) { |
|
3424 |
throw new TypeError('Must specify store reducer'); |
|
3425 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3426 |
const store = registerStoreInstance(storeName, () => createReduxStore(storeName, options).instantiate(registry)); |
19 | 3427 |
return store.store; |
18 | 3428 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3429 |
function batch(callback) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3430 |
// If we're already batching, just call the callback. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3431 |
if (emitter.isPaused) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3432 |
callback(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3433 |
return; |
18 | 3434 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3435 |
emitter.pause(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3436 |
Object.values(stores).forEach(store => store.emitter.pause()); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3437 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3438 |
callback(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3439 |
} finally { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3440 |
emitter.resume(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3441 |
Object.values(stores).forEach(store => store.emitter.resume()); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3442 |
} |
19 | 3443 |
} |
18 | 3444 |
let registry = { |
19 | 3445 |
batch, |
18 | 3446 |
stores, |
16 | 3447 |
namespaces: stores, |
3448 |
// TODO: Deprecate/remove this. |
|
18 | 3449 |
subscribe, |
3450 |
select, |
|
3451 |
resolveSelect, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3452 |
suspendSelect, |
18 | 3453 |
dispatch, |
3454 |
use, |
|
3455 |
register, |
|
19 | 3456 |
registerGenericStore, |
3457 |
registerStore, |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3458 |
__unstableMarkListeningStores |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3459 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3460 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3461 |
// |
16 | 3462 |
// TODO: |
3463 |
// This function will be deprecated as soon as it is no longer internally referenced. |
|
3464 |
function use(plugin, options) { |
|
19 | 3465 |
if (!plugin) { |
3466 |
return; |
|
3467 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3468 |
registry = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3469 |
...registry, |
18 | 3470 |
...plugin(registry, options) |
3471 |
}; |
|
16 | 3472 |
return registry; |
3473 |
} |
|
19 | 3474 |
registry.register(store); |
3475 |
for (const [name, config] of Object.entries(storeConfigs)) { |
|
3476 |
registry.register(createReduxStore(name, config)); |
|
3477 |
} |
|
16 | 3478 |
if (parent) { |
3479 |
parent.subscribe(globalListener); |
|
3480 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3481 |
const registryWithPlugins = withPlugins(registry); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3482 |
lock(registryWithPlugins, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3483 |
privateActionsOf: name => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3484 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3485 |
return unlock(stores[name].store).privateActions; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3486 |
} catch (e) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3487 |
// unlock() throws an error the store was not locked – this means |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3488 |
// there no private actions are available |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3489 |
return {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3490 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3491 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3492 |
privateSelectorsOf: name => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3493 |
try { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3494 |
return unlock(stores[name].store).privateSelectors; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3495 |
} catch (e) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3496 |
return {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3497 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3498 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3499 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3500 |
return registryWithPlugins; |
16 | 3501 |
} |
3502 |
||
19 | 3503 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js |
16 | 3504 |
/** |
3505 |
* Internal dependencies |
|
3506 |
*/ |
|
3507 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3508 |
/* harmony default export */ const default_registry = (createRegistry()); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3509 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3510 |
;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3511 |
/*! |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3512 |
* is-plain-object <https://github.com/jonschlinkert/is-plain-object> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3513 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3514 |
* Copyright (c) 2014-2017, Jon Schlinkert. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3515 |
* Released under the MIT License. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3516 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3517 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3518 |
function is_plain_object_isObject(o) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3519 |
return Object.prototype.toString.call(o) === '[object Object]'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3520 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3521 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3522 |
function is_plain_object_isPlainObject(o) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3523 |
var ctor,prot; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3524 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3525 |
if (is_plain_object_isObject(o) === false) return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3526 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3527 |
// If has modified constructor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3528 |
ctor = o.constructor; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3529 |
if (ctor === undefined) return true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3530 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3531 |
// If has modified prototype |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3532 |
prot = ctor.prototype; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3533 |
if (is_plain_object_isObject(prot) === false) return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3534 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3535 |
// If constructor does not have an Object-specific method |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3536 |
if (prot.hasOwnProperty('isPrototypeOf') === false) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3537 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3538 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3539 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3540 |
// Most likely a plain Object |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3541 |
return true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3542 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3543 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3544 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3545 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3546 |
// EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3547 |
var cjs = __webpack_require__(66); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3548 |
var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs); |
19 | 3549 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js |
18 | 3550 |
let objectStorage; |
3551 |
const storage = { |
|
3552 |
getItem(key) { |
|
16 | 3553 |
if (!objectStorage || !objectStorage[key]) { |
3554 |
return null; |
|
3555 |
} |
|
3556 |
return objectStorage[key]; |
|
3557 |
}, |
|
18 | 3558 |
setItem(key, value) { |
16 | 3559 |
if (!objectStorage) { |
18 | 3560 |
storage.clear(); |
16 | 3561 |
} |
3562 |
objectStorage[key] = String(value); |
|
3563 |
}, |
|
18 | 3564 |
clear() { |
16 | 3565 |
objectStorage = Object.create(null); |
3566 |
} |
|
3567 |
}; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3568 |
/* harmony default export */ const object = (storage); |
16 | 3569 |
|
19 | 3570 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js |
16 | 3571 |
/** |
3572 |
* Internal dependencies |
|
3573 |
*/ |
|
3574 |
||
18 | 3575 |
let default_storage; |
16 | 3576 |
try { |
3577 |
// Private Browsing in Safari 10 and earlier will throw an error when |
|
3578 |
// attempting to set into localStorage. The test here is intentional in |
|
3579 |
// causing a thrown error as condition for using fallback object storage. |
|
3580 |
default_storage = window.localStorage; |
|
3581 |
default_storage.setItem('__wpDataTestLocalStorage', ''); |
|
3582 |
default_storage.removeItem('__wpDataTestLocalStorage'); |
|
3583 |
} catch (error) { |
|
3584 |
default_storage = object; |
|
3585 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3586 |
/* harmony default export */ const storage_default = (default_storage); |
16 | 3587 |
|
19 | 3588 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js |
16 | 3589 |
/** |
3590 |
* External dependencies |
|
3591 |
*/ |
|
3592 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3593 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3594 |
|
16 | 3595 |
/** |
3596 |
* Internal dependencies |
|
3597 |
*/ |
|
3598 |
||
3599 |
||
3600 |
||
3601 |
/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */ |
|
3602 |
||
3603 |
/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */ |
|
3604 |
||
3605 |
/** |
|
3606 |
* @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options. |
|
3607 |
* |
|
3608 |
* @property {Storage} storage Persistent storage implementation. This must |
|
3609 |
* at least implement `getItem` and `setItem` of |
|
3610 |
* the Web Storage API. |
|
3611 |
* @property {string} storageKey Key on which to set in persistent storage. |
|
3612 |
*/ |
|
3613 |
||
3614 |
/** |
|
3615 |
* Default plugin storage. |
|
3616 |
* |
|
3617 |
* @type {Storage} |
|
3618 |
*/ |
|
18 | 3619 |
const DEFAULT_STORAGE = storage_default; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3620 |
|
16 | 3621 |
/** |
3622 |
* Default plugin storage key. |
|
3623 |
* |
|
3624 |
* @type {string} |
|
3625 |
*/ |
|
18 | 3626 |
const DEFAULT_STORAGE_KEY = 'WP_DATA'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3627 |
|
16 | 3628 |
/** |
3629 |
* Higher-order reducer which invokes the original reducer only if state is |
|
3630 |
* inequal from that of the action's `nextState` property, otherwise returning |
|
3631 |
* the original state reference. |
|
3632 |
* |
|
3633 |
* @param {Function} reducer Original reducer. |
|
3634 |
* |
|
3635 |
* @return {Function} Enhanced reducer. |
|
3636 |
*/ |
|
18 | 3637 |
const withLazySameState = reducer => (state, action) => { |
3638 |
if (action.nextState === state) { |
|
3639 |
return state; |
|
3640 |
} |
|
3641 |
return reducer(state, action); |
|
16 | 3642 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3643 |
|
16 | 3644 |
/** |
3645 |
* Creates a persistence interface, exposing getter and setter methods (`get` |
|
3646 |
* and `set` respectively). |
|
3647 |
* |
|
3648 |
* @param {WPDataPersistencePluginOptions} options Plugin options. |
|
3649 |
* |
|
3650 |
* @return {Object} Persistence interface. |
|
3651 |
*/ |
|
3652 |
function createPersistenceInterface(options) { |
|
18 | 3653 |
const { |
3654 |
storage = DEFAULT_STORAGE, |
|
3655 |
storageKey = DEFAULT_STORAGE_KEY |
|
3656 |
} = options; |
|
3657 |
let data; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3658 |
|
16 | 3659 |
/** |
3660 |
* Returns the persisted data as an object, defaulting to an empty object. |
|
3661 |
* |
|
3662 |
* @return {Object} Persisted data. |
|
3663 |
*/ |
|
3664 |
function getData() { |
|
3665 |
if (data === undefined) { |
|
3666 |
// If unset, getItem is expected to return null. Fall back to |
|
3667 |
// empty object. |
|
18 | 3668 |
const persisted = storage.getItem(storageKey); |
16 | 3669 |
if (persisted === null) { |
3670 |
data = {}; |
|
3671 |
} else { |
|
3672 |
try { |
|
3673 |
data = JSON.parse(persisted); |
|
3674 |
} catch (error) { |
|
3675 |
// Similarly, should any error be thrown during parse of |
|
3676 |
// the string (malformed JSON), fall back to empty object. |
|
3677 |
data = {}; |
|
3678 |
} |
|
3679 |
} |
|
3680 |
} |
|
3681 |
return data; |
|
3682 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3683 |
|
16 | 3684 |
/** |
3685 |
* Merges an updated reducer state into the persisted data. |
|
3686 |
* |
|
3687 |
* @param {string} key Key to update. |
|
3688 |
* @param {*} value Updated value. |
|
3689 |
*/ |
|
3690 |
function setData(key, value) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3691 |
data = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3692 |
...data, |
18 | 3693 |
[key]: value |
3694 |
}; |
|
16 | 3695 |
storage.setItem(storageKey, JSON.stringify(data)); |
3696 |
} |
|
3697 |
return { |
|
3698 |
get: getData, |
|
3699 |
set: setData |
|
3700 |
}; |
|
3701 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3702 |
|
16 | 3703 |
/** |
3704 |
* Data plugin to persist store state into a single storage key. |
|
3705 |
* |
|
3706 |
* @param {WPDataRegistry} registry Data registry. |
|
3707 |
* @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options. |
|
3708 |
* |
|
3709 |
* @return {WPDataPlugin} Data plugin. |
|
3710 |
*/ |
|
3711 |
function persistencePlugin(registry, pluginOptions) { |
|
18 | 3712 |
const persistence = createPersistenceInterface(pluginOptions); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3713 |
|
16 | 3714 |
/** |
3715 |
* Creates an enhanced store dispatch function, triggering the state of the |
|
18 | 3716 |
* given store name to be persisted when changed. |
16 | 3717 |
* |
18 | 3718 |
* @param {Function} getState Function which returns current state. |
3719 |
* @param {string} storeName Store name. |
|
3720 |
* @param {?Array<string>} keys Optional subset of keys to save. |
|
16 | 3721 |
* |
3722 |
* @return {Function} Enhanced dispatch function. |
|
3723 |
*/ |
|
18 | 3724 |
function createPersistOnChange(getState, storeName, keys) { |
3725 |
let getPersistedState; |
|
16 | 3726 |
if (Array.isArray(keys)) { |
3727 |
// Given keys, the persisted state should by produced as an object |
|
3728 |
// of the subset of keys. This implementation uses combineReducers |
|
3729 |
// to leverage its behavior of returning the same object when none |
|
3730 |
// of the property values changes. This allows a strict reference |
|
3731 |
// equality to bypass a persistence set on an unchanging state. |
|
18 | 3732 |
const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, { |
3733 |
[key]: (state, action) => action.nextState[key] |
|
3734 |
}), {}); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3735 |
getPersistedState = withLazySameState(build_module_combineReducers(reducers)); |
16 | 3736 |
} else { |
18 | 3737 |
getPersistedState = (state, action) => action.nextState; |
16 | 3738 |
} |
18 | 3739 |
let lastState = getPersistedState(undefined, { |
16 | 3740 |
nextState: getState() |
3741 |
}); |
|
18 | 3742 |
return () => { |
3743 |
const state = getPersistedState(lastState, { |
|
16 | 3744 |
nextState: getState() |
3745 |
}); |
|
3746 |
if (state !== lastState) { |
|
18 | 3747 |
persistence.set(storeName, state); |
16 | 3748 |
lastState = state; |
3749 |
} |
|
3750 |
}; |
|
3751 |
} |
|
3752 |
return { |
|
18 | 3753 |
registerStore(storeName, options) { |
16 | 3754 |
if (!options.persist) { |
18 | 3755 |
return registry.registerStore(storeName, options); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3756 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3757 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3758 |
// Load from persistence to use as initial state. |
18 | 3759 |
const persistedState = persistence.get()[storeName]; |
16 | 3760 |
if (persistedState !== undefined) { |
18 | 3761 |
let initialState = options.reducer(options.initialState, { |
16 | 3762 |
type: '@@WP/PERSISTENCE_RESTORE' |
3763 |
}); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3764 |
if (is_plain_object_isPlainObject(initialState) && is_plain_object_isPlainObject(persistedState)) { |
16 | 3765 |
// If state is an object, ensure that: |
3766 |
// - Other keys are left intact when persisting only a |
|
3767 |
// subset of keys. |
|
3768 |
// - New keys in what would otherwise be used as initial |
|
3769 |
// state are deeply merged as base for persisted value. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3770 |
initialState = cjs_default()(initialState, persistedState, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3771 |
isMergeableObject: is_plain_object_isPlainObject |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3772 |
}); |
16 | 3773 |
} else { |
3774 |
// If there is a mismatch in object-likeness of default |
|
3775 |
// initial or persisted state, defer to persisted value. |
|
3776 |
initialState = persistedState; |
|
3777 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3778 |
options = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3779 |
...options, |
18 | 3780 |
initialState |
3781 |
}; |
|
16 | 3782 |
} |
18 | 3783 |
const store = registry.registerStore(storeName, options); |
3784 |
store.subscribe(createPersistOnChange(store.getState, storeName, options.persist)); |
|
16 | 3785 |
return store; |
3786 |
} |
|
3787 |
}; |
|
3788 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3789 |
persistencePlugin.__unstableMigrate = () => {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3790 |
/* harmony default export */ const persistence = (persistencePlugin); |
19 | 3791 |
|
3792 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js |
|
3793 |
||
3794 |
||
3795 |
;// CONCATENATED MODULE: external ["wp","priorityQueue"] |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3796 |
const external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3797 |
;// CONCATENATED MODULE: external ["wp","element"] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3798 |
const external_wp_element_namespaceObject = window["wp"]["element"]; |
19 | 3799 |
;// CONCATENATED MODULE: external ["wp","isShallowEqual"] |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3800 |
const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; |
19 | 3801 |
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); |
3802 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js |
|
16 | 3803 |
/** |
3804 |
* WordPress dependencies |
|
3805 |
*/ |
|
3806 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3807 |
|
16 | 3808 |
/** |
3809 |
* Internal dependencies |
|
3810 |
*/ |
|
3811 |
||
19 | 3812 |
const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry); |
18 | 3813 |
const { |
3814 |
Consumer, |
|
3815 |
Provider |
|
3816 |
} = Context; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3817 |
|
16 | 3818 |
/** |
3819 |
* A custom react Context consumer exposing the provided `registry` to |
|
3820 |
* children components. Used along with the RegistryProvider. |
|
3821 |
* |
|
3822 |
* You can read more about the react context api here: |
|
3823 |
* https://reactjs.org/docs/context.html#contextprovider |
|
3824 |
* |
|
3825 |
* @example |
|
3826 |
* ```js |
|
18 | 3827 |
* import { |
16 | 3828 |
* RegistryProvider, |
3829 |
* RegistryConsumer, |
|
3830 |
* createRegistry |
|
18 | 3831 |
* } from '@wordpress/data'; |
16 | 3832 |
* |
3833 |
* const registry = createRegistry( {} ); |
|
3834 |
* |
|
3835 |
* const App = ( { props } ) => { |
|
3836 |
* return <RegistryProvider value={ registry }> |
|
3837 |
* <div>Hello There</div> |
|
3838 |
* <RegistryConsumer> |
|
3839 |
* { ( registry ) => ( |
|
3840 |
* <ComponentUsingRegistry |
|
3841 |
* { ...props } |
|
3842 |
* registry={ registry } |
|
3843 |
* ) } |
|
3844 |
* </RegistryConsumer> |
|
3845 |
* </RegistryProvider> |
|
3846 |
* } |
|
3847 |
* ``` |
|
3848 |
*/ |
|
18 | 3849 |
const RegistryConsumer = Consumer; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3850 |
|
16 | 3851 |
/** |
3852 |
* A custom Context provider for exposing the provided `registry` to children |
|
3853 |
* components via a consumer. |
|
3854 |
* |
|
3855 |
* See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for |
|
3856 |
* example. |
|
3857 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3858 |
/* harmony default export */ const context = (Provider); |
16 | 3859 |
|
19 | 3860 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js |
16 | 3861 |
/** |
3862 |
* WordPress dependencies |
|
3863 |
*/ |
|
3864 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3865 |
|
16 | 3866 |
/** |
3867 |
* Internal dependencies |
|
3868 |
*/ |
|
3869 |
||
3870 |
||
3871 |
/** |
|
3872 |
* A custom react hook exposing the registry context for use. |
|
3873 |
* |
|
3874 |
* This exposes the `registry` value provided via the |
|
3875 |
* <a href="#RegistryProvider">Registry Provider</a> to a component implementing |
|
3876 |
* this hook. |
|
3877 |
* |
|
3878 |
* It acts similarly to the `useContext` react hook. |
|
3879 |
* |
|
3880 |
* Note: Generally speaking, `useRegistry` is a low level hook that in most cases |
|
18 | 3881 |
* won't be needed for implementation. Most interactions with the `@wordpress/data` |
3882 |
* API can be performed via the `useSelect` hook, or the `withSelect` and |
|
16 | 3883 |
* `withDispatch` higher order components. |
3884 |
* |
|
3885 |
* @example |
|
3886 |
* ```js |
|
18 | 3887 |
* import { |
16 | 3888 |
* RegistryProvider, |
3889 |
* createRegistry, |
|
3890 |
* useRegistry, |
|
18 | 3891 |
* } from '@wordpress/data'; |
16 | 3892 |
* |
3893 |
* const registry = createRegistry( {} ); |
|
3894 |
* |
|
3895 |
* const SomeChildUsingRegistry = ( props ) => { |
|
19 | 3896 |
* const registry = useRegistry(); |
16 | 3897 |
* // ...logic implementing the registry in other react hooks. |
3898 |
* }; |
|
3899 |
* |
|
3900 |
* |
|
3901 |
* const ParentProvidingRegistry = ( props ) => { |
|
3902 |
* return <RegistryProvider value={ registry }> |
|
3903 |
* <SomeChildUsingRegistry { ...props } /> |
|
3904 |
* </RegistryProvider> |
|
3905 |
* }; |
|
3906 |
* ``` |
|
3907 |
* |
|
3908 |
* @return {Function} A custom react hook exposing the registry context value. |
|
3909 |
*/ |
|
3910 |
function useRegistry() { |
|
19 | 3911 |
return (0,external_wp_element_namespaceObject.useContext)(Context); |
16 | 3912 |
} |
3913 |
||
19 | 3914 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js |
16 | 3915 |
/** |
3916 |
* WordPress dependencies |
|
3917 |
*/ |
|
3918 |
||
19 | 3919 |
const context_Context = (0,external_wp_element_namespaceObject.createContext)(false); |
18 | 3920 |
const { |
3921 |
Consumer: context_Consumer, |
|
3922 |
Provider: context_Provider |
|
3923 |
} = context_Context; |
|
19 | 3924 |
const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer)); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3925 |
|
16 | 3926 |
/** |
3927 |
* Context Provider Component used to switch the data module component rerendering |
|
3928 |
* between Sync and Async modes. |
|
3929 |
* |
|
3930 |
* @example |
|
3931 |
* |
|
3932 |
* ```js |
|
3933 |
* import { useSelect, AsyncModeProvider } from '@wordpress/data'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3934 |
* import { store as blockEditorStore } from '@wordpress/block-editor'; |
16 | 3935 |
* |
3936 |
* function BlockCount() { |
|
3937 |
* const count = useSelect( ( select ) => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3938 |
* return select( blockEditorStore ).getBlockCount() |
16 | 3939 |
* }, [] ); |
3940 |
* |
|
3941 |
* return count; |
|
3942 |
* } |
|
3943 |
* |
|
3944 |
* function App() { |
|
3945 |
* return ( |
|
3946 |
* <AsyncModeProvider value={ true }> |
|
3947 |
* <BlockCount /> |
|
3948 |
* </AsyncModeProvider> |
|
3949 |
* ); |
|
3950 |
* } |
|
3951 |
* ``` |
|
3952 |
* |
|
3953 |
* In this example, the BlockCount component is rerendered asynchronously. |
|
3954 |
* It means if a more critical task is being performed (like typing in an input), |
|
3955 |
* the rerendering is delayed until the browser becomes IDLE. |
|
3956 |
* It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. |
|
3957 |
* |
|
19 | 3958 |
* @param {boolean} props.value Enable Async Mode. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3959 |
* @return {Component} The component to be rendered. |
16 | 3960 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3961 |
/* harmony default export */ const async_mode_provider_context = (context_Provider); |
16 | 3962 |
|
19 | 3963 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js |
16 | 3964 |
/** |
3965 |
* WordPress dependencies |
|
3966 |
*/ |
|
3967 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3968 |
|
16 | 3969 |
/** |
3970 |
* Internal dependencies |
|
3971 |
*/ |
|
3972 |
||
3973 |
function useAsyncMode() { |
|
19 | 3974 |
return (0,external_wp_element_namespaceObject.useContext)(context_Context); |
16 | 3975 |
} |
3976 |
||
19 | 3977 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js |
16 | 3978 |
/** |
3979 |
* WordPress dependencies |
|
3980 |
*/ |
|
3981 |
||
3982 |
||
3983 |
||
3984 |
||
3985 |
/** |
|
3986 |
* Internal dependencies |
|
3987 |
*/ |
|
3988 |
||
3989 |
||
19 | 3990 |
const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3991 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3992 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3993 |
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3994 |
* @template {import('../../types').AnyConfig} C |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3995 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3996 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3997 |
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3998 |
* @template State |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3999 |
* @template {Record<string,import('../../types').ActionCreator>} Actions |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4000 |
* @template Selectors |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4001 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4002 |
/** @typedef {import('../../types').MapSelect} MapSelect */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4003 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4004 |
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4005 |
* @template {MapSelect|StoreDescriptor<any>} T |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4006 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4007 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4008 |
function Store(registry, suspense) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4009 |
const select = suspense ? registry.suspendSelect : registry.select; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4010 |
const queueContext = {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4011 |
let lastMapSelect; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4012 |
let lastMapResult; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4013 |
let lastMapResultValid = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4014 |
let lastIsAsync; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4015 |
let subscriber; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4016 |
let didWarnUnstableReference; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4017 |
const storeStatesOnMount = new Map(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4018 |
function getStoreState(name) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4019 |
var _registry$stores$name; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4020 |
// If there's no store property (custom generic store), return an empty |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4021 |
// object. When comparing the state, the empty objects will cause the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4022 |
// equality check to fail, setting `lastMapResultValid` to false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4023 |
return (_registry$stores$name = registry.stores[name]?.store?.getState?.()) !== null && _registry$stores$name !== void 0 ? _registry$stores$name : {}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4024 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4025 |
const createSubscriber = stores => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4026 |
// The set of stores the `subscribe` function is supposed to subscribe to. Here it is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4027 |
// initialized, and then the `updateStores` function can add new stores to it. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4028 |
const activeStores = [...stores]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4029 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4030 |
// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4031 |
// be called multiple times to establish multiple subscriptions. That's why we need to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4032 |
// keep a set of active subscriptions; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4033 |
const activeSubscriptions = new Set(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4034 |
function subscribe(listener) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4035 |
// Maybe invalidate the value right after subscription was created. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4036 |
// React will call `getValue` after subscribing, to detect store |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4037 |
// updates that happened in the interval between the `getValue` call |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4038 |
// during render and creating the subscription, which is slightly |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4039 |
// delayed. We need to ensure that this second `getValue` call will |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4040 |
// compute a fresh value only if any of the store states have |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4041 |
// changed in the meantime. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4042 |
if (lastMapResultValid) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4043 |
for (const name of activeStores) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4044 |
if (storeStatesOnMount.get(name) !== getStoreState(name)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4045 |
lastMapResultValid = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4046 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4047 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4048 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4049 |
storeStatesOnMount.clear(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4050 |
const onStoreChange = () => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4051 |
// Invalidate the value on store update, so that a fresh value is computed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4052 |
lastMapResultValid = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4053 |
listener(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4054 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4055 |
const onChange = () => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4056 |
if (lastIsAsync) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4057 |
renderQueue.add(queueContext, onStoreChange); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4058 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4059 |
onStoreChange(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4060 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4061 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4062 |
const unsubs = []; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4063 |
function subscribeStore(storeName) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4064 |
unsubs.push(registry.subscribe(onChange, storeName)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4065 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4066 |
for (const storeName of activeStores) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4067 |
subscribeStore(storeName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4068 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4069 |
activeSubscriptions.add(subscribeStore); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4070 |
return () => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4071 |
activeSubscriptions.delete(subscribeStore); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4072 |
for (const unsub of unsubs.values()) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4073 |
// The return value of the subscribe function could be undefined if the store is a custom generic store. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4074 |
unsub?.(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4075 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4076 |
// Cancel existing store updates that were already scheduled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4077 |
renderQueue.cancel(queueContext); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4078 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4079 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4080 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4081 |
// Check if `newStores` contains some stores we're not subscribed to yet, and add them. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4082 |
function updateStores(newStores) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4083 |
for (const newStore of newStores) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4084 |
if (activeStores.includes(newStore)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4085 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4086 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4087 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4088 |
// New `subscribe` calls will subscribe to `newStore`, too. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4089 |
activeStores.push(newStore); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4090 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4091 |
// Add `newStore` to existing subscriptions. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4092 |
for (const subscription of activeSubscriptions) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4093 |
subscription(newStore); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4094 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4095 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4096 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4097 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4098 |
subscribe, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4099 |
updateStores |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4100 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4101 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4102 |
return (mapSelect, isAsync) => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4103 |
function updateValue() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4104 |
// If the last value is valid, and the `mapSelect` callback hasn't changed, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4105 |
// then we can safely return the cached value. The value can change only on |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4106 |
// store update, and in that case value will be invalidated by the listener. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4107 |
if (lastMapResultValid && mapSelect === lastMapSelect) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4108 |
return lastMapResult; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4109 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4110 |
const listeningStores = { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4111 |
current: null |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4112 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4113 |
const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4114 |
if (false) {} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4115 |
if (!subscriber) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4116 |
for (const name of listeningStores.current) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4117 |
storeStatesOnMount.set(name, getStoreState(name)); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4118 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4119 |
subscriber = createSubscriber(listeningStores.current); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4120 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4121 |
subscriber.updateStores(listeningStores.current); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4122 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4123 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4124 |
// If the new value is shallow-equal to the old one, keep the old one so |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4125 |
// that we don't trigger unwanted updates that do a `===` check. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4126 |
if (!external_wp_isShallowEqual_default()(lastMapResult, mapResult)) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4127 |
lastMapResult = mapResult; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4128 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4129 |
lastMapSelect = mapSelect; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4130 |
lastMapResultValid = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4131 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4132 |
function getValue() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4133 |
// Update the value in case it's been invalidated or `mapSelect` has changed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4134 |
updateValue(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4135 |
return lastMapResult; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4136 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4137 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4138 |
// When transitioning from async to sync mode, cancel existing store updates |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4139 |
// that have been scheduled, and invalidate the value so that it's freshly |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4140 |
// computed. It might have been changed by the update we just cancelled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4141 |
if (lastIsAsync && !isAsync) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4142 |
lastMapResultValid = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4143 |
renderQueue.cancel(queueContext); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4144 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4145 |
updateValue(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4146 |
lastIsAsync = isAsync; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4147 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4148 |
// Return a pair of functions that can be passed to `useSyncExternalStore`. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4149 |
return { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4150 |
subscribe: subscriber.subscribe, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4151 |
getValue |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4152 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4153 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4154 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4155 |
function useStaticSelect(storeName) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4156 |
return useRegistry().select(storeName); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4157 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4158 |
function useMappingSelect(suspense, mapSelect, deps) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4159 |
const registry = useRegistry(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4160 |
const isAsync = useAsyncMode(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4161 |
const store = (0,external_wp_element_namespaceObject.useMemo)(() => Store(registry, suspense), [registry, suspense]); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4162 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4163 |
// These are "pass-through" dependencies from the parent hook, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4164 |
// and the parent should catch any hook rule violations. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4165 |
// eslint-disable-next-line react-hooks/exhaustive-deps |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4166 |
const selector = (0,external_wp_element_namespaceObject.useCallback)(mapSelect, deps); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4167 |
const { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4168 |
subscribe, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4169 |
getValue |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4170 |
} = store(selector, isAsync); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4171 |
const result = (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4172 |
(0,external_wp_element_namespaceObject.useDebugValue)(result); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4173 |
return result; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4174 |
} |
18 | 4175 |
|
16 | 4176 |
/** |
4177 |
* Custom react hook for retrieving props from registered selectors. |
|
4178 |
* |
|
4179 |
* In general, this custom React hook follows the |
|
4180 |
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html). |
|
4181 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4182 |
* @template {MapSelect | StoreDescriptor<any>} T |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4183 |
* @param {T} mapSelect Function called on every state change. The returned value is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4184 |
* exposed to the component implementing this hook. The function |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4185 |
* receives the `registry.select` method on the first argument |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4186 |
* and the `registry` on the second argument. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4187 |
* When a store key is passed, all selectors for the store will be |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4188 |
* returned. This is only meant for usage of these selectors in event |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4189 |
* callbacks, not for data needed to create the element tree. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4190 |
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4191 |
* invoked on every state change unless the dependencies change. |
16 | 4192 |
* |
4193 |
* @example |
|
4194 |
* ```js |
|
18 | 4195 |
* import { useSelect } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4196 |
* import { store as myCustomStore } from 'my-custom-store'; |
16 | 4197 |
* |
4198 |
* function HammerPriceDisplay( { currency } ) { |
|
4199 |
* const price = useSelect( ( select ) => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4200 |
* return select( myCustomStore ).getPrice( 'hammer', currency ); |
16 | 4201 |
* }, [ currency ] ); |
4202 |
* return new Intl.NumberFormat( 'en-US', { |
|
4203 |
* style: 'currency', |
|
4204 |
* currency, |
|
4205 |
* } ).format( price ); |
|
4206 |
* } |
|
4207 |
* |
|
4208 |
* // Rendered in the application: |
|
4209 |
* // <HammerPriceDisplay currency="USD" /> |
|
4210 |
* ``` |
|
4211 |
* |
|
4212 |
* In the above example, when `HammerPriceDisplay` is rendered into an |
|
4213 |
* application, the price will be retrieved from the store state using the |
|
4214 |
* `mapSelect` callback on `useSelect`. If the currency prop changes then |
|
4215 |
* any price in the state for that currency is retrieved. If the currency prop |
|
4216 |
* doesn't change and other props are passed in that do change, the price will |
|
4217 |
* not change because the dependency is just the currency. |
|
4218 |
* |
|
18 | 4219 |
* When data is only used in an event callback, the data should not be retrieved |
4220 |
* on render, so it may be useful to get the selectors function instead. |
|
4221 |
* |
|
4222 |
* **Don't use `useSelect` this way when calling the selectors in the render |
|
4223 |
* function because your component won't re-render on a data change.** |
|
4224 |
* |
|
4225 |
* ```js |
|
4226 |
* import { useSelect } from '@wordpress/data'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4227 |
* import { store as myCustomStore } from 'my-custom-store'; |
18 | 4228 |
* |
4229 |
* function Paste( { children } ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4230 |
* const { getSettings } = useSelect( myCustomStore ); |
18 | 4231 |
* function onPaste() { |
4232 |
* // Do something with the settings. |
|
4233 |
* const settings = getSettings(); |
|
4234 |
* } |
|
4235 |
* return <div onPaste={ onPaste }>{ children }</div>; |
|
4236 |
* } |
|
4237 |
* ``` |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4238 |
* @return {UseSelectReturn<T>} A custom react hook. |
16 | 4239 |
*/ |
19 | 4240 |
function useSelect(mapSelect, deps) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4241 |
// On initial call, on mount, determine the mode of this `useSelect` call |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4242 |
// and then never allow it to change on subsequent updates. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4243 |
const staticSelectMode = typeof mapSelect !== 'function'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4244 |
const staticSelectModeRef = (0,external_wp_element_namespaceObject.useRef)(staticSelectMode); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4245 |
if (staticSelectMode !== staticSelectModeRef.current) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4246 |
const prevMode = staticSelectModeRef.current ? 'static' : 'mapping'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4247 |
const nextMode = staticSelectMode ? 'static' : 'mapping'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4248 |
throw new Error(`Switching useSelect from ${prevMode} to ${nextMode} is not allowed`); |
18 | 4249 |
} |
4250 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4251 |
/* eslint-disable react-hooks/rules-of-hooks */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4252 |
// `staticSelectMode` is not allowed to change during the hook instance's, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4253 |
// lifetime, so the rules of hooks are not really violated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4254 |
return staticSelectMode ? useStaticSelect(mapSelect) : useMappingSelect(false, mapSelect, deps); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4255 |
/* eslint-enable react-hooks/rules-of-hooks */ |
16 | 4256 |
} |
4257 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4258 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4259 |
* A variant of the `useSelect` hook that has the same API, but is a compatible |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4260 |
* Suspense-enabled data source. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4261 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4262 |
* @template {MapSelect} T |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4263 |
* @param {T} mapSelect Function called on every state change. The |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4264 |
* returned value is exposed to the component |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4265 |
* using this hook. The function receives the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4266 |
* `registry.suspendSelect` method as the first |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4267 |
* argument and the `registry` as the second one. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4268 |
* @param {Array} deps A dependency array used to memoize the `mapSelect` |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4269 |
* so that the same `mapSelect` is invoked on every |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4270 |
* state change unless the dependencies change. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4271 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4272 |
* @throws {Promise} A suspense Promise that is thrown if any of the called |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4273 |
* selectors is in an unresolved state. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4274 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4275 |
* @return {ReturnType<T>} Data object returned by the `mapSelect` function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4276 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4277 |
function useSuspenseSelect(mapSelect, deps) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4278 |
return useMappingSelect(true, mapSelect, deps); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4279 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4280 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4281 |
;// CONCATENATED MODULE: external "ReactJSXRuntime" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4282 |
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
19 | 4283 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js |
16 | 4284 |
/** |
4285 |
* WordPress dependencies |
|
4286 |
*/ |
|
4287 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4288 |
|
16 | 4289 |
/** |
4290 |
* Internal dependencies |
|
4291 |
*/ |
|
4292 |
||
4293 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4294 |
/** @typedef {import('react').ComponentType} ComponentType */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4295 |
|
16 | 4296 |
/** |
4297 |
* Higher-order component used to inject state-derived props using registered |
|
4298 |
* selectors. |
|
4299 |
* |
|
4300 |
* @param {Function} mapSelectToProps Function called on every state change, |
|
19 | 4301 |
* expected to return object of props to |
4302 |
* merge with the component's own props. |
|
16 | 4303 |
* |
4304 |
* @example |
|
4305 |
* ```js |
|
18 | 4306 |
* import { withSelect } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4307 |
* import { store as myCustomStore } from 'my-custom-store'; |
18 | 4308 |
* |
16 | 4309 |
* function PriceDisplay( { price, currency } ) { |
4310 |
* return new Intl.NumberFormat( 'en-US', { |
|
4311 |
* style: 'currency', |
|
4312 |
* currency, |
|
4313 |
* } ).format( price ); |
|
4314 |
* } |
|
4315 |
* |
|
4316 |
* const HammerPriceDisplay = withSelect( ( select, ownProps ) => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4317 |
* const { getPrice } = select( myCustomStore ); |
16 | 4318 |
* const { currency } = ownProps; |
4319 |
* |
|
4320 |
* return { |
|
4321 |
* price: getPrice( 'hammer', currency ), |
|
4322 |
* }; |
|
4323 |
* } )( PriceDisplay ); |
|
4324 |
* |
|
4325 |
* // Rendered in the application: |
|
4326 |
* // |
|
4327 |
* // <HammerPriceDisplay currency="USD" /> |
|
4328 |
* ``` |
|
4329 |
* In the above example, when `HammerPriceDisplay` is rendered into an |
|
4330 |
* application, it will pass the price into the underlying `PriceDisplay` |
|
4331 |
* component and update automatically if the price of a hammer ever changes in |
|
4332 |
* the store. |
|
4333 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4334 |
* @return {ComponentType} Enhanced component with merged state data props. |
16 | 4335 |
*/ |
4336 |
||
19 | 4337 |
const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => { |
18 | 4338 |
const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); |
4339 |
const mergeProps = useSelect(mapSelect); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4340 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4341 |
...ownProps, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4342 |
...mergeProps |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4343 |
}); |
18 | 4344 |
}), 'withSelect'); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4345 |
/* harmony default export */ const with_select = (withSelect); |
16 | 4346 |
|
19 | 4347 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js |
16 | 4348 |
/** |
4349 |
* WordPress dependencies |
|
4350 |
*/ |
|
4351 |
||
4352 |
||
18 | 4353 |
|
16 | 4354 |
/** |
4355 |
* Internal dependencies |
|
4356 |
*/ |
|
4357 |
||
4358 |
||
4359 |
/** |
|
4360 |
* Custom react hook for returning aggregate dispatch actions using the provided |
|
4361 |
* dispatchMap. |
|
4362 |
* |
|
4363 |
* Currently this is an internal api only and is implemented by `withDispatch` |
|
4364 |
* |
|
19 | 4365 |
* @param {Function} dispatchMap Receives the `registry.dispatch` function as |
4366 |
* the first argument and the `registry` object |
|
4367 |
* as the second argument. Should return an |
|
4368 |
* object mapping props to functions. |
|
4369 |
* @param {Array} deps An array of dependencies for the hook. |
|
16 | 4370 |
* @return {Object} An object mapping props to functions created by the passed |
4371 |
* in dispatchMap. |
|
4372 |
*/ |
|
18 | 4373 |
const useDispatchWithMap = (dispatchMap, deps) => { |
4374 |
const registry = useRegistry(); |
|
19 | 4375 |
const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap); |
4376 |
(0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { |
|
16 | 4377 |
currentDispatchMap.current = dispatchMap; |
4378 |
}); |
|
19 | 4379 |
return (0,external_wp_element_namespaceObject.useMemo)(() => { |
18 | 4380 |
const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4381 |
return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => { |
16 | 4382 |
if (typeof dispatcher !== 'function') { |
4383 |
// eslint-disable-next-line no-console |
|
18 | 4384 |
console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`); |
16 | 4385 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4386 |
return [propName, (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args)]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4387 |
})); |
18 | 4388 |
}, [registry, ...deps]); |
16 | 4389 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4390 |
/* harmony default export */ const use_dispatch_with_map = (useDispatchWithMap); |
16 | 4391 |
|
19 | 4392 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js |
16 | 4393 |
/** |
4394 |
* WordPress dependencies |
|
4395 |
*/ |
|
4396 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4397 |
|
16 | 4398 |
/** |
4399 |
* Internal dependencies |
|
4400 |
*/ |
|
4401 |
||
4402 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4403 |
/** @typedef {import('react').ComponentType} ComponentType */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4404 |
|
16 | 4405 |
/** |
4406 |
* Higher-order component used to add dispatch props using registered action |
|
4407 |
* creators. |
|
4408 |
* |
|
4409 |
* @param {Function} mapDispatchToProps A function of returning an object of |
|
4410 |
* prop names where value is a |
|
4411 |
* dispatch-bound action creator, or a |
|
4412 |
* function to be called with the |
|
4413 |
* component's props and returning an |
|
4414 |
* action creator. |
|
4415 |
* |
|
4416 |
* @example |
|
4417 |
* ```jsx |
|
4418 |
* function Button( { onClick, children } ) { |
|
4419 |
* return <button type="button" onClick={ onClick }>{ children }</button>; |
|
4420 |
* } |
|
4421 |
* |
|
18 | 4422 |
* import { withDispatch } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4423 |
* import { store as myCustomStore } from 'my-custom-store'; |
16 | 4424 |
* |
4425 |
* const SaleButton = withDispatch( ( dispatch, ownProps ) => { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4426 |
* const { startSale } = dispatch( myCustomStore ); |
16 | 4427 |
* const { discountPercent } = ownProps; |
4428 |
* |
|
4429 |
* return { |
|
4430 |
* onClick() { |
|
4431 |
* startSale( discountPercent ); |
|
4432 |
* }, |
|
4433 |
* }; |
|
4434 |
* } )( Button ); |
|
4435 |
* |
|
4436 |
* // Rendered in the application: |
|
4437 |
* // |
|
4438 |
* // <SaleButton discountPercent="20">Start Sale!</SaleButton> |
|
4439 |
* ``` |
|
4440 |
* |
|
4441 |
* @example |
|
4442 |
* In the majority of cases, it will be sufficient to use only two first params |
|
4443 |
* passed to `mapDispatchToProps` as illustrated in the previous example. |
|
4444 |
* However, there might be some very advanced use cases where using the |
|
4445 |
* `registry` object might be used as a tool to optimize the performance of |
|
4446 |
* your component. Using `select` function from the registry might be useful |
|
4447 |
* when you need to fetch some dynamic data from the store at the time when the |
|
4448 |
* event is fired, but at the same time, you never use it to render your |
|
4449 |
* component. In such scenario, you can avoid using the `withSelect` higher |
|
4450 |
* order component to compute such prop, which might lead to unnecessary |
|
4451 |
* re-renders of your component caused by its frequent value change. |
|
4452 |
* Keep in mind, that `mapDispatchToProps` must return an object with functions |
|
4453 |
* only. |
|
4454 |
* |
|
4455 |
* ```jsx |
|
4456 |
* function Button( { onClick, children } ) { |
|
4457 |
* return <button type="button" onClick={ onClick }>{ children }</button>; |
|
4458 |
* } |
|
4459 |
* |
|
18 | 4460 |
* import { withDispatch } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4461 |
* import { store as myCustomStore } from 'my-custom-store'; |
16 | 4462 |
* |
4463 |
* const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => { |
|
4464 |
* // Stock number changes frequently. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4465 |
* const { getStockNumber } = select( myCustomStore ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4466 |
* const { startSale } = dispatch( myCustomStore ); |
16 | 4467 |
* return { |
4468 |
* onClick() { |
|
4469 |
* const discountPercent = getStockNumber() > 50 ? 10 : 20; |
|
4470 |
* startSale( discountPercent ); |
|
4471 |
* }, |
|
4472 |
* }; |
|
4473 |
* } )( Button ); |
|
4474 |
* |
|
4475 |
* // Rendered in the application: |
|
4476 |
* // |
|
4477 |
* // <SaleButton>Start Sale!</SaleButton> |
|
4478 |
* ``` |
|
4479 |
* |
|
4480 |
* _Note:_ It is important that the `mapDispatchToProps` function always |
|
4481 |
* returns an object with the same keys. For example, it should not contain |
|
4482 |
* conditions under which a different value would be returned. |
|
4483 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4484 |
* @return {ComponentType} Enhanced component with merged dispatcher props. |
16 | 4485 |
*/ |
4486 |
||
19 | 4487 |
const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => { |
18 | 4488 |
const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); |
4489 |
const dispatchProps = use_dispatch_with_map(mapDispatch, []); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4490 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4491 |
...ownProps, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4492 |
...dispatchProps |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4493 |
}); |
18 | 4494 |
}, 'withDispatch'); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4495 |
/* harmony default export */ const with_dispatch = (withDispatch); |
16 | 4496 |
|
19 | 4497 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js |
16 | 4498 |
/** |
4499 |
* WordPress dependencies |
|
4500 |
*/ |
|
4501 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4502 |
|
16 | 4503 |
/** |
4504 |
* Internal dependencies |
|
4505 |
*/ |
|
4506 |
||
4507 |
||
4508 |
/** |
|
4509 |
* Higher-order component which renders the original component with the current |
|
4510 |
* registry context passed as its `registry` prop. |
|
4511 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4512 |
* @param {Component} OriginalComponent Original component. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4513 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4514 |
* @return {Component} Enhanced component. |
16 | 4515 |
*/ |
4516 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4517 |
const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RegistryConsumer, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4518 |
children: registry => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4519 |
...props, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4520 |
registry: registry |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4521 |
}) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4522 |
}), 'withRegistry'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4523 |
/* harmony default export */ const with_registry = (withRegistry); |
16 | 4524 |
|
19 | 4525 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js |
16 | 4526 |
/** |
4527 |
* Internal dependencies |
|
4528 |
*/ |
|
4529 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4530 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4531 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4532 |
* @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4533 |
* @template {import('../../types').AnyConfig} StoreConfig |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4534 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4535 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4536 |
* @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4537 |
* @template StoreNameOrDescriptor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4538 |
*/ |
18 | 4539 |
|
16 | 4540 |
/** |
4541 |
* A custom react hook returning the current registry dispatch actions creators. |
|
4542 |
* |
|
4543 |
* Note: The component using this hook must be within the context of a |
|
4544 |
* RegistryProvider. |
|
4545 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4546 |
* @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4547 |
* @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4548 |
* store or its descriptor from which to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4549 |
* retrieve action creators. If not |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4550 |
* provided, the registry.dispatch |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4551 |
* function is returned instead. |
16 | 4552 |
* |
4553 |
* @example |
|
4554 |
* This illustrates a pattern where you may need to retrieve dynamic data from |
|
4555 |
* the server via the `useSelect` hook to use in combination with the dispatch |
|
4556 |
* action. |
|
4557 |
* |
|
4558 |
* ```jsx |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4559 |
* import { useCallback } from 'react'; |
18 | 4560 |
* import { useDispatch, useSelect } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4561 |
* import { store as myCustomStore } from 'my-custom-store'; |
16 | 4562 |
* |
4563 |
* function Button( { onClick, children } ) { |
|
4564 |
* return <button type="button" onClick={ onClick }>{ children }</button> |
|
4565 |
* } |
|
4566 |
* |
|
4567 |
* const SaleButton = ( { children } ) => { |
|
4568 |
* const { stockNumber } = useSelect( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4569 |
* ( select ) => select( myCustomStore ).getStockNumber(), |
16 | 4570 |
* [] |
4571 |
* ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4572 |
* const { startSale } = useDispatch( myCustomStore ); |
16 | 4573 |
* const onClick = useCallback( () => { |
4574 |
* const discountPercent = stockNumber > 50 ? 10: 20; |
|
4575 |
* startSale( discountPercent ); |
|
4576 |
* }, [ stockNumber ] ); |
|
4577 |
* return <Button onClick={ onClick }>{ children }</Button> |
|
4578 |
* } |
|
4579 |
* |
|
4580 |
* // Rendered somewhere in the application: |
|
4581 |
* // |
|
4582 |
* // <SaleButton>Start Sale!</SaleButton> |
|
4583 |
* ``` |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4584 |
* @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook. |
16 | 4585 |
*/ |
19 | 4586 |
const useDispatch = storeNameOrDescriptor => { |
18 | 4587 |
const { |
4588 |
dispatch |
|
4589 |
} = useRegistry(); |
|
19 | 4590 |
return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor); |
16 | 4591 |
}; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4592 |
/* harmony default export */ const use_dispatch = (useDispatch); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4593 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4594 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/dispatch.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4595 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4596 |
* Internal dependencies |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4597 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4598 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4599 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4600 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4601 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4602 |
* Given a store descriptor, returns an object of the store's action creators. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4603 |
* Calling an action creator will cause it to be dispatched, updating the state value accordingly. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4604 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4605 |
* Note: Action creators returned by the dispatch will return a promise when |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4606 |
* they are called. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4607 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4608 |
* @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4609 |
* the store name is also supported. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4610 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4611 |
* @example |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4612 |
* ```js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4613 |
* import { dispatch } from '@wordpress/data'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4614 |
* import { store as myCustomStore } from 'my-custom-store'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4615 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4616 |
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4617 |
* ``` |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4618 |
* @return Object containing the action creators. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4619 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4620 |
function dispatch_dispatch(storeNameOrDescriptor) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4621 |
return default_registry.dispatch(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4622 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4623 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4624 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/select.js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4625 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4626 |
* Internal dependencies |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4627 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4628 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4629 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4630 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4631 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4632 |
* Given a store descriptor, returns an object of the store's selectors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4633 |
* The selector functions are been pre-bound to pass the current state automatically. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4634 |
* As a consumer, you need only pass arguments of the selector, if applicable. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4635 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4636 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4637 |
* @param storeNameOrDescriptor The store descriptor. The legacy calling convention |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4638 |
* of passing the store name is also supported. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4639 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4640 |
* @example |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4641 |
* ```js |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4642 |
* import { select } from '@wordpress/data'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4643 |
* import { store as myCustomStore } from 'my-custom-store'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4644 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4645 |
* select( myCustomStore ).getPrice( 'hammer' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4646 |
* ``` |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4647 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4648 |
* @return Object containing the store's selectors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4649 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4650 |
function select_select(storeNameOrDescriptor) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4651 |
return default_registry.select(storeNameOrDescriptor); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4652 |
} |
16 | 4653 |
|
19 | 4654 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js |
16 | 4655 |
/** |
4656 |
* Internal dependencies |
|
4657 |
*/ |
|
4658 |
||
4659 |
||
4660 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4661 |
|
19 | 4662 |
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ |
18 | 4663 |
|
4664 |
||
4665 |
||
16 | 4666 |
|
4667 |
||
4668 |
||
4669 |
||
4670 |
||
4671 |
||
4672 |
||
4673 |
||
4674 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4675 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4676 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4677 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4678 |
|
16 | 4679 |
/** |
4680 |
* Object of available plugins to use with a registry. |
|
4681 |
* |
|
4682 |
* @see [use](#use) |
|
4683 |
* |
|
4684 |
* @type {Object} |
|
4685 |
*/ |
|
4686 |
||
4687 |
||
4688 |
/** |
|
4689 |
* The combineReducers helper function turns an object whose values are different |
|
4690 |
* reducing functions into a single reducing function you can pass to registerReducer. |
|
4691 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4692 |
* @type {import('./types').combineReducers} |
16 | 4693 |
* @param {Object} reducers An object whose values correspond to different reducing |
4694 |
* functions that need to be combined into one. |
|
4695 |
* |
|
4696 |
* @example |
|
4697 |
* ```js |
|
18 | 4698 |
* import { combineReducers, createReduxStore, register } from '@wordpress/data'; |
16 | 4699 |
* |
4700 |
* const prices = ( state = {}, action ) => { |
|
4701 |
* return action.type === 'SET_PRICE' ? |
|
4702 |
* { |
|
4703 |
* ...state, |
|
4704 |
* [ action.item ]: action.price, |
|
4705 |
* } : |
|
4706 |
* state; |
|
4707 |
* }; |
|
4708 |
* |
|
4709 |
* const discountPercent = ( state = 0, action ) => { |
|
4710 |
* return action.type === 'START_SALE' ? |
|
4711 |
* action.discountPercent : |
|
4712 |
* state; |
|
4713 |
* }; |
|
4714 |
* |
|
18 | 4715 |
* const store = createReduxStore( 'my-shop', { |
16 | 4716 |
* reducer: combineReducers( { |
4717 |
* prices, |
|
4718 |
* discountPercent, |
|
4719 |
* } ), |
|
4720 |
* } ); |
|
18 | 4721 |
* register( store ); |
16 | 4722 |
* ``` |
4723 |
* |
|
19 | 4724 |
* @return {Function} A reducer that invokes every reducer inside the reducers |
4725 |
* object, and constructs a state object with the same shape. |
|
16 | 4726 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4727 |
const build_module_combineReducers = combine_reducers_combineReducers; |
16 | 4728 |
|
4729 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4730 |
* Given a store descriptor, returns an object containing the store's selectors pre-bound to state |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4731 |
* so that you only need to supply additional arguments, and modified so that they return promises |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4732 |
* that resolve to their eventual values, after any resolvers have ran. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4733 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4734 |
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4735 |
* convention of passing the store name is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4736 |
* also supported. |
16 | 4737 |
* |
4738 |
* @example |
|
4739 |
* ```js |
|
18 | 4740 |
* import { resolveSelect } from '@wordpress/data'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4741 |
* import { store as myCustomStore } from 'my-custom-store'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4742 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4743 |
* resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log) |
16 | 4744 |
* ``` |
4745 |
* |
|
4746 |
* @return {Object} Object containing the store's promise-wrapped selectors. |
|
4747 |
*/ |
|
18 | 4748 |
const build_module_resolveSelect = default_registry.resolveSelect; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4749 |
|
16 | 4750 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4751 |
* Given a store descriptor, returns an object containing the store's selectors pre-bound to state |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4752 |
* so that you only need to supply additional arguments, and modified so that they throw promises |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4753 |
* in case the selector is not resolved yet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4754 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4755 |
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4756 |
* convention of passing the store name is |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4757 |
* also supported. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4758 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4759 |
* @return {Object} Object containing the store's suspense-wrapped selectors. |
16 | 4760 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4761 |
const suspendSelect = default_registry.suspendSelect; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4762 |
|
16 | 4763 |
/** |
4764 |
* Given a listener function, the function will be called any time the state value |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4765 |
* of one of the registered stores has changed. If you specify the optional |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4766 |
* `storeNameOrDescriptor` parameter, the listener function will be called only |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4767 |
* on updates on that one specific registered store. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4768 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4769 |
* This function returns an `unsubscribe` function used to stop the subscription. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4770 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4771 |
* @param {Function} listener Callback function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4772 |
* @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name. |
16 | 4773 |
* |
4774 |
* @example |
|
4775 |
* ```js |
|
18 | 4776 |
* import { subscribe } from '@wordpress/data'; |
16 | 4777 |
* |
4778 |
* const unsubscribe = subscribe( () => { |
|
4779 |
* // You could use this opportunity to test whether the derived result of a |
|
4780 |
* // selector has subsequently changed as the result of a state update. |
|
4781 |
* } ); |
|
4782 |
* |
|
4783 |
* // Later, if necessary... |
|
4784 |
* unsubscribe(); |
|
4785 |
* ``` |
|
4786 |
*/ |
|
19 | 4787 |
const subscribe = default_registry.subscribe; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4788 |
|
16 | 4789 |
/** |
19 | 4790 |
* Registers a generic store instance. |
4791 |
* |
|
4792 |
* @deprecated Use `register( storeDescriptor )` instead. |
|
4793 |
* |
|
4794 |
* @param {string} name Store registry name. |
|
4795 |
* @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`). |
|
16 | 4796 |
*/ |
19 | 4797 |
const registerGenericStore = default_registry.registerGenericStore; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4798 |
|
16 | 4799 |
/** |
4800 |
* Registers a standard `@wordpress/data` store. |
|
4801 |
* |
|
18 | 4802 |
* @deprecated Use `register` instead. |
4803 |
* |
|
4804 |
* @param {string} storeName Unique namespace identifier for the store. |
|
4805 |
* @param {Object} options Store description (reducer, actions, selectors, resolvers). |
|
16 | 4806 |
* |
4807 |
* @return {Object} Registered store object. |
|
4808 |
*/ |
|
18 | 4809 |
const registerStore = default_registry.registerStore; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4810 |
|
16 | 4811 |
/** |
4812 |
* Extends a registry to inherit functionality provided by a given plugin. A |
|
4813 |
* plugin is an object with properties aligning to that of a registry, merged |
|
4814 |
* to extend the default registry behavior. |
|
4815 |
* |
|
4816 |
* @param {Object} plugin Plugin object. |
|
4817 |
*/ |
|
19 | 4818 |
const use = default_registry.use; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4819 |
|
18 | 4820 |
/** |
19 | 4821 |
* Registers a standard `@wordpress/data` store descriptor. |
18 | 4822 |
* |
4823 |
* @example |
|
4824 |
* ```js |
|
4825 |
* import { createReduxStore, register } from '@wordpress/data'; |
|
4826 |
* |
|
4827 |
* const store = createReduxStore( 'demo', { |
|
4828 |
* reducer: ( state = 'OK' ) => state, |
|
4829 |
* selectors: { |
|
4830 |
* getValue: ( state ) => state, |
|
4831 |
* }, |
|
4832 |
* } ); |
|
4833 |
* register( store ); |
|
4834 |
* ``` |
|
4835 |
* |
|
19 | 4836 |
* @param {StoreDescriptor} store Store descriptor. |
18 | 4837 |
*/ |
19 | 4838 |
const register = default_registry.register; |
4839 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4840 |
})(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4841 |
|
19 | 4842 |
(window.wp = window.wp || {}).data = __webpack_exports__; |
4843 |
/******/ })() |
|
4844 |
; |