vize 0.49.0 → 0.56.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/dist/config.mjs DELETED
@@ -1,156 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path$1 from "node:path";
3
- import { execFileSync } from "node:child_process";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
5
- import { transform } from "oxc-transform";
6
- //#region src/config.ts
7
- const CONFIG_FILE_NAMES = [
8
- "vize.config.ts",
9
- "vize.config.js",
10
- "vize.config.mjs",
11
- "vize.config.pkl",
12
- "vize.config.json"
13
- ];
14
- const DEFAULT_CONFIG_ENV = {
15
- mode: "development",
16
- command: "serve"
17
- };
18
- const PACKAGE_ROOT = path$1.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
19
- const VIZE_CONFIG_JSON_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "schemas", "vize.config.schema.json");
20
- const VIZE_CONFIG_PKL_SCHEMA_PATH = path$1.join(PACKAGE_ROOT, "pkl", "vize.pkl");
21
- /**
22
- * Define a Vize configuration with type checking.
23
- * Accepts a plain object or a function that receives ConfigEnv.
24
- */
25
- function defineConfig(config) {
26
- return config;
27
- }
28
- /**
29
- * Load `vize.config.*` from the specified directory.
30
- */
31
- async function loadConfig(root, options = {}) {
32
- const { mode = "root", configFile, env } = options;
33
- if (mode === "none") return null;
34
- if (configFile) {
35
- const absolutePath = path$1.isAbsolute(configFile) ? configFile : path$1.resolve(root, configFile);
36
- if (fs.existsSync(absolutePath)) return loadConfigFile(absolutePath, env);
37
- return null;
38
- }
39
- if (mode === "auto") {
40
- const configPath = findConfigFileAuto(root);
41
- if (!configPath) return null;
42
- return loadConfigFile(configPath, env);
43
- }
44
- const configPath = findConfigFileInDir(root);
45
- if (!configPath) return null;
46
- return loadConfigFile(configPath, env);
47
- }
48
- function findConfigFileInDir(dir) {
49
- for (const name of CONFIG_FILE_NAMES) {
50
- const filePath = path$1.join(dir, name);
51
- if (fs.existsSync(filePath)) return filePath;
52
- }
53
- return null;
54
- }
55
- function findConfigFileAuto(startDir) {
56
- let currentDir = path$1.resolve(startDir);
57
- while (true) {
58
- const configPath = findConfigFileInDir(currentDir);
59
- if (configPath) return configPath;
60
- const parentDir = path$1.dirname(currentDir);
61
- if (parentDir === currentDir) return null;
62
- currentDir = parentDir;
63
- }
64
- }
65
- async function loadConfigFile(filePath, env) {
66
- if (!fs.existsSync(filePath)) return null;
67
- const ext = path$1.extname(filePath);
68
- if (ext === ".json") return parseJsonConfig(fs.readFileSync(filePath, "utf-8"), filePath);
69
- if (ext === ".pkl") return loadPklConfig(filePath);
70
- if (ext === ".ts") return loadTypeScriptConfig(filePath, env);
71
- return loadESMConfig(filePath, env);
72
- }
73
- async function resolveConfigExport(exported, env) {
74
- if (typeof exported === "function") return exported(env ?? DEFAULT_CONFIG_ENV);
75
- return exported;
76
- }
77
- async function loadTypeScriptConfig(filePath, env) {
78
- const result = transform(filePath, fs.readFileSync(filePath, "utf-8"), { typescript: { onlyRemoveTypeImports: true } });
79
- const tempFile = filePath.replace(/\.ts$/, `.temp.${Date.now()}.mjs`);
80
- fs.writeFileSync(tempFile, result.code);
81
- try {
82
- const module = await importFresh(tempFile);
83
- return resolveConfigExport(module.default || module, env);
84
- } finally {
85
- fs.rmSync(tempFile, { force: true });
86
- }
87
- }
88
- async function loadESMConfig(filePath, env) {
89
- const module = await importFresh(filePath);
90
- return resolveConfigExport(module.default || module, env);
91
- }
92
- function loadPklConfig(filePath) {
93
- try {
94
- return parseJsonConfig(execFileSync("pkl", [
95
- "eval",
96
- "--format",
97
- "json",
98
- filePath
99
- ], {
100
- cwd: path$1.dirname(filePath),
101
- encoding: "utf-8",
102
- stdio: [
103
- "ignore",
104
- "pipe",
105
- "pipe"
106
- ]
107
- }), filePath);
108
- } catch (error) {
109
- throw new Error(`Failed to evaluate PKL config at ${filePath}. Make sure the 'pkl' CLI is installed and on PATH. ${getErrorMessage(error)}`);
110
- }
111
- }
112
- async function importFresh(filePath) {
113
- const fileUrl = pathToFileURL(filePath);
114
- fileUrl.searchParams.set("t", String(fs.statSync(filePath).mtimeMs));
115
- return import(fileUrl.href);
116
- }
117
- function parseJsonConfig(content, filePath) {
118
- try {
119
- return normalizeLoadedConfig(JSON.parse(content));
120
- } catch (error) {
121
- throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);
122
- }
123
- }
124
- function normalizeLoadedConfig(config) {
125
- return stripNullish(config) ?? {};
126
- }
127
- function stripNullish(value) {
128
- if (value === null) return;
129
- if (Array.isArray(value)) return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== void 0);
130
- if (typeof value === "object" && value !== null) {
131
- const result = {};
132
- for (const [key, entry] of Object.entries(value)) {
133
- const normalizedEntry = stripNullish(entry);
134
- if (normalizedEntry !== void 0) result[key] = normalizedEntry;
135
- }
136
- return result;
137
- }
138
- return value;
139
- }
140
- function getErrorMessage(error) {
141
- if (error instanceof Error) return error.message;
142
- return String(error);
143
- }
144
- /**
145
- * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
146
- */
147
- function normalizeGlobalTypes(config) {
148
- const result = {};
149
- for (const [key, value] of Object.entries(config)) if (typeof value === "string") result[key] = { type: value };
150
- else result[key] = value;
151
- return result;
152
- }
153
- //#endregion
154
- export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
155
-
156
- //# sourceMappingURL=config.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.mjs","names":["path"],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { execFileSync } from \"node:child_process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { transform } from \"oxc-transform\";\nimport type {\n VizeConfig,\n LoadConfigOptions,\n UserConfigExport,\n ConfigEnv,\n GlobalTypesConfig,\n GlobalTypeDeclaration,\n} from \"./types/index.js\";\n\nexport const CONFIG_FILE_NAMES = [\n \"vize.config.ts\",\n \"vize.config.js\",\n \"vize.config.mjs\",\n \"vize.config.pkl\",\n \"vize.config.json\",\n] as const;\n\nconst DEFAULT_CONFIG_ENV: ConfigEnv = {\n mode: \"development\",\n command: \"serve\",\n};\n\nconst PACKAGE_ROOT = path.resolve(fileURLToPath(new URL(\".\", import.meta.url)), \"..\");\n\nexport const VIZE_CONFIG_JSON_SCHEMA_PATH = path.join(\n PACKAGE_ROOT,\n \"schemas\",\n \"vize.config.schema.json\",\n);\n\nexport const VIZE_CONFIG_PKL_SCHEMA_PATH = path.join(PACKAGE_ROOT, \"pkl\", \"vize.pkl\");\n\n/**\n * Define a Vize configuration with type checking.\n * Accepts a plain object or a function that receives ConfigEnv.\n */\nexport function defineConfig(config: UserConfigExport): UserConfigExport {\n return config;\n}\n\n/**\n * Load `vize.config.*` from the specified directory.\n */\nexport async function loadConfig(\n root: string,\n options: LoadConfigOptions = {},\n): Promise<VizeConfig | null> {\n const { mode = \"root\", configFile, env } = options;\n\n if (mode === \"none\") {\n return null;\n }\n\n if (configFile) {\n const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);\n if (fs.existsSync(absolutePath)) {\n return loadConfigFile(absolutePath, env);\n }\n return null;\n }\n\n if (mode === \"auto\") {\n const configPath = findConfigFileAuto(root);\n if (!configPath) {\n return null;\n }\n return loadConfigFile(configPath, env);\n }\n\n const configPath = findConfigFileInDir(root);\n if (!configPath) {\n return null;\n }\n\n return loadConfigFile(configPath, env);\n}\n\nfunction findConfigFileInDir(dir: string): string | null {\n for (const name of CONFIG_FILE_NAMES) {\n const filePath = path.join(dir, name);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n return null;\n}\n\nfunction findConfigFileAuto(startDir: string): string | null {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const configPath = findConfigFileInDir(currentDir);\n if (configPath) {\n return configPath;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return null;\n }\n\n currentDir = parentDir;\n }\n}\n\nasync function loadConfigFile(filePath: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n\n const ext = path.extname(filePath);\n\n if (ext === \".json\") {\n const content = fs.readFileSync(filePath, \"utf-8\");\n return parseJsonConfig(content, filePath);\n }\n\n if (ext === \".pkl\") {\n return loadPklConfig(filePath);\n }\n\n if (ext === \".ts\") {\n return loadTypeScriptConfig(filePath, env);\n }\n\n return loadESMConfig(filePath, env);\n}\n\nasync function resolveConfigExport(\n exported: UserConfigExport,\n env?: ConfigEnv,\n): Promise<VizeConfig> {\n if (typeof exported === \"function\") {\n return exported(env ?? DEFAULT_CONFIG_ENV);\n }\n\n return exported;\n}\n\nasync function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const source = fs.readFileSync(filePath, \"utf-8\");\n const result = transform(filePath, source, {\n typescript: {\n onlyRemoveTypeImports: true,\n },\n });\n\n const tempFile = filePath.replace(/\\.ts$/, `.temp.${Date.now()}.mjs`);\n fs.writeFileSync(tempFile, result.code);\n\n try {\n const module = await importFresh(tempFile);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n } finally {\n fs.rmSync(tempFile, { force: true });\n }\n}\n\nasync function loadESMConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const module = await importFresh(filePath);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n}\n\nfunction loadPklConfig(filePath: string): VizeConfig {\n try {\n const output = execFileSync(\"pkl\", [\"eval\", \"--format\", \"json\", filePath], {\n cwd: path.dirname(filePath),\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return parseJsonConfig(output, filePath);\n } catch (error) {\n throw new Error(\n `Failed to evaluate PKL config at ${filePath}. Make sure the 'pkl' CLI is installed and on PATH. ${getErrorMessage(error)}`,\n );\n }\n}\n\nasync function importFresh(filePath: string): Promise<Record<string, unknown>> {\n const fileUrl = pathToFileURL(filePath);\n fileUrl.searchParams.set(\"t\", String(fs.statSync(filePath).mtimeMs));\n return import(fileUrl.href);\n}\n\nfunction parseJsonConfig(content: string, filePath: string): VizeConfig {\n try {\n return normalizeLoadedConfig(JSON.parse(content));\n } catch (error) {\n throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);\n }\n}\n\nfunction normalizeLoadedConfig(config: unknown): VizeConfig {\n const normalized = stripNullish(config);\n return (normalized ?? {}) as VizeConfig;\n}\n\nfunction stripNullish(value: unknown): unknown {\n if (value === null) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== undefined);\n }\n\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const normalizedEntry = stripNullish(entry);\n if (normalizedEntry !== undefined) {\n result[key] = normalizedEntry;\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects\n */\nexport function normalizeGlobalTypes(\n config: GlobalTypesConfig,\n): Record<string, GlobalTypeDeclaration> {\n const result: Record<string, GlobalTypeDeclaration> = {};\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"string\") {\n result[key] = { type: value };\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n"],"mappings":";;;;;;AAcA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAeA,OAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAErF,MAAa,+BAA+BA,OAAK,KAC/C,cACA,WACA,0BACD;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C;UAC1C,OAAO;AACd,QAAM,IAAI,MAAM,uCAAuC,SAAS,IAAI,gBAAgB,MAAM,GAAG;;;AAIjG,SAAS,sBAAsB,QAA6B;AAE1D,QADmB,aAAa,OAAO,IACjB,EAAE;;AAG1B,SAAS,aAAa,OAAyB;AAC7C,KAAI,UAAU,KACZ;AAGF,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAA,EAAU;AAGzF,KAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAkC,EAAE;AAC1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;GAChD,MAAM,kBAAkB,aAAa,MAAM;AAC3C,OAAI,oBAAoB,KAAA,EACtB,QAAO,OAAO;;AAGlB,SAAO;;AAGT,QAAO;;AAGT,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,QAAO,OAAO,MAAM;;;;;AAMtB,SAAgB,qBACd,QACuC;CACvC,MAAM,SAAgD,EAAE;AACxD,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAC/C,KAAI,OAAO,UAAU,SACnB,QAAO,OAAO,EAAE,MAAM,OAAO;KAE7B,QAAO,OAAO;AAGlB,QAAO"}
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
- import { C as LspConfig, D as CompilerConfig, E as LintRulesConfig, O as VitePluginConfig, S as LinterConfig, T as LintRuleName, _ as MuseaA11yConfig, a as loadConfig, b as MuseaVrtConfig, c as LintPreset, d as RuleSeverity, f as UserConfigExport, g as LoadConfigOptions, h as GlobalTypesConfig, i as defineConfig, l as MaybePromise, m as GlobalTypeDeclaration, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, p as VizeConfig, r as VIZE_CONFIG_PKL_SCHEMA_PATH, s as ConfigEnv, t as CONFIG_FILE_NAMES, u as RuleCategory, v as MuseaAutogenConfig, w as TypeCheckerConfig, x as FormatterConfig, y as MuseaConfig } from "./config-BbNk5gIK.mjs";
2
- export { CONFIG_FILE_NAMES, type CompilerConfig, type ConfigEnv, type FormatterConfig, type GlobalTypeDeclaration, type GlobalTypesConfig, type LintPreset, type LintRuleName, type LintRulesConfig, type LinterConfig, type LoadConfigOptions, type LspConfig, type MaybePromise, type MuseaA11yConfig, type MuseaAutogenConfig, type MuseaConfig, type MuseaVrtConfig, type RuleCategory, type RuleSeverity, type TypeCheckerConfig, type UserConfigExport, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, type VitePluginConfig, type VizeConfig, defineConfig, loadConfig, normalizeGlobalTypes };
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes } from "./config.mjs";
2
- export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };