@visulima/dev-toolbar 0.0.1 → 1.0.0-alpha.10
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/CHANGELOG.md +223 -0
- package/LICENSE.md +188 -0
- package/README.md +304 -29
- package/bin/mcp.js +29 -0
- package/dist/apps/a11y/a11y-app.d.ts +4 -0
- package/dist/apps/a11y/a11y-store.d.ts +42 -0
- package/dist/apps/a11y/a11y-tooltip.d.ts +10 -0
- package/dist/apps/a11y/index.d.ts +3 -0
- package/dist/apps/a11y/index.js +21 -0
- package/dist/apps/annotations/annotations-app.d.ts +4 -0
- package/dist/apps/annotations/index.d.ts +3 -0
- package/dist/apps/annotations/index.js +18 -0
- package/dist/apps/assets/assets-app.d.ts +4 -0
- package/dist/apps/assets/index.d.ts +3 -0
- package/dist/apps/assets/index.js +16 -0
- package/dist/apps/inspector/a11y-capture.d.ts +12 -0
- package/dist/apps/inspector/annotation-overlay.d.ts +55 -0
- package/dist/apps/inspector/annotation-settings.d.ts +33 -0
- package/dist/apps/inspector/element-utils.d.ts +115 -0
- package/dist/apps/inspector/freeze-animations.d.ts +22 -0
- package/dist/apps/inspector/index.d.ts +3 -0
- package/dist/apps/inspector/index.js +30 -0
- package/dist/apps/inspector/inspector-app.d.ts +14 -0
- package/dist/apps/inspector/rulers.d.ts +14 -0
- package/dist/apps/inspector/theme-palette.d.ts +34 -0
- package/dist/apps/module-graph/index.d.ts +3 -0
- package/dist/apps/module-graph/index.js +20 -0
- package/dist/apps/module-graph/module-graph-app.d.ts +4 -0
- package/dist/apps/performance/index.d.ts +3 -0
- package/dist/apps/performance/index.js +17 -0
- package/dist/apps/performance/performance-app.d.ts +4 -0
- package/dist/apps/performance/performance-tooltip.d.ts +4 -0
- package/dist/apps/seo/index.d.ts +3 -0
- package/dist/apps/seo/index.js +17 -0
- package/dist/apps/seo/seo-app.d.ts +4 -0
- package/dist/apps/settings/index.d.ts +3 -0
- package/dist/apps/settings/index.js +17 -0
- package/dist/apps/settings/settings-app.d.ts +4 -0
- package/dist/apps/tailwind/index.d.ts +3 -0
- package/dist/apps/tailwind/index.js +7 -0
- package/dist/apps/tailwind/tailwind-app.d.ts +4 -0
- package/dist/apps/timeline/index.d.ts +3 -0
- package/dist/apps/timeline/index.js +18 -0
- package/dist/apps/timeline/timeline-app.d.ts +4 -0
- package/dist/apps/vite-config/index.d.ts +3 -0
- package/dist/apps/vite-config/index.js +16 -0
- package/dist/apps/vite-config/vite-config-app.d.ts +4 -0
- package/dist/client/overlay.d.ts +1 -0
- package/dist/client/overlay.js +1 -0
- package/dist/hooks/create-hook.d.ts +12 -0
- package/dist/hooks/events.d.ts +7 -0
- package/dist/hooks/global-hook.d.ts +15 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -0
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.js +1 -0
- package/dist/packem_chunks/inject-source.js +9 -0
- package/dist/packem_shared/Alert-D2CvX4fw.js +1 -0
- package/dist/packem_shared/Badge-BEgU04nl.js +1 -0
- package/dist/packem_shared/Button-Bkx66Co7.js +1 -0
- package/dist/packem_shared/Card-CJa4vHVc.js +1 -0
- package/dist/packem_shared/Icon-B6UHkC0o.js +1 -0
- package/dist/packem_shared/Input-Cs6aduTi.js +1 -0
- package/dist/packem_shared/Label-DyCng4Cp.js +1 -0
- package/dist/packem_shared/Popover-BtFVaZYg.js +1 -0
- package/dist/packem_shared/Progress-DN6zn-0l.js +1 -0
- package/dist/packem_shared/Select-DgQ4ss-s.js +1 -0
- package/dist/packem_shared/Separator-D38mKeZv.js +1 -0
- package/dist/packem_shared/Skeleton-Dv-tcA1P.js +1 -0
- package/dist/packem_shared/Switch-C3NTpeoR.js +1 -0
- package/dist/packem_shared/Tabs-DKWMiawt.js +1 -0
- package/dist/packem_shared/Textarea-Yfg3dLZi.js +1 -0
- package/dist/packem_shared/Tooltip-CioncSXj.js +1 -0
- package/dist/packem_shared/annotation-settings-Bv0TH4WI.js +1 -0
- package/dist/packem_shared/annotation-store-bLQRYMaI.js +1 -0
- package/dist/packem_shared/clsx-wGlvpUfw.js +1 -0
- package/dist/packem_shared/createClientRPCContext-DgRxrllw.js +1 -0
- package/dist/packem_shared/createDevToolbarHook-4bZZiHPI.js +1 -0
- package/dist/packem_shared/createServerRPCContext-D-yZrEjs.js +1 -0
- package/dist/packem_shared/getTimelineStore-B1cfjWV8.js +1 -0
- package/dist/packem_shared/loadSettings-hvjR4fcS.js +1 -0
- package/dist/packem_shared/setupGlobalHook-CCf9Logv.js +1 -0
- package/dist/packem_shared/sharedToolbarStylesheet-CaTdYhVe.js +2 -0
- package/dist/packem_shared/store-DaUtLjf3.js +1 -0
- package/dist/packem_shared/use-frame-state-CxrlPUM5.js +1 -0
- package/dist/packem_shared/use-theme-zpm4zmqP.js +1 -0
- package/dist/performance/monitor.d.ts +116 -0
- package/dist/rpc/client.d.ts +9 -0
- package/dist/rpc/functions/annotations.d.ts +28 -0
- package/dist/rpc/functions/assets.d.ts +16 -0
- package/dist/rpc/functions/module-graph.d.ts +17 -0
- package/dist/rpc/functions/open-in-editor.d.ts +16 -0
- package/dist/rpc/functions/tailwind-config.d.ts +15 -0
- package/dist/rpc/functions/vite-config.d.ts +83 -0
- package/dist/rpc/server.d.ts +15 -0
- package/dist/store/annotation-store.d.ts +41 -0
- package/dist/timeline/capture.d.ts +8 -0
- package/dist/timeline/index.d.ts +8 -0
- package/dist/timeline/store.d.ts +42 -0
- package/dist/toolbar/app-manager.d.ts +104 -0
- package/dist/toolbar/components/app-button.d.ts +18 -0
- package/dist/toolbar/components/app-canvas.d.ts +12 -0
- package/dist/toolbar/components/app-tooltip-overlay.d.ts +12 -0
- package/dist/toolbar/components/first-visit-hint.d.ts +15 -0
- package/dist/toolbar/components/index.d.ts +4 -0
- package/dist/toolbar/components/pinned-tooltip-card.d.ts +22 -0
- package/dist/toolbar/components/toolbar-bar.d.ts +9 -0
- package/dist/toolbar/components/toolbar-container.d.ts +49 -0
- package/dist/toolbar/components/vite-overlay-button.d.ts +14 -0
- package/dist/toolbar/context/index.d.ts +2 -0
- package/dist/toolbar/context/toolbar-context.d.ts +107 -0
- package/dist/toolbar/global-api.d.ts +24 -0
- package/dist/toolbar/helpers.d.ts +8 -0
- package/dist/toolbar/hooks/index.d.ts +10 -0
- package/dist/toolbar/hooks/use-apps.d.ts +15 -0
- package/dist/toolbar/hooks/use-frame-state.d.ts +110 -0
- package/dist/toolbar/hooks/use-panel-visible.d.ts +23 -0
- package/dist/toolbar/hooks/use-position.d.ts +24 -0
- package/dist/toolbar/hooks/use-theme.d.ts +15 -0
- package/dist/toolbar/hooks/use-toolbar.d.ts +16 -0
- package/dist/toolbar/index.d.ts +50 -0
- package/dist/toolbar/index.js +21 -0
- package/dist/toolbar/settings.d.ts +17 -0
- package/dist/toolbar/stylesheet.d.ts +3 -0
- package/dist/toolbar/utils/index.d.ts +12 -0
- package/dist/types/annotations.d.ts +156 -0
- package/dist/types/app.d.ts +175 -0
- package/dist/types/global-api.d.ts +91 -0
- package/dist/types/hooks.d.ts +86 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/messaging.d.ts +43 -0
- package/dist/types/rpc.d.ts +137 -0
- package/dist/types/timeline.d.ts +62 -0
- package/dist/types/toolbar.d.ts +56 -0
- package/dist/ui/components/alert.d.ts +19 -0
- package/dist/ui/components/badge.d.ts +9 -0
- package/dist/ui/components/button.d.ts +11 -0
- package/dist/ui/components/card.d.ts +16 -0
- package/dist/ui/components/icon.d.ts +19 -0
- package/dist/ui/components/input.d.ts +7 -0
- package/dist/ui/components/label.d.ts +7 -0
- package/dist/ui/components/popover.d.ts +27 -0
- package/dist/ui/components/progress.d.ts +7 -0
- package/dist/ui/components/select.d.ts +54 -0
- package/dist/ui/components/separator.d.ts +8 -0
- package/dist/ui/components/skeleton.d.ts +6 -0
- package/dist/ui/components/switch.d.ts +11 -0
- package/dist/ui/components/tabs.d.ts +28 -0
- package/dist/ui/components/textarea.d.ts +7 -0
- package/dist/ui/components/tooltip.d.ts +19 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +1 -0
- package/dist/vite/inject-source.d.ts +24 -0
- package/dist/vite/matcher.d.ts +6 -0
- package/dist/vite-plugin.d.ts +149 -0
- package/dist/vite-plugin.js +5 -0
- package/package.json +144 -7
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { ComponentType } from "preact";
|
|
2
|
+
import type { NotificationLevel } from "./toolbar.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Server helpers available to apps
|
|
5
|
+
*/
|
|
6
|
+
export interface ServerHelpers {
|
|
7
|
+
/**
|
|
8
|
+
* RPC client for calling server functions
|
|
9
|
+
*/
|
|
10
|
+
rpc: {
|
|
11
|
+
[K in keyof ServerFunctions]: ServerFunctions[K];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Props passed to app tooltip (hover mini-canvas) components.
|
|
16
|
+
* Keep compact — tooltip components should be lightweight.
|
|
17
|
+
*/
|
|
18
|
+
export interface AppTooltipProps {
|
|
19
|
+
/**
|
|
20
|
+
* Server helpers (RPC, etc.)
|
|
21
|
+
*/
|
|
22
|
+
helpers: ServerHelpers;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Event target for app communication
|
|
26
|
+
*/
|
|
27
|
+
export interface ToolbarAppEventTarget extends EventTarget {
|
|
28
|
+
/**
|
|
29
|
+
* Dispatch a custom event
|
|
30
|
+
*/
|
|
31
|
+
dispatchEvent: (event: Event) => boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* App view configuration
|
|
35
|
+
*/
|
|
36
|
+
export type AppView = {
|
|
37
|
+
/**
|
|
38
|
+
* Render app inline in shadow DOM (default)
|
|
39
|
+
*/
|
|
40
|
+
type: "inline";
|
|
41
|
+
} | {
|
|
42
|
+
/**
|
|
43
|
+
* URL to load in iframe
|
|
44
|
+
*/
|
|
45
|
+
src: string;
|
|
46
|
+
/**
|
|
47
|
+
* Render app in iframe for isolation
|
|
48
|
+
*/
|
|
49
|
+
type: "iframe";
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Props passed to Preact component apps
|
|
53
|
+
*/
|
|
54
|
+
export interface AppComponentProps {
|
|
55
|
+
/**
|
|
56
|
+
* Event target for app communication
|
|
57
|
+
*/
|
|
58
|
+
eventTarget: ToolbarAppEventTarget;
|
|
59
|
+
/**
|
|
60
|
+
* Server helpers (RPC, etc.)
|
|
61
|
+
*/
|
|
62
|
+
helpers: ServerHelpers;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Dev toolbar app definition
|
|
66
|
+
*/
|
|
67
|
+
export interface DevToolbarApp {
|
|
68
|
+
/**
|
|
69
|
+
* Called before app is toggled off
|
|
70
|
+
* Return false to prevent closing
|
|
71
|
+
* @param canvas Shadow root of the app
|
|
72
|
+
* @returns Whether to allow closing
|
|
73
|
+
*/
|
|
74
|
+
beforeTogglingOff?: (canvas: ShadowRoot) => boolean | Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Preact component for rendering (alternative to init)
|
|
77
|
+
* If provided, this will be used instead of init
|
|
78
|
+
*/
|
|
79
|
+
component?: ComponentType<AppComponentProps>;
|
|
80
|
+
/**
|
|
81
|
+
* When true, this app is automatically activated when the toolbar opens for
|
|
82
|
+
* the first time (or when no other app has been activated yet).
|
|
83
|
+
* Only the first registered app with defaultOpen: true is used.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
defaultOpen?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Called when the app is unregistered / removed from the toolbar.
|
|
89
|
+
* Use this for final cleanup (event listeners, timers, subscriptions).
|
|
90
|
+
* @param canvas Shadow root of the app
|
|
91
|
+
*/
|
|
92
|
+
destroy?: (canvas: ShadowRoot) => Promise<void> | void;
|
|
93
|
+
/**
|
|
94
|
+
* Icon HTML string (SVG)
|
|
95
|
+
*/
|
|
96
|
+
icon: string;
|
|
97
|
+
/**
|
|
98
|
+
* Unique identifier for the app
|
|
99
|
+
*/
|
|
100
|
+
id: string;
|
|
101
|
+
/**
|
|
102
|
+
* Initialize the app when opened (vanilla JS/CSS/HTML)
|
|
103
|
+
* @param canvas Shadow root to render into
|
|
104
|
+
* @param eventTarget Event target for app communication
|
|
105
|
+
* @param helpers Server helpers (RPC, etc.)
|
|
106
|
+
*/
|
|
107
|
+
init?: (canvas: ShadowRoot, eventTarget: ToolbarAppEventTarget, helpers: ServerHelpers) => void | Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Display name of the app
|
|
110
|
+
*/
|
|
111
|
+
name: string;
|
|
112
|
+
/**
|
|
113
|
+
* Action button callback — called when the button is activated (active: false → true).
|
|
114
|
+
* When present, clicking the toolbar button will NOT open a panel.
|
|
115
|
+
* Instead the button toggles its active state and calls onClick (activate)
|
|
116
|
+
* or onDeactivate (deactivate).
|
|
117
|
+
*/
|
|
118
|
+
onClick?: () => Promise<void> | void;
|
|
119
|
+
/**
|
|
120
|
+
* Called when the action button is deactivated (active: true → false).
|
|
121
|
+
* Only meaningful when onClick is also provided.
|
|
122
|
+
*/
|
|
123
|
+
onDeactivate?: () => Promise<void> | void;
|
|
124
|
+
/**
|
|
125
|
+
* Optional hover tooltip component — renders a compact live preview when the
|
|
126
|
+
* user hovers over this app's button in the toolbar pill.
|
|
127
|
+
* The component should be small (≤280px wide) and self-contained.
|
|
128
|
+
* If omitted, hovering shows the native title tooltip only.
|
|
129
|
+
*/
|
|
130
|
+
tooltip?: ComponentType<AppTooltipProps>;
|
|
131
|
+
/**
|
|
132
|
+
* App rendering mode
|
|
133
|
+
*/
|
|
134
|
+
view?: AppView;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Internal app state (extends DevToolbarApp)
|
|
138
|
+
*/
|
|
139
|
+
export interface DevToolbarAppState extends DevToolbarApp {
|
|
140
|
+
/**
|
|
141
|
+
* Whether the app is currently active/open
|
|
142
|
+
*/
|
|
143
|
+
active: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Whether this is a built-in app
|
|
146
|
+
*/
|
|
147
|
+
builtIn: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Event target for this app
|
|
150
|
+
*/
|
|
151
|
+
eventTarget: ToolbarAppEventTarget;
|
|
152
|
+
/**
|
|
153
|
+
* Notification state
|
|
154
|
+
*/
|
|
155
|
+
notification: {
|
|
156
|
+
/**
|
|
157
|
+
* Notification level
|
|
158
|
+
*/
|
|
159
|
+
level?: NotificationLevel;
|
|
160
|
+
/**
|
|
161
|
+
* Whether notification is active
|
|
162
|
+
*/
|
|
163
|
+
state: boolean;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* App initialization status
|
|
167
|
+
*/
|
|
168
|
+
status: "ready" | "loading" | "pending" | "error";
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Placeholder for ServerFunctions (defined in rpc.ts)
|
|
172
|
+
*/
|
|
173
|
+
export interface ServerFunctions {
|
|
174
|
+
[key: string]: (...args: any[]) => Promise<any>;
|
|
175
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { DevToolbarApp } from "./app.d.ts";
|
|
2
|
+
import type { DevToolbarHook } from "./hooks.d.ts";
|
|
3
|
+
import type { ServerFunctions } from "./rpc.d.ts";
|
|
4
|
+
import type { ToolbarSettings } from "./toolbar.d.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Global DevTools API interface.
|
|
7
|
+
* Exposed as window.__VISULIMA_DEVTOOLS__
|
|
8
|
+
*/
|
|
9
|
+
interface VisulimaDevTools {
|
|
10
|
+
/**
|
|
11
|
+
* Clears notification for an app.
|
|
12
|
+
*/
|
|
13
|
+
clearNotification: (appId: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Closes the currently active app.
|
|
16
|
+
*/
|
|
17
|
+
closeApp: () => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the currently active app ID.
|
|
20
|
+
*/
|
|
21
|
+
getActiveApp: () => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Gets all registered apps.
|
|
24
|
+
*/
|
|
25
|
+
getApps: () => DevToolbarApp[];
|
|
26
|
+
/**
|
|
27
|
+
* Gets current toolbar settings.
|
|
28
|
+
*/
|
|
29
|
+
getSettings: () => ToolbarSettings;
|
|
30
|
+
/**
|
|
31
|
+
* Hides the toolbar.
|
|
32
|
+
*/
|
|
33
|
+
hide: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Hook instance for event subscriptions.
|
|
36
|
+
*/
|
|
37
|
+
hook: DevToolbarHook;
|
|
38
|
+
/**
|
|
39
|
+
* Shows a notification for an app.
|
|
40
|
+
*/
|
|
41
|
+
notify: (appId: string, level: "info" | "warning" | "error") => void;
|
|
42
|
+
/**
|
|
43
|
+
* Opens an app by ID.
|
|
44
|
+
*/
|
|
45
|
+
openApp: (appId: string) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Registers a custom app.
|
|
48
|
+
*/
|
|
49
|
+
registerApp: (app: DevToolbarApp) => void;
|
|
50
|
+
/**
|
|
51
|
+
* RPC client for calling server functions.
|
|
52
|
+
*/
|
|
53
|
+
rpc: ServerFunctions;
|
|
54
|
+
/**
|
|
55
|
+
* Directly sets the active state of an action button without invoking callbacks.
|
|
56
|
+
* Useful for deactivating a button from async work running outside the toolbar.
|
|
57
|
+
*/
|
|
58
|
+
setAppActive: (appId: string, active: boolean) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Shows the toolbar.
|
|
61
|
+
*/
|
|
62
|
+
show: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Toggles toolbar visibility.
|
|
65
|
+
*/
|
|
66
|
+
toggle: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Unregisters an app by ID.
|
|
69
|
+
*/
|
|
70
|
+
unregisterApp: (appId: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Updates toolbar settings.
|
|
73
|
+
*/
|
|
74
|
+
updateSettings: (settings: Partial<ToolbarSettings>) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Package version.
|
|
77
|
+
*/
|
|
78
|
+
version: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Global API declaration
|
|
82
|
+
*/
|
|
83
|
+
declare global {
|
|
84
|
+
interface Window {
|
|
85
|
+
/**
|
|
86
|
+
* Visulima DevTools global API.
|
|
87
|
+
*/
|
|
88
|
+
__VISULIMA_DEVTOOLS__?: VisulimaDevTools;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export type { VisulimaDevTools };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { DevToolbarApp } from "./app.d.ts";
|
|
2
|
+
import type { TimelineEvent } from "./timeline.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Hook event definitions
|
|
5
|
+
*/
|
|
6
|
+
interface HookEvents {
|
|
7
|
+
[key: string]: (...args: any[]) => void;
|
|
8
|
+
/**
|
|
9
|
+
* App error occurred.
|
|
10
|
+
* @param error Error object.
|
|
11
|
+
* @param appId Optional app ID where error occurred.
|
|
12
|
+
*/
|
|
13
|
+
"app:error": (error: Error, appId?: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* DevTools closed.
|
|
16
|
+
*/
|
|
17
|
+
"devtools:close": () => void;
|
|
18
|
+
/**
|
|
19
|
+
* DevTools initialized.
|
|
20
|
+
*/
|
|
21
|
+
"devtools:init": () => void;
|
|
22
|
+
/**
|
|
23
|
+
* DevTools opened.
|
|
24
|
+
* @param appId ID of the opened app.
|
|
25
|
+
*/
|
|
26
|
+
"devtools:open": (appId: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Timeline event added.
|
|
29
|
+
* @param event Timeline event.
|
|
30
|
+
*/
|
|
31
|
+
"timeline:event": (event: TimelineEvent) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Dev toolbar hook interface.
|
|
35
|
+
* Exposed as window.__DEV_TOOLBAR_HOOK__
|
|
36
|
+
*/
|
|
37
|
+
interface DevToolbarHook {
|
|
38
|
+
/**
|
|
39
|
+
* Adds a timeline event.
|
|
40
|
+
* @param groupId Timeline group ID.
|
|
41
|
+
* @param event Timeline event.
|
|
42
|
+
*/
|
|
43
|
+
addTimelineEvent: (groupId: string, event: TimelineEvent) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Emits an event.
|
|
46
|
+
* @param event Event name.
|
|
47
|
+
* @param args Event arguments.
|
|
48
|
+
*/
|
|
49
|
+
emit: <T extends keyof HookEvents>(event: T, ...args: Parameters<HookEvents[T]>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Unsubscribes from an event.
|
|
52
|
+
* @param event Event name.
|
|
53
|
+
* @param handler Optional specific handler to remove.
|
|
54
|
+
*/
|
|
55
|
+
off: <T extends keyof HookEvents>(event: T, handler?: HookEvents[T]) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Subscribes to an event.
|
|
58
|
+
* @param event Event name.
|
|
59
|
+
* @param handler Event handler.
|
|
60
|
+
* @returns Unsubscribe function.
|
|
61
|
+
*/
|
|
62
|
+
on: <T extends keyof HookEvents>(event: T, handler: HookEvents[T]) => () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Subscribes to an event once.
|
|
65
|
+
* @param event Event name.
|
|
66
|
+
* @param handler Event handler.
|
|
67
|
+
*/
|
|
68
|
+
once: <T extends keyof HookEvents>(event: T, handler: HookEvents[T]) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Registers a custom app.
|
|
71
|
+
* @param app App definition.
|
|
72
|
+
*/
|
|
73
|
+
registerApp: (app: DevToolbarApp) => void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Global hook declaration
|
|
77
|
+
*/
|
|
78
|
+
declare global {
|
|
79
|
+
interface Window {
|
|
80
|
+
/**
|
|
81
|
+
* Dev toolbar hook for library integrations.
|
|
82
|
+
*/
|
|
83
|
+
__DEV_TOOLBAR_HOOK__?: DevToolbarHook;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export type { DevToolbarHook, HookEvents };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type exports
|
|
3
|
+
*/
|
|
4
|
+
export type { AccessibilityInfo, Annotation, AnnotationIntent, AnnotationSeverity, AnnotationStatus, BoundingBox, CreateAnnotationData, FrameworkContext, ThreadMessage, UpdateAnnotationData, } from "./annotations.d.ts";
|
|
5
|
+
export type { AppView, DevToolbarApp, DevToolbarAppState, ServerFunctions, ServerHelpers, ToolbarAppEventTarget } from "./app.d.ts";
|
|
6
|
+
export type { VisulimaDevTools } from "./global-api.d.ts";
|
|
7
|
+
export type { DevToolbarHook, HookEvents } from "./hooks.d.ts";
|
|
8
|
+
export type { ChannelFactory, MessageChannel, MessageChannelContext } from "./messaging.d.ts";
|
|
9
|
+
export type { ClientRPCContext, ClientFunctions as RPCClientFunctions, ServerFunctions as RPCServerFunctions, ServerRPCContext } from "./rpc.d.ts";
|
|
10
|
+
export type { TimelineEvent, TimelineEventLevel, TimelineGroup } from "./timeline.d.ts";
|
|
11
|
+
export { DEFAULT_TIMELINE_GROUPS } from "./timeline.d.ts";
|
|
12
|
+
export type { FrameState, NotificationLevel, PositionAnchor, ToolbarPlacement, ToolbarSettings } from "./toolbar.d.ts";
|
|
13
|
+
export { DEFAULT_TOOLBAR_SETTINGS } from "./toolbar.d.ts";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message channel interface for bidirectional communication
|
|
3
|
+
*/
|
|
4
|
+
export interface MessageChannel<TEvents extends Record<string, (...args: any[]) => void>> {
|
|
5
|
+
/**
|
|
6
|
+
* Unsubscribe from an event
|
|
7
|
+
* @param event Event name
|
|
8
|
+
* @param handler Optional specific handler to remove
|
|
9
|
+
*/
|
|
10
|
+
off: <K extends keyof TEvents>(event: K, handler?: TEvents[K]) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to an event
|
|
13
|
+
* @param event Event name
|
|
14
|
+
* @param handler Event handler
|
|
15
|
+
* @returns Unsubscribe function
|
|
16
|
+
*/
|
|
17
|
+
on: <K extends keyof TEvents>(event: K, handler: TEvents[K]) => () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Subscribe to an event once
|
|
20
|
+
* @param event Event name
|
|
21
|
+
* @param handler Event handler
|
|
22
|
+
*/
|
|
23
|
+
once: <K extends keyof TEvents>(event: K, handler: TEvents[K]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Send a message/event
|
|
26
|
+
* @param event Event name
|
|
27
|
+
* @param data Event data
|
|
28
|
+
*/
|
|
29
|
+
send: <K extends keyof TEvents>(event: K, ...args: Parameters<TEvents[K]>) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Channel factory function
|
|
33
|
+
*/
|
|
34
|
+
export type ChannelFactory<TEvents extends Record<string, (...args: any[]) => void>> = () => MessageChannel<TEvents>;
|
|
35
|
+
/**
|
|
36
|
+
* Factory result providing a method to instantiate named message channels.
|
|
37
|
+
*/
|
|
38
|
+
export interface MessageChannelContext<TEvents extends Record<string, (...args: any[]) => void>> {
|
|
39
|
+
/**
|
|
40
|
+
* Creates and returns a new channel instance.
|
|
41
|
+
*/
|
|
42
|
+
createChannel: () => MessageChannel<TEvents>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
import type { StaticAsset } from "../rpc/functions/assets.d.ts";
|
|
3
|
+
import type { SerializableModuleNode } from "../rpc/functions/module-graph.d.ts";
|
|
4
|
+
import type { TailwindConfigResult } from "../rpc/functions/tailwind-config.d.ts";
|
|
5
|
+
import type { Annotation, CreateAnnotationData, UpdateAnnotationData } from "./annotations.d.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Server-side RPC functions
|
|
8
|
+
* These can be called from the client
|
|
9
|
+
*/
|
|
10
|
+
export interface ServerFunctions {
|
|
11
|
+
/**
|
|
12
|
+
* Extension point for custom server functions
|
|
13
|
+
*/
|
|
14
|
+
[key: string]: (...args: any[]) => Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new annotation
|
|
17
|
+
* @param data Annotation data (id, timestamps, status are generated server-side)
|
|
18
|
+
*/
|
|
19
|
+
createAnnotation: (data: CreateAnnotationData) => Promise<Annotation>;
|
|
20
|
+
/**
|
|
21
|
+
* Delete an annotation and its screenshot
|
|
22
|
+
* @param id Annotation ID
|
|
23
|
+
*/
|
|
24
|
+
deleteAnnotation: (id: string) => Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Get all annotations
|
|
27
|
+
*/
|
|
28
|
+
getAnnotations: () => Promise<Annotation[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get module dependency graph
|
|
31
|
+
*/
|
|
32
|
+
getModuleGraph: () => Promise<SerializableModuleNode[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get a screenshot as a base64 data URL
|
|
35
|
+
* @param annotationId Annotation ID
|
|
36
|
+
*/
|
|
37
|
+
getScreenshot: (annotationId: string) => Promise<string | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Get all static assets from the public directory
|
|
40
|
+
*/
|
|
41
|
+
getStaticAssets: () => Promise<StaticAsset[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Get full Tailwind CSS theme (default + user overrides)
|
|
44
|
+
*/
|
|
45
|
+
getTailwindConfig: () => Promise<TailwindConfigResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Get Vite configuration
|
|
48
|
+
*/
|
|
49
|
+
getViteConfig: () => Promise<Record<string, any>>;
|
|
50
|
+
/**
|
|
51
|
+
* Open file in editor
|
|
52
|
+
* @param file File path
|
|
53
|
+
* @param line Line number (1-based)
|
|
54
|
+
* @param column Column number (1-based)
|
|
55
|
+
* @param editor Editor override (e.g. "code", "webstorm") — empty string means auto-detect
|
|
56
|
+
*/
|
|
57
|
+
openInEditor: (file: string, line?: number, column?: number, editor?: string) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Read file contents
|
|
60
|
+
* @param path File path
|
|
61
|
+
*/
|
|
62
|
+
readFile: (path: string) => Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Save a screenshot for an annotation
|
|
65
|
+
* @param annotationId Annotation ID
|
|
66
|
+
* @param dataUrl Base64 data URL (PNG, JPEG, WebP, or SVG)
|
|
67
|
+
* @returns Relative path within .devtoolbar/
|
|
68
|
+
*/
|
|
69
|
+
saveScreenshot: (annotationId: string, dataUrl: string) => Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Update an existing annotation
|
|
72
|
+
* @param id Annotation ID
|
|
73
|
+
* @param data Fields to update
|
|
74
|
+
*/
|
|
75
|
+
updateAnnotation: (id: string, data: UpdateAnnotationData) => Promise<Annotation | null>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Client-side RPC functions
|
|
79
|
+
* These can be called from the server
|
|
80
|
+
*/
|
|
81
|
+
export interface ClientFunctions {
|
|
82
|
+
[key: string]: (...args: any[]) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Notify client of config change
|
|
85
|
+
* @param config New Vite config
|
|
86
|
+
*/
|
|
87
|
+
onConfigChange: (config: Record<string, unknown>) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Notify client of HMR update
|
|
90
|
+
* @param payload HMR payload
|
|
91
|
+
*/
|
|
92
|
+
onHMRUpdate: (payload: unknown) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Notify client of module update
|
|
95
|
+
* @param module Updated module node
|
|
96
|
+
*/
|
|
97
|
+
onModuleUpdate: (module: SerializableModuleNode) => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* RPC context for server-side
|
|
101
|
+
*/
|
|
102
|
+
export interface ServerRPCContext {
|
|
103
|
+
/**
|
|
104
|
+
* Call a client function
|
|
105
|
+
* @param name Function name
|
|
106
|
+
* @param args Function arguments
|
|
107
|
+
*/
|
|
108
|
+
callClient: <K extends keyof ClientFunctions>(name: K, ...args: Parameters<ClientFunctions[K]>) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Register a server function
|
|
111
|
+
* @param name Function name
|
|
112
|
+
* @param fn Function implementation
|
|
113
|
+
*/
|
|
114
|
+
registerFunction: <K extends keyof ServerFunctions>(name: K, function_: ServerFunctions[K]) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Vite dev server instance
|
|
117
|
+
*/
|
|
118
|
+
server: ViteDevServer;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* RPC context for client-side
|
|
122
|
+
*/
|
|
123
|
+
export interface ClientRPCContext {
|
|
124
|
+
/**
|
|
125
|
+
* Call a server function
|
|
126
|
+
* @param name Function name
|
|
127
|
+
* @param args Function arguments
|
|
128
|
+
*/
|
|
129
|
+
callServer: <K extends keyof ServerFunctions>(name: K, ...args: Parameters<ServerFunctions[K]>) => Promise<ReturnType<ServerFunctions[K]>>;
|
|
130
|
+
/**
|
|
131
|
+
* Register a client function
|
|
132
|
+
* @param name Function name
|
|
133
|
+
* @param function_ Function implementation
|
|
134
|
+
*/
|
|
135
|
+
registerFunction: <K extends keyof ClientFunctions>(name: K, function_: ClientFunctions[K]) => void;
|
|
136
|
+
}
|
|
137
|
+
export { type StaticAsset } from "../rpc/functions/assets.d.ts";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels for timeline events.
|
|
3
|
+
*/
|
|
4
|
+
export type TimelineEventLevel = "info" | "warning" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* A single captured event displayed in the timeline panel.
|
|
7
|
+
*/
|
|
8
|
+
export interface TimelineEvent {
|
|
9
|
+
/**
|
|
10
|
+
* Optional event data
|
|
11
|
+
*/
|
|
12
|
+
data?: Record<string, any>;
|
|
13
|
+
/**
|
|
14
|
+
* Optional duration (milliseconds)
|
|
15
|
+
*/
|
|
16
|
+
duration?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Unique event ID
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
/**
|
|
22
|
+
* Event level
|
|
23
|
+
*/
|
|
24
|
+
level?: TimelineEventLevel;
|
|
25
|
+
/**
|
|
26
|
+
* Optional subtitle
|
|
27
|
+
*/
|
|
28
|
+
subtitle?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Timestamp (milliseconds since epoch)
|
|
31
|
+
*/
|
|
32
|
+
time: number;
|
|
33
|
+
/**
|
|
34
|
+
* Event title
|
|
35
|
+
*/
|
|
36
|
+
title: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A named group that holds related timeline events.
|
|
40
|
+
*/
|
|
41
|
+
export interface TimelineGroup {
|
|
42
|
+
/**
|
|
43
|
+
* Group color (hex or CSS color)
|
|
44
|
+
*/
|
|
45
|
+
color?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Events in this group
|
|
48
|
+
*/
|
|
49
|
+
events: TimelineEvent[];
|
|
50
|
+
/**
|
|
51
|
+
* Group ID
|
|
52
|
+
*/
|
|
53
|
+
id: string;
|
|
54
|
+
/**
|
|
55
|
+
* Group label
|
|
56
|
+
*/
|
|
57
|
+
label: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default timeline groups
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEFAULT_TIMELINE_GROUPS: ReadonlyArray<TimelineGroup>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar placement options (for backward compatibility)
|
|
3
|
+
*/
|
|
4
|
+
export type ToolbarPlacement = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
5
|
+
/**
|
|
6
|
+
* Notification levels
|
|
7
|
+
*/
|
|
8
|
+
export type NotificationLevel = "info" | "warning" | "error";
|
|
9
|
+
/**
|
|
10
|
+
* Position anchor (which edge the toolbar is attached to)
|
|
11
|
+
* Matches Vue DevTools positioning
|
|
12
|
+
*/
|
|
13
|
+
export type PositionAnchor = "top" | "bottom" | "left" | "right";
|
|
14
|
+
/**
|
|
15
|
+
* Frame state - matches Vue DevTools DevToolsFrameState
|
|
16
|
+
* @see https://github.com/vuejs/devtools/blob/main/packages/overlay/src/composables/state.ts
|
|
17
|
+
*/
|
|
18
|
+
export interface FrameState {
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal position as percentage (0-100)
|
|
21
|
+
*/
|
|
22
|
+
left: number;
|
|
23
|
+
/**
|
|
24
|
+
* Whether panel is open
|
|
25
|
+
*/
|
|
26
|
+
open: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Which edge the toolbar is anchored to
|
|
29
|
+
*/
|
|
30
|
+
position: PositionAnchor;
|
|
31
|
+
/**
|
|
32
|
+
* Vertical position as percentage (0-100)
|
|
33
|
+
*/
|
|
34
|
+
top: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Configuration options controlling the toolbar's initial appearance.
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolbarSettings {
|
|
40
|
+
/**
|
|
41
|
+
* Whether toolbar is visible by default
|
|
42
|
+
*/
|
|
43
|
+
defaultVisible: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Toolbar placement on screen
|
|
46
|
+
*/
|
|
47
|
+
placement: ToolbarPlacement;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to show notifications
|
|
50
|
+
*/
|
|
51
|
+
showNotifications: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Default toolbar settings
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEFAULT_TOOLBAR_SETTINGS: ToolbarSettings;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
2
|
+
type AlertVariant = "default" | "destructive" | "info" | "success" | "warning";
|
|
3
|
+
interface AlertProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: ComponentChildren;
|
|
5
|
+
class?: string;
|
|
6
|
+
variant?: AlertVariant;
|
|
7
|
+
}
|
|
8
|
+
interface AlertTitleProps extends JSX.HTMLAttributes<HTMLHeadingElement> {
|
|
9
|
+
children?: ComponentChildren;
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
interface AlertDescriptionProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
children?: ComponentChildren;
|
|
14
|
+
class?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Alert: ({ children, class: className, variant, ...rest }: AlertProps) => JSX.Element;
|
|
17
|
+
declare const AlertTitle: ({ children, class: className, ...rest }: AlertTitleProps) => JSX.Element;
|
|
18
|
+
declare const AlertDescription: ({ children, class: className, ...rest }: AlertDescriptionProps) => JSX.Element;
|
|
19
|
+
export { Alert, AlertDescription, AlertTitle };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
2
|
+
type BadgeVariant = "default" | "destructive" | "info" | "outline" | "secondary" | "success" | "warning";
|
|
3
|
+
interface BadgeProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: ComponentChildren;
|
|
5
|
+
class?: string;
|
|
6
|
+
variant?: BadgeVariant;
|
|
7
|
+
}
|
|
8
|
+
declare const Badge: ({ children, class: className, variant, ...rest }: BadgeProps) => JSX.Element;
|
|
9
|
+
export default Badge;
|