|
| 1 | +import type { DevToolsMessageFilePosition, DevToolsMessageLevel } from '@vitejs/devtools-kit' |
| 2 | + |
| 3 | +/** |
| 4 | + * Severity level of a notification, mirroring devframe's message levels. |
| 5 | + * |
| 6 | + * Determines the color/icon of the entry in the Vite DevTools **Messages** dock |
| 7 | + * and its toast. |
| 8 | + */ |
| 9 | +export type NuxtDevtoolsNotifyLevel = DevToolsMessageLevel |
| 10 | + |
| 11 | +/** |
| 12 | + * A Nuxt-friendly subset of devframe's `DevframeMessageEntryInput`. |
| 13 | + * |
| 14 | + * This is the input accepted by the `devtools:notify` Nuxt hook, the `notify` |
| 15 | + * RPC function and the injected client's `notify()` — all of which forward to |
| 16 | + * the connected `ctx.messages` host so notifications flow through the single |
| 17 | + * devframe Messages system (persistent dock list + toast overlay). |
| 18 | + * |
| 19 | + * Tiers are expressed through the flags below: |
| 20 | + * - **Ephemeral** (toast-only feedback like "Copied!"): `notify: true` with an |
| 21 | + * `autoDismiss` (toast lifetime) and `autoDelete` (entry lifetime) so it never |
| 22 | + * builds up history in the Messages dock. |
| 23 | + * - **Persistent** (server-originated, leveled): omit `autoDelete` so the entry |
| 24 | + * is kept in the Messages dock list. |
| 25 | + */ |
| 26 | +export interface NuxtDevtoolsNotifyInput { |
| 27 | + /** Short title / summary of the message. */ |
| 28 | + message: string |
| 29 | + /** Severity level. Defaults to `'info'`. */ |
| 30 | + level?: NuxtDevtoolsNotifyLevel |
| 31 | + /** Optional detailed description or explanation. */ |
| 32 | + description?: string |
| 33 | + /** Optional tags/labels for filtering in the Messages dock. */ |
| 34 | + labels?: string[] |
| 35 | + /** Optional grouping category (e.g. `'build'`, `'lint'`, `'runtime'`). */ |
| 36 | + category?: string |
| 37 | + /** Optional source file position (e.g. for a build/lint error). */ |
| 38 | + filePosition?: DevToolsMessageFilePosition |
| 39 | + /** Optional stack trace string. */ |
| 40 | + stacktrace?: string |
| 41 | + /** Whether this message should also appear as a transient toast. */ |
| 42 | + notify?: boolean |
| 43 | + /** Time in ms to auto-dismiss the toast (client-side). */ |
| 44 | + autoDismiss?: number |
| 45 | + /** Time in ms to auto-delete the entry from the persistent list (server-side). */ |
| 46 | + autoDelete?: number |
| 47 | +} |
0 commit comments