@chuvenger/devdock 0.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.
@@ -0,0 +1,73 @@
1
+ type DockPosition = "bottom-left" | "bottom-right" | "top-left" | "top-right";
2
+ /** A navigable destination shown in the dock's "Routes" section. */
3
+ interface DevRoute {
4
+ /** Path to navigate to, e.g. "/admin/users". */
5
+ path: string;
6
+ /** Human label. Defaults to `path`. */
7
+ label?: string;
8
+ /** Optional group heading to organize the list. */
9
+ group?: string;
10
+ }
11
+ /** A custom action shown in the dock's "Commands" section. */
12
+ interface DevCommand {
13
+ /** Stable id (used as key). Defaults to `label`. */
14
+ id?: string;
15
+ /** Human label shown in the list. */
16
+ label: string;
17
+ /** Called when the command is selected. May be async. */
18
+ run: () => void | Promise<void>;
19
+ /** Optional group heading to organize the list. */
20
+ group?: string;
21
+ /** Keep the popup open after running (default: false — it closes). */
22
+ keepOpen?: boolean;
23
+ }
24
+ /** Framework-agnostic configuration for the dock. */
25
+ interface DevDockOptions {
26
+ /** Routes to list. */
27
+ routes?: DevRoute[];
28
+ /** Custom commands to list. */
29
+ commands?: DevCommand[];
30
+ /**
31
+ * Whether the dock renders at all. Accepts a boolean or a predicate
32
+ * (re-evaluated on every `update`). When omitted, defaults to
33
+ * `process.env.NODE_ENV !== "production"`.
34
+ *
35
+ * @example enabled: () => location.search.includes("debug")
36
+ */
37
+ enabled?: boolean | (() => boolean);
38
+ /**
39
+ * How to navigate when a route is selected.
40
+ * Defaults to `window.location.assign(path)`.
41
+ */
42
+ onNavigate?: (path: string) => void;
43
+ /** Corner to anchor the button. Default: "bottom-left". */
44
+ position?: DockPosition;
45
+ /** Text on the floating button. Default: "DEV". */
46
+ label?: string;
47
+ /** Heading shown at the top of the popup. Default: "Dev Menu". */
48
+ title?: string;
49
+ /**
50
+ * Optional keyboard shortcut to toggle the popup, e.g. "mod+." or
51
+ * "ctrl+k". "mod" maps to ⌘ on Mac and Ctrl elsewhere. Default: none.
52
+ */
53
+ hotkey?: string | null;
54
+ /** Base z-index for the floating UI. Default: 2147483000. */
55
+ zIndex?: number;
56
+ /** Where to mount the dock. Default: `document.body`. */
57
+ container?: HTMLElement;
58
+ /**
59
+ * Render inside a shadow root so the host page's CSS can't affect the dock
60
+ * (and vice versa). Default: `true` where supported. Set `false` to render
61
+ * in the light DOM (e.g. if you want to style it from the page).
62
+ */
63
+ shadow?: boolean;
64
+ }
65
+ /** A live dock instance returned by {@link createDevDock}. */
66
+ interface DevDockInstance {
67
+ /** Re-render with new options (merged over the current ones). */
68
+ update(options: DevDockOptions): void;
69
+ /** Remove the dock and all its listeners. */
70
+ destroy(): void;
71
+ }
72
+
73
+ export type { DevCommand as D, DevDockInstance as a, DevDockOptions as b, DevRoute as c, DockPosition as d };
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@chuvenger/devdock",
3
+ "version": "0.1.0",
4
+ "description": "A tiny dev-only floating button that opens a popup to jump between dev routes and run custom commands.",
5
+ "author": "Ruven Chu",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Chubacca/devdock.git"
9
+ },
10
+ "homepage": "https://github.com/Chubacca/devdock#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/Chubacca/devdock/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [
18
+ "dev",
19
+ "devtools",
20
+ "developer",
21
+ "debug",
22
+ "react",
23
+ "svelte",
24
+ "react-router",
25
+ "navigation",
26
+ "command-palette"
27
+ ],
28
+ "license": "MIT",
29
+ "type": "module",
30
+ "sideEffects": false,
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.cjs"
39
+ },
40
+ "./react": {
41
+ "types": "./dist/react.d.ts",
42
+ "import": "./dist/react.js",
43
+ "require": "./dist/react.cjs"
44
+ },
45
+ "./react-router": {
46
+ "types": "./dist/react-router.d.ts",
47
+ "import": "./dist/react-router.js",
48
+ "require": "./dist/react-router.cjs"
49
+ },
50
+ "./svelte": {
51
+ "types": "./dist/svelte.d.ts",
52
+ "import": "./dist/svelte.js",
53
+ "require": "./dist/svelte.cjs"
54
+ }
55
+ },
56
+ "main": "./dist/index.cjs",
57
+ "module": "./dist/index.js",
58
+ "types": "./dist/index.d.ts",
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "dev": "tsup --watch",
62
+ "typecheck": "tsc --noEmit",
63
+ "test": "vitest run",
64
+ "test:watch": "vitest",
65
+ "changeset": "changeset",
66
+ "version": "changeset version",
67
+ "release": "bash ./.github/publish-packages.sh",
68
+ "prepublishOnly": "bun run build"
69
+ },
70
+ "peerDependencies": {
71
+ "react": ">=17",
72
+ "react-dom": ">=17",
73
+ "react-router-dom": ">=6",
74
+ "svelte": ">=4"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "react": {
78
+ "optional": true
79
+ },
80
+ "react-dom": {
81
+ "optional": true
82
+ },
83
+ "react-router-dom": {
84
+ "optional": true
85
+ },
86
+ "svelte": {
87
+ "optional": true
88
+ }
89
+ },
90
+ "devDependencies": {
91
+ "@changesets/cli": "^3.0.2",
92
+ "@testing-library/jest-dom": "^6.4.8",
93
+ "@testing-library/react": "^16.0.0",
94
+ "@testing-library/user-event": "^14.5.2",
95
+ "@types/react": "^18.3.3",
96
+ "@types/react-dom": "^18.3.0",
97
+ "jsdom": "^24.1.1",
98
+ "react": "^18.3.1",
99
+ "react-dom": "^18.3.1",
100
+ "react-router-dom": "^6.26.0",
101
+ "tsup": "^8.2.4",
102
+ "typescript": "^5.5.4",
103
+ "vitest": "^2.0.5"
104
+ }
105
+ }