Skip to content

Commit 449936a

Browse files
committed
feat: port react scan to react native
1 parent a1af92e commit 449936a

File tree

8 files changed

+6636
-2539
lines changed

8 files changed

+6636
-2539
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"publint": "publint"
114114
},
115115
"devDependencies": {
116+
"@shopify/react-native-skia": "^1.5.5",
116117
"@types/react": "^18.3.12",
117118
"@types/react-reconciler": "^0.28.8",
118119
"@vercel/style-guide": "^6.0.0",
@@ -121,6 +122,8 @@
121122
"publint": "^0.2.12",
122123
"react": "*",
123124
"react-dom": "*",
125+
"react-native": "0.76.2",
126+
"react-native-reanimated": "~3.16.1",
124127
"react-reconciler": "^0.29.2",
125128
"terser": "^5.36.0",
126129
"tsup": "^8.2.4"

pnpm-lock.yaml

Lines changed: 6053 additions & 2496 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/index.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Fiber, FiberRoot } from 'react-reconciler';
22
import * as React from 'react';
33
import { instrument, type Render } from './instrumentation/index';
4+
import { createStore } from './utils';
45
import {
5-
type ActiveOutline,
6+
ActiveOutline,
67
flushOutlines,
78
getOutline,
8-
type PendingOutline,
9+
PendingOutline,
910
} from './web/outline';
1011
import { createOverlay } from './web/index';
1112
import { logIntro } from './web/log';
@@ -110,16 +111,30 @@ interface Internals {
110111
>;
111112
}
112113

113-
export const ReactScanInternals: Internals = {
114+
export type MeasurementValue = {
115+
width: number;
116+
height: number;
117+
pageX: number;
118+
pageY: number;
119+
};
120+
export type Measurement =
121+
| { kind: 'dom'; value: DOMRect }
122+
| {
123+
kind: 'native';
124+
value: MeasurementValue;
125+
};
126+
127+
export const ReactScanInternals = createStore<Internals>({
114128
onCommitFiberRoot: (_rendererID: number, _root: FiberRoot): void => {
115129
/**/
116130
},
117-
get isProd() {
118-
return (
119-
'_self' in React.createElement('div') &&
120-
!ReactScanInternals.options.runInProduction
121-
);
122-
},
131+
isProd: null!, // todo
132+
// get isProd() {
133+
// return (
134+
// '_self' in React.createElement('div') &&
135+
// !ReactScanInternals.options.runInProduction
136+
// );
137+
// },
123138
isInIframe: window.self !== window.top,
124139
isPaused: false,
125140
componentAllowList: null,
@@ -136,7 +151,7 @@ export const ReactScanInternals: Internals = {
136151
reportData: {},
137152
scheduledOutlines: [],
138153
activeOutlines: [],
139-
};
154+
});
140155

141156
export const getReport = () => ReactScanInternals.reportData;
142157

src/core/instrumentation/placeholder.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { registerDevtoolsHook } from './fiber';
22

33
// __REACT_DEVTOOLS_GLOBAL_HOOK__ must exist before React is ever executed
44
// this is the case with the React Devtools extension, but without it, we need
5-
registerDevtoolsHook({
6-
onCommitFiberRoot() {
7-
/**/
8-
},
9-
});
5+
6+
// sometimes in expo this comes back as undefined
7+
// registerDevtoolsHook({
8+
// onCommitFiberRoot() {
9+
// /**/
10+
// },
11+
// });

0 commit comments

Comments
 (0)