vize 0.48.0 → 0.52.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.
@@ -1,439 +0,0 @@
1
- //#region src/types/compiler.d.ts
2
- /**
3
- * Compiler configuration
4
- */
5
- interface CompilerConfig {
6
- /**
7
- * Compilation mode
8
- * @default 'module'
9
- */
10
- mode?: "module" | "function";
11
- /**
12
- * Enable Vapor mode compilation
13
- * @default false
14
- */
15
- vapor?: boolean;
16
- /**
17
- * Enable SSR mode
18
- * @default false
19
- */
20
- ssr?: boolean;
21
- /**
22
- * Enable source map generation
23
- * @default true in development, false in production
24
- */
25
- sourceMap?: boolean;
26
- /**
27
- * Prefix template identifiers with _ctx
28
- * @default false
29
- */
30
- prefixIdentifiers?: boolean;
31
- /**
32
- * Hoist static nodes
33
- * @default true
34
- */
35
- hoistStatic?: boolean;
36
- /**
37
- * Cache v-on handlers
38
- * @default true
39
- */
40
- cacheHandlers?: boolean;
41
- /**
42
- * Enable TypeScript parsing in <script> blocks
43
- * @default true
44
- */
45
- isTs?: boolean;
46
- /**
47
- * Script file extension for generated output
48
- * @default 'ts'
49
- */
50
- scriptExt?: "ts" | "js";
51
- /**
52
- * Module name for runtime imports
53
- * @default 'vue'
54
- */
55
- runtimeModuleName?: string;
56
- /**
57
- * Global variable name for runtime (IIFE builds)
58
- * @default 'Vue'
59
- */
60
- runtimeGlobalName?: string;
61
- }
62
- /**
63
- * Vite plugin configuration
64
- */
65
- interface VitePluginConfig {
66
- /**
67
- * Files to include in compilation
68
- * @default /\.vue$/
69
- */
70
- include?: string | RegExp | (string | RegExp)[];
71
- /**
72
- * Files to exclude from compilation
73
- * @default /node_modules/
74
- */
75
- exclude?: string | RegExp | (string | RegExp)[];
76
- /**
77
- * Glob patterns to scan for .vue files during pre-compilation
78
- * @default ['**\/*.vue']
79
- */
80
- scanPatterns?: string[];
81
- /**
82
- * Glob patterns to ignore during pre-compilation
83
- * @default ['node_modules/**', 'dist/**', '.git/**']
84
- */
85
- ignorePatterns?: string[];
86
- }
87
- //#endregion
88
- //#region src/types/tools.d.ts
89
- /**
90
- * Linter configuration
91
- */
92
- interface LinterConfig {
93
- /**
94
- * Enable linting
95
- */
96
- enabled?: boolean;
97
- /**
98
- * Built-in lint preset
99
- * @default 'happy-path'
100
- */
101
- preset?: LintPreset;
102
- /**
103
- * Rules to enable/disable
104
- */
105
- rules?: Record<string, RuleSeverity>;
106
- /**
107
- * Category-level severity overrides
108
- */
109
- categories?: Partial<Record<RuleCategory, RuleSeverity>>;
110
- }
111
- /**
112
- * Type checker configuration
113
- */
114
- interface TypeCheckerConfig {
115
- /**
116
- * Enable type checking
117
- * @default false
118
- */
119
- enabled?: boolean;
120
- /**
121
- * Enable strict mode
122
- * @default false
123
- */
124
- strict?: boolean;
125
- /**
126
- * Check component props
127
- * @default true
128
- */
129
- checkProps?: boolean;
130
- /**
131
- * Check component emits
132
- * @default true
133
- */
134
- checkEmits?: boolean;
135
- /**
136
- * Check template bindings
137
- * @default true
138
- */
139
- checkTemplateBindings?: boolean;
140
- /**
141
- * Path to tsconfig.json
142
- * @default auto-detected
143
- */
144
- tsconfig?: string;
145
- /**
146
- * Path to the Corsa binary
147
- */
148
- corsaPath?: string;
149
- }
150
- /**
151
- * Formatter configuration
152
- */
153
- interface FormatterConfig {
154
- /**
155
- * Max line width
156
- * @default 80
157
- */
158
- printWidth?: number;
159
- /**
160
- * Indentation width
161
- * @default 2
162
- */
163
- tabWidth?: number;
164
- /**
165
- * Use tabs for indentation
166
- * @default false
167
- */
168
- useTabs?: boolean;
169
- /**
170
- * Print semicolons
171
- * @default true
172
- */
173
- semi?: boolean;
174
- /**
175
- * Use single quotes
176
- * @default false
177
- */
178
- singleQuote?: boolean;
179
- /**
180
- * Trailing commas
181
- * @default 'all'
182
- */
183
- trailingComma?: "all" | "none" | "es5";
184
- }
185
- /**
186
- * LSP configuration
187
- */
188
- interface LspConfig {
189
- /**
190
- * Enable LSP
191
- * @default true
192
- */
193
- enabled?: boolean;
194
- /**
195
- * Enable diagnostics
196
- * @default true
197
- */
198
- diagnostics?: boolean;
199
- /**
200
- * Enable completions
201
- * @default true
202
- */
203
- completion?: boolean;
204
- /**
205
- * Enable hover information
206
- * @default true
207
- */
208
- hover?: boolean;
209
- /**
210
- * Enable go-to-definition
211
- * @default true
212
- */
213
- definition?: boolean;
214
- /**
215
- * Enable formatting via LSP
216
- * @default true
217
- */
218
- formatting?: boolean;
219
- /**
220
- * Enable code actions
221
- * @default true
222
- */
223
- codeActions?: boolean;
224
- /**
225
- * Use Corsa for type checking in LSP
226
- * @default false
227
- */
228
- corsa?: boolean;
229
- }
230
- //#endregion
231
- //#region src/types/musea.d.ts
232
- /**
233
- * VRT (Visual Regression Testing) configuration for Musea
234
- */
235
- interface MuseaVrtConfig {
236
- /**
237
- * Threshold for pixel comparison (0-1)
238
- * @default 0.1
239
- */
240
- threshold?: number;
241
- /**
242
- * Output directory for screenshots
243
- * @default '__musea_snapshots__'
244
- */
245
- outDir?: string;
246
- /**
247
- * Viewport sizes
248
- */
249
- viewports?: Array<{
250
- width: number;
251
- height: number;
252
- name?: string;
253
- }>;
254
- }
255
- /**
256
- * A11y configuration for Musea
257
- */
258
- interface MuseaA11yConfig {
259
- /**
260
- * Enable a11y checking
261
- * @default false
262
- */
263
- enabled?: boolean;
264
- /**
265
- * Axe-core rules to enable/disable
266
- */
267
- rules?: Record<string, boolean>;
268
- }
269
- /**
270
- * Autogen configuration for Musea
271
- */
272
- interface MuseaAutogenConfig {
273
- /**
274
- * Enable auto-generation of variants
275
- * @default false
276
- */
277
- enabled?: boolean;
278
- /**
279
- * Max variants to generate per component
280
- * @default 10
281
- */
282
- maxVariants?: number;
283
- }
284
- /**
285
- * Musea component gallery configuration
286
- */
287
- interface MuseaConfig {
288
- /**
289
- * Glob patterns for art files
290
- * @default ['**\/*.art.vue']
291
- */
292
- include?: string[];
293
- /**
294
- * Glob patterns to exclude
295
- * @default ['node_modules/**', 'dist/**']
296
- */
297
- exclude?: string[];
298
- /**
299
- * Base path for gallery
300
- * @default '/__musea__'
301
- */
302
- basePath?: string;
303
- /**
304
- * Enable Storybook compatibility
305
- * @default false
306
- */
307
- storybookCompat?: boolean;
308
- /**
309
- * Enable inline art detection in .vue files
310
- * @default false
311
- */
312
- inlineArt?: boolean;
313
- /**
314
- * VRT configuration
315
- */
316
- vrt?: MuseaVrtConfig;
317
- /**
318
- * A11y configuration
319
- */
320
- a11y?: MuseaA11yConfig;
321
- /**
322
- * Autogen configuration
323
- */
324
- autogen?: MuseaAutogenConfig;
325
- }
326
- //#endregion
327
- //#region src/types/loader.d.ts
328
- /**
329
- * Global type declaration
330
- */
331
- interface GlobalTypeDeclaration {
332
- /**
333
- * TypeScript type string
334
- */
335
- type: string;
336
- /**
337
- * Default value
338
- */
339
- defaultValue?: string;
340
- }
341
- /**
342
- * Global types configuration
343
- */
344
- type GlobalTypesConfig = Record<string, GlobalTypeDeclaration | string>;
345
- /**
346
- * Options for loading vize.config file
347
- */
348
- interface LoadConfigOptions {
349
- /**
350
- * Config file search mode
351
- * - 'root': Search only in the specified root directory
352
- * - 'auto': Search from cwd upward until finding a config file
353
- * - 'none': Don't load config file
354
- * @default 'root'
355
- */
356
- mode?: "root" | "auto" | "none";
357
- /**
358
- * Custom config file path (overrides automatic search)
359
- */
360
- configFile?: string;
361
- /**
362
- * Config environment for dynamic config resolution
363
- */
364
- env?: ConfigEnv;
365
- }
366
- //#endregion
367
- //#region src/types/core.d.ts
368
- type MaybePromise<T> = T | Promise<T>;
369
- interface ConfigEnv {
370
- mode: string;
371
- command: "serve" | "build" | "check" | "lint" | "fmt";
372
- isSsrBuild?: boolean;
373
- }
374
- type UserConfigExport = VizeConfig | ((env: ConfigEnv) => MaybePromise<VizeConfig>);
375
- type RuleSeverity = "off" | "warn" | "error";
376
- type RuleCategory = "correctness" | "suspicious" | "style" | "perf" | "a11y" | "security";
377
- type LintPreset = "happy-path" | "opinionated" | "essential" | "nuxt";
378
- /**
379
- * Vize configuration options
380
- */
381
- interface VizeConfig {
382
- /**
383
- * JSON Schema reference for editor autocompletion.
384
- */
385
- $schema?: string;
386
- /**
387
- * Vue compiler options
388
- */
389
- compiler?: CompilerConfig;
390
- /**
391
- * Vite plugin options
392
- */
393
- vite?: VitePluginConfig;
394
- /**
395
- * Linter options
396
- */
397
- linter?: LinterConfig;
398
- /**
399
- * Type checker options
400
- */
401
- typeChecker?: TypeCheckerConfig;
402
- /**
403
- * Formatter options
404
- */
405
- formatter?: FormatterConfig;
406
- /**
407
- * LSP options
408
- */
409
- lsp?: LspConfig;
410
- /**
411
- * Musea component gallery options
412
- */
413
- musea?: MuseaConfig;
414
- /**
415
- * Global type declarations
416
- */
417
- globalTypes?: GlobalTypesConfig;
418
- }
419
- //#endregion
420
- //#region src/config.d.ts
421
- declare const CONFIG_FILE_NAMES: readonly ["vize.config.ts", "vize.config.js", "vize.config.mjs", "vize.config.pkl", "vize.config.json"];
422
- declare const VIZE_CONFIG_JSON_SCHEMA_PATH: string;
423
- declare const VIZE_CONFIG_PKL_SCHEMA_PATH: string;
424
- /**
425
- * Define a Vize configuration with type checking.
426
- * Accepts a plain object or a function that receives ConfigEnv.
427
- */
428
- declare function defineConfig(config: UserConfigExport): UserConfigExport;
429
- /**
430
- * Load `vize.config.*` from the specified directory.
431
- */
432
- declare function loadConfig(root: string, options?: LoadConfigOptions): Promise<VizeConfig | null>;
433
- /**
434
- * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
435
- */
436
- declare function normalizeGlobalTypes(config: GlobalTypesConfig): Record<string, GlobalTypeDeclaration>;
437
- //#endregion
438
- export { LspConfig as C, VitePluginConfig as E, LinterConfig as S, CompilerConfig as T, MuseaA11yConfig as _, loadConfig as a, MuseaVrtConfig as b, LintPreset as c, RuleSeverity as d, UserConfigExport as f, LoadConfigOptions as g, GlobalTypesConfig as h, defineConfig as i, MaybePromise as l, GlobalTypeDeclaration as m, VIZE_CONFIG_JSON_SCHEMA_PATH as n, normalizeGlobalTypes as o, VizeConfig as p, VIZE_CONFIG_PKL_SCHEMA_PATH as r, ConfigEnv as s, CONFIG_FILE_NAMES as t, RuleCategory as u, MuseaAutogenConfig as v, TypeCheckerConfig as w, FormatterConfig as x, MuseaConfig as y };
439
- //# sourceMappingURL=config-tYKh_ZMu.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-tYKh_ZMu.d.mts","names":[],"sources":["../src/types/compiler.ts","../src/types/tools.ts","../src/types/musea.ts","../src/types/loader.ts","../src/types/core.ts","../src/config.ts"],"mappings":";;AAOA;;UAAiB,cAAA;EAAc;;;;EAK7B,IAAA;EAwBA;;;;EAlBA,KAAA;EAgDA;;;;EA1CA,GAAA;EA0D+B;;;;EApD/B,SAAA;EA+DsC;;;;EAzDtC,iBAAA;EAmDsC;;;;EA7CtC,WAAA;EA+DA;;;;EAzDA,aAAA;;ACvCF;;;ED6CE,IAAA;EC9BuB;;;;EDoCvB,SAAA;EC/Ba;;;;EDqCb,iBAAA;EC/CS;;;;EDqDT,iBAAA;AAAA;;;;UAUe,gBAAA;ECrDuC;AAUxD;;;EDgDE,OAAA,YAAmB,MAAA,aAAmB,MAAA;EC3CtC;;;;EDiDA,OAAA,YAAmB,MAAA,aAAmB,MAAA;ECnBtC;;;;EDyBA,YAAA;ECV8B;;;;EDgB9B,cAAA;AAAA;;;AAlGF;;;AAAA,UCEiB,YAAA;EDGf;;;ECCA,OAAA;EDuBA;;;;ECjBA,MAAA,GAAS,UAAA;ED+CT;;;EC1CA,KAAA,GAAQ,MAAA,SAAe,YAAA;ED0DR;;;ECrDf,UAAA,GAAa,OAAA,CAAQ,MAAA,CAAO,YAAA,EAAc,YAAA;AAAA;;;;UAU3B,iBAAA;EDgDf;;;;EC3CA,OAAA;EDiDsC;;;;EC3CtC,MAAA;;;;AAzCF;EA+CE,UAAA;;;;;EAMA,UAAA;EAjC0C;;;;EAuC1C,qBAAA;EAvDA;;;;EA6DA,QAAA;EAlDuB;;;EAuDv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zCI,YAAA,MAAkB,CAAA,GAAI,OAAA,CAAQ,CAAA;AAAA,UAEzB,SAAA;EACf,IAAA;EACA,OAAA;EACA,UAAA;AAAA;AAAA,KAGU,gBAAA,GAAmB,UAAA,KAAe,GAAA,EAAK,SAAA,KAAc,YAAA,CAAa,UAAA;AAAA,KAMlE,YAAA;AAAA,KAEA,YAAA;AAAA,KAEA,UAAA;;;;UASK,UAAA;EJ6CgB;;;EIzC/B,OAAA;EJoDmB;;;EI/CnB,QAAA,GAAW,cAAA;EJyCX;;;EIpCA,IAAA,GAAO,gBAAA;EJ0CY;;;EIrCnB,MAAA,GAAS,YAAA;EJiDK;;;EI5Cd,WAAA,GAAc,iBAAA;;AHpDhB;;EGyDE,SAAA,GAAY,eAAA;EH/CH;;;EGoDT,GAAA,GAAM,SAAA;EH1CoC;;;EG+C1C,KAAA,GAAQ,WAAA;EH/CY;;;EGoDpB,WAAA,GAAc,iBAAA;AAAA;;;cCnEH,iBAAA;AAAA,cAeA,4BAAA;AAAA,cAMA,2BAAA;;;;;iBAMG,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,gBAAA;;;;iBAOlC,UAAA,CACpB,IAAA,UACA,OAAA,GAAS,iBAAA,GACR,OAAA,CAAQ,UAAA;;;;iBA2LK,oBAAA,CACd,MAAA,EAAQ,iBAAA,GACP,MAAA,SAAe,qBAAA"}
package/dist/config.d.mts DELETED
@@ -1,2 +0,0 @@
1
- import { a as loadConfig, i as defineConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, r as VIZE_CONFIG_PKL_SCHEMA_PATH, t as CONFIG_FILE_NAMES } from "./config-tYKh_ZMu.mjs";
2
- export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
package/dist/config.mjs DELETED
@@ -1,156 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { execFileSync } from "node:child_process";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
5
- import { transform } from "oxc-transform";
6
- //#region src/config.ts
7
- const CONFIG_FILE_NAMES = [
8
- "vize.config.ts",
9
- "vize.config.js",
10
- "vize.config.mjs",
11
- "vize.config.pkl",
12
- "vize.config.json"
13
- ];
14
- const DEFAULT_CONFIG_ENV = {
15
- mode: "development",
16
- command: "serve"
17
- };
18
- const PACKAGE_ROOT = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
19
- const VIZE_CONFIG_JSON_SCHEMA_PATH = path.join(PACKAGE_ROOT, "schemas", "vize.config.schema.json");
20
- const VIZE_CONFIG_PKL_SCHEMA_PATH = path.join(PACKAGE_ROOT, "pkl", "vize.pkl");
21
- /**
22
- * Define a Vize configuration with type checking.
23
- * Accepts a plain object or a function that receives ConfigEnv.
24
- */
25
- function defineConfig(config) {
26
- return config;
27
- }
28
- /**
29
- * Load `vize.config.*` from the specified directory.
30
- */
31
- async function loadConfig(root, options = {}) {
32
- const { mode = "root", configFile, env } = options;
33
- if (mode === "none") return null;
34
- if (configFile) {
35
- const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);
36
- if (fs.existsSync(absolutePath)) return loadConfigFile(absolutePath, env);
37
- return null;
38
- }
39
- if (mode === "auto") {
40
- const configPath = findConfigFileAuto(root);
41
- if (!configPath) return null;
42
- return loadConfigFile(configPath, env);
43
- }
44
- const configPath = findConfigFileInDir(root);
45
- if (!configPath) return null;
46
- return loadConfigFile(configPath, env);
47
- }
48
- function findConfigFileInDir(dir) {
49
- for (const name of CONFIG_FILE_NAMES) {
50
- const filePath = path.join(dir, name);
51
- if (fs.existsSync(filePath)) return filePath;
52
- }
53
- return null;
54
- }
55
- function findConfigFileAuto(startDir) {
56
- let currentDir = path.resolve(startDir);
57
- while (true) {
58
- const configPath = findConfigFileInDir(currentDir);
59
- if (configPath) return configPath;
60
- const parentDir = path.dirname(currentDir);
61
- if (parentDir === currentDir) return null;
62
- currentDir = parentDir;
63
- }
64
- }
65
- async function loadConfigFile(filePath, env) {
66
- if (!fs.existsSync(filePath)) return null;
67
- const ext = path.extname(filePath);
68
- if (ext === ".json") return parseJsonConfig(fs.readFileSync(filePath, "utf-8"), filePath);
69
- if (ext === ".pkl") return loadPklConfig(filePath);
70
- if (ext === ".ts") return loadTypeScriptConfig(filePath, env);
71
- return loadESMConfig(filePath, env);
72
- }
73
- async function resolveConfigExport(exported, env) {
74
- if (typeof exported === "function") return exported(env ?? DEFAULT_CONFIG_ENV);
75
- return exported;
76
- }
77
- async function loadTypeScriptConfig(filePath, env) {
78
- const result = transform(filePath, fs.readFileSync(filePath, "utf-8"), { typescript: { onlyRemoveTypeImports: true } });
79
- const tempFile = filePath.replace(/\.ts$/, `.temp.${Date.now()}.mjs`);
80
- fs.writeFileSync(tempFile, result.code);
81
- try {
82
- const module = await importFresh(tempFile);
83
- return resolveConfigExport(module.default || module, env);
84
- } finally {
85
- fs.rmSync(tempFile, { force: true });
86
- }
87
- }
88
- async function loadESMConfig(filePath, env) {
89
- const module = await importFresh(filePath);
90
- return resolveConfigExport(module.default || module, env);
91
- }
92
- function loadPklConfig(filePath) {
93
- try {
94
- return parseJsonConfig(execFileSync("pkl", [
95
- "eval",
96
- "--format",
97
- "json",
98
- filePath
99
- ], {
100
- cwd: path.dirname(filePath),
101
- encoding: "utf-8",
102
- stdio: [
103
- "ignore",
104
- "pipe",
105
- "pipe"
106
- ]
107
- }), filePath);
108
- } catch (error) {
109
- throw new Error(`Failed to evaluate PKL config at ${filePath}. Make sure the 'pkl' CLI is installed and on PATH. ${getErrorMessage(error)}`);
110
- }
111
- }
112
- async function importFresh(filePath) {
113
- const fileUrl = pathToFileURL(filePath);
114
- fileUrl.searchParams.set("t", String(fs.statSync(filePath).mtimeMs));
115
- return import(fileUrl.href);
116
- }
117
- function parseJsonConfig(content, filePath) {
118
- try {
119
- return normalizeLoadedConfig(JSON.parse(content));
120
- } catch (error) {
121
- throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);
122
- }
123
- }
124
- function normalizeLoadedConfig(config) {
125
- return stripNullish(config) ?? {};
126
- }
127
- function stripNullish(value) {
128
- if (value === null) return;
129
- if (Array.isArray(value)) return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== void 0);
130
- if (typeof value === "object" && value !== null) {
131
- const result = {};
132
- for (const [key, entry] of Object.entries(value)) {
133
- const normalizedEntry = stripNullish(entry);
134
- if (normalizedEntry !== void 0) result[key] = normalizedEntry;
135
- }
136
- return result;
137
- }
138
- return value;
139
- }
140
- function getErrorMessage(error) {
141
- if (error instanceof Error) return error.message;
142
- return String(error);
143
- }
144
- /**
145
- * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
146
- */
147
- function normalizeGlobalTypes(config) {
148
- const result = {};
149
- for (const [key, value] of Object.entries(config)) if (typeof value === "string") result[key] = { type: value };
150
- else result[key] = value;
151
- return result;
152
- }
153
- //#endregion
154
- export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
155
-
156
- //# sourceMappingURL=config.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { execFileSync } from \"node:child_process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { transform } from \"oxc-transform\";\nimport type {\n VizeConfig,\n LoadConfigOptions,\n UserConfigExport,\n ConfigEnv,\n GlobalTypesConfig,\n GlobalTypeDeclaration,\n} from \"./types/index.js\";\n\nexport const CONFIG_FILE_NAMES = [\n \"vize.config.ts\",\n \"vize.config.js\",\n \"vize.config.mjs\",\n \"vize.config.pkl\",\n \"vize.config.json\",\n] as const;\n\nconst DEFAULT_CONFIG_ENV: ConfigEnv = {\n mode: \"development\",\n command: \"serve\",\n};\n\nconst PACKAGE_ROOT = path.resolve(fileURLToPath(new URL(\".\", import.meta.url)), \"..\");\n\nexport const VIZE_CONFIG_JSON_SCHEMA_PATH = path.join(\n PACKAGE_ROOT,\n \"schemas\",\n \"vize.config.schema.json\",\n);\n\nexport const VIZE_CONFIG_PKL_SCHEMA_PATH = path.join(PACKAGE_ROOT, \"pkl\", \"vize.pkl\");\n\n/**\n * Define a Vize configuration with type checking.\n * Accepts a plain object or a function that receives ConfigEnv.\n */\nexport function defineConfig(config: UserConfigExport): UserConfigExport {\n return config;\n}\n\n/**\n * Load `vize.config.*` from the specified directory.\n */\nexport async function loadConfig(\n root: string,\n options: LoadConfigOptions = {},\n): Promise<VizeConfig | null> {\n const { mode = \"root\", configFile, env } = options;\n\n if (mode === \"none\") {\n return null;\n }\n\n if (configFile) {\n const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);\n if (fs.existsSync(absolutePath)) {\n return loadConfigFile(absolutePath, env);\n }\n return null;\n }\n\n if (mode === \"auto\") {\n const configPath = findConfigFileAuto(root);\n if (!configPath) {\n return null;\n }\n return loadConfigFile(configPath, env);\n }\n\n const configPath = findConfigFileInDir(root);\n if (!configPath) {\n return null;\n }\n\n return loadConfigFile(configPath, env);\n}\n\nfunction findConfigFileInDir(dir: string): string | null {\n for (const name of CONFIG_FILE_NAMES) {\n const filePath = path.join(dir, name);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n return null;\n}\n\nfunction findConfigFileAuto(startDir: string): string | null {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const configPath = findConfigFileInDir(currentDir);\n if (configPath) {\n return configPath;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return null;\n }\n\n currentDir = parentDir;\n }\n}\n\nasync function loadConfigFile(filePath: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n\n const ext = path.extname(filePath);\n\n if (ext === \".json\") {\n const content = fs.readFileSync(filePath, \"utf-8\");\n return parseJsonConfig(content, filePath);\n }\n\n if (ext === \".pkl\") {\n return loadPklConfig(filePath);\n }\n\n if (ext === \".ts\") {\n return loadTypeScriptConfig(filePath, env);\n }\n\n return loadESMConfig(filePath, env);\n}\n\nasync function resolveConfigExport(\n exported: UserConfigExport,\n env?: ConfigEnv,\n): Promise<VizeConfig> {\n if (typeof exported === \"function\") {\n return exported(env ?? DEFAULT_CONFIG_ENV);\n }\n\n return exported;\n}\n\nasync function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const source = fs.readFileSync(filePath, \"utf-8\");\n const result = transform(filePath, source, {\n typescript: {\n onlyRemoveTypeImports: true,\n },\n });\n\n const tempFile = filePath.replace(/\\.ts$/, `.temp.${Date.now()}.mjs`);\n fs.writeFileSync(tempFile, result.code);\n\n try {\n const module = await importFresh(tempFile);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n } finally {\n fs.rmSync(tempFile, { force: true });\n }\n}\n\nasync function loadESMConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const module = await importFresh(filePath);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n}\n\nfunction loadPklConfig(filePath: string): VizeConfig {\n try {\n const output = execFileSync(\"pkl\", [\"eval\", \"--format\", \"json\", filePath], {\n cwd: path.dirname(filePath),\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return parseJsonConfig(output, filePath);\n } catch (error) {\n throw new Error(\n `Failed to evaluate PKL config at ${filePath}. Make sure the 'pkl' CLI is installed and on PATH. ${getErrorMessage(error)}`,\n );\n }\n}\n\nasync function importFresh(filePath: string): Promise<Record<string, unknown>> {\n const fileUrl = pathToFileURL(filePath);\n fileUrl.searchParams.set(\"t\", String(fs.statSync(filePath).mtimeMs));\n return import(fileUrl.href);\n}\n\nfunction parseJsonConfig(content: string, filePath: string): VizeConfig {\n try {\n return normalizeLoadedConfig(JSON.parse(content));\n } catch (error) {\n throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);\n }\n}\n\nfunction normalizeLoadedConfig(config: unknown): VizeConfig {\n const normalized = stripNullish(config);\n return (normalized ?? {}) as VizeConfig;\n}\n\nfunction stripNullish(value: unknown): unknown {\n if (value === null) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== undefined);\n }\n\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const normalizedEntry = stripNullish(entry);\n if (normalizedEntry !== undefined) {\n result[key] = normalizedEntry;\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects\n */\nexport function normalizeGlobalTypes(\n config: GlobalTypesConfig,\n): Record<string, GlobalTypeDeclaration> {\n const result: Record<string, GlobalTypeDeclaration> = {};\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"string\") {\n result[key] = { type: value };\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n"],"mappings":";;;;;;AAcA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAe,KAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAErF,MAAa,+BAA+B,KAAK,KAC/C,cACA,WACA,0BACD;AAED,MAAa,8BAA8B,KAAK,KAAK,cAAc,OAAO,WAAW;;;;;AAMrF,SAAgB,aAAa,QAA4C;AACvE,QAAO;;;;;AAMT,eAAsB,WACpB,MACA,UAA6B,EAAE,EACH;CAC5B,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ;AAE3C,KAAI,SAAS,OACX,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AAQ,MAAM,CACtB,QAAO,MAAM,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAA,EAAU;AAGzF,KAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAkC,EAAE;AAC1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;GAChD,MAAM,kBAAkB,aAAa,MAAM;AAC3C,OAAI,oBAAoB,KAAA,EACtB,QAAO,OAAO;;AAGlB,SAAO;;AAGT,QAAO;;AAGT,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,QAAO,OAAO,MAAM;;;;;AAMtB,SAAgB,qBACd,QACuC;CACvC,MAAM,SAAgD,EAAE;AACxD,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAC/C,KAAI,OAAO,UAAU,SACnB,QAAO,OAAO,EAAE,MAAM,OAAO;KAE7B,QAAO,OAAO;AAGlB,QAAO"}
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
- import { C as LspConfig, E as VitePluginConfig, S as LinterConfig, T as CompilerConfig, _ as MuseaA11yConfig, a as loadConfig, b as MuseaVrtConfig, c as LintPreset, d as RuleSeverity, f as UserConfigExport, g as LoadConfigOptions, h as GlobalTypesConfig, i as defineConfig, l as MaybePromise, m as GlobalTypeDeclaration, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, p as VizeConfig, r as VIZE_CONFIG_PKL_SCHEMA_PATH, s as ConfigEnv, t as CONFIG_FILE_NAMES, u as RuleCategory, v as MuseaAutogenConfig, w as TypeCheckerConfig, x as FormatterConfig, y as MuseaConfig } from "./config-tYKh_ZMu.mjs";
2
- export { CONFIG_FILE_NAMES, type CompilerConfig, type ConfigEnv, type FormatterConfig, type GlobalTypeDeclaration, type GlobalTypesConfig, type LintPreset, type LinterConfig, type LoadConfigOptions, type LspConfig, type MaybePromise, type MuseaA11yConfig, type MuseaAutogenConfig, type MuseaConfig, type MuseaVrtConfig, type RuleCategory, type RuleSeverity, type TypeCheckerConfig, type UserConfigExport, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, type VitePluginConfig, type VizeConfig, defineConfig, loadConfig, normalizeGlobalTypes };
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes } from "./config.mjs";
2
- export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };