Skip to content

Commit 24af7e3

Browse files
authored
feat: preact props, states and contexts (#177)
* feat: preact props, states and contexts
1 parent 7a57c11 commit 24af7e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3256
-2182
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "node scripts/workspace.mjs dev",
88
"pack": "node scripts/workspace.mjs pack",
99
"pack:bump": "pnpm --filter scan pack:bump",
10-
"lint": "node scripts/workspace.mjs lint",
10+
"lint": "pnpm --parallel lint",
1111
"eslint:fix": "eslint --fix packages/*"
1212
},
1313
"devDependencies": {

packages/extension/src/types/global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ declare global {
2424
}
2525

2626
var __REACT_DEVTOOLS_GLOBAL_HOOK__: Window['__REACT_DEVTOOLS_GLOBAL_HOOK__'];
27-
type TTimer = ReturnType<typeof setTimeout> | ReturnType<typeof setInterval> | null;
27+
type TTimer = NodeJS.Timeout;
2828

2929
var _reactScan: typeof reactScan;
3030
}

packages/scan/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
src/core/web/assets/css/styles.css
1+
src/web/assets/css/styles.css

packages/scan/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@
197197
"postbuild": "pnpm copy-astro && node ../../scripts/version-warning.mjs",
198198
"build:copy": "NODE_ENV=production tsup && cat dist/auto.global.js | pbcopy",
199199
"copy-astro": "cp -R src/core/monitor/params/astro dist/core/monitor/params",
200-
"dev:css": "npx tailwindcss -i ./src/core/web/assets/css/styles.tailwind.css -o ./src/core/web/assets/css/styles.css --watch",
200+
"dev:css": "npx tailwindcss -i ./src/web/assets/css/styles.tailwind.css -o ./src/web/assets/css/styles.css --watch",
201201
"dev:tsup": "NODE_ENV=development tsup --watch",
202202
"dev": "pnpm copy-astro && npm-run-all --parallel dev:css dev:tsup",
203-
"build:css": "npx tailwindcss -i ./src/core/web/assets/css/styles.tailwind.css -o ./src/core/web/assets/css/styles.css --minify",
203+
"build:css": "npx tailwindcss -i ./src/web/assets/css/styles.tailwind.css -o ./src/web/assets/css/styles.css --minify",
204204
"lint": "eslint 'src/**/*.{ts,tsx}' --fix",
205205
"pack": "npm version patch && pnpm build && npm pack",
206206
"pack:bump": "bun scripts/bump-version.js && nr pack && echo $(pwd)/react-scan-$(node -p \"require('./package.json').version\").tgz | pbcopy",

packages/scan/src/core/fast-serialize.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest';
2-
import { fastSerialize } from 'src/core/instrumentation';
2+
import { fastSerialize } from '~core/instrumentation';
33

