Skip to content

Commit e1a5701

Browse files
committed
refactor(bippy): update to version 0.3.6
1 parent 6f4baa1 commit e1a5701

17 files changed

+767
-3040
lines changed

biome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"files": {
99
"ignoreUnknown": false,
1010
"include": ["packages/**/*.ts", "packages/**/*.tsx", "*.ts", "*.tsx"],
11-
"ignore": ["*.gen.ts", "node_modules", "dist", "coverage", "css-to-tailwind.ts"]
11+
"ignore": ["node_modules", "dist", "coverage", "css-to-tailwind.ts"]
1212
},
1313
"formatter": {
1414
"enabled": true,

packages/bippy/CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# bippy
22

3+
## 0.3.6
4+
5+
### Patch Changes
6+
7+
- fix side effects
8+
9+
## 0.3.5
10+
11+
### Patch Changes
12+
13+
- fix instrument
14+
315
## 0.3.4
416

517
### Patch Changes

packages/bippy/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bippy",
3-
"version": "0.3.4",
3+
"version": "0.3.6",
44
"description": "hack into react internals",
55
"publishConfig": {
66
"access": "public"
@@ -27,7 +27,6 @@
2727
"name": "Aiden Bai",
2828
"email": "[email protected]"
2929
},
30-
"sideEffects": false,
3130
"type": "module",
3231
"exports": {
3332
"./package.json": "./package.json",

packages/bippy/src/core.ts

-86
Original file line numberDiff line numberDiff line change
@@ -544,92 +544,6 @@ export const getLatestFiber = (fiber: Fiber): Fiber => {
544544
return fiber;
545545
};
546546

547-
interface FiberDiff {
548-
path: ('child' | 'sibling')[];
549-
type: 'props' | 'state' | 'type' | 'ref' | 'children';
550-
thisFiber: Fiber;
551-
otherFiber: Fiber;
552-
}
553-
554-
export const diffFiber = (thisFiber: Fiber, otherFiber: Fiber): FiberDiff[] => {
555-
const path: FiberDiff['path'] = [];
556-
const diffs: FiberDiff[] = [];
557-
558-
const traverse = (current: Fiber, other: Fiber, currentPath: ('child' | 'sibling')[]) => {
559-
if (current.type !== other.type) {
560-
diffs.push({
561-
path: [...currentPath],
562-
type: 'type',
563-
thisFiber: current,
564-
otherFiber: other
565-
});
566-
}
567-
568-
if (current.ref !== other.ref) {
569-
diffs.push({
570-
path: [...currentPath],
571-
type: 'ref',
572-
thisFiber: current,
573-
otherFiber: other
574-
});
575-
}
576-
577-
// Compare props
578-
const currentProps = current.memoizedProps || {};
579-
const otherProps = other.memoizedProps || {};
580-
const allProps = new Set([...Object.keys(currentProps), ...Object.keys(otherProps)]);
581-
582-
for (const prop of allProps) {
583-
if (currentProps[prop] !== otherProps[prop]) {
584-
diffs.push({
585-
path: [...currentPath],
586-
type: 'props',
587-
thisFiber: current,
588-
otherFiber: other
589-
});
590-
break; // Only record one props difference per fiber
591-
}
592-
}
593-
594-
// Compare state
595-
if (current.memoizedState !== other.memoizedState) {
596-
diffs.push({
597-
path: [...currentPath],
598-
type: 'state',
599-
thisFiber: current,
600-
otherFiber: other
601-
});
602-
}
603-
604-
// Recursively traverse children
605-
if (current.child && other.child) {
606-
traverse(current.child, other.child, [...currentPath, 'child']);
607-
} else if (current.child || other.child) {
608-
diffs.push({
609-
path: [...currentPath],
610-
type: 'children',
611-
thisFiber: current,
612-
otherFiber: other
613-
});
614-
}
615-
616-
// Recursively traverse siblings
617-
if (current.sibling && other.sibling) {
618-
traverse(current.sibling, other.sibling, [...currentPath, 'sibling']);
619-
} else if (current.sibling || other.sibling) {
620-
diffs.push({
621-
path: [...currentPath],
622-
type: 'children',
623-
thisFiber: current,
624-
otherFiber: other
625-
});
626-
}
627-
};
628-
629-
traverse(thisFiber, otherFiber, path);
630-
return diffs;
631-
};
632-
633547
export type RenderPhase = 'mount' | 'update' | 'unmount';
634548

635549
export type RenderHandler = <S>(

packages/bippy/src/rdt-hook.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const installRDTHook = (
4848
): ReactDevToolsGlobalHook => {
4949
const renderers = new Map<number, ReactRenderer>();
5050
let i = 0;
51-
const rdtHook: ReactDevToolsGlobalHook = {
51+
let rdtHook: ReactDevToolsGlobalHook = {
5252
checkDCE,
5353
supportsFiber: true,
5454
supportsFlight: true,
@@ -78,7 +78,7 @@ export const installRDTHook = (
7878
set(newHook) {
7979
if (newHook && typeof newHook === 'object') {
8080
const ourRenderers = rdtHook.renderers;
81-
globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = newHook;
81+
rdtHook = newHook;
8282
if (ourRenderers.size > 0) {
8383
ourRenderers.forEach((renderer, id) => {
8484
newHook.renderers.set(id, renderer);

packages/kitchen-sink/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "rm -rf node_modules/.vite && pnpm i && vite"
99
},
1010
"dependencies": {
11-
"bippy": "^0.3.4",
11+
"bippy": "^0.3.6",
1212
"clsx": "^2.1.1",
1313
"react": "19.0.0",
1414
"react-dom": "19.0.0",

0 commit comments

Comments
 (0)