@vizejs/native 0.101.0 → 0.104.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.
@@ -0,0 +1,98 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+
4
+ const { loadTarget, nativeTargets } = require("./native-targets");
5
+
6
+ const loadErrors = [];
7
+
8
+ function tryRequire(specifier) {
9
+ try {
10
+ return require(specifier);
11
+ } catch (error) {
12
+ loadErrors.push(error);
13
+ return null;
14
+ }
15
+ }
16
+
17
+ function loadConfiguredBinding() {
18
+ if (!process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
19
+ return null;
20
+ }
21
+ return tryRequire(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
22
+ }
23
+
24
+ function loadNativeBinding() {
25
+ const configured = loadConfiguredBinding();
26
+ if (configured) {
27
+ return configured;
28
+ }
29
+
30
+ for (const target of nativeTargets(loadErrors)) {
31
+ const binding = loadTarget(target, loadErrors);
32
+ if (binding) {
33
+ return binding;
34
+ }
35
+ }
36
+
37
+ return null;
38
+ }
39
+
40
+ function loadWasiBinding() {
41
+ let wasiBinding = null;
42
+ let wasiBindingError = null;
43
+
44
+ wasiBinding = tryRequire("./vize-vitrine.wasi.cjs");
45
+ if (!wasiBinding && process.env.NAPI_RS_FORCE_WASI) {
46
+ wasiBindingError = loadErrors[loadErrors.length - 1];
47
+ }
48
+
49
+ if (!wasiBinding) {
50
+ wasiBinding = tryRequire("@vizejs/native-wasm32-wasi");
51
+ if (!wasiBinding && process.env.NAPI_RS_FORCE_WASI) {
52
+ const error = loadErrors[loadErrors.length - 1];
53
+ if (!wasiBindingError) {
54
+ wasiBindingError = error;
55
+ } else if (wasiBindingError !== error) {
56
+ wasiBindingError.cause = error;
57
+ }
58
+ }
59
+ }
60
+
61
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
62
+ const error = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
63
+ error.cause = wasiBindingError;
64
+ throw error;
65
+ }
66
+
67
+ return wasiBinding;
68
+ }
69
+
70
+ function buildLoadError() {
71
+ if (loadErrors.length === 0) {
72
+ return new Error("Failed to load native binding");
73
+ }
74
+
75
+ return new Error(
76
+ `Cannot find native binding. ` +
77
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
78
+ "Please try `npm i` again after removing both package-lock.json and node_modules directory.",
79
+ {
80
+ cause: loadErrors.reduce((error, current) => {
81
+ current.cause = error;
82
+ return current;
83
+ }),
84
+ },
85
+ );
86
+ }
87
+
88
+ let nativeBinding = loadNativeBinding();
89
+
90
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
91
+ nativeBinding = loadWasiBinding() || nativeBinding;
92
+ }
93
+
94
+ if (!nativeBinding) {
95
+ throw buildLoadError();
96
+ }
97
+
98
+ module.exports = nativeBinding;
@@ -0,0 +1,132 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+
4
+ const { readFileSync } = require("node:fs");
5
+ const { execSync } = require("node:child_process");
6
+
7
+ const binaryName = "vize-vitrine";
8
+ const packageVersion = require("./package.json").version;
9
+
10
+ function isFileMusl(file) {
11
+ return file.includes("libc.musl-") || file.includes("ld-musl-");
12
+ }
13
+
14
+ function isMuslFromFilesystem() {
15
+ try {
16
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+
22
+ function isMuslFromReport() {
23
+ let report = null;
24
+
25
+ if (typeof process.report?.getReport === "function") {
26
+ process.report.excludeNetwork = true;
27
+ report = process.report.getReport();
28
+ }
29
+
30
+ if (!report) {
31
+ return null;
32
+ }
33
+ if (report.header && report.header.glibcVersionRuntime) {
34
+ return false;
35
+ }
36
+ if (Array.isArray(report.sharedObjects)) {
37
+ return report.sharedObjects.some(isFileMusl);
38
+ }
39
+
40
+ return false;
41
+ }
42
+
43
+ function isMuslFromChildProcess() {
44
+ try {
45
+ return execSync("ldd --version", { encoding: "utf8" }).includes("musl");
46
+ } catch {
47
+ return false;
48
+ }
49
+ }
50
+
51
+ function isMusl() {
52
+ if (process.platform !== "linux") {
53
+ return false;
54
+ }
55
+
56
+ const fromFs = isMuslFromFilesystem();
57
+ if (fromFs !== null) {
58
+ return fromFs;
59
+ }
60
+
61
+ const fromReport = isMuslFromReport();
62
+ if (fromReport !== null) {
63
+ return fromReport;
64
+ }
65
+
66
+ return isMuslFromChildProcess();
67
+ }
68
+
69
+ function nativeTargets(loadErrors) {
70
+ if (process.platform === "darwin") {
71
+ if (process.arch === "arm64" || process.arch === "x64") {
72
+ return ["darwin-universal", `darwin-${process.arch}`];
73
+ }
74
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
75
+ return [];
76
+ }
77
+
78
+ if (process.platform === "linux") {
79
+ if (process.arch === "arm64" || process.arch === "x64") {
80
+ return [`linux-${process.arch}-${isMusl() ? "musl" : "gnu"}`];
81
+ }
82
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
83
+ return [];
84
+ }
85
+
86
+ if (process.platform === "win32") {
87
+ if (process.arch === "arm64" || process.arch === "x64") {
88
+ return [`win32-${process.arch}-msvc`];
89
+ }
90
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
91
+ return [];
92
+ }
93
+
94
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
95
+ return [];
96
+ }
97
+
98
+ function requireTargetPackage(target) {
99
+ const packageName = `@vizejs/native-${target}`;
100
+ const binding = require(packageName);
101
+ const bindingPackageVersion = require(`${packageName}/package.json`).version;
102
+
103
+ if (
104
+ bindingPackageVersion !== packageVersion &&
105
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
106
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
107
+ ) {
108
+ throw new Error(
109
+ `Native binding package version mismatch, expected ${packageVersion} but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
110
+ );
111
+ }
112
+
113
+ return binding;
114
+ }
115
+
116
+ function loadTarget(target, loadErrors) {
117
+ try {
118
+ return require(`./${binaryName}.${target}.node`);
119
+ } catch (error) {
120
+ loadErrors.push(error);
121
+ }
122
+
123
+ try {
124
+ return requireTargetPackage(target);
125
+ } catch (error) {
126
+ loadErrors.push(error);
127
+ }
128
+
129
+ return null;
130
+ }
131
+
132
+ module.exports = { loadTarget, nativeTargets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/native",
3
- "version": "0.101.0",
3
+ "version": "0.104.0",
4
4
  "description": "High-performance Vue.js compiler - Native bindings",
5
5
  "keywords": [
6
6
  "compiler",
@@ -10,6 +10,10 @@
10
10
  "vize",
11
11
  "vue"
12
12
  ],
13
+ "homepage": "https://github.com/ubugeeei/vize",
14
+ "bugs": {
15
+ "url": "https://github.com/ubugeeei/vize/issues"
16
+ },
13
17
  "license": "MIT",
14
18
  "repository": {
15
19
  "type": "git",
@@ -17,7 +21,10 @@
17
21
  },
18
22
  "files": [
19
23
  "index.js",
20
- "index.d.ts"
24
+ "index.d.ts",
25
+ "native-binding.js",
26
+ "native-targets.js",
27
+ "types"
21
28
  ],
22
29
  "main": "index.js",
23
30
  "types": "index.d.ts",
@@ -28,14 +35,14 @@
28
35
  "@napi-rs/cli": "3.6.2"
29
36
  },
30
37
  "optionalDependencies": {
31
- "@vizejs/native-darwin-arm64": "0.101.0",
32
- "@vizejs/native-darwin-x64": "0.101.0",
33
- "@vizejs/native-linux-arm64-gnu": "0.101.0",
34
- "@vizejs/native-linux-arm64-musl": "0.101.0",
35
- "@vizejs/native-linux-x64-gnu": "0.101.0",
36
- "@vizejs/native-linux-x64-musl": "0.101.0",
37
- "@vizejs/native-win32-arm64-msvc": "0.101.0",
38
- "@vizejs/native-win32-x64-msvc": "0.101.0"
38
+ "@vizejs/native-darwin-arm64": "0.104.0",
39
+ "@vizejs/native-darwin-x64": "0.104.0",
40
+ "@vizejs/native-linux-arm64-gnu": "0.104.0",
41
+ "@vizejs/native-linux-arm64-musl": "0.104.0",
42
+ "@vizejs/native-linux-x64-gnu": "0.104.0",
43
+ "@vizejs/native-linux-x64-musl": "0.104.0",
44
+ "@vizejs/native-win32-arm64-msvc": "0.104.0",
45
+ "@vizejs/native-win32-x64-msvc": "0.104.0"
39
46
  },
40
47
  "napi": {
41
48
  "binaryName": "vize-vitrine",
@@ -50,6 +57,9 @@
50
57
  "aarch64-unknown-linux-musl"
51
58
  ]
52
59
  },
60
+ "engines": {
61
+ "node": ">=22"
62
+ },
53
63
  "scripts": {
54
64
  "build": "node ./scripts/build-local.mjs --release",
55
65
  "build:ci": "napi build --platform --profile ci --manifest-path ../../crates/vize_vitrine/Cargo.toml -p vize_vitrine --features napi --output-dir .",
package/types/art.d.ts ADDED
@@ -0,0 +1,239 @@
1
+ /* eslint-disable */
2
+
3
+ /** Art descriptor for NAPI */
4
+ export interface ArtDescriptorNapi {
5
+ filename: string;
6
+ metadata: ArtMetadataNapi;
7
+ variants: Array<ArtVariantNapi>;
8
+ hasScriptSetup: boolean;
9
+ hasScript: boolean;
10
+ styleCount: number;
11
+ }
12
+
13
+ /** Art metadata for NAPI */
14
+ export interface ArtMetadataNapi {
15
+ title: string;
16
+ description?: string;
17
+ component?: string;
18
+ category?: string;
19
+ tags: Array<string>;
20
+ status: string;
21
+ order?: number;
22
+ }
23
+
24
+ /** Art parse options for NAPI */
25
+ export interface ArtParseOptionsNapi {
26
+ filename?: string;
27
+ }
28
+
29
+ /** Art variant for NAPI */
30
+ export interface ArtVariantNapi {
31
+ name: string;
32
+ template: string;
33
+ isDefault: boolean;
34
+ skipVrt: boolean;
35
+ }
36
+
37
+ export interface AutogenConfigNapi {
38
+ maxVariants?: number;
39
+ includeDefault?: boolean;
40
+ includeBooleanToggles?: boolean;
41
+ includeEnumVariants?: boolean;
42
+ includeBoundaryValues?: boolean;
43
+ includeEmptyStrings?: boolean;
44
+ }
45
+
46
+ export interface AutogenOutputNapi {
47
+ variants: Array<GeneratedVariantNapi>;
48
+ artFileContent: string;
49
+ componentName: string;
50
+ }
51
+
52
+ /** Catalog entry for NAPI */
53
+ export interface CatalogEntryNapi {
54
+ title: string;
55
+ description?: string;
56
+ category?: string;
57
+ tags: Array<string>;
58
+ status: string;
59
+ variantCount: number;
60
+ docPath: string;
61
+ sourcePath: string;
62
+ }
63
+
64
+ /** Catalog output for NAPI */
65
+ export interface CatalogOutputNapi {
66
+ markdown: string;
67
+ filename: string;
68
+ componentCount: number;
69
+ categories: Array<string>;
70
+ tags: Array<string>;
71
+ }
72
+
73
+ /** CSF output for NAPI */
74
+ export interface CsfOutputNapi {
75
+ code: string;
76
+ filename: string;
77
+ }
78
+
79
+ /** Declaration generation options for NAPI */
80
+ export interface DeclarationOptionsNapi {
81
+ filename?: string;
82
+ }
83
+
84
+ /** Declaration generation result for NAPI */
85
+ export interface DeclarationResultNapi {
86
+ code: string;
87
+ }
88
+
89
+ /** Doc options for NAPI */
90
+ export interface DocOptionsNapi {
91
+ includeSource?: boolean;
92
+ includeTemplates?: boolean;
93
+ includeMetadata?: boolean;
94
+ includeToc?: boolean;
95
+ tocThreshold?: number;
96
+ basePath?: string;
97
+ title?: string;
98
+ }
99
+
100
+ /** Doc output for NAPI */
101
+ export interface DocOutputNapi {
102
+ markdown: string;
103
+ filename: string;
104
+ title: string;
105
+ category?: string;
106
+ variantCount: number;
107
+ }
108
+
109
+ /** Format options for NAPI. */
110
+ export interface FormatOptionsNapi {
111
+ printWidth?: number;
112
+ tabWidth?: number;
113
+ useTabs?: boolean;
114
+ semi?: boolean;
115
+ singleQuote?: boolean;
116
+ sortAttributes?: boolean;
117
+ singleAttributePerLine?: boolean;
118
+ maxAttributesPerLine?: number;
119
+ normalizeDirectiveShorthands?: boolean;
120
+ }
121
+
122
+ /** Format result for NAPI. */
123
+ export interface FormatResultNapi {
124
+ code: string;
125
+ changed: boolean;
126
+ }
127
+
128
+ export interface GeneratedVariantNapi {
129
+ name: string;
130
+ isDefault: boolean;
131
+ props: any;
132
+ description?: string;
133
+ }
134
+
135
+ /** Palette options for NAPI */
136
+ export interface PaletteOptionsNapi {
137
+ inferOptions?: boolean;
138
+ minSelectValues?: number;
139
+ maxSelectValues?: number;
140
+ groupByType?: boolean;
141
+ }
142
+
143
+ /** Palette output for NAPI */
144
+ export interface PaletteOutputNapi {
145
+ title: string;
146
+ controls: Array<PropControlNapi>;
147
+ groups: Array<string>;
148
+ json: string;
149
+ typescript: string;
150
+ }
151
+
152
+ /** Prop control for NAPI */
153
+ export interface PropControlNapi {
154
+ name: string;
155
+ control: string;
156
+ defaultValue?: any;
157
+ description?: string;
158
+ required: boolean;
159
+ options: Array<SelectOptionNapi>;
160
+ range?: RangeConfigNapi;
161
+ group?: string;
162
+ }
163
+
164
+ export interface PropDefinitionNapi {
165
+ name: string;
166
+ propType: string;
167
+ required: boolean;
168
+ defaultValue?: any;
169
+ }
170
+
171
+ /** Range config for NAPI */
172
+ export interface RangeConfigNapi {
173
+ min: number;
174
+ max: number;
175
+ step?: number;
176
+ }
177
+
178
+ /** Select option for NAPI */
179
+ export interface SelectOptionNapi {
180
+ label: string;
181
+ value: any;
182
+ }
183
+
184
+ /** Transform Art to Storybook CSF 3.0 */
185
+ export declare function artToCsf(
186
+ source: string,
187
+ options?: ArtParseOptionsNapi | undefined | null,
188
+ ): CsfOutputNapi;
189
+
190
+ /** Format a Vue SFC source string. */
191
+ export declare function formatSfc(
192
+ source: string,
193
+ options?: FormatOptionsNapi | undefined | null,
194
+ ): FormatResultNapi;
195
+
196
+ /** Generate catalog from multiple Art sources (high-performance batch) */
197
+ export declare function generateArtCatalog(
198
+ sources: Array<string>,
199
+ docOptions?: DocOptionsNapi | undefined | null,
200
+ ): CatalogOutputNapi;
201
+
202
+ /** Generate component documentation from Art source */
203
+ export declare function generateArtDoc(
204
+ source: string,
205
+ artOptions?: ArtParseOptionsNapi | undefined | null,
206
+ docOptions?: DocOptionsNapi | undefined | null,
207
+ ): DocOutputNapi;
208
+
209
+ /** Batch generate docs with parallel processing */
210
+ export declare function generateArtDocsBatch(
211
+ sources: Array<string>,
212
+ docOptions?: DocOptionsNapi | undefined | null,
213
+ ): Array<DocOutputNapi>;
214
+
215
+ /** Generate props palette from Art source */
216
+ export declare function generateArtPalette(
217
+ source: string,
218
+ artOptions?: ArtParseOptionsNapi | undefined | null,
219
+ paletteOptions?: PaletteOptionsNapi | undefined | null,
220
+ ): PaletteOutputNapi;
221
+
222
+ /** Generate a Vue SFC `.d.ts` declaration from Croquis analysis. */
223
+ export declare function generateDeclaration(
224
+ source: string,
225
+ options?: DeclarationOptionsNapi | undefined | null,
226
+ ): DeclarationResultNapi;
227
+
228
+ /** Generate .art.vue variants from component prop definitions */
229
+ export declare function generateVariants(
230
+ componentPath: string,
231
+ props: Array<PropDefinitionNapi>,
232
+ config?: AutogenConfigNapi | undefined | null,
233
+ ): AutogenOutputNapi;
234
+
235
+ /** Parse Art file (*.art.vue) */
236
+ export declare function parseArt(
237
+ source: string,
238
+ options?: ArtParseOptionsNapi | undefined | null,
239
+ ): ArtDescriptorNapi;
package/types/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+
3
+ /** Run the Rust Vize CLI with argv-style arguments. */
4
+ export declare function runCli(args: Array<string>): void;
@@ -0,0 +1,66 @@
1
+ /* eslint-disable */
2
+
3
+ /** Compile result */
4
+ export interface CompileResult {
5
+ /** Generated code */
6
+ code: string;
7
+ /** Preamble code (imports) */
8
+ preamble: string;
9
+ /** AST (serialized as JSON) */
10
+ ast: any;
11
+ /** Source map */
12
+ map?: any;
13
+ /** Used helpers */
14
+ helpers: Array<string>;
15
+ /** Template strings for Vapor mode static parts */
16
+ templates?: Array<string>;
17
+ }
18
+
19
+ /** Compiler options for bindings */
20
+ export interface CompilerOptions {
21
+ /** Output mode: "module" or "function" */
22
+ mode?: string;
23
+ /** Whether to prefix identifiers */
24
+ prefixIdentifiers?: boolean;
25
+ /** Whether to hoist static nodes */
26
+ hoistStatic?: boolean;
27
+ /** Whether to cache event handlers */
28
+ cacheHandlers?: boolean;
29
+ /** Scope ID for scoped CSS */
30
+ scopeId?: string;
31
+ /** Whether in SSR mode */
32
+ ssr?: boolean;
33
+ /** Whether to generate source map */
34
+ sourceMap?: boolean;
35
+ /** Filename for source map */
36
+ filename?: string;
37
+ /** Output mode: "vdom" or "vapor" */
38
+ outputMode?: string;
39
+ /** Whether the template contains TypeScript */
40
+ isTs?: boolean;
41
+ /** Whether the template targets a custom renderer instead of the DOM. */
42
+ customRenderer?: boolean;
43
+ /**
44
+ * Script extension handling: "preserve" (keep TypeScript) or "downcompile" (transpile to JS)
45
+ * Defaults to "downcompile"
46
+ */
47
+ scriptExt?: string;
48
+ }
49
+
50
+ /** Compile Vue template to VDom render function */
51
+ export declare function compile(
52
+ template: string,
53
+ options?: CompilerOptions | undefined | null,
54
+ ): CompileResult;
55
+
56
+ /** Compile Vue template to Vapor mode */
57
+ export declare function compileVapor(
58
+ template: string,
59
+ options?: CompilerOptions | undefined | null,
60
+ ): CompileResult;
61
+
62
+ /** Parse template to AST only */
63
+ export declare function parseTemplate(
64
+ template: string,
65
+ options?: CompilerOptions | undefined | null,
66
+ ): any;
package/types/css.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ /* eslint-disable */
2
+
3
+ /** CSS compile options for NAPI */
4
+ export interface CssCompileOptionsNapi {
5
+ /** Filename for error reporting */
6
+ filename?: string;
7
+ /** Whether to apply scoped CSS transformation */
8
+ scoped?: boolean;
9
+ /** Scope ID for scoped CSS (e.g., "data-v-abc123"). Must be the full attribute name. */
10
+ scopeId?: string;
11
+ /** Whether to generate source maps */
12
+ sourceMap?: boolean;
13
+ /** Whether to minify the output */
14
+ minify?: boolean;
15
+ /** Whether to enable CSS Modules transforms */
16
+ cssModules?: boolean;
17
+ /** Whether to enable custom media query resolution */
18
+ customMedia?: boolean;
19
+ /** Browser targets for autoprefixing */
20
+ targets?: CssTargetsNapi;
21
+ }
22
+
23
+ /** CSS compile result for NAPI */
24
+ export interface CssCompileResultNapi {
25
+ /** Compiled CSS code */
26
+ code: string;
27
+ /** Source map (if requested) */
28
+ map?: string;
29
+ /** CSS variables found (from v-bind()) */
30
+ cssVars: Array<string>;
31
+ /** Errors during compilation */
32
+ errors: Array<string>;
33
+ /** Warnings during compilation */
34
+ warnings: Array<string>;
35
+ }
36
+
37
+ /** Browser targets for CSS autoprefixing */
38
+ export interface CssTargetsNapi {
39
+ chrome?: number;
40
+ firefox?: number;
41
+ safari?: number;
42
+ edge?: number;
43
+ ios?: number;
44
+ android?: number;
45
+ }
46
+
47
+ /**
48
+ * Compile a CSS string with scoped CSS, v-bind() extraction, and optional minification.
49
+ * Unlike `compileSfc`, the `scopeId` is used as-is without stripping the "data-v-" prefix.
50
+ * Callers must pass the full attribute name (e.g., "data-v-abc123").
51
+ */
52
+ export declare function compileCss(
53
+ source: string,
54
+ options?: CssCompileOptionsNapi | undefined | null,
55
+ ): CssCompileResultNapi;