bippy 0.6.1-dev.051a9b2 → 0.6.1-dev.3a24abf
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/README.md +26 -48
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +32 -44
- package/dist/core.d.ts +32 -44
- package/dist/core.js +1 -1
- package/dist/core2.cjs +9 -0
- package/dist/core2.d.cts +3 -3
- package/dist/core2.d.ts +3 -3
- package/dist/core2.js +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -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 +1 -1
- package/dist/install-hook-only.d.ts +1 -1
- 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 +14 -4
- package/dist/source.d.cts +1 -1
- package/dist/source.d.ts +1 -1
- package/dist/source.js +14 -4
- package/dist/types.d.cts +291 -0
- package/dist/types.d.ts +291 -0
- package/package.json +14 -12
- package/src/core.ts +206 -155
- package/src/generated/react-work-tags.ts +169 -0
- package/src/rdt-hook.ts +24 -67
- package/src/react-internals.ts +67 -0
- package/src/source/constants.ts +1 -1
- package/src/source/get-source.ts +2 -1
- package/src/source/owner-stack.ts +64 -77
- package/src/source/parse-stack.ts +1 -1
- package/src/source/symbolication.ts +25 -4
- package/src/types.ts +154 -333
- package/src/unsubscribe.ts +2 -2
- package/dist/get-source.cjs +0 -19
- package/dist/get-source.js +0 -19
- package/dist/react-refresh.cjs +0 -9
- package/dist/react-refresh.d.cts +0 -66
- package/dist/react-refresh.d.ts +0 -66
- package/dist/react-refresh.js +0 -9
- package/dist/unsubscribe.d.cts +0 -298
- package/dist/unsubscribe.d.ts +0 -298
- package/src/react-refresh/constants.ts +0 -9
- package/src/react-refresh/detect-hmr-transport.ts +0 -33
- package/src/react-refresh/index.ts +0 -173
- package/src/react-refresh/metro-hmr-transport.ts +0 -188
- package/src/react-refresh/next-webpack-hmr-transport.ts +0 -72
- package/src/react-refresh/normalize-hmr-file-path.ts +0 -24
- package/src/react-refresh/types.ts +0 -7
- package/src/react-refresh/vite-hmr-transport.ts +0 -116
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// Generated by the React internals Vite+ plugin from react-devtools-core.
|
|
2
|
+
|
|
3
|
+
export interface ReactWorkTagMap {
|
|
4
|
+
ActivityComponent: number;
|
|
5
|
+
CacheComponent: number;
|
|
6
|
+
ClassComponent: number;
|
|
7
|
+
ContextConsumer: number;
|
|
8
|
+
ContextProvider: number;
|
|
9
|
+
CoroutineComponent: number;
|
|
10
|
+
CoroutineHandlerPhase: number;
|
|
11
|
+
DehydratedSuspenseComponent: number;
|
|
12
|
+
ForwardRef: number;
|
|
13
|
+
Fragment: number;
|
|
14
|
+
FunctionComponent: number;
|
|
15
|
+
HostComponent: number;
|
|
16
|
+
HostHoistable: number;
|
|
17
|
+
HostPortal: number;
|
|
18
|
+
HostRoot: number;
|
|
19
|
+
HostSingleton: number;
|
|
20
|
+
HostText: number;
|
|
21
|
+
IncompleteClassComponent: number;
|
|
22
|
+
IncompleteFunctionComponent: number;
|
|
23
|
+
IndeterminateComponent: number;
|
|
24
|
+
LazyComponent: number;
|
|
25
|
+
LegacyHiddenComponent: number;
|
|
26
|
+
MemoComponent: number;
|
|
27
|
+
Mode: number;
|
|
28
|
+
OffscreenComponent: number;
|
|
29
|
+
Profiler: number;
|
|
30
|
+
ScopeComponent: number;
|
|
31
|
+
SimpleMemoComponent: number;
|
|
32
|
+
SuspenseComponent: number;
|
|
33
|
+
SuspenseListComponent: number;
|
|
34
|
+
Throw: number;
|
|
35
|
+
TracingMarkerComponent: number;
|
|
36
|
+
ViewTransitionComponent: number;
|
|
37
|
+
YieldComponent: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const defineReactWorkTags = <const VersionedWorkTags extends Record<string, ReactWorkTagMap>>(
|
|
41
|
+
workTags: VersionedWorkTags,
|
|
42
|
+
): VersionedWorkTags => workTags;
|
|
43
|
+
|
|
44
|
+
export const ReactWorkTags = defineReactWorkTags({
|
|
45
|
+
"17.0.1": {
|
|
46
|
+
ActivityComponent: -1,
|
|
47
|
+
CacheComponent: -1,
|
|
48
|
+
ClassComponent: 1,
|
|
49
|
+
ContextConsumer: 9,
|
|
50
|
+
ContextProvider: 10,
|
|
51
|
+
CoroutineComponent: -1,
|
|
52
|
+
CoroutineHandlerPhase: -1,
|
|
53
|
+
DehydratedSuspenseComponent: 18,
|
|
54
|
+
ForwardRef: 11,
|
|
55
|
+
Fragment: 7,
|
|
56
|
+
FunctionComponent: 0,
|
|
57
|
+
HostComponent: 5,
|
|
58
|
+
HostHoistable: -1,
|
|
59
|
+
HostPortal: 4,
|
|
60
|
+
HostRoot: 3,
|
|
61
|
+
HostSingleton: -1,
|
|
62
|
+
HostText: 6,
|
|
63
|
+
IncompleteClassComponent: 17,
|
|
64
|
+
IncompleteFunctionComponent: -1,
|
|
65
|
+
IndeterminateComponent: 2,
|
|
66
|
+
LazyComponent: 16,
|
|
67
|
+
LegacyHiddenComponent: 24,
|
|
68
|
+
MemoComponent: 14,
|
|
69
|
+
Mode: 8,
|
|
70
|
+
OffscreenComponent: 23,
|
|
71
|
+
Profiler: 12,
|
|
72
|
+
ScopeComponent: 21,
|
|
73
|
+
SimpleMemoComponent: 15,
|
|
74
|
+
SuspenseComponent: 13,
|
|
75
|
+
SuspenseListComponent: 19,
|
|
76
|
+
Throw: -1,
|
|
77
|
+
TracingMarkerComponent: -1,
|
|
78
|
+
ViewTransitionComponent: -1,
|
|
79
|
+
YieldComponent: -1,
|
|
80
|
+
},
|
|
81
|
+
"17.0.2": {
|
|
82
|
+
ActivityComponent: 31,
|
|
83
|
+
CacheComponent: 24,
|
|
84
|
+
ClassComponent: 1,
|
|
85
|
+
ContextConsumer: 9,
|
|
86
|
+
ContextProvider: 10,
|
|
87
|
+
CoroutineComponent: -1,
|
|
88
|
+
CoroutineHandlerPhase: -1,
|
|
89
|
+
DehydratedSuspenseComponent: 18,
|
|
90
|
+
ForwardRef: 11,
|
|
91
|
+
Fragment: 7,
|
|
92
|
+
FunctionComponent: 0,
|
|
93
|
+
HostComponent: 5,
|
|
94
|
+
HostHoistable: 26,
|
|
95
|
+
HostPortal: 4,
|
|
96
|
+
HostRoot: 3,
|
|
97
|
+
HostSingleton: 27,
|
|
98
|
+
HostText: 6,
|
|
99
|
+
IncompleteClassComponent: 17,
|
|
100
|
+
IncompleteFunctionComponent: 28,
|
|
101
|
+
IndeterminateComponent: 2,
|
|
102
|
+
LazyComponent: 16,
|
|
103
|
+
LegacyHiddenComponent: 23,
|
|
104
|
+
MemoComponent: 14,
|
|
105
|
+
Mode: 8,
|
|
106
|
+
OffscreenComponent: 22,
|
|
107
|
+
Profiler: 12,
|
|
108
|
+
ScopeComponent: 21,
|
|
109
|
+
SimpleMemoComponent: 15,
|
|
110
|
+
SuspenseComponent: 13,
|
|
111
|
+
SuspenseListComponent: 19,
|
|
112
|
+
Throw: 29,
|
|
113
|
+
TracingMarkerComponent: 25,
|
|
114
|
+
ViewTransitionComponent: 30,
|
|
115
|
+
YieldComponent: -1,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export type ReactWorkTagVersion = keyof typeof ReactWorkTags;
|
|
120
|
+
|
|
121
|
+
const react17Point0Point2WorkTags = ReactWorkTags["17.0.2"];
|
|
122
|
+
|
|
123
|
+
export const ActivityComponentTag = react17Point0Point2WorkTags.ActivityComponent;
|
|
124
|
+
export const CacheComponentTag = react17Point0Point2WorkTags.CacheComponent;
|
|
125
|
+
export const ClassComponentTag = react17Point0Point2WorkTags.ClassComponent;
|
|
126
|
+
export const ContextConsumerTag = react17Point0Point2WorkTags.ContextConsumer;
|
|
127
|
+
export const ContextProviderTag = react17Point0Point2WorkTags.ContextProvider;
|
|
128
|
+
export const DehydratedSuspenseComponentTag =
|
|
129
|
+
react17Point0Point2WorkTags.DehydratedSuspenseComponent;
|
|
130
|
+
export const ForwardRefTag = react17Point0Point2WorkTags.ForwardRef;
|
|
131
|
+
export const FragmentTag = react17Point0Point2WorkTags.Fragment;
|
|
132
|
+
export const FunctionComponentTag = react17Point0Point2WorkTags.FunctionComponent;
|
|
133
|
+
export const HostComponentTag = react17Point0Point2WorkTags.HostComponent;
|
|
134
|
+
export const HostHoistableTag = react17Point0Point2WorkTags.HostHoistable;
|
|
135
|
+
export const HostPortalTag = react17Point0Point2WorkTags.HostPortal;
|
|
136
|
+
export const HostRootTag = react17Point0Point2WorkTags.HostRoot;
|
|
137
|
+
export const HostSingletonTag = react17Point0Point2WorkTags.HostSingleton;
|
|
138
|
+
export const HostTextTag = react17Point0Point2WorkTags.HostText;
|
|
139
|
+
export const IncompleteClassComponentTag = react17Point0Point2WorkTags.IncompleteClassComponent;
|
|
140
|
+
export const IncompleteFunctionComponentTag =
|
|
141
|
+
react17Point0Point2WorkTags.IncompleteFunctionComponent;
|
|
142
|
+
export const IndeterminateComponentTag = react17Point0Point2WorkTags.IndeterminateComponent;
|
|
143
|
+
export const LazyComponentTag = react17Point0Point2WorkTags.LazyComponent;
|
|
144
|
+
export const LegacyHiddenComponentTag = react17Point0Point2WorkTags.LegacyHiddenComponent;
|
|
145
|
+
export const MemoComponentTag = react17Point0Point2WorkTags.MemoComponent;
|
|
146
|
+
export const ModeTag = react17Point0Point2WorkTags.Mode;
|
|
147
|
+
export const OffscreenComponentTag = react17Point0Point2WorkTags.OffscreenComponent;
|
|
148
|
+
export const ProfilerTag = react17Point0Point2WorkTags.Profiler;
|
|
149
|
+
export const ScopeComponentTag = react17Point0Point2WorkTags.ScopeComponent;
|
|
150
|
+
export const SimpleMemoComponentTag = react17Point0Point2WorkTags.SimpleMemoComponent;
|
|
151
|
+
export const SuspenseComponentTag = react17Point0Point2WorkTags.SuspenseComponent;
|
|
152
|
+
export const SuspenseListComponentTag = react17Point0Point2WorkTags.SuspenseListComponent;
|
|
153
|
+
export const ThrowTag = react17Point0Point2WorkTags.Throw;
|
|
154
|
+
export const TracingMarkerComponentTag = react17Point0Point2WorkTags.TracingMarkerComponent;
|
|
155
|
+
export const ViewTransitionComponentTag = react17Point0Point2WorkTags.ViewTransitionComponent;
|
|
156
|
+
|
|
157
|
+
export type ReactWorkTag = Exclude<
|
|
158
|
+
(typeof ReactWorkTags)[ReactWorkTagVersion][keyof ReactWorkTagMap],
|
|
159
|
+
-1
|
|
160
|
+
>;
|
|
161
|
+
|
|
162
|
+
export type HostWorkTag =
|
|
163
|
+
| typeof HostComponentTag
|
|
164
|
+
| typeof HostHoistableTag
|
|
165
|
+
| typeof HostSingletonTag
|
|
166
|
+
| typeof HostTextTag;
|
|
167
|
+
|
|
168
|
+
export const getReactWorkTags = (version: string): Readonly<ReactWorkTagMap> =>
|
|
169
|
+
/^17\.0\.1(?:\D|$)/.test(version) ? ReactWorkTags["17.0.1"] : ReactWorkTags["17.0.2"];
|
package/src/rdt-hook.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// this file is super important to load the __REACT_DEVTOOLS_GLOBAL_HOOK__ object
|
|
3
|
-
// without this, we can't stub the React DevTools global hook, we don't have a way to instrument the application
|
|
4
|
-
// make sure you import this file first before anything else (particularly React)
|
|
1
|
+
// This module must load before React so renderers can inject into the hook.
|
|
5
2
|
|
|
6
3
|
import type { ReactDevToolsGlobalHook, ReactRenderer } from "./types.js";
|
|
7
4
|
import { toUnsubscribe, type Unsubscribe } from "./unsubscribe.js";
|
|
@@ -13,14 +10,12 @@ const objectDefineProperty = Object.defineProperty;
|
|
|
13
10
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
14
11
|
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
15
12
|
|
|
16
|
-
const NO_OP = () => {
|
|
17
|
-
/**/
|
|
18
|
-
};
|
|
13
|
+
const NO_OP = (): void => {};
|
|
19
14
|
|
|
20
15
|
const checkDCE = (functionToCheck: unknown): void => {
|
|
21
16
|
try {
|
|
22
17
|
const code = Function.prototype.toString.call(functionToCheck);
|
|
23
|
-
if (code.
|
|
18
|
+
if (code.includes("^_^")) {
|
|
24
19
|
setTimeout(() => {
|
|
25
20
|
throw new Error(
|
|
26
21
|
"React is running in production mode, but dead code " +
|
|
@@ -39,27 +34,12 @@ export const isRealReactDevtools = (
|
|
|
39
34
|
return Boolean(rdtHook && "getFiberRoots" in rdtHook);
|
|
40
35
|
};
|
|
41
36
|
|
|
42
|
-
let isReactRefreshOverride = false;
|
|
43
|
-
let injectFnStr: string | undefined = undefined;
|
|
44
|
-
|
|
45
|
-
export const isReactRefresh = (
|
|
46
|
-
rdtHook: ReactDevToolsGlobalHook | undefined | null = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__,
|
|
47
|
-
): boolean => {
|
|
48
|
-
if (isReactRefreshOverride) return true;
|
|
49
|
-
if (rdtHook && typeof rdtHook.inject === "function") {
|
|
50
|
-
injectFnStr = rdtHook.inject.toString();
|
|
51
|
-
}
|
|
52
|
-
// https://github.com/facebook/react/blob/8f8b336734d7c807f5aa11b0f31540e63302d789/packages/react-refresh/src/ReactFreshRuntime.js#L459
|
|
53
|
-
return Boolean(injectFnStr?.includes("(injected)"));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
37
|
export const _onActiveListeners = new Set<() => unknown>();
|
|
57
38
|
|
|
58
39
|
export const _renderers = new Set<ReactRenderer>();
|
|
59
40
|
|
|
60
41
|
const rendererInjectListeners = new Set<(renderer: ReactRenderer) => void>();
|
|
61
|
-
//
|
|
62
|
-
// wrapper in the call chain, so notifications are deduped per renderer
|
|
42
|
+
// HACK: Hook replacement can leave an old inject wrapper in the call chain, so notifications must be deduplicated.
|
|
63
43
|
const notifiedRenderers = new WeakSet<ReactRenderer>();
|
|
64
44
|
let notifyingInject: ReactDevToolsGlobalHook["inject"] | null = null;
|
|
65
45
|
|
|
@@ -80,12 +60,7 @@ const ensureInjectNotifiesListeners = (rdtHook: ReactDevToolsGlobalHook): void =
|
|
|
80
60
|
notifyingInject = nextInject;
|
|
81
61
|
};
|
|
82
62
|
|
|
83
|
-
/**
|
|
84
|
-
* Subscribes to future renderer injections into the DevTools hook. The
|
|
85
|
-
* single shared inject wrapper lets multiple consumers (override methods,
|
|
86
|
-
* react-refresh, user code) observe renderers without stacking patches
|
|
87
|
-
* whose restore order matters. Returns an unsubscribe function.
|
|
88
|
-
*/
|
|
63
|
+
/** Subscribes to renderer injections without stacking competing hook patches. */
|
|
89
64
|
export const onRendererInject = (listener: (renderer: ReactRenderer) => void): Unsubscribe => {
|
|
90
65
|
ensureInjectNotifiesListeners(getRDTHook());
|
|
91
66
|
rendererInjectListeners.add(listener);
|
|
@@ -94,6 +69,13 @@ export const onRendererInject = (listener: (renderer: ReactRenderer) => void): U
|
|
|
94
69
|
});
|
|
95
70
|
};
|
|
96
71
|
|
|
72
|
+
const ensureRendererMap = (rdtHook: ReactDevToolsGlobalHook): Map<number, ReactRenderer> => {
|
|
73
|
+
if (!(rdtHook.renderers instanceof Map)) {
|
|
74
|
+
rdtHook.renderers = new Map();
|
|
75
|
+
}
|
|
76
|
+
return rdtHook.renderers;
|
|
77
|
+
};
|
|
78
|
+
|
|
97
79
|
export const installRDTHook = (onActive?: () => unknown): ReactDevToolsGlobalHook => {
|
|
98
80
|
if (onActive) {
|
|
99
81
|
_onActiveListeners.add(onActive);
|
|
@@ -134,19 +116,18 @@ export const installRDTHook = (onActive?: () => unknown): ReactDevToolsGlobalHoo
|
|
|
134
116
|
if (newHook && typeof newHook === "object") {
|
|
135
117
|
const ourRenderers = rdtHook.renderers;
|
|
136
118
|
rdtHook = newHook;
|
|
119
|
+
const nextRenderers = ensureRendererMap(rdtHook);
|
|
137
120
|
if (ourRenderers.size > 0) {
|
|
138
121
|
ourRenderers.forEach((renderer, id) => {
|
|
139
122
|
_renderers.add(renderer);
|
|
140
|
-
|
|
141
|
-
newHook.renderers.set(id, renderer);
|
|
123
|
+
nextRenderers.set(id, renderer);
|
|
142
124
|
});
|
|
143
125
|
patchRDTHook(onActive);
|
|
144
126
|
}
|
|
145
127
|
}
|
|
146
128
|
},
|
|
147
129
|
});
|
|
148
|
-
//
|
|
149
|
-
// https://github.com/facebook/react/blob/18eaf51bd51fed8dfed661d64c306759101d0bfd/packages/react-devtools-extensions/src/contentScripts/installHook.js#L30C6-L30C27
|
|
130
|
+
// HACK: The DevTools extension uses hasOwnProperty to decide whether it may replace an earlier hook.
|
|
150
131
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
151
132
|
const originalWindowHasOwnProperty = window.hasOwnProperty;
|
|
152
133
|
let hasRanHack = false;
|
|
@@ -156,7 +137,6 @@ export const installRDTHook = (onActive?: () => unknown): ReactDevToolsGlobalHoo
|
|
|
156
137
|
try {
|
|
157
138
|
if (!hasRanHack && args[0] === "__REACT_DEVTOOLS_GLOBAL_HOOK__") {
|
|
158
139
|
globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = undefined;
|
|
159
|
-
// special falsy value to know that we've already installed before
|
|
160
140
|
hasRanHack = true;
|
|
161
141
|
return -0;
|
|
162
142
|
}
|
|
@@ -175,9 +155,11 @@ export const patchRDTHook = (onActive?: () => unknown): void => {
|
|
|
175
155
|
if (onActive) {
|
|
176
156
|
_onActiveListeners.add(onActive);
|
|
177
157
|
}
|
|
158
|
+
let didNotifyActiveListeners = false;
|
|
178
159
|
try {
|
|
179
160
|
const rdtHook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
180
161
|
if (!rdtHook) return;
|
|
162
|
+
const renderers = ensureRendererMap(rdtHook);
|
|
181
163
|
if (!rdtHook._instrumentationSource) {
|
|
182
164
|
rdtHook.checkDCE = checkDCE;
|
|
183
165
|
rdtHook.supportsFiber = true;
|
|
@@ -185,48 +167,28 @@ export const patchRDTHook = (onActive?: () => unknown): void => {
|
|
|
185
167
|
rdtHook.hasUnsupportedRendererAttached = false;
|
|
186
168
|
rdtHook._instrumentationSource = BIPPY_INSTRUMENTATION_STRING;
|
|
187
169
|
rdtHook._instrumentationIsActive = false;
|
|
188
|
-
//
|
|
170
|
+
// HACK: DevTools detection must happen after setting the source to avoid recursive patching.
|
|
189
171
|
const isReactDevtools = isRealReactDevtools(rdtHook);
|
|
190
172
|
if (!isReactDevtools) {
|
|
191
173
|
rdtHook.on = NO_OP;
|
|
192
174
|
}
|
|
193
|
-
if (
|
|
175
|
+
if (renderers.size) {
|
|
176
|
+
renderers.forEach((renderer) => _renderers.add(renderer));
|
|
194
177
|
rdtHook._instrumentationIsActive = true;
|
|
195
178
|
_onActiveListeners.forEach((listener) => listener());
|
|
196
|
-
|
|
179
|
+
didNotifyActiveListeners = true;
|
|
197
180
|
}
|
|
198
181
|
const prevInject = rdtHook.inject;
|
|
199
|
-
const isRefresh = isReactRefresh(rdtHook);
|
|
200
|
-
if (isRefresh && !isReactDevtools) {
|
|
201
|
-
isReactRefreshOverride = true;
|
|
202
|
-
// but since the underlying implementation doens't care,
|
|
203
|
-
// it's ok: https://github.com/facebook/react/blob/18eaf51bd51fed8dfed661d64c306759101d0bfd/packages/react-refresh/src/ReactFreshRuntime.js#L430
|
|
204
|
-
const injectedRendererId = rdtHook.inject({
|
|
205
|
-
scheduleRefresh() {},
|
|
206
|
-
} as unknown as ReactRenderer);
|
|
207
|
-
if (injectedRendererId) {
|
|
208
|
-
rdtHook._instrumentationIsActive = true;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
182
|
rdtHook.inject = (renderer) => {
|
|
212
183
|
const rendererId = prevInject(renderer);
|
|
213
184
|
_renderers.add(renderer);
|
|
214
|
-
|
|
215
|
-
// react refresh doesn't inject this properly
|
|
216
|
-
// https://github.com/facebook/react/blob/18eaf51bd51fed8dfed661d64c306759101d0bfd/packages/react-refresh/src/ReactFreshRuntime.js#L430
|
|
217
|
-
rdtHook.renderers.set(rendererId, renderer);
|
|
218
|
-
}
|
|
185
|
+
renderers.set(rendererId, renderer);
|
|
219
186
|
rdtHook._instrumentationIsActive = true;
|
|
220
187
|
_onActiveListeners.forEach((listener) => listener());
|
|
221
188
|
return rendererId;
|
|
222
189
|
};
|
|
223
190
|
}
|
|
224
|
-
if (
|
|
225
|
-
rdtHook.renderers.size ||
|
|
226
|
-
rdtHook._instrumentationIsActive ||
|
|
227
|
-
// depending on this to inject is unsafe, since inject could occur before and we wouldn't know
|
|
228
|
-
isReactRefresh()
|
|
229
|
-
) {
|
|
191
|
+
if (!didNotifyActiveListeners && (renderers.size || rdtHook._instrumentationIsActive)) {
|
|
230
192
|
onActive?.();
|
|
231
193
|
}
|
|
232
194
|
} catch {}
|
|
@@ -245,8 +207,7 @@ export const getRDTHook = (onActive?: () => unknown): ReactDevToolsGlobalHook =>
|
|
|
245
207
|
}
|
|
246
208
|
|
|
247
209
|
patchRDTHook(onActive);
|
|
248
|
-
|
|
249
|
-
return globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ as ReactDevToolsGlobalHook;
|
|
210
|
+
return globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ ?? installRDTHook(onActive);
|
|
250
211
|
};
|
|
251
212
|
|
|
252
213
|
export const isClientEnvironment = (): boolean => {
|
|
@@ -257,12 +218,8 @@ export const isClientEnvironment = (): boolean => {
|
|
|
257
218
|
);
|
|
258
219
|
};
|
|
259
220
|
|
|
260
|
-
/**
|
|
261
|
-
* Usually used purely for side effect
|
|
262
|
-
*/
|
|
263
221
|
export const safelyInstallRDTHook = () => {
|
|
264
222
|
try {
|
|
265
|
-
// __REACT_DEVTOOLS_GLOBAL_HOOK__ must exist before React is ever executed
|
|
266
223
|
if (isClientEnvironment()) {
|
|
267
224
|
getRDTHook();
|
|
268
225
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ActivityComponentTag,
|
|
3
|
+
ClassComponentTag,
|
|
4
|
+
ContextConsumerTag,
|
|
5
|
+
DehydratedSuspenseComponentTag,
|
|
6
|
+
ForwardRefTag,
|
|
7
|
+
FragmentTag,
|
|
8
|
+
FunctionComponentTag,
|
|
9
|
+
getReactWorkTags,
|
|
10
|
+
HostComponentTag,
|
|
11
|
+
HostHoistableTag,
|
|
12
|
+
HostPortalTag,
|
|
13
|
+
HostRootTag,
|
|
14
|
+
HostSingletonTag,
|
|
15
|
+
HostTextTag,
|
|
16
|
+
LazyComponentTag,
|
|
17
|
+
LegacyHiddenComponentTag,
|
|
18
|
+
MemoComponentTag,
|
|
19
|
+
OffscreenComponentTag,
|
|
20
|
+
ReactWorkTags,
|
|
21
|
+
SimpleMemoComponentTag,
|
|
22
|
+
SuspenseComponentTag,
|
|
23
|
+
SuspenseListComponentTag,
|
|
24
|
+
ViewTransitionComponentTag,
|
|
25
|
+
} from "./generated/react-work-tags.js";
|
|
26
|
+
export type {
|
|
27
|
+
HostWorkTag,
|
|
28
|
+
ReactWorkTag,
|
|
29
|
+
ReactWorkTagMap,
|
|
30
|
+
ReactWorkTagVersion,
|
|
31
|
+
} from "./generated/react-work-tags.js";
|
|
32
|
+
|
|
33
|
+
// HACK: React does not export Fiber flags. Keep these values aligned with ReactFiberFlags.
|
|
34
|
+
export const ReactFiberFlags = {
|
|
35
|
+
ChildDeletion: 0b10000,
|
|
36
|
+
Cloned: 0b1000,
|
|
37
|
+
ContentReset: 0b100000,
|
|
38
|
+
Hydrating: 0b1000000000000,
|
|
39
|
+
PerformedWork: 0b1,
|
|
40
|
+
Placement: 0b10,
|
|
41
|
+
Snapshot: 0b10000000000,
|
|
42
|
+
Update: 0b100,
|
|
43
|
+
Visibility: 0b10000000000000,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const ReactBuildType = {
|
|
47
|
+
Development: 1,
|
|
48
|
+
Production: 0,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const MutationMask =
|
|
52
|
+
ReactFiberFlags.Placement |
|
|
53
|
+
ReactFiberFlags.Update |
|
|
54
|
+
ReactFiberFlags.ChildDeletion |
|
|
55
|
+
ReactFiberFlags.ContentReset |
|
|
56
|
+
ReactFiberFlags.Hydrating |
|
|
57
|
+
ReactFiberFlags.Visibility |
|
|
58
|
+
ReactFiberFlags.Snapshot;
|
|
59
|
+
|
|
60
|
+
// HACK: React does not export its legacy mode and element symbols, which differ between React 17, 18, and 19.
|
|
61
|
+
export const CONCURRENT_MODE_NUMBER = 0xeacf;
|
|
62
|
+
export const ELEMENT_TYPE_SYMBOL_STRING = "Symbol(react.element)";
|
|
63
|
+
export const TRANSITIONAL_ELEMENT_TYPE_SYMBOL_STRING = "Symbol(react.transitional.element)";
|
|
64
|
+
export const CONCURRENT_MODE_SYMBOL_STRING = "Symbol(react.concurrent_mode)";
|
|
65
|
+
export const DEPRECATED_ASYNC_MODE_SYMBOL_STRING = "Symbol(react.async_mode)";
|
|
66
|
+
export const CONCURRENT_MODE_SYMBOL_DESCRIPTION = "react.concurrent_mode";
|
|
67
|
+
export const DEPRECATED_ASYNC_MODE_SYMBOL_DESCRIPTION = "react.async_mode";
|
package/src/source/constants.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const SERVER_COMPONENT_URL_PREFIXES = ["rsc://", ABOUT_REACT_PREFIX] as c
|
|
|
18
18
|
|
|
19
19
|
export const ANONYMOUS_FILE_PATTERNS = ["<anonymous>", "eval", ""] as const;
|
|
20
20
|
|
|
21
|
-
export const SOURCE_FILE_EXTENSION_REGEX = /\.(jsx|
|
|
21
|
+
export const SOURCE_FILE_EXTENSION_REGEX = /\.(cjs|cts|js|jsx|mdx|mjs|mts|ts|tsx)$/;
|
|
22
22
|
|
|
23
23
|
export const BUNDLED_FILE_PATTERN_REGEX =
|
|
24
24
|
/(\.min|bundle|chunk|vendor|vendors|runtime|polyfill|polyfills)\.(js|mjs|cjs)$|(chunk|bundle|vendor|vendors|runtime|polyfill|polyfills|framework|app|main|index)[-_.][A-Za-z0-9_-]{4,}\.(js|mjs|cjs)$|[\da-f]{8,}\.(js|mjs|cjs)$|[-_.][\da-f]{20,}\.(js|mjs|cjs)$|\/dist\/|\/build\/|\/.next\/|\/out\/|\/node_modules\/|\.webpack\.|\.vite\.|\.turbopack\./i;
|
package/src/source/get-source.ts
CHANGED
|
@@ -171,6 +171,7 @@ export const normalizeFileName = (fileName: string): string => {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
let normalizedFileName = fileName;
|
|
174
|
+
const isWindowsDrivePath = /^[a-zA-Z]:[\\/]/.test(normalizedFileName);
|
|
174
175
|
|
|
175
176
|
const isHttpUrl =
|
|
176
177
|
normalizedFileName.startsWith("http://") || normalizedFileName.startsWith("https://");
|
|
@@ -214,7 +215,7 @@ export const normalizeFileName = (fileName: string): string => {
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
if (SCHEME_REGEX.test(normalizedFileName)) {
|
|
218
|
+
if (!isWindowsDrivePath && SCHEME_REGEX.test(normalizedFileName)) {
|
|
218
219
|
const schemeMatch = normalizedFileName.match(SCHEME_REGEX);
|
|
219
220
|
if (schemeMatch) {
|
|
220
221
|
normalizedFileName = normalizedFileName.slice(schemeMatch[0].length);
|