@vizejs/nuxt 0.429.0 → 0.429.2
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/{addons-7LzN4Qa1.d.mts → addons-CrR0MCzZ.d.mts} +12 -0
- package/dist/{generation-0O5ZoaRp.mjs → generation-CXADZreI.mjs} +136 -14
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +54 -45
- package/dist/lint/index.d.mts +18 -4
- package/dist/lint/index.mjs +1 -1
- package/package.json +7 -7
|
@@ -403,8 +403,20 @@ interface NuxtLintConfigAddon {
|
|
|
403
403
|
name: string;
|
|
404
404
|
getConfigs(): NuxtLintAwaitable<readonly NuxtLintConfigItem[] | undefined>;
|
|
405
405
|
}
|
|
406
|
+
/** Nuxt options that decide whether an unimport registry is actually injected. */
|
|
407
|
+
interface NuxtLintAutoImportOptions {
|
|
408
|
+
imports?: false | {
|
|
409
|
+
autoImport?: boolean;
|
|
410
|
+
};
|
|
411
|
+
nitro?: {
|
|
412
|
+
imports?: false | {
|
|
413
|
+
autoImport?: boolean;
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
}
|
|
406
417
|
/** The Nuxt hook surface used by lint config addons. */
|
|
407
418
|
interface NuxtLintConfigAddonNuxt {
|
|
419
|
+
options?: NuxtLintAutoImportOptions;
|
|
408
420
|
hook(name: "imports:context" | "nitro:init", callback: (value: unknown) => unknown): void;
|
|
409
421
|
callHook(name: typeof VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, addons: NuxtLintConfigAddon[]): NuxtLintAwaitable<void>;
|
|
410
422
|
}
|
|
@@ -3,12 +3,19 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { glob, lstat, mkdir, open, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
6
|
-
import { Worker, isMainThread, parentPort } from "node:worker_threads";
|
|
7
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { Worker, isMainThread, parentPort } from "node:worker_threads";
|
|
8
8
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
9
9
|
import { buildNuxtLintPlan, collectNuxtLintDirs, resolveNuxtLintFeatures } from "@vizejs/nuxt-lint-config";
|
|
10
10
|
import { createServer } from "node:http";
|
|
11
11
|
//#region src/builder.ts
|
|
12
|
+
function getDetectedNuxtMajor(nuxt) {
|
|
13
|
+
const nuxtLike = nuxt;
|
|
14
|
+
const version = nuxtLike?._version ?? nuxtLike?.version ?? nuxtLike?.options?._nuxtVersion;
|
|
15
|
+
if (!version) return null;
|
|
16
|
+
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
17
|
+
return major === 2 || major === 3 || major === 4 ? major : null;
|
|
18
|
+
}
|
|
12
19
|
function isViteNuxtBuilder(builder) {
|
|
13
20
|
if (typeof builder !== "string") return false;
|
|
14
21
|
return builder === "vite" || builder.includes("vite-builder") || builder === "rolldown-vite" || builder.includes("rolldown-vite-builder");
|
|
@@ -17,6 +24,12 @@ function isWebpackNuxtBuilder(builder) {
|
|
|
17
24
|
if (typeof builder !== "string") return false;
|
|
18
25
|
return builder === "webpack" || builder.includes("webpack-builder");
|
|
19
26
|
}
|
|
27
|
+
function hasNuxtViteCompilerSupport(nuxt) {
|
|
28
|
+
if (isWebpackNuxtBuilder(nuxt.options.builder)) return false;
|
|
29
|
+
if (isViteNuxtBuilder(nuxt.options.builder)) return true;
|
|
30
|
+
if (nuxt.options.vite) return true;
|
|
31
|
+
return getDetectedNuxtMajor(nuxt) !== 2;
|
|
32
|
+
}
|
|
20
33
|
function getNuxtBuilderKind(builder) {
|
|
21
34
|
if (isViteNuxtBuilder(builder)) return "vite";
|
|
22
35
|
if (isWebpackNuxtBuilder(builder)) return "webpack";
|
|
@@ -79,12 +92,12 @@ function matchesNuxtLintCheckerFile(file, rootDir, options) {
|
|
|
79
92
|
}
|
|
80
93
|
//#endregion
|
|
81
94
|
//#region src/lint/checker/worker.ts
|
|
82
|
-
function resolveOxlintEntrypoint(
|
|
95
|
+
function resolveOxlintEntrypoint() {
|
|
83
96
|
try {
|
|
84
|
-
const
|
|
85
|
-
return path.
|
|
97
|
+
const plugin = fileURLToPath(import.meta.resolve("oxlint-plugin-vize"));
|
|
98
|
+
return path.resolve(path.dirname(plugin), "..", "bin", "oxlint-vize");
|
|
86
99
|
} catch (error) {
|
|
87
|
-
throw new Error(
|
|
100
|
+
throw new Error("Unable to resolve oxlint-vize. Install oxlint-plugin-vize before enabling the Nuxt lint checker.", { cause: error });
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
function projectPattern(pattern, cwd) {
|
|
@@ -214,7 +227,7 @@ async function runNuxtLintCheckerTask(task) {
|
|
|
214
227
|
hasWarnings: false,
|
|
215
228
|
output: ""
|
|
216
229
|
};
|
|
217
|
-
const stdout = await executeOxlint(task.oxlintEntrypoint ?? resolveOxlintEntrypoint(
|
|
230
|
+
const stdout = await executeOxlint(task.oxlintEntrypoint ?? resolveOxlintEntrypoint(), await checkerArgs(task), task.cwd);
|
|
218
231
|
let payload;
|
|
219
232
|
try {
|
|
220
233
|
payload = JSON.parse(stdout);
|
|
@@ -529,6 +542,10 @@ async function setupNuxtLintChecker(checker, nuxt, generation, dependencies = {}
|
|
|
529
542
|
//#region src/lint/addons.ts
|
|
530
543
|
/** Hook other Nuxt modules use to extend Vize's generated lint config. */
|
|
531
544
|
const VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK = "vize:lint:config:addons";
|
|
545
|
+
function autoImportEnabled(imports) {
|
|
546
|
+
if (imports === false) return false;
|
|
547
|
+
return imports?.autoImport !== false;
|
|
548
|
+
}
|
|
532
549
|
function asImportContext(value) {
|
|
533
550
|
if (value == null || typeof value !== "object" || !("getImports" in value)) return;
|
|
534
551
|
return typeof value.getImports === "function" ? value : void 0;
|
|
@@ -556,7 +573,7 @@ function createNuxtImportGlobalsAddon(nuxt) {
|
|
|
556
573
|
return {
|
|
557
574
|
name: "vize:lint:import-globals",
|
|
558
575
|
async getConfigs() {
|
|
559
|
-
const imports = [...await unimport?.getImports() ?? [], ...await nitroUnimport?.getImports() ?? []].sort((left, right) => left.from.localeCompare(right.from) || left.name.localeCompare(right.name));
|
|
576
|
+
const imports = [...autoImportEnabled(nuxt.options?.imports) ? await unimport?.getImports() ?? [] : [], ...autoImportEnabled(nuxt.options?.nitro?.imports) ? await nitroUnimport?.getImports() ?? [] : []].sort((left, right) => left.from.localeCompare(right.from) || left.name.localeCompare(right.name));
|
|
560
577
|
return [{
|
|
561
578
|
name: "nuxt/import-globals",
|
|
562
579
|
globals: Object.fromEntries(imports.map((imported) => [imported.as ?? imported.name, "readonly"]))
|
|
@@ -588,6 +605,13 @@ function setupNuxtLintConfigAddons(nuxt) {
|
|
|
588
605
|
}
|
|
589
606
|
//#endregion
|
|
590
607
|
//#region src/lint/emitter.ts
|
|
608
|
+
/**
|
|
609
|
+
* Oxlint artifact emission for the engine-neutral Nuxt lint plan.
|
|
610
|
+
*
|
|
611
|
+
* The plan deliberately keeps eslint-compatible Patina rule ids. Oxlint loads
|
|
612
|
+
* Patina as the `vize` JavaScript plugin, so this boundary is the one place
|
|
613
|
+
* those ids gain their `vize/` prefix.
|
|
614
|
+
*/
|
|
591
615
|
const PATINA_RULE_NAMESPACES = new Set([
|
|
592
616
|
"a11y",
|
|
593
617
|
"css",
|
|
@@ -625,21 +649,22 @@ function mergeRules(target, source) {
|
|
|
625
649
|
Object.assign(target, prefixVizeRules(source));
|
|
626
650
|
}
|
|
627
651
|
/** Render the complete generated oxlint config, including its trailing newline. */
|
|
628
|
-
function renderNuxtOxlintConfig(items, pluginSpecifier) {
|
|
652
|
+
function renderNuxtOxlintConfig(items, pluginSpecifier, globBase) {
|
|
653
|
+
const rebase = (glob) => globBase ? rebaseGlob(glob, globBase.rootDir, globBase.configDir) : glob;
|
|
629
654
|
const ignorePatterns = [];
|
|
630
655
|
const globals = {};
|
|
631
656
|
const rules = {};
|
|
632
657
|
const overrides = [];
|
|
633
658
|
for (const item of items) {
|
|
634
659
|
if (item.files) {
|
|
635
|
-
const override = { files:
|
|
636
|
-
if (item.ignores) override.excludeFiles =
|
|
660
|
+
const override = { files: item.files.map(rebase) };
|
|
661
|
+
if (item.ignores) override.excludeFiles = item.ignores.map(rebase);
|
|
637
662
|
if (item.globals) override.globals = { ...item.globals };
|
|
638
663
|
if (item.rules) override.rules = prefixVizeRules(item.rules);
|
|
639
664
|
overrides.push(override);
|
|
640
665
|
continue;
|
|
641
666
|
}
|
|
642
|
-
if (item.ignores) ignorePatterns.push(...item.ignores);
|
|
667
|
+
if (item.ignores) ignorePatterns.push(...item.ignores.map(rebase));
|
|
643
668
|
mergeGlobals(globals, item.globals);
|
|
644
669
|
mergeRules(rules, item.rules);
|
|
645
670
|
}
|
|
@@ -657,6 +682,16 @@ function renderNuxtOxlintConfig(items, pluginSpecifier) {
|
|
|
657
682
|
if (overrides.length > 0) config.overrides = overrides;
|
|
658
683
|
return `${JSON.stringify(config, null, 2)}\n`;
|
|
659
684
|
}
|
|
685
|
+
function rebaseGlob(glob, rootDir, configDir) {
|
|
686
|
+
const negated = glob.startsWith("!");
|
|
687
|
+
const body = negated ? glob.slice(1) : glob;
|
|
688
|
+
if (path.isAbsolute(body)) return glob;
|
|
689
|
+
let relative = path.relative(configDir, path.resolve(rootDir, body));
|
|
690
|
+
relative = relative.split(path.sep).join("/");
|
|
691
|
+
if (relative.length === 0) relative = ".";
|
|
692
|
+
else if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
693
|
+
return negated ? `!${relative}` : relative;
|
|
694
|
+
}
|
|
660
695
|
//#endregion
|
|
661
696
|
//#region src/lint/nuxt-state.ts
|
|
662
697
|
/**
|
|
@@ -679,6 +714,80 @@ function toNuxtLintProjectState(options, overrides = {}) {
|
|
|
679
714
|
};
|
|
680
715
|
}
|
|
681
716
|
//#endregion
|
|
717
|
+
//#region src/lint/project-rules.ts
|
|
718
|
+
/**
|
|
719
|
+
* Project lint rules layered under the generated Nuxt oxlint config.
|
|
720
|
+
*
|
|
721
|
+
* The artifact keeps `settings.vize.preset` at `incremental` so Nuxt-only rules
|
|
722
|
+
* stay enabled. A preset from `vize.config.json` is therefore expanded into
|
|
723
|
+
* explicit rule entries instead of replacing that runtime preset.
|
|
724
|
+
*/
|
|
725
|
+
const CONFIG_PRESETS = [
|
|
726
|
+
"happy-path",
|
|
727
|
+
"opinionated",
|
|
728
|
+
"essential",
|
|
729
|
+
"incremental",
|
|
730
|
+
"ecosystem",
|
|
731
|
+
"nuxt"
|
|
732
|
+
];
|
|
733
|
+
async function readProjectLintRules(rootDir, loadPreset = loadPresetRules) {
|
|
734
|
+
const linter = await readVizeConfigLinter(rootDir);
|
|
735
|
+
if (!linter) return void 0;
|
|
736
|
+
const rules = {
|
|
737
|
+
...linter.preset && linter.preset !== "incremental" ? await loadPreset(linter.preset, linter.typeAware) : {},
|
|
738
|
+
...linter.rules
|
|
739
|
+
};
|
|
740
|
+
return Object.keys(rules).length > 0 ? rules : void 0;
|
|
741
|
+
}
|
|
742
|
+
async function loadPresetRules(preset, typeAware) {
|
|
743
|
+
const { createVizeRuleConfig } = await import("oxlint-plugin-vize");
|
|
744
|
+
const generated = createVizeRuleConfig({
|
|
745
|
+
includeTypeAware: typeAware,
|
|
746
|
+
preset
|
|
747
|
+
});
|
|
748
|
+
const rules = {};
|
|
749
|
+
for (const [id, severity] of Object.entries(generated)) {
|
|
750
|
+
if (!isSeverity(severity)) continue;
|
|
751
|
+
const bare = id.startsWith("vize/") ? id.slice(5) : id;
|
|
752
|
+
if (bare.length > 0) rules[bare] = severity;
|
|
753
|
+
}
|
|
754
|
+
return rules;
|
|
755
|
+
}
|
|
756
|
+
async function readVizeConfigLinter(rootDir) {
|
|
757
|
+
const file = path.join(rootDir, "vize.config.json");
|
|
758
|
+
let text;
|
|
759
|
+
try {
|
|
760
|
+
text = await readFile(file, "utf8");
|
|
761
|
+
} catch (error) {
|
|
762
|
+
if (error.code === "ENOENT") return void 0;
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
const parsed = JSON.parse(text);
|
|
766
|
+
if (!parsed.linter || typeof parsed.linter !== "object") return void 0;
|
|
767
|
+
const linter = parsed.linter;
|
|
768
|
+
return {
|
|
769
|
+
preset: isConfigPreset(linter.preset) ? linter.preset : void 0,
|
|
770
|
+
typeAware: linter.typeAware === true,
|
|
771
|
+
rules: explicitRules(linter.rules)
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function explicitRules(value) {
|
|
775
|
+
if (!value || typeof value !== "object") return {};
|
|
776
|
+
const rules = {};
|
|
777
|
+
for (const [id, severity] of Object.entries(value)) {
|
|
778
|
+
if (!isSeverity(severity)) continue;
|
|
779
|
+
const bare = id.startsWith("vize/") ? id.slice(5) : id;
|
|
780
|
+
if (bare.length > 0) rules[bare] = severity;
|
|
781
|
+
}
|
|
782
|
+
return rules;
|
|
783
|
+
}
|
|
784
|
+
function isConfigPreset(value) {
|
|
785
|
+
return typeof value === "string" && CONFIG_PRESETS.includes(value);
|
|
786
|
+
}
|
|
787
|
+
function isSeverity(value) {
|
|
788
|
+
return value === "off" || value === "warn" || value === "error";
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
682
791
|
//#region src/lint/inspector-view.ts
|
|
683
792
|
/** Render the dependency-free UI served by the in-process lint-plan inspector. */
|
|
684
793
|
function renderNuxtLintInspectorHtml(nonce) {
|
|
@@ -1183,12 +1292,24 @@ async function setupNuxtLintConfigGeneration(lint, nuxt, dependencies = {}) {
|
|
|
1183
1292
|
const hasTypeScriptProbe = dependencies.hasTypeScript ?? hasTypeScript;
|
|
1184
1293
|
const resolvePluginSpecifier = dependencies.resolvePluginSpecifier ?? resolveVizePluginSpecifier;
|
|
1185
1294
|
const resolveAddons = dependencies.resolveAddons ?? ("callHook" in nuxt ? setupNuxtLintConfigAddons(nuxt) : void 0);
|
|
1295
|
+
const resolveProjectRules = dependencies.resolveProjectLintRules ?? readProjectLintRules;
|
|
1186
1296
|
let currentPlan = [];
|
|
1187
1297
|
const regenerate = async () => {
|
|
1188
1298
|
const plan = buildNuxtLintPlan(resolveNuxtLintFeatures(featureOptions, () => hasTypeScriptProbe(planRoot)), collectNuxtLintDirs(toNuxtLintProjectState(nuxt.options, { rootDir: planRoot })));
|
|
1189
1299
|
const addons = await resolveAddons?.() ?? [];
|
|
1190
|
-
const
|
|
1191
|
-
const
|
|
1300
|
+
const projectRules = await resolveProjectRules(planRoot);
|
|
1301
|
+
const nextPlan = [
|
|
1302
|
+
...projectRules && Object.keys(projectRules).length > 0 ? [{
|
|
1303
|
+
name: "project/preset",
|
|
1304
|
+
rules: projectRules
|
|
1305
|
+
}] : [],
|
|
1306
|
+
...plan,
|
|
1307
|
+
...addons
|
|
1308
|
+
];
|
|
1309
|
+
const changed = await writeFileIfChanged(configFile, renderNuxtOxlintConfig(nextPlan, resolvePluginSpecifier(path.dirname(configFile)), {
|
|
1310
|
+
rootDir: planRoot,
|
|
1311
|
+
configDir: path.dirname(configFile)
|
|
1312
|
+
}));
|
|
1192
1313
|
currentPlan = nextPlan;
|
|
1193
1314
|
return changed;
|
|
1194
1315
|
};
|
|
@@ -1198,6 +1319,7 @@ async function setupNuxtLintConfigGeneration(lint, nuxt, dependencies = {}) {
|
|
|
1198
1319
|
};
|
|
1199
1320
|
await regenerate();
|
|
1200
1321
|
nuxt.hook("builder:generateApp", regenerate);
|
|
1322
|
+
if (getDetectedNuxtMajor(nuxt) === 2) nuxt.hook("build:templates", regenerate);
|
|
1201
1323
|
if (autoInit) await initRootOxlintConfig(nuxtRoot, configFile);
|
|
1202
1324
|
return {
|
|
1203
1325
|
configFile,
|
|
@@ -1207,4 +1329,4 @@ async function setupNuxtLintConfigGeneration(lint, nuxt, dependencies = {}) {
|
|
|
1207
1329
|
};
|
|
1208
1330
|
}
|
|
1209
1331
|
//#endregion
|
|
1210
|
-
export { toNuxtLintProjectState as a, setupNuxtLintConfigAddons as c, createNuxtLintCheckerVitePlugin as d, resolveNuxtLintCheckerOptions as f, setupLintInspector as i, setupNuxtLintChecker as l, setupNuxtLintConfigGeneration as n, renderNuxtOxlintConfig as o,
|
|
1332
|
+
export { toNuxtLintProjectState as a, setupNuxtLintConfigAddons as c, createNuxtLintCheckerVitePlugin as d, resolveNuxtLintCheckerOptions as f, setupLintInspector as i, setupNuxtLintChecker as l, hasNuxtViteCompilerSupport as m, setupNuxtLintConfigGeneration as n, renderNuxtOxlintConfig as o, getDetectedNuxtMajor as p, writeFileIfChanged as r, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK as s, ROOT_OXLINT_CONFIG_NAMES as t, createNuxtLintCheckerWebpackPlugin as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as VizeNuxtUiOptions, S as VizeNuxtComposablesOptions, _ as VizeNuxtLintCheckerOptions, b as VizeNuxtCompilerOptions, c as NuxtMuseaOptions, d as VizeNuxtDevOptions, f as VizeNuxtMajorVersion, h as VizeNuxtLintOptions, l as VizeNuxtBridgeOptions, m as VizeNuxtUnoCssOptions, n as NuxtLintConfigAddon, p as VizeNuxtOptions, u as VizeNuxtCompatibilityOptions, x as VizeNuxtVueVersion, y as VizeNuxtCompilerCompatibilityOptions } from "./addons-
|
|
1
|
+
import { C as VizeNuxtUiOptions, S as VizeNuxtComposablesOptions, _ as VizeNuxtLintCheckerOptions, b as VizeNuxtCompilerOptions, c as NuxtMuseaOptions, d as VizeNuxtDevOptions, f as VizeNuxtMajorVersion, h as VizeNuxtLintOptions, l as VizeNuxtBridgeOptions, m as VizeNuxtUnoCssOptions, n as NuxtLintConfigAddon, p as VizeNuxtOptions, u as VizeNuxtCompatibilityOptions, x as VizeNuxtVueVersion, y as VizeNuxtCompilerCompatibilityOptions } from "./addons-CrR0MCzZ.mjs";
|
|
2
2
|
import { MuseaOptions } from "@vizejs/vite-plugin-musea";
|
|
3
3
|
|
|
4
4
|
//#region src/schema.d.ts
|
|
@@ -55,6 +55,9 @@ type NuxtWithBuilderOptions = {
|
|
|
55
55
|
dedupe?: string[];
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
+
vue?: {
|
|
59
|
+
compilerOptions?: Record<string, unknown>;
|
|
60
|
+
};
|
|
58
61
|
nitro?: {
|
|
59
62
|
virtual?: Record<string, string>;
|
|
60
63
|
publicAssets?: unknown[];
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as setupLintInspector, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, p as
|
|
1
|
+
import { i as setupLintInspector, l as setupNuxtLintChecker, m as hasNuxtViteCompilerSupport, n as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor } from "./generation-CXADZreI.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path, { dirname, join, resolve } from "node:path";
|
|
@@ -733,6 +733,17 @@ function escapeRegExp(char) {
|
|
|
733
733
|
return "\\^$+?.()|[]{}".includes(char) ? `\\${char}` : char;
|
|
734
734
|
}
|
|
735
735
|
//#endregion
|
|
736
|
+
//#region src/module-id.ts
|
|
737
|
+
/** Recognize compiled modules without assigning raw Vue/style queries to Vize. */
|
|
738
|
+
function isVizeGeneratedVueModuleId(id) {
|
|
739
|
+
const normalized = id.replace(/^\/@id\/__x00__|^__x00__/, "");
|
|
740
|
+
if (/\.vue\.tsx?(?:\?|$)/.test(normalized)) return true;
|
|
741
|
+
const queryIndex = normalized.indexOf("?");
|
|
742
|
+
if (queryIndex === -1 || !normalized.slice(0, queryIndex).endsWith(".vue")) return false;
|
|
743
|
+
const params = new URLSearchParams(normalized.slice(queryIndex + 1));
|
|
744
|
+
return params.has("vue") && (params.has("vize") || params.has("vize-ssr")) && !params.has("type");
|
|
745
|
+
}
|
|
746
|
+
//#endregion
|
|
736
747
|
//#region src/utils.ts
|
|
737
748
|
const NUXT_OG_IMAGE_RENDERER_SFC_EXCLUDE = /\.takumi\.vue(?:\?|$)|[?&]og-image-depth=/;
|
|
738
749
|
function normalizeUrlPrefix(value) {
|
|
@@ -766,12 +777,6 @@ function mergeNuxtCompilerPatterns(defaultPattern, userPattern) {
|
|
|
766
777
|
function isVizeVirtualVueModuleId(id) {
|
|
767
778
|
return id.startsWith("\0") && /\.vue\.tsx?(?:\?|$)/.test(id);
|
|
768
779
|
}
|
|
769
|
-
function isVizeGeneratedVueModuleId(id) {
|
|
770
|
-
let normalized = id;
|
|
771
|
-
if (normalized.startsWith("/@id/__x00__")) normalized = normalized.slice(12);
|
|
772
|
-
else if (normalized.startsWith("__x00__")) normalized = normalized.slice(7);
|
|
773
|
-
return /\.vue\.tsx?(?:\?|$)/.test(normalized);
|
|
774
|
-
}
|
|
775
780
|
/**
|
|
776
781
|
* Recognize raw `.jsx`/`.tsx` Vue component modules compiled by Vize.
|
|
777
782
|
*
|
|
@@ -1014,15 +1019,10 @@ function rewriteBareVueImportsToClientRuntime(code) {
|
|
|
1014
1019
|
});
|
|
1015
1020
|
}
|
|
1016
1021
|
//#endregion
|
|
1017
|
-
//#region src/
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
i18n: true,
|
|
1022
|
-
stableInjectedKeys: true
|
|
1023
|
-
};
|
|
1024
|
-
const DEFAULT_NUXT_UNOCSS_OPTIONS = { originalSource: {} };
|
|
1025
|
-
const DEFAULT_NUXT_DEV_OPTIONS = { stylesheetLinks: true };
|
|
1022
|
+
//#region src/compiler-option-bridge.ts
|
|
1023
|
+
function unsupportedNuxtVueCompilerOptions(options) {
|
|
1024
|
+
return Object.entries(options ?? {}).filter(([key, value]) => value !== void 0 && (key !== "whitespace" || value !== "condense" && value !== "preserve")).map(([key]) => key);
|
|
1025
|
+
}
|
|
1026
1026
|
function isLegacyVueVersion(version) {
|
|
1027
1027
|
return version === .11 || version === 1 || version === 2 || version === "2.7" || version === "legacy";
|
|
1028
1028
|
}
|
|
@@ -1037,19 +1037,33 @@ function normalizeNuxtCompilerCompatibilityOptions(compatibility) {
|
|
|
1037
1037
|
if (compatibility.webpackVersion !== void 0) normalized.webpackVersion = compatibility.webpackVersion;
|
|
1038
1038
|
return normalized;
|
|
1039
1039
|
}
|
|
1040
|
-
function resolveNuxtCompilerOptions(rootDir, baseURL, buildAssetsDir, compiler, compatibility = {}) {
|
|
1040
|
+
function resolveNuxtCompilerOptions(rootDir, baseURL, buildAssetsDir, compiler, compatibility = {}, vueCompilerOptions) {
|
|
1041
1041
|
if (compiler === false) return false;
|
|
1042
1042
|
if (compatibility.supportsViteCompiler === false && compatibility.forceViteCompiler !== true) return false;
|
|
1043
1043
|
const compatibilityOptions = normalizeNuxtCompilerCompatibilityOptions(compatibility);
|
|
1044
|
+
const unsupported = unsupportedNuxtVueCompilerOptions(vueCompilerOptions);
|
|
1045
|
+
if (unsupported.length > 0) compatibilityOptions.hostCompiler = true;
|
|
1044
1046
|
const hasCompatibilityOptions = Object.keys(compatibilityOptions).length > 0;
|
|
1045
1047
|
const overrides = typeof compiler === "object" && compiler != null ? compiler : {};
|
|
1046
1048
|
return buildNuxtCompilerOptions(rootDir, baseURL, buildAssetsDir, {
|
|
1047
1049
|
vueVersion: compatibility.vueVersion,
|
|
1048
1050
|
...hasCompatibilityOptions ? { compatibility: compatibilityOptions } : {},
|
|
1049
1051
|
mode: compatibility.scriptSetupInStandalone === true ? "function" : void 0,
|
|
1050
|
-
...
|
|
1052
|
+
...vueCompilerOptions?.whitespace === "condense" || vueCompilerOptions?.whitespace === "preserve" ? { whitespace: vueCompilerOptions.whitespace } : {},
|
|
1053
|
+
...overrides,
|
|
1054
|
+
...unsupported.length > 0 ? { compatibility: compatibilityOptions } : {}
|
|
1051
1055
|
});
|
|
1052
1056
|
}
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region src/options.ts
|
|
1059
|
+
const DEFAULT_NUXT_BRIDGE_OPTIONS = {
|
|
1060
|
+
autoImports: true,
|
|
1061
|
+
components: true,
|
|
1062
|
+
i18n: true,
|
|
1063
|
+
stableInjectedKeys: true
|
|
1064
|
+
};
|
|
1065
|
+
const DEFAULT_NUXT_UNOCSS_OPTIONS = { originalSource: {} };
|
|
1066
|
+
const DEFAULT_NUXT_DEV_OPTIONS = { stylesheetLinks: true };
|
|
1053
1067
|
function resolveNuxtBridgeOptions(bridge) {
|
|
1054
1068
|
if (bridge === false) return {
|
|
1055
1069
|
autoImports: false,
|
|
@@ -1203,6 +1217,19 @@ const VUE_SSR_EXTERNAL = [
|
|
|
1203
1217
|
"vue/server-renderer",
|
|
1204
1218
|
"@vue/server-renderer"
|
|
1205
1219
|
];
|
|
1220
|
+
const VUE_RUNTIME_DEDUPE = [
|
|
1221
|
+
"vue",
|
|
1222
|
+
"@vue/reactivity",
|
|
1223
|
+
"@vue/runtime-core",
|
|
1224
|
+
"@vue/runtime-dom",
|
|
1225
|
+
"@vue/shared"
|
|
1226
|
+
];
|
|
1227
|
+
function dedupeVueRuntimePackages(vite) {
|
|
1228
|
+
vite.resolve ||= {};
|
|
1229
|
+
const dedupe = new Set(vite.resolve.dedupe ?? []);
|
|
1230
|
+
for (const packageName of VUE_RUNTIME_DEDUPE) dedupe.add(packageName);
|
|
1231
|
+
vite.resolve.dedupe = [...dedupe];
|
|
1232
|
+
}
|
|
1206
1233
|
function externalizeVueRuntimeForNuxtSsr(config) {
|
|
1207
1234
|
const rolldownOptions = config.build?.rolldownOptions;
|
|
1208
1235
|
if (!rolldownOptions) return;
|
|
@@ -1216,13 +1243,6 @@ function externalizeVueRuntimeForNuxtSsr(config) {
|
|
|
1216
1243
|
//#endregion
|
|
1217
1244
|
//#region src/index.ts
|
|
1218
1245
|
const VIZE_NUXT_AUTO_IMPORT_PATCHED = "__vizeNuxtAutoImportPatched";
|
|
1219
|
-
const VUE_RUNTIME_DEDUPE = [
|
|
1220
|
-
"vue",
|
|
1221
|
-
"@vue/reactivity",
|
|
1222
|
-
"@vue/runtime-core",
|
|
1223
|
-
"@vue/runtime-dom",
|
|
1224
|
-
"@vue/shared"
|
|
1225
|
-
];
|
|
1226
1246
|
const moduleMeta = {
|
|
1227
1247
|
name: "@vizejs/nuxt",
|
|
1228
1248
|
configKey: "vize"
|
|
@@ -1271,18 +1291,6 @@ function registerNuxt2CompatibilityHooks(nuxt) {
|
|
|
1271
1291
|
nuxt.hook("builder:prepared", () => {});
|
|
1272
1292
|
nuxt.hook("build:templates", () => {});
|
|
1273
1293
|
}
|
|
1274
|
-
function getDetectedNuxtMajor(nuxt) {
|
|
1275
|
-
const nuxtLike = nuxt;
|
|
1276
|
-
const version = nuxtLike?._version ?? nuxtLike?.version ?? (typeof nuxtLike?.options?._nuxtVersion === "string" ? nuxtLike.options._nuxtVersion : null);
|
|
1277
|
-
if (!version) return null;
|
|
1278
|
-
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
1279
|
-
return major === 2 || major === 3 || major === 4 ? major : null;
|
|
1280
|
-
}
|
|
1281
|
-
function hasNuxtViteCompilerSupport(nuxt) {
|
|
1282
|
-
if (isViteNuxtBuilder(nuxt.options.builder)) return true;
|
|
1283
|
-
if (nuxt.options.vite) return true;
|
|
1284
|
-
return getDetectedNuxtMajor(nuxt) !== 2;
|
|
1285
|
-
}
|
|
1286
1294
|
function getNuxtAppBaseURL(nuxt) {
|
|
1287
1295
|
return nuxt.options.app?.baseURL ?? nuxt.options.router?.base;
|
|
1288
1296
|
}
|
|
@@ -1292,12 +1300,6 @@ function getNuxtBuildAssetsDir(nuxt) {
|
|
|
1292
1300
|
function shouldUseVizeCompiler(compilerOptions) {
|
|
1293
1301
|
return compilerOptions !== false && compilerOptions.compatibility?.hostCompiler !== true && (compilerOptions.vueVersion ?? 3) === 3;
|
|
1294
1302
|
}
|
|
1295
|
-
function dedupeVueRuntimePackages(vite) {
|
|
1296
|
-
vite.resolve ||= {};
|
|
1297
|
-
const dedupe = new Set(vite.resolve.dedupe ?? []);
|
|
1298
|
-
for (const packageName of VUE_RUNTIME_DEDUPE) dedupe.add(packageName);
|
|
1299
|
-
vite.resolve.dedupe = [...dedupe];
|
|
1300
|
-
}
|
|
1301
1303
|
function isViteSsrTransform(args) {
|
|
1302
1304
|
const options = args[0];
|
|
1303
1305
|
return typeof options === "object" && options !== null && "ssr" in options && options.ssr === true;
|
|
@@ -1357,14 +1359,21 @@ async function setupVizeNuxtModule(options, nuxt) {
|
|
|
1357
1359
|
const compilerOptions = resolveNuxtCompilerOptions(nuxt.options.rootDir, appBaseURL, buildAssetsDir, options.compiler, {
|
|
1358
1360
|
supportsViteCompiler,
|
|
1359
1361
|
vueVersion
|
|
1360
|
-
});
|
|
1362
|
+
}, nuxt.options.vue?.compilerOptions);
|
|
1363
|
+
if (compilerOptions !== false && compilerOptions.compatibility?.hostCompiler === true) {
|
|
1364
|
+
const unsupported = unsupportedNuxtVueCompilerOptions(nuxt.options.vue?.compilerOptions);
|
|
1365
|
+
if (unsupported.length > 0) console.warn(`@vizejs/nuxt: vue.compilerOptions.${unsupported.join(", ")} cannot be forwarded to the native compiler; keeping Nuxt's Vue compiler.`);
|
|
1366
|
+
}
|
|
1361
1367
|
await setupLintInspector(options.lint, nuxt, compilerOptions, lintGeneration, nuxt.options.dev);
|
|
1362
1368
|
const usesVizeCompiler = shouldUseVizeCompiler(compilerOptions);
|
|
1363
1369
|
if (compilerOptions !== false && compilerOptions.compatibility?.hostCompiler !== true) {
|
|
1364
1370
|
const { default: vize } = await import("@vizejs/vite-plugin");
|
|
1365
1371
|
nuxt.options.vite ||= {};
|
|
1366
1372
|
nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
|
|
1367
|
-
nuxt.options.vite.plugins.push(vize(
|
|
1373
|
+
nuxt.options.vite.plugins.push(vize({
|
|
1374
|
+
...compilerOptions,
|
|
1375
|
+
ssrModuleIdRoot: nuxt.options.srcDir
|
|
1376
|
+
}));
|
|
1368
1377
|
}
|
|
1369
1378
|
let isNuxtBuild = false;
|
|
1370
1379
|
let isViteBuild = false;
|
package/dist/lint/index.d.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { _ as VizeNuxtLintCheckerOptions, a as ResolveNuxtLintConfigAddons, g as ResolvedVizeNuxtLintCheckerOptions, h as VizeNuxtLintOptions, i as NuxtLintImport, n as NuxtLintConfigAddon, o as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, r as NuxtLintConfigAddonNuxt, s as setupNuxtLintConfigAddons, t as NuxtLintAwaitable, v as resolveNuxtLintCheckerOptions } from "../addons-
|
|
2
|
-
import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState } from "@vizejs/nuxt-lint-config";
|
|
1
|
+
import { _ as VizeNuxtLintCheckerOptions, a as ResolveNuxtLintConfigAddons, g as ResolvedVizeNuxtLintCheckerOptions, h as VizeNuxtLintOptions, i as NuxtLintImport, n as NuxtLintConfigAddon, o as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, r as NuxtLintConfigAddonNuxt, s as setupNuxtLintConfigAddons, t as NuxtLintAwaitable, v as resolveNuxtLintCheckerOptions } from "../addons-CrR0MCzZ.mjs";
|
|
2
|
+
import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState, NuxtLintSeverity } from "@vizejs/nuxt-lint-config";
|
|
3
3
|
export * from "@vizejs/nuxt-lint-config";
|
|
4
4
|
|
|
5
|
+
//#region src/lint/project-rules.d.ts
|
|
6
|
+
type ProjectLintRules = Record<string, NuxtLintSeverity>;
|
|
7
|
+
//#endregion
|
|
5
8
|
//#region src/lint/generation.d.ts
|
|
6
9
|
/** Root config names supported by oxlint's config discovery. */
|
|
7
10
|
declare const ROOT_OXLINT_CONFIG_NAMES: readonly [".oxlintrc.json", ".oxlintrc.jsonc", "oxlint.config.ts", "oxlint.config.mts"];
|
|
@@ -19,6 +22,8 @@ interface NuxtLintGenerationDependencies {
|
|
|
19
22
|
resolveAddons?: () => Awaitable$1<readonly NuxtLintConfigItem[]>;
|
|
20
23
|
hasTypeScript?: (rootDir: string) => boolean;
|
|
21
24
|
resolvePluginSpecifier?: (configDir: string) => string;
|
|
25
|
+
/** `vize.config.json` rules. Tests inject this so generation never loads the native preset binding. */
|
|
26
|
+
resolveProjectLintRules?: (rootDir: string) => Awaitable$1<ProjectLintRules | undefined>;
|
|
22
27
|
}
|
|
23
28
|
interface NuxtLintConfigGeneration {
|
|
24
29
|
configFile: string;
|
|
@@ -52,7 +57,7 @@ interface NuxtLintCheckerTask {
|
|
|
52
57
|
emitWarning: boolean;
|
|
53
58
|
emitError: boolean;
|
|
54
59
|
fix: boolean;
|
|
55
|
-
/** Test/integration override. Normal callers
|
|
60
|
+
/** Test/integration override. Normal callers use oxlint-vize. */
|
|
56
61
|
oxlintEntrypoint?: string;
|
|
57
62
|
}
|
|
58
63
|
interface NuxtLintCheckerResult {
|
|
@@ -206,7 +211,16 @@ interface NuxtLintStateOverrides {
|
|
|
206
211
|
declare function toNuxtLintProjectState(options: NuxtLintSourceOptions, overrides?: NuxtLintStateOverrides): NuxtLintProjectState;
|
|
207
212
|
//#endregion
|
|
208
213
|
//#region src/lint/emitter.d.ts
|
|
214
|
+
/**
|
|
215
|
+
* Plan globs are relative to the Nuxt root. Oxlint resolves `overrides` and
|
|
216
|
+
* `ignorePatterns` from the generated config's directory, so the emitter
|
|
217
|
+
* rebases them when it knows both directories.
|
|
218
|
+
*/
|
|
219
|
+
interface NuxtOxlintGlobBase {
|
|
220
|
+
rootDir: string;
|
|
221
|
+
configDir: string;
|
|
222
|
+
}
|
|
209
223
|
/** Render the complete generated oxlint config, including its trailing newline. */
|
|
210
|
-
declare function renderNuxtOxlintConfig(items: readonly NuxtLintConfigItem[], pluginSpecifier: string): string;
|
|
224
|
+
declare function renderNuxtOxlintConfig(items: readonly NuxtLintConfigItem[], pluginSpecifier: string, globBase?: NuxtOxlintGlobBase): string;
|
|
211
225
|
//#endregion
|
|
212
226
|
export { type NuxtLintAwaitable, type NuxtLintCheckerSetup, type NuxtLintCheckerSetupDependencies, type NuxtLintConfigAddon, type NuxtLintConfigAddonNuxt, type NuxtLintConfigGeneration, type NuxtLintGenerationDependencies, type NuxtLintImport, type NuxtLintSourceOptions, type NuxtLintStateOverrides, ROOT_OXLINT_CONFIG_NAMES, type ResolveNuxtLintConfigAddons, type ResolvedVizeNuxtLintCheckerOptions, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, type VizeNuxtLintCheckerOptions, type VizeNuxtLintOptions, createNuxtLintCheckerVitePlugin, createNuxtLintCheckerWebpackPlugin, renderNuxtOxlintConfig, resolveNuxtLintCheckerOptions, setupNuxtLintChecker, setupNuxtLintConfigAddons, setupNuxtLintConfigGeneration, toNuxtLintProjectState, writeFileIfChanged };
|
package/dist/lint/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as toNuxtLintProjectState, c as setupNuxtLintConfigAddons, d as createNuxtLintCheckerVitePlugin, f as resolveNuxtLintCheckerOptions, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, o as renderNuxtOxlintConfig, r as writeFileIfChanged, s as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, t as ROOT_OXLINT_CONFIG_NAMES, u as createNuxtLintCheckerWebpackPlugin } from "../generation-
|
|
1
|
+
import { a as toNuxtLintProjectState, c as setupNuxtLintConfigAddons, d as createNuxtLintCheckerVitePlugin, f as resolveNuxtLintCheckerOptions, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, o as renderNuxtOxlintConfig, r as writeFileIfChanged, s as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, t as ROOT_OXLINT_CONFIG_NAMES, u as createNuxtLintCheckerWebpackPlugin } from "../generation-CXADZreI.mjs";
|
|
2
2
|
export * from "@vizejs/nuxt-lint-config";
|
|
3
3
|
export { ROOT_OXLINT_CONFIG_NAMES, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, createNuxtLintCheckerVitePlugin, createNuxtLintCheckerWebpackPlugin, renderNuxtOxlintConfig, resolveNuxtLintCheckerOptions, setupNuxtLintChecker, setupNuxtLintConfigAddons, setupNuxtLintConfigGeneration, toNuxtLintProjectState, writeFileIfChanged };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/nuxt",
|
|
3
|
-
"version": "0.429.
|
|
3
|
+
"version": "0.429.2",
|
|
4
4
|
"description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@nuxt/kit": "3.11.2",
|
|
52
|
-
"@vizejs/native": "0.429.
|
|
53
|
-
"@vizejs/nuxt-lint-config": "0.429.
|
|
54
|
-
"@vizejs/vite-plugin": "0.429.
|
|
55
|
-
"@vizejs/vite-plugin-musea": "0.429.
|
|
56
|
-
"oxlint-plugin-vize": "0.429.
|
|
57
|
-
"vize": "0.429.
|
|
52
|
+
"@vizejs/native": "0.429.2",
|
|
53
|
+
"@vizejs/nuxt-lint-config": "0.429.2",
|
|
54
|
+
"@vizejs/vite-plugin": "0.429.2",
|
|
55
|
+
"@vizejs/vite-plugin-musea": "0.429.2",
|
|
56
|
+
"oxlint-plugin-vize": "0.429.2",
|
|
57
|
+
"vize": "0.429.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"jiti-nuxt2": "npm:jiti@1.21.7",
|