Skip to content

Commit 4d5703f

Browse files
committed
initial draft done
1 parent b6a1f20 commit 4d5703f

File tree

97 files changed

+4397
-2235
lines changed

Some content is hidden

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

97 files changed

+4397
-2235
lines changed

devtools-ui/components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tsx": true,
66
"tailwind": {
77
"config": "",
8-
"css": "./src/global.css",
8+
"css": "./src/index.css",
99
"baseColor": "neutral",
1010
"cssVariables": true,
1111
"prefix": ""

devtools-ui/package-lock.json

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

devtools-ui/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
"scripts": {
55
"build": "rm -fr dist && npm run tsup",
66
"tsup": "tsup",
7-
"watch": "npm run tsup -- --watch --watch ../source/dist"
7+
"watch": "npm run tsup -- --watch ./src --watch ../source/dist"
88
},
99
"author": "Infinite Table",
1010
"license": "MIT",
1111
"description": "",
1212
"dependencies": {
1313
"@radix-ui/react-checkbox": "^1.1.4",
14-
"@radix-ui/react-dialog": "^1.1.6",
14+
"@radix-ui/react-collapsible": "^1.1.4",
15+
"@radix-ui/react-dialog": "^1.1.7",
1516
"@radix-ui/react-popover": "^1.1.6",
1617
"@radix-ui/react-select": "^2.1.6",
17-
"@radix-ui/react-separator": "^1.1.2",
18-
"@radix-ui/react-slot": "^1.1.2",
19-
"@radix-ui/react-tooltip": "^1.1.8",
18+
"@radix-ui/react-separator": "^1.1.3",
19+
"@radix-ui/react-slot": "^1.2.0",
20+
"@radix-ui/react-tabs": "^1.1.4",
21+
"@radix-ui/react-tooltip": "^1.2.0",
2022
"@tailwindcss/postcss": "^4.0.15",
2123
"@types/chrome": "^0.0.260",
2224
"@vanilla-extract/esbuild-plugin": "^2.3.15",
@@ -27,6 +29,7 @@
2729
"lucide-react": "^0.483.0",
2830
"react": "^19.0.0",
2931
"react-dom": "^19.0.0",
32+
"react-resizable-panels": "^2.1.7",
3033
"tailwind-merge": "^3.0.2",
3134
"tailwindcss": "^4.0.15",
3235
"tw-animate-css": "^1.2.4"
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
import { useCallback, useState } from 'react';
2+
import { useDevToolsMessagingContext } from '../lib/DevToolsMessagingContext';
3+
import type {
4+
DevToolsOverrides,
5+
ErrorCodeKey,
6+
InfiniteTablePropColumnVisibility,
7+
} from '@infinite-table/infinite-react';
8+
import { APIManagerContext } from '../lib/APIManagerContext';
9+
10+
export const APIManagerWithContext = function ({
11+
children,
12+
}: {
13+
children: React.ReactNode;
14+
}) {
15+
const {
16+
activeDebugId,
17+
sendMessageToHostPage: sendMessageToContentScript,
18+
currentInstance,
19+
} = useDevToolsMessagingContext();
20+
const [renderKey, setRenderKey] = useState(0);
21+
const rerender = useCallback(() => {
22+
setRenderKey((prev) => prev + 1);
23+
}, []);
24+
25+
const [overridenProperties] = useState<Set<keyof DevToolsOverrides>>(() => {
26+
return new Set();
27+
});
28+
29+
const sendMessage = useCallback(
30+
(
31+
options: {
32+
type: string;
33+
property?: keyof DevToolsOverrides;
34+
},
35+
payload: any,
36+
) => {
37+
const { type, property } = options;
38+
39+
sendMessageToContentScript(type, {
40+
...payload,
41+
debugId: activeDebugId,
42+
property,
43+
});
44+
45+
if (!property || type === 'revertProperty' || type === 'revertAll') {
46+
return;
47+
}
48+
overridenProperties.add(property as keyof DevToolsOverrides);
49+
rerender();
50+
},
51+
[activeDebugId, sendMessageToContentScript],
52+
);
53+
54+
const revertProperty = useCallback(
55+
(property: keyof DevToolsOverrides) => {
56+
overridenProperties.delete(property);
57+
sendMessage(
58+
{ type: 'revertProperty', property },
59+
{
60+
property,
61+
debugId: activeDebugId,
62+
},
63+
);
64+
rerender();
65+
},
66+
[activeDebugId, sendMessage],
67+
);
68+
69+
const revertAll = useCallback(() => {
70+
overridenProperties.clear();
71+
sendMessage(
72+
{ type: 'revertAll' },
73+
{
74+
debugId: activeDebugId,
75+
},
76+
);
77+
rerender();
78+
}, [activeDebugId, sendMessage]);
79+
80+
const setColumnVisibility = useCallback(
81+
(columnVisibility: InfiniteTablePropColumnVisibility) => {
82+
sendMessage(
83+
{ type: 'setColumnVisibility', property: 'columnVisibility' },
84+
{
85+
columnVisibility,
86+
debugId: activeDebugId,
87+
},
88+
);
89+
},
90+
[activeDebugId, sendMessage],
91+
);
92+
93+
const discardWarning = useCallback(
94+
(warning: ErrorCodeKey) => {
95+
sendMessage(
96+
{ type: 'discardWarning' },
97+
{
98+
warning,
99+
debugId: activeDebugId,
100+
},
101+
);
102+
},
103+
[activeDebugId, sendMessage],
104+
);
105+
106+
const discardAllWarnings = useCallback(() => {
107+
sendMessage(
108+
{ type: 'discardAllWarnings' },
109+
{
110+
debugId: activeDebugId,
111+
},
112+
);
113+
}, [activeDebugId, sendMessage]);
114+
115+
const setGroupBy = useCallback(
116+
(groupBy: { field: string }[]) => {
117+
sendMessage(
118+
{ type: 'setGroupBy', property: 'groupBy' },
119+
{
120+
groupBy,
121+
debugId: activeDebugId,
122+
},
123+
);
124+
},
125+
[activeDebugId, sendMessage],
126+
);
127+
128+
const setGroupRenderStrategy = useCallback(
129+
(groupRenderStrategy: string) => {
130+
sendMessage(
131+
{ type: 'setGroupRenderStrategy', property: 'groupRenderStrategy' },
132+
{
133+
groupRenderStrategy,
134+
debugId: activeDebugId,
135+
},
136+
);
137+
},
138+
[activeDebugId, sendMessage],
139+
);
140+
141+
const setSortInfo = useCallback(
142+
(sortInfo: { field: string; dir: 1 | -1 }[]) => {
143+
sendMessage(
144+
{ type: 'setSortInfo', property: 'sortInfo' },
145+
{ sortInfo, debugId: activeDebugId },
146+
);
147+
},
148+
[activeDebugId, sendMessage],
149+
);
150+
151+
const setMultiSort = useCallback(
152+
(multiSort: boolean) => {
153+
sendMessage(
154+
{ type: 'setMultiSort', property: 'multiSort' },
155+
{ multiSort, debugId: activeDebugId },
156+
);
157+
},
158+
[activeDebugId, sendMessage],
159+
);
160+
161+
return (
162+
<APIManagerContext.Provider
163+
value={{
164+
discardWarning,
165+
discardAllWarnings,
166+
warnings: currentInstance?.debugWarnings || {},
167+
setColumnVisibility,
168+
setGroupBy,
169+
setGroupRenderStrategy,
170+
setSortInfo,
171+
setMultiSort,
172+
revertProperty,
173+
revertAll,
174+
rerender,
175+
overridenProperties,
176+
}}
177+
>
178+
{children}
179+
</APIManagerContext.Provider>
180+
);
181+
};

0 commit comments

Comments
 (0)