@vizejs/vite-plugin 0.58.0 → 0.60.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 CHANGED
@@ -12,15 +12,10 @@ High-performance native Vite plugin for Vue SFC compilation powered by [Vize](ht
12
12
 
13
13
  ## Installation
14
14
 
15
- ```bash
16
- # npm
17
- npm install @vizejs/vite-plugin vize
18
-
19
- # pnpm
20
- pnpm add @vizejs/vite-plugin vize
15
+ Install `vp` once from the [Vite+ install guide](https://viteplus.dev/guide/install), then add the packages:
21
16
 
22
- # yarn
23
- yarn add @vizejs/vite-plugin vize
17
+ ```bash
18
+ vp install -D @vizejs/vite-plugin vize
24
19
  ```
25
20
 
26
21
  ## Usage
@@ -0,0 +1,634 @@
1
+ import { defineConfig, loadConfig } from "vize";
2
+ import { Plugin } from "vite";
3
+
4
+ //#region ../vize/src/types/compiler.d.ts
5
+ /**
6
+ * Compiler configuration
7
+ */
8
+ interface CompilerConfig {
9
+ /**
10
+ * Compilation mode
11
+ * @default 'module'
12
+ */
13
+ mode?: "module" | "function";
14
+ /**
15
+ * Enable Vapor mode compilation
16
+ * @default false
17
+ */
18
+ vapor?: boolean;
19
+ /**
20
+ * Treat lowercase non-HTML tags as custom renderer elements instead of Vue components.
21
+ * Useful for TresJS and other custom renderers.
22
+ * @default false
23
+ */
24
+ customRenderer?: boolean;
25
+ /**
26
+ * Enable SSR mode
27
+ * @default false
28
+ */
29
+ ssr?: boolean;
30
+ /**
31
+ * Enable source map generation
32
+ * @default true in development, false in production
33
+ */
34
+ sourceMap?: boolean;
35
+ /**
36
+ * Prefix template identifiers with _ctx
37
+ * @default false
38
+ */
39
+ prefixIdentifiers?: boolean;
40
+ /**
41
+ * Hoist static nodes
42
+ * @default true
43
+ */
44
+ hoistStatic?: boolean;
45
+ /**
46
+ * Cache v-on handlers
47
+ * @default true
48
+ */
49
+ cacheHandlers?: boolean;
50
+ /**
51
+ * Enable TypeScript parsing in <script> blocks
52
+ * @default true
53
+ */
54
+ isTs?: boolean;
55
+ /**
56
+ * Script file extension for generated output
57
+ * @default 'ts'
58
+ */
59
+ scriptExt?: "ts" | "js";
60
+ /**
61
+ * Module name for runtime imports
62
+ * @default 'vue'
63
+ */
64
+ runtimeModuleName?: string;
65
+ /**
66
+ * Global variable name for runtime (IIFE builds)
67
+ * @default 'Vue'
68
+ */
69
+ runtimeGlobalName?: string;
70
+ }
71
+ /**
72
+ * Vite plugin configuration
73
+ */
74
+ interface VitePluginConfig {
75
+ /**
76
+ * Files to include in compilation
77
+ * @default /\.vue$/
78
+ */
79
+ include?: string | RegExp | (string | RegExp)[];
80
+ /**
81
+ * Files to exclude from compilation
82
+ * @default /node_modules/
83
+ */
84
+ exclude?: string | RegExp | (string | RegExp)[];
85
+ /**
86
+ * Glob patterns to scan for .vue files during pre-compilation
87
+ * @default ['**\/*.vue']
88
+ */
89
+ scanPatterns?: string[];
90
+ /**
91
+ * Glob patterns to ignore during pre-compilation
92
+ * @default ['node_modules/**', 'dist/**', '.git/**']
93
+ */
94
+ ignorePatterns?: string[];
95
+ }
96
+ //#endregion
97
+ //#region ../vize/src/types/rules.d.ts
98
+ declare const LINT_RULE_NAMES: readonly ["a11y/alt-text", "a11y/anchor-has-content", "a11y/anchor-is-valid", "a11y/aria-props", "a11y/aria-role", "a11y/aria-unsupported-elements", "a11y/click-events-have-key-events", "a11y/form-control-has-label", "a11y/heading-has-content", "a11y/heading-levels", "a11y/iframe-has-title", "a11y/img-alt", "a11y/interactive-supports-focus", "a11y/label-has-for", "a11y/landmark-roles", "a11y/media-has-caption", "a11y/mouse-events-have-key-events", "a11y/no-access-key", "a11y/no-aria-hidden-on-focusable", "a11y/no-autofocus", "a11y/no-distracting-elements", "a11y/no-i-for-icon", "a11y/no-redundant-roles", "a11y/no-refer-to-non-existent-id", "a11y/no-role-presentation-on-focusable", "a11y/no-static-element-interactions", "a11y/placeholder-label-option", "a11y/role-has-required-aria-props", "a11y/tabindex-no-positive", "a11y/use-list", "html/deprecated-attr", "html/deprecated-element", "html/id-duplication", "html/no-consecutive-br", "html/no-duplicate-dt", "html/no-empty-palpable-content", "html/require-datetime", "script/no-get-current-instance", "script/no-next-tick", "script/no-options-api", "ssr/no-browser-globals-in-ssr", "ssr/no-hydration-mismatch", "type/no-floating-promises", "type/no-unsafe-template-binding", "type/require-typed-emits", "type/require-typed-props", "vapor/no-inline-template", "vapor/no-suspense", "vapor/no-vue-lifecycle-events", "vapor/prefer-static-class", "vapor/require-vapor-attribute", "vue/attribute-hyphenation", "vue/attribute-order", "vue/component-definition-name-casing", "vue/component-name-in-template-casing", "vue/html-quotes", "vue/html-self-closing", "vue/multi-word-component-names", "vue/mustache-interpolation-spacing", "vue/no-boolean-attr-value", "vue/no-child-content", "vue/no-dupe-v-else-if", "vue/no-duplicate-attributes", "vue/no-inline-style", "vue/no-lone-template", "vue/no-multi-spaces", "vue/no-mutating-props", "vue/no-preprocessor-lang", "vue/no-reserved-component-names", "vue/no-script-non-standard-lang", "vue/no-src-attribute", "vue/no-template-key", "vue/no-template-lang", "vue/no-template-shadow", "vue/no-textarea-mustache", "vue/no-unsafe-url", "vue/no-unused-components", "vue/no-unused-properties", "vue/no-unused-vars", "vue/no-use-v-if-with-v-for", "vue/no-useless-template-attributes", "vue/no-v-html", "vue/no-v-text-v-html-on-component", "vue/permitted-contents", "vue/prefer-props-shorthand", "vue/prop-name-casing", "vue/require-component-is", "vue/require-component-registration", "vue/require-scoped-style", "vue/require-v-for-key", "vue/scoped-event-names", "vue/sfc-element-order", "vue/single-style-block", "vue/use-unique-element-ids", "vue/use-v-on-exact", "vue/v-bind-style", "vue/v-on-style", "vue/v-slot-style", "vue/valid-attribute-name", "vue/valid-v-bind", "vue/valid-v-else", "vue/valid-v-for", "vue/valid-v-if", "vue/valid-v-memo", "vue/valid-v-model", "vue/valid-v-on", "vue/valid-v-show", "vue/valid-v-slot", "vue/warn-custom-block", "vue/warn-custom-directive"];
99
+ type LintRuleName = (typeof LINT_RULE_NAMES)[number];
100
+ type LintRulesConfig = Partial<Record<LintRuleName, RuleSeverity>>;
101
+ //#endregion
102
+ //#region ../vize/src/types/tools.d.ts
103
+ /**
104
+ * Linter configuration
105
+ */
106
+ interface LinterConfig {
107
+ /**
108
+ * Enable linting
109
+ */
110
+ enabled?: boolean;
111
+ /**
112
+ * Built-in lint preset
113
+ * @default 'happy-path'
114
+ */
115
+ preset?: LintPreset;
116
+ /**
117
+ * Rules to enable/disable
118
+ */
119
+ rules?: LintRulesConfig;
120
+ /**
121
+ * Category-level severity overrides
122
+ */
123
+ categories?: Partial<Record<RuleCategory, RuleSeverity>>;
124
+ }
125
+ /**
126
+ * Type checker configuration
127
+ */
128
+ interface TypeCheckerConfig {
129
+ /**
130
+ * Enable type checking
131
+ * @default false
132
+ */
133
+ enabled?: boolean;
134
+ /**
135
+ * Enable strict mode
136
+ * @default false
137
+ */
138
+ strict?: boolean;
139
+ /**
140
+ * Check component props
141
+ * @default true
142
+ */
143
+ checkProps?: boolean;
144
+ /**
145
+ * Check component emits
146
+ * @default true
147
+ */
148
+ checkEmits?: boolean;
149
+ /**
150
+ * Check template bindings
151
+ * @default true
152
+ */
153
+ checkTemplateBindings?: boolean;
154
+ /**
155
+ * Path to tsconfig.json
156
+ * @default auto-detected
157
+ */
158
+ tsconfig?: string;
159
+ /**
160
+ * Path to the Corsa binary
161
+ */
162
+ corsaPath?: string;
163
+ }
164
+ /**
165
+ * Formatter configuration
166
+ */
167
+ interface FormatterConfig {
168
+ /**
169
+ * Max line width
170
+ * @default 80
171
+ */
172
+ printWidth?: number;
173
+ /**
174
+ * Indentation width
175
+ * @default 2
176
+ */
177
+ tabWidth?: number;
178
+ /**
179
+ * Use tabs for indentation
180
+ * @default false
181
+ */
182
+ useTabs?: boolean;
183
+ /**
184
+ * Print semicolons
185
+ * @default true
186
+ */
187
+ semi?: boolean;
188
+ /**
189
+ * Use single quotes
190
+ * @default false
191
+ */
192
+ singleQuote?: boolean;
193
+ /**
194
+ * Trailing commas
195
+ * @default 'all'
196
+ */
197
+ trailingComma?: "all" | "none" | "es5";
198
+ }
199
+ /**
200
+ * LSP configuration
201
+ */
202
+ interface LspConfig {
203
+ /**
204
+ * Enable LSP
205
+ * @default false
206
+ */
207
+ enabled?: boolean;
208
+ /**
209
+ * Enable linter diagnostics.
210
+ * Prefer this over `diagnostics` for new configs.
211
+ * @default false
212
+ */
213
+ lint?: boolean;
214
+ /**
215
+ * Enable linter diagnostics.
216
+ * @deprecated Use `lint` instead.
217
+ * @default false
218
+ */
219
+ diagnostics?: boolean;
220
+ /**
221
+ * Enable type checking diagnostics and type-aware LSP features.
222
+ * @default false
223
+ */
224
+ typecheck?: boolean;
225
+ /**
226
+ * Enable the editor assistance bundle: completion, hover, navigation,
227
+ * symbols, rename, code lens, semantic tokens, links, folding, inlay hints,
228
+ * and file rename handling. Formatting stays separately opt-in.
229
+ * @default false
230
+ */
231
+ editor?: boolean;
232
+ /**
233
+ * Enable completions.
234
+ * @default false
235
+ */
236
+ completion?: boolean;
237
+ /**
238
+ * Enable hover information
239
+ * @default false
240
+ */
241
+ hover?: boolean;
242
+ /**
243
+ * Enable go-to-definition
244
+ * @default false
245
+ */
246
+ definition?: boolean;
247
+ /**
248
+ * Enable find references
249
+ * @default false
250
+ */
251
+ references?: boolean;
252
+ /**
253
+ * Enable document symbols
254
+ * @default false
255
+ */
256
+ documentSymbols?: boolean;
257
+ /**
258
+ * Enable workspace symbols
259
+ * @default false
260
+ */
261
+ workspaceSymbols?: boolean;
262
+ /**
263
+ * Enable formatting via LSP
264
+ * @default false
265
+ */
266
+ formatting?: boolean;
267
+ /**
268
+ * Enable code actions
269
+ * @default false
270
+ */
271
+ codeActions?: boolean;
272
+ /**
273
+ * Enable rename
274
+ * @default false
275
+ */
276
+ rename?: boolean;
277
+ /**
278
+ * Enable code lens
279
+ * @default false
280
+ */
281
+ codeLens?: boolean;
282
+ /**
283
+ * Enable semantic tokens
284
+ * @default false
285
+ */
286
+ semanticTokens?: boolean;
287
+ /**
288
+ * Enable document links
289
+ * @default false
290
+ */
291
+ documentLinks?: boolean;
292
+ /**
293
+ * Enable folding ranges
294
+ * @default false
295
+ */
296
+ foldingRanges?: boolean;
297
+ /**
298
+ * Enable inlay hints
299
+ * @default false
300
+ */
301
+ inlayHints?: boolean;
302
+ /**
303
+ * Enable file rename edits
304
+ * @default false
305
+ */
306
+ fileRename?: boolean;
307
+ /**
308
+ * Use Corsa for type checking in LSP
309
+ * @default false
310
+ */
311
+ corsa?: boolean;
312
+ }
313
+ //#endregion
314
+ //#region ../vize/src/types/musea.d.ts
315
+ /**
316
+ * VRT (Visual Regression Testing) configuration for Musea
317
+ */
318
+ interface MuseaVrtConfig {
319
+ /**
320
+ * Threshold for pixel comparison (0-1)
321
+ * @default 0.1
322
+ */
323
+ threshold?: number;
324
+ /**
325
+ * Output directory for screenshots
326
+ * @default '__musea_snapshots__'
327
+ */
328
+ outDir?: string;
329
+ /**
330
+ * Viewport sizes
331
+ */
332
+ viewports?: Array<{
333
+ width: number;
334
+ height: number;
335
+ name?: string;
336
+ }>;
337
+ }
338
+ /**
339
+ * A11y configuration for Musea
340
+ */
341
+ interface MuseaA11yConfig {
342
+ /**
343
+ * Enable a11y checking
344
+ * @default false
345
+ */
346
+ enabled?: boolean;
347
+ /**
348
+ * Axe-core rules to enable/disable
349
+ */
350
+ rules?: Record<string, boolean>;
351
+ }
352
+ /**
353
+ * Autogen configuration for Musea
354
+ */
355
+ interface MuseaAutogenConfig {
356
+ /**
357
+ * Enable auto-generation of variants
358
+ * @default false
359
+ */
360
+ enabled?: boolean;
361
+ /**
362
+ * Max variants to generate per component
363
+ * @default 10
364
+ */
365
+ maxVariants?: number;
366
+ }
367
+ /**
368
+ * Musea component gallery configuration
369
+ */
370
+ interface MuseaConfig {
371
+ /**
372
+ * Glob patterns for art files
373
+ * @default ['**\/*.art.vue']
374
+ */
375
+ include?: string[];
376
+ /**
377
+ * Glob patterns to exclude
378
+ * @default ['node_modules/**', 'dist/**']
379
+ */
380
+ exclude?: string[];
381
+ /**
382
+ * Base path for gallery
383
+ * @default '/__musea__'
384
+ */
385
+ basePath?: string;
386
+ /**
387
+ * Enable Storybook compatibility
388
+ * @default false
389
+ */
390
+ storybookCompat?: boolean;
391
+ /**
392
+ * Enable inline art detection in .vue files
393
+ * @default false
394
+ */
395
+ inlineArt?: boolean;
396
+ /**
397
+ * VRT configuration
398
+ */
399
+ vrt?: MuseaVrtConfig;
400
+ /**
401
+ * A11y configuration
402
+ */
403
+ a11y?: MuseaA11yConfig;
404
+ /**
405
+ * Autogen configuration
406
+ */
407
+ autogen?: MuseaAutogenConfig;
408
+ }
409
+ //#endregion
410
+ //#region ../vize/src/types/loader.d.ts
411
+ /**
412
+ * Global type declaration
413
+ */
414
+ interface GlobalTypeDeclaration {
415
+ /**
416
+ * TypeScript type string
417
+ */
418
+ type: string;
419
+ /**
420
+ * Default value
421
+ */
422
+ defaultValue?: string;
423
+ }
424
+ /**
425
+ * Global types configuration
426
+ */
427
+ type GlobalTypesConfig = Record<string, GlobalTypeDeclaration | string>;
428
+ /**
429
+ * Options for loading vize.config file
430
+ */
431
+ interface LoadConfigOptions {
432
+ /**
433
+ * Config file search mode
434
+ * - 'root': Search only in the specified root directory
435
+ * - 'auto': Search from cwd upward until finding a config file
436
+ * - 'none': Don't load config file
437
+ * @default 'root'
438
+ */
439
+ mode?: "root" | "auto" | "none";
440
+ /**
441
+ * Custom config file path (overrides automatic search)
442
+ */
443
+ configFile?: string;
444
+ /**
445
+ * Config environment for dynamic config resolution
446
+ */
447
+ env?: ConfigEnv;
448
+ }
449
+ //#endregion
450
+ //#region ../vize/src/types/core.d.ts
451
+ interface ConfigEnv {
452
+ mode: string;
453
+ command: "serve" | "build" | "check" | "lint" | "fmt";
454
+ isSsrBuild?: boolean;
455
+ }
456
+ type RuleSeverity = "off" | "warn" | "error";
457
+ type RuleCategory = "correctness" | "suspicious" | "style" | "perf" | "a11y" | "security";
458
+ type LintPreset = "happy-path" | "opinionated" | "essential" | "nuxt";
459
+ /**
460
+ * Vize configuration options
461
+ */
462
+ interface VizeConfig {
463
+ /**
464
+ * JSON Schema reference for editor autocompletion.
465
+ */
466
+ $schema?: string;
467
+ /**
468
+ * Vue compiler options
469
+ */
470
+ compiler?: CompilerConfig;
471
+ /**
472
+ * Vite plugin options
473
+ */
474
+ vite?: VitePluginConfig;
475
+ /**
476
+ * Linter options
477
+ */
478
+ linter?: LinterConfig;
479
+ /**
480
+ * Type checker options
481
+ */
482
+ typeChecker?: TypeCheckerConfig;
483
+ /**
484
+ * Formatter options
485
+ */
486
+ formatter?: FormatterConfig;
487
+ /**
488
+ * LSP options
489
+ */
490
+ lsp?: LspConfig;
491
+ /**
492
+ * Musea component gallery options
493
+ */
494
+ musea?: MuseaConfig;
495
+ /**
496
+ * Global type declarations
497
+ */
498
+ globalTypes?: GlobalTypesConfig;
499
+ }
500
+ //#endregion
501
+ //#region src/types.d.ts
502
+ interface VizeOptions {
503
+ /**
504
+ * Override the public base used for dev-time asset URLs such as /@fs paths.
505
+ * Useful for frameworks like Nuxt that serve Vite from a subpath (e.g. /_nuxt/).
506
+ */
507
+ devUrlBase?: string;
508
+ /**
509
+ * Files to include in compilation
510
+ * @default /\.vue$/
511
+ */
512
+ include?: string | RegExp | (string | RegExp)[];
513
+ /**
514
+ * Files to exclude from compilation
515
+ * @default /node_modules/
516
+ */
517
+ exclude?: string | RegExp | (string | RegExp)[];
518
+ /**
519
+ * Force production mode
520
+ * @default auto-detected from Vite config
521
+ */
522
+ isProduction?: boolean;
523
+ /**
524
+ * Enable SSR mode
525
+ * @default false
526
+ */
527
+ ssr?: boolean;
528
+ /**
529
+ * Enable source map generation
530
+ * @default true in development, false in production
531
+ */
532
+ sourceMap?: boolean;
533
+ /**
534
+ * Enable Vapor mode compilation
535
+ * @default false
536
+ */
537
+ vapor?: boolean;
538
+ /**
539
+ * Treat lowercase non-HTML tags as custom renderer elements instead of Vue components.
540
+ * Useful for TresJS and other custom renderers.
541
+ * @default false
542
+ */
543
+ customRenderer?: boolean;
544
+ /**
545
+ * Root directory to scan for .vue files
546
+ * @default Vite's root
547
+ */
548
+ root?: string;
549
+ /**
550
+ * Glob patterns to scan for .vue files during pre-compilation
551
+ * @default ['**\/*.vue']
552
+ */
553
+ scanPatterns?: string[];
554
+ /**
555
+ * Glob patterns to ignore during pre-compilation
556
+ * @default ['node_modules/**', 'dist/**', '.git/**']
557
+ */
558
+ ignorePatterns?: string[];
559
+ /**
560
+ * Config file search mode
561
+ * - 'root': Search only in the project root directory
562
+ * - 'auto': Search from cwd upward until finding a config file
563
+ * - false: Disable config file loading
564
+ * @default 'root'
565
+ */
566
+ configMode?: "root" | "auto" | false;
567
+ /**
568
+ * Custom config file path (overrides automatic search)
569
+ */
570
+ configFile?: string;
571
+ /**
572
+ * Handle .vue files in node_modules (on-demand compilation).
573
+ * When true, vize will compile .vue files from node_modules that other plugins
574
+ * (like vite-plugin-vue-inspector) may import directly.
575
+ * Set to false if another Vue plugin (e.g. Nuxt) handles node_modules .vue files.
576
+ * @default true
577
+ */
578
+ handleNodeModulesVue?: boolean;
579
+ /**
580
+ * Enable debug logging
581
+ * @default false
582
+ */
583
+ debug?: boolean;
584
+ }
585
+ interface StyleBlockInfo {
586
+ /** Raw style content (uncompiled for preprocessor langs) */
587
+ content: string;
588
+ /** Language of the style block (e.g., "css", "scss", "less", "sass", "stylus") */
589
+ lang: string | null;
590
+ /** Whether the style block has the scoped attribute */
591
+ scoped: boolean;
592
+ /** CSS Modules: true for unnamed `module`, or the binding name for `module="name"` */
593
+ module: boolean | string;
594
+ /** Index of this style block in the SFC */
595
+ index: number;
596
+ }
597
+ interface CompiledModule {
598
+ code: string;
599
+ css?: string;
600
+ scopeId: string;
601
+ hasScoped: boolean;
602
+ templateHash?: string;
603
+ styleHash?: string;
604
+ scriptHash?: string;
605
+ /** Per-block style metadata extracted from the source SFC */
606
+ styles?: StyleBlockInfo[];
607
+ }
608
+ //#endregion
609
+ //#region src/virtual.d.ts
610
+ interface DynamicImportAliasRule {
611
+ fromPrefix: string;
612
+ toPrefix: string;
613
+ }
614
+ //#endregion
615
+ //#region src/transform.d.ts
616
+ declare function rewriteStaticAssetUrls(code: string, aliasRules: DynamicImportAliasRule[]): string;
617
+ //#endregion
618
+ //#region src/plugin/index.d.ts
619
+ declare function vize(options?: VizeOptions): Plugin[];
620
+ //#endregion
621
+ //#region src/config.d.ts
622
+ /**
623
+ * Shared config store for inter-plugin communication.
624
+ * Key = project root, Value = resolved VizeConfig.
625
+ * Used by musea() and other plugins to access the unified config.
626
+ */
627
+ declare const vizeConfigStore: Map<string, VizeConfig>;
628
+ //#endregion
629
+ //#region src/index.d.ts
630
+ declare const __internal: {
631
+ rewriteStaticAssetUrls: typeof rewriteStaticAssetUrls;
632
+ };
633
+ //#endregion
634
+ export { type CompiledModule, type LoadConfigOptions, type VizeConfig, type VizeOptions, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, vizeConfigStore };