bippy 0.3.16 → 0.3.17

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 (41) hide show
  1. package/README.md +25 -3
  2. package/dist/{core-BS9Kf-6A.cjs → core-BBir3S-T.cjs} +11 -227
  3. package/dist/core-D6O33Pnm.d.cts +225 -0
  4. package/dist/{core-BOYfIZ0s.d.cts → core-DACuZw71.d.ts} +33 -101
  5. package/dist/{core-C20dLY3P.js → core-wkpXT9Yv.js} +2 -151
  6. package/dist/core.cjs +13 -12
  7. package/dist/core.d.cts +2 -1
  8. package/dist/core.d.ts +2 -1
  9. package/dist/core.js +2 -1
  10. package/dist/experiments/inspect.cjs +6 -5
  11. package/dist/experiments/inspect.js +4 -3
  12. package/dist/index.cjs +14 -13
  13. package/dist/index.d.cts +3 -2
  14. package/dist/index.d.ts +3 -2
  15. package/dist/index.iife.js +1 -1
  16. package/dist/index.js +3 -2
  17. package/dist/jsx-runtime.cjs +3 -2
  18. package/dist/jsx-runtime.d.cts +3 -2
  19. package/dist/jsx-runtime.d.ts +3 -2
  20. package/dist/jsx-runtime.js +3 -2
  21. package/dist/override.cjs +123 -0
  22. package/dist/override.d.cts +14 -0
  23. package/dist/override.d.ts +14 -0
  24. package/dist/override.js +120 -0
  25. package/dist/rdt-hook-Cm8ZY78C.cjs +226 -0
  26. package/dist/rdt-hook-D8LwQB-4.js +160 -0
  27. package/dist/{source-l0-0Utl0.js → source-CbtKVSlW.js} +2 -1
  28. package/dist/{source-CpUl2rbU.cjs → source-ChLNXW9d.cjs} +5 -4
  29. package/dist/source.cjs +5 -74
  30. package/dist/source.d.cts +2 -3
  31. package/dist/source.d.ts +2 -3
  32. package/dist/source.js +5 -4
  33. package/dist/{src-CYAt7ssK.js → src-C5k3J1-J.js} +1 -1
  34. package/dist/{src-8X9f2vzK.cjs → src-CnUcXxCc.cjs} +2 -2
  35. package/dist/types-B532E9im.d.cts +74 -0
  36. package/dist/types-CRmgqKuE.d.ts +74 -0
  37. package/package.json +11 -1
  38. package/dist/core-CmL25iLV.d.ts +0 -293
  39. package/dist/source.iife.js +0 -14
  40. /package/dist/{index-BtBZHVmz.d.cts → index-D25YYUbd.d.ts} +0 -0
  41. /package/dist/{index-D0E78WnU.d.ts → index-D_TYgLX3.d.cts} +0 -0
package/README.md CHANGED
@@ -82,7 +82,7 @@ while all of the information is there, it's not super easy to work with, and cha
82
82
 
83
83
  however, fibers aren't directly accessible by the user. so, we have to hack our way around to accessing it.
84
84
 
