@vizejs/wasm 0.290.0 → 0.302.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/index.d.ts CHANGED
@@ -4,6 +4,54 @@
4
4
  * This package provides WebAssembly bindings for the Vue compiler implemented in Rust.
5
5
  */
6
6
 
7
+ import type { FormatOptions, FormatResult, LintOptions, LintResult } from "./lint-format.js";
8
+
9
+ export type {
10
+ FormatOptions,
11
+ FormatResult,
12
+ LintDiagnostic,
13
+ LintOptions,
14
+ LintPosition,
15
+ LintPreset,
16
+ LintResult,
17
+ } from "./lint-format.js";
18
+
19
+ /** Binding classification accepted by template identifier rewriting. */
20
+ export type BindingType =
21
+ | "setup-let"
22
+ | "setup-maybe-ref"
23
+ | "setup-ref"
24
+ | "setup-reactive-const"
25
+ | "setup-const"
26
+ | "props"
27
+ | "props-aliased"
28
+ | "data"
29
+ | "options"
30
+ | "literal-const"
31
+ | "js-global-universal"
32
+ | "js-global-browser"
33
+ | "js-global-node"
34
+ | "js-global-deno"
35
+ | "js-global-bun"
36
+ | "vue-global"
37
+ | "external-module";
38
+
39
+ export interface BindingMetadata {
40
+ bindings: Record<string, BindingType>;
41
+ propsAliases: Record<string, string>;
42
+ isScriptSetup: boolean;
43
+ }
44
+
45
+ /** Source Map v3 emitted for a directly compiled VDOM template. */
46
+ export interface SourceMap {
47
+ version: 3;
48
+ file: string;
49
+ sources: string[];
50
+ sourcesContent: string[];
51
+ names: string[];
52
+ mappings: string;
53
+ }
54
+
7
55
  /** Compiler options for template compilation */
