bippy 0.6.1 → 0.7.0-dev.697d535

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.
Files changed (67) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +223 -463
  3. package/dist/core.cjs +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/errors.d.cts +410 -0
  6. package/dist/errors.d.ts +410 -0
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.d.cts +153 -3
  9. package/dist/index.d.ts +153 -3
  10. package/dist/index.js +1 -1
  11. package/dist/install-hook-only.cjs +1 -1
  12. package/dist/install-hook-only.d.cts +9 -1
  13. package/dist/install-hook-only.d.ts +9 -1
  14. package/dist/install-hook-only.js +1 -1
  15. package/dist/rdt-hook.cjs +1 -1
  16. package/dist/rdt-hook.js +1 -1
  17. package/dist/source.cjs +14 -5
  18. package/dist/source.d.cts +86 -69
  19. package/dist/source.d.ts +86 -69
  20. package/dist/source.js +14 -5
  21. package/package.json +26 -27
  22. package/src/core.ts +353 -685
  23. package/src/errors.ts +34 -0
  24. package/src/index.ts +1 -0
  25. package/src/install-hook-only.ts +2 -2
  26. package/src/rdt-hook.ts +160 -161
  27. package/src/react-internals/generated/react-work-tags.ts +318 -0
  28. package/src/react-internals/index.ts +67 -0
  29. package/src/react-internals/semver.ts +80 -0
  30. package/src/react-internals/types.ts +186 -0
  31. package/src/react.ts +76 -0
  32. package/src/source/constants.ts +1 -1
  33. package/src/source/error-stack.ts +11 -0
  34. package/src/source/get-display-name-from-source.ts +44 -40
  35. package/src/source/get-source.ts +43 -26
  36. package/src/source/index.ts +11 -1
  37. package/src/source/inspect-hooks.ts +220 -207
  38. package/src/source/owner-stack.ts +119 -174
  39. package/src/source/parse-debug-stack.ts +4 -4
  40. package/src/source/parse-hook-names.ts +14 -53
  41. package/src/source/parse-stack.ts +14 -31
  42. package/src/source/renderer-dispatchers.ts +30 -0
  43. package/src/source/symbolication.ts +709 -120
  44. package/dist/core.d.cts +0 -214
  45. package/dist/core.d.ts +0 -214
  46. package/dist/core2.d.cts +0 -3
  47. package/dist/core2.d.ts +0 -3
  48. package/dist/get-source.cjs +0 -19
  49. package/dist/get-source.js +0 -19
  50. package/dist/index.iife.js +0 -9
  51. package/dist/install-hook-only.iife.js +0 -9
  52. package/dist/react-refresh.cjs +0 -9
  53. package/dist/react-refresh.d.cts +0 -66
  54. package/dist/react-refresh.d.ts +0 -66
  55. package/dist/react-refresh.js +0 -9
  56. package/dist/unsubscribe.d.cts +0 -298
  57. package/dist/unsubscribe.d.ts +0 -298
  58. package/src/react-refresh/constants.ts +0 -9
  59. package/src/react-refresh/detect-hmr-transport.ts +0 -33
  60. package/src/react-refresh/index.ts +0 -173
  61. package/src/react-refresh/metro-hmr-transport.ts +0 -188
  62. package/src/react-refresh/next-webpack-hmr-transport.ts +0 -72
  63. package/src/react-refresh/normalize-hmr-file-path.ts +0 -24
  64. package/src/react-refresh/types.ts +0 -7
  65. package/src/react-refresh/vite-hmr-transport.ts +0 -116
  66. package/src/types.ts +0 -438
  67. package/src/unsubscribe.ts +0 -17
@@ -1,5 +1,4 @@
1
1
  export interface StackFrame {
2
- args?: unknown[];
3
2
  columnNumber?: number;
4
3
  lineNumber?: number;
5
4
  // start of the enclosing function (the definition, not the call site);
@@ -16,8 +15,6 @@ export interface StackFrame {
16
15
  }
17
16
 
18
17
  export interface ParseOptions {
19
- slice?: number | [number, number];
20
- allowEmpty?: boolean;
21
18
  includeInElement?: boolean;
22
19
  }
23
20
 
@@ -31,22 +28,22 @@ export const parseStack = (stackString: string, options?: ParseOptions): StackFr
31
28
  const frames: StackFrame[] = [];
32
29
  for (const rawLine of lines) {
33
30
  if (/^\s*at\s+/.test(rawLine)) {
34
- const parsed = parseV8OrIeString(rawLine, undefined)[0];
31
+ const parsed = parseV8OrIeString(rawLine)[0];
35
32
  if (parsed) frames.push(parsed);
36
33
  } else if (/^\s*in\s+/.test(rawLine)) {
37
34
  const elementName = rawLine.replace(/^\s*in\s+/, "").replace(/\s*\(at .*\)$/, "");
38
35
  frames.push({ functionName: elementName, source: rawLine });
39
36
  } else if (rawLine.match(FIREFOX_SAFARI_STACK_REGEXP)) {
40
- const parsed = parseFFOrSafariString(rawLine, undefined)[0];
37
+ const parsed = parseFFOrSafariString(rawLine)[0];
41
38
  if (parsed) frames.push(parsed);
42
39
  }
43
40
  }
44
- return applySlice(frames, options);
41
+ return frames;
45
42
  }
