@devlens/vue 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +143 -28
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # @devlens/vue
2
2
 
3
- DevLens Vue 3 integration -- automatic runtime error detection for Vue applications.
3
+ **Automatic runtime error detection for Vue 3 apps. One plugin. Zero config.**
4
+
5
+ Vue's `app.config.errorHandler` gives you a raw error and a component name. That's it. No path, no context, no suggestion. You're on your own.
6
+
7
+ DevLens catches Vue errors, Vue warnings, failed API calls, null property access, and missing render data -- then tells you exactly what went wrong, where, and how to fix it.
8
+
9
+ ## The Problem
10
+
11
+ Vue silently swallows many issues that cause blank UIs:
12
+
13
+ - `app.config.errorHandler` fires, but you forgot to set one -- error lost
14
+ - `app.config.warnHandler` fires in dev, but you never check the console
15
+ - A reactive ref is `null` because the API hasn't responded yet -- template renders blank
16
+ - Computed properties return `undefined` silently -- no error, no clue
17
+ - `fetch` fails with 500 -- the Promise resolves, you destructure `null`
18
+
19
+ **DevLens catches all of these the moment they happen, with full context.**
4
20
 
5
21
  ## Installation
6
22
 
@@ -8,69 +24,168 @@ DevLens Vue 3 integration -- automatic runtime error detection for Vue applicati
8
24
  npm install @devlens/core @devlens/vue
9
25
  ```
10
26
 
11
- **Peer dependencies:** Vue >= 3.3.0
27
+ **Requirements:** Vue >= 3.3.0
12
28
 
13
- ## Quick Start
29
+ ## Setup -- 3 Lines
14
30
 
15
31
  ```ts
16
32
  import { createApp } from 'vue';
17
33
  import { createDevLensPlugin } from '@devlens/vue';
18
34
 
19
35
  const app = createApp(App);
20
-
21
- app.use(createDevLensPlugin({
22
- enabled: true,
23
- minSeverity: 'warn',
24
- }));
25
-
36
+ app.use(createDevLensPlugin());
26
37
  app.mount('#app');
27
38
  ```
28
39
 
29
- The plugin automatically installs `app.config.errorHandler` and `app.config.warnHandler` to capture Vue errors and warnings.
40
+ That's it. DevLens auto-installs:
41
+ - **Error handler** -- captures all Vue component errors via `app.config.errorHandler`
42
+ - **Warn handler** -- captures Vue warnings via `app.config.warnHandler`
43
+ - **Network interceptor** -- detects failed fetch/XHR calls
44
+ - **Global catcher** -- captures uncaught errors and unhandled promise rejections
30
45
 
31
- ## Guarded Ref
46
+ ## Guarded Ref -- Detect Null Access on Reactive Data
32
47
 
33
- Reactive ref with null/undefined detection:
48
+ Replace `ref()` with `useGuardedRef()`. Same reactivity, but null/undefined property access is detected automatically:
34
49
 
35
50
  ```ts
36
51
  import { useGuardedRef } from '@devlens/vue';
37
52
 
53
+ // In setup() or <script setup>
38
54
  const user = useGuardedRef(initialUser, 'UserProfile');
39
55
 
40
- // Accessing null/undefined properties on user.value triggers detection
56
+ // In your template:
57
+ // <img :src="user.profile.avatar" />
58
+ //
59
+ // If user.profile.avatar is null, DevLens immediately logs:
60
+ //
61
+ // [NULL] DevLens [WARN] null-access: Property "avatar" is null
62
+ // at path "user.profile.avatar"
63
+ // |- Path: user.profile.avatar
64
+ // |- Value: null
65
+ // |- Source: UserProfile
66
+ // \- Suggestion: Check if "avatar" is loaded before accessing
41
67
  ```
42
68
 
43
- ## Watch Data
69
+ **How it works:** The ref value is wrapped in an ES6 Proxy. When the source ref changes, the proxy is recreated. The original data is untouched -- the proxy only observes.
70
+
71
+ ## Guarded Watch -- Monitor Data Dependencies
44
72
 
45
- Monitor data for null/undefined values:
73
+ Watch multiple values for null/undefined. Perfect for components that depend on async data:
46
74
 
47
75
  ```ts
48
76
  import { useGuardedWatch } from '@devlens/vue';
49
77
 
78
+ // In setup() or <script setup>
79
+ const user = ref(null);
80
+ const posts = ref(undefined);
81
+ const settings = ref({ theme: 'dark' });
82
+
50
83
  useGuardedWatch({ user, posts, settings }, 'Dashboard');
51
84
 
85
+ // DevLens logs:
86
+ //
87
+ // [RENDER] DevLens [WARN] render-data: "user" is null in Dashboard
88
+ // |- Path: Dashboard.user
89
+ // |- Value: null
90
+ // \- Suggestion: "user" is null -- check data loading in Dashboard
91
+ //
52
92
  // [RENDER] DevLens [WARN] render-data: "posts" is undefined in Dashboard
