@vizejs/nuxt 0.680.0 → 0.682.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";
@@ -1440,6 +1440,38 @@ function externalizeVueRuntimeForNuxtSsr(config) {
1440
1440
  rolldownOptions.external = [...new Set([...previous == null ? [] : Array.isArray(previous) ? previous : [previous], ...VUE_SSR_EXTERNAL])];
1441
1441
  }
1442
1442
  //#endregion
1443
+ //#region src/server-plugins.ts
1444
+ /** Keep the stylesheet virtual module and its server plugin registration together. */
1445
+ async function registerNuxtDevStylesheets(options, devAssetBase, resolver, registerLegacy) {
1446
+ options.nitro ||= {};
1447
+ options.nitro.virtual ||= {};
1448
+ options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(devAssetBase)};`;
1449
+ await registerNuxtServerPlugin(options.rootDir, {
1450
+ nitro2: resolver.resolve("./runtime/server/dev-stylesheet-links"),
1451
+ nitro3: resolver.resolve("./runtime/server/dev-stylesheet-links-nitro3")
1452
+ }, registerLegacy);
1453
+ }
1454
+ /** Use the host's server API selection while retaining older Nuxt/Bridge Kit support. */
1455
+ async function registerNuxtServerPlugin(rootDir, variants, registerLegacy) {
1456
+ let entry;
1457
+ try {
1458
+ entry = createRequire(`${rootDir}/package.json`).resolve("nuxt/kit");
1459
+ } catch (error) {
1460
+ if (error instanceof Error && "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) {
1461
+ await registerLegacy(variants.nitro2);
1462
+ return;
1463
+ }
1464
+ throw error;
1465
+ }
1466
+ const kit = await import(pathToFileURL(entry).href);
1467
+ if (typeof kit === "object" && kit !== null && "addNitroPlugin" in kit) {
1468
+ if (typeof kit.addNitroPlugin !== "function") throw new TypeError("The host nuxt/kit addNitroPlugin export must be a function.");
1469
+ kit.addNitroPlugin(variants);
1470
+ return;
1471
+ }
1472
+ await registerLegacy(variants.nitro2);
1473
+ }
1474
+ //#endregion
1443
1475
  //#region src/index.ts
1444
1476
  const VIZE_NUXT_AUTO_IMPORT_PATCHED = "__vizeNuxtAutoImportPatched";
1445
1477
  const moduleMeta = {
@@ -1457,9 +1489,6 @@ function loadNuxtKit() {
1457
1489
  nuxtKitPromise ||= import("@nuxt/kit");
1458
1490
  return nuxtKitPromise;
1459
1491
  }
1460
- async function addNuxtServerPlugin(plugin) {
1461
- (await loadNuxtKit()).addServerPlugin(plugin);
1462
- }
1463
1492
  async function addNuxtVitePlugin(plugin) {
1464
1493
  (await loadNuxtKit()).addVitePlugin(plugin);
1465
1494
  }
@@ -1570,15 +1599,7 @@ async function setupVizeNuxtModule(raw, nuxt) {
1570
1599
  });
1571
1600
  }
1572
1601
  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
- }
1602
+ if (nuxt.options.dev && devOptions.stylesheetLinks) await registerNuxtDevStylesheets(nuxt.options, compilerOptions.devUrlBase ?? buildNuxtDevAssetBase(appBaseURL, buildAssetsDir), resolver, async (plugin) => (await loadNuxtKit()).addServerPlugin(plugin));
1582
1603
  nuxt.hook("vite:configResolved", (config) => {
1583
1604
  isViteBuild = config.command === "build" || isNuxtBuild || nuxt.options.dev === false;
1584
1605
  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.680.0",
3
+ "version": "0.682.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.680.0",
53
- "@vizejs/nuxt-lint-config": "0.680.0",
54
- "@vizejs/vite-plugin": "0.680.0",
55
- "@vizejs/vite-plugin-musea": "0.680.0",
56
- "vize": "0.680.0"
52
+ "@vizejs/native": "0.682.0",
53
+ "@vizejs/nuxt-lint-config": "0.682.0",
54
+ "@vizejs/vite-plugin": "0.682.0",
55
+ "@vizejs/vite-plugin-musea": "0.682.0",
56
+ "vize": "0.682.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "jiti-nuxt2": "npm:jiti@1.21.7",
60
- "oxlint-plugin-vize": "0.680.0",
60
+ "oxlint-plugin-vize": "0.682.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"