46
43
  if (stackString.match(CHROME_IE_STACK_REGEXP)) {
47
- return parseV8OrIeString(stackString, options);
44
+ return parseV8OrIeString(stackString);
48
45
  }
49
- return parseFFOrSafariString(stackString, options);
46
+ return parseFFOrSafariString(stackString);
50
47
  };
51
48
 
52
49
  export const extractLocation = (
@@ -66,21 +63,10 @@ export const extractLocation = (
66
63
  return [parts[1], parts[2] || undefined, parts[3] || undefined] as const;
67
64
  };
68
65
 
69
- const applySlice = <T>(lines: T[], options?: ParseOptions): T[] => {
70
- if (options && options.slice != null) {
71
- if (Array.isArray(options.slice)) return lines.slice(options.slice[0], options.slice[1]);
72
- return lines.slice(0, options.slice);
73
- }
74
- return lines;
75
- };
76
-
77
- export const parseV8OrIeString = (stack: string, options?: ParseOptions): StackFrame[] => {
78
- const filteredLines = applySlice(
79
- stack.split("\n").filter((line) => {
80
- return !!line.match(CHROME_IE_STACK_REGEXP);
81
- }),
82
- options,
83
- );
66
+ export const parseV8OrIeString = (stack: string): StackFrame[] => {
67
+ const filteredLines = stack.split("\n").filter((line) => {
68
+ return !!line.match(CHROME_IE_STACK_REGEXP);
69
+ });
84
70
 
85
71
  return filteredLines.map((line): StackFrame => {
86
72
  let currentLine = line;
@@ -100,7 +86,7 @@ export const parseV8OrIeString = (stack: string, options?: ParseOptions): StackF
100
86
 
101
87
  const locationParts = extractLocation(locationMatch ? locationMatch[1] : sanitizedLine);
102
88
  const functionName = (locationMatch && sanitizedLine) || undefined;
103
- const fileName = ["eval", "<anonymous>"].includes(locationParts[0])
89
+ const fileName = ["eval", "<anonymous>", "(native)"].includes(locationParts[0])
104
90
  ? undefined
105
91
  : locationParts[0];
106
92
 
@@ -114,13 +100,10 @@ export const parseV8OrIeString = (stack: string, options?: ParseOptions): StackF
114
100
  });
115
101
  };
116
102
 
117
- export const parseFFOrSafariString = (stack: string, options?: ParseOptions): StackFrame[] => {
118
- const filteredLines = applySlice(
119
- stack.split("\n").filter((line) => {
120
- return !line.match(SAFARI_NATIVE_CODE_REGEXP);
121
- }),
122
- options,
123
- );
103
+ export const parseFFOrSafariString = (stack: string): StackFrame[] => {
104
+ const filteredLines = stack.split("\n").filter((line) => {
105
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
106
+ });
124
107
 
125
108
  return filteredLines.map((line): StackFrame => {
126
109
  let currentLine = line;
@@ -0,0 +1,30 @@
1
+ import type { RendererDispatcherRef } from "../react-internals/index.js";
2
+ import { _renderers, getRDTHook } from "../rdt-hook.js";
3
+
4
+ export const getRendererDispatcherRefs = (): RendererDispatcherRef[] => {
5
+ const rdtHook = getRDTHook();
6
+ const renderers = new Set([..._renderers, ...rdtHook.renderers.values()]);
7
+ const currentDispatcherRefs: RendererDispatcherRef[] = [];
8
+ const seenCurrentDispatcherRefs = new Set<object>();
9
+ for (const renderer of renderers) {
10
+ const currentDispatcherRef = renderer.currentDispatcherRef;
11
+ if (!currentDispatcherRef || seenCurrentDispatcherRefs.has(currentDispatcherRef)) continue;
12
+ seenCurrentDispatcherRefs.add(currentDispatcherRef);
13
+ currentDispatcherRefs.push(currentDispatcherRef);
14
+ }
15
+ return currentDispatcherRefs;
16
+ };
17
+
18
+ export const readDispatcher = (currentDispatcherRef: RendererDispatcherRef): unknown =>
19
+ "H" in currentDispatcherRef ? currentDispatcherRef.H : currentDispatcherRef.current;
20
+
21
+ export const writeDispatcher = (
22
+ currentDispatcherRef: RendererDispatcherRef,
23
+ dispatcher: unknown,
24
+ ): void => {
25
+ if ("H" in currentDispatcherRef) {
26
+ currentDispatcherRef.H = dispatcher;
27
+ } else {
28
+ currentDispatcherRef.current = dispatcher;
29
+ }
30
+ };