bippy 0.6.1-dev.879f777 → 0.6.1-dev.94e5797
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 +120 -97
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +2 -6
- package/dist/core.d.ts +2 -6
- package/dist/core.js +1 -1
- package/dist/core2.cjs +1 -1
- package/dist/core2.d.cts +2 -2
- package/dist/core2.d.ts +2 -2
- package/dist/core2.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/rdt-hook.cjs +1 -1
- package/dist/rdt-hook.js +1 -1
- package/dist/source.cjs +5 -5
- package/dist/source.js +6 -6
- package/package.json +1 -1
- package/src/core.ts +6 -16
- package/src/react.ts +2 -2
package/src/core.ts
CHANGED
|
@@ -70,7 +70,7 @@ export const isValidElement = (element: unknown): element is React.ReactElement
|
|
|
70
70
|
/**
|
|
71
71
|
* Returns `true` if object is a React Fiber.
|
|
72
72
|
*/
|
|
73
|
-
export const
|
|
73
|
+
export const isFiber = (fiber: unknown): fiber is Fiber =>
|
|
74
74
|
typeof fiber === "object" &&
|
|
75
75
|
fiber !== null &&
|
|
76
76
|
"tag" in fiber &&
|
|
@@ -84,7 +84,7 @@ const isFiberRoot = (fiberRoot: unknown): fiberRoot is FiberRoot =>
|
|
|
84
84
|
typeof fiberRoot === "object" &&
|
|
85
85
|
fiberRoot !== null &&
|
|
86
86
|
"current" in fiberRoot &&
|
|
87
|
-
|
|
87
|
+
isFiber(fiberRoot.current);
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Returns `true` if fiber is a host fiber. Host fibers are DOM nodes in react-dom, `View` in react-native, etc.
|
|
@@ -123,16 +123,6 @@ export const isCompositeFiber = (fiber: Fiber): boolean => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
/**
|
|
127
|
-
* Returns `true` if the object is a {@link Fiber}
|
|
128
|
-
*/
|
|
129
|
-
export const isFiber = (maybeFiber: unknown): maybeFiber is Fiber => {
|
|
130
|
-
if (!maybeFiber || typeof maybeFiber !== "object") return false;
|
|
131
|
-
// this is a fast check. pendingProps will ALWAYS exist in fiber
|
|
132
|
-
// `containerInfo` is in FiberRootNode, not FiberNode
|
|
133
|
-
return "pendingProps" in maybeFiber && !("containerInfo" in maybeFiber);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
126
|
/**
|
|
137
127
|
* 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.
|
|
138
128
|
*/
|
|
@@ -837,14 +827,14 @@ const getLegacyRootFiber = (hostInstance: object): Fiber | null => {
|
|
|
837
827
|
const current = Reflect.get(internalRoot, "current");
|
|
838
828
|
if (typeof current !== "object" || current === null) return null;
|
|
839
829
|
const child = Reflect.get(current, "child");
|
|
840
|
-
return
|
|
830
|
+
return isFiber(child) ? child : null;
|
|
841
831
|
};
|
|
842
832
|
|
|
843
833
|
const getInternalInstanceHandle = (hostInstance: object): Fiber | null => {
|
|
844
834
|
const internalInstanceHandle =
|
|
845
835
|
Reflect.get(hostInstance, "__internalInstanceHandle") ??
|
|
846
836
|
Reflect.get(hostInstance, "_internalInstanceHandle");
|
|
847
|
-
return
|
|
837
|
+
return isFiber(internalInstanceHandle) ? internalInstanceHandle : null;
|
|
848
838
|
};
|
|
849
839
|
|
|
850
840
|
const getPublicHostInstance = (stateNode: unknown): unknown => {
|
|
@@ -880,14 +870,14 @@ export const getFiber = <T>(hostInstance: T): Fiber | null => {
|
|
|
880
870
|
|
|
881
871
|
for (const knownKey of knownFiberPropertyKeys) {
|
|
882
872
|
const fiber = Reflect.get(hostInstance, knownKey);
|
|
883
|
-
if (
|
|
873
|
+
if (isFiber(fiber)) return fiber;
|
|
884
874
|
}
|
|
885
875
|
|
|
886
876
|
for (const key of Object.keys(hostInstance)) {
|
|
887
877
|
if (isFiberPropertyKey(key)) {
|
|
888
878
|
knownFiberPropertyKeys.add(key);
|
|
889
879
|
const fiber = Reflect.get(hostInstance, key);
|
|
890
|
-
if (
|
|
880
|
+
if (isFiber(fiber)) return fiber;
|
|
891
881
|
}
|
|
892
882
|
}
|
|
893
883
|
}
|
package/src/react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./install-hook-only.js";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { isFiber } from "./core.js";
|
|
4
4
|
import type { Fiber } from "./react-internals/index.js";
|
|
5
5
|
|
|
6
6
|
export type { Fiber } from "./react-internals/index.js";
|
|
@@ -18,7 +18,7 @@ const captureFiberFromHook = (useCaptureHook: () => void): Fiber | null => {
|
|
|
18
18
|
const bindProxy = new Proxy(originalBind, {
|
|
19
19
|
apply: (bind, functionToBind, boundArguments) => {
|
|
20
20
|
const fiber = boundArguments[1];
|
|
21
|
-
if (!capturedFiber &&
|
|
21
|
+
if (!capturedFiber && isFiber(fiber)) {
|
|
22
22
|
capturedFiber = fiber;
|
|
23
23
|
}
|
|
24
24
|
return Reflect.apply(bind, functionToBind, boundArguments);
|