@vingy/vuebugger 0.3.3 → 0.4.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/README.md +36 -2
- package/dist/constants.d.ts +2 -0
- package/dist/debug.d.ts +8 -0
- package/dist/devtools.d.ts +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3140 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/registry.d.ts +6 -0
- package/dist/types.d.ts +16 -0
- package/package.json +11 -8
- package/dist/index.d.mts +0 -32
- package/dist/index.mjs +0 -3959
package/README.md
CHANGED
|
@@ -5,8 +5,10 @@ Vue devtools provide an easy way to inspect component state. But when having som
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Debug composables and reactive state easily
|
|
8
|
-
- Tree-shakable with zero runtime overhead
|
|
8
|
+
- Tree-shakable with zero runtime overhead in production
|
|
9
9
|
- Simple API: just call `debug(name, state)`
|
|
10
|
+
- Opt-in production mode via `__ENABLE_VUEBUGGER__`
|
|
11
|
+
- Conditionally register state with `debug(name, state, { enable })`
|
|
10
12
|
|
|
11
13
|
## Quick start
|
|
12
14
|
|
|
@@ -24,6 +26,8 @@ createApp(App).use(Vuebugger)
|
|
|
24
26
|
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
29
|
+
### Basic usage
|
|
30
|
+
|
|
27
31
|
`debug()` registers values from composables so they show up in Vue Devtools.
|
|
28
32
|
|
|
29
33
|
```ts
|
|
@@ -43,6 +47,36 @@ export const useFoo = (initial: number) => {
|
|
|
43
47
|
}
|
|
44
48
|
```
|
|
45
49
|
|
|
50
|
+
### Options
|
|
51
|
+
|
|
52
|
+
`debug()` accepts an optional third argument:
|
|
53
|
+
|
|
54
|
+
| Option | Type | Default | Description |
|
|
55
|
+
| -------- | --------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
56
|
+
| `enable` | `MaybeRefOrGetter<boolean>` | `undefined` | Only register state when truthy. When reactive, the entry is added and removed from devtools automatically as the value changes. |
|
|
57
|
+
|
|
46
58
|
See the demo app in [demo/](../../demo/).
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
## Production usage
|
|
61
|
+
|
|
62
|
+
By default, Vuebugger is only active when `import.meta.env.DEV` is `true`, so it is automatically disabled and tree-shaken away in production builds with zero runtime overhead.
|
|
63
|
+
|
|
64
|
+
If you need Vuebugger active in a production build (e.g. for staging environments or opt-in debugging), set `__ENABLE_VUEBUGGER__` in your `vite.config.ts`:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
export default defineConfig({
|
|
68
|
+
define: {
|
|
69
|
+
__ENABLE_VUEBUGGER__: true,
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Setting it to `false` explicitly disables Vuebugger even in development:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
define: {
|
|
78
|
+
__ENABLE_VUEBUGGER__: false,
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When `__ENABLE_VUEBUGGER__` is not defined at all, the original behaviour is preserved — active in dev, inactive in production.
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { VuebuggerEntry } from './types';
|
|
3
|
+
export declare const setUidGenerator: (fn: () => string) => void;
|
|
4
|
+
export type DebugOptions = {
|
|
5
|
+
enable?: MaybeRefOrGetter<boolean>;
|
|
6
|
+
};
|
|
7
|
+
export declare const moduleScopes: Map<string, import('vue').EffectScope>;
|
|
8
|
+
export declare const debug: <T extends Record<string, any>>(groupId: VuebuggerEntry["groupId"], state: T, options?: DebugOptions) => T;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { DevtoolsApi, DevtoolsApiHandler } from './types';
|
|
3
|
+
export declare const handleGetInspectorTree: DevtoolsApiHandler<'getInspectorTree'>;
|
|
4
|
+
export declare const handleGetInspectorState: (api: DevtoolsApi) => DevtoolsApiHandler<"getInspectorState">;
|
|
5
|
+
export declare const handleInspectComponent: DevtoolsApiHandler<'inspectComponent'>;
|
|
6
|
+
export declare const handleEditInspectorState: DevtoolsApiHandler<'editInspectorState'>;
|
|
7
|
+
export declare function setupComposableDevtools<T>(app: App<T>): void;
|
package/dist/index.d.ts
ADDED