vize 0.90.0 → 0.91.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 @@
1
+ {"version":3,"file":"config-XMCb6V8W.d.mts","names":[],"sources":["../src/types/generated.ts","../src/types/rules.ts","../src/types/runtime.ts","../src/types/index.ts","../src/config.ts"],"mappings":";;AAOA;;;;KAAY,UAAA;AAAA,KAEA,YAAA;AAAA,KAEA,YAAA;;;;UAKK,UAAA;EACf,QAAA,GAAW,cAAA;EACX,IAAA,GAAO,gBAAA;EACP,MAAA,GAAS,YAAA;EACT,WAAA,GAAc,iBAAA;EACd,SAAA,GAAY,eAAA;EACZ,cAAA,GAAiB,oBAAA;EACjB,GAAA,GAAM,oBAAA;EACN,KAAA,GAAQ,WAAA;EACR,WAAA,GAAc,iBAAA;AAAA;;;;UAKC,cAAA;EANP;;;EAUR,IAAA;EAjBA;;;EAqBA,KAAA;EAnBA;;;EAuBA,GAAA;EArBA;;;EAyBA,SAAA;EAvBA;;;EA2BA,iBAAA;EAzBA;;;EA6BA,WAAA;EAxBe;;;EA4Bf,aAAA;EAxBA;;;EA4BA,IAAA;EAZA;;;EAgBA,SAAA;EAAA;;;EAIA,iBAAA;EAIiB;AAKnB;;EALE,iBAAA;AAAA;;;;UAKe,gBAAA;EAQ6B;;;EAJ5C,OAAA,YAAmB,MAAA,aAAmB,MAAA;EAItC;;;EAAA,OAAA,YAAmB,MAAA,aAAmB,MAAA;EAQtC;;;EAJA,YAAA;EAS2B;;;EAL3B,cAAA;AAAA;;;;UAKe,YAAA;EAoBb;;;EAhBF,OAAA;EAoBE;;;EAhBF,MAAA;EAsBgC;;;EAlBhC,KAAA;IAAA,CACG,CAAA;EAAA;EAiCH;;;EA5BA,UAAA;IACE,WAAA;IACA,UAAA;IACA,KAAA;IACA,IAAA;IACA,IAAA;IACA,QAAA;EAAA;AAAA;AA+DJ;;;AAAA,UAzDiB,iBAAA;EA6Df;;;EAzDA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AM,SAAA;AAAA;;;;;;KCrBI,SAAA,GAAS,oBAAA;;;cCVR,iBAAA;AAAA,cAeA,4BAAA;AAAA,cAMA,2BAAA;;;AJ3Bb;;iBIqCgB,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,gBAAA;;;AJnCxD;iBI0CsB,UAAA,CACpB,IAAA,UACA,OAAA,GAAS,iBAAA,GACR,OAAA,CAAQ,UAAA;;;;iBAqOK,oBAAA,CACd,MAAA,EAAQ,iBAAA,GACP,MAAA,SAAe,qBAAA"}
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as loadConfig, i as defineConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, r as VIZE_CONFIG_PKL_SCHEMA_PATH, t as CONFIG_FILE_NAMES } from "./config-CTXni-Py.mjs";
1
+ import { a as loadConfig, i as defineConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, r as VIZE_CONFIG_PKL_SCHEMA_PATH, t as CONFIG_FILE_NAMES } from "./config-XMCb6V8W.mjs";
2
2
  export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
package/dist/config.mjs CHANGED
@@ -1,15 +1,14 @@
1
1
  import * as fs from "node:fs";
2
- import * as os from "node:os";
3
2
  import * as path from "node:path";
4
3
  import { execFileSync } from "node:child_process";
5
4
  import { fileURLToPath, pathToFileURL } from "node:url";
6
5
  import { transform } from "oxc-transform";
7
6
  //#region src/config.ts
8
7
  const CONFIG_FILE_NAMES = [
8
+ "vize.config.pkl",
9
9
  "vize.config.ts",
10
10
  "vize.config.js",
11
11
  "vize.config.mjs",
12
- "vize.config.pkl",
13
12
  "vize.config.json"
14
13
  ];
