@rozenite/vite-plugin 1.13.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.
Files changed (57) hide show
  1. package/README.md +12 -0
  2. package/dist/bundle-dts.d.ts.map +1 -1
  3. package/dist/client-plugin.d.ts.map +1 -1
  4. package/dist/dev-host/assets/index-BgAxGQdD.js +13 -0
  5. package/dist/dev-host/assets/index-ClIYIppU.css +1 -0
  6. package/dist/dev-host/index.html +3 -3
  7. package/dist/dev-host/manifest.json +2 -2
  8. package/dist/index.cjs +34 -63
  9. package/dist/index.d.ts +9 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +34 -63
  12. package/dist/load-config.d.ts.map +1 -1
  13. package/dist/package-json.d.ts.map +1 -1
  14. package/dist/react-native-plugin.d.ts.map +1 -1
  15. package/dist/require-plugin.d.ts.map +1 -1
  16. package/dist/sdk-plugin.d.ts.map +1 -1
  17. package/dist/server-plugin.d.ts.map +1 -1
  18. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  19. package/dist/utils.d.ts.map +1 -1
  20. package/package.json +29 -30
  21. package/src/bundle-dts.ts +6 -14
  22. package/src/client-plugin.ts +13 -36
  23. package/src/dev-host/App.tsx +184 -414
  24. package/src/dev-host/components/DispatchForm.tsx +97 -121
  25. package/src/dev-host/components/FlowList.tsx +70 -102
  26. package/src/dev-host/components/MessageDetailsPane.tsx +50 -83
  27. package/src/dev-host/components/MessageLogPane.tsx +75 -66
  28. package/src/dev-host/components/PanelTabs.tsx +19 -10
  29. package/src/dev-host/constants.ts +0 -19
  30. package/src/dev-host/flow-runtime.ts +15 -12
  31. package/src/dev-host/index.html +1 -1
  32. package/src/dev-host/main.tsx +1 -10
  33. package/src/dev-host/styles.css +162 -830
  34. package/src/dev-host/types.ts +0 -9
  35. package/src/dev-host/utils.ts +1 -7
  36. package/src/dev-host/vite.config.mts +2 -0
  37. package/src/index.ts +16 -16
  38. package/src/load-config.ts +9 -20
  39. package/src/package-json.ts +1 -3
  40. package/src/react-native-plugin.ts +4 -2
  41. package/src/require-plugin.ts +6 -18
  42. package/src/sdk-plugin.ts +3 -0
  43. package/src/server-plugin.ts +3 -0
  44. package/src/utils.ts +1 -4
  45. package/dist/dev-host/assets/index-CkxvBMpp.css +0 -1
  46. package/dist/dev-host/assets/index-cNKHRwej.js +0 -11
  47. package/src/dev-host/components/MessagePayloadDetail.tsx +0 -32
  48. package/src/dev-host/components/ResizeHandle.tsx +0 -33
  49. package/src/dev-host/components/icons.tsx +0 -79
  50. package/src/dev-host/components/ui/Button.tsx +0 -91
  51. package/src/dev-host/components/ui/DropdownMenu.tsx +0 -84
  52. package/src/dev-host/components/ui/IconButton.tsx +0 -41
  53. package/src/dev-host/components/ui/Input.tsx +0 -73
  54. package/src/dev-host/components/ui/ScrollArea.tsx +0 -20
  55. package/src/dev-host/components/ui/Tabs.tsx +0 -166
  56. package/src/dev-host/components/ui/Textarea.tsx +0 -79
  57. package/src/dev-host/components/ui/ToggleGroup.tsx +0 -120
@@ -1,84 +1,93 @@
1
+ import { Button, DataTable, ScrollArea } from '@rozenite/ui';
2
+ import { Trash2 } from 'lucide-react';
3
+ import { useMemo } from 'react';
4
+ import type { DataTableColumn } from '@rozenite/ui';
1
5
  import type { MessageEntry } from '../types.js';
