@vizejs/nuxt 0.803.0 → 0.805.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/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as setupLintInspector, m as hasNuxtViteCompilerSupport, o as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor, t as setupNuxtLintChecker } from "./setup-
|
|
1
|
+
import { c as setupLintInspector, m as hasNuxtViteCompilerSupport, o as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor, t as setupNuxtLintChecker } from "./setup-CewfseSX.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs, { readFileSync, realpathSync } from "node:fs";
|
|
4
4
|
import path, { dirname, join, resolve } from "node:path";
|
|
@@ -334,8 +334,13 @@ function loadRuntimeComponents(rootDir, moduleNames) {
|
|
|
334
334
|
}
|
|
335
335
|
return resolved;
|
|
336
336
|
}
|
|
337
|
+
function normalizedPath(filePath) {
|
|
338
|
+
return filePath.replace(/\\/g, "/");
|
|
339
|
+
}
|
|
337
340
|
function createNuxtComponentResolver(options) {
|
|
338
341
|
const registered = /* @__PURE__ */ new Map();
|
|
342
|
+
const everScannedFiles = /* @__PURE__ */ new Set();
|
|
343
|
+
let scannedFiles = /* @__PURE__ */ new Set();
|
|
339
344
|
let dtsResolved = null;
|
|
340
345
|
let runtimeResolved = null;
|
|
341
346
|
function getDtsResolved() {
|
|
@@ -348,6 +353,9 @@ function createNuxtComponentResolver(options) {
|
|
|
348
353
|
}
|
|
349
354
|
return {
|
|
350
355
|
register(components) {
|
|
356
|
+
registered.clear();
|
|
357
|
+
scannedFiles = new Set(components.map((component) => normalizedPath(component.filePath)));
|
|
358
|
+
for (const file of scannedFiles) everScannedFiles.add(file);
|
|
351
359
|
for (const component of components) {
|
|
352
360
|
const resolved = createComponentImport(registeredComponentPath(component, components), component.export || "default", false, component.mode);
|
|
353
361
|
addRegisteredComponentAlias(registered, component.pascalName, resolved);
|
|
@@ -371,7 +379,8 @@ function createNuxtComponentResolver(options) {
|
|
|
371
379
|
const registeredResolved = selectRegisteredComponent(registered.get(normalizedName), mode);
|
|
372
380
|
if (registeredResolved) return registeredResolved;
|
|
373
381
|
const dtsResolved = getDtsResolved().get(normalizedName);
|
|
374
|
-
|
|
382
|
+
const dtsFile = dtsResolved && normalizedPath(dtsResolved.filePath);
|
|
383
|
+
if (!(!!dtsFile && everScannedFiles.has(dtsFile) && !scannedFiles.has(dtsFile)) && matchesBuildMode(dtsResolved, mode)) return dtsResolved;
|
|
375
384
|
if (!/[A-Z]/.test(normalizedName)) return null;
|
|
376
385
|
const runtimeResolved = getRuntimeResolved().get(normalizedName);
|
|
377
386
|
return matchesBuildMode(runtimeResolved, mode) ? runtimeResolved : null;
|
|
@@ -379,6 +388,74 @@ function createNuxtComponentResolver(options) {
|
|
|
379
388
|
};
|
|
380
389
|
}
|
|
381
390
|
//#endregion
|
|
391
|
+
//#region src/component-hmr.ts
|
|
392
|
+
const COMPONENT_FILE_EXT_RE = /\.(?:[cm]?[jt]s|vue)$/;
|
|
393
|
+
function resolutionKey(resolved) {
|
|
394
|
+
if (!resolved) return "";
|
|
395
|
+
return `${resolved.filePath.replace(COMPONENT_FILE_EXT_RE, "")}#${resolved.exportName}#${resolved.lazy ? "lazy" : ""}#${resolved.mode ?? ""}`;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The bridge resolves Nuxt components inside Vize's compiled modules, where
|
|
399
|
+
* Nuxt's own loader never runs, so Nuxt cannot know which of those modules
|
|
400
|
+
* named a component. When a component file appears or disappears, Nuxt
|
|
401
|
+
* rescans its components before later hot-update hooks run; this then reloads
|
|
402
|
+
* every compiled module whose component names now resolve differently. A page
|
|
403
|
+
* saved together with a new component then imports it, and a page whose
|
|
404
|
+
* component was renamed or deleted loses the import and warns instead of
|
|
405
|
+
* failing to load, as with Nuxt's loader and @vitejs/plugin-vue.
|
|
406
|
+
*
|
|
407
|
+
* Resolutions are only recorded in dev, so builds pay nothing for this.
|
|
408
|
+
*/
|
|
409
|
+
function createNuxtComponentBridge(nuxtOptions) {
|
|
410
|
+
const resolver = createNuxtComponentResolver({
|
|
411
|
+
buildDir: nuxtOptions.buildDir,
|
|
412
|
+
moduleNames: nuxtOptions.modules.filter((moduleName) => typeof moduleName === "string"),
|
|
413
|
+
rootDir: nuxtOptions.rootDir
|
|
414
|
+
});
|
|
415
|
+
const dev = nuxtOptions.dev === true;
|
|
416
|
+
const recorded = /* @__PURE__ */ new WeakMap();
|
|
417
|
+
return {
|
|
418
|
+
register(components) {
|
|
419
|
+
resolver.register(components);
|
|
420
|
+
},
|
|
421
|
+
/** The resolver for one transform of `id`, which records what it resolves in dev. */
|
|
422
|
+
resolverFor(environment, id, mode) {
|
|
423
|
+
if (!dev || !environment) return (name) => resolver.resolve(name, mode);
|
|
424
|
+
const modules = recorded.get(environment) ?? /* @__PURE__ */ new Map();
|
|
425
|
+
recorded.set(environment, modules);
|
|
426
|
+
modules.delete(id);
|
|
427
|
+
let keys;
|
|
428
|
+
return (name) => {
|
|
429
|
+
const resolved = resolver.resolve(name, mode);
|
|
430
|
+
if (!keys) modules.set(id, {
|
|
431
|
+
mode,
|
|
432
|
+
keys: keys = /* @__PURE__ */ new Map()
|
|
433
|
+
});
|
|
434
|
+
keys.set(name, resolutionKey(resolved));
|
|
435
|
+
return resolved;
|
|
436
|
+
};
|
|
437
|
+
},
|
|
438
|
+
hotUpdate: { handler({ type, modules }) {
|
|
439
|
+
if (type === "update" || !this.environment) return;
|
|
440
|
+
const records = recorded.get(this.environment);
|
|
441
|
+
if (!records) return;
|
|
442
|
+
const affected = new Set(modules);
|
|
443
|
+
for (const [id, { mode, keys }] of records) {
|
|
444
|
+
let changed = false;
|
|
445
|
+
for (const [name, key] of keys) if (resolutionKey(resolver.resolve(name, mode)) !== key) {
|
|
446
|
+
changed = true;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
if (!changed) continue;
|
|
450
|
+
records.delete(id);
|
|
451
|
+
const module = this.environment.moduleGraph.getModuleById(id);
|
|
452
|
+
if (module) affected.add(module);
|
|
453
|
+
}
|
|
454
|
+
if (affected.size !== modules.length) return [...affected];
|
|
455
|
+
} }
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
382
459
|
//#region src/lint/module-setup.ts
|
|
383
460
|
/** Whether user config asks for lint, as opposed to inheriting the module default. */
|
|
384
461
|
function isLintRequested(...configured) {
|
|
@@ -1684,23 +1761,21 @@ async function setupVizeNuxtModule(raw, nuxt) {
|
|
|
1684
1761
|
if (usesVizeCompiler && bridgeOptions.autoImports) nuxt.hook("imports:context", (ctx) => {
|
|
1685
1762
|
unimportCtx = ctx;
|
|
1686
1763
|
});
|
|
1687
|
-
const nuxtComponentResolver = usesVizeCompiler && bridgeOptions.components ?
|
|
1688
|
-
buildDir: nuxt.options.buildDir,
|
|
1689
|
-
moduleNames: nuxt.options.modules.filter((moduleName) => typeof moduleName === "string"),
|
|
1690
|
-
rootDir: nuxt.options.rootDir
|
|
1691
|
-
}) : null;
|
|
1764
|
+
const nuxtComponentResolver = usesVizeCompiler && bridgeOptions.components ? createNuxtComponentBridge(nuxt.options) : null;
|
|
1692
1765
|
if (nuxtComponentResolver) nuxt.hook("components:extend", (comps) => {
|
|
1693
1766
|
nuxtComponentResolver.register(comps);
|
|
1694
1767
|
});
|
|
1695
1768
|
if (usesVizeCompiler && (bridgeOptions.autoImports || bridgeOptions.components || bridgeOptions.i18n || bridgeOptions.stableInjectedKeys)) await addNuxtVitePlugin({
|
|
1696
1769
|
name: "vizejs:nuxt-transform-bridge",
|
|
1697
1770
|
enforce: "post",
|
|
1771
|
+
hotUpdate: nuxtComponentResolver?.hotUpdate,
|
|
1698
1772
|
async transform(code, id, ...args) {
|
|
1699
1773
|
if (!isVizeGeneratedVueModuleId(id) && !isVizeJsxModuleId(id)) return;
|
|
1700
1774
|
let result = code;
|
|
1701
1775
|
let changed = false;
|
|
1702
|
-
|
|
1703
|
-
|
|
1776
|
+
const resolveComponent = nuxtComponentResolver?.resolverFor(this.environment, id, isViteSsrTransform(args) ? "server" : "client");
|
|
1777
|
+
if (resolveComponent && hasComponentBridgeInput(result)) {
|
|
1778
|
+
const nextComponentResult = injectNuxtComponentImports(result, resolveComponent);
|
|
1704
1779
|
if (nextComponentResult !== result) {
|
|
1705
1780
|
result = nextComponentResult;
|
|
1706
1781
|
changed = true;
|
package/dist/lint/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as ROOT_OXLINT_CONFIG_NAMES, d as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, f as setupNuxtLintConfigAddons, i as resolveNuxtLintCheckerOptions, l as toNuxtLintProjectState, n as createNuxtLintCheckerWebpackPlugin, o as setupNuxtLintConfigGeneration, r as createNuxtLintCheckerVitePlugin, s as writeFileIfChanged, t as setupNuxtLintChecker, u as renderNuxtOxlintConfig } from "../setup-
|
|
1
|
+
import { a as ROOT_OXLINT_CONFIG_NAMES, d as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, f as setupNuxtLintConfigAddons, i as resolveNuxtLintCheckerOptions, l as toNuxtLintProjectState, n as createNuxtLintCheckerWebpackPlugin, o as setupNuxtLintConfigGeneration, r as createNuxtLintCheckerVitePlugin, s as writeFileIfChanged, t as setupNuxtLintChecker, u as renderNuxtOxlintConfig } from "../setup-CewfseSX.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 };
|
|
@@ -554,6 +554,7 @@ async function importConfigModuleWithDependencies(configPath, registerModuleHook
|
|
|
554
554
|
let temporary;
|
|
555
555
|
try {
|
|
556
556
|
temporary = await realpath(await mkdtemp(join(tmpdir(), "vize-config-module-")));
|
|
557
|
+
await mkdir(join(temporary, "node_modules"), { mode: 448 });
|
|
557
558
|
} catch (error) {
|
|
558
559
|
finishAdapter();
|
|
559
560
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.805.0",
|
|
4
4
|
"description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@nuxt/kit": "3.21.8",
|
|
53
|
-
"@vizejs/native": "0.
|
|
54
|
-
"@vizejs/nuxt-lint-config": "0.
|
|
55
|
-
"@vizejs/vite-plugin": "0.
|
|
56
|
-
"@vizejs/vite-plugin-musea": "0.
|
|
57
|
-
"vize": "0.
|
|
53
|
+
"@vizejs/native": "0.805.0",
|
|
54
|
+
"@vizejs/nuxt-lint-config": "0.805.0",
|
|
55
|
+
"@vizejs/vite-plugin": "0.805.0",
|
|
56
|
+
"@vizejs/vite-plugin-musea": "0.805.0",
|
|
57
|
+
"vize": "0.805.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"jiti-nuxt2": "npm:jiti@1.21.7",
|
|
61
61
|
"oxlint": "1.78.0",
|
|
62
|
-
"oxlint-plugin-vize": "0.
|
|
62
|
+
"oxlint-plugin-vize": "0.805.0",
|
|
63
63
|
"typescript": "6.0.3",
|
|
64
64
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.5.0",
|
|
65
65
|
"vite-plus": "1.5.0",
|