15
14
  const DEFAULT_CONFIG_ENV = {
@@ -37,71 +36,68 @@ async function loadConfig(root, options = {}) {
37
36
  if (fs.existsSync(absolutePath)) return loadConfigFile(absolutePath, env);
38
37
  return null;
39
38
  }
40
- if (mode === "auto") {
41
- const configPath = findConfigFileAuto(root);
42
- if (!configPath) return null;
43
- return loadConfigFile(configPath, env);
44
- }
45
- const configPath = findConfigFileInDir(root);
46
- if (!configPath) return null;
47
- return loadConfigFile(configPath, env);
39
+ if (mode === "auto") return loadConfigFromDirAuto(root, env);
40
+ return loadConfigFromDir(root, env);
48
41
  }
49
- function findConfigFileInDir(dir) {
42
+ async function loadConfigFromDir(dir, env) {
50
43
  for (const name of CONFIG_FILE_NAMES) {
51
44
  const filePath = path.join(dir, name);
52
- if (fs.existsSync(filePath)) return filePath;
45
+ if (!fs.existsSync(filePath)) continue;
46
+ const config = await loadConfigFile(filePath, env);
47
+ if (config !== null) return config;
53
48
  }
54
49
  return null;
55
50
  }
56
- function findConfigFileAuto(startDir) {
51
+ async function loadConfigFromDirAuto(startDir, env) {
57
52
  let currentDir = path.resolve(startDir);
58
53
  while (true) {
59
- const configPath = findConfigFileInDir(currentDir);
60
- if (configPath) return configPath;
54
+ const config = await loadConfigFromDir(currentDir, env);
55
+ if (config !== null) return config;
61
56
  const parentDir = path.dirname(currentDir);
62
57
  if (parentDir === currentDir) return null;
63
58
  currentDir = parentDir;
64
59
  }
65
60
  }
66
61
  async function loadConfigFile(filePath, env) {
67
- if (!fs.existsSync(filePath)) return null;
68
- const ext = path.extname(filePath);
69
- if (ext === ".json") return parseJsonConfig(fs.readFileSync(filePath, "utf-8"), filePath);
70
- if (ext === ".pkl") return loadPklConfig(filePath);
71
- if (ext === ".ts") return loadTypeScriptConfig(filePath, env);
72
- return loadESMConfig(filePath, env);
62
+ const absolutePath = path.resolve(filePath);
63
+ if (!fs.existsSync(absolutePath)) return null;
64
+ const ext = path.extname(absolutePath);
65
+ if (ext === ".pkl") return loadPklConfig(absolutePath);
66
+ if (ext === ".json") return parseJsonConfig(fs.readFileSync(absolutePath, "utf-8"), absolutePath);
67
+ if (ext === ".ts") return loadTypeScriptConfig(absolutePath, env);
68
+ return loadESMConfig(absolutePath, env);
73
69
  }
74
- async function resolveConfigExport(exported, env) {
75
- if (typeof exported === "function") return exported(env ?? DEFAULT_CONFIG_ENV);
76
- return exported;
77
- }
78
- async function loadTypeScriptConfig(filePath, env) {
79
- const result = transform(filePath, fs.readFileSync(filePath, "utf-8"), { typescript: { onlyRemoveTypeImports: true } });
80
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "vize-config-"));
81
- const tempFile = path.join(tempDir, "config.mjs");
82
- fs.writeFileSync(tempFile, result.code, {
83
- flag: "wx",
84
- mode: 384
85
- });
70
+ function findPklBinary() {
86
71
  try {
87
- const module = await importFresh(tempFile);
88
- return resolveConfigExport(module.default || module, env);
89
- } finally {
90
- fs.rmSync(tempDir, {
91
- recursive: true,
92
- force: true
93
- });
72
+ const pklPkgPath = import.meta.resolve?.("@pkl-community/pkl");
73
+ if (pklPkgPath) {
74
+ const pklLibDir = path.dirname(fileURLToPath(pklPkgPath));
75
+ const pklPackageDir = path.dirname(pklLibDir);
76
+ const candidates = [
77
+ path.join(pklLibDir, "main.js"),
78
+ path.join(pklPackageDir, "pkl"),
79
+ path.join(pklPackageDir, "pkl.exe")
80
+ ];
81
+ for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
82
+ }
83
+ } catch {}
84
+ try {
85
+ execFileSync("pkl", ["--version"], { stdio: "ignore" });
86
+ return "pkl";
87
+ } catch {
88
+ return null;
94
89
  }
95
90
  }
96
- async function loadESMConfig(filePath, env) {
97
- const module = await importFresh(filePath);
98
- return resolveConfigExport(module.default || module, env);
99
- }
100
91
  function loadPklConfig(filePath) {
92
+ const pklBin = findPklBinary();
93
+ if (!pklBin) {
94
+ console.warn("[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. Falling back to the next config format.");
95
+ return null;
96
+ }
101
97
  try {
102
- return parseJsonConfig(execFileSync("pkl", [
98
+ return parseJsonConfig(execFileSync(pklBin, [
103
99
  "eval",
104
- "--format",
100
+ "-f",
105
101
  "json",
106
102
  filePath
107
103
  ], {
@@ -111,12 +107,36 @@ function loadPklConfig(filePath) {
111
107
  "ignore",
112
108
  "pipe",
113
109
  "pipe"
114
- ]
110
+ ],
111
+ timeout: 3e4
115
112
  }), filePath);
116
113
  } catch (error) {
117
- throw new Error(`Failed to evaluate PKL config at ${filePath}. Make sure the 'pkl' CLI is installed and on PATH. ${getErrorMessage(error)}`);
114
+ console.warn(`[vize] Failed to evaluate ${filePath}: ${getErrorMessage(error)}`);
115
+ return null;
118
116
  }
119
117
  }
118
+ async function resolveConfigExport(exported, env) {
119
+ if (typeof exported === "function") return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));
120
+ return normalizeLoadedConfig(exported);
121
+ }
122
+ async function loadTypeScriptConfig(filePath, env) {
123
+ const result = transform(filePath, fs.readFileSync(filePath, "utf-8"), { typescript: { onlyRemoveTypeImports: true } });
124
+ const tempFile = path.join(path.dirname(filePath), `.vize-config-${process.pid}-${Date.now()}.mjs`);
125
+ fs.writeFileSync(tempFile, result.code, {
126
+ flag: "wx",
127
+ mode: 384
128
+ });
129
+ try {
130
+ const module = await importFresh(tempFile);
131
+ return resolveConfigExport(module.default || module, env);
132
+ } finally {
133
+ fs.rmSync(tempFile, { force: true });
134
+ }
135
+ }
136
+ async function loadESMConfig(filePath, env) {
137
+ const module = await importFresh(filePath);
138
+ return resolveConfigExport(module.default || module, env);
139
+ }
120
140
  async function importFresh(filePath) {
121
141
  const fileUrl = pathToFileURL(filePath);
122
142
  fileUrl.searchParams.set("t", String(fs.statSync(filePath).mtimeMs));
@@ -130,7 +150,7 @@ function parseJsonConfig(content, filePath) {
130
150
  }
131
151
  }
132
152
  function normalizeLoadedConfig(config) {
133
- return stripNullish(config) ?? {};
153
+ return normalizeConfigAliases(stripNullish(config) ?? {});
134
154
  }
135
155
  function stripNullish(value) {
136
156
  if (value === null) return;
@@ -153,11 +173,21 @@ function getErrorMessage(error) {
153
173
  * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
154
174
  */
155
175
  function normalizeGlobalTypes(config) {
176
+ const resolvedConfig = "types" in config && typeof config.types === "object" && config.types !== null && !Array.isArray(config.types) ? config.types : config;
156
177
  const result = {};
157
- for (const [key, value] of Object.entries(config)) if (typeof value === "string") result[key] = { type: value };
178
+ for (const [key, value] of Object.entries(resolvedConfig)) if (typeof value === "string") result[key] = { type: value };
158
179
  else result[key] = value;
159
180
  return result;
160
181
  }
182
+ function normalizeConfigAliases(config) {
183
+ if (config.lsp === void 0) return config;
184
+ const { lsp, ...rest } = config;
185
+ if (config.languageServer !== void 0) return rest;
186
+ return {
187
+ ...rest,
188
+ languageServer: lsp
189
+ };
190
+ }
161
191
  //#endregion
162
192
  export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
163
193
 
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as os from \"node:os\";\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 tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"vize-config-\"));\n const tempFile = path.join(tempDir, \"config.mjs\");\n fs.writeFileSync(tempFile, result.code, { flag: \"wx\", mode: 0o600 });\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(tempDir, { recursive: true, 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":";;;;;;;AAeA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAe,KAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAErF,MAAa,+BAA+B,KAAK,KAC/C,cACA,WACA,0BACD;AAED,MAAa,8BAA8B,KAAK,KAAK,cAAc,OAAO,WAAW;;;;;AAMrF,SAAgB,aAAa,QAA4C;CACvE,OAAO;;;;;AAMT,eAAsB,WACpB,MACA,UAA6B,EAAE,EACH;CAC5B,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ;CAE3C,IAAI,SAAS,QACX,OAAO;CAGT,IAAI,YAAY;EACd,MAAM,eAAe,KAAK,WAAW,WAAW,GAAG,aAAa,KAAK,QAAQ,MAAM,WAAW;EAC9F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M,EACtB,OAAO,MAAM,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAA,EAAU;CAGzF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAkC,EAAE;EAC1C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;GAChD,MAAM,kBAAkB,aAAa,MAAM;GAC3C,IAAI,oBAAoB,KAAA,GACtB,OAAO,OAAO;;EAGlB,OAAO;;CAGT,OAAO;;AAGT,SAAS,gBAAgB,OAAwB;CAC/C,IAAI,iBAAiB,OACnB,OAAO,MAAM;CAGf,OAAO,OAAO,MAAM;;;;;AAMtB,SAAgB,qBACd,QACuC;CACvC,MAAM,SAAgD,EAAE;CACxD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAC/C,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,EAAE,MAAM,OAAO;MAE7B,OAAO,OAAO;CAGlB,OAAO"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { execFileSync } from \"node:child_process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { transform } from \"oxc-transform\";\nimport type {\n LanguageServerConfig,\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.pkl\",\n \"vize.config.ts\",\n \"vize.config.js\",\n \"vize.config.mjs\",\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\ntype CompatVizeConfig = VizeConfig & {\n lsp?: LanguageServerConfig;\n};\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 return loadConfigFromDirAuto(root, env);\n }\n\n return loadConfigFromDir(root, env);\n}\n\nasync function loadConfigFromDir(dir: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n for (const name of CONFIG_FILE_NAMES) {\n const filePath = path.join(dir, name);\n if (!fs.existsSync(filePath)) {\n continue;\n }\n\n const config = await loadConfigFile(filePath, env);\n if (config !== null) {\n return config;\n }\n }\n return null;\n}\n\nasync function loadConfigFromDirAuto(\n startDir: string,\n env?: ConfigEnv,\n): Promise<VizeConfig | null> {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const config = await loadConfigFromDir(currentDir, env);\n if (config !== null) {\n return config;\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 const absolutePath = path.resolve(filePath);\n if (!fs.existsSync(absolutePath)) {\n return null;\n }\n\n const ext = path.extname(absolutePath);\n\n if (ext === \".pkl\") {\n return loadPklConfig(absolutePath);\n }\n\n if (ext === \".json\") {\n const content = fs.readFileSync(absolutePath, \"utf-8\");\n return parseJsonConfig(content, absolutePath);\n }\n\n if (ext === \".ts\") {\n return loadTypeScriptConfig(absolutePath, env);\n }\n\n return loadESMConfig(absolutePath, env);\n}\n\nfunction findPklBinary(): string | null {\n try {\n const pklPkgPath = import.meta.resolve?.(\"@pkl-community/pkl\");\n if (pklPkgPath) {\n const pklLibDir = path.dirname(fileURLToPath(pklPkgPath));\n const pklPackageDir = path.dirname(pklLibDir);\n const candidates = [\n path.join(pklLibDir, \"main.js\"),\n path.join(pklPackageDir, \"pkl\"),\n path.join(pklPackageDir, \"pkl.exe\"),\n ];\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n }\n }\n } catch {\n // Fall back to PATH below.\n }\n\n try {\n execFileSync(\"pkl\", [\"--version\"], { stdio: \"ignore\" });\n return \"pkl\";\n } catch {\n return null;\n }\n}\n\nfunction loadPklConfig(filePath: string): VizeConfig | null {\n const pklBin = findPklBinary();\n if (!pklBin) {\n console.warn(\n \"[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. \" +\n \"Falling back to the next config format.\",\n );\n return null;\n }\n\n try {\n const output = execFileSync(pklBin, [\"eval\", \"-f\", \"json\", filePath], {\n cwd: path.dirname(filePath),\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n timeout: 30_000,\n });\n return parseJsonConfig(output, filePath);\n } catch (error) {\n console.warn(`[vize] Failed to evaluate ${filePath}: ${getErrorMessage(error)}`);\n return null;\n }\n}\n\nasync function resolveConfigExport(\n exported: UserConfigExport,\n env?: ConfigEnv,\n): Promise<VizeConfig> {\n if (typeof exported === \"function\") {\n return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));\n }\n\n return normalizeLoadedConfig(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 = path.join(\n path.dirname(filePath),\n `.vize-config-${process.pid}-${Date.now()}.mjs`,\n );\n fs.writeFileSync(tempFile, result.code, { flag: \"wx\", mode: 0o600 });\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\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 normalizeConfigAliases((normalized ?? {}) as CompatVizeConfig);\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 resolvedConfig =\n \"types\" in config &&\n typeof config.types === \"object\" &&\n config.types !== null &&\n !Array.isArray(config.types)\n ? config.types\n : config;\n\n const result: Record<string, GlobalTypeDeclaration> = {};\n for (const [key, value] of Object.entries(resolvedConfig)) {\n if (typeof value === \"string\") {\n result[key] = { type: value };\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction normalizeConfigAliases(config: CompatVizeConfig): VizeConfig {\n if (config.lsp === undefined) {\n return config;\n }\n\n const { lsp, ...rest } = config;\n if (config.languageServer !== undefined) {\n return rest;\n }\n\n return {\n ...rest,\n languageServer: lsp,\n };\n}\n"],"mappings":";;;;;;AAeA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAe,KAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAErF,MAAa,+BAA+B,KAAK,KAC/C,cACA,WACA,0BACD;AAED,MAAa,8BAA8B,KAAK,KAAK,cAAc,OAAO,WAAW;;;;;AAUrF,SAAgB,aAAa,QAA4C;CACvE,OAAO;;;;;AAMT,eAAsB,WACpB,MACA,UAA6B,EAAE,EACH;CAC5B,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ;CAE3C,IAAI,SAAS,QACX,OAAO;CAGT,IAAI,YAAY;EACd,MAAM,eAAe,KAAK,WAAW,WAAW,GAAG,aAAa,KAAK,QAAQ,MAAM,WAAW;EAC9F,IAAI,GAAG,WAAW,aAAa,EAC7B,OAAO,eAAe,cAAc,IAAI;EAE1C,OAAO;;CAGT,IAAI,SAAS,QACX,OAAO,sBAAsB,MAAM,IAAI;CAGzC,OAAO,kBAAkB,MAAM,IAAI;;AAGrC,eAAe,kBAAkB,KAAa,KAA6C;CACzF,KAAK,MAAM,QAAQ,mBAAmB;EACpC,MAAM,WAAW,KAAK,KAAK,KAAK,KAAK;EACrC,I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5B,OAAO;CAGT,OAAO;EACL,GAAG;EACH,gBAAgB;EACjB"}
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
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-CTXni-Py.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 };
1
+ import { C as MuseaConfig, D as TypeCheckerConfig, E as RuleSeverity, O as VitePluginConfig, S as MuseaAutogenConfig, T as RuleCategory, _ as GlobalTypesConfig, a as loadConfig, b as LinterConfig, c as ConfigEnv, d as UserConfigExport, f as LintRuleName, g as GlobalTypeDeclaration, h as FormatterConfig, i as defineConfig, k as VizeConfig, l as LoadConfigOptions, m as CompilerConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, p as LintRulesConfig, r as VIZE_CONFIG_PKL_SCHEMA_PATH, s as LspConfig, t as CONFIG_FILE_NAMES, u as MaybePromise, v as LanguageServerConfig, w as MuseaVrtConfig, x as MuseaA11yConfig, y as LintPreset } from "./config-XMCb6V8W.mjs";
2
+ export { CONFIG_FILE_NAMES, type CompilerConfig, type ConfigEnv, type FormatterConfig, type GlobalTypeDeclaration, type GlobalTypesConfig, type LanguageServerConfig, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vize",
3
- "version": "0.90.0",
3
+ "version": "0.91.0",
4
4
  "description": "Vize - High-performance Vue.js toolchain in Rust",
5
5
  "keywords": [
6
6
  "cli",
@@ -56,14 +56,15 @@
56
56
  "vite-plus": "0.1.21"
57
57
  },
58
58
  "optionalDependencies": {
59
- "@vizejs/native-darwin-arm64": "0.90.0",
60
- "@vizejs/native-darwin-x64": "0.90.0",
61
- "@vizejs/native-linux-arm64-gnu": "0.90.0",
62
- "@vizejs/native-linux-arm64-musl": "0.90.0",
63
- "@vizejs/native-linux-x64-gnu": "0.90.0",
64
- "@vizejs/native-linux-x64-musl": "0.90.0",
65
- "@vizejs/native-win32-arm64-msvc": "0.90.0",
66
- "@vizejs/native-win32-x64-msvc": "0.90.0"
59
+ "@pkl-community/pkl": "0.27.2",
60
+ "@vizejs/native-darwin-arm64": "0.91.0",
61
+ "@vizejs/native-darwin-x64": "0.91.0",
62
+ "@vizejs/native-linux-arm64-gnu": "0.91.0",
63
+ "@vizejs/native-linux-arm64-musl": "0.91.0",
64
+ "@vizejs/native-linux-x64-gnu": "0.91.0",
65
+ "@vizejs/native-linux-x64-musl": "0.91.0",
66
+ "@vizejs/native-win32-arm64-msvc": "0.91.0",
67
+ "@vizejs/native-win32-x64-msvc": "0.91.0"
67
68
  },
68
69
  "engines": {
69
70
  "node": ">=22"
@@ -0,0 +1,37 @@
1
+ /// Compiler configuration for Vize.
2
+ module vize.CompilerConfig
3
+
4
+ class CompilerConfig {
5
+ /// Compilation mode.
6
+ mode: ("module"|"function") = "module"
7
+
8
+ /// Enable Vapor mode compilation.
9
+ vapor: Boolean = false
10
+
11
+ /// Enable SSR mode.
12
+ ssr: Boolean = false
13
+
14
+ /// Enable source map generation.
15
+ sourceMap: Boolean = false
16
+
17
+ /// Prefix template identifiers with _ctx.
18
+ prefixIdentifiers: Boolean = false
19
+
20
+ /// Hoist static nodes.
21
+ hoistStatic: Boolean = true
22
+
23
+ /// Cache v-on handlers.
24
+ cacheHandlers: Boolean = true
25
+
26
+ /// Enable TypeScript parsing in <script> blocks.
27
+ isTs: Boolean = true
28
+
29
+ /// Script file extension for generated output.
30
+ scriptExt: ("ts"|"js") = "ts"
31
+
32
+ /// Module name for runtime imports.
33
+ runtimeModuleName: String = "vue"
34
+
35
+ /// Global variable name for runtime (IIFE builds).
36
+ runtimeGlobalName: String = "Vue"
37
+ }
@@ -0,0 +1,67 @@
1
+ /// Formatter configuration for Vize.
2
+ module vize.FormatterConfig
3
+
4
+ class FormatterConfig {
5
+ /// Maximum line width.
6
+ printWidth: Int = 100
7
+
8
+ /// Indentation width.
9
+ tabWidth: Int = 2
10
+
11
+ /// Use tabs for indentation.
12
+ useTabs: Boolean = false
13
+
14
+ /// Print semicolons.
15
+ semi: Boolean = true
16
+
17
+ /// Use single quotes.
18
+ singleQuote: Boolean = false
19
+
20
+ /// Use single quotes in JSX.
21
+ jsxSingleQuote: Boolean = false
22
+
23
+ /// Trailing comma mode.
24
+ trailingComma: ("all"|"none"|"es5") = "all"
25
+
26
+ /// Print spaces between brackets in object literals.
27
+ bracketSpacing: Boolean = true
28
+
29
+ /// Keep > on the last line of multiline tags.
30
+ bracketSameLine: Boolean = false
31
+
32
+ /// Arrow parens mode.
33
+ arrowParens: ("always"|"avoid") = "always"
34
+
35
+ /// End-of-line mode.
36
+ endOfLine: ("lf"|"crlf"|"cr"|"auto") = "lf"
37
+
38
+ /// Quote properties mode.
39
+ quoteProps: ("as-needed"|"consistent"|"preserve") = "as-needed"
40
+
41
+ /// Force one attribute per line.
42
+ singleAttributePerLine: Boolean = false
43
+
44
+ /// Indent script/style blocks.
45
+ vueIndentScriptAndStyle: Boolean = false
46
+
47
+ /// Sort attributes.
48
+ sortAttributes: Boolean = true
49
+
50
+ /// Attribute ordering strategy.
51
+ attributeSortOrder: ("alphabetical"|"as-written") = "alphabetical"
52
+
53
+ /// Merge bind and non-bind attrs for sorting.
54
+ mergeBindAndNonBindAttrs: Boolean = false
55
+
56
+ /// Maximum attributes per line before wrapping.
57
+ maxAttributesPerLine: Int? = null
58
+
59
+ /// Custom attribute groups.
60
+ attributeGroups: Listing<Listing<String>>? = null
61
+
62
+ /// Normalize directive shorthands.
63
+ normalizeDirectiveShorthands: Boolean = true
64
+
65
+ /// Sort SFC blocks in canonical order.
66
+ sortBlocks: Boolean = true
67
+ }
@@ -0,0 +1,15 @@
1
+ /// Global type declarations configuration for Vize.
2
+ module vize.GlobalTypesConfig
3
+
4
+ class TypeDeclaration {
5
+ /// TypeScript type string.
6
+ type: String
7
+
8
+ /// Default value expression for virtual TS stubs.
9
+ defaultValue: String? = null
10
+ }
11
+
12
+ class GlobalTypesConfig {
13
+ /// Global type declarations.
14
+ types: Mapping<String, TypeDeclaration> = new Mapping {}
15
+ }
@@ -0,0 +1,70 @@
1
+ /// Language server configuration for Vize.
2
+ module vize.LanguageServerConfig
3
+
4
+ class LanguageServerConfig {
5
+ /// Enable the language server.
6
+ enabled: Boolean? = null
7
+
8
+ /// Enable lint diagnostics.
9
+ lint: Boolean? = null
10
+
11
+ /// Deprecated alias for `lint`.
12
+ diagnostics: Boolean? = null
13
+
14
+ /// Enable project type checking diagnostics.
15
+ typecheck: Boolean? = null
16
+
17
+ /// Enable editor-oriented IDE features.
18
+ editor: Boolean? = null
19
+
20
+ /// Enable completions.
21
+ completion: Boolean? = null
22
+
23
+ /// Enable hover information.
24
+ hover: Boolean? = null
25
+
26
+ /// Enable go-to-definition.
27
+ definition: Boolean? = null
28
+
29
+ /// Enable reference search.
30
+ references: Boolean? = null
31
+
32
+ /// Enable document symbols.
33
+ documentSymbols: Boolean? = null
34
+
35
+ /// Enable workspace symbols.
36
+ workspaceSymbols: Boolean? = null
37
+
38
+ /// Enable formatting via the language server.
39
+ formatting: Boolean? = null
40
+
41
+ /// Enable code actions.
42
+ codeActions: Boolean? = null
43
+
44
+ /// Enable rename support.
45
+ rename: Boolean? = null
46
+
47
+ /// Enable code lenses.
48
+ codeLens: Boolean? = null
49
+
50
+ /// Enable semantic tokens.
51
+ semanticTokens: Boolean? = null
52
+
53
+ /// Enable document links.
54
+ documentLinks: Boolean? = null
55
+
56
+ /// Enable folding ranges.
57
+ foldingRanges: Boolean? = null
58
+
59
+ /// Enable inlay hints.
60
+ inlayHints: Boolean? = null
61
+
62
+ /// Enable file rename edits.
63
+ fileRename: Boolean? = null
64
+
65
+ /// Enable Corsa-backed IDE features.
66
+ corsa: Boolean? = null
67
+
68
+ /// Deprecated alias for `corsa`.
69
+ tsgo: Boolean? = null
70
+ }
@@ -0,0 +1,17 @@
1
+ /// Linter configuration for Vize.
2
+ module vize.LinterConfig
3
+
4
+ typealias RuleSeverity = "off"|"warn"|"error"
5
+
6
+ typealias RuleCategory = "correctness"|"suspicious"|"style"|"perf"|"a11y"|"security"
7
+
8
+ class LinterConfig {
9
+ /// Enable linting.
10
+ enabled: Boolean = true
11
+
12
+ /// Rules to enable/disable.
13
+ rules: Mapping<String, RuleSeverity> = new Mapping {}
14
+
15
+ /// Category-level severity overrides.
16
+ categories: Mapping<RuleCategory, RuleSeverity> = new Mapping {}
17
+ }
@@ -0,0 +1,6 @@
1
+ /// Deprecated alias for `LanguageServerConfig.pkl`.
2
+ module vize.LspConfig
3
+
4
+ import "LanguageServerConfig.pkl"
5
+
6
+ typealias LspConfig = LanguageServerConfig.LanguageServerConfig
@@ -0,0 +1,38 @@
1
+ /// Musea component gallery configuration for Vize.
2
+ module vize.MuseaConfig
3
+
4
+ class Viewport {
5
+ width: Int
6
+ height: Int
7
+ name: String? = null
8
+ }
9
+
10
+ class VrtConfig {
11
+ threshold: Float = 0.1
12
+ outDir: String = "__musea_snapshots__"
13
+ viewports: Listing<Viewport> = new Listing {}
14
+ }
15
+
16
+ class A11yConfig {
17
+ enabled: Boolean = false
18
+ rules: Mapping<String, Boolean> = new Mapping {}
19
+ }
20
+
21
+ class AutogenConfig {
22
+ enabled: Boolean = false
23
+ maxVariants: Int = 10
24
+ }
25
+
26
+ class MuseaConfig {
27
+ include: Listing<String> = new Listing { "**/*.art.vue" }
28
+ exclude: Listing<String> = new Listing {
29
+ "node_modules/**"
30
+ "dist/**"
31
+ }
32
+ basePath: String = "/__musea__"
33
+ storybookCompat: Boolean = false
34
+ inlineArt: Boolean = false
35
+ vrt: VrtConfig = new VrtConfig {}
36
+ a11y: A11yConfig = new A11yConfig {}
37
+ autogen: AutogenConfig = new AutogenConfig {}
38
+ }
package/pkl/PklProject ADDED
@@ -0,0 +1,16 @@
1
+ amends "pkl:Project"
2
+
3
+ package {
4
+ name = "vize"
5
+ version = "0.25.0"
6
+ baseUri = "package://pkg.pkl-lang.org/github.com/ubugeeei/vize/vize"
7
+ packageZipUrl = "https://github.com/ubugeeei/vize/releases/download/v\(version)/vize@\(version).zip"
8
+ description = "Pkl schema for Vize configuration"
9
+ authors {
10
+ "ubugeeei <ubugeeei@users.noreply.github.com>"
11
+ }
12
+ }
13
+
14
+ dependencies {
15
+ ["json_schema"] { uri = "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.1.0" }
16
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "resolvedDependencies": {
4
+ "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1": {
5
+ "type": "remote",
6
+ "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.1.0",
7
+ "checksums": {
8
+ "sha256": "d4d55e43325eb781b011846988e9a2f5ddf3d8265acef2d4757fb02f9fd9fd4e"
9
+ }
10
+ },
11
+ "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": {
12
+ "type": "remote",
13
+ "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3",
14
+ "checksums": {
15
+ "sha256": "0b1db5755fa0c7651d5c62e0d5ef8a9ed4ed6411fe31769d06714600162e1589"
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,43 @@
1
+ /// Type checker configuration for Vize.
2
+ module vize.TypeCheckerConfig
3
+
4
+ class TypeCheckerConfig {
5
+ /// Enable type checking.
6
+ enabled: Boolean = true
7
+
8
+ /// Enable strict mode.
9
+ strict: Boolean = false
10
+
11
+ /// Check component props.
12
+ checkProps: Boolean = true
13
+
14
+ /// Check component emits.
15
+ checkEmits: Boolean = true
16
+
17
+ /// Check template bindings.
18
+ checkTemplateBindings: Boolean = true
19
+
20
+ /// Check reactivity loss patterns.
21
+ checkReactivity: Boolean = true
22
+
23
+ /// Check setup context violations.
24
+ checkSetupContext: Boolean = true
25
+
26
+ /// Check invalid exports in <script setup>.
27
+ checkInvalidExports: Boolean = true
28
+
29
+ /// Check fallthrough attrs on multi-root templates.
30
+ checkFallthroughAttrs: Boolean = true
31
+
32
+ /// Path to tsconfig.json.
33
+ tsconfig: String? = null
34
+
35
+ /// Path to tsgo binary.
36
+ tsgoPath: String? = null
37
+
38
+ /// Path to a .d.ts file that declares template globals.
39
+ globalsFile: String? = null
40
+
41
+ /// Number of parallel Corsa servers to use.
42
+ servers: Int? = null
43
+ }