@rozenite/vite-plugin 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle-dts.d.ts.map +1 -1
- package/dist/client-plugin.d.ts.map +1 -1
- package/dist/dev-config-module.d.ts.map +1 -1
- package/dist/dev-host/assets/{index-Xsb6uYhI.js → index-BgAxGQdD.js} +8 -8
- package/dist/dev-host/assets/index-ClIYIppU.css +1 -0
- package/dist/dev-host/index.html +2 -2
- package/dist/dev-host/manifest.json +2 -2
- package/dist/index.cjs +21 -66
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -66
- package/dist/load-config.d.ts.map +1 -1
- package/dist/package-json.d.ts.map +1 -1
- package/dist/react-native-plugin.d.ts.map +1 -1
- package/dist/require-plugin.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +25 -25
- package/src/bundle-dts.ts +3 -12
- package/src/client-plugin.ts +9 -34
- package/src/dev-config-module.ts +1 -4
- package/src/dev-host/App.tsx +20 -56
- package/src/dev-host/components/DispatchForm.tsx +4 -14
- package/src/dev-host/components/FlowList.tsx +4 -16
- package/src/dev-host/components/MessageDetailsPane.tsx +3 -9
- package/src/dev-host/components/MessageLogPane.tsx +4 -13
- package/src/dev-host/components/PanelTabs.tsx +3 -13
- package/src/dev-host/config.ts +2 -6
- package/src/dev-host/flow-runtime.ts +6 -24
- package/src/dev-host/server.ts +3 -9
- package/src/dev-host/types.ts +1 -5
- package/src/dev-host/utils.ts +3 -12
- package/src/index.ts +4 -14
- package/src/load-config.ts +9 -20
- package/src/package-json.ts +1 -3
- package/src/react-native-plugin.ts +1 -2
- package/src/require-plugin.ts +6 -18
- package/src/utils.ts +1 -4
- package/dist/dev-host/assets/index-DU3zXL2c.css +0 -1
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,GAAI,WAAW,MAAM,EAAE,UAAU,MAAM,KAAG,MAAM,GAAG,IAYxF,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,IAAI,MAAM,CAAC,KAAG,CAAC,MAAM,CAAC,CAU7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rozenite/vite-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Vite plugin for developing React Native DevTools plugins with hot reload and development tools",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"src",
|
|
12
|
-
"templates"
|
|
13
|
-
],
|
|
14
5
|
"keywords": [
|
|
15
|
-
"react-native",
|
|
16
6
|
"devtools",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
7
|
+
"plugin",
|
|
8
|
+
"react-native",
|
|
9
|
+
"vite"
|
|
19
10
|
],
|
|
20
11
|
"homepage": "https://github.com/callstackincubator/rozenite#readme",
|
|
21
12
|
"bugs": {
|
|
22
13
|
"url": "https://github.com/callstackincubator/rozenite/issues"
|
|
23
14
|
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Szymon Chmal <szymon.chmal@callstack.com>",
|
|
24
17
|
"repository": {
|
|
25
18
|
"type": "git",
|
|
26
19
|
"url": "https://github.com/callstackincubator/rozenite.git"
|
|
27
20
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"templates"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
33
30
|
"exports": {
|
|
34
31
|
"./package.json": "./package.json",
|
|
35
32
|
".": {
|
|
@@ -39,20 +36,18 @@
|
|
|
39
36
|
"default": "./dist/index.cjs"
|
|
40
37
|
}
|
|
41
38
|
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.50.1",
|
|
44
44
|
"@tailwindcss/vite": "4.2.2",
|
|
45
45
|
"@vitejs/plugin-react": "^4.3.4",
|
|
46
46
|
"ejs": "^3.1.9",
|
|
47
|
+
"lucide-react": "^0.263.1",
|
|
47
48
|
"vite-plugin-dts": "~4.5.0",
|
|
48
49
|
"vite-plugin-react-native-web": "^2.1.1",
|
|
49
|
-
"
|
|
50
|
-
"@rozenite/ui": "2.0.0"
|
|
51
|
-
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"react": "*",
|
|
54
|
-
"react-dom": "*",
|
|
55
|
-
"vite": "^7.3.1"
|
|
50
|
+
"@rozenite/ui": "2.1.0"
|
|
56
51
|
},
|
|
57
52
|
"devDependencies": {
|
|
58
53
|
"@types/ejs": "^3.1.5",
|
|
@@ -61,6 +56,11 @@
|
|
|
61
56
|
"react": "19.2.3",
|
|
62
57
|
"react-dom": "19.2.3"
|
|
63
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": "*",
|
|
61
|
+
"react-dom": "*",
|
|
62
|
+
"vite": "^7.3.1"
|
|
63
|
+
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=20"
|
|
66
66
|
},
|
package/src/bundle-dts.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
Extractor,
|
|
5
|
-
ExtractorConfig,
|
|
6
|
-
ExtractorLogLevel,
|
|
7
|
-
} from '@microsoft/api-extractor';
|
|
3
|
+
import { Extractor, ExtractorConfig, ExtractorLogLevel } from '@microsoft/api-extractor';
|
|
8
4
|
|
|
9
5
|
type Target = 'react-native' | 'metro' | 'sdk';
|
|
10
6
|
|
|
@@ -37,16 +33,11 @@ export const normalizeRolledUpDeclarations = (content: string) => {
|
|
|
37
33
|
);
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
export const bundleTargetDeclarations = async (
|
|
41
|
-
projectRoot: string,
|
|
42
|
-
target: Target,
|
|
43
|
-
) => {
|
|
36
|
+
export const bundleTargetDeclarations = async (projectRoot: string, target: Target) => {
|
|
44
37
|
const targetRoot = path.join(projectRoot, 'dist', target);
|
|
45
38
|
const publicEntryPath = path.join(targetRoot, 'index.d.ts');
|
|
46
39
|
const bundleEntryPath =
|
|
47
|
-
target === 'sdk'
|
|
48
|
-
? path.join(targetRoot, `${target}.d.ts`)
|
|
49
|
-
: publicEntryPath;
|
|
40
|
+
target === 'sdk' ? path.join(targetRoot, `${target}.d.ts`) : publicEntryPath;
|
|
50
41
|
const entryPath = await fs
|
|
51
42
|
.access(bundleEntryPath)
|
|
52
43
|
.then(() => bundleEntryPath)
|
package/src/client-plugin.ts
CHANGED
|
@@ -7,10 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { normalizePath } from 'vite';
|
|
8
8
|
import { loadConfig, RozeniteConfig } from './load-config.js';
|
|
9
9
|
import { getPackageJSON } from './package-json.js';
|
|
10
|
-
import {
|
|
11
|
-
DEV_HOST_CONFIG_GLOBAL_KEY,
|
|
12
|
-
DEV_HOST_STATE_ELEMENT_ID,
|
|
13
|
-
} from './dev-host/constants.js';
|
|
10
|
+
import { DEV_HOST_CONFIG_GLOBAL_KEY, DEV_HOST_STATE_ELEMENT_ID } from './dev-host/constants.js';
|
|
14
11
|
import {
|
|
15
12
|
getBuiltDevHostAssets,
|
|
16
13
|
getDevHostHtmlTemplate,
|
|
@@ -46,12 +43,7 @@ type DevHostState = {
|
|
|
46
43
|
panels: DevHostPanelEntry[];
|
|
47
44
|
};
|
|
48
45
|
|
|
49
|
-
const TEMPLATES_DIR = path.resolve(
|
|
50
|
-
fileURLToPath(import.meta.url),
|
|
51
|
-
'..',
|
|
52
|
-
'..',
|
|
53
|
-
'templates',
|
|
54
|
-
);
|
|
46
|
+
const TEMPLATES_DIR = path.resolve(fileURLToPath(import.meta.url), '..', '..', 'templates');
|
|
55
47
|
|
|
56
48
|
const PACKAGE_DIR = path.resolve(fileURLToPath(import.meta.url), '..', '..');
|
|
57
49
|
|
|
@@ -178,9 +170,7 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
178
170
|
|
|
179
171
|
config.server ??= {};
|
|
180
172
|
config.server.open =
|
|
181
|
-
config.server.open === true
|
|
182
|
-
? DEV_HOST_ROUTE
|
|
183
|
-
: (config.server.open ?? DEV_HOST_ROUTE);
|
|
173
|
+
config.server.open === true ? DEV_HOST_ROUTE : (config.server.open ?? DEV_HOST_ROUTE);
|
|
184
174
|
// Keep in sync with `DEV_SERVER_URL` in packages/runtime/src/dev-mode.ts
|
|
185
175
|
config.server.port = 8888;
|
|
186
176
|
|
|
@@ -192,10 +182,7 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
192
182
|
config.build.rollupOptions.input = {
|
|
193
183
|
...(config.build.rollupOptions.input as Record<string, string>),
|
|
194
184
|
...Object.fromEntries(
|
|
195
|
-
panels.map((panel) => [
|
|
196
|
-
panel.name,
|
|
197
|
-
`${DEVTOOLS_DIR}/${panel.htmlFile}`,
|
|
198
|
-
]),
|
|
185
|
+
panels.map((panel) => [panel.name, `${DEVTOOLS_DIR}/${panel.htmlFile}`]),
|
|
199
186
|
),
|
|
200
187
|
};
|
|
201
188
|
config.build.rollupOptions.output = {
|
|
@@ -213,9 +200,7 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
213
200
|
return devConfigModuleId;
|
|
214
201
|
}
|
|
215
202
|
|
|
216
|
-
const isPanel = getPanels().some(
|
|
217
|
-
(panel) => `${DEVTOOLS_DIR}/${panel.htmlFile}` === id,
|
|
218
|
-
);
|
|
203
|
+
const isPanel = getPanels().some((panel) => `${DEVTOOLS_DIR}/${panel.htmlFile}` === id);
|
|
219
204
|
|
|
220
205
|
if (isPanel) {
|
|
221
206
|
return id;
|
|
@@ -231,9 +216,7 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
231
216
|
return devConfigModule;
|
|
232
217
|
}
|
|
233
218
|
|
|
234
|
-
const panel = getPanels().find(
|
|
235
|
-
(panel) => `${DEVTOOLS_DIR}/${panel.htmlFile}` === id,
|
|
236
|
-
);
|
|
219
|
+
const panel = getPanels().find((panel) => `${DEVTOOLS_DIR}/${panel.htmlFile}` === id);
|
|
237
220
|
|
|
238
221
|
if (panel) {
|
|
239
222
|
return generatePanelHtmlContent(panel);
|
|
@@ -287,14 +270,8 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
287
270
|
|
|
288
271
|
server.middlewares.use((req, res, next) => {
|
|
289
272
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
290
|
-
res.setHeader(
|
|
291
|
-
|
|
292
|
-
'GET, POST, PUT, DELETE, OPTIONS',
|
|
293
|
-
);
|
|
294
|
-
res.setHeader(
|
|
295
|
-
'Access-Control-Allow-Headers',
|
|
296
|
-
'Content-Type, Authorization',
|
|
297
|
-
);
|
|
273
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
274
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
298
275
|
|
|
299
276
|
if (req.method === 'OPTIONS') {
|
|
300
277
|
res.statusCode = 200;
|
|
@@ -336,9 +313,7 @@ export const rozeniteClientPlugin = (): Plugin => {
|
|
|
336
313
|
return;
|
|
337
314
|
}
|
|
338
315
|
|
|
339
|
-
const panel = panels.find(
|
|
340
|
-
(panel) => `/${DEVTOOLS_DIR}/` + panel.htmlFile === url,
|
|
341
|
-
);
|
|
316
|
+
const panel = panels.find((panel) => `/${DEVTOOLS_DIR}/` + panel.htmlFile === url);
|
|
342
317
|
|
|
343
318
|
if (panel) {
|
|
344
319
|
const htmlContent = generatePanelHtmlContent(panel);
|
package/src/dev-config-module.ts
CHANGED
|
@@ -18,10 +18,7 @@ export const resolveRozeniteDevConfigModuleId = (id: string) => {
|
|
|
18
18
|
return null;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const loadRozeniteDevConfigModule = (
|
|
22
|
-
id: string,
|
|
23
|
-
projectRoot: string,
|
|
24
|
-
) => {
|
|
21
|
+
export const loadRozeniteDevConfigModule = (id: string, projectRoot: string) => {
|
|
25
22
|
if (id !== RESOLVED_ROZENITE_DEV_CONFIG_MODULE_ID) {
|
|
26
23
|
return null;
|
|
27
24
|
}
|
package/src/dev-host/App.tsx
CHANGED
|
@@ -31,9 +31,7 @@ type AppProps = DevHostState & {
|
|
|
31
31
|
type MobileDevtoolsTab = 'log' | 'actions';
|
|
32
32
|
|
|
33
33
|
const useNarrowViewport = () => {
|
|
34
|
-
const [isNarrow, setIsNarrow] = useState(
|
|
35
|
-
() => window.matchMedia('(max-width: 960px)').matches,
|
|
36
|
-
);
|
|
34
|
+
const [isNarrow, setIsNarrow] = useState(() => window.matchMedia('(max-width: 960px)').matches);
|
|
37
35
|
|
|
38
36
|
useEffect(() => {
|
|
39
37
|
const mediaQuery = window.matchMedia('(max-width: 960px)');
|
|
@@ -50,50 +48,34 @@ const useNarrowViewport = () => {
|
|
|
50
48
|
return isNarrow;
|
|
51
49
|
};
|
|
52
50
|
|
|
53
|
-
export const App = ({
|
|
54
|
-
packageName,
|
|
55
|
-
packageDescription,
|
|
56
|
-
panels,
|
|
57
|
-
flows,
|
|
58
|
-
presets,
|
|
59
|
-
}: AppProps) => {
|
|
51
|
+
export const App = ({ packageName, packageDescription, panels, flows, presets }: AppProps) => {
|
|
60
52
|
const [activePanel, setActivePanel] = useState<DevHostPanelEntry | null>(() =>
|
|
61
53
|
getInitialPanel(panels),
|
|
62
54
|
);
|
|
63
55
|
const [commandType, setCommandType] = useState('');
|
|
64
56
|
const [commandPayload, setCommandPayload] = useState('');
|
|
65
57
|
const [messages, setMessages] = useState<MessageEntry[]>([]);
|
|
66
|
-
const [selectedMessageId, setSelectedMessageId] = useState<string | null>(
|
|
67
|
-
null,
|
|
68
|
-
);
|
|
58
|
+
const [selectedMessageId, setSelectedMessageId] = useState<string | null>(null);
|
|
69
59
|
const [isDetailsOpen, setIsDetailsOpen] = useState(false);
|
|
70
|
-
const [activeMobileTab, setActiveMobileTab] =
|
|
71
|
-
useState<MobileDevtoolsTab>('log');
|
|
60
|
+
const [activeMobileTab, setActiveMobileTab] = useState<MobileDevtoolsTab>('log');
|
|
72
61
|
const [iframeLoadNonce, setIframeLoadNonce] = useState(0);
|
|
73
62
|
const iframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
74
63
|
const lastAutoRunLoadRef = useRef(0);
|
|
75
64
|
const isNarrowViewport = useNarrowViewport();
|
|
76
|
-
const {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{ pluginId: packageName, type, payload },
|
|
87
|
-
'*',
|
|
88
|
-
);
|
|
89
|
-
appendMessage({ direction: 'in', type, payload });
|
|
90
|
-
},
|
|
91
|
-
});
|
|
65
|
+
const { flowRuns, runFlow, stopFlow, hasRunningFlow, registerMessage, resetMessages } =
|
|
66
|
+
useFlowRunner({
|
|
67
|
+
sendMessage: (type, payload) => {
|
|
68
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
69
|
+
{ pluginId: packageName, type, payload },
|
|
70
|
+
'*',
|
|
71
|
+
);
|
|
72
|
+
appendMessage({ direction: 'in', type, payload });
|
|
73
|
+
},
|
|
74
|
+
});
|
|
92
75
|
|
|
93
76
|
const activeSource = activePanel?.source ?? '';
|
|
94
77
|
const activeLabel = activePanel?.label ?? '';
|
|
95
|
-
const selectedMessage =
|
|
96
|
-
messages.find((message) => message.id === selectedMessageId) ?? null;
|
|
78
|
+
const selectedMessage = messages.find((message) => message.id === selectedMessageId) ?? null;
|
|
97
79
|
const panelDescription = packageDescription.trim();
|
|
98
80
|
const trimmedCommandType = commandType.trim();
|
|
99
81
|
const trimmedCommandPayload = commandPayload.trim();
|
|
@@ -266,10 +248,7 @@ export const App = ({
|
|
|
266
248
|
value={activeMobileTab}
|
|
267
249
|
onValueChange={(value) => setActiveMobileTab(value as MobileDevtoolsTab)}
|
|
268
250
|
>
|
|
269
|
-
<Tabs.List
|
|
270
|
-
className="dev-host-mobile-tab-list"
|
|
271
|
-
aria-label="DevTools sections"
|
|
272
|
-
>
|
|
251
|
+
<Tabs.List className="dev-host-mobile-tab-list" aria-label="DevTools sections">
|
|
273
252
|
<Tabs.Tab value="log">Log</Tabs.Tab>
|
|
274
253
|
<Tabs.Tab value="actions">Actions</Tabs.Tab>
|
|
275
254
|
</Tabs.List>
|
|
@@ -319,34 +298,19 @@ export const App = ({
|
|
|
319
298
|
<PluginHeader className="dev-host-header">
|
|
320
299
|
<div className="dev-host-header-title">
|
|
321
300
|
<PluginHeader.Title>Rozenite Dev Host</PluginHeader.Title>
|
|
322
|
-
<PluginHeader.Subtitle
|
|
323
|
-
className="dev-host-header-subtitle"
|
|
324
|
-
title={panelDescription}
|
|
325
|
-
>
|
|
301
|
+
<PluginHeader.Subtitle className="dev-host-header-subtitle" title={panelDescription}>
|
|
326
302
|
{packageName}
|
|
327
303
|
</PluginHeader.Subtitle>
|
|
328
304
|
</div>
|
|
329
305
|
<PluginHeader.Actions>
|
|
330
306
|
<PluginHeader.ThemeSwitcher />
|
|
331
|
-
<PanelTabs
|
|
332
|
-
panels={panels}
|
|
333
|
-
activeSource={activeSource}
|
|
334
|
-
onValueChange={selectPanel}
|
|
335
|
-
/>
|
|
307
|
+
<PanelTabs panels={panels} activeSource={activeSource} onValueChange={selectPanel} />
|
|
336
308
|
</PluginHeader.Actions>
|
|
337
309
|
</PluginHeader>
|
|
338
310
|
|
|
339
311
|
<PluginShell.Body className="dev-host-body">
|
|
340
|
-
<Split
|
|
341
|
-
|
|
342
|
-
className="dev-host-main-split"
|
|
343
|
-
autoSaveId="dev-host"
|
|
344
|
-
>
|
|
345
|
-
<Split.Pane
|
|
346
|
-
defaultSize={64}
|
|
347
|
-
minSize={30}
|
|
348
|
-
className="dev-host-preview"
|
|
349
|
-
>
|
|
312
|
+
<Split direction="vertical" className="dev-host-main-split" autoSaveId="dev-host">
|
|
313
|
+
<Split.Pane defaultSize={64} minSize={30} className="dev-host-preview">
|
|
350
314
|
{panels.length === 0 ? (
|
|
351
315
|
<div className="flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground">
|
|
352
316
|
No panels were defined in rozenite.config.ts.
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { Button, Input, Select, Tabs, Textarea } from '@rozenite/ui';
|
|
2
2
|
import { RotateCcw, Send } from 'lucide-react';
|
|
3
3
|
import { useState, type FormEvent } from 'react';
|
|
4
|
-
import type {
|
|
5
|
-
DevHostFlowEntry,
|
|
6
|
-
DevHostFlowRunState,
|
|
7
|
-
DevHostPresetEntry,
|
|
8
|
-
} from '../types.js';
|
|
4
|
+
import type { DevHostFlowEntry, DevHostFlowRunState, DevHostPresetEntry } from '../types.js';
|
|
9
5
|
import { FlowList } from './FlowList.js';
|
|
10
6
|
|
|
11
7
|
type DispatchFormProps = {
|
|
@@ -72,9 +68,7 @@ export const DispatchForm = ({
|
|
|
72
68
|
>
|
|
73
69
|
<Select.Trigger
|
|
74
70
|
className="w-auto"
|
|
75
|
-
aria-label={
|
|
76
|
-
presets.length > 0 ? 'Open presets' : 'No presets available'
|
|
77
|
-
}
|
|
71
|
+
aria-label={presets.length > 0 ? 'Open presets' : 'No presets available'}
|
|
78
72
|
disabled={presets.length === 0}
|
|
79
73
|
title={presets.length > 0 ? 'Presets' : 'No presets available'}
|
|
80
74
|
>
|
|
@@ -97,9 +91,7 @@ export const DispatchForm = ({
|
|
|
97
91
|
<span className="dev-host-label">Command</span>
|
|
98
92
|
<Input
|
|
99
93
|
value={commandType}
|
|
100
|
-
onChange={(event) =>
|
|
101
|
-
onCommandTypeChange(event.currentTarget.value)
|
|
102
|
-
}
|
|
94
|
+
onChange={(event) => onCommandTypeChange(event.currentTarget.value)}
|
|
103
95
|
placeholder="get-snapshot"
|
|
104
96
|
spellCheck={false}
|
|
105
97
|
/>
|
|
@@ -109,9 +101,7 @@ export const DispatchForm = ({
|
|
|
109
101
|
<span className="dev-host-label">Payload</span>
|
|
110
102
|
<Textarea
|
|
111
103
|
value={commandPayload}
|
|
112
|
-
onChange={(event) =>
|
|
113
|
-
onCommandPayloadChange(event.currentTarget.value)
|
|
114
|
-
}
|
|
104
|
+
onChange={(event) => onCommandPayloadChange(event.currentTarget.value)}
|
|
115
105
|
placeholder='{"example": true}'
|
|
116
106
|
spellCheck={false}
|
|
117
107
|
/>
|
|
@@ -76,24 +76,14 @@ export const FlowList = ({
|
|
|
76
76
|
<span className="dev-host-label">Flow runs</span>
|
|
77
77
|
<div className="dev-host-flow-runs">
|
|
78
78
|
{flowRuns.map((flowRun) => (
|
|
79
|
-
<div
|
|
80
|
-
key={flowRun.id}
|
|
81
|
-
className="dev-host-flow-state"
|
|
82
|
-
data-status={flowRun.status}
|
|
83
|
-
>
|
|
79
|
+
<div key={flowRun.id} className="dev-host-flow-state" data-status={flowRun.status}>
|
|
84
80
|
<div className="dev-host-flow-state-header">
|
|
85
81
|
<span className="dev-host-flow-title">
|
|
86
82
|
{flowRun.flowDisplayName}
|
|
87
|
-
{flowRun.autoRun ?
|
|
88
|
-
<Badge variant="outline">Auto</Badge>
|
|
89
|
-
) : null}
|
|
83
|
+
{flowRun.autoRun ? <Badge variant="outline">Auto</Badge> : null}
|
|
90
84
|
</span>
|
|
91
85
|
{flowRun.status === 'running' ? (
|
|
92
|
-
<Button
|
|
93
|
-
variant="ghost"
|
|
94
|
-
size="compact"
|
|
95
|
-
onClick={() => onStopFlow(flowRun.id)}
|
|
96
|
-
>
|
|
86
|
+
<Button variant="ghost" size="compact" onClick={() => onStopFlow(flowRun.id)}>
|
|
97
87
|
<Square />
|
|
98
88
|
Stop
|
|
99
89
|
</Button>
|
|
@@ -103,9 +93,7 @@ export const FlowList = ({
|
|
|
103
93
|
{getStatusLabel(flowRun.status)}
|
|
104
94
|
</span>
|
|
105
95
|
{flowRun.error ? (
|
|
106
|
-
<div className="dev-host-flow-state-error">
|
|
107
|
-
{flowRun.error}
|
|
108
|
-
</div>
|
|
96
|
+
<div className="dev-host-flow-state-error">{flowRun.error}</div>
|
|
109
97
|
) : null}
|
|
110
98
|
{flowRun.result != null ? (
|
|
111
99
|
<pre className="dev-host-flow-state-result">
|
|
@@ -44,9 +44,7 @@ export const MessageDetailsPane = ({
|
|
|
44
44
|
<div className="dev-host-details">
|
|
45
45
|
<div className="dev-host-detail-section">
|
|
46
46
|
<span className="dev-host-label">Date</span>
|
|
47
|
-
<div className="dev-host-detail-value">
|
|
48
|
-
{formatMessageDate(selectedMessage.date)}
|
|
49
|
-
</div>
|
|
47
|
+
<div className="dev-host-detail-value">{formatMessageDate(selectedMessage.date)}</div>
|
|
50
48
|
</div>
|
|
51
49
|
<div className="dev-host-detail-section">
|
|
52
50
|
<span className="dev-host-label">Type</span>
|
|
@@ -55,12 +53,8 @@ export const MessageDetailsPane = ({
|
|
|
55
53
|
<div className="dev-host-detail-section">
|
|
56
54
|
<span className="dev-host-label">Payload</span>
|
|
57
55
|
<div className="dev-host-detail-payload">
|
|
58
|
-
{typeof selectedMessage.payload === 'object' &&
|
|
59
|
-
|
|
60
|
-
<JsonInspector
|
|
61
|
-
data={selectedMessage.payload}
|
|
62
|
-
defaultExpandedDepth={2}
|
|
63
|
-
/>
|
|
56
|
+
{typeof selectedMessage.payload === 'object' && selectedMessage.payload !== null ? (
|
|
57
|
+
<JsonInspector data={selectedMessage.payload} defaultExpandedDepth={2} />
|
|
64
58
|
) : (
|
|
65
59
|
<pre className="m-0 whitespace-pre-wrap break-words">
|
|
66
60
|
{formatPayloadForCommandInput(selectedMessage.payload)}
|
|
@@ -27,9 +27,7 @@ export const MessageLogPane = ({
|
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
29
|
<span
|
|
30
|
-
className={
|
|
31
|
-
isSent ? 'dev-host-direction-in' : 'dev-host-direction-out'
|
|
32
|
-
}
|
|
30
|
+
className={isSent ? 'dev-host-direction-in' : 'dev-host-direction-out'}
|
|
33
31
|
aria-label={isSent ? 'Sent message' : 'Received message'}
|
|
34
32
|
title={isSent ? 'Sent message' : 'Received message'}
|
|
35
33
|
>
|
|
@@ -42,17 +40,13 @@ export const MessageLogPane = ({
|
|
|
42
40
|
accessorKey: 'date',
|
|
43
41
|
header: 'Date',
|
|
44
42
|
cell: ({ row }) => (
|
|
45
|
-
<span className="text-muted-foreground">
|
|
46
|
-
{formatMessageTableDate(row.original.date)}
|
|
47
|
-
</span>
|
|
43
|
+
<span className="text-muted-foreground">{formatMessageTableDate(row.original.date)}</span>
|
|
48
44
|
),
|
|
49
45
|
},
|
|
50
46
|
{
|
|
51
47
|
accessorKey: 'type',
|
|
52
48
|
header: 'Type',
|
|
53
|
-
cell: ({ getValue }) => (
|
|
54
|
-
<span className="font-medium">{getValue<string>()}</span>
|
|
55
|
-
),
|
|
49
|
+
cell: ({ getValue }) => <span className="font-medium">{getValue<string>()}</span>,
|
|
56
50
|
},
|
|
57
51
|
{
|
|
58
52
|
id: 'payload',
|
|
@@ -84,10 +78,7 @@ export const MessageLogPane = ({
|
|
|
84
78
|
</Button>
|
|
85
79
|
</header>
|
|
86
80
|
|
|
87
|
-
<ScrollArea
|
|
88
|
-
className="dev-host-scroll"
|
|
89
|
-
viewportClassName="dev-host-scroll-viewport"
|
|
90
|
-
>
|
|
81
|
+
<ScrollArea className="dev-host-scroll" viewportClassName="dev-host-scroll-viewport">
|
|
91
82
|
<DataTable
|
|
92
83
|
className="dev-host-message-table"
|
|
93
84
|
columns={columns}
|
|
@@ -7,11 +7,7 @@ type PanelTabsProps = {
|
|
|
7
7
|
onValueChange: (value: string) => void;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export const PanelTabs = ({
|
|
11
|
-
panels,
|
|
12
|
-
activeSource,
|
|
13
|
-
onValueChange,
|
|
14
|
-
}: PanelTabsProps) => {
|
|
10
|
+
export const PanelTabs = ({ panels, activeSource, onValueChange }: PanelTabsProps) => {
|
|
15
11
|
if (panels.length === 0) {
|
|
16
12
|
return null;
|
|
17
13
|
}
|
|
@@ -19,14 +15,8 @@ export const PanelTabs = ({
|
|
|
19
15
|
const activePanel = panels.find((panel) => panel.source === activeSource);
|
|
20
16
|
|
|
21
17
|
return (
|
|
22
|
-
<Select
|
|
23
|
-
|
|
24
|
-
onValueChange={(value) => onValueChange(String(value))}
|
|
25
|
-
>
|
|
26
|
-
<Select.Trigger
|
|
27
|
-
className="dev-host-panel-select"
|
|
28
|
-
aria-label="Plugin panel"
|
|
29
|
-
>
|
|
18
|
+
<Select value={activeSource} onValueChange={(value) => onValueChange(String(value))}>
|
|
19
|
+
<Select.Trigger className="dev-host-panel-select" aria-label="Plugin panel">
|
|
30
20
|
<Select.Value>{activePanel?.label}</Select.Value>
|
|
31
21
|
</Select.Trigger>
|
|
32
22
|
<Select.Content align="end">
|
package/src/dev-host/config.ts
CHANGED
|
@@ -19,9 +19,7 @@ const getEntryDisplayName = (value: unknown, fallback: string) => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const getDevHostConfig = () => {
|
|
22
|
-
const value = (window as unknown as Record<string, unknown>)[
|
|
23
|
-
DEV_HOST_CONFIG_GLOBAL_KEY
|
|
24
|
-
];
|
|
22
|
+
const value = (window as unknown as Record<string, unknown>)[DEV_HOST_CONFIG_GLOBAL_KEY];
|
|
25
23
|
|
|
26
24
|
if (typeof value !== 'object' || value === null) {
|
|
27
25
|
return {} as { presets?: unknown; flows?: unknown };
|
|
@@ -30,9 +28,7 @@ const getDevHostConfig = () => {
|
|
|
30
28
|
return value as { presets?: unknown; flows?: unknown };
|
|
31
29
|
};
|
|
32
30
|
|
|
33
|
-
const isDevHostPresetSource = (
|
|
34
|
-
value: unknown,
|
|
35
|
-
): value is DevHostPresetSource => {
|
|
31
|
+
const isDevHostPresetSource = (value: unknown): value is DevHostPresetSource => {
|
|
36
32
|
return (
|
|
37
33
|
typeof value === 'object' &&
|
|
38
34
|
value !== null &&
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
DevFlowMessage,
|
|
5
|
-
DevFlowMessageMatcher,
|
|
6
|
-
} from '../load-config.js';
|
|
7
|
-
import type {
|
|
8
|
-
DevHostFlowEntry,
|
|
9
|
-
DevHostFlowRunState,
|
|
10
|
-
MessageEntry,
|
|
11
|
-
} from './types.js';
|
|
2
|
+
import type { DevFlowContext, DevFlowMessage, DevFlowMessageMatcher } from '../load-config.js';
|
|
3
|
+
import type { DevHostFlowEntry, DevHostFlowRunState, MessageEntry } from './types.js';
|
|
12
4
|
|
|
13
5
|
type FlowRunnerOptions = {
|
|
14
6
|
sendMessage: (type: string, payload: unknown) => void;
|
|
@@ -44,10 +36,7 @@ const toFlowMessage = (message: MessageEntry): DevFlowMessage => {
|
|
|
44
36
|
};
|
|
45
37
|
};
|
|
46
38
|
|
|
47
|
-
const matchesMessage = (
|
|
48
|
-
message: DevFlowMessage,
|
|
49
|
-
matcher?: DevFlowMessageMatcher,
|
|
50
|
-
) => {
|
|
39
|
+
const matchesMessage = (message: DevFlowMessage, matcher?: DevFlowMessageMatcher) => {
|
|
51
40
|
if (!matcher) {
|
|
52
41
|
return true;
|
|
53
42
|
}
|
|
@@ -219,9 +208,7 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
|
|
|
219
208
|
timeoutId = window.setTimeout(() => {
|
|
220
209
|
cleanup();
|
|
221
210
|
reject(
|
|
222
|
-
new Error(
|
|
223
|
-
`Timed out waiting for a matching message after ${options.timeoutMs}ms.`,
|
|
224
|
-
),
|
|
211
|
+
new Error(`Timed out waiting for a matching message after ${options.timeoutMs}ms.`),
|
|
225
212
|
);
|
|
226
213
|
}, options.timeoutMs);
|
|
227
214
|
}
|
|
@@ -252,10 +239,7 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
|
|
|
252
239
|
|
|
253
240
|
const updateRunState = (
|
|
254
241
|
nextState: Partial<
|
|
255
|
-
Omit<
|
|
256
|
-
DevHostFlowRunState,
|
|
257
|
-
'id' | 'flowName' | 'flowDisplayName' | 'autoRun'
|
|
258
|
-
>
|
|
242
|
+
Omit<DevHostFlowRunState, 'id' | 'flowName' | 'flowDisplayName' | 'autoRun'>
|
|
259
243
|
>,
|
|
260
244
|
) => {
|
|
261
245
|
setFlowRuns((current) =>
|
|
@@ -302,9 +286,7 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
|
|
|
302
286
|
};
|
|
303
287
|
|
|
304
288
|
const hasRunningFlow = (flowName: string) => {
|
|
305
|
-
return flowRuns.some(
|
|
306
|
-
(run) => run.flowName === flowName && run.status === 'running',
|
|
307
|
-
);
|
|
289
|
+
return flowRuns.some((run) => run.flowName === flowName && run.status === 'running');
|
|
308
290
|
};
|
|
309
291
|
|
|
310
292
|
return {
|
package/src/dev-host/server.ts
CHANGED
|
@@ -33,9 +33,7 @@ export const getDevHostSourceEntryFile = (packageDir: string) => {
|
|
|
33
33
|
return path.join(packageDir, 'src', 'dev-host', 'main.tsx');
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export const getBuiltDevHostAssets = (
|
|
37
|
-
packageDir: string,
|
|
38
|
-
): DevHostBuiltAssets | null => {
|
|
36
|
+
export const getBuiltDevHostAssets = (packageDir: string): DevHostBuiltAssets | null => {
|
|
39
37
|
const devHostDistDir = path.join(packageDir, 'dist', 'dev-host');
|
|
40
38
|
const manifestPath = path.join(devHostDistDir, 'manifest.json');
|
|
41
39
|
|
|
@@ -43,15 +41,11 @@ export const getBuiltDevHostAssets = (
|
|
|
43
41
|
return null;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
const manifest = JSON.parse(
|
|
47
|
-
fs.readFileSync(manifestPath, 'utf8'),
|
|
48
|
-
) as DevHostBuildManifest;
|
|
44
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as DevHostBuildManifest;
|
|
49
45
|
const entry = manifest[DEV_HOST_BUILD_ENTRY_KEY];
|
|
50
46
|
|
|
51
47
|
if (!entry?.file) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`Missing ${DEV_HOST_BUILD_ENTRY_KEY} entry in dev host manifest.`,
|
|
54
|
-
);
|
|
48
|
+
throw new Error(`Missing ${DEV_HOST_BUILD_ENTRY_KEY} entry in dev host manifest.`);
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
return {
|