93
+ // |- Path: Dashboard.posts
94
+ // |- Value: undefined
95
+ // \- Suggestion: "posts" is undefined -- check data loading in Dashboard
96
+ ```
97
+
98
+ Runs `immediate: true` and `deep: true`, so it catches issues on mount and on every change.
99
+
100
+ ## Vue Error and Warning Capture
101
+
102
+ The plugin auto-installs `app.config.errorHandler` and `app.config.warnHandler`:
103
+
104
+ ```
105
+ [ERR] DevLens [ERROR] unhandled-error: Vue error in UserProfile: Cannot read property of null
106
+ |- Component: UserProfile
107
+ |- Lifecycle Hook: mounted
108
+ |- Source: Vue:UserProfile
109
+ \- Suggestion: Error in mounted of UserProfile -- check the component logic
110
+
111
+ [ERR] DevLens [WARN] unhandled-error: Vue warning in Dashboard: Invalid prop type
112
+ |- Component: Dashboard
113
+ |- Source: Vue:Dashboard
114
+ \- Suggestion: Check the Vue warning above -- it may indicate a potential issue
115
+ ```
116
+
117
+ Every captured error includes the **component name**, **lifecycle hook**, and a **suggestion**.
118
+
119
+ ## Configuration
120
+
121
+ ```ts
122
+ app.use(createDevLensPlugin({
123
+ enabled: true,
124
+ minSeverity: 'warn',
125
+ throttleMs: 1000,
126
+ maxIssues: 100,
127
+ modules: {
128
+ network: {
129
+ fetch: true,
130
+ xhr: true,
131
+ ignoreUrls: ['/health'],
132
+ },
133
+ catcher: {
134
+ windowErrors: true,
135
+ unhandledRejections: true,
136
+ },
137
+ },
138
+ ignore: {
139
+ messages: [/ResizeObserver/],
140
+ },
141
+ }));
53
142
  ```
54
143
 
55
144
  ## API Reference
56
145
 
146
+ ### Functions
147
+
57
148
  | Export | Description |
58
149
  |--------|-------------|
59
- | `createDevLensPlugin(options?)` | Vue 3 plugin with auto error/warn handlers |
60
- | `useDevLens()` | Inject the engine instance |
61
- | `useGuardedRef(initialValue, label?)` | Reactive ref with null/undefined detection |
62
- | `useGuardedWatch(data, label?)` | Watch data for null/undefined |
150
+ | `createDevLensPlugin(options?)` | Vue 3 plugin. Installs engine, error/warn handlers, network interceptor, global catcher. Returns plugin with `install()`, `uninstall()`, `getEngine()`. |
151
+ | `useDevLens()` | Composable that injects the `DevLensEngine` instance (or `null` if disabled). Use for custom reporting. |
152
+ | `useGuardedRef(initial, label?)` | Returns a reactive ref wrapped in a Proxy that detects null/undefined property access at any depth. |
153
+ | `useGuardedWatch(data, label?)` | Watches a `Record<string, unknown>` for null/undefined values. Runs immediately and deeply. |
154
+
155
+ ### Types
156
+
157
+ | Export | Description |
158
+ |--------|-------------|
159
+ | `DevLensPluginOptions` | Same as `DevLensConfig` from `@devlens/core` |
160
+ | `DevLensKey` | Vue injection key (Symbol) for the engine instance |
161
+
162
+ ## Works With
163
+
164
+ - **Vue 3.3+** -- Composition API and Options API
165
+ - **Nuxt 3** -- client-side only (DevLens is browser-side)
166
+ - **Vite, Vue CLI** -- any Vue 3 setup
167
+ - **@devlens/ui** -- add the [visual debug panel](https://www.npmjs.com/package/@devlens/ui) for a full browser overlay
168
+ - **Pinia, Vuex** -- state store data can be watched with `useGuardedWatch`
169
+
170
+ ## Why @devlens/vue
171
+
172
+ - **3-line setup** -- `app.use()` and done
173
+ - **Zero config** -- error/warn handlers, network, global catcher all auto-installed
174
+ - **~5KB** ESM bundle -- negligible impact
175
+ - **Production-safe** -- auto-disabled in production, zero overhead, tree-shakeable
176
+ - **Non-invasive** -- no patching Vue internals, standard plugin API
177
+ - **Composition API native** -- `useGuardedRef` and `useGuardedWatch` work in `setup()` and `<script setup>`
178
+ - **Full TypeScript** -- complete type declarations, strict mode compatible
179
+
180
+ ## Roadmap
63
181
 
64
- ## Details
182
+ | Version | Feature | Status |
183
+ |---------|---------|--------|
184
+ | v1.0 | Vue plugin with auto error/warn capture, guarded composables | Current |
185
+ | v2.0 | AI-powered analysis -- integrate Claude and Gemini models to analyze detected issues, explain root causes in the context of your Vue components, and suggest template/script fixes | Planned |
65
186
 
66
- - ~5KB ESM bundle
67
- - Auto error handler: `app.config.errorHandler`
68
- - Auto warn handler: `app.config.warnHandler`
69
- - Network interceptor and global catcher auto-installed
70
- - Dual ESM + CJS output
71
- - Full TypeScript declarations
72
- - Production-safe -- auto-disabled in production
187
+ The v2.0 AI integration will understand Vue-specific patterns (reactivity pitfalls, lifecycle timing, prop validation) and provide targeted fix suggestions that account for your component structure.
73
188
 
74
189
  ## License
75
190
 
76
- MIT -- [github.com/crashsense/devlens](https://github.com/crashsense/devlens)
191
+ MIT -- [GitHub](https://github.com/crashsense/devlens) -- [Changelog](https://github.com/crashsense/devlens/blob/main/CHANGELOG.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlens/vue",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "DevLens Vue integration - automatic error detection for Vue apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -54,7 +54,7 @@
54
54
  "vue": ">=3.3.0"
55
55
  },
56
56
  "dependencies": {
57
- "@devlens/core": "2.0.0"
57
+ "@devlens/core": "2.0.1"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^25.3.0",