@visulima/vite-overlay 2.0.0-alpha.9 → 2.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.
package/README.md CHANGED
@@ -93,14 +93,23 @@ export default defineConfig({
93
93
  // Array of console method names to forward (default: ["error"])
94
94
  forwardedConsoleMethods: ["error", "warn"],
95
95
 
96
- // Custom React plugin name for detection (optional)
96
+ // Custom plugin names for framework detection (all optional)
97
97
  reactPluginName: "@vitejs/plugin-react",
98
-
99
- // Custom Vue plugin name for detection (optional)
100
98
  vuePluginName: "@vitejs/plugin-vue",
99
+ sveltePluginName: "@sveltejs/vite-plugin-svelte",
100
+ preactPluginName: "@preact/preset-vite",
101
+ solidPluginName: "vite-plugin-solid",
102
+
103
+ // Explicit framework override; skips auto-detection (optional)
104
+ // "react" | "vue" | "svelte" | "preact" | "solid"
105
+ framework: "react",
106
+
107
+ // Capture process-wide unhandled rejections and show them in the overlay (default: true).
108
+ // Set to false to leave Node's default crash semantics untouched.
109
+ interceptUnhandledRejection: true,
101
110
 
102
111
  // Whether to show the balloon button in the overlay (default: true)
103
- showBallonButton: true,
112
+ showBalloonButton: true,
104
113
 
105
114
  // Overlay configuration (optional)
106
115
  overlay: {
@@ -138,19 +147,25 @@ export default defineConfig({
138
147
 
139
148
  #### Options
140
149
 
141
- | Option | Type | Default | Description |
142
- | ------------------------- | -------------------------- | ----------- | -------------------------------------------------------------------------------- |
143
- | `forwardConsole` | `boolean` | `true` | Enable/disable client-side runtime error logging and overlay display |
144
- | `forwardedConsoleMethods` | `string[]` | `["error"]` | Array of console method names to intercept and forward to overlay |
145
- | `reactPluginName` | `string` | `undefined` | Custom React plugin name for detection (useful for custom React plugins) |
146
- | `vuePluginName` | `string` | `undefined` | Custom Vue plugin name for detection (useful for custom Vue plugins) |
147
- | `showBallonButton` | `boolean` | `true` | Whether to show the floating balloon button for error navigation |
148
- | `overlay` | `OverlayConfig` | `undefined` | Overlay configuration options |
149
- | `overlay.balloon` | `BalloonConfig` | `undefined` | Balloon button configuration |
150
- | `overlay.balloon.style` | `string \| CSS.Properties` | `undefined` | Balloon button styles (string or CSS.Properties object) |
151
- | `overlay.customCSS` | `string \| CSS.Properties` | `undefined` | Custom CSS to inject for styling customization (string or CSS.Properties object) |
152
- | `solutionFinders` | `SolutionFinder[]` | `[]` | Array of custom solution finder functions for enhanced error analysis |
153
- | `logClientRuntimeError` | `boolean` | `undefined` | **@deprecated** Use `forwardConsole` instead |
150
+ | Option | Type | Default | Description |
151
+ | ----------------------------- | ----------------------------------------------------- | ----------- | -------------------------------------------------------------------------------- |
152
+ | `forwardConsole` | `boolean` | `true` | Enable/disable client-side runtime error logging and overlay display |
153
+ | `forwardedConsoleMethods` | `string[]` | `["error"]` | Array of console method names to intercept and forward to overlay |
154
+ | `framework` | `"react" \| "vue" \| "svelte" \| "preact" \| "solid"` | `undefined` | Explicit framework override; skips auto-detection |
155
+ | `interceptUnhandledRejection` | `boolean` | `true` | Capture process-wide `unhandledRejection` and render it in the overlay |
156
+ | `reactPluginName` | `string` | `undefined` | Custom React plugin name for detection |
157
+ | `vuePluginName` | `string` | `undefined` | Custom Vue plugin name for detection |
158
+ | `sveltePluginName` | `string` | `undefined` | Custom Svelte plugin name for detection |
159
+ | `preactPluginName` | `string` | `undefined` | Custom Preact plugin name for detection |
160
+ | `solidPluginName` | `string` | `undefined` | Custom Solid plugin name for detection |
161
+ | `showBalloonButton` | `boolean` | `true` | Whether to show the floating balloon button for error navigation |
162
+ | `overlay` | `OverlayConfig` | `undefined` | Overlay configuration options |
163
+ | `overlay.balloon` | `BalloonConfig` | `undefined` | Balloon button configuration |
164
+ | `overlay.balloon.style` | `string \| CSS.Properties` | `undefined` | Balloon button styles (string or CSS.Properties object) |
165
+ | `overlay.customCSS` | `string \| CSS.Properties` | `undefined` | Custom CSS to inject for styling customization (string or CSS.Properties object) |
166
+ | `solutionFinders` | `SolutionFinder[]` | `[]` | Array of custom solution finder functions for enhanced error analysis |
167
+ | `showBallonButton` | `boolean` | `undefined` | **@deprecated** Misspelling of `showBalloonButton` |
168
+ | `logClientRuntimeError` | `boolean` | `undefined` | **@deprecated** Use `forwardConsole` instead |
154
169
 
155
170
  ## Error Handling
156
171
 
@@ -188,7 +203,7 @@ When errors occur, a floating balloon button appears in the bottom-right corner
188
203
  - Navigate through multiple errors
189
204
  - Access error overlay controls
190
205
 
191
- The balloon button can be disabled by setting `showBallonButton: false` in the plugin options.
206
+ The balloon button can be disabled by setting `showBalloonButton: false` in the plugin options.
192
207
 
193
208
  ### Keyboard Shortcuts
194
209
 
@@ -202,10 +217,16 @@ The balloon button can be disabled by setting `showBallonButton: false` in the p
202
217
 
203
218
  You can extend the plugin with custom solution finders:
204
219
 
220
+ All public option types are exported from the package, so you can type a shared config object or a custom solution finder without reaching into `@visulima/error`:
221
+
222
+ ```typescript
223
+ import type { BalloonConfig, BalloonPosition, OverlayConfig, SolutionFinder, VisulimaViteOverlayOptions } from "@visulima/vite-overlay";
224
+ ```
225
+
205
226
  ```typescript
206
227
  import { defineConfig } from "vite";
207
228
  import errorOverlay from "@visulima/vite-overlay";
208
- import type { SolutionFinder } from "@visulima/error/solution";
229
+ import type { SolutionFinder } from "@visulima/vite-overlay";
209
230
 
210
231
  const customSolutionFinder: SolutionFinder = {
211
232
  name: "custom-finder",
package/dist/index.d.ts CHANGED
@@ -1,27 +1,148 @@
1
- import { SolutionFinder } from '@visulima/error/solution';
2
1
  import { Plugin } from 'vite';
3
2
  import '@visulima/error/error';
3
+ import { SolutionFinder } from '@visulima/error/solution';
4
+ export type { Solution, SolutionFinder } from '@visulima/error/solution';
4
5
  import { Properties } from 'csstype';
6
+ /**
7
+ * Framework hint used to route framework-aware solutions. When omitted, the plugin
8
+ * auto-detects the framework from the configured Vite plugins.
9
+ */
10
+ type Framework = "preact" | "react" | "solid" | "svelte" | "vue";
11
+ /**
12
+ * Balloon position options
13
+ */
5
14
  type BalloonPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
15
+ /**
16
+ * Custom style options for the balloon trigger
17
+ * Can be either a CSS string or a CSS.Properties object
18
+ */
6
19
  type BalloonStyle = string | Properties;
20
+ /**
21
+ * Balloon configuration options
22
+ */
7
23
  interface BalloonConfig {
8
24
  readonly enabled?: boolean;
9
25
  readonly icon?: string;
10
26
  readonly position?: BalloonPosition;
11
27
  readonly style?: BalloonStyle;
12
28
  }
29
+ /**
30
+ * Overlay configuration options
31
+ */
13
32
  interface OverlayConfig {
14
33
  readonly balloon?: BalloonConfig;
34
+ /**
35
+ * Custom CSS to inject into the overlay for styling customization.
36
+ * This CSS will be injected into the shadow DOM and can be used to override
37
+ * the default styles of the overlay and button elements.
38
+ * Can be either a CSS string or a CSS.Properties object.
39
+ */
15
40
  readonly customCSS?: string | Properties;
16
41
  }
17
- declare const errorOverlayPlugin: (options?: {
18
- forwardConsole?: boolean;
19
- forwardedConsoleMethods?: string[];
20
- logClientRuntimeError?: boolean;
21
- overlay?: OverlayConfig;
22
- reactPluginName?: string;
23
- showBallonButton?: boolean;
24
- solutionFinders?: SolutionFinder[];
25
- vuePluginName?: string;
26
- }) => Plugin;
27
- export { errorOverlayPlugin as default };
42
+ /**
43
+ * Options accepted by the `@visulima/vite-overlay` plugin.
44
+ */
45
+ interface VisulimaViteOverlayOptions {
46
+ /**
47
+ * Whether client runtime errors are forwarded to (and displayed in) the overlay.
48
+ * @default true
49
+ */
50
+ readonly forwardConsole?: boolean;
51
+ /**
52
+ * Console method names to forward from the client (e.g. `["error", "warn"]`).
53
+ * @default ["error"]
54
+ */
55
+ readonly forwardedConsoleMethods?: string[];
56
+ /**
57
+ * Explicitly set the framework used for framework-aware hints. When omitted, the plugin
58
+ * auto-detects React / Vue / Svelte / Preact / Solid from the configured Vite plugins.
59
+ */
60
+ readonly framework?: Framework;
61
+ /**
62
+ * Capture process-wide `unhandledRejection` events and render them in the overlay.
63
+ * Set to `false` to leave Node's default crash semantics untouched (useful when other
64
+ * tooling in the dev process produces unrelated rejections).
65
+ * @default true
66
+ */
67
+ readonly interceptUnhandledRejection?: boolean;
68
+ /**
69
+ * @deprecated Use {@link VisulimaViteOverlayOptions.forwardConsole} instead.
70
+ */
71
+ readonly logClientRuntimeError?: boolean;
72
+ /**
73
+ * Overlay UI configuration (balloon button, custom CSS).
74
+ */
75
+ readonly overlay?: OverlayConfig;
76
+ /**
77
+ * Custom Preact plugin name to match during auto-detection.
78
+ */
79
+ readonly preactPluginName?: string;
80
+ /**
81
+ * Custom React plugin name to match during auto-detection.
82
+ */
83
+ readonly reactPluginName?: string;
84
+ /**
85
+ * @deprecated Misspelling of {@link VisulimaViteOverlayOptions.showBalloonButton}. Kept for
86
+ * backward compatibility; prefer `showBalloonButton` or `overlay.balloon.enabled`.
87
+ */
88
+ readonly showBallonButton?: boolean;
89
+ /**
90
+ * Whether to show the balloon button.
91
+ * @default true
92
+ */
93
+ readonly showBalloonButton?: boolean;
94
+ /**
95
+ * Custom Solid plugin name to match during auto-detection.
96
+ */
97
+ readonly solidPluginName?: string;
98
+ /**
99
+ * Custom solution finders to run before the built-in finders.
100
+ */
101
+ readonly solutionFinders?: SolutionFinder[];
102
+ /**
103
+ * Custom Svelte plugin name to match during auto-detection.
104
+ */
105
+ readonly sveltePluginName?: string;
106
+ /**
107
+ * Custom Vue plugin name to match during auto-detection.
108
+ */
109
+ readonly vuePluginName?: string;
110
+ }
111
+ /**
112
+ * Creates a solution finder specifically designed for Vite-related errors.
113
+ * Provides intelligent suggestions for common Vite import resolution and configuration issues.
114
+ * @param rootPath The root path of the project
115
+ * @returns A solution finder object for Vite-specific error handling
116
+ */
117
+ declare const createViteSolutionFinder: (rootPath: string) => SolutionFinder;
118
+ /**
119
+ * Default export for creating Vite solution finders.
120
+ * @see createViteSolutionFinder
121
+ */
122
+
123
+ /**
124
+ * Main Vite plugin for error overlay functionality.
125
+ * Intercepts runtime errors and displays them in a user-friendly overlay.
126
+ * @param options Plugin configuration options
127
+ * @param options.forwardConsole Whether to log client runtime errors (optional)
128
+ * @param options.forwardedConsoleMethods Array of console method names to forward (optional)
129
+ * @param [options.logClientRuntimeError] [deprecated] Use forwardConsole instead
130
+ * @param options.reactPluginName Custom React plugin name (optional)
131
+ * @param options.solutionFinders Custom solution finders (optional)
132
+ * @param options.vuePluginName Custom Vue plugin name (optional)
133
+ * @param options.sveltePluginName Custom Svelte plugin name (optional)
134
+ * @param options.preactPluginName Custom Preact plugin name (optional)
135
+ * @param options.solidPluginName Custom Solid plugin name (optional)
136
+ * @param options.framework Explicit framework override; skips auto-detection (optional)
137
+ * @param options.interceptUnhandledRejection Capture process-wide unhandled rejections (optional, default true)
138
+ * @param options.showBalloonButton Whether to show the balloon button (optional)
139
+ * @param options.showBallonButton [deprecated] Misspelling of showBalloonButton
140
+ * @param options.overlay Overlay configuration (optional)
141
+ * @returns The Vite plugin configuration
142
+ */
143
+ declare const errorOverlayPlugin: (options?: VisulimaViteOverlayOptions) => Plugin;
144
+ /**
145
+ * Default export of the Vite error overlay plugin.
146
+ * Use this plugin to enable error overlay functionality in your Vite project.
147
+ */
148
+ export { type BalloonConfig, type BalloonPosition, type BalloonStyle, type Framework, type OverlayConfig, type VisulimaViteOverlayOptions, createViteSolutionFinder, errorOverlayPlugin as default };