@vizejs/nuxt 0.681.0 → 0.683.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.
@@ -44,7 +44,7 @@ interface VizeNuxtCompilerCompatibilityOptions {
44
44
  hostCompiler?: boolean;
45
45
  scriptSetupInStandalone?: boolean;
46
46
  optionsApiVapor?: boolean;
47
- nuxtVersion?: 2 | 3 | 4;
47
+ nuxtVersion?: 2 | 3 | 4 | 5;
48
48
  webpackVersion?: 4 | 5;
49
49
  }
50
50
  interface VizeNuxtInspectorLintPlanRequest {
@@ -215,7 +215,7 @@ interface VizeNuxtLintOptions extends NuxtLintFeatures {
215
215
  }
216
216
  //#endregion
217
217
  //#region src/options.d.ts
218
- type VizeNuxtMajorVersion = 2 | 3 | 4;
218
+ type VizeNuxtMajorVersion = 2 | 3 | 4 | 5;
219
219
  interface VizeNuxtCompatibilityOptions {
220
220
  /**
221
221
  * Override the detected Nuxt major version.
@@ -0,0 +1,41 @@
1
+ //#region src/dev-html.ts
2
+ function sanitizeNuxtDevStylesheetLinks(html, buildAssetsDir = "/_nuxt/") {
3
+ function normalizeUrlPrefix(value) {
4
+ const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
5
+ return withLeadingSlash.endsWith("/") ? withLeadingSlash : `${withLeadingSlash}/`;
6
+ }
7
+ const normalizedAssetsDir = normalizeUrlPrefix(buildAssetsDir);
8
+ const seenHrefs = /* @__PURE__ */ new Set();
9
+ function decodePathPart(pathPart) {
10
+ try {
11
+ return decodeURIComponent(pathPart);
12
+ } catch {
13
+ return pathPart;
14
+ }
15
+ }
16
+ function hasUnsafePathSegment(pathPart) {
17
+ return pathPart.split(/[\\/]/).some((segment) => segment === "..");
18
+ }
19
+ /** A `<style src>` module: the src stylesheet, with a style query naming its SFC. */
20
+ function isSfcStyleSrcModule(pathPart, query) {
21
+ if (!/\.(?:css|scss|sass|less|styl|stylus)$/i.test(pathPart)) return false;
22
+ const params = new URLSearchParams(query.replaceAll("&amp;", "&"));
23
+ return params.has("vue") && params.get("type") === "style" && (params.get("vize-file")?.endsWith(".vue") ?? false);
24
+ }
25
+ function isAllowedNuxtDevStylesheetPath(pathPart, query) {
26
+ return isSfcStyleSrcModule(pathPart, query) || pathPart.startsWith("@fs/") || pathPart.startsWith("@id/") || pathPart.startsWith("assets/") || pathPart.startsWith("virtual:") || /^(?:[^/\\]+\/)*[^/\\]+\.vue\.__vize_style_\d+\.css$/i.test(pathPart) || /^__[\w.-]+\.css$/i.test(pathPart) || /^[\w.-]+\.css$/i.test(pathPart);
27
+ }
28
+ function shouldKeepHref(href) {
29
+ if (seenHrefs.has(href)) return false;
30
+ seenHrefs.add(href);
31
+ if (!href.startsWith(normalizedAssetsDir)) return true;
32
+ const [pathAndQuery] = href.slice(normalizedAssetsDir.length).split("#");
33
+ const [pathPart, query = ""] = pathAndQuery.split("?", 2);
34
+ const decodedPath = decodePathPart(pathPart);
35
+ if (decodedPath.includes("\0") || hasUnsafePathSegment(decodedPath)) return false;
36
+ return isAllowedNuxtDevStylesheetPath(decodedPath, query);
37
+ }
38
+ return html.replace(/<link\b(?=[^>]*\brel=(["'])stylesheet\1)[^>]*\bhref=(["'])(.*?)\2[^>]*>/gi, (tag, _relQuote, _hrefQuote, href) => shouldKeepHref(href) ? tag : "");
39
+ }
40
+ //#endregion
41
+ export { sanitizeNuxtDevStylesheetLinks as t };
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-CEbRbA-x.mjs";
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-DqK0ees1.mjs";
2
2
  import { MuseaOptions } from "@vizejs/vite-plugin-musea";
3
3
 
4
4
  //#region src/schema.d.ts
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-BGzgtkeQ.mjs";
1
+ import { c as setupLintInspector, m as hasNuxtViteCompilerSupport, o as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor, t as setupNuxtLintChecker } from "./setup-qxQcXWk0.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";
@@ -1249,7 +1249,8 @@ async function setupNuxtViteCompiler(compilerOptions, nuxt, compiler) {
1249
1249
  const plugins = vize({
1250
1250
  ...explicit,
1251
1251
  nuxtPageMeta: true,
1252
- ssrModuleIdRoot: host.srcDir
1252
+ ssrModuleIdRoot: host.srcDir,
1253
+ ...host.buildDir ? { typeResolutionFallbackTsconfig: resolve(host.buildDir, "tsconfig.json") } : {}
1253
1254
  }, defaults, "nuxt");
1254
1255
  host.vite.plugins.push(plugins);
1255
1256
  const stage = plugins.find((plugin) => plugin.name === "vite-plugin-vize:sfc");
@@ -1440,6 +1441,38 @@ function externalizeVueRuntimeForNuxtSsr(config) {
1440
1441
  rolldownOptions.external = [...new Set([...previous == null ? [] : Array.isArray(previous) ? previous : [previous], ...VUE_SSR_EXTERNAL])];
1441
1442
  }
1442
1443
  //#endregion
1444
+ //#region src/server-plugins.ts
1445
+ /** Keep the stylesheet virtual module and its server plugin registration together. */
1446
+ async function registerNuxtDevStylesheets(options, devAssetBase, resolver, registerLegacy) {
1447
+ options.nitro ||= {};
1448
+ options.nitro.virtual ||= {};
1449
+ options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(devAssetBase)};`;
1450
+ await registerNuxtServerPlugin(options.rootDir, {
1451
+ nitro2: resolver.resolve("./runtime/server/dev-stylesheet-links"),
1452
+ nitro3: resolver.resolve("./runtime/server/dev-stylesheet-links-nitro3")
1453
+ }, registerLegacy);
1454
+ }
1455
+ /** Use the host's server API selection while retaining older Nuxt/Bridge Kit support. */
1456
+ async function registerNuxtServerPlugin(rootDir, variants, registerLegacy) {
1457
+ let entry;
1458
+ try {
1459
+ entry = createRequire(`${rootDir}/package.json`).resolve("nuxt/kit");
1460
+ } catch (error) {
1461
+ if (error instanceof Error && "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
1462
+ await registerLegacy(variants.nitro2);
1463
+ return;
1464
+ }
1465
+ throw error;
1466
+ }
1467
+ const kit = await import(pathToFileURL(entry).href);
1468
+ if (typeof kit === "object" && kit !== null && "addNitroPlugin" in kit) {
1469
+ if (typeof kit.addNitroPlugin !== "function") throw new TypeError("The host nuxt/kit addNitroPlugin export must be a function.");
1470
+ kit.addNitroPlugin(variants);
1471
+ return;
1472
+ }
1473
+ await registerLegacy(variants.nitro2);
1474
+ }
1475
+ //#endregion
1443
1476
  //#region src/index.ts
1444
1477
  const VIZE_NUXT_AUTO_IMPORT_PATCHED = "__vizeNuxtAutoImportPatched";
1445
1478
  const moduleMeta = {
@@ -1457,9 +1490,6 @@ function loadNuxtKit() {
1457
1490
  nuxtKitPromise ||= import("@nuxt/kit");
1458
1491
  return nuxtKitPromise;
1459
1492
  }
1460
- async function addNuxtServerPlugin(plugin) {
1461
- (await loadNuxtKit()).addServerPlugin(plugin);
1462
- }
1463
1493
  async function addNuxtVitePlugin(plugin) {
1464
1494
  (await loadNuxtKit()).addVitePlugin(plugin);
1465
1495
  }
@@ -1570,15 +1600,7 @@ async function setupVizeNuxtModule(raw, nuxt) {
1570
1600
  });
1571
1601
  }
1572
1602
  if (usesVizeCompiler) {
1573
- if (nuxt.options.dev && devOptions.stylesheetLinks) {
1574
- const devAssetBase = compilerOptions.devUrlBase ?? buildNuxtDevAssetBase(appBaseURL, buildAssetsDir);
1575
- nuxt.options.nitro ||= {};
1576
- nuxt.options.nitro.virtual ||= {};
1577
- if (nuxt.options.nitro.virtual) {
1578
- nuxt.options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(devAssetBase)};`;
1579
- await addNuxtServerPlugin(resolver.resolve("./runtime/server/dev-stylesheet-links"));
1580
- }
1581
- }
1603
+ if (nuxt.options.dev && devOptions.stylesheetLinks) await registerNuxtDevStylesheets(nuxt.options, compilerOptions.devUrlBase ?? buildNuxtDevAssetBase(appBaseURL, buildAssetsDir), resolver, async (plugin) => (await loadNuxtKit()).addServerPlugin(plugin));
1582
1604
  nuxt.hook("vite:configResolved", (config) => {
1583
1605
  isViteBuild = config.command === "build" || isNuxtBuild || nuxt.options.dev === false;
1584
1606
  for (let i = config.plugins.length - 1; i >= 0; i--) {
@@ -1,4 +1,4 @@
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-CEbRbA-x.mjs";
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-DqK0ees1.mjs";
2
2
  import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState, NuxtLintRuleConfig } from "@vizejs/nuxt-lint-config";
3
3
  export * from "@vizejs/nuxt-lint-config";
4
4
 
@@ -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-BGzgtkeQ.mjs";
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-qxQcXWk0.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 };
@@ -0,0 +1,12 @@
1
+ //#region src/runtime/server/dev-stylesheet-links-nitro3.d.ts
2
+ interface NuxtHtmlContext {
3
+ head: string[];
4
+ }
5
+ interface NitroRenderHooks {
6
+ hooks: {
7
+ hook(name: "render:html", callback: (html: NuxtHtmlContext) => void): void;
8
+ };
9
+ }
10
+ declare function registerDevStylesheetLinks(nitroApp: NitroRenderHooks): void;
11
+ //#endregion
12
+ export { registerDevStylesheetLinks as default };
@@ -0,0 +1,10 @@
1
+ import { t as sanitizeNuxtDevStylesheetLinks } from "../../dev-html-Bm3tnOAn.mjs";
2
+ import { devAssetBase } from "#vizejs/nuxt/dev-stylesheet-links-config";
3
+ //#region src/runtime/server/dev-stylesheet-links-nitro3.ts
4
+ function registerDevStylesheetLinks(nitroApp) {
5
+ nitroApp.hooks.hook("render:html", (html) => {
6
+ html.head = [sanitizeNuxtDevStylesheetLinks(html.head.join(""), devAssetBase)];
7
+ });
8
+ }
9
+ //#endregion
10
+ export { registerDevStylesheetLinks as default };
@@ -1,45 +1,6 @@
1
+ import { t as sanitizeNuxtDevStylesheetLinks } from "../../dev-html-Bm3tnOAn.mjs";
1
2
  import { defineNitroPlugin } from "nitropack/runtime";
2
3
  import { devAssetBase } from "#vizejs/nuxt/dev-stylesheet-links-config";
3
- //#region src/dev-html.ts
4
- function sanitizeNuxtDevStylesheetLinks(html, buildAssetsDir = "/_nuxt/") {
5
- function normalizeUrlPrefix(value) {
6
- const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
7
- return withLeadingSlash.endsWith("/") ? withLeadingSlash : `${withLeadingSlash}/`;
8
- }
9
- const normalizedAssetsDir = normalizeUrlPrefix(buildAssetsDir);
10
- const seenHrefs = /* @__PURE__ */ new Set();
11
- function decodePathPart(pathPart) {
12
- try {
13
- return decodeURIComponent(pathPart);
14
- } catch {
15
- return pathPart;
16
- }
17
- }
18
- function hasUnsafePathSegment(pathPart) {
19
- return pathPart.split(/[\\/]/).some((segment) => segment === "..");
20
- }
21
- /** A `<style src>` module: the src stylesheet, with a style query naming its SFC. */
22
- function isSfcStyleSrcModule(pathPart, query) {
23
- if (!/\.(?:css|scss|sass|less|styl|stylus)$/i.test(pathPart)) return false;
24
- const params = new URLSearchParams(query.replaceAll("&amp;", "&"));
25
- return params.has("vue") && params.get("type") === "style" && (params.get("vize-file")?.endsWith(".vue") ?? false);
26
- }
27
- function isAllowedNuxtDevStylesheetPath(pathPart, query) {
28
- return isSfcStyleSrcModule(pathPart, query) || pathPart.startsWith("@fs/") || pathPart.startsWith("@id/") || pathPart.startsWith("assets/") || pathPart.startsWith("virtual:") || /^(?:[^/\\]+\/)*[^/\\]+\.vue\.__vize_style_\d+\.css$/i.test(pathPart) || /^__[\w.-]+\.css$/i.test(pathPart) || /^[\w.-]+\.css$/i.test(pathPart);
29
- }
30
- function shouldKeepHref(href) {
31
- if (seenHrefs.has(href)) return false;
32
- seenHrefs.add(href);
33
- if (!href.startsWith(normalizedAssetsDir)) return true;
34
- const [pathAndQuery] = href.slice(normalizedAssetsDir.length).split("#");
35
- const [pathPart, query = ""] = pathAndQuery.split("?", 2);
36
- const decodedPath = decodePathPart(pathPart);
37
- if (decodedPath.includes("\0") || hasUnsafePathSegment(decodedPath)) return false;
38
- return isAllowedNuxtDevStylesheetPath(decodedPath, query);
39
- }
40
- return html.replace(/<link\b(?=[^>]*\brel=(["'])stylesheet\1)[^>]*\bhref=(["'])(.*?)\2[^>]*>/gi, (tag, _relQuote, _hrefQuote, href) => shouldKeepHref(href) ? tag : "");
41
- }
42
- //#endregion
43
4
  //#region src/runtime/server/dev-stylesheet-links.ts
44
5
  var dev_stylesheet_links_default = defineNitroPlugin((nitroApp) => {
45
6
  nitroApp.hooks.hook("render:response", (response) => {
@@ -18,7 +18,7 @@ function getDetectedNuxtMajor(nuxt) {
18
18
  const version = nuxtLike?._version ?? nuxtLike?.version ?? nuxtLike?.options?._nuxtVersion ?? nuxtLike?.constructor?.version;
19
19
  if (!version) return null;
20
20
  const major = Number.parseInt(version.replace(/^v/, "").split(".")[0] ?? "", 10);
21
- return major === 2 || major === 3 || major === 4 ? major : null;
21
+ return major === 2 || major === 3 || major === 4 || major === 5 ? major : null;
22
22
  }
23
23
  function isViteNuxtBuilder(builder) {
24
24
  if (typeof builder !== "string") return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/nuxt",
3
- "version": "0.681.0",
3
+ "version": "0.683.0",
4
4
  "description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
5
5
  "keywords": [
6
6
  "compiler",
@@ -49,15 +49,15 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@nuxt/kit": "3.21.8",
52
- "@vizejs/native": "0.681.0",
53
- "@vizejs/nuxt-lint-config": "0.681.0",
54
- "@vizejs/vite-plugin": "0.681.0",
55
- "@vizejs/vite-plugin-musea": "0.681.0",
56
- "vize": "0.681.0"
52
+ "@vizejs/native": "0.683.0",
53
+ "@vizejs/nuxt-lint-config": "0.683.0",
54
+ "@vizejs/vite-plugin": "0.683.0",
55
+ "@vizejs/vite-plugin-musea": "0.683.0",
56
+ "vize": "0.683.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "jiti-nuxt2": "npm:jiti@1.21.7",
60
- "oxlint-plugin-vize": "0.681.0",
60
+ "oxlint-plugin-vize": "0.683.0",
61
61
  "typescript": "6.0.3",
62
62
  "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
63
63
  "vite-plus": "1.3.0",
@@ -65,7 +65,7 @@
65
65
  "vue-router": "4.5.1"
66
66
  },
67
67
  "peerDependencies": {
68
- "nuxt": "^2.16.0 || ^3.0.0 || ^4.0.0",
68
+ "nuxt": "^2.16.0 || ^3.0.0 || ^4.0.0 || ^5.0.0-0",
69
69
  "oxlint": "^1.64.0",
70
70
  "oxlint-plugin-vize": ">=0.474.0",
71
71
  "vite": "^7.3.0 || ^8.0.0"