@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,15 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
interface TailwindConfigResult {
|
|
3
|
+
/** CSS files that \@import tailwindcss */
|
|
4
|
+
cssFiles: string[];
|
|
5
|
+
/** User-defined \@theme overrides/extensions */
|
|
6
|
+
customTheme: Record<string, string>;
|
|
7
|
+
/** Full default Tailwind theme tokens */
|
|
8
|
+
defaultTheme: Record<string, string>;
|
|
9
|
+
/** Detected Tailwind version */
|
|
10
|
+
version: "v3" | "v4" | "unknown";
|
|
11
|
+
}
|
|
12
|
+
declare const getTailwindConfig: (server: ViteDevServer) => Promise<TailwindConfigResult>;
|
|
13
|
+
export type { TailwindConfigResult };
|
|
14
|
+
export { getTailwindConfig };
|
|
15
|
+
export default getTailwindConfig;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
type PluginInfo = {
|
|
3
|
+
enforce?: "post" | "pre";
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
/** Alias entry with find always normalized to string (RegExp serialized as "/pattern/flags") */
|
|
7
|
+
type AliasEntry = {
|
|
8
|
+
find: string;
|
|
9
|
+
replacement: string;
|
|
10
|
+
};
|
|
11
|
+
type ViteConfigSnapshot = {
|
|
12
|
+
base: string;
|
|
13
|
+
build: {
|
|
14
|
+
assetsDir?: string;
|
|
15
|
+
assetsInlineLimit?: number;
|
|
16
|
+
chunkSizeWarningLimit?: number;
|
|
17
|
+
cssCodeSplit?: boolean;
|
|
18
|
+
emptyOutDir?: boolean | null;
|
|
19
|
+
minify?: "esbuild" | "oxc" | "terser" | boolean;
|
|
20
|
+
outDir?: string;
|
|
21
|
+
reportCompressedSize?: boolean;
|
|
22
|
+
sourcemap?: "hidden" | "inline" | boolean;
|
|
23
|
+
target?: false | string | string[];
|
|
24
|
+
};
|
|
25
|
+
cacheDir: string;
|
|
26
|
+
css: {
|
|
27
|
+
devSourcemap?: boolean;
|
|
28
|
+
preprocessors: string[];
|
|
29
|
+
};
|
|
30
|
+
define?: Record<string, unknown>;
|
|
31
|
+
env?: Record<string, string>;
|
|
32
|
+
envDir?: string;
|
|
33
|
+
envPrefix?: string | string[];
|
|
34
|
+
esbuild?: {
|
|
35
|
+
jsx?: string;
|
|
36
|
+
jsxFactory?: string;
|
|
37
|
+
jsxFragment?: string;
|
|
38
|
+
jsxImportSource?: string;
|
|
39
|
+
target?: string | string[];
|
|
40
|
+
};
|
|
41
|
+
mode: string;
|
|
42
|
+
optimizeDeps: {
|
|
43
|
+
exclude?: string[];
|
|
44
|
+
include?: string[];
|
|
45
|
+
};
|
|
46
|
+
plugins: PluginInfo[];
|
|
47
|
+
publicDir: string;
|
|
48
|
+
resolve: {
|
|
49
|
+
alias?: AliasEntry[] | Record<string, string>;
|
|
50
|
+
conditions?: string[];
|
|
51
|
+
dedupe?: string[];
|
|
52
|
+
extensions?: string[];
|
|
53
|
+
mainFields?: string[];
|
|
54
|
+
preserveSymlinks?: boolean;
|
|
55
|
+
};
|
|
56
|
+
root: string;
|
|
57
|
+
server: {
|
|
58
|
+
cors?: boolean;
|
|
59
|
+
hmrEnabled?: boolean;
|
|
60
|
+
hmrPort?: number;
|
|
61
|
+
host?: boolean | string;
|
|
62
|
+
https?: boolean;
|
|
63
|
+
middlewareMode?: boolean | string;
|
|
64
|
+
open?: boolean | string;
|
|
65
|
+
origin?: string;
|
|
66
|
+
port?: number;
|
|
67
|
+
proxy?: string[];
|
|
68
|
+
strictPort?: boolean;
|
|
69
|
+
};
|
|
70
|
+
ssr?: {
|
|
71
|
+
external?: string[];
|
|
72
|
+
noExternal?: boolean | string[];
|
|
73
|
+
target?: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Gets Vite configuration from the dev server.
|
|
78
|
+
* @param server Vite dev server instance.
|
|
79
|
+
* @returns Vite config snapshot with the most useful fields.
|
|
80
|
+
*/
|
|
81
|
+
declare const getViteConfig: (server: ViteDevServer) => Promise<ViteConfigSnapshot>;
|
|
82
|
+
export { getViteConfig };
|
|
83
|
+
export default getViteConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
import type { ServerFunctions, ServerRPCContext } from "../types/rpc.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Creates server-side RPC context.
|
|
5
|
+
* @param server Vite dev server instance.
|
|
6
|
+
* @param customFunctions Custom server functions to register.
|
|
7
|
+
* @param options Additional options (e.g. which editor to launch).
|
|
8
|
+
* @param options.editor Editor to use for "open in editor" functionality.
|
|
9
|
+
* @returns Server RPC context.
|
|
10
|
+
*/
|
|
11
|
+
declare const createServerRPCContext: (server: ViteDevServer, customFunctions?: Partial<ServerFunctions>, options?: {
|
|
12
|
+
editor?: string;
|
|
13
|
+
}) => ServerRPCContext;
|
|
14
|
+
export { createServerRPCContext };
|
|
15
|
+
export default createServerRPCContext;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Annotation } from "../types/annotations.d.ts";
|
|
2
|
+
/** Base directory for annotation storage (relative to project root) */
|
|
3
|
+
export declare const STORE_DIR = ".devtoolbar";
|
|
4
|
+
export declare const ANNOTATIONS_FILE = "annotations.json";
|
|
5
|
+
export declare const SCREENSHOTS_DIR = "screenshots";
|
|
6
|
+
/**
|
|
7
|
+
* Resolves absolute paths for the annotation store.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolvePaths: (root: string) => {
|
|
10
|
+
annotationsFile: string;
|
|
11
|
+
base: string;
|
|
12
|
+
screenshotsDir: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validates that a resolved file path stays inside the store base directory.
|
|
16
|
+
* Prevents directory traversal attacks.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isPathInsideBase: (filepath: string, baseDir: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Sanitizes an ID for use as a filename — strips path separators and
|
|
21
|
+
* non-alphanumeric characters (except hyphens) to prevent traversal.
|
|
22
|
+
*/
|
|
23
|
+
export declare const sanitizeId: (id: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Ensures the store directories exist.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ensureStoreDir: (root: string) => Promise<void>;
|
|
28
|
+
export declare const withLock: <T>(function_: () => Promise<T>) => Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Reads all annotations from disk.
|
|
31
|
+
*/
|
|
32
|
+
export declare const readAnnotations: (root: string) => Promise<Annotation[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Writes annotations to disk.
|
|
35
|
+
*/
|
|
36
|
+
export declare const writeAnnotations: (root: string, annotations: Annotation[]) => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Deletes a screenshot file from disk.
|
|
39
|
+
* Validates the path stays inside the store directory to prevent traversal.
|
|
40
|
+
*/
|
|
41
|
+
export declare const deleteScreenshotFile: (root: string, screenshotPath: string) => Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline event capture
|
|
3
|
+
* Intercepts HMR events, fetch requests, and JS errors and feeds them
|
|
4
|
+
* into the timeline store so the Timeline app can display them.
|
|
5
|
+
*/
|
|
6
|
+
declare const startTimelineCapture: () => void;
|
|
7
|
+
export { startTimelineCapture };
|
|
8
|
+
export default startTimelineCapture;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline system exports
|
|
3
|
+
*/
|
|
4
|
+
export type { TimelineEvent, TimelineEventLevel, TimelineGroup } from "../types/timeline.d.ts";
|
|
5
|
+
export { DEFAULT_TIMELINE_GROUPS } from "../types/timeline.d.ts";
|
|
6
|
+
export { startTimelineCapture } from "./capture.d.ts";
|
|
7
|
+
export type { TimelineStore } from "./store.d.ts";
|
|
8
|
+
export { getTimelineStore } from "./store.d.ts";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TimelineEvent, TimelineGroup } from "../types/timeline.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Timeline store for managing timeline events.
|
|
4
|
+
*/
|
|
5
|
+
declare class TimelineStore {
|
|
6
|
+
private groups;
|
|
7
|
+
private maxEvents;
|
|
8
|
+
constructor(maxEvents?: number);
|
|
9
|
+
/**
|
|
10
|
+
* Adds an event to a group.
|
|
11
|
+
*/
|
|
12
|
+
addEvent(groupId: string, event: TimelineEvent): void;
|
|
13
|
+
/**
|
|
14
|
+
* Gets all timeline groups.
|
|
15
|
+
*/
|
|
16
|
+
getGroups(): TimelineGroup[];
|
|
17
|
+
/**
|
|
18
|
+
* Gets events for a specific group.
|
|
19
|
+
*/
|
|
20
|
+
getGroupEvents(groupId: string): TimelineEvent[];
|
|
21
|
+
/**
|
|
22
|
+
* Gets all events across all groups.
|
|
23
|
+
*/
|
|
24
|
+
getAllEvents(): TimelineEvent[];
|
|
25
|
+
/**
|
|
26
|
+
* Clears events for a specific group.
|
|
27
|
+
*/
|
|
28
|
+
clearGroup(groupId: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Clears all events from all groups.
|
|
31
|
+
*/
|
|
32
|
+
clearAll(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Gets events within a time range.
|
|
35
|
+
*/
|
|
36
|
+
getEventsInRange(startTime: number, endTime: number): TimelineEvent[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets or creates the timeline store singleton instance.
|
|
40
|
+
*/
|
|
41
|
+
declare const getTimelineStore: () => TimelineStore;
|
|
42
|
+
export { getTimelineStore, TimelineStore };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { DevToolbarApp, DevToolbarAppState } from "../types/app.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Manages the lifecycle of all registered dev-toolbar apps.
|
|
4
|
+
*/
|
|
5
|
+
declare class AppManager {
|
|
6
|
+
private apps;
|
|
7
|
+
private activeAppId;
|
|
8
|
+
private initializedApps;
|
|
9
|
+
private appCanvases;
|
|
10
|
+
/**
|
|
11
|
+
* Registers an app with the toolbar.
|
|
12
|
+
* @param app App definition.
|
|
13
|
+
* @param builtIn Whether this is a built-in app.
|
|
14
|
+
*/
|
|
15
|
+
registerApp(app: DevToolbarApp, builtIn?: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Unregisters an app and calls its destroy hook if initialized.
|
|
18
|
+
* @param appId App ID to unregister.
|
|
19
|
+
*/
|
|
20
|
+
unregisterApp(appId: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the app state for a given ID.
|
|
23
|
+
* @param appId App ID to look up.
|
|
24
|
+
* @returns App state or undefined.
|
|
25
|
+
*/
|
|
26
|
+
getApp(appId: string): DevToolbarAppState | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Returns all registered app states.
|
|
29
|
+
*/
|
|
30
|
+
getAllApps(): DevToolbarAppState[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns the currently active app state, or undefined if none is active.
|
|
33
|
+
*/
|
|
34
|
+
getActiveApp(): DevToolbarAppState | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Toggles the active state of an app.
|
|
37
|
+
* @param appId App ID to toggle.
|
|
38
|
+
* @returns Whether the toggle was successful.
|
|
39
|
+
*/
|
|
40
|
+
toggleApp(appId: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Directly sets the active state of an action button without invoking callbacks.
|
|
43
|
+
* Use this to deactivate a button from outside the toolbar (e.g. after async work).
|
|
44
|
+
* @param appId The unique identifier of the app whose active state to change.
|
|
45
|
+
* @param active New active state.
|
|
46
|
+
*/
|
|
47
|
+
setAppActive(appId: string, active: boolean): void;
|
|
48
|
+
/**
|
|
49
|
+
* Returns whether an app has already had its init() called.
|
|
50
|
+
* @param appId App ID to check.
|
|
51
|
+
*/
|
|
52
|
+
isAppInitialized(appId: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Marks an app as having been initialized.
|
|
55
|
+
* @param appId App ID to mark.
|
|
56
|
+
*/
|
|
57
|
+
markAppInitialized(appId: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Opens an app and initializes it if necessary.
|
|
60
|
+
* @param appId App ID to open.
|
|
61
|
+
* @returns Whether the open was successful.
|
|
62
|
+
*/
|
|
63
|
+
openApp(appId: string): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Closes an active app.
|
|
66
|
+
* @param appId App ID to close.
|
|
67
|
+
* @returns Whether the close was successful.
|
|
68
|
+
*/
|
|
69
|
+
closeApp(appId: string): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Sets a notification for an app.
|
|
72
|
+
* @param appId The unique identifier of the app to notify.
|
|
73
|
+
* @param state Whether the notification is currently visible.
|
|
74
|
+
* @param level The severity level of the notification badge.
|
|
75
|
+
*/
|
|
76
|
+
setNotification(appId: string, state: boolean, level?: "info" | "warning" | "error"): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clears the notification for an app.
|
|
79
|
+
* @param appId The unique identifier of the app whose notification to clear.
|
|
80
|
+
*/
|
|
81
|
+
clearNotification(appId: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the canvas element and shadow root for an app.
|
|
84
|
+
* @param appId The unique identifier of the app whose canvas to retrieve.
|
|
85
|
+
* @returns Canvas element with shadow root or undefined.
|
|
86
|
+
*/
|
|
87
|
+
getAppCanvas(appId: string): {
|
|
88
|
+
element: HTMLElement;
|
|
89
|
+
shadowRoot: ShadowRoot;
|
|
90
|
+
} | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Stores the canvas element and shadow root for an app.
|
|
93
|
+
* @param appId The unique identifier of the app whose canvas to store.
|
|
94
|
+
* @param canvas The canvas object containing the host element and its shadow root.
|
|
95
|
+
* @param canvas.element The host HTMLElement that wraps the app's shadow DOM.
|
|
96
|
+
* @param canvas.shadowRoot The ShadowRoot attached to the canvas element.
|
|
97
|
+
*/
|
|
98
|
+
setAppCanvas(appId: string, canvas: {
|
|
99
|
+
element: HTMLElement;
|
|
100
|
+
shadowRoot: ShadowRoot;
|
|
101
|
+
}): void;
|
|
102
|
+
}
|
|
103
|
+
export { AppManager };
|
|
104
|
+
export default AppManager;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import type { DevToolbarAppState } from "../../types/index.d.ts";
|
|
3
|
+
interface AppButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* App state
|
|
6
|
+
*/
|
|
7
|
+
app: DevToolbarAppState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* App button component — shown in the toolbar pill.
|
|
11
|
+
* When an app declares a `tooltip` component, hovering the button shows a live
|
|
12
|
+
* mini-canvas via AppTooltipOverlay (rendered outside overflow:hidden pill).
|
|
13
|
+
* @param props Component props
|
|
14
|
+
* @param props.app App state
|
|
15
|
+
* @returns Rendered button component
|
|
16
|
+
*/
|
|
17
|
+
declare const AppButton: ({ app }: AppButtonProps) => ComponentChildren;
|
|
18
|
+
export default AppButton;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import type { DevToolbarAppState } from "../../types/index.d.ts";
|
|
3
|
+
interface DevPanelProps {
|
|
4
|
+
activeAppId: string | undefined;
|
|
5
|
+
apps: DevToolbarAppState[];
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onToggleApp: (appId: string) => Promise<void>;
|
|
8
|
+
panelVisible: boolean;
|
|
9
|
+
position: "bottom" | "left" | "right" | "top";
|
|
10
|
+
}
|
|
11
|
+
declare const DevPanel: ({ activeAppId, apps, onClose, onToggleApp, panelVisible, position }: DevPanelProps) => ComponentChildren;
|
|
12
|
+
export default DevPanel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
interface AppTooltipOverlayProps {
|
|
3
|
+
position: "bottom" | "left" | "right" | "top";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Floating mini-canvas that appears when hovering a toolbar app button that
|
|
7
|
+
* provides a `tooltip` component. Rendered as `position:fixed` so it escapes
|
|
8
|
+
* the pill's `overflow:hidden`. The leave-debounce (handled in ToolbarContainer)
|
|
9
|
+
* keeps it visible while the mouse moves from button to tooltip.
|
|
10
|
+
*/
|
|
11
|
+
declare const AppTooltipOverlay: ({ position }: AppTooltipOverlayProps) => ComponentChildren;
|
|
12
|
+
export default AppTooltipOverlay;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
interface FirstVisitHintProps {
|
|
3
|
+
onDismiss: () => void;
|
|
4
|
+
position: "bottom" | "left" | "right" | "top";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* First-visit hint overlay showing keyboard and interaction tips.
|
|
8
|
+
* Appears ~600 ms after mount to let the toolbar pill animate in first.
|
|
9
|
+
* @param props Component props
|
|
10
|
+
* @param props.onDismiss Called after the dismiss animation completes
|
|
11
|
+
* @param props.position Current toolbar position (controls hint placement)
|
|
12
|
+
* @returns Rendered hint component
|
|
13
|
+
*/
|
|
14
|
+
declare const FirstVisitHint: ({ onDismiss, position }: FirstVisitHintProps) => ComponentChildren;
|
|
15
|
+
export default FirstVisitHint;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import type { PinnedTooltip } from "../context/index.d.ts";
|
|
3
|
+
interface PinnedTooltipCardProps {
|
|
4
|
+
/** Called once when a drag ends so the parent can persist the new position. */
|
|
5
|
+
onMove: (id: string, x: number, y: number) => void;
|
|
6
|
+
onUnpin: (id: string) => void;
|
|
7
|
+
pinned: PinnedTooltip;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A pinned tooltip card — persists on screen until the user unpins it.
|
|
11
|
+
*
|
|
12
|
+
* Position is updated via direct DOM style mutations during drag so that
|
|
13
|
+
* Preact never re-renders the component on mousemove — drag is silky smooth
|
|
14
|
+
* regardless of how expensive the tooltip content component is.
|
|
15
|
+
* @param props Component props
|
|
16
|
+
* @param props.onMove Called with the pin ID and final (x, y) coordinates when a drag ends
|
|
17
|
+
* @param props.onUnpin Called with the pin ID when the user clicks the unpin button
|
|
18
|
+
* @param props.pinned Pinned tooltip descriptor — contains the app reference and initial position
|
|
19
|
+
* @returns Rendered draggable pinned card, or null if the app has no tooltip component
|
|
20
|
+
*/
|
|
21
|
+
declare const PinnedTooltipCard: ({ onMove, onUnpin, pinned }: PinnedTooltipCardProps) => ComponentChildren;
|
|
22
|
+
export default PinnedTooltipCard;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsxImportSource preact */
|
|
2
|
+
import type { ComponentChildren } from "preact";
|
|
3
|
+
/**
|
|
4
|
+
* Toolbar bar — row of app buttons inside the pill.
|
|
5
|
+
* Left/right placement rotates the whole pill 90deg via CSS,
|
|
6
|
+
* so this always stays flex-row internally.
|
|
7
|
+
*/
|
|
8
|
+
declare const ToolbarBar: () => ComponentChildren;
|
|
9
|
+
export default ToolbarBar;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import type { DevToolbarAppState } from "../../types/index.d.ts";
|
|
3
|
+
interface ToolbarContainerProps {
|
|
4
|
+
/**
|
|
5
|
+
* Active app ID
|
|
6
|
+
*/
|
|
7
|
+
activeAppId: string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Initial apps
|
|
10
|
+
*/
|
|
11
|
+
apps: DevToolbarAppState[];
|
|
12
|
+
/**
|
|
13
|
+
* Callback when notification should be cleared
|
|
14
|
+
*/
|
|
15
|
+
onClearNotification: (appId: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Callback when app should be registered
|
|
18
|
+
*/
|
|
19
|
+
onRegisterApp: (app: DevToolbarAppState) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when notification should be set
|
|
22
|
+
*/
|
|
23
|
+
onSetNotification: (appId: string, state: boolean, level?: "error" | "info" | "warning") => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback when app should be toggled
|
|
26
|
+
*/
|
|
27
|
+
onToggleApp: (appId: string) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Callback when app should be unregistered
|
|
30
|
+
*/
|
|
31
|
+
onUnregisterApp: (appId: string) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Root toolbar container component — orchestrates the toolbar pill, app panel,
|
|
35
|
+
* tooltip overlays, pinned cards, and first-visit hint.
|
|
36
|
+
* Manages active app state, hover tooltips, pinned tooltip persistence (localStorage),
|
|
37
|
+
* and delegates app lifecycle events to the parent via callbacks.
|
|
38
|
+
* @param props Component props
|
|
39
|
+
* @param props.activeAppId ID of the currently open app, or null if no app is open
|
|
40
|
+
* @param props.apps Initial array of registered app states
|
|
41
|
+
* @param props.onClearNotification Called when an app's notification badge should be cleared
|
|
42
|
+
* @param props.onRegisterApp Called when a new app is dynamically registered
|
|
43
|
+
* @param props.onSetNotification Called when an app requests a notification badge update
|
|
44
|
+
* @param props.onToggleApp Called when the user clicks an app button to open/close it
|
|
45
|
+
* @param props.onUnregisterApp Called when an app is dynamically unregistered
|
|
46
|
+
* @returns Rendered toolbar component tree
|
|
47
|
+
*/
|
|
48
|
+
declare const ToolbarContainer: ({ activeAppId, apps, onClearNotification, onRegisterApp, onSetNotification, onToggleApp, onUnregisterApp, }: ToolbarContainerProps) => ComponentChildren;
|
|
49
|
+
export default ToolbarContainer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
/**
|
|
3
|
+
* Shows a red error button in the toolbar when `@visulima/vite-overlay` errors exist.
|
|
4
|
+
* Clicking toggles the vite-overlay panel visibility.
|
|
5
|
+
*
|
|
6
|
+
* Only rendered when:
|
|
7
|
+
* - `@visulima/vite-overlay` is installed and active (window.ErrorOverlay is defined)
|
|
8
|
+
* - At least one error is present in the history
|
|
9
|
+
*
|
|
10
|
+
* Renders with its own left separator so it stays visually grouped on the
|
|
11
|
+
* right side of the toolbar, distinct from the regular app buttons.
|
|
12
|
+
*/
|
|
13
|
+
declare const ViteOverlayButton: () => ComponentChildren;
|
|
14
|
+
export default ViteOverlayButton;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** @jsxImportSource preact */
|
|
2
|
+
import { createContext } from "preact";
|
|
3
|
+
import type { DevToolbarAppState, ToolbarPlacement } from "../../types/index.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A tooltip that has been pinned by the user — stays visible until unpinned.
|
|
6
|
+
*/
|
|
7
|
+
export interface PinnedTooltip {
|
|
8
|
+
/** The app whose tooltip is shown */
|
|
9
|
+
app: DevToolbarAppState;
|
|
10
|
+
/** Unique instance identifier (appId + timestamp) */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Initial left position (viewport px) */
|
|
13
|
+
initialX: number;
|
|
14
|
+
/** Initial top position (viewport px) */
|
|
15
|
+
initialY: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Shared state and actions exposed by the ToolbarContext.
|
|
19
|
+
*/
|
|
20
|
+
export interface ToolbarContextState {
|
|
21
|
+
/**
|
|
22
|
+
* Currently active app ID
|
|
23
|
+
*/
|
|
24
|
+
activeAppId: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* All registered apps
|
|
27
|
+
*/
|
|
28
|
+
apps: DevToolbarAppState[];
|
|
29
|
+
/**
|
|
30
|
+
* Clears the notification badge for an app.
|
|
31
|
+
*/
|
|
32
|
+
clearNotification: (appId: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Currently hovered app (has a tooltip component)
|
|
35
|
+
*/
|
|
36
|
+
hoveredApp: DevToolbarAppState | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Viewport rect of the hovered app button (for tooltip positioning)
|
|
39
|
+
*/
|
|
40
|
+
hoveredAppRect: DOMRect | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Whether toolbar is being dragged
|
|
43
|
+
*/
|
|
44
|
+
isDragging: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether toolbar is visible
|
|
47
|
+
*/
|
|
48
|
+
isVisible: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Currently pinned tooltip cards
|
|
51
|
+
*/
|
|
52
|
+
pinnedTooltips: PinnedTooltip[];
|
|
53
|
+
/**
|
|
54
|
+
* Pin a tooltip at the given viewport position.
|
|
55
|
+
* Multiple pins from the same app are allowed (each gets a unique id).
|
|
56
|
+
*/
|
|
57
|
+
pinTooltip: (app: DevToolbarAppState, x: number, y: number) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Toolbar placement on screen
|
|
60
|
+
*/
|
|
61
|
+
placement: ToolbarPlacement;
|
|
62
|
+
/**
|
|
63
|
+
* Registers an app with the toolbar.
|
|
64
|
+
*/
|
|
65
|
+
registerApp: (app: DevToolbarAppState) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the dragging state.
|
|
68
|
+
*/
|
|
69
|
+
setDragging: (dragging: boolean) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Sets or clears the hovered app. Pass undefined to start the leave debounce.
|
|
72
|
+
*/
|
|
73
|
+
setHoveredApp: (app: DevToolbarAppState | undefined, rect?: DOMRect) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Sets a notification for an app.
|
|
76
|
+
*/
|
|
77
|
+
setNotification: (appId: string, state: boolean, level?: "info" | "warning" | "error") => void;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the toolbar placement.
|
|
80
|
+
*/
|
|
81
|
+
setPlacement: (placement: ToolbarPlacement) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Sets toolbar visibility.
|
|
84
|
+
*/
|
|
85
|
+
setVisible: (visible: boolean) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Toggles an app's active state.
|
|
88
|
+
*/
|
|
89
|
+
toggleApp: (appId: string) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Removes a pinned tooltip by its instance id.
|
|
92
|
+
*/
|
|
93
|
+
unpinTooltip: (id: string) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Unregisters an app.
|
|
96
|
+
*/
|
|
97
|
+
unregisterApp: (appId: string) => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Preact context object that exposes the toolbar's shared state to all child components.
|
|
101
|
+
*/
|
|
102
|
+
export declare const ToolbarContext: ReturnType<typeof createContext<ToolbarContextState | undefined>>;
|
|
103
|
+
/**
|
|
104
|
+
* Accesses the toolbar context, throwing if used outside a provider.
|
|
105
|
+
* @throws Error if used outside ToolbarContext provider.
|
|
106
|
+
*/
|
|
107
|
+
export declare const useToolbarContext: () => ToolbarContextState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { VisulimaDevTools } from "../types/global-api.d.ts";
|
|
2
|
+
import type { DevToolbarApp } from "../types/index.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the global DevTools API implementation.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createGlobalAPI: (appManager: {
|
|
7
|
+
clearNotification: (id: string) => void;
|
|
8
|
+
getActiveApp: () => DevToolbarApp | undefined;
|
|
9
|
+
getApps: () => DevToolbarApp[];
|
|
10
|
+
registerApp: (app: DevToolbarApp) => void;
|
|
11
|
+
setAppActive: (id: string, active: boolean) => void;
|
|
12
|
+
setNotification: (id: string, state: boolean, level?: "info" | "warning" | "error") => void;
|
|
13
|
+
toggleApp: (id: string) => Promise<boolean>;
|
|
14
|
+
unregisterApp: (id: string) => void;
|
|
15
|
+
}, toolbar: {
|
|
16
|
+
hide: () => void;
|
|
17
|
+
show: () => void;
|
|
18
|
+
toggle: () => void;
|
|
19
|
+
}) => VisulimaDevTools;
|
|
20
|
+
/**
|
|
21
|
+
* Mounts the global API on the window object so it can be accessed from outside the toolbar.
|
|
22
|
+
* @param api API instance to expose globally.
|
|
23
|
+
*/
|
|
24
|
+
export declare const setupGlobalAPI: (api: VisulimaDevTools) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ServerHelpers } from "../types/app.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Creates server helpers that proxy RPC calls for use within app init().
|
|
4
|
+
* @returns Server helpers instance.
|
|
5
|
+
*/
|
|
6
|
+
declare const createServerHelpers: () => ServerHelpers;
|
|
7
|
+
export { createServerHelpers };
|
|
8
|
+
export default createServerHelpers;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { useApps } from "./use-apps.d.ts";
|
|
2
|
+
export type { DevToolsFrameState, UseFrameStateReturn } from "./use-frame-state.d.ts";
|
|
3
|
+
export { useFrameState } from "./use-frame-state.d.ts";
|
|
4
|
+
export type { UsePanelVisibleReturn } from "./use-panel-visible.d.ts";
|
|
5
|
+
export { usePanelVisible } from "./use-panel-visible.d.ts";
|
|
6
|
+
export type { UsePositionReturn } from "./use-position.d.ts";
|
|
7
|
+
export { usePosition } from "./use-position.d.ts";
|
|
8
|
+
export type { Theme, UseThemeReturn } from "./use-theme.d.ts";
|
|
9
|
+
export { useTheme } from "./use-theme.d.ts";
|
|
10
|
+
export { useToolbar } from "./use-toolbar.d.ts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DevToolbarAppState } from "../../types/index.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Exposes app management methods from the toolbar context.
|
|
4
|
+
*/
|
|
5
|
+
declare const useApps: () => {
|
|
6
|
+
activeAppId: string | undefined;
|
|
7
|
+
apps: DevToolbarAppState[];
|
|
8
|
+
clearNotification: (appId: string) => void;
|
|
9
|
+
registerApp: (app: DevToolbarAppState) => void;
|
|
10
|
+
setNotification: (appId: string, state: boolean, level?: "info" | "warning" | "error") => void;
|
|
11
|
+
toggleApp: (appId: string) => Promise<void>;
|
|
12
|
+
unregisterApp: (appId: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export { useApps };
|
|
15
|
+
export default useApps;
|