2
- import { cn, formatMessageTableDate, formatPayloadPreview } from '../utils.js';
3
- import { ClearIcon } from './icons.js';
4
- import { ScrollArea } from './ui/ScrollArea.js';
5
- import { IconButton } from './ui/IconButton.js';
6
+ import { formatMessageTableDate, formatPayloadPreview } from '../utils.js';
6
7
 
7
8
  type MessageLogPaneProps = {
8
9
  messages: MessageEntry[];
9
- selectedMessageId: string | null;
10
10
  onSelectMessage: (messageId: string) => void;
11
11
  onClearMessages: () => void;
12
12
  };
13
13
 
14
14
  export const MessageLogPane = ({
15
15
  messages,
16
- selectedMessageId,
17
16
  onSelectMessage,
18
17
  onClearMessages,
19
18
  }: MessageLogPaneProps) => {
20
- return (
21
- <div className="rz-pane">
22
- <div className="rz-log-pane">
23
- <div className="rz-sidebar-header">
24
- <div className="rz-sidebar-title">Message Log</div>
25
- <div className="rz-header-actions">
26
- <IconButton
27
- type="button"
28
- onClick={onClearMessages}
29
- disabled={messages.length === 0}
30
- aria-label="Clear message log"
31
- title="Clear message log"
32
- >
33
- <ClearIcon />
34
- </IconButton>
35
- </div>
36
- </div>
37
-
38
- <ScrollArea className="rz-sidebar-scroll">
39
- <div className="rz-message-list">
40
- <div className="rz-message-list-header">
41
- <div className="rz-message-header-cell">Dir</div>
42
- <div className="rz-message-header-cell">Date</div>
43
- <div className="rz-message-header-cell">Type</div>
44
- <div className="rz-message-header-cell">Payload</div>
45
- </div>
46
-
47
- {messages.map((message) => (
48
- <button
49
- key={message.id}
50
- type="button"
51
- className="rz-message-row"
52
- data-selected={message.id === selectedMessageId}
53
- onClick={() => onSelectMessage(message.id)}
54
- >
55
- <div
56
- className={cn(
57
- 'rz-message-cell rz-message-direction',
58
- message.direction === 'in' ? 'rz-message-dir-in' : 'rz-message-dir-out',
59
- )}
60
- aria-label={message.direction === 'in' ? 'Sent message' : 'Received message'}
61
- title={message.direction === 'in' ? 'Sent message' : 'Received message'}
62
- >
63
- <span className="rz-message-arrow" aria-hidden="true">
64
- {message.direction === 'in' ? '↑' : '↓'}
65
- </span>
66
- </div>
19
+ const columns = useMemo<DataTableColumn<MessageEntry>[]>(
20
+ () => [
21
+ {
22
+ accessorKey: 'direction',
23
+ header: 'Dir',
24
+ cell: ({ getValue }) => {
25
+ const direction = getValue<MessageEntry['direction']>();
26
+ const isSent = direction === 'in';
67
27
 
68
- <div className="rz-message-cell rz-message-date">
69
- {formatMessageTableDate(message.date)}
70
- </div>
28
+ return (
29
+ <span
30
+ className={isSent ? 'dev-host-direction-in' : 'dev-host-direction-out'}
31
+ aria-label={isSent ? 'Sent message' : 'Received message'}
32
+ title={isSent ? 'Sent message' : 'Received message'}
33
+ >
34
+ {isSent ? '↑' : '↓'}
35
+ </span>
36
+ );
37
+ },
38
+ },
39
+ {
40
+ accessorKey: 'date',
41
+ header: 'Date',
42
+ cell: ({ row }) => (
43
+ <span className="text-muted-foreground">{formatMessageTableDate(row.original.date)}</span>
44
+ ),
45
+ },
46
+ {
47
+ accessorKey: 'type',
48
+ header: 'Type',
49
+ cell: ({ getValue }) => <span className="font-medium">{getValue<string>()}</span>,
50
+ },
51
+ {
52
+ id: 'payload',
53
+ accessorFn: (message) => formatPayloadPreview(message.payload),
54
+ header: 'Payload',
55
+ cell: ({ getValue }) => (
56
+ <span className="block max-w-160 truncate font-mono text-xs text-muted-foreground">
57
+ {getValue<string>()}
58
+ </span>
59
+ ),
60
+ },
61
+ ],
62
+ [],
63
+ );
71
64
 
72
- <div className="rz-message-cell rz-message-type">{message.type}</div>
65
+ return (
66
+ <section className="dev-host-pane">
67
+ <header className="dev-host-pane-header">
68
+ <h2 className="dev-host-pane-title">Message Log</h2>
69
+ <Button
70
+ variant="ghost"
71
+ size="icon"
72
+ onClick={onClearMessages}
73
+ disabled={messages.length === 0}
74
+ aria-label="Clear message log"
75
+ title="Clear message log"
76
+ >
77
+ <Trash2 />
78
+ </Button>
79
+ </header>
73
80
 
74
- <pre className="rz-message-cell rz-message-preview">
75
- {formatPayloadPreview(message.payload)}
76
- </pre>
77
- </button>
78
- ))}
79
- </div>
80
- </ScrollArea>
81
- </div>
82
- </div>
81
+ <ScrollArea className="dev-host-scroll" viewportClassName="dev-host-scroll-viewport">
82
+ <DataTable
83
+ className="dev-host-message-table"
84
+ columns={columns}
85
+ data={messages}
86
+ emptyMessage="No messages yet."
87
+ getRowId={(message) => message.id}
88
+ onRowClick={(message) => onSelectMessage(message.id)}
89
+ />
90
+ </ScrollArea>
91
+ </section>
83
92
  );
84
93
  };
@@ -1,5 +1,5 @@
1
+ import { Select } from '@rozenite/ui';
1
2
  import type { DevHostPanelEntry } from '../types.js';
2
- import { ToggleGroup } from './ui/ToggleGroup.js';
3
3
 
4
4
  type PanelTabsProps = {
5
5
  panels: DevHostPanelEntry[];
@@ -8,15 +8,24 @@ type PanelTabsProps = {
8
8
  };
9
9
 
10
10
  export const PanelTabs = ({ panels, activeSource, onValueChange }: PanelTabsProps) => {
11
+ if (panels.length === 0) {
12
+ return null;
13
+ }
14
+
15
+ const activePanel = panels.find((panel) => panel.source === activeSource);
16
+
11
17
  return (
12
- <ToggleGroup
13
- aria-label="Plugin panels"
14
- value={activeSource}
15
- onChange={onValueChange}
16
- options={panels.map((panel) => ({
17
- key: panel.source,
18
- label: panel.label,
19
- }))}
20
- />
18
+ <Select value={activeSource} onValueChange={(value) => onValueChange(String(value))}>
19
+ <Select.Trigger className="dev-host-panel-select" aria-label="Plugin panel">
20
+ <Select.Value>{activePanel?.label}</Select.Value>
21
+ </Select.Trigger>
22
+ <Select.Content align="end">
23
+ {panels.map((panel) => (
24
+ <Select.Item key={panel.source} value={panel.source}>
25
+ {panel.label}
26
+ </Select.Item>
27
+ ))}
28
+ </Select.Content>
29
+ </Select>
21
30
  );
22
31
  };
@@ -10,22 +10,3 @@ export const MIN_DETAILS_WIDTH = 280;
10
10
  export const DEFAULT_COMMAND_WIDTH = 320;
11
11
  export const MIN_COMMAND_WIDTH = 260;
12
12
  export const SPLITTER_SIZE = 6;
13
-
14
- export const jsonTreeTheme = {
15
- base00: 'transparent',
16
- base01: '#374151',
17
- base02: '#4b5563',
18
- base03: '#6b7280',
19
- base04: '#9ca3af',
20
- base05: '#d1d5db',
21
- base06: '#e5e7eb',
22
- base07: '#f9fafb',
23
- base08: '#ef4444',
24
- base09: '#f59e0b',
25
- base0A: '#10b981',
26
- base0B: '#3b82f6',
27
- base0C: '#06b6d4',
28
- base0D: '#8b5cf6',
29
- base0E: '#ec4899',
30
- base0F: '#f97316',
31
- };
@@ -36,10 +36,7 @@ const toFlowMessage = (message: MessageEntry): DevFlowMessage => {
36
36
  };
37
37
  };
38
38
 
39
- const matchesMessage = (
40
- message: DevFlowMessage,
41
- matcher?: DevFlowMessageMatcher,
42
- ) => {
39
+ const matchesMessage = (message: DevFlowMessage, matcher?: DevFlowMessageMatcher) => {
43
40
  if (!matcher) {
44
41
  return true;
45
42
  }
@@ -138,12 +135,12 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
138
135
  }
139
136
  };
140
137
 
141
- const cleanupRun = () => {
142
- activeRun.cleanups.forEach((cleanup) => cleanup());
143
- activeRun.cleanups.clear();
144
- activeRun.listeners.clear();
145
- activeRunsRef.current.delete(runId);
146
- };
138
+ const cleanupRun = () => {
139
+ activeRun.cleanups.forEach((cleanup) => cleanup());
140
+ activeRun.cleanups.clear();
141
+ activeRun.listeners.clear();
142
+ activeRunsRef.current.delete(runId);
143
+ };
147
144
 
148
145
  const onMessage: DevFlowContext['onMessage'] = (matcher, listener) => {
149
146
  throwIfAborted();
@@ -203,7 +200,9 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
203
200
  resolve(message);
204
201
  });