85
- luckily, react [reads from a property](https://github.com/facebook/react/blob/6a4b46cd70d2672bc4be59dcb5b8dede22ed0cef/packages/react-reconciler/src/reactFiberDevToolsHook.js#L48) in the window object: `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` and runs handlers on it when certain events happen. this property must exist before react's bundle is executed. this is intended for react devtools, but we can use it to our advantage.
85
+ luckily, react [reads from a property](https://github.com/facebook/react/blob/6a4b46cd70d2672bc4be59dcb5b8dede22ed0cef/packages/react-reconciler/src/ReactFiberDevToolsHook.js#L48) in the window object: `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` and runs handlers on it when certain events happen. this property must exist before react's bundle is executed. this is intended for react devtools, but we can use it to our advantage.
86
86
 
87
87
  here's what it roughly looks like:
88
88
 
@@ -397,7 +397,7 @@ import { isValidFiber } from 'bippy';
397
397
  console.log(isValidFiber(fiber));
398
398
  ```
399
399
 
400
- ## getFiberFromHostInstance
400
+ ### getFiberFromHostInstance
401
401
 
402
402
  returns the fiber associated with a given host instance (e.g., a DOM element).
403
403
 
@@ -408,7 +408,7 @@ const fiber = getFiberFromHostInstance(document.querySelector('div'));
408
408
  console.log(fiber);
409
409
  ```
410
410
 
411
- ## getLatestFiber
411
+ ### getLatestFiber
412
412
 
413
413
  returns the latest fiber (since it may be double-buffered). usually use this in combination with `getFiberFromHostInstance`.
414
414
 
@@ -421,6 +421,28 @@ const latestFiber = getLatestFiber(
421
421
  console.log(latestFiber);
422
422
  ```
423
423
 
424
+ ### getFiberSource
425
+
426
+ returns the source code location of a fiber.
427
+
428
+ ```typescript
429
+ import { getFiberSource } from 'bippy/source';
430
+
431
+ const fiber = getFiberFromHostInstance(document.querySelector('div'));
432
+
433
+ console.log(await getFiberSource(fiber));
434
+ ```
435
+
436
+ > note: in order to get accurate source locations in react >= 19, you need to add this in your `tsconfig.json`:
437
+ >
438
+ > ```json
439
+ > {
440
+ > "compilerOptions": {
441
+ > "jsxImportSource": "bippy/dist"
442
+ > }
443
+ > }
444
+ > ```
445
+
424
446
  ## examples
425
447
 
426
448
  the best way to understand bippy is to [read the source code](https://github.com/aidenybai/bippy/blob/main/src/core.ts). here are some examples of how you can use it:
@@ -6,158 +6,8 @@
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
+ const require_rdt_hook = require('./rdt-hook-Cm8ZY78C.cjs');
9
10
 
10
- //#region src/rdt-hook.ts
11
- const version = "0.3.16";
12
- const BIPPY_INSTRUMENTATION_STRING = `bippy-${version}`;
13
- const objectDefineProperty = Object.defineProperty;
14
- const objectHasOwnProperty = Object.prototype.hasOwnProperty;
15
- const NO_OP = () => {};
16
- const checkDCE = (fn) => {
17
- try {
18
- const code = Function.prototype.toString.call(fn);
19
- if (code.indexOf("^_^") > -1) setTimeout(() => {
20
- throw new Error("React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://reactjs.org/link/perf-use-production-build");
21
- });
22
- } catch {}
23
- };
24
- const isRealReactDevtools = (rdtHook = getRDTHook()) => {
25
- return "getFiberRoots" in rdtHook;
26
- };
27
- let isReactRefreshOverride = false;
28
- let injectFnStr = void 0;
29
- const isReactRefresh = (rdtHook = getRDTHook()) => {
30
- if (isReactRefreshOverride) return true;
31
- if (typeof rdtHook.inject === "function") injectFnStr = rdtHook.inject.toString();
32
- return Boolean(injectFnStr?.includes("(injected)"));
33
- };
34
- const onActiveListeners = new Set();
35
- const _renderers = new Set();
36
- const installRDTHook = (onActive) => {
37
- const renderers = new Map();
38
- let i = 0;
39
- let rdtHook = {
40
- checkDCE,
41
- supportsFiber: true,
42
- supportsFlight: true,
43
- hasUnsupportedRendererAttached: false,
44
- renderers,
45
- onCommitFiberRoot: NO_OP,
46
- onCommitFiberUnmount: NO_OP,
47
- onPostCommitFiberRoot: NO_OP,
48
- inject(renderer) {
49
- const nextID = ++i;
50
- renderers.set(nextID, renderer);
51
- _renderers.add(renderer);
52
- if (!rdtHook._instrumentationIsActive) {
53
- rdtHook._instrumentationIsActive = true;
54
- onActiveListeners.forEach((listener) => listener());
55
- }
56
- return nextID;
57
- },
58
- _instrumentationSource: BIPPY_INSTRUMENTATION_STRING,
59
- _instrumentationIsActive: false
60
- };
61
- try {
62
- objectDefineProperty(globalThis, "__REACT_DEVTOOLS_GLOBAL_HOOK__", {
63
- get() {
64
- return rdtHook;
65
- },
66
- set(newHook) {
67
- if (newHook && typeof newHook === "object") {
68
- const ourRenderers = rdtHook.renderers;
69
- rdtHook = newHook;
70
- if (ourRenderers.size > 0) {
71
- ourRenderers.forEach((renderer, id) => {
72
- _renderers.add(renderer);
73
- newHook.renderers.set(id, renderer);
74
- });
75
- patchRDTHook(onActive);
76
- }
77
- }
78
- },
79
- configurable: true,
80
- enumerable: true
81
- });
82
- const originalWindowHasOwnProperty = window.hasOwnProperty;
83
- let hasRanHack = false;
84
- objectDefineProperty(window, "hasOwnProperty", {
85
- value: function() {
86
- try {
87
- if (!hasRanHack && arguments[0] === "__REACT_DEVTOOLS_GLOBAL_HOOK__") {
88
- globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = void 0;
89
- hasRanHack = true;
90
- return -0;
91
- }
92
- } catch {}
93
- return originalWindowHasOwnProperty.apply(this, arguments);
94
- },
95
- configurable: true,
96
- writable: true
97
- });
98
- } catch {
99
- patchRDTHook(onActive);
100
- }
101
- return rdtHook;
102
- };
103
- const patchRDTHook = (onActive) => {
104
- if (onActive) onActiveListeners.add(onActive);
105
- try {
106
- const rdtHook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
107
- if (!rdtHook) return;
108
- if (!rdtHook._instrumentationSource) {
109
- rdtHook.checkDCE = checkDCE;
110
- rdtHook.supportsFiber = true;
111
- rdtHook.supportsFlight = true;
112
- rdtHook.hasUnsupportedRendererAttached = false;
113
- rdtHook._instrumentationSource = BIPPY_INSTRUMENTATION_STRING;
114
- rdtHook._instrumentationIsActive = false;
115
- if (rdtHook.renderers.size) {
116
- rdtHook._instrumentationIsActive = true;
117
- onActiveListeners.forEach((listener) => listener());
118
- return;
119
- }
120
- const prevInject = rdtHook.inject;
121
- if (isReactRefresh(rdtHook) && !isRealReactDevtools()) {
122
- isReactRefreshOverride = true;
123
- const nextID = rdtHook.inject({ scheduleRefresh() {} });
124
- if (nextID) rdtHook._instrumentationIsActive = true;
125
- }
126
- rdtHook.inject = (renderer) => {
127
- const id = prevInject(renderer);
128
- _renderers.add(renderer);
129
- rdtHook._instrumentationIsActive = true;
130
- onActiveListeners.forEach((listener) => listener());
131
- return id;
132
- };
133
- }
134
- if (rdtHook.renderers.size || rdtHook._instrumentationIsActive || isReactRefresh()) onActive?.();
135
- } catch {}
136
- };
137
- const hasRDTHook = () => {
138
- return objectHasOwnProperty.call(globalThis, "__REACT_DEVTOOLS_GLOBAL_HOOK__");
139
- };
140
- /**
141
- * Returns the current React DevTools global hook.
142
- */
143
- const getRDTHook = (onActive) => {
144
- if (!hasRDTHook()) return installRDTHook(onActive);
145
- patchRDTHook(onActive);
146
- return globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
147
- };
148
- const isClientEnvironment = () => {
149
- return Boolean(typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"));
150
- };
151
- /**
152
- * Usually used purely for side effect
153
- */
154
- const safelyInstallRDTHook = () => {
155
- try {
156
- if (isClientEnvironment()) getRDTHook();
157
- } catch {}
158
- };
159
-
160
- //#endregion
161
11
  //#region src/install-hook-script-string.ts
162
12
  const INSTALL_HOOK_SCRIPT_STRING = "(()=>{try{var t=()=>{};const n=new Map;let o=0;globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__={checkDCE:t,supportsFiber:!0,supportsFlight:!0,hasUnsupportedRendererAttached:!1,renderers:n,onCommitFiberRoot:t,onCommitFiberUnmount:t,onPostCommitFiberRoot:t,inject(t){var e=++o;return n.set(e,t),globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__._instrumentationIsActive=!0,e},_instrumentationIsActive:!1,_script:!0}}catch{}})()";
163
13
 
@@ -464,8 +314,8 @@ const detectReactBuildType = (renderer) => {
464
314
  * Returns `true` if bippy's instrumentation is active.
465
315
  */
466
316
  const isInstrumentationActive = () => {
467
- const rdtHook = getRDTHook();
468
- return Boolean(rdtHook._instrumentationIsActive) || isRealReactDevtools() || isReactRefresh();
317
+ const rdtHook = require_rdt_hook.getRDTHook();
318
+ return Boolean(rdtHook._instrumentationIsActive) || require_rdt_hook.isRealReactDevtools() || require_rdt_hook.isReactRefresh();
469
319
  };
470
320
  /**
471
321
  * Returns the latest fiber (since it may be double-buffered).
@@ -624,10 +474,10 @@ const createFiberVisitor = ({ onRender }) => {
624
474
  * });
625
475
  */
626
476
  const instrument = (options) => {
627
- return getRDTHook(() => {
628
- const rdtHook = getRDTHook();
477
+ return require_rdt_hook.getRDTHook(() => {
478
+ const rdtHook = require_rdt_hook.getRDTHook();
629
479
  options.onActive?.();
630
- rdtHook._instrumentationSource = options.name ?? BIPPY_INSTRUMENTATION_STRING;
480
+ rdtHook._instrumentationSource = options.name ?? require_rdt_hook.BIPPY_INSTRUMENTATION_STRING;
631
481
  const prevOnCommitFiberRoot = rdtHook.onCommitFiberRoot;
632
482
  if (options.onCommitFiberRoot) rdtHook.onCommitFiberRoot = (rendererID, root, priority) => {
633
483
  if (prevOnCommitFiberRoot) prevOnCommitFiberRoot(rendererID, root, priority);
@@ -646,7 +496,7 @@ const instrument = (options) => {
646
496
  });
647
497
  };
648
498
  const getFiberFromHostInstance = (hostInstance) => {
649
- const rdtHook = getRDTHook();
499
+ const rdtHook = require_rdt_hook.getRDTHook();
650
500
  for (const renderer of rdtHook.renderers.values()) try {
651
501
  const fiber = renderer.findFiberByHostInstance?.(hostInstance);
652
502
  if (fiber) return fiber;
@@ -661,16 +511,16 @@ const INSTALL_ERROR = new Error();
661
511
  const _fiberRoots = new Set();
662
512
  const secure = (options, secureOptions = {}) => {
663
513
  const onActive = options.onActive;
664
- const isRDTHookInstalled = hasRDTHook();
665
- const isUsingRealReactDevtools = isRealReactDevtools();
666
- const isUsingReactRefresh = isReactRefresh();
514
+ const isRDTHookInstalled = require_rdt_hook.hasRDTHook();
515
+ const isUsingRealReactDevtools = require_rdt_hook.isRealReactDevtools();
516
+ const isUsingReactRefresh = require_rdt_hook.isReactRefresh();
667
517
  let timeout;
668
518
  let isProduction = secureOptions.isProduction ?? false;
669
519
  options.onActive = () => {
670
520
  clearTimeout(timeout);
671
521
  let isSecure = true;
672
522
  try {
673
- const rdtHook = getRDTHook();
523
+ const rdtHook = require_rdt_hook.getRDTHook();
674
524
  for (const renderer of rdtHook.renderers.values()) {
675
525
  const [majorVersion] = renderer.version.split(".");
676
526
  if (Number(majorVersion) < (secureOptions.minReactMajorVersion ?? 17)) isSecure = false;
@@ -742,12 +592,6 @@ const onCommitFiberRoot = (handler) => {
742
592
  };
743
593
 
744
594
  //#endregion
745
- Object.defineProperty(exports, 'BIPPY_INSTRUMENTATION_STRING', {
746
- enumerable: true,
747
- get: function () {
748
- return BIPPY_INSTRUMENTATION_STRING;
749
- }
750
- });
751
595
  Object.defineProperty(exports, 'CONCURRENT_MODE_NUMBER', {
752
596
  enumerable: true,
753
597
  get: function () {
@@ -892,12 +736,6 @@ Object.defineProperty(exports, '_fiberRoots', {
892
736
  return _fiberRoots;
893
737
  }
894
738
  });
895
- Object.defineProperty(exports, '_renderers', {
896
- enumerable: true,
897
- get: function () {
898
- return _renderers;
899
- }
900
- });
901
739
  Object.defineProperty(exports, 'createFiberVisitor', {
902
740
  enumerable: true,
903
741
  get: function () {
@@ -976,12 +814,6 @@ Object.defineProperty(exports, 'getNearestHostFibers', {
976
814
  return getNearestHostFibers;
977
815
  }
978
816
  });
979
- Object.defineProperty(exports, 'getRDTHook', {
980
- enumerable: true,
981
- get: function () {
982
- return getRDTHook;
983
- }
984
- });
985
817
  Object.defineProperty(exports, 'getTimings', {
986
818
  enumerable: true,
987
819
  get: function () {
@@ -1000,30 +832,12 @@ Object.defineProperty(exports, 'hasMemoCache', {
1000
832
  return hasMemoCache;
1001
833
  }
1002
834
  });
1003
- Object.defineProperty(exports, 'hasRDTHook', {
1004
- enumerable: true,
1005
- get: function () {
1006
- return hasRDTHook;
1007
- }
1008
- });
1009
- Object.defineProperty(exports, 'installRDTHook', {
1010
- enumerable: true,
1011
- get: function () {
1012
- return installRDTHook;
1013
- }
1014
- });
1015
835
  Object.defineProperty(exports, 'instrument', {
1016
836
  enumerable: true,
1017
837
  get: function () {
1018
838
  return instrument;
1019
839
  }
1020
840
  });
1021
- Object.defineProperty(exports, 'isClientEnvironment', {
1022
- enumerable: true,
1023
- get: function () {
1024
- return isClientEnvironment;
1025
- }
1026
- });
1027
841
  Object.defineProperty(exports, 'isCompositeFiber', {
1028
842
  enumerable: true,
1029
843
  get: function () {
@@ -1042,18 +856,6 @@ Object.defineProperty(exports, 'isInstrumentationActive', {
1042
856
  return isInstrumentationActive;
1043
857
  }
1044
858
  });
1045
- Object.defineProperty(exports, 'isReactRefresh', {
1046
- enumerable: true,
1047
- get: function () {
1048
- return isReactRefresh;
1049
- }
1050
- });
1051
- Object.defineProperty(exports, 'isRealReactDevtools', {
1052
- enumerable: true,
1053
- get: function () {
1054
- return isRealReactDevtools;
1055
- }
1056
- });
1057
859
  Object.defineProperty(exports, 'isValidElement', {
1058
860
  enumerable: true,
1059
861
  get: function () {
@@ -1078,18 +880,6 @@ Object.defineProperty(exports, 'onCommitFiberRoot', {
1078
880
  return onCommitFiberRoot;
1079
881
  }
1080
882
  });
1081
- Object.defineProperty(exports, 'patchRDTHook', {
1082
- enumerable: true,
1083
- get: function () {
1084
- return patchRDTHook;
1085
- }
1086
- });
1087
- Object.defineProperty(exports, 'safelyInstallRDTHook', {
1088
- enumerable: true,
1089
- get: function () {
1090
- return safelyInstallRDTHook;
1091
- }
1092
- });
1093
883
  Object.defineProperty(exports, 'secure', {
1094
884
  enumerable: true,
1095
885
  get: function () {
@@ -1155,10 +945,4 @@ Object.defineProperty(exports, 'updateFiberRecursively', {
1155
945
  get: function () {
1156
946
  return updateFiberRecursively;
1157
947
  }
1158
- });
1159
- Object.defineProperty(exports, 'version', {
1160
- enumerable: true,
1161
- get: function () {
1162
- return version;
1163
- }
1164
948
  });
@@ -0,0 +1,225 @@
1
+ import { ContextDependency, Fiber, FiberRoot, MemoizedState, ReactDevToolsGlobalHook, ReactRenderer } from "./types-B532E9im.cjs";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/install-hook-script-string.d.ts
5
+ declare const INSTALL_HOOK_SCRIPT_STRING = "(()=>{try{var t=()=>{};const n=new Map;let o=0;globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__={checkDCE:t,supportsFiber:!0,supportsFlight:!0,hasUnsupportedRendererAttached:!1,renderers:n,onCommitFiberRoot:t,onCommitFiberUnmount:t,onPostCommitFiberRoot:t,inject(t){var e=++o;return n.set(e,t),globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__._instrumentationIsActive=!0,e},_instrumentationIsActive:!1,_script:!0}}catch{}})()";
6
+
7
+ //#endregion
8
+ //#region src/rdt-hook.d.ts
9
+ declare const version: string | undefined;
10
+ declare const BIPPY_INSTRUMENTATION_STRING: string;
11
+ declare const isRealReactDevtools: (rdtHook?: ReactDevToolsGlobalHook) => boolean;
12
+ declare const isReactRefresh: (rdtHook?: ReactDevToolsGlobalHook) => boolean;
13
+ declare const _renderers: Set<ReactRenderer>;
14
+ declare const installRDTHook: (onActive?: () => unknown) => ReactDevToolsGlobalHook;
15
+ declare const patchRDTHook: (onActive?: () => unknown) => void;
16
+ declare const hasRDTHook: () => boolean;
17
+ /**
18
+ * Returns the current React DevTools global hook.
19
+ */
20
+ declare const getRDTHook: (onActive?: () => unknown) => ReactDevToolsGlobalHook;
21
+ declare const isClientEnvironment: () => boolean;
22
+ /**
23
+ * Usually used purely for side effect
24
+ */
25
+ declare const safelyInstallRDTHook: () => void;
26
+
27
+ //#endregion
28
+ //#region src/core.d.ts
29
+ declare const FunctionComponentTag = 0;
30
+ declare const ClassComponentTag = 1;
31
+ declare const HostRootTag = 3;
32
+ declare const HostComponentTag = 5;
33
+ declare const HostTextTag = 6;
34
+ declare const FragmentTag = 7;
35
+ declare const ContextConsumerTag = 9;
36
+ declare const ForwardRefTag = 11;
37
+ declare const SuspenseComponentTag = 13;
38
+ declare const MemoComponentTag = 14;
39
+ declare const SimpleMemoComponentTag = 15;
40
+ declare const DehydratedSuspenseComponentTag = 18;
41
+ declare const OffscreenComponentTag = 22;
42
+ declare const LegacyHiddenComponentTag = 23;
43
+ declare const HostHoistableTag = 26;
44
+ declare const HostSingletonTag = 27;
45
+ declare const CONCURRENT_MODE_NUMBER = 60111;
46
+ declare const ELEMENT_TYPE_SYMBOL_STRING = "Symbol(react.element)";
47
+ declare const TRANSITIONAL_ELEMENT_TYPE_SYMBOL_STRING = "Symbol(react.transitional.element)";
48
+ declare const CONCURRENT_MODE_SYMBOL_STRING = "Symbol(react.concurrent_mode)";
49
+ declare const DEPRECATED_ASYNC_MODE_SYMBOL_STRING = "Symbol(react.async_mode)";
50
+ /**
51
+ * Returns `true` if object is a React Element.
52
+ *
53
+ * @see https://react.dev/reference/react/isValidElement
54
+ */
55
+ declare const isValidElement: (element: unknown) => element is React$1.ReactElement;
56
+ /**
57
+ * Returns `true` if object is a React Fiber.
58
+ */
59
+ declare const isValidFiber: (fiber: unknown) => fiber is Fiber;
60
+ /**
61
+ * Returns `true` if fiber is a host fiber. Host fibers are DOM nodes in react-dom, `View` in react-native, etc.
62
+ *
63
+ * @see https://reactnative.dev/architecture/glossary#host-view-tree-and-host-view
64
+ */
65
+ declare const isHostFiber: (fiber: Fiber) => boolean;
66
+ /**
67
+ * Returns `true` if fiber is a composite fiber. Composite fibers are fibers that can render (like functional components, class components, etc.)
68
+ *
69
+ * @see https://reactnative.dev/architecture/glossary#react-composite-components
70
+ */
71
+ declare const isCompositeFiber: (fiber: Fiber) => boolean;
72
+ /**
73
+ * Traverses up or down a {@link Fiber}'s contexts, return `true` to stop and select the current and previous context value.
74
+ */
75
+ declare const traverseContexts: (fiber: Fiber, selector: (nextValue: ContextDependency<unknown> | null | undefined, prevValue: ContextDependency<unknown> | null | undefined) => boolean | void) => boolean;
76
+ /**
77
+ * Traverses up or down a {@link Fiber}'s states, return `true` to stop and select the current and previous state value. This stores both state values and effects.
78
+ */
79
+ declare const traverseState: (fiber: Fiber, selector: (nextValue: MemoizedState | null | undefined, prevValue: MemoizedState | null | undefined) => boolean | void) => boolean;
80
+ /**
81
+ * Traverses up or down a {@link Fiber}'s props, return `true` to stop and select the current and previous props value.
82
+ */
83
+ declare const traverseProps: (fiber: Fiber, selector: (propName: string, nextValue: unknown, prevValue: unknown) => boolean | void) => boolean;
84
+ /**
85
+ * Returns `true` if the {@link Fiber} has rendered. Note that this does not mean the fiber has rendered in the current commit, just that it has rendered in the past.
86
+ */
87
+ declare const didFiberRender: (fiber: Fiber) => boolean;
88
+ /**
89
+ * Returns `true` if the {@link Fiber} has committed. Note that this does not mean the fiber has committed in the current commit, just that it has committed in the past.
90
+ */
91
+ declare const didFiberCommit: (fiber: Fiber) => boolean;
92
+ /**
93
+ * Returns all host {@link Fiber}s that have committed and rendered.
94
+ */
95
+ declare const getMutatedHostFibers: (fiber: Fiber) => Fiber[];
96
+ /**
97
+ * Returns the stack of {@link Fiber}s from the current fiber to the root fiber.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * [fiber, fiber.return, fiber.return.return, ...]
102
+ * ```
103
+ */
104
+ declare const getFiberStack: (fiber: Fiber) => Fiber[];
105
+ /**
106
+ * Returns `true` if the {@link Fiber} should be filtered out during reconciliation.
107
+ */
108
+ declare const shouldFilterFiber: (fiber: Fiber) => boolean;
109
+ /**
110
+ * Returns the nearest host {@link Fiber} to the current {@link Fiber}.
111
+ */
112
+ declare const getNearestHostFiber: (fiber: Fiber, ascending?: boolean) => Fiber | null;
113
+ /**
114
+ * Returns all host {@link Fiber}s in the tree that are associated with the current {@link Fiber}.
115
+ */
116
+ declare const getNearestHostFibers: (fiber: Fiber) => Fiber[];
117
+ /**
118
+ * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.
119
+ */
120
+ declare const traverseFiber: (fiber: Fiber | null, selector: (node: Fiber) => boolean | void, ascending?: boolean) => Fiber | null;
121
+ /**
122
+ * Returns the timings of the {@link Fiber}.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const { selfTime, totalTime } = getTimings(fiber);
127
+ * console.log(selfTime, totalTime);
128
+ * ```
129
+ */
130
+ declare const getTimings: (fiber?: Fiber | null | undefined) => {
131
+ selfTime: number;
132
+ totalTime: number;
133
+ };
134
+ /**
135
+ * Returns `true` if the {@link Fiber} uses React Compiler's memo cache.
136
+ */
137
+ declare const hasMemoCache: (fiber: Fiber) => boolean;
138
+ /**
139
+ * Returns the type (e.g. component definition) of the {@link Fiber}
140
+ */
141
+ declare const getType: (type: unknown) => React$1.ComponentType<unknown> | null;
142
+ /**
143
+ * Returns the display name of the {@link Fiber} type.
144
+ */
145
+ declare const getDisplayName: (type: unknown) => string | null;
146
+ /**
147
+ * Returns the build type of the React renderer.
148
+ */
149
+ declare const detectReactBuildType: (renderer: ReactRenderer) => "development" | "production";
150
+ /**
151
+ * Returns `true` if bippy's instrumentation is active.
152
+ */
153
+ declare const isInstrumentationActive: () => boolean;
154
+ /**
155
+ * Returns the latest fiber (since it may be double-buffered).
156
+ */
157
+ declare const getLatestFiber: (fiber: Fiber) => Fiber;
158
+ type RenderPhase = 'mount' | 'update' | 'unmount';
159
+ type RenderHandler = <S>(fiber: Fiber, phase: RenderPhase, state?: S) => unknown;
160
+ declare const fiberIdMap: WeakMap<Fiber, number>;
161
+ declare const setFiberId: (fiber: Fiber, id?: number) => void;
162
+ declare const getFiberId: (fiber: Fiber) => number;
163
+ declare const mountFiberRecursively: (onRender: RenderHandler, firstChild: Fiber, traverseSiblings: boolean) => void;
164
+ declare const updateFiberRecursively: (onRender: RenderHandler, nextFiber: Fiber, prevFiber: Fiber, parentFiber: Fiber | null) => void;
165
+ declare const unmountFiber: (onRender: RenderHandler, fiber: Fiber) => void;
166
+ declare const unmountFiberChildrenRecursively: (onRender: RenderHandler, fiber: Fiber) => void;
167
+ /**
168
+ * Creates a fiber visitor function. Must pass a fiber root and a render handler.
169
+ * @example
170
+ * traverseRenderedFibers(root, (fiber, phase) => {
171
+ * console.log(phase)
172
+ * })
173
+ */
174
+ declare const traverseRenderedFibers: (root: FiberRoot, onRender: RenderHandler) => void;
175
+ /**
176
+ * @deprecated use `traverseRenderedFibers` instead
177
+ */
178
+ declare const createFiberVisitor: ({
179
+ onRender
180
+ }: {
181
+ onRender: RenderHandler;
182
+ onError: (error: unknown) => unknown;
183
+ }) => (<S>(_rendererID: number, root: FiberRoot | Fiber, _state?: S) => void);
184
+ interface InstrumentationOptions {
185
+ onCommitFiberRoot?: (rendererID: number, root: FiberRoot, priority: void | number) => unknown;
186
+ onCommitFiberUnmount?: (rendererID: number, fiber: Fiber) => unknown;
187
+ onPostCommitFiberRoot?: (rendererID: number, root: FiberRoot) => unknown;
188
+ onActive?: () => unknown;
189
+ name?: string;
190
+ }
191
+ /**
192
+ * Instruments the DevTools hook.
193
+ * @example
194
+ * const hook = instrument({
195
+ * onActive() {
196
+ * console.log('initialized');
197
+ * },
198
+ * onCommitFiberRoot(rendererID, root) {
199
+ * console.log('fiberRoot', root.current)
200
+ * },
201
+ * });
202
+ */
203
+ declare const instrument: (options: InstrumentationOptions) => ReactDevToolsGlobalHook;
204
+ declare const getFiberFromHostInstance: <T>(hostInstance: T) => Fiber | null;
205
+ declare const INSTALL_ERROR: Error;
206
+ declare const _fiberRoots: Set<any>;
207
+ declare const secure: (options: InstrumentationOptions, secureOptions?: {
208
+ minReactMajorVersion?: number;
209
+ dangerouslyRunInProduction?: boolean;
210
+ onError?: (error?: unknown) => unknown;
211
+ installCheckTimeout?: number;
212
+ isProduction?: boolean;
213
+ }) => InstrumentationOptions;
214
+ /**
215
+ * a wrapper around the {@link instrument} function that sets the `onCommitFiberRoot` hook.
216
+ *
217
+ * @example
218
+ * onCommitFiberRoot((root) => {
219
+ * console.log(root.current);
220
+ * });
221
+ */
222
+ declare const onCommitFiberRoot: (handler: (root: FiberRoot) => void) => ReactDevToolsGlobalHook;
223
+
224
+ //#endregion
225
+ export { BIPPY_INSTRUMENTATION_STRING, CONCURRENT_MODE_NUMBER, CONCURRENT_MODE_SYMBOL_STRING, ClassComponentTag, ContextConsumerTag, DEPRECATED_ASYNC_MODE_SYMBOL_STRING, DehydratedSuspenseComponentTag, ELEMENT_TYPE_SYMBOL_STRING, ForwardRefTag, FragmentTag, FunctionComponentTag, HostComponentTag, HostHoistableTag, HostRootTag, HostSingletonTag, HostTextTag, INSTALL_ERROR, INSTALL_HOOK_SCRIPT_STRING, InstrumentationOptions, LegacyHiddenComponentTag, MemoComponentTag, OffscreenComponentTag, RenderHandler, RenderPhase, SimpleMemoComponentTag, SuspenseComponentTag, TRANSITIONAL_ELEMENT_TYPE_SYMBOL_STRING, _fiberRoots, _renderers, createFiberVisitor, detectReactBuildType, didFiberCommit, didFiberRender, fiberIdMap, getDisplayName, getFiberFromHostInstance, getFiberId, getFiberStack, getLatestFiber, getMutatedHostFibers, getNearestHostFiber, getNearestHostFibers, getRDTHook, getTimings, getType, hasMemoCache, hasRDTHook, installRDTHook, instrument, isClientEnvironment, isCompositeFiber, isHostFiber, isInstrumentationActive, isReactRefresh, isRealReactDevtools, isValidElement, isValidFiber, mountFiberRecursively, onCommitFiberRoot, patchRDTHook, safelyInstallRDTHook, secure, setFiberId, shouldFilterFiber, traverseContexts, traverseFiber, traverseProps, traverseRenderedFibers, traverseState, unmountFiber, unmountFiberChildrenRecursively, updateFiberRecursively, version };