@primer/react 0.0.0-20260224134212 → 0.0.0-20260224140728
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,4CAA4C;IAC5C,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,CAAC;0CA4CG,aAAa,CAAC,CAAC,CAAC;;mCATrB,CAAC;mDAbe,MAAM,CAAC;EAqG9D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import { useContext, useId, useEffect, useState, useRef,
|
|
2
|
+
import { useContext, useId, useEffect, useState, useRef, useReducer, createContext } from 'react';
|
|
3
3
|
import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect.js';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -21,6 +21,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
21
21
|
function createDescendantRegistry() {
|
|
22
22
|
const Context = /*#__PURE__*/createContext({
|
|
23
23
|
register: () => () => {},
|
|
24
|
+
updateValue: () => {},
|
|
24
25
|
key: -1
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -38,34 +39,55 @@ function createDescendantRegistry() {
|
|
|
38
39
|
return new Map();
|
|
39
40
|
}
|
|
40
41
|
function useRegisterDescendantCallback(valueCallback) {
|
|
41
|
-
const $ = c(
|
|
42
|
+
const $ = c(16);
|
|
42
43
|
const {
|
|
43
44
|
register,
|
|
45
|
+
updateValue,
|
|
44
46
|
key
|
|
45
47
|
} = useContext(Context);
|
|
46
48
|
const id = useId();
|
|
47
49
|
let t0;
|
|
48
|
-
if ($[0] !== id || $[1] !== register
|
|
49
|
-
t0 = () => register(id
|
|
50
|
+
if ($[0] !== id || $[1] !== register) {
|
|
51
|
+
t0 = () => register(id);
|
|
50
52
|
$[0] = id;
|
|
51
53
|
$[1] = register;
|
|
52
|
-
$[2] =
|
|
53
|
-
$[3] = t0;
|
|
54
|
+
$[2] = t0;
|
|
54
55
|
} else {
|
|
55
|
-
t0 = $[
|
|
56
|
+
t0 = $[2];
|
|
56
57
|
}
|
|
57
58
|
let t1;
|
|
58
|
-
if ($[
|
|
59
|
-
t1 = [register, id,
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[8] = t1;
|
|
59
|
+
if ($[3] !== id || $[4] !== key || $[5] !== register) {
|
|
60
|
+
t1 = [register, id, key];
|
|
61
|
+
$[3] = id;
|
|
62
|
+
$[4] = key;
|
|
63
|
+
$[5] = register;
|
|
64
|
+
$[6] = t1;
|
|
65
65
|
} else {
|
|
66
|
-
t1 = $[
|
|
66
|
+
t1 = $[6];
|
|
67
67
|
}
|
|
68
68
|
useEffect(t0, t1);
|
|
69
|
+
let t2;
|
|
70
|
+
if ($[7] !== id || $[8] !== updateValue || $[9] !== valueCallback) {
|
|
71
|
+
t2 = () => updateValue(id, valueCallback());
|
|
72
|
+
$[7] = id;
|
|
73
|
+
$[8] = updateValue;
|
|
74
|
+
$[9] = valueCallback;
|
|
75
|
+
$[10] = t2;
|
|
76
|
+
} else {
|
|
77
|
+
t2 = $[10];
|
|
78
|
+
}
|
|
79
|
+
let t3;
|
|
80
|
+
if ($[11] !== id || $[12] !== key || $[13] !== updateValue || $[14] !== valueCallback) {
|
|
81
|
+
t3 = [updateValue, id, valueCallback, key];
|
|
82
|
+
$[11] = id;
|
|
83
|
+
$[12] = key;
|
|
84
|
+
$[13] = updateValue;
|
|
85
|
+
$[14] = valueCallback;
|
|
86
|
+
$[15] = t3;
|
|
87
|
+
} else {
|
|
88
|
+
t3 = $[15];
|
|
89
|
+
}
|
|
90
|
+
useEffect(t2, t3);
|
|
69
91
|
return id;
|
|
70
92
|
}
|
|
71
93
|
|
|
@@ -83,87 +105,130 @@ function createDescendantRegistry() {
|
|
|
83
105
|
const valueCallback = t0;
|
|
84
106
|
return useRegisterDescendantCallback(valueCallback);
|
|
85
107
|
}
|
|
108
|
+
const unsetValue = Symbol('unset');
|
|
86
109
|
|
|
87
110
|
/** Provide context for registering descendant components. This only needs to wrap `children`. */
|
|
88
|
-
function Provider({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const [key,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
if (workingRegistryRef.current instanceof Map) {
|
|
124
|
-
workingRegistryRef.current.set(id, value);
|
|
125
|
-
} else if (workingRegistryRef.current === 'idle') {
|
|
126
|
-
queueRebuild();
|
|
127
|
-
}
|
|
128
|
-
return () => {
|
|
111
|
+
function Provider(t0) {
|
|
112
|
+
const $ = c(13);
|
|
113
|
+
const {
|
|
114
|
+
children,
|
|
115
|
+
setRegistry
|
|
116
|
+
} = t0;
|
|
117
|
+
const workingRegistryRef = useRef("queued");
|
|
118
|
+
const [key, incrementKey] = useReducer(_temp2, 0);
|
|
119
|
+
let t1;
|
|
120
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
121
|
+
t1 = () => {
|
|
122
|
+
workingRegistryRef.current = "queued";
|
|
123
|
+
incrementKey();
|
|
124
|
+
};
|
|
125
|
+
$[0] = t1;
|
|
126
|
+
} else {
|
|
127
|
+
t1 = $[0];
|
|
128
|
+
}
|
|
129
|
+
const queueRebuild = t1;
|
|
130
|
+
let t2;
|
|
131
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
132
|
+
t2 = function instantiateNewRegistry() {
|
|
133
|
+
if (workingRegistryRef.current === "queued") {
|
|
134
|
+
workingRegistryRef.current = new Map();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
$[1] = t2;
|
|
138
|
+
} else {
|
|
139
|
+
t2 = $[1];
|
|
140
|
+
}
|
|
141
|
+
useIsomorphicLayoutEffect(t2);
|
|
142
|
+
let t3;
|
|
143
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
144
|
+
t3 = id => {
|
|
129
145
|
if (workingRegistryRef.current instanceof Map) {
|
|
130
|
-
workingRegistryRef.current.
|
|
131
|
-
} else
|
|
132
|
-
|
|
146
|
+
workingRegistryRef.current.set(id, unsetValue);
|
|
147
|
+
} else {
|
|
148
|
+
if (workingRegistryRef.current === "idle") {
|
|
149
|
+
queueRebuild();
|
|
150
|
+
}
|
|
133
151
|
}
|
|
152
|
+
return () => {
|
|
153
|
+
if (workingRegistryRef.current instanceof Map) {
|
|
154
|
+
workingRegistryRef.current.delete(id);
|
|
155
|
+
} else {
|
|
156
|
+
if (workingRegistryRef.current === "idle") {
|
|
157
|
+
queueRebuild();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
134
161
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
$[2] = t3;
|
|
163
|
+
} else {
|
|
164
|
+
t3 = $[2];
|
|
165
|
+
}
|
|
166
|
+
const register = t3;
|
|
167
|
+
let t4;
|
|
168
|
+
if ($[3] !== setRegistry) {
|
|
169
|
+
t4 = (id_0, value) => {
|
|
170
|
+
if (workingRegistryRef.current instanceof Map) {
|
|
171
|
+
workingRegistryRef.current.set(id_0, value);
|
|
172
|
+
} else {
|
|
173
|
+
if (workingRegistryRef.current === "idle") {
|
|
174
|
+
setRegistry(prev_0 => new Map(prev_0).set(id_0, value));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
$[3] = setRegistry;
|
|
179
|
+
$[4] = t4;
|
|
180
|
+
} else {
|
|
181
|
+
t4 = $[4];
|
|
182
|
+
}
|
|
183
|
+
const updateValue = t4;
|
|
184
|
+
let t5;
|
|
185
|
+
if ($[5] !== setRegistry) {
|
|
186
|
+
t5 = function commitWorkingRegistry() {
|
|
187
|
+
if (workingRegistryRef.current instanceof Map) {
|
|
188
|
+
const setEntries = Array.from(workingRegistryRef.current.entries()).filter(_temp3);
|
|
189
|
+
setRegistry(new Map(setEntries));
|
|
190
|
+
workingRegistryRef.current = "idle";
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
$[5] = setRegistry;
|
|
194
|
+
$[6] = t5;
|
|
195
|
+
} else {
|
|
196
|
+
t5 = $[6];
|
|
197
|
+
}
|
|
198
|
+
useEffect(t5);
|
|
199
|
+
let t6;
|
|
200
|
+
if ($[7] !== key || $[8] !== updateValue) {
|
|
201
|
+
t6 = {
|
|
202
|
+
register,
|
|
203
|
+
updateValue,
|
|
204
|
+
key
|
|
205
|
+
};
|
|
206
|
+
$[7] = key;
|
|
207
|
+
$[8] = updateValue;
|
|
208
|
+
$[9] = t6;
|
|
209
|
+
} else {
|
|
210
|
+
t6 = $[9];
|
|
211
|
+
}
|
|
212
|
+
const contextValue = t6;
|
|
213
|
+
let t7;
|
|
214
|
+
if ($[10] !== children || $[11] !== contextValue) {
|
|
215
|
+
t7 = /*#__PURE__*/jsx(Context.Provider, {
|
|
216
|
+
value: contextValue,
|
|
217
|
+
children: children
|
|
218
|
+
});
|
|
219
|
+
$[10] = children;
|
|
220
|
+
$[11] = contextValue;
|
|
221
|
+
$[12] = t7;
|
|
222
|
+
} else {
|
|
223
|
+
t7 = $[12];
|
|
224
|
+
}
|
|
225
|
+
return t7;
|
|
226
|
+
}
|
|
227
|
+
function _temp3(entry) {
|
|
228
|
+
return entry[1] !== unsetValue;
|
|
229
|
+
}
|
|
230
|
+
function _temp2(prev) {
|
|
231
|
+
return prev + 1;
|
|
167
232
|
}
|
|
168
233
|
return {
|
|
169
234
|
Provider,
|
package/package.json
CHANGED