vize 0.474.0 → 0.475.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,766 @@
1
+ import * as nodeModule from "node:module";
2
+ import { createRequire, globalPaths } from "node:module";
3
+ import * as fs$1 from "node:fs";
4
+ import { lstatSync, realpathSync } from "node:fs";
5
+ import * as path$1 from "node:path";
6
+ import { dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { randomUUID } from "node:crypto";
8
+ import { fileURLToPath, pathToFileURL } from "node:url";
9
+ import { execFileSync } from "node:child_process";
10
+ import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
11
+ import { tmpdir } from "node:os";
12
+ //#region src/config/pkl.js
13
+ const PACKAGE_ROOT$1 = path$1.resolve(fileURLToPath(new URL(".", import.meta.url)), "../..");
14
+ const DOCUMENTED_PKL_SCHEMA_IMPORT_RE = /^(\s*(?:amends|import)\s+)(["'])node_modules\/vize\/pkl\/(VizeConfig\.pkl|vize\.pkl)\2/gm;
15
+ /**
16
+ * Evaluate a `vize.config.pkl` file and return its JSON representation.
17
+ *
18
+ * The npm-facing loader keeps PKL execution in Node because it needs package
19
+ * resolution for `@pkl-community/pkl`, but all structural config normalization
20
+ * happens in Rust after this function returns. A missing PKL runtime returns
21
+ * `null` so config discovery can fall through to lower-priority formats; an
22
+ * evaluation failure throws because a present PKL config should not silently be
23
+ * ignored.
24
+ */
25
+ function loadPklConfigJson(filePath) {
26
+ const pklBin = findPklBinary();
27
+ if (!pklBin) {
28
+ console.warn("[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. Falling back to the next config format.");
29
+ return null;
30
+ }
31
+ const patchedFilePath = createPklConfigWithBundledSchemaImports(filePath);
32
+ const evalFilePath = patchedFilePath ?? filePath;
33
+ try {
34
+ return execFileSync(pklBin, [
35
+ "eval",
36
+ "-f",
37
+ "json",
38
+ evalFilePath
39
+ ], {
40
+ cwd: path$1.dirname(filePath),
41
+ encoding: "utf-8",
42
+ stdio: [
43
+ "ignore",
44
+ "pipe",
45
+ "pipe"
46
+ ],
47
+ timeout: 3e4
48
+ });
49
+ } catch (error) {
50
+ throw new Error(`Failed to evaluate vize PKL config at ${filePath}: ${getErrorMessage$1(error)}`);
51
+ } finally {
52
+ if (patchedFilePath) fs$1.rmSync(patchedFilePath, { force: true });
53
+ }
54
+ }
55
+ function findPklBinary() {
56
+ try {
57
+ const pklPkgPath = import.meta.resolve?.("@pkl-community/pkl");
58
+ if (pklPkgPath) {
59
+ const pklLibDir = path$1.dirname(fileURLToPath(pklPkgPath));
60
+ const pklPackageDir = path$1.dirname(pklLibDir);
61
+ const candidates = [
62
+ path$1.join(pklLibDir, "main.js"),
63
+ path$1.join(pklPackageDir, "pkl"),
64
+ path$1.join(pklPackageDir, "pkl.exe")
65
+ ];
66
+ for (const candidate of candidates) if (fs$1.existsSync(candidate)) try {
67
+ execFileSync(candidate, ["--version"], { stdio: "ignore" });
68
+ return candidate;
69
+ } catch {}
70
+ }
71
+ } catch {}
72
+ try {
73
+ execFileSync("pkl", ["--version"], { stdio: "ignore" });
74
+ return "pkl";
75
+ } catch {
76
+ return null;
77
+ }
78
+ }
79
+ function createPklConfigWithBundledSchemaImports(filePath) {
80
+ const configDir = path$1.dirname(filePath);
81
+ const source = fs$1.readFileSync(filePath, "utf-8");
82
+ let patched = false;
83
+ const content = source.replace(DOCUMENTED_PKL_SCHEMA_IMPORT_RE, (match, prefix, quote, schemaFile) => {
84
+ const projectSchemaPath = path$1.join(configDir, "node_modules", "vize", "pkl", schemaFile);
85
+ if (fs$1.existsSync(projectSchemaPath)) return match;
86
+ const bundledSchemaPath = path$1.join(PACKAGE_ROOT$1, "pkl", schemaFile);
87
+ if (!fs$1.existsSync(bundledSchemaPath)) return match;
88
+ patched = true;
89
+ return `${prefix}${quote}${pathToFileURL(bundledSchemaPath).href}${quote}`;
90
+ });
91
+ if (!patched) return null;
92
+ const tempFile = path$1.join(configDir, `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.pkl`);
93
+ fs$1.writeFileSync(tempFile, content, {
94
+ flag: "wx",
95
+ mode: 384
96
+ });
97
+ return tempFile;
98
+ }
99
+ function getErrorMessage$1(error) {
100
+ if (error instanceof Error) return error.message;
101
+ return String(error);
102
+ }
103
+ //#endregion
104
+ //#region ../../crates/vize_carton/src/config/loader/module-runtime.mjs
105
+ const configFailureArtifacts = /* @__PURE__ */ new WeakMap();
106
+ const configEvaluationTimings = /* @__PURE__ */ new WeakMap();
107
+ function beginConfigTiming(rows, phase, boundary) {
108
+ const start = rows ? performance.now() : void 0;
109
+ let finished = false;
110
+ if (boundary) boundary.active = true;
111
+ return () => {
112
+ if (start !== void 0 && !finished) {
113
+ const end = performance.now();
114
+ rows.push({
115
+ phase,
116
+ elapsedMs: end - start,
117
+ processId: process.pid
118
+ });
119
+ if (boundary) {
120
+ boundary.active = false;
121
+ if (boundary.resolvedAt !== void 0) {
122
+ rows.push({
123
+ phase: "public_load_until_owned_resolve",
124
+ elapsedMs: boundary.resolvedAt - start,
125
+ processId: process.pid
126
+ });
127
+ rows.push({
128
+ phase: "public_load_after_owned_resolve",
129
+ elapsedMs: end - boundary.resolvedAt,
130
+ processId: process.pid
131
+ });
132
+ }
133
+ }
134
+ finished = true;
135
+ }
136
+ };
137
+ }
138
+ async function beginPublicLoadProfile() {
139
+ const started = performance.now();
140
+ let session;
141
+ const close = () => {
142
+ try {
143
+ session?.disconnect();
144
+ } catch {}
145
+ };
146
+ try {
147
+ const { Session } = await import("node:inspector/promises");
148
+ session = new Session();
149
+ session.connect();
150
+ await session.post("Profiler.enable");
151
+ await session.post("Profiler.start");
152
+ const setupMs = performance.now() - started;
153
+ return async () => {
154
+ const stopping = performance.now();
155
+ try {
156
+ const { profile } = await session.post("Profiler.stop");
157
+ return {
158
+ status: "recorded",
159
+ setupMs,
160
+ stopMs: performance.now() - stopping,
161
+ profile
162
+ };
163
+ } catch (error) {
164
+ return {
165
+ status: "unavailable",
166
+ setupMs,
167
+ reason: String(error)
168
+ };
169
+ } finally {
170
+ close();
171
+ }
172
+ };
173
+ } catch (error) {
174
+ close();
175
+ return async () => ({
176
+ status: "unavailable",
177
+ reason: String(error)
178
+ });
179
+ }
180
+ }
181
+ function configModuleImportPath(configURL, windows = process.platform === "win32") {
182
+ return fileURLToPath(configURL, { windows });
183
+ }
184
+ async function importConfigModule(configPath, withoutVite) {
185
+ return (await importConfigModuleWithDependencies(configPath, nodeModule.registerHooks, withoutVite)).namespace;
186
+ }
187
+ function failedConfigModuleObservation(error) {
188
+ const paths = /* @__PURE__ */ new Set();
189
+ let complete = false;
190
+ if (error?.code === "ERR_MODULE_NOT_FOUND" && typeof error.url === "string") try {
191
+ const url = new URL(error.url);
192
+ if (url.protocol === "file:") {
193
+ paths.add(fileURLToPath(url));
194
+ complete = true;
195
+ }
196
+ } catch {}
197
+ const diagnostics = Array.isArray(error?.errors) ? error.errors : [];
198
+ if (diagnostics.length) complete = true;
199
+ for (const diagnostic of diagnostics) {
200
+ let requested = false;
201
+ if (diagnostic?.code !== "UNRESOLVED_IMPORT" || typeof diagnostic.id !== "string" || !isAbsolute(diagnostic.id) || typeof diagnostic.exporter !== "string") {
202
+ complete = false;
203
+ continue;
204
+ }
205
+ paths.add(diagnostic.id);
206
+ const request = diagnostic.exporter;
207
+ if (!(isAbsolute(request) || request.startsWith("./") || request.startsWith("../"))) {
208
+ complete = false;
209
+ continue;
210
+ }
211
+ if (/[%#?]/.test(request)) {
212
+ complete = false;
213
+ continue;
214
+ }
215
+ try {
216
+ const url = isAbsolute(request) ? pathToFileURL(request) : new URL(request, pathToFileURL(diagnostic.id));
217
+ if (url.protocol === "file:" && extname(url.pathname)) {
218
+ paths.add(fileURLToPath(url));
219
+ requested = true;
220
+ }
221
+ } catch {}
222
+ complete &&= requested;
223
+ }
224
+ return {
225
+ paths: [...paths],
226
+ complete
227
+ };
228
+ }
229
+ /** Keep runtime imports observable until the optional export evaluator settles. */
230
+ async function captureConfigEvaluation(load, configPath, registerModuleHooks, evaluate, privateDirectory, observeDependencies, ownedAdapter, timings, boundary) {
231
+ const files = new Set([configPath]);
232
+ const requestedFiles = /* @__PURE__ */ new Set();
233
+ let complete = true;
234
+ let moduleGraphLoaded = false;
235
+ const owners = new Set([pathToFileURL(configPath).href]);
236
+ const isPrivate = (path) => {
237
+ if (!privateDirectory) return false;
238
+ const inside = relative(privateDirectory, path);
239
+ return inside !== ".." && !inside.startsWith(`..${sep}`) && !isAbsolute(inside);
240
+ };
241
+ const hooks = typeof registerModuleHooks === "function" ? registerModuleHooks({ resolve(specifier, context, nextResolve) {
242
+ const result = nextResolve(specifier, context);
243
+ if (result.url.startsWith("file:")) {
244
+ const path = fileURLToPath(result.url);
245
+ if (boundary?.active && boundary.resolvedAt === void 0 && isPrivate(path)) boundary.resolvedAt = performance.now();
246
+ if (owners.has(result.url) || owners.has(context.parentURL) || isPrivate(path)) {
247
+ owners.add(result.url);
248
+ if (!isPrivate(path)) files.add(path);
249
+ if (owners.has(context.parentURL) && (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:"))) try {
250
+ const requested = new URL(specifier, context.parentURL);
251
+ if (requested.protocol === "file:") {
252
+ const requestedPath = fileURLToPath(requested);
253
+ if (extname(requestedPath) && !isPrivate(requestedPath)) requestedFiles.add(requestedPath);
254
+ }
255
+ } catch {}
256
+ }
257
+ }
258
+ return result;
259
+ } }) : void 0;
260
+ try {
261
+ const { namespace, dependencies = [] } = await load();
262
+ for (const path of dependencies) if (!isPrivate(path)) files.add(path);
263
+ moduleGraphLoaded = true;
264
+ const finish = beginConfigTiming(timings, "export_evaluation");
265
+ let value;
266
+ try {
267
+ value = evaluate ? await evaluate(namespace) : namespace;
268
+ } finally {
269
+ finish();
270
+ }
271
+ return {
272
+ namespace,
273
+ value,
274
+ dependencies: [...files]
275
+ };
276
+ } catch (error) {
277
+ if (ownedAdapter && error !== null && (typeof error === "object" || typeof error === "function")) configFailureArtifacts.set(error, [
278
+ [ownedAdapter, configPath],
279
+ [pathToFileURL(ownedAdapter).href, pathToFileURL(configPath).href],
280
+ [relative(dirname(configPath), ownedAdapter), relative(dirname(configPath), configPath)]
281
+ ]);
282
+ complete = false;
283
+ try {
284
+ const observed = failedConfigModuleObservation(error);
285
+ complete = observed.complete && (privateDirectory === void 0 || moduleGraphLoaded);
286
+ for (const path of observed.paths) if (!isPrivate(path)) files.add(path);
287
+ } catch {}
288
+ throw error;
289
+ } finally {
290
+ hooks?.deregister();
291
+ observeDependencies?.([...files, ...requestedFiles], complete);
292
+ }
293
+ }
294
+ /** Await evaluate(namespace) once before sealing its graph; retain the namespace unchanged. */
295
+ async function importConfigModuleWithDependencies(configPath, registerModuleHooks = nodeModule.registerHooks, withoutVite, evaluate, observeDependencies, beforeRead) {
296
+ const timings = process.env.VIZE_TRACE_EDITOR_PREPARATION === "1" ? [] : void 0;
297
+ const boundary = timings ? {
298
+ active: false,
299
+ resolvedAt: void 0
300
+ } : void 0;
301
+ const finishTotal = beginConfigTiming(timings, "module_total");
302
+ const finishSelection = beginConfigTiming(timings, "engine_selection_with_ack");
303
+ let selectionFinished = false;
304
+ let result;
305
+ const watchInputs = new Set([configPath]);
306
+ let complete = false;
307
+ const observe = (paths, observedComplete) => {
308
+ for (const path of paths) watchInputs.add(path);
309
+ complete = observedComplete;
310
+ };
311
+ try {
312
+ const configURL = pathToFileURL(configPath);
313
+ const require = createRequire(configURL);
314
+ const searchPaths = require.resolve.paths("vite") ?? [];
315
+ let candidate;
316
+ for (const directory of searchPaths.filter((path) => !globalPaths.includes(path))) {
317
+ const requested = join(directory, "vite");
318
+ watchInputs.add(requested);
319
+ await beforeRead?.([requested]);
320
+ if (lstatSync(requested, { throwIfNoEntry: false }) !== void 0) {
321
+ candidate = requested;
322
+ watchInputs.add(join(candidate, "package.json"));
323
+ break;
324
+ }
325
+ }
326
+ if (typeof registerModuleHooks !== "function") {
327
+ if (evaluate) throw new Error("Tracking imports while evaluating a Vite config requires Node.js 22.15 or newer. Upgrade Node.js; installed Vite alone cannot track runtime imports.");
328
+ if (candidate === void 0 && !withoutVite) throw new Error("Loading a Vite config without project Vite requires Node.js 22.15 or newer to track imported configuration files. Upgrade Node.js or install Vite in the project.");
329
+ }
330
+ if (candidate === void 0) {
331
+ finishSelection();
332
+ selectionFinished = true;
333
+ await beforeRead?.([configPath]);
334
+ result = await captureConfigEvaluation(async () => ({ namespace: await (withoutVite ? withoutVite(configURL) : import(configURL.href)) }), configPath, registerModuleHooks, evaluate, void 0, observe, void 0, timings);
335
+ return result;
336
+ }
337
+ const viteDirectory = realpathSync(candidate);
338
+ watchInputs.add(join(viteDirectory, "package.json"));
339
+ await beforeRead?.([join(candidate, "package.json"), join(viteDirectory, "package.json")]);
340
+ const resolvedEntry = require.resolve("vite");
341
+ watchInputs.add(resolvedEntry);
342
+ const viteEntry = realpathSync(resolvedEntry);
343
+ watchInputs.add(viteEntry);
344
+ const entryPath = relative(viteDirectory, viteEntry);
345
+ if (entryPath === ".." || entryPath.startsWith(`..${sep}`) || isAbsolute(entryPath)) throw new Error(`Resolved loader escapes selected project Vite: ${candidate} -> ${viteEntry}`);
346
+ await beforeRead?.([resolvedEntry, viteEntry]);
347
+ finishSelection();
348
+ selectionFinished = true;
349
+ const finishImport = beginConfigTiming(timings, "engine_import");
350
+ let loadConfigFromFile;
351
+ try {
352
+ ({loadConfigFromFile} = await import(pathToFileURL(viteEntry).href));
353
+ } finally {
354
+ finishImport();
355
+ }
356
+ const finishAdapter = beginConfigTiming(timings, "adapter_prepare");
357
+ let temporary;
358
+ try {
359
+ temporary = await realpath(await mkdtemp(join(tmpdir(), "vize-config-module-")));
360
+ } catch (error) {
361
+ finishAdapter();
362
+ throw error;
363
+ }
364
+ try {
365
+ const adapter = join(temporary, "config.mjs");
366
+ await writeFile(adapter, `import * as original from ${JSON.stringify(configModuleImportPath(configURL))};\nexport default { namespace: original };\n`, {
367
+ flag: "wx",
368
+ mode: 384
369
+ });
370
+ finishAdapter();
371
+ result = await captureConfigEvaluation(async () => {
372
+ const finishAck = beginConfigTiming(timings, "selected_before_read_ack");
373
+ try {
374
+ await beforeRead?.([configPath]);
375
+ } finally {
376
+ finishAck();
377
+ }
378
+ const finishProfile = timings ? await beginPublicLoadProfile() : void 0;
379
+ const finishLoad = beginConfigTiming(timings, "public_load", boundary);
380
+ let loaded;
381
+ try {
382
+ loaded = await loadConfigFromFile({
383
+ mode: "development",
384
+ command: "serve"
385
+ }, adapter, dirname(configPath), "silent", void 0, "bundle");
386
+ } finally {
387
+ finishLoad();
388
+ if (finishProfile) timings.find((row) => row.phase === "public_load").cpuProfile = await finishProfile();
389
+ }
390
+ if (!loaded) throw new Error(`Vite did not load the selected config: ${configPath}`);
391
+ return {
392
+ namespace: loaded.config.namespace,
393
+ dependencies: loaded.dependencies
394
+ };
395
+ }, configPath, registerModuleHooks, evaluate, temporary, observe, adapter, timings, boundary);
396
+ return result;
397
+ } catch (error) {
398
+ finishAdapter();
399
+ throw error;
400
+ } finally {
401
+ const finishCleanup = beginConfigTiming(timings, "adapter_cleanup");
402
+ try {
403
+ await rm(temporary, {
404
+ recursive: true,
405
+ force: true
406
+ });
407
+ } finally {
408
+ finishCleanup();
409
+ }
410
+ }
411
+ } catch (error) {
412
+ if (timings && error !== null && (typeof error === "object" || typeof error === "function")) configEvaluationTimings.set(error, timings);
413
+ throw error;
414
+ } finally {
415
+ if (!selectionFinished) finishSelection();
416
+ finishTotal();
417
+ if (timings && result) configEvaluationTimings.set(result, timings);
418
+ observeDependencies?.([...watchInputs], complete);
419
+ }
420
+ }
421
+ //#endregion
422
+ //#region ../../crates/vize_carton/src/config/loader/vite-runtime.mjs
423
+ const vueOptionSchema = JSON.parse("{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"compiler\":{\"$ref\":\"#/definitions/CompilerConfig\"},\"experimentals\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"boolean\"},{\"type\":\"object\",\"additionalProperties\":true},{\"type\":\"null\"}]}},\"dialect\":{\"type\":\"string\",\"enum\":[\"vue\",\"petite-vue\"]},\"vite\":{\"$ref\":\"#/definitions/VitePluginConfig\"},\"musea\":{\"$ref\":\"#/definitions/MuseaConfig\"},\"typeChecker\":{\"$ref\":\"#/definitions/TypeCheckerConfig\"},\"linter\":{\"$ref\":\"#/definitions/LinterConfig\"},\"formatter\":{\"$ref\":\"#/definitions/FormatterConfig\"},\"languageServer\":{\"$ref\":\"#/definitions/LanguageServerConfig\"},\"globalTypes\":{\"$ref\":\"#/definitions/GlobalTypesConfig\"},\"files\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignores\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"basePath\":{\"type\":\"string\"},\"lib\":{\"$ref\":\"#/definitions/LibConfig\"},\"version\":{\"$ref\":\"#/definitions/VueVersion\"},\"entries\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"basePath\":{\"type\":\"string\"},\"files\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignores\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"linter\":{\"$ref\":\"#/definitions/LinterConfig\"}},\"additionalProperties\":false}}},\"additionalProperties\":false,\"definitions\":{\"CompilerConfig\":{\"type\":\"object\",\"properties\":{\"mode\":{\"type\":\"string\",\"enum\":[\"module\",\"function\"]},\"vapor\":{\"type\":\"boolean\"},\"jsxMode\":{\"type\":\"string\",\"enum\":[\"vdom\",\"vapor\"]},\"jsxCompat\":{\"type\":\"string\",\"enum\":[\"native\",\"babel\"]},\"customRenderer\":{\"type\":\"boolean\"},\"customElements\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ssr\":{\"type\":\"boolean\"},\"templateSyntax\":{\"type\":\"string\",\"enum\":[\"standard\",\"strict\",\"quirks\"]},\"whitespace\":{\"type\":\"string\",\"enum\":[\"condense\",\"preserve\",\"vue2-line-breaks\",\"vue2-preserve\"]},\"sourceMap\":{\"type\":\"boolean\"},\"prefixIdentifiers\":{\"type\":\"boolean\"},\"hoistStatic\":{\"type\":\"boolean\"},\"cacheHandlers\":{\"type\":\"boolean\"},\"isTs\":{\"type\":\"boolean\"},\"scriptExt\":{\"type\":\"string\",\"enum\":[\"ts\",\"js\"]},\"runtimeModuleName\":{\"type\":\"string\"},\"runtimeGlobalName\":{\"type\":\"string\"},\"compatibility\":{\"$ref\":\"#/definitions/CompilerCompatibilityConfig\"}},\"additionalProperties\":false},\"CompilerCompatibilityConfig\":{\"type\":\"object\",\"properties\":{\"vueVersion\":{\"$ref\":\"#/definitions/VueVersion\"},\"hostCompiler\":{\"type\":\"boolean\"},\"scriptSetupInStandalone\":{\"type\":\"boolean\"},\"optionsApiVapor\":{\"type\":\"boolean\"},\"nuxtVersion\":{\"type\":\"integer\",\"enum\":[2,3,4]},\"webpackVersion\":{\"type\":\"integer\",\"enum\":[4,5]}},\"additionalProperties\":false},\"VueVersion\":{\"type\":\"string\",\"enum\":[\"3\",\"2.7\",\"2\",\"1\",\"0.11\",\"0.10\"]},\"VitePluginConfig\":{\"type\":\"object\",\"properties\":{\"include\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]},\"exclude\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]},\"scanPatterns\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignorePatterns\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"MuseaConfig\":{\"type\":\"object\",\"properties\":{\"include\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"exclude\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"basePath\":{\"type\":\"string\"},\"storybookCompat\":{\"type\":\"boolean\"},\"inlineArt\":{\"type\":\"boolean\"},\"vrt\":{\"$ref\":\"#/definitions/MuseaVrtConfig\"},\"a11y\":{\"$ref\":\"#/definitions/MuseaA11yConfig\"},\"autogen\":{\"$ref\":\"#/definitions/MuseaAutogenConfig\"}},\"additionalProperties\":false},\"MuseaVrtConfig\":{\"type\":\"object\",\"properties\":{\"threshold\":{\"type\":\"number\"},\"outDir\":{\"type\":\"string\"},\"viewports\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/MuseaViewport\"}}},\"additionalProperties\":false},\"MuseaViewport\":{\"type\":\"object\",\"properties\":{\"width\":{\"type\":\"integer\"},\"height\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"width\",\"height\"]},\"MuseaA11yConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"rules\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"boolean\"}}},\"additionalProperties\":false},\"MuseaAutogenConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"maxVariants\":{\"type\":\"integer\"}},\"additionalProperties\":false},\"TypeCheckerConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"strict\":{\"type\":\"boolean\"},\"checkProps\":{\"type\":\"boolean\"},\"checkEmits\":{\"type\":\"boolean\"},\"checkTemplateBindings\":{\"type\":\"boolean\"},\"checkReactivity\":{\"type\":\"boolean\"},\"checkSetupContext\":{\"type\":\"boolean\"},\"checkInvalidExports\":{\"type\":\"boolean\"},\"checkFallthroughAttrs\":{\"type\":\"boolean\"},\"optionsApi\":{\"type\":\"boolean\"},\"legacyVue2\":{\"type\":\"boolean\"},\"jsxTypecheck\":{\"type\":\"boolean\"},\"tsconfig\":{\"type\":\"string\"},\"corsaPath\":{\"type\":\"string\"},\"tsgoPath\":{\"type\":\"string\"},\"globalsFile\":{\"type\":\"string\"},\"servers\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":32},\"lspRequestTimeoutMs\":{\"type\":\"integer\",\"minimum\":1}},\"additionalProperties\":false},\"LinterConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"preset\":{\"type\":\"string\",\"enum\":[\"general-recommended\",\"general_recommended\",\"generalRecommended\",\"happy-path\",\"happy_path\",\"happy\",\"default\",\"recommended\",\"opinionated\",\"strict\",\"all\",\"essential\",\"incremental\",\"ecosystem\",\"nuxt\"]},\"typeAware\":{\"type\":\"boolean\"},\"crossFile\":{\"type\":\"boolean\"},\"crossFileTree\":{\"type\":\"boolean\"},\"crossFileComplexity\":{\"type\":\"boolean\"},\"strictReactivity\":{\"type\":\"boolean\"},\"maxWarnings\":{\"type\":\"integer\",\"minimum\":0},\"rules\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]}},\"ruleOptions\":{\"$ref\":\"#/definitions/LintRuleOptions\"},\"categories\":{\"type\":\"object\",\"properties\":{\"correctness\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"suspicious\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"style\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"perf\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"a11y\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"security\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]}},\"additionalProperties\":false}},\"additionalProperties\":false},\"LintRuleOptions\":{\"type\":\"object\",\"properties\":{\"script/define-props-destructuring\":{\"type\":\"object\",\"properties\":{\"destructure\":{\"type\":\"string\",\"enum\":[\"only-when-assigned\",\"always\",\"never\"]}},\"additionalProperties\":false},\"html/no-empty-palpable-content\":{\"type\":\"object\",\"properties\":{\"contentDirectives\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"type/strict-boolean-expressions\":{\"type\":\"object\",\"properties\":{\"allowString\":{\"type\":\"boolean\"},\"allowNumber\":{\"type\":\"boolean\"},\"allowNullableObject\":{\"type\":\"boolean\"},\"allowNullableBoolean\":{\"type\":\"boolean\"},\"allowNullableString\":{\"type\":\"boolean\"},\"allowNullableNumber\":{\"type\":\"boolean\"},\"allowNullableEnum\":{\"type\":\"boolean\"},\"allowAny\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"script/no-restricted-globals\":{\"$ref\":\"#/definitions/NoRestrictedGlobalsOptions\"},\"script/no-restricted-members\":{\"$ref\":\"#/definitions/NoRestrictedMembersOptions\"},\"vue/component-name-in-template-casing\":{\"type\":\"object\",\"properties\":{\"casing\":{\"type\":\"string\",\"enum\":[\"PascalCase\",\"kebab-case\"]},\"registeredComponentsOnly\":{\"type\":\"boolean\"},\"globals\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"script/custom-event-name-casing\":{\"type\":\"object\",\"properties\":{\"casing\":{\"type\":\"string\",\"enum\":[\"camelCase\",\"kebab-case\"]}},\"additionalProperties\":false},\"vue/no-mutating-props\":{\"type\":\"object\",\"properties\":{\"shallowOnly\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"vue/require-component-registration\":{\"type\":\"object\",\"properties\":{\"globals\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"vue/sfc-element-order\":{\"type\":\"object\",\"properties\":{\"order\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]}}},\"additionalProperties\":false},\"vue/html-self-closing\":{\"type\":\"object\",\"properties\":{\"html\":{\"type\":\"object\",\"properties\":{\"void\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"normal\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"component\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]}},\"additionalProperties\":false},\"svg\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"math\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]}},\"additionalProperties\":false},\"vue/v-on-event-hyphenation\":{\"type\":\"string\",\"enum\":[\"always\",\"never\"]},\"vue/attribute-hyphenation\":{\"type\":\"string\",\"enum\":[\"always\",\"never\"]},\"vue/valid-v-on\":{\"type\":\"object\",\"properties\":{\"modifiers\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"vue/valid-v-slot\":{\"type\":\"object\",\"properties\":{\"allowModifiers\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"musea/prefer-design-tokens\":{\"$ref\":\"#/definitions/MuseaPreferDesignTokensOptions\"}},\"additionalProperties\":false},\"NoRestrictedGlobalsOptions\":{\"type\":\"object\",\"properties\":{\"globals\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/RestrictedGlobal\"}}},\"additionalProperties\":false},\"RestrictedGlobal\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"message\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"name\"]},\"NoRestrictedMembersOptions\":{\"type\":\"object\",\"properties\":{\"members\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/RestrictedMember\"}}},\"additionalProperties\":false},\"RestrictedMember\":{\"type\":\"object\",\"properties\":{\"object\":{\"type\":\"string\"},\"property\":{\"type\":\"string\"},\"message\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"object\",\"property\"]},\"MuseaPreferDesignTokensOptions\":{\"type\":\"object\",\"properties\":{\"tokens\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/MuseaDesignToken\"}}},\"additionalProperties\":false},\"MuseaDesignToken\":{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"tier\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"path\",\"value\"]},\"FormatterConfig\":{\"type\":\"object\",\"properties\":{\"sortImports\":{\"oneOf\":[{\"type\":\"boolean\",\"enum\":[false]},{\"$ref\":\"#/definitions/SortImportsConfig\"}]},\"printWidth\":{\"type\":\"integer\"},\"tabWidth\":{\"type\":\"integer\"},\"useTabs\":{\"type\":\"boolean\"},\"semi\":{\"type\":\"boolean\"},\"singleQuote\":{\"type\":\"boolean\"},\"jsxSingleQuote\":{\"type\":\"boolean\"},\"trailingComma\":{\"type\":\"string\",\"enum\":[\"all\",\"none\",\"es5\"]},\"bracketSpacing\":{\"type\":\"boolean\"},\"bracketSameLine\":{\"type\":\"boolean\"},\"arrowParens\":{\"type\":\"string\",\"enum\":[\"always\",\"avoid\"]},\"endOfLine\":{\"type\":\"string\",\"enum\":[\"lf\",\"crlf\",\"cr\",\"auto\"]},\"quoteProps\":{\"type\":\"string\",\"enum\":[\"as-needed\",\"consistent\",\"preserve\"]},\"singleAttributePerLine\":{\"type\":\"boolean\"},\"vueIndentScriptAndStyle\":{\"type\":\"boolean\"},\"sortAttributes\":{\"type\":\"boolean\"},\"attributeSortOrder\":{\"type\":\"string\",\"enum\":[\"alphabetical\",\"as-written\"]},\"mergeBindAndNonBindAttrs\":{\"type\":\"boolean\"},\"maxAttributesPerLine\":{\"type\":\"integer\"},\"attributeGroups\":{\"type\":\"array\",\"items\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"normalizeDirectiveShorthands\":{\"type\":\"boolean\"},\"sortBlocks\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"SortImportsConfig\":{\"type\":\"object\",\"properties\":{\"partitionByNewline\":{\"type\":\"boolean\"},\"partitionByComment\":{\"type\":\"boolean\"},\"sortSideEffects\":{\"type\":\"boolean\"},\"order\":{\"type\":\"string\",\"enum\":[\"asc\",\"desc\"]},\"ignoreCase\":{\"type\":\"boolean\"},\"newlinesBetween\":{\"type\":\"boolean\"},\"internalPattern\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"groups\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}},{\"type\":\"object\",\"properties\":{\"newlinesBetween\":{\"type\":\"boolean\"}},\"additionalProperties\":false,\"required\":[\"newlinesBetween\"]}]}},\"customGroups\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ImportSortCustomGroup\"}}},\"additionalProperties\":false},\"ImportSortCustomGroup\":{\"type\":\"object\",\"properties\":{\"groupName\":{\"type\":\"string\"},\"elementNamePattern\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"selector\":{\"type\":\"string\"},\"modifiers\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false,\"required\":[\"groupName\"]},\"LanguageServerConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"lint\":{\"type\":\"boolean\"},\"diagnostics\":{\"type\":\"boolean\"},\"typecheck\":{\"type\":\"boolean\"},\"editor\":{\"type\":\"boolean\"},\"ecosystem\":{\"type\":\"boolean\"},\"crossFile\":{\"type\":\"boolean\"},\"legacyVue2\":{\"type\":\"boolean\"},\"completion\":{\"type\":\"boolean\"},\"signatureHelp\":{\"type\":\"boolean\"},\"hover\":{\"type\":\"boolean\"},\"definition\":{\"type\":\"boolean\"},\"references\":{\"type\":\"boolean\"},\"documentSymbols\":{\"type\":\"boolean\"},\"workspaceSymbols\":{\"type\":\"boolean\"},\"formatting\":{\"type\":\"boolean\"},\"codeActions\":{\"type\":\"boolean\"},\"rename\":{\"type\":\"boolean\"},\"codeLens\":{\"type\":\"boolean\"},\"semanticTokens\":{\"type\":\"boolean\"},\"documentLinks\":{\"type\":\"boolean\"},\"foldingRanges\":{\"type\":\"boolean\"},\"inlayHints\":{\"type\":\"boolean\"},\"fileRename\":{\"type\":\"boolean\"},\"corsa\":{\"type\":\"boolean\"},\"tsgo\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"GlobalTypesConfig\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"string\"},{\"$ref\":\"#/definitions/GlobalTypeDeclaration\"}]}},\"GlobalTypeDeclaration\":{\"type\":\"object\",\"properties\":{\"type\":{\"type\":\"string\"},\"defaultValue\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"type\"]},\"LibConfig\":{\"type\":\"object\",\"properties\":{\"dir\":{\"type\":\"string\"},\"uiDir\":{\"type\":\"string\"},\"composableDir\":{\"type\":\"string\"},\"lockfile\":{\"type\":\"string\"},\"registries\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"object\",\"properties\":{\"source\":{\"type\":\"string\"},\"dir\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"source\"]}]},\"propertyNames\":{\"pattern\":\"^@[a-z0-9][a-z0-9._-]*$\"}}},\"additionalProperties\":false}}}");
424
+ const sourceConfigKey = Symbol.for("@vizejs/vite-plugin/vite-plus/source");
425
+ function object(value) {
426
+ if (value === null || typeof value !== "object") return false;
427
+ const prototype = Object.getPrototypeOf(value);
428
+ return prototype === Object.prototype || prototype === null;
429
+ }
430
+ function merge(base, own) {
431
+ const result = { ...base };
432
+ for (const [key, value] of Object.entries(own)) result[key] = object(value) && object(result[key]) ? merge(result[key], value) : value;
433
+ return result;
434
+ }
435
+ async function resolveSource(value, env, parents = /* @__PURE__ */ new Set()) {
436
+ value = await value;
437
+ if (parents.has(value)) throw new Error("Circular Vue configuration source");
438
+ parents.add(value);
439
+ try {
440
+ if ((typeof value === "function" || object(value)) && sourceConfigKey in value) return await resolveSource(value[sourceConfigKey], env, parents);
441
+ const config = await (typeof value === "function" ? value(env) : value);
442
+ if (!object(config)) throw new Error("Vite config must export an object or a config function");
443
+ rejectLegacyConfig(config);
444
+ return config;
445
+ } finally {
446
+ parents.delete(value);
447
+ }
448
+ }
449
+ function rejectLegacyConfig(source) {
450
+ if (Object.hasOwn(source, "extends")) throw new Error("Custom config extends is no longer supported; use defineConfig(vpConfig).withVue(vueConfig)");
451
+ if (Object.hasOwn(source, "vize")) throw new Error("vize: configuration is no longer supported; move Vue settings to vue: in vite.config.*");
452
+ for (const key of [
453
+ "lint",
454
+ "fmt",
455
+ "pack"
456
+ ]) if ((Array.isArray(source[key]) ? source[key] : [source[key]]).some((value) => object(value) && Object.hasOwn(value, "vize"))) throw new Error(`${key}.vize is no longer supported; use ${key}.vue or the shared vue: settings`);
457
+ }
458
+ const VITE_CONFIG_FILE_NAMES = [
459
+ "vite.config.ts",
460
+ "vite.config.js",
461
+ "vite.config.mjs",
462
+ "vite.config.cjs",
463
+ "vite.config.mts",
464
+ "vite.config.cts"
465
+ ];
466
+ function isViteConfigFile(filePath) {
467
+ return /(?:^|[/\\])vite\.config\.(?:[cm]?[jt]s)$/.test(filePath);
468
+ }
469
+ /** Project workflows support JSX without an extra feature flag. Legacy config stays unchanged. */
470
+ function projectConfigDefaults() {
471
+ return { typeChecker: { jsxTypecheck: true } };
472
+ }
473
+ /** Resolve just the native settings from an ordinary Vite or Vite+ export. */
474
+ async function resolveViteConfigExport$1(exported, env, configDir) {
475
+ env ??= {
476
+ mode: "development",
477
+ command: "serve"
478
+ };
479
+ if (env.command !== "build" && env.command !== "serve") env = {
480
+ ...env,
481
+ command: "serve"
482
+ };
483
+ return projectViteConfigSource(await resolveSource(exported, env), env, configDir);
484
+ }
485
+ /** Project already evaluated settings; the owning adapter evaluates its Vite export once. */
486
+ async function projectViteConfigSource(source, env, configDir) {
487
+ if (!object(source)) throw new TypeError("Vite config source must be an object");
488
+ env ??= {
489
+ mode: "development",
490
+ command: "serve"
491
+ };
492
+ if (env.command !== "build" && env.command !== "serve") env = {
493
+ ...env,
494
+ command: "serve"
495
+ };
496
+ rejectLegacyConfig(source);
497
+ const selected = vueConfigOptions(source);
498
+ const canonical = selected === void 0 ? {} : flatVueOptions(selected);
499
+ const overrides = {};
500
+ if (object(source.compiler)) {
501
+ const { vueVersion, ...compiler } = source.compiler;
502
+ const version = vueVersion ?? compiler.compatibility?.vueVersion;
503
+ overrides.compiler = merge(compiler, version === void 0 ? {} : { compatibility: { vueVersion: String(version === .1 ? "0.10" : version === "legacy" ? 2 : version) } });
504
+ }
505
+ if (typeof source.typecheck === "boolean") overrides.typeChecker = { enabled: source.typecheck };
506
+ else if (object(source.typecheck)) overrides.typeChecker = source.typecheck;
507
+ const lint = source.lint?.vue;
508
+ if (typeof lint === "boolean") overrides.linter = { enabled: lint };
509
+ else if (object(lint)) {
510
+ const { typecheck: _typecheck, locale: _locale, helpLevel: _helpLevel, ...native } = lint;
511
+ overrides.linter = native;
512
+ }
513
+ if (object(source.fmt)) {
514
+ const { vue, sortImports } = source.fmt;
515
+ overrides.formatter = merge(sortImports === void 0 ? {} : { sortImports }, object(vue) ? vue : {});
516
+ }
517
+ const root = typeof source.root === "string" ? resolve(configDir ?? ".", source.root) : configDir;
518
+ const config = overlayVueOptions(merge(projectConfigDefaults(), overrides), canonical);
519
+ return root ? {
520
+ ...projectPaths(config, root, false),
521
+ __vizeProjectRoot: root
522
+ } : config;
523
+ }
524
+ /** Validate only canonical settings; selecting them never evaluates a legacy callback. */
525
+ function vueConfigOptions(source) {
526
+ const selected = source.vue;
527
+ if (selected !== void 0) validateVueOption(selected, vueOptionSchema, "vue");
528
+ return selected;
529
+ }
530
+ function flatVueOptions(selected) {
531
+ const { version, entries, ...sections } = selected;
532
+ return {
533
+ ...sections,
534
+ ...version === void 0 ? {} : { vue: { version } },
535
+ ...entries === void 0 ? {} : { entries: entries.map(flatVueOptions) }
536
+ };
537
+ }
538
+ function overlayVueOptions(base, own) {
539
+ const result = { ...base };
540
+ for (const [key, value] of Object.entries(own)) {
541
+ if (value === void 0) continue;
542
+ const previous = Object.hasOwn(result, key) ? result[key] : void 0;
543
+ Object.defineProperty(result, key, {
544
+ value: object(value) && object(previous) ? overlayVueOptions(previous, value) : value,
545
+ enumerable: true,
546
+ configurable: true,
547
+ writable: true
548
+ });
549
+ }
550
+ return result;
551
+ }
552
+ function validateVueOption(value, schema, label) {
553
+ const refuse = (reason) => {
554
+ throw new TypeError(`${label}: ${reason}`);
555
+ };
556
+ if (schema.$ref) return validateVueOption(value, vueOptionSchema.definitions[schema.$ref.split("/").at(-1)], label);
557
+ if (schema.oneOf) {
558
+ if (schema.oneOf.filter((candidate) => {
559
+ try {
560
+ validateVueOption(value, candidate, label);
561
+ return true;
562
+ } catch (error) {
563
+ if (!(error instanceof TypeError)) throw error;
564
+ return false;
565
+ }
566
+ }).length !== 1) refuse("must match one documented native option type");
567
+ return;
568
+ }
569
+ if (schema.enum && !schema.enum.includes(value)) refuse("unsupported native option value");
570
+ const valid = {
571
+ object: object(value),
572
+ array: Array.isArray(value),
573
+ string: typeof value === "string",
574
+ boolean: typeof value === "boolean",
575
+ integer: Number.isInteger(value),
576
+ number: typeof value === "number" && Number.isFinite(value),
577
+ null: value === null
578
+ };
579
+ if (schema.type && !valid[schema.type]) refuse(`must be ${schema.type}`);
580
+ if (schema.minimum !== void 0 && value < schema.minimum) refuse(`must be >= ${schema.minimum}`);
581
+ if (schema.maximum !== void 0 && value > schema.maximum) refuse(`must be <= ${schema.maximum}`);
582
+ if (Array.isArray(value) && schema.items) for (let index = 0; index < value.length; index++) validateVueOption(value[index], schema.items, `${label}[${index}]`);
583
+ if (object(value)) {
584
+ for (const required of schema.required ?? []) if (!Object.hasOwn(value, required) || value[required] === void 0) refuse(`missing ${required}`);
585
+ for (const [key, item] of Object.entries(value)) {
586
+ const documented = Object.hasOwn(schema.properties ?? {}, key);
587
+ if (!documented && schema.additionalProperties === false) refuse(`unknown option ${key}`);
588
+ if (schema.propertyNames?.pattern && !new RegExp(schema.propertyNames.pattern).test(key)) refuse(`invalid native option name ${key}`);
589
+ const rule = documented ? schema.properties[key] : schema.additionalProperties;
590
+ if (item !== void 0 && object(rule)) validateVueOption(item, rule, `${label}.${key}`);
591
+ }
592
+ }
593
+ }
594
+ function projectPaths(config, root, entry) {
595
+ if (!root || !object(config)) return config;
596
+ const result = { ...config };
597
+ if (typeof config.basePath === "string" || config.files !== void 0 || entry && config.ignores !== void 0) result.basePath = resolve(root, config.basePath ?? ".");
598
+ if (Array.isArray(config.entries)) result.entries = config.entries.map((value) => projectPaths(value, root, true));
599
+ if (object(config.typeChecker)) {
600
+ result.typeChecker = { ...config.typeChecker };
601
+ for (const key of [
602
+ "tsconfig",
603
+ "corsaPath",
604
+ "tsgoPath",
605
+ "globalsFile"
606
+ ]) if (typeof config.typeChecker[key] === "string") result.typeChecker[key] = resolve(root, config.typeChecker[key]);
607
+ }
608
+ return result;
609
+ }
610
+ //#endregion
611
+ //#region src/config.ts
612
+ const require = createRequire(import.meta.url);
613
+ const CONFIG_FILE_NAMES = VITE_CONFIG_FILE_NAMES;
614
+ const RETIRED_CONFIG = /^vize\.config\.(?:pkl|[cm]?[jt]s|json)$/;
615
+ const CONFIG_MIGRATION = "vize.config.* is no longer supported; move Vue settings to vue: in vite.config.* and TypeScript settings to tsconfig.json";
616
+ const DEFAULT_CONFIG_ENV = {
617
+ mode: "development",
618
+ command: "serve"
619
+ };
620
+ const PACKAGE_ROOT = path$1.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
621
+ const VIZE_CONFIG_JSON_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "schemas", "vize.config.schema.json");
622
+ const VIZE_CONFIG_PKL_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "pkl", "vize.pkl");
623
+ /**
624
+ * Define a Vize configuration with type checking.
625
+ * Accepts a plain object or a function that receives ConfigEnv.
626
+ */
627
+ function defineConfig(config) {
628
+ return config;
629
+ }
630
+ /** Resolve native settings from an already loaded Vite/Vite+ export, without starting its plugins. */
631
+ async function resolveViteConfigExport(exported, env, configDir) {
632
+ return normalizeLoadedConfig(await resolveViteConfigExport$1(exported, env, configDir));
633
+ }
634
+ /**
635
+ * Load project settings from `vite.config.*`; TypeScript settings stay in tsconfig.json.
636
+ */
637
+ async function loadConfig(root, options = {}) {
638
+ const { mode = "root", configFile, env, viteConfig = true } = options;
639
+ if (mode === "none") return null;
640
+ if (configFile) {
641
+ const absolutePath = path$1.isAbsolute(configFile) ? configFile : path$1.resolve(root, configFile);
642
+ if (fs$1.existsSync(absolutePath)) return loadConfigFile(absolutePath, env);
643
+ return null;
644
+ }
645
+ if (mode === "auto") return loadConfigFromDirAuto(root, env, viteConfig);
646
+ return loadConfigFromDir(root, env, viteConfig);
647
+ }
648
+ async function loadConfigFromDir(dir, env, viteConfig = true) {
649
+ for (const name of viteConfig ? CONFIG_FILE_NAMES : []) {
650
+ const filePath = path$1.join(dir, name);
651
+ if (!fs$1.existsSync(filePath)) continue;
652
+ const config = await loadConfigFile(filePath, env);
653
+ if (config !== null) return config;
654
+ }
655
+ if (viteConfig && fs$1.existsSync(dir) && fs$1.readdirSync(dir).some((name) => RETIRED_CONFIG.test(name))) throw new Error(CONFIG_MIGRATION);
656
+ return null;
657
+ }
658
+ async function loadConfigFromDirAuto(startDir, env, viteConfig = true) {
659
+ let currentDir = path$1.resolve(startDir);
660
+ while (true) {
661
+ const config = await loadConfigFromDir(currentDir, env, viteConfig);
662
+ if (config !== null) return config;
663
+ if ([
664
+ "package.json",
665
+ "tsconfig.json",
666
+ "jsconfig.json"
667
+ ].some((name) => fs$1.existsSync(path$1.join(currentDir, name)))) return null;
668
+ const parentDir = path$1.dirname(currentDir);
669
+ if (parentDir === currentDir) return null;
670
+ currentDir = parentDir;
671
+ }
672
+ }
673
+ async function loadConfigFile(filePath, env) {
674
+ const absolutePath = path$1.resolve(filePath);
675
+ if (RETIRED_CONFIG.test(path$1.basename(absolutePath))) throw new Error(CONFIG_MIGRATION);
676
+ if (!fs$1.existsSync(absolutePath)) return null;
677
+ const ext = path$1.extname(absolutePath);
678
+ if (isViteConfigFile(absolutePath)) {
679
+ const module = await importConfigModule(absolutePath, () => null);
680
+ if (module !== null) return resolveFileExport(module.default ?? module, absolutePath, env);
681
+ }
682
+ if (ext === ".pkl") return loadPklConfig(absolutePath);
683
+ if (ext === ".json") return parseJsonConfig(fs$1.readFileSync(absolutePath, "utf-8"), absolutePath);
684
+ if (ext === ".ts" || ext === ".mts") return loadTypeScriptConfig(absolutePath, env);
685
+ return loadESMConfig(absolutePath, env);
686
+ }
687
+ function loadPklConfig(filePath) {
688
+ const output = loadPklConfigJson(filePath);
689
+ return output === null ? null : parseJsonConfig(output, filePath);
690
+ }
691
+ async function resolveConfigExport(exported, env) {
692
+ if (typeof exported === "function") return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));
693
+ return normalizeLoadedConfig(exported);
694
+ }
695
+ async function loadTypeScriptConfig(filePath, env) {
696
+ const source = fs$1.readFileSync(filePath, "utf-8");
697
+ const code = rewriteSelfConfigImports((await (await import("oxc-transform")).transform(filePath, source, { typescript: { onlyRemoveTypeImports: true } })).code);
698
+ const tempFile = path$1.join(path$1.dirname(filePath), `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.mjs`);
699
+ fs$1.writeFileSync(tempFile, code, {
700
+ flag: "wx",
701
+ mode: 384
702
+ });
703
+ try {
704
+ const module = await importFresh(tempFile);
705
+ return resolveFileExport(module.default || module, filePath, env);
706
+ } finally {
707
+ fs$1.rmSync(tempFile, { force: true });
708
+ }
709
+ }
710
+ async function loadESMConfig(filePath, env) {
711
+ const module = await importFresh(filePath);
712
+ return resolveFileExport(module.default || module, filePath, env);
713
+ }
714
+ async function resolveFileExport(exported, filePath, env) {
715
+ return isViteConfigFile(filePath) ? resolveViteConfigExport(exported, env, path$1.dirname(filePath)) : resolveConfigExport(exported, env);
716
+ }
717
+ async function importFresh(filePath) {
718
+ const fileUrl = pathToFileURL(filePath);
719
+ fileUrl.searchParams.set("t", String(fs$1.statSync(filePath).mtimeMs));
720
+ return import(fileUrl.href);
721
+ }
722
+ function rewriteSelfConfigImports(code) {
723
+ return code.replace(/\bfrom\s+(["'])(vize(?:\/config)?)\1/gu, (_match, quote, specifier) => {
724
+ return `from ${quote}${resolveSelfConfigImportUrl(specifier)}${quote}`;
725
+ }).replace(/\bimport\s+(["'])(vize(?:\/config)?)\1/gu, (_match, quote, specifier) => {
726
+ return `import ${quote}${resolveSelfConfigImportUrl(specifier)}${quote}`;
727
+ }).replace(/\bimport\s*\(\s*(["'])(vize(?:\/config)?)\1\s*\)/gu, (_match, quote, specifier) => {
728
+ return `import(${quote}${resolveSelfConfigImportUrl(specifier)}${quote})`;
729
+ });
730
+ }
731
+ function resolveSelfConfigImportUrl(specifier) {
732
+ const distTarget = specifier === "vize" ? path$1.join(PACKAGE_ROOT, "dist", "index.mjs") : path$1.join(PACKAGE_ROOT, "dist", "config.mjs");
733
+ const sourceTarget = path$1.join(PACKAGE_ROOT, "src", "config.ts");
734
+ return pathToFileURL(fs$1.existsSync(distTarget) ? distTarget : sourceTarget).href;
735
+ }
736
+ function parseJsonConfig(content, filePath) {
737
+ try {
738
+ return normalizeLoadedConfig(JSON.parse(content));
739
+ } catch (error) {
740
+ throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);
741
+ }
742
+ }
743
+ function normalizeLoadedConfig(config) {
744
+ const hasExtends = (value) => value !== null && typeof value === "object" && Object.hasOwn(value, "extends");
745
+ const entries = Array.isArray(config) ? config : config && typeof config === "object" && "entries" in config ? config.entries : void 0;
746
+ if (hasExtends(config) || Array.isArray(entries) && entries.some(hasExtends)) throw new Error("Custom config extends is no longer supported; use defineConfig(vpConfig).withVue(vueConfig); standard tsconfig extends remains supported");
747
+ return require("@vizejs/native").normalizeVizeConfig(config ?? null);
748
+ }
749
+ function getErrorMessage(error) {
750
+ if (error instanceof Error) return error.message;
751
+ return String(error);
752
+ }
753
+ /**
754
+ * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
755
+ */
756
+ function normalizeGlobalTypes(config) {
757
+ const resolvedConfig = "types" in config && typeof config.types === "object" && config.types !== null && !Array.isArray(config.types) ? config.types : config;
758
+ const result = {};
759
+ for (const [key, value] of Object.entries(resolvedConfig)) if (typeof value === "string") result[key] = { type: value };
760
+ else result[key] = value;
761
+ return result;
762
+ }
763
+ //#endregion
764
+ export { loadConfig as a, resolveViteConfigExport as c, defineConfig as i, VITE_CONFIG_FILE_NAMES as l, VIZE_CONFIG_JSON_SCHEMA_PATH as n, normalizeGlobalTypes as o, VIZE_CONFIG_PKL_SCHEMA_PATH as r, resolveConfigExport as s, CONFIG_FILE_NAMES as t };
765
+
766
+ //# sourceMappingURL=config-BnQMtsWA.mjs.map