@vizejs/nuxt 0.426.3 → 0.428.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.
@@ -1,6 +1,40 @@
1
1
  import { NuxtLintConfigItem, NuxtLintFeatures } from "@vizejs/nuxt-lint-config";
2
2
  import { MuseaOptions } from "@vizejs/vite-plugin-musea";
3
3
 
4
+ //#region src/libraries.d.ts
5
+ /** Options for auto-registering `@vizejs/ui` components (and its `use*` helpers). */
6
+ interface VizeNuxtUiOptions {
7
+ /** Component name prefix, for example `"Vz"` for `<VzButton>`. @default "" */
8
+ prefix?: string;
9
+ /** Only register these families (package subpaths without `./`). @default every family */
10
+ include?: string[];
11
+ /** Never register these families. @default [] */
12
+ exclude?: string[];
13
+ /** Also auto-import the `use*` helpers exported by the included families. @default true */
14
+ composables?: boolean;
15
+ /** Resolve to the package or to `vize lib pull` copies. @default "package" */
16
+ source?: "local" | "package";
17
+ /** Lockfile path relative to the Nuxt root. @default "vize-lib.lock.json" */
18
+ lockfile?: string;
19
+ /** In local mode, fall back to the package for families that were not pulled. @default true */
20
+ fallback?: boolean;
21
+ }
22
+ /** Options for auto-importing `@vizejs/composable` exports. */
23
+ interface VizeNuxtComposablesOptions {
24
+ /** Only import from these entries (for example `"use-toggle"`). @default every entry */
25
+ include?: string[];
26
+ /** Never import from these entries. @default [] */
27
+ exclude?: string[];
28
+ /** Only import these export names. @default every runtime export */
29
+ names?: string[];
30
+ /** Resolve to the package or to `vize lib pull` copies. @default "package" */
31
+ source?: "local" | "package";
32
+ /** Lockfile path relative to the Nuxt root. @default "vize-lib.lock.json" */
33
+ lockfile?: string;
34
+ /** In local mode, fall back to the package for entries that were not pulled. @default true */
35
+ fallback?: boolean;
36
+ }
37
+ //#endregion
4
38
  //#region src/compiler-options.d.ts
5
39
  type VizeNuxtPattern = string | RegExp;
6
40
  type VizeNuxtVueVersion = 0.11 | 1 | 2 | "2.7" | 3 | "legacy";
@@ -336,6 +370,21 @@ interface VizeNuxtOptions {
336
370
  * Real Nuxt composables are available via Nuxt's own plugin pipeline.
337
371
  */
338
372
  nuxtMusea?: NuxtMuseaOptions;
373
+ /**
374
+ * Auto-register every `@vizejs/ui` component (and auto-import its `use*`
375
+ * helpers) from the library catalog, as direct family subpath imports.
376
+ * Requires `@vizejs/ui` in the project. Opt-in.
377
+ *
378
+ * @default false
379
+ */
380
+ ui?: boolean | VizeNuxtUiOptions;
381
+ /**
382
+ * Auto-import every `@vizejs/composable` export from the library catalog,
383
+ * as direct entry subpath imports. Requires `@vizejs/composable`. Opt-in.
384
+ *
385
+ * @default false
386
+ */
387
+ composables?: boolean | VizeNuxtComposablesOptions;
339
388
  }
340
389
  //#endregion
341
390
  //#region src/lint/addons.d.ts
@@ -372,4 +421,4 @@ type ResolveNuxtLintConfigAddons = () => Promise<readonly NuxtLintConfigItem[]>;
372
421
  */
373
422
  declare function setupNuxtLintConfigAddons(nuxt: NuxtLintConfigAddonNuxt): ResolveNuxtLintConfigAddons;
374
423
  //#endregion