205
202
 
206
- controller.signal.addEventListener('abort', handleAbort, { once: true });
203
+ controller.signal.addEventListener('abort', handleAbort, {
204
+ once: true,
205
+ });
207
206
 
208
207
  if (options?.timeoutMs != null) {
209
208
  timeoutId = window.setTimeout(() => {
@@ -238,7 +237,11 @@ export const useFlowRunner = ({ sendMessage }: FlowRunnerOptions) => {
238
237
  ...current,
239
238
  ]);
240
239
 
241
- const updateRunState = (nextState: Partial<Omit<DevHostFlowRunState, 'id' | 'flowName' | 'flowDisplayName' | 'autoRun'>>) => {
240
+ const updateRunState = (
241
+ nextState: Partial<
242
+ Omit<DevHostFlowRunState, 'id' | 'flowName' | 'flowDisplayName' | 'autoRun'>
243
+ >,
244
+ ) => {
242
245
  setFlowRuns((current) =>
243
246
  current.map((run) =>
244
247
  run.id === runId
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
@@ -1,15 +1,10 @@
1
1
  import { StrictMode } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
- import { BaseProvider, DarkTheme } from 'baseui';
4
- import { Client as Styletron } from 'styletron-engine-monolithic';
5
- import { Provider as StyletronProvider } from 'styletron-react';
6
3
  import { App } from './App.js';
7
4
  import { getDevHostFlows, getDevHostPresets } from './config.js';
8
5
  import './styles.css';
9
6
  import { readDevHostState } from './utils.js';
10
7
 
11
- const styletron = new Styletron();
12
-
13
8
  const rootElement = document.getElementById('root');
14
9
 
15
10
  if (!rootElement) {
@@ -22,10 +17,6 @@ const presets = getDevHostPresets();
22
17
 
23
18
  createRoot(rootElement).render(
24
19
  <StrictMode>
25
- <StyletronProvider value={styletron}>
26
- <BaseProvider theme={DarkTheme}>
27
- <App {...state} flows={flows} presets={presets} />
28
- </BaseProvider>
29
- </StyletronProvider>
20
+ <App {...state} flows={flows} presets={presets} />
30
21
  </StrictMode>,
31
22
  );