bippy 0.6.1-dev.3a24abf → 0.6.1-dev.d7876ea
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 +7 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +22 -24
- package/dist/core.d.ts +22 -24
- package/dist/core.js +1 -1
- package/dist/core2.cjs +1 -1
- package/dist/core2.d.cts +3 -3
- package/dist/core2.d.ts +3 -3
- package/dist/core2.js +1 -1
- package/dist/{types.d.cts → errors.d.cts} +174 -29
- package/dist/{types.d.ts → errors.d.ts} +174 -29
- 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.iife.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 +18 -9
- package/dist/source.d.ts +18 -9
- package/dist/source.js +13 -13
- package/package.json +9 -5
- package/src/core.ts +195 -156
- package/src/errors.ts +99 -0
- package/src/generated/react-work-tags.d.ts +261 -0
- package/src/generated/react-work-tags.js +240 -0
- package/src/rdt-hook.ts +144 -96
- package/src/react-internals.ts +43 -45
- package/src/semver.ts +78 -0
- package/src/source/error-stack.ts +11 -0
- package/src/source/index.ts +9 -1
- package/src/source/inspect-hooks.ts +199 -164
- package/src/source/owner-stack.ts +21 -38
- package/src/source/parse-debug-stack.ts +4 -4
- package/src/source/symbolication.ts +358 -103
- package/src/types.ts +12 -2
- package/src/generated/react-work-tags.ts +0 -169
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { getDisplayName, getType, traverseFiber } from "../core.js";
|
|
2
2
|
import { _renderers, getRDTHook } from "../rdt-hook.js";
|
|
3
|
-
import {
|
|
4
|
-
ActivityComponentTag,
|
|
5
|
-
ClassComponentTag,
|
|
6
|
-
ForwardRefTag,
|
|
7
|
-
FunctionComponentTag,
|
|
8
|
-
HostComponentTag,
|
|
9
|
-
HostHoistableTag,
|
|
10
|
-
HostSingletonTag,
|
|
11
|
-
LazyComponentTag,
|
|
12
|
-
SimpleMemoComponentTag,
|
|
13
|
-
SuspenseComponentTag,
|
|
14
|
-
SuspenseListComponentTag,
|
|
15
|
-
ViewTransitionComponentTag,
|
|
16
|
-
} from "../react-internals.js";
|
|
3
|
+
import { getReactWorkTagsForFiber } from "../react-internals.js";
|
|
17
4
|
import type { Fiber, RendererDispatcherRef, ServerComponentInfo } from "../types.js";
|
|
18
5
|
import {
|
|
19
6
|
SERVER_FRAME_MARKER,
|
|
20
7
|
SERVER_ENV_PATTERN,
|
|
21
8
|
SERVER_COMPONENT_URL_PREFIXES,
|
|
22
9
|
} from "./constants.js";
|
|
23
|
-
|
|
10
|
+
import { getPrepareStackTrace, setPrepareStackTrace } from "./error-stack.js";
|
|
24
11
|
import { parseDebugStack } from "./parse-debug-stack.js";
|
|
25
12
|
import { parseStack, StackFrame } from "./parse-stack.js";
|
|
26
13
|
import { symbolicateStack } from "./symbolication.js";
|
|
@@ -160,9 +147,8 @@ const describeNativeComponentFrame = (
|
|
|
160
147
|
return cachedFrame;
|
|
161
148
|
}
|
|
162
149
|
|
|
163
|
-
const previousPrepareStackTrace =
|
|
164
|
-
|
|
165
|
-
(Error as { prepareStackTrace?: typeof Error.prepareStackTrace }).prepareStackTrace = undefined;
|
|
150
|
+
const previousPrepareStackTrace = getPrepareStackTrace();
|
|
151
|
+
setPrepareStackTrace(undefined);
|
|
166
152
|
reEntry = true;
|
|
167
153
|
|
|
168
154
|
const dispatcherSnapshots = clearRendererDispatchers();
|
|
@@ -173,7 +159,7 @@ const describeNativeComponentFrame = (
|
|
|
173
159
|
try {
|
|
174
160
|
// HACK: Run the control and sample under the same property name so their stacks share a frame.
|
|
175
161
|
const RunInRootFrame = {
|
|
176
|
-
DetermineComponentFrameRoot() {
|
|
162
|
+
DetermineComponentFrameRoot(this: void) {
|
|
177
163
|
let control: unknown;
|
|
178
164
|
try {
|
|
179
165
|
if (construct) {
|
|
@@ -325,7 +311,7 @@ const describeNativeComponentFrame = (
|
|
|
325
311
|
} finally {
|
|
326
312
|
reEntry = false;
|
|
327
313
|
|
|
328
|
-
|
|
314
|
+
setPrepareStackTrace(previousPrepareStackTrace);
|
|
329
315
|
|
|
330
316
|
restoreRendererDispatchers(dispatcherSnapshots);
|
|
331
317
|
console.error = previousConsoleError;
|
|
@@ -341,32 +327,33 @@ const describeNativeComponentFrame = (
|
|
|
341
327
|
// https://github.com/facebook/react/blob/ac3e705a18696168acfcaed39dce0cfaa6be8836/packages/react-reconciler/src/ReactFiberComponentStack.js#L180
|
|
342
328
|
export const describeFiber = (fiber: Fiber, childFiber: Fiber | null): string => {
|
|
343
329
|
let stackFrame = "";
|
|
330
|
+
const workTags = getReactWorkTagsForFiber(fiber);
|
|
344
331
|
switch (fiber.tag) {
|
|
345
|
-
case
|
|
332
|
+
case workTags.ActivityComponent:
|
|
346
333
|
stackFrame = describeBuiltInComponentFrame("Activity");
|
|
347
334
|
break;
|
|
348
|
-
case
|
|
335
|
+
case workTags.ClassComponent:
|
|
349
336
|
stackFrame = describeNativeComponentFrame(fiber.type, true);
|
|
350
337
|
break;
|
|
351
|
-
case
|
|
338
|
+
case workTags.ForwardRef:
|
|
352
339
|
stackFrame = describeNativeComponentFrame(getType(fiber.type) ?? fiber.type, false);
|
|
353
340
|
break;
|
|
354
|
-
case
|
|
355
|
-
case
|
|
341
|
+
case workTags.FunctionComponent:
|
|
342
|
+
case workTags.SimpleMemoComponent:
|
|
356
343
|
stackFrame = describeNativeComponentFrame(fiber.type, false);
|
|
357
344
|
break;
|
|
358
|
-
case
|
|
359
|
-
case
|
|
360
|
-
case
|
|
345
|
+
case workTags.HostComponent:
|
|
346
|
+
case workTags.HostHoistable:
|
|
347
|
+
case workTags.HostSingleton:
|
|
361
348
|
if (typeof fiber.type === "string") {
|
|
362
349
|
stackFrame = describeBuiltInComponentFrame(fiber.type);
|
|
363
350
|
}
|
|
364
351
|
break;
|
|
365
|
-
case
|
|
352
|
+
case workTags.LazyComponent:
|
|
366
353
|
// TODO: When we support Thenables as component types we should rename this.
|
|
367
354
|
stackFrame = describeBuiltInComponentFrame("Lazy");
|
|
368
355
|
break;
|
|
369
|
-
case
|
|
356
|
+
case workTags.SuspenseComponent:
|
|
370
357
|
if (fiber.child !== childFiber && childFiber !== null) {
|
|
371
358
|
// If we came from the second Fiber then we're in the Suspense Fallback.
|
|
372
359
|
stackFrame = describeBuiltInComponentFrame("Suspense Fallback");
|
|
@@ -374,10 +361,10 @@ export const describeFiber = (fiber: Fiber, childFiber: Fiber | null): string =>
|
|
|
374
361
|
stackFrame = describeBuiltInComponentFrame("Suspense");
|
|
375
362
|
}
|
|
376
363
|
break;
|
|
377
|
-
case
|
|
364
|
+
case workTags.SuspenseListComponent:
|
|
378
365
|
stackFrame = describeBuiltInComponentFrame("SuspenseList");
|
|
379
366
|
break;
|
|
380
|
-
case
|
|
367
|
+
case workTags.ViewTransitionComponent:
|
|
381
368
|
// Note: enableViewTransition feature flag is not available in this codebase,
|
|
382
369
|
// so we'll always include ViewTransition
|
|
383
370
|
stackFrame = describeBuiltInComponentFrame("ViewTransition");
|
|
@@ -406,8 +393,8 @@ export const getFallbackParentStack = (thisFiber: Fiber): string => {
|
|
|
406
393
|
// Since we don't have __DEV__ in this codebase, we'll check for _debugInfo
|
|
407
394
|
const debugInfo = currentFiber._debugInfo;
|
|
408
395
|
if (debugInfo && Array.isArray(debugInfo)) {
|
|
409
|
-
for (let
|
|
410
|
-
const debugEntry = debugInfo[
|
|
396
|
+
for (let debugInfoIndex = debugInfo.length - 1; debugInfoIndex >= 0; debugInfoIndex--) {
|
|
397
|
+
const debugEntry = debugInfo[debugInfoIndex];
|
|
411
398
|
if (typeof debugEntry.name === "string") {
|
|
412
399
|
componentStack += describeDebugInfoFrame(debugEntry.name, debugEntry.env);
|
|
413
400
|
}
|
|
@@ -445,14 +432,10 @@ export const getFallbackParentStack = (thisFiber: Fiber): string => {
|
|
|
445
432
|
* @see https://github.com/facebook/react/blob/main/packages/react-devtools-shared/src/backend/shared/DevToolsOwnerStack.js#L12
|
|
446
433
|
*/
|
|
447
434
|
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
435
|
let formattedStack = stack;
|
|
452
436
|
if (!formattedStack) {
|
|
453
437
|
return "";
|
|
454
438
|
}
|
|
455
|
-
Error.prepareStackTrace = prevPrepareStackTrace;
|
|
456
439
|
|
|
457
440
|
if (formattedStack.startsWith("Error: react-stack-top-frame\n")) {
|
|
458
441
|
// 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);
|