bippy 0.6.1-dev.3a24abf → 0.6.1-dev.93556ef
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/LICENSE +1 -1
- package/README.md +26 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +39 -42
- package/dist/core.d.ts +39 -42
- package/dist/core.js +1 -1
- package/dist/core2.cjs +1 -1
- package/dist/core2.d.cts +11 -3
- package/dist/core2.d.ts +11 -3
- package/dist/core2.js +1 -1
- package/dist/{types.d.cts → errors.d.cts} +187 -68
- package/dist/{types.d.ts → errors.d.ts} +187 -68
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.iife.js +1 -1
- package/dist/index.js +1 -1
- package/dist/install-hook-only.cjs +1 -1
- package/dist/install-hook-only.d.cts +8 -0
- package/dist/install-hook-only.d.ts +8 -0
- package/dist/install-hook-only.iife.js +1 -1
- package/dist/install-hook-only.js +1 -1
- package/dist/rdt-hook.cjs +1 -1
- package/dist/rdt-hook.js +1 -1
- package/dist/source.cjs +13 -14
- package/dist/source.d.cts +86 -69
- package/dist/source.d.ts +86 -69
- package/dist/source.js +13 -14
- package/package.json +10 -6
- package/src/core.ts +246 -293
- package/src/errors.ts +34 -0
- package/src/install-hook-only.ts +2 -2
- package/src/rdt-hook.ts +152 -110
- package/src/react-internals/generated/react-work-tags.ts +318 -0
- package/src/react-internals/index.ts +67 -0
- package/src/react-internals/semver.ts +80 -0
- package/src/{types.ts → react-internals/types.ts} +13 -86
- package/src/source/error-stack.ts +11 -0
- package/src/source/get-display-name-from-source.ts +44 -40
- package/src/source/get-source.ts +42 -26
- package/src/source/index.ts +11 -1
- package/src/source/inspect-hooks.ts +220 -207
- package/src/source/owner-stack.ts +86 -128
- package/src/source/parse-debug-stack.ts +4 -4
- package/src/source/parse-hook-names.ts +14 -53
- package/src/source/parse-stack.ts +14 -31
- package/src/source/renderer-dispatchers.ts +30 -0
- package/src/source/symbolication.ts +703 -135
- package/src/generated/react-work-tags.ts +0 -169
- package/src/react-internals.ts +0 -67
- package/src/unsubscribe.ts +0 -17
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { compareSemver } from "../semver.js";
|
|
2
|
+
|
|
3
|
+
export const ReactBuildType = {
|
|
4
|
+
Development: 1,
|
|
5
|
+
Production: 0,
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
export const ReactFiberFlags = {
|
|
9
|
+
ChildDeletion: 16,
|
|
10
|
+
Cloned: 8,
|
|
11
|
+
ContentReset: 32,
|
|
12
|
+
Hydrating: 4096,
|
|
13
|
+
PerformedWork: 1,
|
|
14
|
+
Placement: 2,
|
|
15
|
+
Snapshot: 1024,
|
|
16
|
+
Update: 4,
|
|
17
|
+
Visibility: 8192,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export const ReactSymbols = {
|
|
21
|
+
CONCURRENT_MODE_NUMBER: 60111,
|
|
22
|
+
CONCURRENT_MODE_SYMBOL_DESCRIPTION: "react.concurrent_mode",
|
|
23
|
+
CONCURRENT_MODE_SYMBOL_STRING: "Symbol(react.concurrent_mode)",
|
|
24
|
+
DEPRECATED_ASYNC_MODE_SYMBOL_DESCRIPTION: "react.async_mode",
|
|
25
|
+
DEPRECATED_ASYNC_MODE_SYMBOL_STRING: "Symbol(react.async_mode)",
|
|
26
|
+
ELEMENT_SYMBOL_STRING: "Symbol(react.transitional.element)",
|
|
27
|
+
LEGACY_ELEMENT_SYMBOL_STRING: "Symbol(react.element)",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
export interface ReactWorkTagMap {
|
|
31
|
+
ActivityComponent: number;
|
|
32
|
+
CacheComponent: number;
|
|
33
|
+
ClassComponent: number;
|
|
34
|
+
ContextConsumer: number;
|
|
35
|
+
ContextProvider: number;
|
|
36
|
+
CoroutineComponent: number;
|
|
37
|
+
CoroutineHandlerPhase: number;
|
|
38
|
+
DehydratedSuspenseComponent: number;
|
|
39
|
+
ForwardRef: number;
|
|
40
|
+
Fragment: number;
|
|
41
|
+
FunctionComponent: number;
|
|
42
|
+
HostComponent: number;
|
|
43
|
+
HostHoistable: number;
|
|
44
|
+
HostPortal: number;
|
|
45
|
+
HostRoot: number;
|
|
46
|
+
HostSingleton: number;
|
|
47
|
+
HostText: number;
|
|
48
|
+
IncompleteClassComponent: number;
|
|
49
|
+
IncompleteFunctionComponent: number;
|
|
50
|
+
IndeterminateComponent: number;
|
|
51
|
+
LazyComponent: number;
|
|
52
|
+
LegacyHiddenComponent: number;
|
|
53
|
+
MemoComponent: number;
|
|
54
|
+
Mode: number;
|
|
55
|
+
OffscreenComponent: number;
|
|
56
|
+
Profiler: number;
|
|
57
|
+
ScopeComponent: number;
|
|
58
|
+
SimpleMemoComponent: number;
|
|
59
|
+
SuspenseComponent: number;
|
|
60
|
+
SuspenseListComponent: number;
|
|
61
|
+
Throw: number;
|
|
62
|
+
TracingMarkerComponent: number;
|
|
63
|
+
ViewTransitionComponent: number;
|
|
64
|
+
YieldComponent: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const defineReactWorkTags = <const VersionedWorkTags extends Record<string, ReactWorkTagMap>>(
|
|
68
|
+
workTags: VersionedWorkTags,
|
|
69
|
+
): VersionedWorkTags => workTags;
|
|
70
|
+
|
|
71
|
+
const reactWorkTagsByVersion = defineReactWorkTags({
|
|
72
|
+
"16.0.0": {
|
|
73
|
+
ActivityComponent: -1,
|
|
74
|
+
CacheComponent: -1,
|
|
75
|
+
ClassComponent: 2,
|
|
76
|
+
ContextConsumer: 12,
|
|
77
|
+
ContextProvider: 13,
|
|
78
|
+
CoroutineComponent: 7,
|
|
79
|
+
CoroutineHandlerPhase: 8,
|
|
80
|
+
DehydratedSuspenseComponent: -1,
|
|
81
|
+
ForwardRef: 14,
|
|
82
|
+
Fragment: 10,
|
|
83
|
+
FunctionComponent: 1,
|
|
84
|
+
HostComponent: 5,
|
|
85
|
+
HostHoistable: -1,
|
|
86
|
+
HostPortal: 4,
|
|
87
|
+
HostRoot: 3,
|
|
88
|
+
HostSingleton: -1,
|
|
89
|
+
HostText: 6,
|
|
90
|
+
IncompleteClassComponent: -1,
|
|
91
|
+
IncompleteFunctionComponent: -1,
|
|
92
|
+
IndeterminateComponent: 0,
|
|
93
|
+
LazyComponent: -1,
|
|
94
|
+
LegacyHiddenComponent: -1,
|
|
95
|
+
MemoComponent: -1,
|
|
96
|
+
Mode: 11,
|
|
97
|
+
OffscreenComponent: -1,
|
|
98
|
+
Profiler: 15,
|
|
99
|
+
ScopeComponent: -1,
|
|
100
|
+
SimpleMemoComponent: -1,
|
|
101
|
+
SuspenseComponent: 16,
|
|
102
|
+
SuspenseListComponent: -1,
|
|
103
|
+
Throw: -1,
|
|
104
|
+
TracingMarkerComponent: -1,
|
|
105
|
+
ViewTransitionComponent: -1,
|
|
106
|
+
YieldComponent: 9,
|
|
107
|
+
},
|
|
108
|
+
"16.4.3-alpha": {
|
|
109
|
+
ActivityComponent: -1,
|
|
110
|
+
CacheComponent: -1,
|
|
111
|
+
ClassComponent: 2,
|
|
112
|
+
ContextConsumer: 11,
|
|
113
|
+
ContextProvider: 12,
|
|
114
|
+
CoroutineComponent: -1,
|
|
115
|
+
CoroutineHandlerPhase: -1,
|
|
116
|
+
DehydratedSuspenseComponent: -1,
|
|
117
|
+
ForwardRef: 13,
|
|
118
|
+
Fragment: 9,
|
|
119
|
+
FunctionComponent: 0,
|
|
120
|
+
HostComponent: 7,
|
|
121
|
+
HostHoistable: -1,
|
|
122
|
+
HostPortal: 6,
|
|
123
|
+
HostRoot: 5,
|
|
124
|
+
HostSingleton: -1,
|
|
125
|
+
HostText: 8,
|
|
126
|
+
IncompleteClassComponent: -1,
|
|
127
|
+
IncompleteFunctionComponent: -1,
|
|
128
|
+
IndeterminateComponent: 4,
|
|
129
|
+
LazyComponent: -1,
|
|
130
|
+
LegacyHiddenComponent: -1,
|
|
131
|
+
MemoComponent: -1,
|
|
132
|
+
Mode: 10,
|
|
133
|
+
OffscreenComponent: -1,
|
|
134
|
+
Profiler: 15,
|
|
135
|
+
ScopeComponent: -1,
|
|
136
|
+
SimpleMemoComponent: -1,
|
|
137
|
+
SuspenseComponent: 16,
|
|
138
|
+
SuspenseListComponent: -1,
|
|
139
|
+
Throw: -1,
|
|
140
|
+
TracingMarkerComponent: -1,
|
|
141
|
+
ViewTransitionComponent: -1,
|
|
142
|
+
YieldComponent: -1,
|
|
143
|
+
},
|
|
144
|
+
"16.6.0-beta.0": {
|
|
145
|
+
ActivityComponent: -1,
|
|
146
|
+
CacheComponent: -1,
|
|
147
|
+
ClassComponent: 1,
|
|
148
|
+
ContextConsumer: 9,
|
|
149
|
+
ContextProvider: 10,
|
|
150
|
+
CoroutineComponent: -1,
|
|
151
|
+
CoroutineHandlerPhase: -1,
|
|
152
|
+
DehydratedSuspenseComponent: 18,
|
|
153
|
+
ForwardRef: 11,
|
|
154
|
+
Fragment: 7,
|
|
155
|
+
FunctionComponent: 0,
|
|
156
|
+
HostComponent: 5,
|
|
157
|
+
HostHoistable: -1,
|
|
158
|
+
HostPortal: 4,
|
|
159
|
+
HostRoot: 3,
|
|
160
|
+
HostSingleton: -1,
|
|
161
|
+
HostText: 6,
|
|
162
|
+
IncompleteClassComponent: 17,
|
|
163
|
+
IncompleteFunctionComponent: -1,
|
|
164
|
+
IndeterminateComponent: 2,
|
|
165
|
+
LazyComponent: 16,
|
|
166
|
+
LegacyHiddenComponent: -1,
|
|
167
|
+
MemoComponent: 14,
|
|
168
|
+
Mode: 8,
|
|
169
|
+
OffscreenComponent: -1,
|
|
170
|
+
Profiler: 12,
|
|
171
|
+
ScopeComponent: -1,
|
|
172
|
+
SimpleMemoComponent: 15,
|
|
173
|
+
SuspenseComponent: 13,
|
|
174
|
+
SuspenseListComponent: 19,
|
|
175
|
+
Throw: -1,
|
|
176
|
+
TracingMarkerComponent: -1,
|
|
177
|
+
ViewTransitionComponent: -1,
|
|
178
|
+
YieldComponent: -1,
|
|
179
|
+
},
|
|
180
|
+
"17.0.0-alpha": {
|
|
181
|
+
ActivityComponent: -1,
|
|
182
|
+
CacheComponent: -1,
|
|
183
|
+
ClassComponent: 1,
|
|
184
|
+
ContextConsumer: 9,
|
|
185
|
+
ContextProvider: 10,
|
|
186
|
+
CoroutineComponent: -1,
|
|
187
|
+
CoroutineHandlerPhase: -1,
|
|
188
|
+
DehydratedSuspenseComponent: 18,
|
|
189
|
+
ForwardRef: 11,
|
|
190
|
+
Fragment: 7,
|
|
191
|
+
FunctionComponent: 0,
|
|
192
|
+
HostComponent: 5,
|
|
193
|
+
HostHoistable: -1,
|
|
194
|
+
HostPortal: 4,
|
|
195
|
+
HostRoot: 3,
|
|
196
|
+
HostSingleton: -1,
|
|
197
|
+
HostText: 6,
|
|
198
|
+
IncompleteClassComponent: 17,
|
|
199
|
+
IncompleteFunctionComponent: -1,
|
|
200
|
+
IndeterminateComponent: 2,
|
|
201
|
+
LazyComponent: 16,
|
|
202
|
+
LegacyHiddenComponent: 24,
|
|
203
|
+
MemoComponent: 14,
|
|
204
|
+
Mode: 8,
|
|
205
|
+
OffscreenComponent: 23,
|
|
206
|
+
Profiler: 12,
|
|
207
|
+
ScopeComponent: 21,
|
|
208
|
+
SimpleMemoComponent: 15,
|
|
209
|
+
SuspenseComponent: 13,
|
|
210
|
+
SuspenseListComponent: 19,
|
|
211
|
+
Throw: -1,
|
|
212
|
+
TracingMarkerComponent: -1,
|
|
213
|
+
ViewTransitionComponent: -1,
|
|
214
|
+
YieldComponent: -1,
|
|
215
|
+
},
|
|
216
|
+
"17.0.2": {
|
|
217
|
+
ActivityComponent: 31,
|
|
218
|
+
CacheComponent: 24,
|
|
219
|
+
ClassComponent: 1,
|
|
220
|
+
ContextConsumer: 9,
|
|
221
|
+
ContextProvider: 10,
|
|
222
|
+
CoroutineComponent: -1,
|
|
223
|
+
CoroutineHandlerPhase: -1,
|
|
224
|
+
DehydratedSuspenseComponent: 18,
|
|
225
|
+
ForwardRef: 11,
|
|
226
|
+
Fragment: 7,
|
|
227
|
+
FunctionComponent: 0,
|
|
228
|
+
HostComponent: 5,
|
|
229
|
+
HostHoistable: 26,
|
|
230
|
+
HostPortal: 4,
|
|
231
|
+
HostRoot: 3,
|
|
232
|
+
HostSingleton: 27,
|
|
233
|
+
HostText: 6,
|
|
234
|
+
IncompleteClassComponent: 17,
|
|
235
|
+
IncompleteFunctionComponent: 28,
|
|
236
|
+
IndeterminateComponent: 2,
|
|
237
|
+
LazyComponent: 16,
|
|
238
|
+
LegacyHiddenComponent: 23,
|
|
239
|
+
MemoComponent: 14,
|
|
240
|
+
Mode: 8,
|
|
241
|
+
OffscreenComponent: 22,
|
|
242
|
+
Profiler: 12,
|
|
243
|
+
ScopeComponent: 21,
|
|
244
|
+
SimpleMemoComponent: 15,
|
|
245
|
+
SuspenseComponent: 13,
|
|
246
|
+
SuspenseListComponent: 19,
|
|
247
|
+
Throw: 29,
|
|
248
|
+
TracingMarkerComponent: 25,
|
|
249
|
+
ViewTransitionComponent: 30,
|
|
250
|
+
YieldComponent: -1,
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export type ReactWorkTagVersion = keyof typeof reactWorkTagsByVersion;
|
|
255
|
+
|
|
256
|
+
export interface GetReactWorkTags {
|
|
257
|
+
(): Readonly<ReactWorkTagMap>;
|
|
258
|
+
<Version extends ReactWorkTagVersion>(
|
|
259
|
+
reactVersion: Version,
|
|
260
|
+
): Readonly<(typeof reactWorkTagsByVersion)[Version]>;
|
|
261
|
+
(reactVersion: string): Readonly<ReactWorkTagMap>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type ReactWorkTag = Exclude<
|
|
265
|
+
(typeof reactWorkTagsByVersion)[ReactWorkTagVersion][keyof ReactWorkTagMap],
|
|
266
|
+
-1
|
|
267
|
+
>;
|
|
268
|
+
|
|
269
|
+
export type HostWorkTag = Exclude<
|
|
270
|
+
| (typeof reactWorkTagsByVersion)[ReactWorkTagVersion]["HostComponent"]
|
|
271
|
+
| (typeof reactWorkTagsByVersion)[ReactWorkTagVersion]["HostHoistable"]
|
|
272
|
+
| (typeof reactWorkTagsByVersion)[ReactWorkTagVersion]["HostSingleton"]
|
|
273
|
+
| (typeof reactWorkTagsByVersion)[ReactWorkTagVersion]["HostText"],
|
|
274
|
+
-1
|
|
275
|
+
>;
|
|
276
|
+
|
|
277
|
+
interface ReactWorkTagRange {
|
|
278
|
+
isMinimumExcluded: boolean;
|
|
279
|
+
minimumVersion: string;
|
|
280
|
+
workTags: Readonly<ReactWorkTagMap>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const reactWorkTagRanges: ReactWorkTagRange[] = [
|
|
284
|
+
{
|
|
285
|
+
isMinimumExcluded: true,
|
|
286
|
+
minimumVersion: "17.0.1",
|
|
287
|
+
workTags: reactWorkTagsByVersion["17.0.2"],
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
isMinimumExcluded: false,
|
|
291
|
+
minimumVersion: "17.0.0-alpha",
|
|
292
|
+
workTags: reactWorkTagsByVersion["17.0.0-alpha"],
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
isMinimumExcluded: false,
|
|
296
|
+
minimumVersion: "16.6.0-beta.0",
|
|
297
|
+
workTags: reactWorkTagsByVersion["16.6.0-beta.0"],
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
isMinimumExcluded: false,
|
|
301
|
+
minimumVersion: "16.4.3-alpha",
|
|
302
|
+
workTags: reactWorkTagsByVersion["16.4.3-alpha"],
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
const defaultReactWorkTags = reactWorkTagsByVersion["17.0.2"];
|
|
307
|
+
|
|
308
|
+
export const getReactWorkTags: GetReactWorkTags = (reactVersion?: string) => {
|
|
309
|
+
if (reactVersion === undefined) return defaultReactWorkTags;
|
|
310
|
+
for (const range of reactWorkTagRanges) {
|
|
311
|
+
const comparison = compareSemver(reactVersion, range.minimumVersion);
|
|
312
|
+
if (comparison === null) return defaultReactWorkTags;
|
|
313
|
+
if (comparison === 1 || (comparison === 0 && !range.isMinimumExcluded)) {
|
|
314
|
+
return range.workTags;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return reactWorkTagsByVersion["16.0.0"];
|
|
318
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getReactWorkTags, ReactFiberFlags } from "./generated/react-work-tags.js";
|
|
2
|
+
import type { ReactWorkTagMap } from "./generated/react-work-tags.js";
|
|
3
|
+
import { isSemver } from "./semver.js";
|
|
4
|
+
import type { Fiber, ReactRenderer } from "./types.js";
|
|
5
|
+
|
|
6
|
+
export { compareSemver } from "./semver.js";
|
|
7
|
+
export {
|
|
8
|
+
getReactWorkTags,
|
|
9
|
+
ReactBuildType,
|
|
10
|
+
ReactFiberFlags,
|
|
11
|
+
ReactSymbols,
|
|
12
|
+
} from "./generated/react-work-tags.js";
|
|
13
|
+
export type {
|
|
14
|
+
HostWorkTag,
|
|
15
|
+
ReactWorkTag,
|
|
16
|
+
ReactWorkTagMap,
|
|
17
|
+
ReactWorkTagVersion,
|
|
18
|
+
} from "./generated/react-work-tags.js";
|
|
19
|
+
export * from "./types.js";
|
|
20
|
+
|
|
21
|
+
const defaultReactWorkTags = getReactWorkTags();
|
|
22
|
+
const fiberReactWorkTags = new WeakMap<Fiber, Readonly<ReactWorkTagMap>>();
|
|
23
|
+
|
|
24
|
+
export const getReactWorkTagsForRenderer = (
|
|
25
|
+
renderer?: ReactRenderer | null,
|
|
26
|
+
): Readonly<ReactWorkTagMap> => {
|
|
27
|
+
const reconcilerVersion = renderer?.reconcilerVersion;
|
|
28
|
+
if (reconcilerVersion && isSemver(reconcilerVersion)) {
|
|
29
|
+
return getReactWorkTags(reconcilerVersion);
|
|
30
|
+
}
|
|
31
|
+
return renderer?.version ? getReactWorkTags(renderer.version) : defaultReactWorkTags;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const setReactWorkTagsForFiber = (fiber: Fiber, renderer?: ReactRenderer): void => {
|
|
35
|
+
const workTags = getReactWorkTagsForRenderer(renderer);
|
|
36
|
+
fiberReactWorkTags.set(fiber, workTags);
|
|
37
|
+
if (fiber.alternate) fiberReactWorkTags.set(fiber.alternate, workTags);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getReactWorkTagsForFiber = (fiber: Fiber): Readonly<ReactWorkTagMap> => {
|
|
41
|
+
const cachedWorkTags = fiberReactWorkTags.get(fiber);
|
|
42
|
+
if (cachedWorkTags) return cachedWorkTags;
|
|
43
|
+
|
|
44
|
+
const traversedFibers: Fiber[] = [fiber];
|
|
45
|
+
let rootFiber = fiber;
|
|
46
|
+
while (rootFiber.return) {
|
|
47
|
+
rootFiber = rootFiber.return;
|
|
48
|
+
traversedFibers.push(rootFiber);
|
|
49
|
+
}
|
|
50
|
+
const workTags = fiberReactWorkTags.get(rootFiber) ?? defaultReactWorkTags;
|
|
51
|
+
for (const traversedFiber of traversedFibers) {
|
|
52
|
+
fiberReactWorkTags.set(traversedFiber, workTags);
|
|
53
|
+
if (traversedFiber.alternate) {
|
|
54
|
+
fiberReactWorkTags.set(traversedFiber.alternate, workTags);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return workTags;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const MutationMask =
|
|
61
|
+
ReactFiberFlags.Placement |
|
|
62
|
+
ReactFiberFlags.Update |
|
|
63
|
+
ReactFiberFlags.ChildDeletion |
|
|
64
|
+
ReactFiberFlags.ContentReset |
|
|
65
|
+
ReactFiberFlags.Hydrating |
|
|
66
|
+
ReactFiberFlags.Visibility |
|
|
67
|
+
ReactFiberFlags.Snapshot;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
interface SemanticVersion {
|
|
2
|
+
major: string;
|
|
3
|
+
minor: string;
|
|
4
|
+
patch: string;
|
|
5
|
+
prerelease: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const SEMVER_PATTERN =
|
|
9
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
10
|
+
const NUMERIC_IDENTIFIER_PATTERN = /^\d+$/;
|
|
11
|
+
|
|
12
|
+
export const isSemver = (version: string): boolean => parseSemver(version) !== null;
|
|
13
|
+
|
|
14
|
+
const parseSemver = (version: string): SemanticVersion | null => {
|
|
15
|
+
const match = SEMVER_PATTERN.exec(version);
|
|
16
|
+
if (!match) return null;
|
|
17
|
+
const prerelease = match[4]?.split(".") ?? [];
|
|
18
|
+
if (
|
|
19
|
+
prerelease.some(
|
|
20
|
+
(identifier) =>
|
|
21
|
+
NUMERIC_IDENTIFIER_PATTERN.test(identifier) &&
|
|
22
|
+
identifier.length > 1 &&
|
|
23
|
+
identifier.startsWith("0"),
|
|
24
|
+
)
|
|
25
|
+
) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
major: match[1],
|
|
30
|
+
minor: match[2],
|
|
31
|
+
patch: match[3],
|
|
32
|
+
prerelease,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const compareNumericIdentifiers = (left: string, right: string): -1 | 0 | 1 => {
|
|
37
|
+
if (left.length !== right.length) return left.length < right.length ? -1 : 1;
|
|
38
|
+
if (left === right) return 0;
|
|
39
|
+
return left < right ? -1 : 1;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const comparePrereleaseIdentifiers = (left: string, right: string): -1 | 0 | 1 => {
|
|
43
|
+
const isLeftNumeric = NUMERIC_IDENTIFIER_PATTERN.test(left);
|
|
44
|
+
const isRightNumeric = NUMERIC_IDENTIFIER_PATTERN.test(right);
|
|
45
|
+
if (isLeftNumeric && isRightNumeric) return compareNumericIdentifiers(left, right);
|
|
46
|
+
if (isLeftNumeric !== isRightNumeric) return isLeftNumeric ? -1 : 1;
|
|
47
|
+
if (left === right) return 0;
|
|
48
|
+
return left < right ? -1 : 1;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const comparePrerelease = (left: string[], right: string[]): -1 | 0 | 1 => {
|
|
52
|
+
if (left.length === 0 || right.length === 0) {
|
|
53
|
+
if (left.length === right.length) return 0;
|
|
54
|
+
return left.length === 0 ? 1 : -1;
|
|
55
|
+
}
|
|
56
|
+
const identifierCount = Math.max(left.length, right.length);
|
|
57
|
+
for (let identifierIndex = 0; identifierIndex < identifierCount; identifierIndex++) {
|
|
58
|
+
const leftIdentifier = left[identifierIndex];
|
|
59
|
+
const rightIdentifier = right[identifierIndex];
|
|
60
|
+
if (leftIdentifier === undefined || rightIdentifier === undefined) {
|
|
61
|
+
return leftIdentifier === undefined ? -1 : 1;
|
|
62
|
+
}
|
|
63
|
+
const comparison = comparePrereleaseIdentifiers(leftIdentifier, rightIdentifier);
|
|
64
|
+
if (comparison !== 0) return comparison;
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const compareSemver = (leftVersion: string, rightVersion: string): -1 | 0 | 1 | null => {
|
|
70
|
+
const left = parseSemver(leftVersion);
|
|
71
|
+
const right = parseSemver(rightVersion);
|
|
72
|
+
if (!left || !right) return null;
|
|
73
|
+
const majorComparison = compareNumericIdentifiers(left.major, right.major);
|
|
74
|
+
if (majorComparison !== 0) return majorComparison;
|
|
75
|
+
const minorComparison = compareNumericIdentifiers(left.minor, right.minor);
|
|
76
|
+
if (minorComparison !== 0) return minorComparison;
|
|
77
|
+
const patchComparison = compareNumericIdentifiers(left.patch, right.patch);
|
|
78
|
+
if (patchComparison !== 0) return patchComparison;
|
|
79
|
+
return comparePrerelease(left.prerelease, right.prerelease);
|
|
80
|
+
};
|
|
@@ -1,85 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type ReactReconciler from "react-reconciler";
|
|
3
|
-
import type { HostWorkTag, ReactWorkTag } from "./react-
|
|
3
|
+
import type { HostWorkTag, ReactWorkTag } from "./generated/react-work-tags.js";
|
|
4
4
|
|
|
5
|
-
export type BundleType = ReactReconciler.BundleType;
|
|
6
|
-
export type Flags = ReactReconciler.Flags;
|
|
7
|
-
export type HookType = ReactReconciler.HookType;
|
|
8
|
-
export type LanePriority = ReactReconciler.LanePriority;
|
|
9
|
-
export type Lanes = ReactReconciler.Lanes;
|
|
10
|
-
export type MutableSource = ReactReconciler.MutableSource;
|
|
11
|
-
export type OpaqueHandle = ReactReconciler.OpaqueHandle;
|
|
12
|
-
export type OpaqueRoot = ReactReconciler.OpaqueRoot;
|
|
13
|
-
export type React$AbstractComponent<
|
|
14
|
-
Config,
|
|
15
|
-
Instance = unknown,
|
|
16
|
-
> = ReactReconciler.React$AbstractComponent<Config, Instance>;
|
|
17
|
-
export type RootTag = ReactReconciler.RootTag;
|
|
18
|
-
export type TypeOfMode = ReactReconciler.TypeOfMode;
|
|
19
5
|
export type WorkTag = ReactReconciler.WorkTag | ReactWorkTag;
|
|
20
6
|
|
|
21
|
-
export interface HostConfig<
|
|
22
|
-
Type = unknown,
|
|
23
|
-
HostProps = unknown,
|
|
24
|
-
Container = unknown,
|
|
25
|
-
Instance = unknown,
|
|
26
|
-
TextInstance = unknown,
|
|
27
|
-
SuspenseInstance = unknown,
|
|
28
|
-
HydratableInstance = unknown,
|
|
29
|
-
FormInstance = unknown,
|
|
30
|
-
PublicInstance = unknown,
|
|
31
|
-
HostContext = unknown,
|
|
32
|
-
ChildSet = unknown,
|
|
33
|
-
TimeoutHandle = unknown,
|
|
34
|
-
NoTimeout = unknown,
|
|
35
|
-
TransitionStatus = unknown,
|
|
36
|
-
> extends ReactReconciler.HostConfig<
|
|
37
|
-
Type,
|
|
38
|
-
HostProps,
|
|
39
|
-
Container,
|
|
40
|
-
Instance,
|
|
41
|
-
TextInstance,
|
|
42
|
-
SuspenseInstance,
|
|
43
|
-
HydratableInstance,
|
|
44
|
-
FormInstance,
|
|
45
|
-
PublicInstance,
|
|
46
|
-
HostContext,
|
|
47
|
-
ChildSet,
|
|
48
|
-
TimeoutHandle,
|
|
49
|
-
NoTimeout,
|
|
50
|
-
TransitionStatus
|
|
51
|
-
> {}
|
|
52
|
-
|
|
53
7
|
export interface Source extends ReactReconciler.Source {}
|
|
54
|
-
export interface RefObject extends ReactReconciler.RefObject {}
|
|
55
|
-
export interface Thenable<T> extends ReactReconciler.Thenable<T> {}
|
|
56
8
|
|
|
57
9
|
export interface ReactContext<T> extends ReactReconciler.ReactContext<T> {}
|
|
58
10
|
|
|
59
|
-
export interface ReactProviderType<T> extends ReactReconciler.ReactProviderType<T> {}
|
|
60
|
-
export interface ReactProvider<T> extends ReactReconciler.ReactProvider<T> {}
|
|
61
|
-
export interface ReactConsumer<T> extends ReactReconciler.ReactConsumer<T> {}
|
|
62
|
-
export interface ReactPortal extends ReactReconciler.ReactPortal {}
|
|
63
|
-
|
|
64
|
-
export interface ComponentSelector extends ReactReconciler.ComponentSelector {}
|
|
65
|
-
export interface HasPseudoClassSelector extends ReactReconciler.HasPseudoClassSelector {}
|
|
66
|
-
export interface RoleSelector extends ReactReconciler.RoleSelector {}
|
|
67
|
-
export interface TextSelector extends ReactReconciler.TextSelector {}
|
|
68
|
-
export interface TestNameSelector extends ReactReconciler.TestNameSelector {}
|
|
69
|
-
export type Selector = ReactReconciler.Selector;
|
|
70
|
-
|
|
71
|
-
export interface DevToolsConfig<
|
|
72
|
-
Instance = unknown,
|
|
73
|
-
TextInstance = unknown,
|
|
74
|
-
RendererInspectionConfig = unknown,
|
|
75
|
-
> extends ReactReconciler.DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {}
|
|
76
|
-
|
|
77
|
-
export interface SuspenseHydrationCallbacks<
|
|
78
|
-
SuspenseInstance = unknown,
|
|
79
|
-
> extends ReactReconciler.SuspenseHydrationCallbacks<SuspenseInstance> {}
|
|
80
|
-
|
|
81
|
-
export interface TransitionTracingCallbacks extends ReactReconciler.TransitionTracingCallbacks {}
|
|
82
|
-
|
|
83
11
|
// HACK: React 17 exposes observedBits while React 18+ exposes memoizedValue on context dependencies.
|
|
84
12
|
export interface ContextDependency<T> extends Omit<
|
|
85
13
|
ReactReconciler.ContextDependency<T>,
|
|
@@ -89,17 +17,13 @@ export interface ContextDependency<T> extends Omit<
|
|
|
89
17
|
observedBits?: number;
|
|
90
18
|
}
|
|
91
19
|
|
|
92
|
-
export interface
|
|
93
|
-
|
|
20
|
+
export interface DebugThenableState {
|
|
21
|
+
thenables?: unknown[];
|
|
94
22
|
}
|
|
95
23
|
|
|
96
|
-
export interface
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
deps: null | unknown[];
|
|
100
|
-
destroy: ((...args: unknown[]) => unknown) | null;
|
|
101
|
-
next: Effect | null;
|
|
102
|
-
tag: number;
|
|
24
|
+
export interface Dependencies extends Omit<ReactReconciler.Dependencies, "firstContext"> {
|
|
25
|
+
_debugThenableState?: DebugThenableState | unknown[];
|
|
26
|
+
firstContext: ContextDependency<unknown> | null;
|
|
103
27
|
}
|
|
104
28
|
|
|
105
29
|
export interface ServerComponentInfo {
|
|
@@ -115,15 +39,18 @@ export interface ReactDebugInfo {
|
|
|
115
39
|
name?: string;
|
|
116
40
|
}
|
|
117
41
|
|
|
42
|
+
export interface ReactMemoCache {
|
|
43
|
+
data: unknown[][];
|
|
44
|
+
index: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
118
47
|
export interface FiberDebugSource extends Source {
|
|
119
48
|
columnNumber?: number;
|
|
120
49
|
}
|
|
121
50
|
|
|
122
51
|
export interface FiberUpdateQueue {
|
|
123
52
|
[key: string]: unknown;
|
|
124
|
-
|
|
125
|
-
lastEffect: Effect | null;
|
|
126
|
-
memoCache?: unknown;
|
|
53
|
+
memoCache?: ReactMemoCache;
|
|
127
54
|
}
|
|
128
55
|
|
|
129
56
|
// HACK: @types/react-reconciler does not yet include React 19 debug fields or recursive server owners.
|
|
@@ -160,7 +87,7 @@ export interface Fiber<T = unknown> extends Omit<
|
|
|
160
87
|
sibling: Fiber | null;
|
|
161
88
|
stateNode: T;
|
|
162
89
|
tag: WorkTag;
|
|
163
|
-
updateQueue: FiberUpdateQueue;
|
|
90
|
+
updateQueue: FiberUpdateQueue | null;
|
|
164
91
|
}
|
|
165
92
|
|
|
166
93
|
export interface HostFiber<T = unknown> extends Fiber<T> {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ErrorConstructorWithPrepareStackTrace {
|
|
2
|
+
prepareStackTrace?: unknown;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
const errorConstructor: ErrorConstructorWithPrepareStackTrace = Error;
|
|
6
|
+
|
|
7
|
+
export const getPrepareStackTrace = (): unknown => errorConstructor.prepareStackTrace;
|
|
8
|
+
|
|
9
|
+
export const setPrepareStackTrace = (prepareStackTrace: unknown): void => {
|
|
10
|
+
errorConstructor.prepareStackTrace = prepareStackTrace;
|
|
11
|
+
};
|