44
describe('fastSerialize', () => {
55
it('serializes null', () => {
@@ -27,8 +27,8 @@ describe('fastSerialize', () => {
2727
});
2828

2929
it('serializes functions', () => {
30-
// eslint-disable-next-line @typescript-eslint/no-empty-function
31-
const testFunc = (x:2) => 3
30+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31+
const testFunc = (x: 2) => 3
3232
expect(fastSerialize(testFunc)).toBe('(x) => 3');
3333
});
3434

packages/scan/src/core/index.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,19 @@ import {
1212
} from 'bippy';
1313
import type * as React from 'react';
1414
import type { Fiber } from 'react-reconciler';
15-
import { ICONS } from '@web-assets/svgs/svgs';
16-
import {
17-
createInspectElementStateMachine,
18-
type States,
19-
} from '@web-inspect-element/inspect-state-machine';
20-
import { playGeigerClickSound } from '@web-utils/geiger';
21-
import { readLocalStorage, saveLocalStorage } from '@web-utils/helpers';
22-
import { log, logIntro } from '@web-utils/log';
23-
import { flushOutlines, type Outline } from '@web-utils/outline';
24-
import {
25-
aggregateChanges,
26-
aggregateRender,
27-
updateFiberRenderData,
28-
type RenderData,
29-
} from 'src/core/utils';
30-
import { createInstrumentation, type Render } from './instrumentation';
31-
import type { InternalInteraction } from './monitor/types';
15+
import styles from '~web/assets/css/styles.css';
16+
import { log, logIntro } from '~web/utils/log';
17+
import { ICONS } from '~web/assets/svgs/svgs';
18+
import { type States } from '~web/components/inspector/utils';
19+
import { initReactScanOverlay } from '~web/overlay';
20+
import { createToolbar } from '~web/toolbar';
21+
import { playGeigerClickSound } from '~web/utils/geiger';
22+
import { saveLocalStorage, readLocalStorage } from '~web/utils/helpers';
23+
import { type Outline, flushOutlines } from '~web/utils/outline';
24+
import { type RenderData, aggregateRender, aggregateChanges, updateFiberRenderData } from '~core/utils';
3225
import { type getSession } from './monitor/utils';
33-
import styles from './web/assets/css/styles.css';
34-
import { initReactScanOverlay } from './web/overlay';
35-
import { createToolbar } from './web/toolbar';
26+
import type { InternalInteraction } from './monitor/types';
27+
import { createInstrumentation, type Render } from './instrumentation';
3628

3729
let toolbarContainer: HTMLElement | null = null;
3830
let shadowRoot: ShadowRoot | null = null;
@@ -589,8 +581,6 @@ export const start = () => {
589581
if (!ctx) return;
590582
startFlushOutlineInterval();
591583

592-
createInspectElementStateMachine(shadowRoot);
593-
594584
globalThis.__REACT_SCAN__ = {
595585
ReactScanInternals,
596586
};
@@ -599,10 +589,6 @@ export const start = () => {
599589
toolbarContainer = createToolbar(shadowRoot);
600590
}
601591

602-
const overlayElement = document.createElement('react-scan-overlay');
603-
604-
document.documentElement.appendChild(overlayElement);
605-
606592
logIntro();
607593
},
608594
onCommitStart() {

packages/scan/src/core/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
instrument,
1515
} from 'bippy';
1616
import { isValidElement } from 'preact';
17-
import { isEqual } from 'src/core/utils';
18-
import { getChangedPropsDetailed } from '@web-inspect-element/utils';
1917
import { ReactScanInternals, Store, getIsProduction } from './index';
18+
import { getChangedPropsDetailed } from '~web/components/inspector/utils';
19+
import { isEqual } from '~core/utils';
2020

2121
let fps = 0;
2222
let lastTime = performance.now();

packages/scan/src/core/monitor/performance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getDisplayName } from 'bippy';
22
import { type Fiber } from 'react-reconciler';
3+
import { getCompositeComponentFromElement } from '~web/components/inspector/utils';
34
import { Store } from '../..';
4-
import { getCompositeComponentFromElement } from '../web/inspect-element/utils';
55
import type {
66
PerformanceInteraction,
77
PerformanceInteractionEntry,

packages/scan/src/core/monitor/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { onIdle } from '../web/utils/helpers';
1+
import { onIdle } from '~web/utils/helpers';
22
import { isSSR } from './constants';
33
import { Device, type Session } from './types';
44

packages/scan/src/core/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { getType } from 'bippy';
22
import { type Fiber } from 'react-reconciler';
3-
import type { AggregatedRender } from '@web-utils/outline';
4-
import { ReactScanInternals } from '..';
3+
import { ReactScanInternals } from '~core/index';
4+
import { type AggregatedRender } from '~web/utils/outline';
55
import type { AggregatedChange, Render, RenderChange } from './instrumentation';
66

7-
// Helper function for Set union
87
const unionSets = <T>(setA: Set<T>, setB: Set<T>): Set<T> => {
98
const union = new Set(setA);
109
for (const elem of setB) {

0 commit comments

Comments
 (0)