vize 0.474.0 → 0.476.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -32
- package/dist/cli.mjs +34 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/config-BnQMtsWA.mjs +766 -0
- package/dist/config-BnQMtsWA.mjs.map +1 -0
- package/dist/{config-DIyA9raO.d.mts → config-DkTqtxYs.d.mts} +12 -16
- package/dist/config-DkTqtxYs.d.mts.map +1 -0
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +65 -65
- package/pkl/LanguageServerConfig.pkl +6 -0
- package/pkl/LinterConfig.pkl +1 -1
- package/pkl/VizeConfig.pkl +0 -8
- package/pkl/jsonschema/LinterSchemaDefinitions.pkl +2 -2
- package/pkl/jsonschema/generate.pkl +4 -9
- package/pkl/vize.pkl +3 -4
- package/schemas/vize.config.schema.json +22 -30
- package/src/config.ts +26 -9
- package/src/init/detect.ts +2 -0
- package/src/init/plan-project.ts +2 -2
- package/src/init/report.ts +6 -1
- package/src/init/select.ts +2 -5
- package/src/init.ts +2 -1
- package/src/setup/config.ts +14 -0
- package/src/setup/vite.ts +2 -0
- package/src/setup.ts +11 -0
- package/src/types/generated.ts +23 -18
- package/src/types/runtime.ts +6 -1
- package/dist/config-C5DKms5s.mjs +0 -517
- package/dist/config-C5DKms5s.mjs.map +0 -1
- package/dist/config-DIyA9raO.d.mts.map +0 -1
package/dist/config-C5DKms5s.mjs
DELETED
|
@@ -1,517 +0,0 @@
|
|
|
1
|
-
import { createRequire, globalPaths } from "node:module";
|
|
2
|
-
import * as fs$1 from "node:fs";
|
|
3
|
-
import { lstatSync, realpathSync } from "node:fs";
|
|
4
|
-
import * as path$1 from "node:path";
|
|
5
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
7
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
-
import { execFileSync } from "node:child_process";
|
|
9
|
-
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
10
|
-
import { tmpdir } from "node:os";
|
|
11
|
-
//#region src/config/pkl.js
|
|
12
|
-
const PACKAGE_ROOT$1 = path$1.resolve(fileURLToPath(new URL(".", import.meta.url)), "../..");
|
|
13
|
-
const DOCUMENTED_PKL_SCHEMA_IMPORT_RE = /^(\s*(?:amends|import)\s+)(["'])node_modules\/vize\/pkl\/(VizeConfig\.pkl|vize\.pkl)\2/gm;
|
|
14
|
-
/**
|
|
15
|
-
* Evaluate a `vize.config.pkl` file and return its JSON representation.
|
|
16
|
-
*
|
|
17
|
-
* The npm-facing loader keeps PKL execution in Node because it needs package
|
|
18
|
-
* resolution for `@pkl-community/pkl`, but all structural config normalization
|
|
19
|
-
* happens in Rust after this function returns. A missing PKL runtime returns
|
|
20
|
-
* `null` so config discovery can fall through to lower-priority formats; an
|
|
21
|
-
* evaluation failure throws because a present PKL config should not silently be
|
|
22
|
-
* ignored.
|
|
23
|
-
*/
|
|
24
|
-
function loadPklConfigJson(filePath) {
|
|
25
|
-
const pklBin = findPklBinary();
|
|
26
|
-
if (!pklBin) {
|
|
27
|
-
console.warn("[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. Falling back to the next config format.");
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
const patchedFilePath = createPklConfigWithBundledSchemaImports(filePath);
|
|
31
|
-
const evalFilePath = patchedFilePath ?? filePath;
|
|
32
|
-
try {
|
|
33
|
-
return execFileSync(pklBin, [
|
|
34
|
-
"eval",
|
|
35
|
-
"-f",
|
|
36
|
-
"json",
|
|
37
|
-
evalFilePath
|
|
38
|
-
], {
|
|
39
|
-
cwd: path$1.dirname(filePath),
|
|
40
|
-
encoding: "utf-8",
|
|
41
|
-
stdio: [
|
|
42
|
-
"ignore",
|
|
43
|
-
"pipe",
|
|
44
|
-
"pipe"
|
|
45
|
-
],
|
|
46
|
-
timeout: 3e4
|
|
47
|
-
});
|
|
48
|
-
} catch (error) {
|
|
49
|
-
throw new Error(`Failed to evaluate vize PKL config at ${filePath}: ${getErrorMessage$1(error)}`);
|
|
50
|
-
} finally {
|
|
51
|
-
if (patchedFilePath) fs$1.rmSync(patchedFilePath, { force: true });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function findPklBinary() {
|
|
55
|
-
try {
|
|
56
|
-
const pklPkgPath = import.meta.resolve?.("@pkl-community/pkl");
|
|
57
|
-
if (pklPkgPath) {
|
|
58
|
-
const pklLibDir = path$1.dirname(fileURLToPath(pklPkgPath));
|
|
59
|
-
const pklPackageDir = path$1.dirname(pklLibDir);
|
|
60
|
-
const candidates = [
|
|
61
|
-
path$1.join(pklLibDir, "main.js"),
|
|
62
|
-
path$1.join(pklPackageDir, "pkl"),
|
|
63
|
-
path$1.join(pklPackageDir, "pkl.exe")
|
|
64
|
-
];
|
|
65
|
-
for (const candidate of candidates) if (fs$1.existsSync(candidate)) try {
|
|
66
|
-
execFileSync(candidate, ["--version"], { stdio: "ignore" });
|
|
67
|
-
return candidate;
|
|
68
|
-
} catch {}
|
|
69
|
-
}
|
|
70
|
-
} catch {}
|
|
71
|
-
try {
|
|
72
|
-
execFileSync("pkl", ["--version"], { stdio: "ignore" });
|
|
73
|
-
return "pkl";
|
|
74
|
-
} catch {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function createPklConfigWithBundledSchemaImports(filePath) {
|
|
79
|
-
const configDir = path$1.dirname(filePath);
|
|
80
|
-
const source = fs$1.readFileSync(filePath, "utf-8");
|
|
81
|
-
let patched = false;
|
|
82
|
-
const content = source.replace(DOCUMENTED_PKL_SCHEMA_IMPORT_RE, (match, prefix, quote, schemaFile) => {
|
|
83
|
-
const projectSchemaPath = path$1.join(configDir, "node_modules", "vize", "pkl", schemaFile);
|
|
84
|
-
if (fs$1.existsSync(projectSchemaPath)) return match;
|
|
85
|
-
const bundledSchemaPath = path$1.join(PACKAGE_ROOT$1, "pkl", schemaFile);
|
|
86
|
-
if (!fs$1.existsSync(bundledSchemaPath)) return match;
|
|
87
|
-
patched = true;
|
|
88
|
-
return `${prefix}${quote}${pathToFileURL(bundledSchemaPath).href}${quote}`;
|
|
89
|
-
});
|
|
90
|
-
if (!patched) return null;
|
|
91
|
-
const tempFile = path$1.join(configDir, `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.pkl`);
|
|
92
|
-
fs$1.writeFileSync(tempFile, content, {
|
|
93
|
-
flag: "wx",
|
|
94
|
-
mode: 384
|
|
95
|
-
});
|
|
96
|
-
return tempFile;
|
|
97
|
-
}
|
|
98
|
-
function getErrorMessage$1(error) {
|
|
99
|
-
if (error instanceof Error) return error.message;
|
|
100
|
-
return String(error);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region ../../crates/vize_carton/src/config/loader/module-runtime.mjs
|
|
104
|
-
function configModuleImportPath(configURL, windows = process.platform === "win32") {
|
|
105
|
-
return fileURLToPath(configURL, { windows });
|
|
106
|
-
}
|
|
107
|
-
async function importConfigModule(configPath, withoutVite = (configURL) => import(configURL.href)) {
|
|
108
|
-
const configURL = pathToFileURL(configPath);
|
|
109
|
-
const require = createRequire(configURL);
|
|
110
|
-
const candidate = (require.resolve.paths("vite") ?? []).filter((directory) => !globalPaths.includes(directory)).map((directory) => join(directory, "vite")).find((directory) => lstatSync(directory, { throwIfNoEntry: false }) !== void 0);
|
|
111
|
-
if (candidate === void 0) return withoutVite(configURL);
|
|
112
|
-
const viteDirectory = realpathSync(candidate);
|
|
113
|
-
const viteEntry = realpathSync(require.resolve("vite"));
|
|
114
|
-
const entryPath = relative(viteDirectory, viteEntry);
|
|
115
|
-
if (entryPath === ".." || entryPath.startsWith(`..${sep}`) || isAbsolute(entryPath)) throw new Error(`Resolved loader escapes selected project Vite: ${candidate} -> ${viteEntry}`);
|
|
116
|
-
const { loadConfigFromFile } = await import(pathToFileURL(viteEntry).href);
|
|
117
|
-
const temporary = await mkdtemp(join(tmpdir(), "vize-config-module-"));
|
|
118
|
-
try {
|
|
119
|
-
const adapter = join(temporary, "config.mjs");
|
|
120
|
-
await writeFile(adapter, `import * as original from ${JSON.stringify(configModuleImportPath(configURL))};\nexport default { namespace: original };\n`, {
|
|
121
|
-
flag: "wx",
|
|
122
|
-
mode: 384
|
|
123
|
-
});
|
|
124
|
-
const loaded = await loadConfigFromFile({
|
|
125
|
-
mode: "development",
|
|
126
|
-
command: "serve"
|
|
127
|
-
}, adapter, dirname(configPath), "silent", void 0, "bundle");
|
|
128
|
-
if (!loaded) throw new Error(`Vite did not load the selected config: ${configPath}`);
|
|
129
|
-
return loaded.config.namespace;
|
|
130
|
-
} finally {
|
|
131
|
-
await rm(temporary, {
|
|
132
|
-
recursive: true,
|
|
133
|
-
force: true
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region ../../crates/vize_carton/src/config/loader/vite-runtime.mjs
|
|
139
|
-
const vueOptionSchema = JSON.parse("{\"type\":\"object\",\"properties\":{\"compiler\":{\"$ref\":\"#/definitions/CompilerConfig\"},\"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\"]},\"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\":[\"happy-path\",\"opinionated\",\"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\"},\"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}}}");
|
|
140
|
-
const sourceConfigKey = Symbol.for("@vizejs/vite-plugin/vite-plus/source");
|
|
141
|
-
function object(value) {
|
|
142
|
-
if (value === null || typeof value !== "object") return false;
|
|
143
|
-
const prototype = Object.getPrototypeOf(value);
|
|
144
|
-
return prototype === Object.prototype || prototype === null;
|
|
145
|
-
}
|
|
146
|
-
function merge(base, own) {
|
|
147
|
-
const result = { ...base };
|
|
148
|
-
for (const [key, value] of Object.entries(own)) result[key] = object(value) && object(result[key]) ? merge(result[key], value) : value;
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
async function resolveSource(value, env, parents = /* @__PURE__ */ new Set()) {
|
|
152
|
-
value = await value;
|
|
153
|
-
if (parents.has(value)) throw new Error("Circular extends in Vize's Vite config");
|
|
154
|
-
parents.add(value);
|
|
155
|
-
try {
|
|
156
|
-
if (typeof value === "function" && sourceConfigKey in value) return await resolveSource(value[sourceConfigKey], env, parents);
|
|
157
|
-
const config = await (typeof value === "function" ? value(env) : value);
|
|
158
|
-
if (!object(config)) throw new Error("Vite config must export an object or a config function");
|
|
159
|
-
const { extends: bases, ...own } = config;
|
|
160
|
-
let inherited = {};
|
|
161
|
-
for (const base of Array.isArray(bases) ? bases : bases ? [bases] : []) inherited = mergeViteSource(inherited, await resolveSource(base, env, parents));
|
|
162
|
-
return mergeViteSource(inherited, own);
|
|
163
|
-
} finally {
|
|
164
|
-
parents.delete(value);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const VITE_CONFIG_FILE_NAMES = [
|
|
168
|
-
"vite.config.ts",
|
|
169
|
-
"vite.config.js",
|
|
170
|
-
"vite.config.mjs",
|
|
171
|
-
"vite.config.cjs",
|
|
172
|
-
"vite.config.mts",
|
|
173
|
-
"vite.config.cts"
|
|
174
|
-
];
|
|
175
|
-
function isViteConfigFile(filePath) {
|
|
176
|
-
return /(?:^|[/\\])vite\.config\.(?:[cm]?[jt]s)$/.test(filePath);
|
|
177
|
-
}
|
|
178
|
-
/** Project workflows support JSX without an extra feature flag. Legacy config stays unchanged. */
|
|
179
|
-
function projectConfigDefaults() {
|
|
180
|
-
return { typeChecker: { jsxTypecheck: true } };
|
|
181
|
-
}
|
|
182
|
-
/** Resolve just the native settings from an ordinary Vite or Vite+ export. */
|
|
183
|
-
async function resolveViteConfigExport$1(exported, env, configDir) {
|
|
184
|
-
env ??= {
|
|
185
|
-
mode: "development",
|
|
186
|
-
command: "serve"
|
|
187
|
-
};
|
|
188
|
-
if (env.command !== "build" && env.command !== "serve") env = {
|
|
189
|
-
...env,
|
|
190
|
-
command: "serve"
|
|
191
|
-
};
|
|
192
|
-
return projectViteConfigSource(await resolveSource(exported, env), env, configDir);
|
|
193
|
-
}
|
|
194
|
-
/** Project already evaluated settings; the owning adapter evaluates its Vite export once. */
|
|
195
|
-
async function projectViteConfigSource(source, env, configDir) {
|
|
196
|
-
if (!object(source)) throw new TypeError("Vite config source must be an object");
|
|
197
|
-
env ??= {
|
|
198
|
-
mode: "development",
|
|
199
|
-
command: "serve"
|
|
200
|
-
};
|
|
201
|
-
if (env.command !== "build" && env.command !== "serve") env = {
|
|
202
|
-
...env,
|
|
203
|
-
command: "serve"
|
|
204
|
-
};
|
|
205
|
-
const selected = vueConfigOptions(source);
|
|
206
|
-
const canonical = selected === void 0 ? {} : flatVueOptions(selected);
|
|
207
|
-
let shared = await (typeof source.vize === "function" ? source.vize(env) : source.vize);
|
|
208
|
-
const alias = object(shared) ? shared.lint : void 0;
|
|
209
|
-
if (object(shared)) {
|
|
210
|
-
const { lint: _lint, ...native } = shared;
|
|
211
|
-
shared = native;
|
|
212
|
-
}
|
|
213
|
-
const overrides = {};
|
|
214
|
-
if (object(source.compiler)) {
|
|
215
|
-
const { vueVersion, ...compiler } = source.compiler;
|
|
216
|
-
const version = vueVersion ?? compiler.compatibility?.vueVersion;
|
|
217
|
-
overrides.compiler = merge(compiler, version === void 0 ? {} : { compatibility: { vueVersion: String(version === .1 ? "0.10" : version === "legacy" ? 2 : version) } });
|
|
218
|
-
}
|
|
219
|
-
if (typeof source.typecheck === "boolean") overrides.typeChecker = { enabled: source.typecheck };
|
|
220
|
-
else if (object(source.typecheck)) overrides.typeChecker = source.typecheck;
|
|
221
|
-
const lint = source.lint?.vize === void 0 ? alias : source.lint.vize;
|
|
222
|
-
if (typeof lint === "boolean") overrides.linter = { enabled: lint };
|
|
223
|
-
else if (object(lint)) {
|
|
224
|
-
const { typecheck: _typecheck, locale: _locale, helpLevel: _helpLevel, ...native } = merge(object(alias) ? alias : {}, lint);
|
|
225
|
-
overrides.linter = native;
|
|
226
|
-
}
|
|
227
|
-
if (object(source.fmt)) {
|
|
228
|
-
const { vize, sortImports } = source.fmt;
|
|
229
|
-
overrides.formatter = merge(sortImports === void 0 ? {} : { sortImports }, object(vize) ? vize : {});
|
|
230
|
-
}
|
|
231
|
-
const root = typeof source.root === "string" ? resolve(configDir ?? ".", source.root) : configDir;
|
|
232
|
-
if (Array.isArray(shared)) {
|
|
233
|
-
const entries = canonical.entries;
|
|
234
|
-
const { entries: _entries, ...own } = canonical;
|
|
235
|
-
const retained = entries === void 0 ? shared : shared.filter(isUnscopedEntry);
|
|
236
|
-
return [
|
|
237
|
-
{
|
|
238
|
-
...projectConfigDefaults(),
|
|
239
|
-
...root ? { __vizeProjectRoot: root } : {}
|
|
240
|
-
},
|
|
241
|
-
...retained.map((entry) => projectPaths(entry, root, true)),
|
|
242
|
-
projectPaths({
|
|
243
|
-
...overlayVueOptions(overrides, own),
|
|
244
|
-
...root ? { __vizeProjectRoot: root } : {}
|
|
245
|
-
}, root, false),
|
|
246
|
-
...(entries ?? []).map((entry) => projectPaths(entry, root, true))
|
|
247
|
-
];
|
|
248
|
-
}
|
|
249
|
-
const config = overlayVueOptions(merge(merge(projectConfigDefaults(), shared ?? {}), overrides), canonical);
|
|
250
|
-
return root ? {
|
|
251
|
-
...projectPaths(config, root, false),
|
|
252
|
-
__vizeProjectRoot: root
|
|
253
|
-
} : config;
|
|
254
|
-
}
|
|
255
|
-
/** Validate only canonical settings; selecting them never evaluates a legacy callback. */
|
|
256
|
-
function vueConfigOptions(source) {
|
|
257
|
-
const selected = source.vue;
|
|
258
|
-
if (selected !== void 0) validateVueOption(selected, vueOptionSchema, "vue");
|
|
259
|
-
return selected;
|
|
260
|
-
}
|
|
261
|
-
/** Share canonical composition with adapters while their other Vite fields keep Vite merging. */
|
|
262
|
-
function mergeVueConfigOptions(base, own) {
|
|
263
|
-
vueConfigOptions({ vue: base });
|
|
264
|
-
vueConfigOptions({ vue: own });
|
|
265
|
-
if (base === void 0) return own;
|
|
266
|
-
if (own === void 0) return base;
|
|
267
|
-
return overlayVueOptions(base, own);
|
|
268
|
-
}
|
|
269
|
-
function mergeViteSource(base, own) {
|
|
270
|
-
const result = merge(base, own);
|
|
271
|
-
const selected = mergeVueConfigOptions(base.vue, own.vue);
|
|
272
|
-
if (selected !== void 0) result.vue = selected;
|
|
273
|
-
return result;
|
|
274
|
-
}
|
|
275
|
-
function flatVueOptions(selected) {
|
|
276
|
-
const { version, entries, ...sections } = selected;
|
|
277
|
-
return {
|
|
278
|
-
...sections,
|
|
279
|
-
...version === void 0 ? {} : { vue: { version } },
|
|
280
|
-
...entries === void 0 ? {} : { entries: entries.map(flatVueOptions) }
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function isUnscopedEntry(entry) {
|
|
284
|
-
return !object(entry) || [
|
|
285
|
-
"basePath",
|
|
286
|
-
"files",
|
|
287
|
-
"ignores"
|
|
288
|
-
].every((key) => entry[key] == null);
|
|
289
|
-
}
|
|
290
|
-
function overlayVueOptions(base, own) {
|
|
291
|
-
const result = { ...base };
|
|
292
|
-
for (const [key, value] of Object.entries(own)) {
|
|
293
|
-
if (value === void 0) continue;
|
|
294
|
-
const previous = Object.hasOwn(result, key) ? result[key] : void 0;
|
|
295
|
-
Object.defineProperty(result, key, {
|
|
296
|
-
value: object(value) && object(previous) ? overlayVueOptions(previous, value) : value,
|
|
297
|
-
enumerable: true,
|
|
298
|
-
configurable: true,
|
|
299
|
-
writable: true
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
return result;
|
|
303
|
-
}
|
|
304
|
-
function validateVueOption(value, schema, label) {
|
|
305
|
-
const refuse = (reason) => {
|
|
306
|
-
throw new TypeError(`${label}: ${reason}`);
|
|
307
|
-
};
|
|
308
|
-
if (schema.$ref) return validateVueOption(value, vueOptionSchema.definitions[schema.$ref.split("/").at(-1)], label);
|
|
309
|
-
if (schema.oneOf) {
|
|
310
|
-
if (schema.oneOf.filter((candidate) => {
|
|
311
|
-
try {
|
|
312
|
-
validateVueOption(value, candidate, label);
|
|
313
|
-
return true;
|
|
314
|
-
} catch (error) {
|
|
315
|
-
if (!(error instanceof TypeError)) throw error;
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
}).length !== 1) refuse("must match one documented native option type");
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (schema.enum && !schema.enum.includes(value)) refuse("unsupported native option value");
|
|
322
|
-
const valid = {
|
|
323
|
-
object: object(value),
|
|
324
|
-
array: Array.isArray(value),
|
|
325
|
-
string: typeof value === "string",
|
|
326
|
-
boolean: typeof value === "boolean",
|
|
327
|
-
integer: Number.isInteger(value),
|
|
328
|
-
number: typeof value === "number" && Number.isFinite(value),
|
|
329
|
-
null: value === null
|
|
330
|
-
};
|
|
331
|
-
if (schema.type && !valid[schema.type]) refuse(`must be ${schema.type}`);
|
|
332
|
-
if (schema.minimum !== void 0 && value < schema.minimum) refuse(`must be >= ${schema.minimum}`);
|
|
333
|
-
if (schema.maximum !== void 0 && value > schema.maximum) refuse(`must be <= ${schema.maximum}`);
|
|
334
|
-
if (Array.isArray(value) && schema.items) for (let index = 0; index < value.length; index++) validateVueOption(value[index], schema.items, `${label}[${index}]`);
|
|
335
|
-
if (object(value)) {
|
|
336
|
-
for (const required of schema.required ?? []) if (!Object.hasOwn(value, required) || value[required] === void 0) refuse(`missing ${required}`);
|
|
337
|
-
for (const [key, item] of Object.entries(value)) {
|
|
338
|
-
const documented = Object.hasOwn(schema.properties ?? {}, key);
|
|
339
|
-
if (!documented && schema.additionalProperties === false) refuse(`unknown option ${key}`);
|
|
340
|
-
if (schema.propertyNames?.pattern && !new RegExp(schema.propertyNames.pattern).test(key)) refuse(`invalid native option name ${key}`);
|
|
341
|
-
const rule = documented ? schema.properties[key] : schema.additionalProperties;
|
|
342
|
-
if (item !== void 0 && object(rule)) validateVueOption(item, rule, `${label}.${key}`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
function projectPaths(config, root, entry) {
|
|
347
|
-
if (!root || !object(config)) return config;
|
|
348
|
-
const result = { ...config };
|
|
349
|
-
if (typeof config.basePath === "string" || config.files !== void 0 || entry && config.ignores !== void 0) result.basePath = resolve(root, config.basePath ?? ".");
|
|
350
|
-
if (Array.isArray(config.entries)) result.entries = config.entries.map((value) => projectPaths(value, root, true));
|
|
351
|
-
if (object(config.typeChecker)) {
|
|
352
|
-
result.typeChecker = { ...config.typeChecker };
|
|
353
|
-
for (const key of [
|
|
354
|
-
"tsconfig",
|
|
355
|
-
"corsaPath",
|
|
356
|
-
"tsgoPath",
|
|
357
|
-
"globalsFile"
|
|
358
|
-
]) if (typeof config.typeChecker[key] === "string") result.typeChecker[key] = resolve(root, config.typeChecker[key]);
|
|
359
|
-
}
|
|
360
|
-
return result;
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
|
-
//#region src/config.ts
|
|
364
|
-
const require = createRequire(import.meta.url);
|
|
365
|
-
const CONFIG_FILE_NAMES = [
|
|
366
|
-
"vize.config.pkl",
|
|
367
|
-
"vize.config.ts",
|
|
368
|
-
"vize.config.js",
|
|
369
|
-
"vize.config.mjs",
|
|
370
|
-
"vize.config.json"
|
|
371
|
-
];
|
|
372
|
-
const DEFAULT_CONFIG_ENV = {
|
|
373
|
-
mode: "development",
|
|
374
|
-
command: "serve"
|
|
375
|
-
};
|
|
376
|
-
const PACKAGE_ROOT = path$1.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
|
377
|
-
const VIZE_CONFIG_JSON_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "schemas", "vize.config.schema.json");
|
|
378
|
-
const VIZE_CONFIG_PKL_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "pkl", "vize.pkl");
|
|
379
|
-
/**
|
|
380
|
-
* Define a Vize configuration with type checking.
|
|
381
|
-
* Accepts a plain object or a function that receives ConfigEnv.
|
|
382
|
-
*/
|
|
383
|
-
function defineConfig(config) {
|
|
384
|
-
return config;
|
|
385
|
-
}
|
|
386
|
-
/** Resolve native settings from an already loaded Vite/Vite+ export, without starting its plugins. */
|
|
387
|
-
async function resolveViteConfigExport(exported, env, configDir) {
|
|
388
|
-
return normalizeLoadedConfig(await resolveViteConfigExport$1(exported, env, configDir));
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Load project settings from a compatible dedicated config or `vite.config.*`.
|
|
392
|
-
*/
|
|
393
|
-
async function loadConfig(root, options = {}) {
|
|
394
|
-
const { mode = "root", configFile, env, viteConfig = true } = options;
|
|
395
|
-
if (mode === "none") return null;
|
|
396
|
-
if (configFile) {
|
|
397
|
-
const absolutePath = path$1.isAbsolute(configFile) ? configFile : path$1.resolve(root, configFile);
|
|
398
|
-
if (fs$1.existsSync(absolutePath)) return loadConfigFile(absolutePath, env);
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
if (mode === "auto") return loadConfigFromDirAuto(root, env, viteConfig);
|
|
402
|
-
return loadConfigFromDir(root, env, viteConfig);
|
|
403
|
-
}
|
|
404
|
-
async function loadConfigFromDir(dir, env, viteConfig = true) {
|
|
405
|
-
for (const name of [...CONFIG_FILE_NAMES, ...viteConfig ? VITE_CONFIG_FILE_NAMES : []]) {
|
|
406
|
-
const filePath = path$1.join(dir, name);
|
|
407
|
-
if (!fs$1.existsSync(filePath)) continue;
|
|
408
|
-
const config = await loadConfigFile(filePath, env);
|
|
409
|
-
if (config !== null) return config;
|
|
410
|
-
}
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
async function loadConfigFromDirAuto(startDir, env, viteConfig = true) {
|
|
414
|
-
let currentDir = path$1.resolve(startDir);
|
|
415
|
-
while (true) {
|
|
416
|
-
const config = await loadConfigFromDir(currentDir, env, viteConfig);
|
|
417
|
-
if (config !== null) return config;
|
|
418
|
-
if ([
|
|
419
|
-
"package.json",
|
|
420
|
-
"tsconfig.json",
|
|
421
|
-
"jsconfig.json"
|
|
422
|
-
].some((name) => fs$1.existsSync(path$1.join(currentDir, name)))) return null;
|
|
423
|
-
const parentDir = path$1.dirname(currentDir);
|
|
424
|
-
if (parentDir === currentDir) return null;
|
|
425
|
-
currentDir = parentDir;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
async function loadConfigFile(filePath, env) {
|
|
429
|
-
const absolutePath = path$1.resolve(filePath);
|
|
430
|
-
if (!fs$1.existsSync(absolutePath)) return null;
|
|
431
|
-
const ext = path$1.extname(absolutePath);
|
|
432
|
-
if (isViteConfigFile(absolutePath)) {
|
|
433
|
-
const module = await importConfigModule(absolutePath, () => null);
|
|
434
|
-
if (module !== null) return resolveFileExport(module.default ?? module, absolutePath, env);
|
|
435
|
-
}
|
|
436
|
-
if (ext === ".pkl") return loadPklConfig(absolutePath);
|
|
437
|
-
if (ext === ".json") return parseJsonConfig(fs$1.readFileSync(absolutePath, "utf-8"), absolutePath);
|
|
438
|
-
if (ext === ".ts" || ext === ".mts") return loadTypeScriptConfig(absolutePath, env);
|
|
439
|
-
return loadESMConfig(absolutePath, env);
|
|
440
|
-
}
|
|
441
|
-
function loadPklConfig(filePath) {
|
|
442
|
-
const output = loadPklConfigJson(filePath);
|
|
443
|
-
return output === null ? null : parseJsonConfig(output, filePath);
|
|
444
|
-
}
|
|
445
|
-
async function resolveConfigExport(exported, env) {
|
|
446
|
-
if (typeof exported === "function") return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));
|
|
447
|
-
return normalizeLoadedConfig(exported);
|
|
448
|
-
}
|
|
449
|
-
async function loadTypeScriptConfig(filePath, env) {
|
|
450
|
-
const source = fs$1.readFileSync(filePath, "utf-8");
|
|
451
|
-
const code = rewriteSelfConfigImports((await (await import("oxc-transform")).transform(filePath, source, { typescript: { onlyRemoveTypeImports: true } })).code);
|
|
452
|
-
const tempFile = path$1.join(path$1.dirname(filePath), `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.mjs`);
|
|
453
|
-
fs$1.writeFileSync(tempFile, code, {
|
|
454
|
-
flag: "wx",
|
|
455
|
-
mode: 384
|
|
456
|
-
});
|
|
457
|
-
try {
|
|
458
|
-
const module = await importFresh(tempFile);
|
|
459
|
-
return resolveFileExport(module.default || module, filePath, env);
|
|
460
|
-
} finally {
|
|
461
|
-
fs$1.rmSync(tempFile, { force: true });
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
async function loadESMConfig(filePath, env) {
|
|
465
|
-
const module = await importFresh(filePath);
|
|
466
|
-
return resolveFileExport(module.default || module, filePath, env);
|
|
467
|
-
}
|
|
468
|
-
async function resolveFileExport(exported, filePath, env) {
|
|
469
|
-
return isViteConfigFile(filePath) ? resolveViteConfigExport(exported, env, path$1.dirname(filePath)) : resolveConfigExport(exported, env);
|
|
470
|
-
}
|
|
471
|
-
async function importFresh(filePath) {
|
|
472
|
-
const fileUrl = pathToFileURL(filePath);
|
|
473
|
-
fileUrl.searchParams.set("t", String(fs$1.statSync(filePath).mtimeMs));
|
|
474
|
-
return import(fileUrl.href);
|
|
475
|
-
}
|
|
476
|
-
function rewriteSelfConfigImports(code) {
|
|
477
|
-
return code.replace(/\bfrom\s+(["'])(vize(?:\/config)?)\1/gu, (_match, quote, specifier) => {
|
|
478
|
-
return `from ${quote}${resolveSelfConfigImportUrl(specifier)}${quote}`;
|
|
479
|
-
}).replace(/\bimport\s+(["'])(vize(?:\/config)?)\1/gu, (_match, quote, specifier) => {
|
|
480
|
-
return `import ${quote}${resolveSelfConfigImportUrl(specifier)}${quote}`;
|
|
481
|
-
}).replace(/\bimport\s*\(\s*(["'])(vize(?:\/config)?)\1\s*\)/gu, (_match, quote, specifier) => {
|
|
482
|
-
return `import(${quote}${resolveSelfConfigImportUrl(specifier)}${quote})`;
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
function resolveSelfConfigImportUrl(specifier) {
|
|
486
|
-
const distTarget = specifier === "vize" ? path$1.join(PACKAGE_ROOT, "dist", "index.mjs") : path$1.join(PACKAGE_ROOT, "dist", "config.mjs");
|
|
487
|
-
const sourceTarget = path$1.join(PACKAGE_ROOT, "src", "config.ts");
|
|
488
|
-
return pathToFileURL(fs$1.existsSync(distTarget) ? distTarget : sourceTarget).href;
|
|
489
|
-
}
|
|
490
|
-
function parseJsonConfig(content, filePath) {
|
|
491
|
-
try {
|
|
492
|
-
return normalizeLoadedConfig(JSON.parse(content));
|
|
493
|
-
} catch (error) {
|
|
494
|
-
throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
function normalizeLoadedConfig(config) {
|
|
498
|
-
return require("@vizejs/native").normalizeVizeConfig(config ?? null);
|
|
499
|
-
}
|
|
500
|
-
function getErrorMessage(error) {
|
|
501
|
-
if (error instanceof Error) return error.message;
|
|
502
|
-
return String(error);
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
|
|
506
|
-
*/
|
|
507
|
-
function normalizeGlobalTypes(config) {
|
|
508
|
-
const resolvedConfig = "types" in config && typeof config.types === "object" && config.types !== null && !Array.isArray(config.types) ? config.types : config;
|
|
509
|
-
const result = {};
|
|
510
|
-
for (const [key, value] of Object.entries(resolvedConfig)) if (typeof value === "string") result[key] = { type: value };
|
|
511
|
-
else result[key] = value;
|
|
512
|
-
return result;
|
|
513
|
-
}
|
|
514
|
-
//#endregion
|
|
515
|
-
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 };
|
|
516
|
-
|
|
517
|
-
//# sourceMappingURL=config-C5DKms5s.mjs.map
|