Skip to content

Commit b403b88

Browse files
committed
fix devtools and release 1.0.1 devtools version
1 parent cc30772 commit b403b88

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

devtools/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"manifest_version": 3,
33
"name": "Infinite Table DevTools Extension",
4-
"version": "1.0",
4+
"version": "1.0.1",
55
"description": "A Chrome extension for Infinite Table",
6-
"permissions": ["activeTab", "tabs", "scripting", "storage"],
6+
"permissions": ["tabs", "storage"],
77
"devtools_page": "./src/index.html",
88

99
"action": {

devtools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.0.0",
55
"description": "A Chrome extension for Infinite Table",
66
"scripts": {
7-
"build": " vite build && zip -r devtools.zip dist",
7+
"build": "rm -fr devtools.zip && vite build && zip -r devtools.zip dist",
88
"watch": " vite build --watch",
99
"lint": "eslint ."
1010
},

devtools/src/hooks/useOnPageStorageChange.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@ import { useCallback, useEffect, useState } from 'react';
22
import { getPageUrlOfCurrentTab } from '../lib/getCurrentPageUrl';
33
import { type PageData } from 'devtools-ui';
44

5-
import {
6-
sendMessageToBackgroundScript,
7-
sendMessageToHostPage,
8-
} from '../lib/messagingUtils';
5+
import { sendMessageToBackgroundScript } from '../lib/messagingUtils';
6+
7+
const getEmptyPageData = (): PageData => ({
8+
allLogs: [],
9+
logsPerInstance: {},
10+
instances: {},
11+
});
912

1013
export function useOnPageStorageChange<T>(
1114
storageArea: chrome.storage.SessionStorageArea,
1215
) {
13-
const [pageData, setPageData] = useState<PageData | null>(null);
16+
const [pageData, doSetPageData] = useState<PageData | null>(null);
17+
const setPageData = useCallback(
18+
(pageData: PageData) => {
19+
doSetPageData({
20+
...getEmptyPageData(),
21+
...pageData,
22+
});
23+
},
24+
[doSetPageData],
25+
);
1426

1527
const getLogs = useCallback(
1628
(debugId?: string) => {

examples/src/pages/tests/table/props/data/huge-updates.page.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ const randomlyUpdateData = (
8080
}
8181
STARTED = true;
8282
setInterval(() => {
83+
if (!STARTED) {
84+
return;
85+
}
8386
const numberOfRowsToUpdate = 2;
8487
const { renderStartIndex, renderEndIndex } = api.getVerticalRenderRange();
8588
const dataArray = dataSourceApi.getRowInfoArray();
@@ -93,7 +96,7 @@ const randomlyUpdateData = (
9396
updateRow(dataSourceApi, row);
9497
}
9598
}
96-
}, 30);
99+
}, 100);
97100
};
98101

99102
const columns: InfiniteTablePropColumns<Developer> = {
@@ -140,9 +143,27 @@ const columns: InfiniteTablePropColumns<Developer> = {
140143
};
141144

142145
export default () => {
146+
const [api, setApi] = React.useState<InfiniteTableApi<Developer> | null>(
147+
null,
148+
);
149+
const [dataSourceApi, setDataSourceApi] =
150+
React.useState<DataSourceApi<Developer> | null>(null);
143151
return (
144152
<>
145153
<React.StrictMode>
154+
<button
155+
className="bg-blue-500 text-white p-2 rounded-md cursor-pointer"
156+
onClick={() => {
157+
STARTED = !STARTED;
158+
159+
console.log('STARTED', STARTED);
160+
if (STARTED) {
161+
randomlyUpdateData(api!, dataSourceApi!);
162+
}
163+
}}
164+
>
165+
Toggle updates
166+
</button>
146167
<DataSource<Developer>
147168
data={dataSource}
148169
primaryKey="id"
@@ -153,12 +174,15 @@ export default () => {
153174
groupBy={[{ field: 'stack' }]}
154175
>
155176
<InfiniteTable<Developer>
177+
debugId="huge-updates"
156178
domProps={{
157179
style: {
158180
height: '100%',
159181
},
160182
}}
161183
onReady={({ api, dataSourceApi }) => {
184+
setApi(api);
185+
setDataSourceApi(dataSourceApi);
162186
randomlyUpdateData(api, dataSourceApi);
163187
}}
164188
columnDefaultWidth={100}

0 commit comments

Comments
 (0)