375
- export { VizeNuxtLintCheckerOptions as _, ResolveNuxtLintConfigAddons as a, VizeNuxtCompilerOptions as b, NuxtMuseaOptions as c, VizeNuxtDevOptions as d, VizeNuxtMajorVersion as f, ResolvedVizeNuxtLintCheckerOptions as g, VizeNuxtLintOptions as h, NuxtLintImport as i, VizeNuxtBridgeOptions as l, VizeNuxtUnoCssOptions as m, NuxtLintConfigAddon as n, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK as o, VizeNuxtOptions as p, NuxtLintConfigAddonNuxt as r, setupNuxtLintConfigAddons as s, NuxtLintAwaitable as t, VizeNuxtCompatibilityOptions as u, resolveNuxtLintCheckerOptions as v, VizeNuxtVueVersion as x, VizeNuxtCompilerCompatibilityOptions as y };
424
+ export { VizeNuxtUiOptions as C, VizeNuxtComposablesOptions as S, VizeNuxtLintCheckerOptions as _, ResolveNuxtLintConfigAddons as a, VizeNuxtCompilerOptions as b, NuxtMuseaOptions as c, VizeNuxtDevOptions as d, VizeNuxtMajorVersion as f, ResolvedVizeNuxtLintCheckerOptions as g, VizeNuxtLintOptions as h, NuxtLintImport as i, VizeNuxtBridgeOptions as l, VizeNuxtUnoCssOptions as m, NuxtLintConfigAddon as n, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK as o, VizeNuxtOptions as p, NuxtLintConfigAddonNuxt as r, setupNuxtLintConfigAddons as s, NuxtLintAwaitable as t, VizeNuxtCompatibilityOptions as u, resolveNuxtLintCheckerOptions as v, VizeNuxtVueVersion as x, VizeNuxtCompilerCompatibilityOptions as y };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ 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-BLKAdEmK.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-7LzN4Qa1.mjs";
2
2
  import { MuseaOptions } from "@vizejs/vite-plugin-musea";
3
3
 
4
4
  //#region src/schema.d.ts
@@ -90,4 +90,4 @@ declare const vizeNuxtModule: ((this: VizeNuxtModuleContext | void, inlineOption
90
90
  };
91
91
  };
92
92
  //#endregion
93
- export { type MuseaOptions, type NuxtMuseaOptions, type VizeNuxtBridgeOptions, type VizeNuxtCompatibilityOptions, type VizeNuxtCompilerCompatibilityOptions, type VizeNuxtCompilerOptions, type VizeNuxtDevOptions, type VizeNuxtLintCheckerOptions, type VizeNuxtLintOptions, type VizeNuxtMajorVersion, type VizeNuxtOptions, type VizeNuxtUnoCssOptions, type VizeNuxtVueVersion, vizeNuxtModule as default };
93
+ export { type MuseaOptions, type NuxtMuseaOptions, type VizeNuxtBridgeOptions, type VizeNuxtCompatibilityOptions, type VizeNuxtCompilerCompatibilityOptions, type VizeNuxtCompilerOptions, type VizeNuxtComposablesOptions, type VizeNuxtDevOptions, type VizeNuxtLintCheckerOptions, type VizeNuxtLintOptions, type VizeNuxtMajorVersion, type VizeNuxtOptions, type VizeNuxtUiOptions, type VizeNuxtUnoCssOptions, type VizeNuxtVueVersion, vizeNuxtModule as default };
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { i as setupLintInspector, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, p as isViteNuxtBuilder } from "./generation-0O5ZoaRp.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import fs from "node:fs";
4
- import path, { dirname, resolve } from "node:path";
4
+ import path, { dirname, join, resolve } from "node:path";
5
5
  import { parseSync } from "vite";
6
+ import { pathToFileURL } from "node:url";
6
7
  import { createHash } from "node:crypto";
7
8
  //#region src/components.ts