8
56
  export interface CompilerOptions {
9
57
  /** Output mode: "module" or "function" */
@@ -18,9 +66,9 @@ export interface CompilerOptions {
18
66
  scopeId?: string;
19
67
  /** Whether in SSR mode */
20
68
  ssr?: boolean;
21
- /** Whether to generate source map */
69
+ /** Whether to generate a source map for direct VDOM template compilation */
22
70
  sourceMap?: boolean;
23
- /** Filename for source map */
71
+ /** Filename used for source-map identity, SFC parsing, and generated module IDs */
24
72
  filename?: string;
25
73
  /** Output mode: "vdom" or "vapor" */
26
74
  outputMode?: "vdom" | "vapor";
@@ -28,7 +76,21 @@ export interface CompilerOptions {
28
76
  isTs?: boolean;
29
77
  /** Whether the template targets a custom renderer instead of the DOM. */
30
78
  customRenderer?: boolean;
31
- /** Enable Vue parser quirk compatibility for known edge cases. */
79
+ /** Template syntax compatibility mode. */
80
+ templateSyntax?: "standard" | "strict" | "quirks";
81
+ /** Enable Vue in-tag comments (`// ...`) inside opening tags. */
82
+ experimentalInTagComments?: boolean;
83
+ /** Enable `v-match` / `v-case` patterned template desugaring. */
84
+ experimentalPatternedTemplate?: boolean;
85
+ /** Runtime package imported by generated VDOM modules and SFC client output. */
86
+ runtimeModuleName?: string;
87
+ /** Runtime global read by function-mode VDOM and standalone SFC client output. */
88
+ runtimeGlobalName?: string;
89
+ /** SFC TypeScript output handling. */
90
+ scriptExt?: "preserve" | "downcompile";
91
+ /** Script binding information used by direct template compilation. */
92
+ bindingMetadata?: BindingMetadata;
93
+ /** @deprecated Use `templateSyntax: "quirks"`. */
32
94
  vueParserQuirks?: boolean;
33
95
  }
34
96
 
@@ -40,8 +102,8 @@ export interface CompileResult {
40
102
  preamble: string;
41
103
  /** AST (serialized) */
42
104
  ast: object;
43
- /** Source map */
44
- map?: object | null;
105
+ /** Source map, present when `sourceMap` is enabled for VDOM output. */
106
+ map?: SourceMap;
45
107
  /** Used helpers */
46
108
  helpers: string[];
47
109
  /** Template strings for Vapor mode static parts */
@@ -123,10 +185,7 @@ export interface SfcParseOptions {
123
185
  }
124
186
 
125
187
  /** SFC compile options */
126
- export interface SfcCompileOptions extends CompilerOptions {
127
- /** Filename for the SFC */
128
- filename?: string;
129
- }
188
+ export interface SfcCompileOptions extends CompilerOptions {}
130
189
 
131
190
  /** Result of SFC compilation */
132
191
  export interface SfcCompileResult {
@@ -139,7 +198,7 @@ export interface SfcCompileResult {
139
198
  /** Generated JavaScript code */
140
199
  code: string;
141
200
  /** Binding metadata */
142
- bindings?: object;
201
+ bindings?: BindingMetadata;
143
202
  };
144
203
  /** Generated CSS */
145
204
  css?: string;
@@ -149,6 +208,8 @@ export interface SfcCompileResult {
149
208
  warnings: string[];
150
209
  /** Compile-time macro artifacts */
151
210
  macroArtifacts?: MacroArtifact[];
211
+ /** Flat binding map for feeding a later template-only compile. */
212
+ bindingMetadata?: Record<string, BindingType>;
152
213
  }
153
214
 
154
215
  /** JSX/TSX compile options */
@@ -248,50 +309,35 @@ export declare class Compiler {
248
309
  }
249
310
 
250
311
  /** Compile template to VDom render function */
251
- export declare function compile(
252
- template: string,
253
- options?: CompilerOptions
254
- ): CompileResult;
312
+ export declare function compile(template: string, options?: CompilerOptions): CompileResult;
255
313
 
256
314
  /** Compile template to Vapor mode */
257
- export declare function compileVapor(
258
- template: string,
259
- options?: CompilerOptions
260
- ): CompileResult;
315
+ export declare function compileVapor(template: string, options?: CompilerOptions): CompileResult;
261
316
 
262
317
  /** Parse template to AST */
263
- export declare function parseTemplate(
264
- template: string,
265
- options?: CompilerOptions
266
- ): object;
318
+ export declare function parseTemplate(template: string, options?: CompilerOptions): object;
267
319
 
268
320
  /** Parse SFC (.vue file) */
269
- export declare function parseSfc(
270
- source: string,
271
- options?: SfcParseOptions
272
- ): SfcDescriptor;
321
+ export declare function parseSfc(source: string, options?: SfcParseOptions): SfcDescriptor;
273
322
 
274
323
  /** Compile SFC (.vue file) */
275
- export declare function compileSfc(
276
- source: string,
277
- options?: SfcCompileOptions
278
- ): SfcCompileResult;
324
+ export declare function compileSfc(source: string, options?: SfcCompileOptions): SfcCompileResult;
279
325
 
280
326
  /** Compile JSX/TSX to render code */
281
- export declare function compileJsx(
282
- source: string,
283
- options?: JsxCompileOptions
284
- ): JsxCompileResult;
327
+ export declare function compileJsx(source: string, options?: JsxCompileOptions): JsxCompileResult;
285
328
 
286
329
  /** Compile CSS with LightningCSS */
287
- export declare function compileCss(
288
- css: string,
289
- options?: CssCompileOptions
290
- ): CssCompileResult;
330
+ export declare function compileCss(css: string, options?: CssCompileOptions): CssCompileResult;
331
+
332
+ /** Lint a Vue SFC */
333
+ export declare function lintSfc(source: string, options?: LintOptions): LintResult;
334
+
335
+ /** Format a Vue SFC */
336
+ export declare function formatSfc(source: string, options?: FormatOptions): FormatResult;
291
337
 
292
338
  /** Initialize the WASM module */
293
339
  export declare function init(
294
- moduleOrPath?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module
340
+ moduleOrPath?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module,
295
341
  ): Promise<void>;
296
342
 
297
343
  /** Check if the WASM module is initialized */
package/index.js CHANGED
@@ -13,6 +13,8 @@ import initWasm, {
13
13
  compileSfc as wasmCompileSfc,
14
14
  compileJsx as wasmCompileJsx,
15
15
  compileCss as wasmCompileCss,
16
+ lintSfc as wasmLintSfc,
17
+ formatSfc as wasmFormatSfc,
16
18
  } from "./vize_vitrine.js";
17
19
 
18
20
  let initialized = false;
@@ -34,9 +36,17 @@ export async function init(moduleOrPath) {
34
36
  return initPromise;
35
37
  }
36
38
 
37
- initPromise = initWasm(moduleOrPath).then(() => {
38
- initialized = true;
39
- });
39
+ const initOptions =
40
+ moduleOrPath === undefined ? undefined : { module_or_path: moduleOrPath };
41
+ initPromise = initWasm(initOptions).then(
42
+ () => {
43
+ initialized = true;
44
+ },
45
+ (error) => {
46
+ initPromise = null;
47
+ throw error;
48
+ }
49
+ );
40
50
 
41
51
  return initPromise;
42
52
  }
@@ -237,4 +247,28 @@ export function compileCss(css, options = {}) {
237
247
  return wasmCompileCss(css, options);
238
248
  }
239
249
 
250
+ /**
251
+ * Lint a Vue SFC.
252
+ *
253
+ * @param {string} source
254
+ * @param {object} [options]
255
+ * @returns {object}
256
+ */
257
+ export function lintSfc(source, options = {}) {
258
+ ensureInitialized();
259
+ return wasmLintSfc(source, options);
260
+ }
261
+
262
+ /**
263
+ * Format a Vue SFC.
264
+ *
265
+ * @param {string} source
266
+ * @param {object} [options]
267
+ * @returns {object}
268
+ */
269
+ export function formatSfc(source, options = {}) {
270
+ ensureInitialized();
271
+ return wasmFormatSfc(source, options);
272
+ }
273
+
240
274
  export default init;
@@ -0,0 +1,93 @@
1
+ /** Built-in lint preset. */
2
+ export type LintPreset =
3
+ | "general-recommended"
4
+ | "happy-path"
5
+ | "essential"
6
+ | "incremental"
7
+ | "ecosystem"
8
+ | "opinionated"
9
+ | "nuxt";
10
+
11
+ /** Options for linting a Vue SFC. */
12
+ export interface LintOptions {
13
+ /** Filename reported in the result (default: "anonymous.vue"). */
14
+ filename?: string;
15
+ /** Built-in lint preset (default: "ecosystem"). */
16
+ preset?: LintPreset;
17
+ /** Run only the named rules. */
18
+ enabledRules?: string[];
19
+ /** Locale for diagnostic messages (default: "en"). */
20
+ locale?: "en" | "ja" | "zh";
21
+ }
22
+
23
+ /** One-based source position reported by the linter. */
24
+ export interface LintPosition {
25
+ /** One-based line number. */
26
+ line: number;
27
+ /** One-based column number. */
28
+ column: number;
29
+ /** Byte offset in the original source. */
30
+ offset: number;
31
+ }
32
+
33
+ /** Diagnostic reported by the linter. */
34
+ export interface LintDiagnostic {
35
+ /** Rule that produced the diagnostic. */
36
+ rule: string;
37
+ /** Diagnostic severity. */
38
+ severity: "error" | "warning";
39
+ /** Localized diagnostic message. */
40
+ message: string;
41
+ /** Location in the original source. */
42
+ location: {
43
+ start: LintPosition;
44
+ end: LintPosition;
45
+ };
46
+ /** Optional remediation hint. */
47
+ help: string | undefined;
48
+ }
49
+
50
+ /** Result of linting a Vue SFC. */
51
+ export interface LintResult {
52
+ /** Filename associated with the source. */
53
+ filename: string;
54
+ /** Number of error diagnostics. */
55
+ errorCount: number;
56
+ /** Number of warning diagnostics. */
57
+ warningCount: number;
58
+ /** Diagnostics in source order. */
59
+ diagnostics: LintDiagnostic[];
60
+ }
61
+
62
+ /** Options for formatting a Vue SFC. */
63
+ export interface FormatOptions {
64
+ printWidth?: number;
65
+ tabWidth?: number;
66
+ useTabs?: boolean;
67
+ semi?: boolean;
68
+ singleQuote?: boolean;
69
+ jsxSingleQuote?: boolean;
70
+ trailingComma?: "none" | "es5" | "all";
71
+ bracketSpacing?: boolean;
72
+ bracketSameLine?: boolean;
73
+ arrowParens?: "always" | "avoid";
74
+ endOfLine?: "lf" | "crlf" | "cr" | "auto";
75
+ quoteProps?: "as-needed" | "consistent" | "preserve";
76
+ singleAttributePerLine?: boolean;
77
+ vueIndentScriptAndStyle?: boolean;
78
+ sortAttributes?: boolean;
79
+ attributeSortOrder?: "alphabetical" | "as-written";
80
+ mergeBindAndNonBindAttrs?: boolean;
81
+ maxAttributesPerLine?: number | null;
82
+ attributeGroups?: string[][] | null;
83
+ normalizeDirectiveShorthands?: boolean;
84
+ sortBlocks?: boolean;
85
+ }
86
+
87
+ /** Result of formatting a Vue SFC. */
88
+ export interface FormatResult {
89
+ /** Formatted source. */
90
+ code: string;
91
+ /** Whether the source changed. */
92
+ changed: boolean;
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/wasm",
3
- "version": "0.290.0",
3
+ "version": "0.302.0",
4
4
  "description": "Vize WASM bindings for browser environments",
5
5
  "homepage": "https://github.com/ubugeeei-prod/vize",
6
6
  "bugs": {
@@ -15,6 +15,7 @@
15
15
  "files": [
16
16
  "index.js",
17
17
  "index.d.ts",
18
+ "lint-format.d.ts",
18
19
  "vize_vitrine_bg.wasm",
19
20
  "vize_vitrine.js",
20
21
  "vize_vitrine.d.ts",
Binary file