bippy 0.6.1-dev.3a24abf → 0.6.1-dev.b88fcb4
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 +7 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +39 -41
- package/dist/core.d.ts +39 -41
- 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} +205 -31
- package/dist/{types.d.ts → errors.d.ts} +205 -31
- 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 -13
- package/dist/source.d.cts +27 -9
- package/dist/source.d.ts +27 -9
- package/dist/source.js +13 -13
- package/package.json +10 -6
- package/src/core.ts +269 -224
- package/src/errors.ts +99 -0
- package/src/rdt-hook.ts +154 -99
- package/src/react-internals/generated/react-work-tags.ts +314 -0
- package/src/react-internals/index.ts +67 -0
- package/src/react-internals/semver.ts +78 -0
- package/src/{types.ts → react-internals/types.ts} +13 -3
- package/src/source/error-stack.ts +11 -0
- package/src/source/get-display-name-from-source.ts +1 -1
- package/src/source/get-source.ts +2 -2
- package/src/source/index.ts +9 -1
- package/src/source/inspect-hooks.ts +199 -165
- package/src/source/owner-stack.ts +26 -39
- package/src/source/parse-debug-stack.ts +4 -4
- package/src/source/parse-hook-names.ts +1 -1
- package/src/source/symbolication.ts +468 -101
- package/src/generated/react-work-tags.ts +0 -169
- package/src/react-internals.ts +0 -67
- package/src/unsubscribe.ts +0 -17
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import { getDisplayName, getType, traverseFiber } from "../core.js";
|
|
2
2
|
import { _renderers, getRDTHook } from "../rdt-hook.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
HostHoistableTag,
|
|
10
|
-
HostSingletonTag,
|
|
11
|
-
LazyComponentTag,
|
|
12
|
-
SimpleMemoComponentTag,
|
|
13
|
-
SuspenseComponentTag,
|
|
14
|
-
SuspenseListComponentTag,
|
|
15
|
-
ViewTransitionComponentTag,
|
|
16
|
-
} from "../react-internals.js";
|
|
17
|
-
import type { Fiber, RendererDispatcherRef, ServerComponentInfo } from "../types.js";
|
|
3
|
+
import { getReactWorkTagsForFiber } from "../react-internals/index.js";
|
|
4
|
+
import type {
|
|
5
|
+
Fiber,
|
|
6
|
+
RendererDispatcherRef,
|
|
7
|
+
ServerComponentInfo,
|
|
8
|
+
} from "../react-internals/index.js";
|
|
18
9
|
import {
|
|
19
10
|
SERVER_FRAME_MARKER,
|
|
20
11
|
SERVER_ENV_PATTERN,
|
|
21
12
|
SERVER_COMPONENT_URL_PREFIXES,
|
|
22
13
|
} from "./constants.js";
|
|
23
|
-
|
|
14
|
+
import { getPrepareStackTrace, setPrepareStackTrace } from "./error-stack.js";
|
|
24
15
|
import { parseDebugStack } from "./parse-debug-stack.js";
|
|
25
16
|
import { parseStack, StackFrame } from "./parse-stack.js";
|
|
26
17
|
import { symbolicateStack } from "./symbolication.js";
|
|
@@ -160,9 +151,8 @@ const describeNativeComponentFrame = (
|
|
|
160
151
|
return cachedFrame;
|
|
161
152
|
}
|
|
162
153
|
|
|
163
|
-
const previousPrepareStackTrace =
|
|
164
|
-
|
|
165
|
-
(Error as { prepareStackTrace?: typeof Error.prepareStackTrace }).prepareStackTrace = undefined;
|
|
154
|
+
const previousPrepareStackTrace = getPrepareStackTrace();
|
|
155
|
+
setPrepareStackTrace(undefined);
|
|
166
156
|
reEntry = true;
|
|
167
157
|
|
|
168
158
|
const dispatcherSnapshots = clearRendererDispatchers();
|
|
@@ -173,7 +163,7 @@ const describeNativeComponentFrame = (
|
|
|
173
163
|
try {
|
|
174
164
|
// HACK: Run the control and sample under the same property name so their stacks share a frame.
|
|
175
165
|
const RunInRootFrame = {
|
|
176
|
-
DetermineComponentFrameRoot() {
|
|
166
|
+
DetermineComponentFrameRoot(this: void) {
|
|
177
167
|
let control: unknown;
|
|
178
168
|
try {
|
|
179
169
|
if (construct) {
|
|
@@ -325,7 +315,7 @@ const describeNativeComponentFrame = (
|
|
|
325
315
|
} finally {
|
|
326
316
|
reEntry = false;
|
|
327
317
|
|
|
328
|
-
|
|
318
|
+
setPrepareStackTrace(previousPrepareStackTrace);
|
|
329
319
|
|
|
330
320
|
restoreRendererDispatchers(dispatcherSnapshots);
|
|
331
321
|
console.error = previousConsoleError;
|
|
@@ -341,32 +331,33 @@ const describeNativeComponentFrame = (
|
|
|
341
331
|
// https://github.com/facebook/react/blob/ac3e705a18696168acfcaed39dce0cfaa6be8836/packages/react-reconciler/src/ReactFiberComponentStack.js#L180
|
|
342
332
|
export const describeFiber = (fiber: Fiber, childFiber: Fiber | null): string => {
|
|
343
333
|
let stackFrame = "";
|
|
334
|
+
const workTags = getReactWorkTagsForFiber(fiber);
|
|
344
335
|
switch (fiber.tag) {
|
|
345
|
-
case
|
|
336
|
+
case workTags.ActivityComponent:
|
|
346
337
|
stackFrame = describeBuiltInComponentFrame("Activity");
|
|
347
338
|
break;
|
|
348
|
-
case
|
|
339
|
+
case workTags.ClassComponent:
|
|
349
340
|
stackFrame = describeNativeComponentFrame(fiber.type, true);
|
|
350
341
|
break;
|
|
351
|
-
case
|
|
342
|
+
case workTags.ForwardRef:
|
|
352
343
|
stackFrame = describeNativeComponentFrame(getType(fiber.type) ?? fiber.type, false);
|
|
353
344
|
break;
|
|
354
|
-
case
|
|
355
|
-
case
|
|
345
|
+
case workTags.FunctionComponent:
|
|
346
|
+
case workTags.SimpleMemoComponent:
|
|
356
347
|
stackFrame = describeNativeComponentFrame(fiber.type, false);
|
|
357
348
|
break;
|
|
358
|
-
case
|
|
359
|
-
case
|
|
360
|
-
case
|
|
349
|
+
case workTags.HostComponent:
|
|
350
|
+
case workTags.HostHoistable:
|
|
351
|
+
case workTags.HostSingleton:
|
|
361
352
|
if (typeof fiber.type === "string") {
|
|
362
353
|
stackFrame = describeBuiltInComponentFrame(fiber.type);
|
|
363
354
|
}
|
|
364
355
|
break;
|
|
365
|
-
case
|
|
356
|
+
case workTags.LazyComponent:
|
|
366
357
|
// TODO: When we support Thenables as component types we should rename this.
|
|
367
358
|
stackFrame = describeBuiltInComponentFrame("Lazy");
|
|
368
359
|
break;
|
|
369
|
-
case
|
|
360
|
+
case workTags.SuspenseComponent:
|
|
370
361
|
if (fiber.child !== childFiber && childFiber !== null) {
|
|
371
362
|
// If we came from the second Fiber then we're in the Suspense Fallback.
|
|
372
363
|
stackFrame = describeBuiltInComponentFrame("Suspense Fallback");
|
|
@@ -374,10 +365,10 @@ export const describeFiber = (fiber: Fiber, childFiber: Fiber | null): string =>
|
|
|
374
365
|
stackFrame = describeBuiltInComponentFrame("Suspense");
|
|
375
366
|
}
|
|
376
367
|
break;
|
|
377
|
-
case
|
|
368
|
+
case workTags.SuspenseListComponent:
|
|
378
369
|
stackFrame = describeBuiltInComponentFrame("SuspenseList");
|
|
379
370
|
break;
|
|
380
|
-
case
|
|
371
|
+
case workTags.ViewTransitionComponent:
|
|
381
372
|
// Note: enableViewTransition feature flag is not available in this codebase,
|
|
382
373
|
// so we'll always include ViewTransition
|
|
383
374
|
stackFrame = describeBuiltInComponentFrame("ViewTransition");
|
|
@@ -406,8 +397,8 @@ export const getFallbackParentStack = (thisFiber: Fiber): string => {
|
|
|
406
397
|
// Since we don't have __DEV__ in this codebase, we'll check for _debugInfo
|
|
407
398
|
const debugInfo = currentFiber._debugInfo;
|
|
408
399
|
if (debugInfo && Array.isArray(debugInfo)) {
|
|
409
|
-
for (let
|
|
410
|
-
const debugEntry = debugInfo[
|
|
400
|
+
for (let debugInfoIndex = debugInfo.length - 1; debugInfoIndex >= 0; debugInfoIndex--) {
|
|
401
|
+
const debugEntry = debugInfo[debugInfoIndex];
|
|
411
402
|
if (typeof debugEntry.name === "string") {
|
|
412
403
|
componentStack += describeDebugInfoFrame(debugEntry.name, debugEntry.env);
|
|
413
404
|
}
|
|
@@ -445,14 +436,10 @@ export const getFallbackParentStack = (thisFiber: Fiber): string => {
|
|
|
445
436
|
* @see https://github.com/facebook/react/blob/main/packages/react-devtools-shared/src/backend/shared/DevToolsOwnerStack.js#L12
|
|
446
437
|
*/
|
|
447
438
|
export const formatOwnerStack = (stack: string): string => {
|
|
448
|
-
const prevPrepareStackTrace = Error.prepareStackTrace;
|
|
449
|
-
// HACK: V8 API allows undefined but bun-types declares it as non-optional
|
|
450
|
-
(Error as { prepareStackTrace?: typeof Error.prepareStackTrace }).prepareStackTrace = undefined;
|
|
451
439
|
let formattedStack = stack;
|
|
452
440
|
if (!formattedStack) {
|
|
453
441
|
return "";
|
|
454
442
|
}
|
|
455
|
-
Error.prepareStackTrace = prevPrepareStackTrace;
|
|
456
443
|
|
|
457
444
|
if (formattedStack.startsWith("Error: react-stack-top-frame\n")) {
|
|
458
445
|
// V8's default formatting prefixes with the error message which we
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSX_FACTORY_FRAME_COUNT, REACT_STACK_BOTTOM_FRAME_PATTERNS } from "./constants.js";
|
|
2
|
+
import { getPrepareStackTrace, setPrepareStackTrace } from "./error-stack.js";
|
|
2
3
|
import { parseStack, StackFrame } from "./parse-stack.js";
|
|
3
4
|
|
|
4
5
|
interface V8CallSite {
|
|
@@ -117,14 +118,13 @@ export const parseDebugStack = (debugStack: Error): ParsedDebugStack => {
|
|
|
117
118
|
}
|
|
118
119
|
return stackString;
|
|
119
120
|
};
|
|
120
|
-
const previousPrepareStackTrace =
|
|
121
|
-
|
|
122
|
-
Error.prepareStackTrace = collectFramesAndFormatStack as typeof Error.prepareStackTrace;
|
|
121
|
+
const previousPrepareStackTrace = getPrepareStackTrace();
|
|
122
|
+
setPrepareStackTrace(collectFramesAndFormatStack);
|
|
123
123
|
let stackString: string;
|
|
124
124
|
try {
|
|
125
125
|
stackString = String(debugStack.stack);
|
|
126
126
|
} finally {
|
|
127
|
-
|
|
127
|
+
setPrepareStackTrace(previousPrepareStackTrace);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
const result = structuredResult ?? parseMaterializedStack(stackString);
|
|
@@ -35,7 +35,7 @@ const flattenHooksTree = (hooksTree: HooksTree): HooksNode[] => {
|
|
|
35
35
|
|
|
36
36
|
const findSourceContentByFileName = (
|
|
37
37
|
sources: string[],
|
|
38
|
-
sourcesContent: string
|
|
38
|
+
sourcesContent: Array<string | null> | undefined,
|
|
39
39
|
fileName: string,
|
|
40
40
|
): string | null => {
|
|
41
41
|
if (!sourcesContent) return null;
|