8
9
  const COMPONENT_CALL_RE = /_?resolveComponent\s*\(\s*["'`]([^"'`]+)["'`]\s*(?:,\s*[^)]+)?\)/g;
@@ -1090,6 +1091,88 @@ function createNuxtModuleResolver() {
1090
1091
  const moduleDir = dirname(nodeRequire.resolve("@vizejs/nuxt"));
1091
1092
  return { resolve: (...segments) => resolve(moduleDir, ...segments) };
1092
1093
  }
1094
+ //#endregion
1095
+ //#region src/libraries.ts
1096
+ function projectLoader(rootDir, specifier, option) {
1097
+ return async () => {
1098
+ const projectRequire = createRequire(join(rootDir, "package.json"));
1099
+ let resolved;
1100
+ try {
1101
+ resolved = projectRequire.resolve(specifier);
1102
+ } catch (error) {
1103
+ throw new Error(`[@vizejs/nuxt] \`vize.${option}\` needs ${specifier.replace(/\/resolver$/, "")} installed in the project`, { cause: error });
1104
+ }
1105
+ return await import(pathToFileURL(resolved).href);
1106
+ };
1107
+ }
1108
+ /** Resolve resolver modules from the Nuxt project, so the project's installed versions drive registration. */
1109
+ function createProjectLibraryLoaders(rootDir) {
1110
+ return {
1111
+ ui: projectLoader(rootDir, "@vizejs/ui/resolver", "ui"),
1112
+ composables: projectLoader(rootDir, "@vizejs/composable/resolver", "composables")
1113
+ };
1114
+ }
1115
+ function withoutUndefined(options) {
1116
+ return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
1117
+ }
1118
+ /**
1119
+ * Plan component and import registrations from the library catalogs.
1120
+ * Everything resolves to direct family/entry subpaths, so tree shaking is
1121
+ * identical to hand-written imports; Nuxt generates the typed `.d.ts` files.
1122
+ */
1123
+ async function planVizeLibraryIntegration(options, rootDir, loaders = createProjectLibraryLoaders(rootDir)) {
1124
+ const plan = {
1125
+ components: [],
1126
+ imports: []
1127
+ };
1128
+ if (options.ui !== void 0 && options.ui !== false) {
1129
+ const ui = options.ui === true ? {} : options.ui;
1130
+ const resolverOptions = withoutUndefined({
1131
+ prefix: ui.prefix,
1132
+ include: ui.include,
1133
+ exclude: ui.exclude,
1134
+ source: ui.source,
1135
+ lockfile: ui.lockfile,
1136
+ fallback: ui.fallback,
1137
+ root: rootDir
1138
+ });
1139
+ const module = await loaders.ui();
1140
+ for (const item of module.listVizeUiComponents(resolverOptions)) plan.components.push({
1141
+ name: item.as ?? item.name,
1142
+ export: item.name,
1143
+ filePath: item.from
1144
+ });
1145
+ if (ui.composables !== false) for (const item of module.listVizeUiComposables(resolverOptions)) plan.imports.push({
1146
+ name: item.name,
1147
+ from: item.from
1148
+ });
1149
+ }
1150
+ if (options.composables !== void 0 && options.composables !== false) {
1151
+ const composables = options.composables === true ? {} : options.composables;
1152
+ const module = await loaders.composables();
1153
+ const taken = new Set(plan.imports.map((item) => item.name));
1154
+ for (const item of module.listVizeComposableImports(withoutUndefined({
1155
+ ...composables,
1156
+ root: rootDir
1157
+ }))) if (!taken.has(item.name)) plan.imports.push({
1158
+ name: item.name,
1159
+ from: item.from
1160
+ });
1161
+ }
1162
+ return plan;
1163
+ }
1164
+ /** Register the planned components and imports with Nuxt. */
1165
+ async function setupVizeLibraries(options, rootDir, loadKit, loaders) {
1166
+ if (!(options.ui !== void 0 && options.ui !== false || options.composables !== void 0 && options.composables !== false)) return {
1167
+ components: [],
1168
+ imports: []
1169
+ };
1170
+ const plan = await planVizeLibraryIntegration(options, rootDir, loaders);
1171
+ const kit = await loadKit();
1172
+ for (const component of plan.components) kit.addComponent(component);
1173
+ if (plan.imports.length > 0) kit.addImports(plan.imports);
1174
+ return plan;
1175
+ }
1093
1176
  function readTextFile(filePath) {
1094
1177
  return fs.readFileSync(filePath, "utf-8");
1095
1178
  }
@@ -1114,6 +1197,23 @@ function appendOriginalVueSourceForUnoCss(code, normalizedId, options = {}) {
1114
1197
  }
1115
1198
  }
1116
1199
  //#endregion
1200
+ //#region src/ssr-runtime.ts
1201
+ const VUE_SSR_EXTERNAL = [
1202
+ "vue",
1203
+ "vue/server-renderer",
1204
+ "@vue/server-renderer"
1205
+ ];
1206
+ function externalizeVueRuntimeForNuxtSsr(config) {
1207
+ const rolldownOptions = config.build?.rolldownOptions;
1208
+ if (!rolldownOptions) return;
1209
+ const previous = rolldownOptions.external;
1210
+ if (typeof previous === "function") {
1211
+ rolldownOptions.external = (id, ...args) => VUE_SSR_EXTERNAL.some((specifier) => specifier === id) || previous(id, ...args);
1212
+ return;
1213
+ }
1214
+ rolldownOptions.external = [...new Set([...previous == null ? [] : Array.isArray(previous) ? previous : [previous], ...VUE_SSR_EXTERNAL])];
1215
+ }
1216
+ //#endregion
1117
1217
  //#region src/index.ts
1118
1218
  const VIZE_NUXT_AUTO_IMPORT_PATCHED = "__vizeNuxtAutoImportPatched";
1119
1219
  const VUE_RUNTIME_DEDUPE = [
@@ -1250,6 +1350,10 @@ async function setupVizeNuxtModule(options, nuxt) {
1250
1350
  const museaOptions = detectedNuxtMajor === 2 ? false : resolveNuxtMuseaOptions(options.musea);
1251
1351
  const unocssOptions = resolveNuxtUnoCssOptions(options.unocss);
1252
1352
  if (museaOptions !== false) nuxt.hook("components:dirs", appendMuseaArtComponentIgnore);
1353
+ await setupVizeLibraries({
1354
+ ui: options.ui,
1355
+ composables: options.composables
1356
+ }, nuxt.options.rootDir, loadNuxtKit);
1253
1357
  const compilerOptions = resolveNuxtCompilerOptions(nuxt.options.rootDir, appBaseURL, buildAssetsDir, options.compiler, {
1254
1358
  supportsViteCompiler,
1255
1359
  vueVersion
@@ -1264,12 +1368,17 @@ async function setupVizeNuxtModule(options, nuxt) {
1264
1368
  }
1265
1369
  let isNuxtBuild = false;
1266
1370
  let isViteBuild = false;
1267
- if (usesVizeCompiler) nuxt.hook("build:before", () => {
1268
- if (nuxt.options.dev !== false) return;
1269
- isNuxtBuild = true;
1270
- nuxt.options.vite ||= {};
1271
- dedupeVueRuntimePackages(nuxt.options.vite);
1272
- });
1371
+ if (usesVizeCompiler) {
1372
+ nuxt.hook("build:before", () => {
1373
+ if (nuxt.options.dev !== false) return;
1374
+ isNuxtBuild = true;
1375
+ nuxt.options.vite ||= {};
1376
+ dedupeVueRuntimePackages(nuxt.options.vite);
1377
+ });
1378
+ nuxt.hook("vite:extendConfig", (config, context) => {
1379
+ if (nuxt.options.dev === false && context?.isServer) externalizeVueRuntimeForNuxtSsr(config);
1380
+ });
1381
+ }
1273
1382
  if (usesVizeCompiler) {
1274
1383
  if (nuxt.options.dev && devOptions.stylesheetLinks) {
1275
1384
  const devAssetBase = compilerOptions.devUrlBase ?? buildNuxtDevAssetBase(appBaseURL, buildAssetsDir);
@@ -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-BLKAdEmK.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-7LzN4Qa1.mjs";
2
2
  import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState } from "@vizejs/nuxt-lint-config";
3
3
  export * from "@vizejs/nuxt-lint-config";
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/nuxt",
3
- "version": "0.426.3",
3
+ "version": "0.428.0",
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.426.3",
53
- "@vizejs/nuxt-lint-config": "0.426.3",
54
- "@vizejs/vite-plugin": "0.426.3",
55
- "@vizejs/vite-plugin-musea": "0.426.3",
56
- "oxlint-plugin-vize": "0.426.3",
57
- "vize": "0.426.3"
52
+ "@vizejs/native": "0.428.0",
53
+ "@vizejs/nuxt-lint-config": "0.428.0",
54
+ "@vizejs/vite-plugin": "0.428.0",
55
+ "@vizejs/vite-plugin-musea": "0.428.0",
56
+ "oxlint-plugin-vize": "0.428.0",
57
+ "vize": "0.428.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "jiti-nuxt2": "npm:jiti@1.21.7",