@vizejs/nuxt 0.243.0 → 0.250.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.d.mts +58 -3
- package/dist/index.mjs +208 -164
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { defineNuxtModule } from "@nuxt/kit";
|
|
2
1
|
import { MuseaOptions, MuseaOptions as MuseaOptions$1 } from "@vizejs/vite-plugin-musea";
|
|
3
2
|
|
|
4
3
|
//#region src/compiler-options.d.ts
|
|
@@ -239,6 +238,62 @@ interface VizeNuxtOptions {
|
|
|
239
238
|
}
|
|
240
239
|
//#endregion
|
|
241
240
|
//#region src/index.d.ts
|
|
242
|
-
|
|
241
|
+
type NuxtWithBuilderOptions = {
|
|
242
|
+
_version?: string;
|
|
243
|
+
version?: string;
|
|
244
|
+
hook(name: string, callback: (...args: unknown[]) => unknown): void;
|
|
245
|
+
options: {
|
|
246
|
+
app?: {
|
|
247
|
+
baseURL?: string;
|
|
248
|
+
buildAssetsDir?: string;
|
|
249
|
+
};
|
|
250
|
+
builder?: string;
|
|
251
|
+
build?: {
|
|
252
|
+
publicPath?: string;
|
|
253
|
+
};
|
|
254
|
+
buildDir: string;
|
|
255
|
+
dev?: boolean;
|
|
256
|
+
modules: unknown[];
|
|
257
|
+
rootDir: string;
|
|
258
|
+
router?: {
|
|
259
|
+
base?: string;
|
|
260
|
+
};
|
|
261
|
+
vite?: {
|
|
262
|
+
plugins?: unknown[];
|
|
263
|
+
resolve?: {
|
|
264
|
+
dedupe?: string[];
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
nitro?: {
|
|
268
|
+
virtual?: Record<string, string>;
|
|
269
|
+
};
|
|
270
|
+
vize?: Partial<VizeNuxtOptions>;
|
|
271
|
+
_requiredModules?: Record<string, boolean>;
|
|
272
|
+
_nuxtVersion?: string;
|
|
273
|
+
[key: string]: unknown;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
type VizeNuxtModuleContext = {
|
|
277
|
+
nuxt?: NuxtWithBuilderOptions;
|
|
278
|
+
};
|
|
279
|
+
declare const vizeNuxtModule: ((this: VizeNuxtModuleContext | void, inlineOptions?: Partial<VizeNuxtOptions>, nuxtArg?: NuxtWithBuilderOptions) => Promise<void>) & {
|
|
280
|
+
getMeta: () => {
|
|
281
|
+
readonly name: "@vizejs/nuxt";
|
|
282
|
+
readonly configKey: "vize";
|
|
283
|
+
};
|
|
284
|
+
getOptions: (inlineOptions?: Partial<VizeNuxtOptions>, nuxt?: NuxtWithBuilderOptions) => VizeNuxtOptions;
|
|
285
|
+
meta: {
|
|
286
|
+
readonly name: "@vizejs/nuxt";
|
|
287
|
+
readonly configKey: "vize";
|
|
288
|
+
};
|
|
289
|
+
defaults: {
|
|
290
|
+
musea: false;
|
|
291
|
+
nuxtMusea: {
|
|
292
|
+
route: {
|
|
293
|
+
path: string;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
};
|
|
243
298
|
//#endregion
|
|
244
|
-
export { type MuseaOptions, type NuxtMuseaOptions, type VizeNuxtBridgeOptions, type VizeNuxtCompatibilityOptions, type VizeNuxtCompilerCompatibilityOptions, type VizeNuxtCompilerOptions, type VizeNuxtDevOptions, type VizeNuxtMajorVersion, type VizeNuxtOptions, type VizeNuxtUnoCssOptions, type VizeNuxtVueVersion,
|
|
299
|
+
export { type MuseaOptions, type NuxtMuseaOptions, type VizeNuxtBridgeOptions, type VizeNuxtCompatibilityOptions, type VizeNuxtCompilerCompatibilityOptions, type VizeNuxtCompilerOptions, type VizeNuxtDevOptions, type VizeNuxtMajorVersion, type VizeNuxtOptions, type VizeNuxtUnoCssOptions, type VizeNuxtVueVersion, vizeNuxtModule as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { addServerPlugin, addVitePlugin, createResolver, defineNuxtModule, getNuxtVersion, isNuxt2 } from "@nuxt/kit";
|
|
3
2
|
import fs from "node:fs";
|
|
4
|
-
import path, { dirname } from "node:path";
|
|
3
|
+
import path, { dirname, resolve } from "node:path";
|
|
5
4
|
import { createHash } from "node:crypto";
|
|
6
5
|
//#region src/components.ts
|
|
7
6
|
const COMPONENT_CALL_RE = /_?resolveComponent\s*\(\s*["'`]([^"'`]+)["'`]\s*(?:,\s*[^)]+)?\)/g;
|
|
@@ -707,7 +706,8 @@ function resolveNuxtMuseaOptions(musea) {
|
|
|
707
706
|
//#region src/resolver.ts
|
|
708
707
|
const nodeRequire = createRequire(`${process.cwd()}/package.json`);
|
|
709
708
|
function createNuxtModuleResolver() {
|
|
710
|
-
|
|
709
|
+
const moduleDir = dirname(nodeRequire.resolve("@vizejs/nuxt"));
|
|
710
|
+
return { resolve: (...segments) => resolve(moduleDir, ...segments) };
|
|
711
711
|
}
|
|
712
712
|
function readTextFile(filePath) {
|
|
713
713
|
return fs.readFileSync(filePath, "utf-8");
|
|
@@ -743,24 +743,66 @@ const VUE_RUNTIME_DEDUPE = [
|
|
|
743
743
|
"@vue/shared"
|
|
744
744
|
];
|
|
745
745
|
const VUE_CLIENT_RUNTIME_IMPORT = "vue/dist/vue.runtime.esm-bundler.js";
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
746
|
+
const moduleMeta = {
|
|
747
|
+
name: "@vizejs/nuxt",
|
|
748
|
+
configKey: "vize"
|
|
749
|
+
};
|
|
750
|
+
const moduleDefaults = {
|
|
751
|
+
musea: false,
|
|
752
|
+
nuxtMusea: { route: { path: "/" } }
|
|
753
|
+
};
|
|
754
|
+
let nuxtKitPromise = null;
|
|
755
|
+
function loadNuxtKit() {
|
|
756
|
+
nuxtKitPromise ||= import("@nuxt/kit");
|
|
757
|
+
return nuxtKitPromise;
|
|
758
|
+
}
|
|
759
|
+
async function addNuxtServerPlugin(plugin) {
|
|
760
|
+
const { addServerPlugin } = await loadNuxtKit();
|
|
761
|
+
addServerPlugin(plugin);
|
|
762
|
+
}
|
|
763
|
+
async function addNuxtVitePlugin(plugin) {
|
|
764
|
+
const { addVitePlugin } = await loadNuxtKit();
|
|
765
|
+
addVitePlugin(plugin);
|
|
766
|
+
}
|
|
767
|
+
function isPlainRecord(value) {
|
|
768
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
769
|
+
}
|
|
770
|
+
function mergePlainRecords(...values) {
|
|
771
|
+
const result = {};
|
|
772
|
+
for (const value of values) {
|
|
773
|
+
if (!value) continue;
|
|
774
|
+
for (const [key, nextValue] of Object.entries(value)) {
|
|
775
|
+
const currentValue = result[key];
|
|
776
|
+
result[key] = isPlainRecord(currentValue) && isPlainRecord(nextValue) ? mergePlainRecords(currentValue, nextValue) : nextValue;
|
|
777
|
+
}
|
|
753
778
|
}
|
|
779
|
+
return result;
|
|
780
|
+
}
|
|
781
|
+
function resolveModuleOptions(inlineOptions, nuxt) {
|
|
782
|
+
return mergePlainRecords(moduleDefaults, nuxt?.options.vize, inlineOptions);
|
|
783
|
+
}
|
|
784
|
+
function markNuxtRequiredModule(nuxt) {
|
|
785
|
+
nuxt.options._requiredModules ||= {};
|
|
786
|
+
nuxt.options._requiredModules[moduleMeta.name] = true;
|
|
787
|
+
}
|
|
788
|
+
function registerNuxt2CompatibilityHooks(nuxt) {
|
|
789
|
+
if (getDetectedNuxtMajor(nuxt) !== 2) return;
|
|
790
|
+
nuxt.hook("close", () => {});
|
|
791
|
+
nuxt.hook("builder:prepared", () => {});
|
|
792
|
+
nuxt.hook("build:templates", () => {});
|
|
793
|
+
}
|
|
794
|
+
function getDetectedNuxtMajor(nuxt) {
|
|
795
|
+
const nuxtLike = nuxt;
|
|
796
|
+
const version = nuxtLike?._version ?? nuxtLike?.version ?? (typeof nuxtLike?.options?._nuxtVersion === "string" ? nuxtLike.options._nuxtVersion : null);
|
|
797
|
+
if (!version) return null;
|
|
798
|
+
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
799
|
+
return major === 2 || major === 3 || major === 4 ? major : null;
|
|
754
800
|
}
|
|
755
801
|
function hasNuxtViteCompilerSupport(nuxt) {
|
|
756
802
|
const builder = nuxt.options.builder;
|
|
757
803
|
if (typeof builder === "string") return builder === "vite" || builder.includes("vite-builder");
|
|
758
804
|
if (nuxt.options.vite) return true;
|
|
759
|
-
|
|
760
|
-
return !isNuxt2(nuxt);
|
|
761
|
-
} catch {
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
805
|
+
return getDetectedNuxtMajor(nuxt) !== 2;
|
|
764
806
|
}
|
|
765
807
|
function getNuxtAppBaseURL(nuxt) {
|
|
766
808
|
return nuxt.options.app?.baseURL ?? nuxt.options.router?.base;
|
|
@@ -846,168 +888,170 @@ function patchNuxtAutoImportTransformPlugin(plugin, isBuild) {
|
|
|
846
888
|
};
|
|
847
889
|
plugin[VIZE_NUXT_AUTO_IMPORT_PATCHED] = true;
|
|
848
890
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
if (
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
891
|
+
async function setupVizeNuxtModule(options, nuxt) {
|
|
892
|
+
const resolver = createNuxtModuleResolver();
|
|
893
|
+
const detectedNuxtMajor = options.compatibility?.nuxtVersion ?? getDetectedNuxtMajor(nuxt) ?? 3;
|
|
894
|
+
const vueVersion = options.compatibility?.vueVersion ?? (detectedNuxtMajor === 2 ? 2 : 3);
|
|
895
|
+
const nuxtWithBuilderOptions = nuxt;
|
|
896
|
+
const supportsViteCompiler = hasNuxtViteCompilerSupport(nuxtWithBuilderOptions);
|
|
897
|
+
const appBaseURL = getNuxtAppBaseURL(nuxtWithBuilderOptions);
|
|
898
|
+
const buildAssetsDir = getNuxtBuildAssetsDir(nuxtWithBuilderOptions);
|
|
899
|
+
const bridgeOptions = resolveNuxtBridgeOptions(options.bridge);
|
|
900
|
+
const devOptions = resolveNuxtDevOptions(options.dev);
|
|
901
|
+
const museaOptions = resolveNuxtMuseaOptions(options.musea);
|
|
902
|
+
const unocssOptions = resolveNuxtUnoCssOptions(options.unocss);
|
|
903
|
+
if (museaOptions !== false) nuxt.hook("components:dirs", appendMuseaArtComponentIgnore);
|
|
904
|
+
const compilerOptions = resolveNuxtCompilerOptions(nuxt.options.rootDir, appBaseURL, buildAssetsDir, options.compiler, {
|
|
905
|
+
supportsViteCompiler,
|
|
906
|
+
vueVersion
|
|
907
|
+
});
|
|
908
|
+
const usesVizeCompiler = shouldUseVizeCompiler(compilerOptions);
|
|
909
|
+
if (compilerOptions !== false) {
|
|
910
|
+
const { default: vize } = await import("@vizejs/vite-plugin");
|
|
911
|
+
nuxt.options.vite ||= {};
|
|
912
|
+
nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
|
|
913
|
+
nuxt.options.vite.plugins.push(vize(compilerOptions));
|
|
914
|
+
}
|
|
915
|
+
let isNuxtBuild = false;
|
|
916
|
+
let isViteBuild = false;
|
|
917
|
+
if (usesVizeCompiler) nuxt.hook("build:before", () => {
|
|
918
|
+
if (nuxt.options.dev !== false) return;
|
|
919
|
+
isNuxtBuild = true;
|
|
920
|
+
nuxt.options.vite ||= {};
|
|
921
|
+
dedupeVueRuntimePackages(nuxt.options.vite);
|
|
922
|
+
});
|
|
923
|
+
if (usesVizeCompiler) {
|
|
924
|
+
if (nuxt.options.dev && devOptions.stylesheetLinks) {
|
|
925
|
+
const devAssetBase = compilerOptions.devUrlBase ?? buildNuxtDevAssetBase(appBaseURL, buildAssetsDir);
|
|
926
|
+
nuxt.options.nitro ||= {};
|
|
927
|
+
nuxt.options.nitro.virtual ||= {};
|
|
928
|
+
if (nuxt.options.nitro.virtual) {
|
|
929
|
+
nuxt.options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(devAssetBase)};`;
|
|
930
|
+
await addNuxtServerPlugin(resolver.resolve("./runtime/server/dev-stylesheet-links"));
|
|
931
|
+
}
|
|
881
932
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
933
|
+
nuxt.hook("vite:configResolved", (config) => {
|
|
934
|
+
isViteBuild = config.command === "build" || isNuxtBuild || nuxt.options.dev === false;
|
|
935
|
+
for (let i = config.plugins.length - 1; i >= 0; i--) {
|
|
936
|
+
const p = config.plugins[i];
|
|
937
|
+
const name = p && typeof p === "object" && "name" in p ? p.name : "";
|
|
938
|
+
if (name === "vite:vue") config.plugins.splice(i, 1);
|
|
939
|
+
else if (bridgeOptions.stableInjectedKeys && name === "nuxt:compiler:keyed-functions") patchNuxtKeyedFunctionsPlugin(p);
|
|
940
|
+
if (bridgeOptions.autoImports) patchNuxtAutoImportTransformPlugin(p, isViteBuild);
|
|
941
|
+
}
|
|
889
942
|
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
943
|
+
}
|
|
944
|
+
let unimportCtx = null;
|
|
945
|
+
if (usesVizeCompiler && bridgeOptions.autoImports) nuxt.hook("imports:context", (ctx) => {
|
|
946
|
+
unimportCtx = ctx;
|
|
947
|
+
});
|
|
948
|
+
const nuxtComponentResolver = usesVizeCompiler && bridgeOptions.components ? createNuxtComponentResolver({
|
|
949
|
+
buildDir: nuxt.options.buildDir,
|
|
950
|
+
moduleNames: nuxt.options.modules.filter((moduleName) => typeof moduleName === "string"),
|
|
951
|
+
rootDir: nuxt.options.rootDir
|
|
952
|
+
}) : null;
|
|
953
|
+
if (nuxtComponentResolver) nuxt.hook("components:extend", (comps) => {
|
|
954
|
+
nuxtComponentResolver.register(comps);
|
|
955
|
+
});
|
|
956
|
+
if (usesVizeCompiler && (bridgeOptions.autoImports || bridgeOptions.components || bridgeOptions.i18n || bridgeOptions.stableInjectedKeys)) await addNuxtVitePlugin({
|
|
957
|
+
name: "vizejs:nuxt-transform-bridge",
|
|
958
|
+
enforce: "post",
|
|
959
|
+
async transform(code, id, ...args) {
|
|
960
|
+
if (!isVizeGeneratedVueModuleId(id) && !isVizeJsxModuleId(id)) return;
|
|
961
|
+
let result = code;
|
|
962
|
+
let changed = false;
|
|
963
|
+
if (nuxtComponentResolver) {
|
|
964
|
+
const nextComponentResult = injectNuxtComponentImports(result, (name) => {
|
|
965
|
+
return nuxtComponentResolver.resolve(name);
|
|
966
|
+
});
|
|
967
|
+
if (nextComponentResult !== result) {
|
|
968
|
+
result = nextComponentResult;
|
|
969
|
+
changed = true;
|
|
898
970
|
}
|
|
899
971
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (name === "vite:vue") config.plugins.splice(i, 1);
|
|
906
|
-
else if (bridgeOptions.stableInjectedKeys && name === "nuxt:compiler:keyed-functions") patchNuxtKeyedFunctionsPlugin(p);
|
|
907
|
-
if (bridgeOptions.autoImports) patchNuxtAutoImportTransformPlugin(p, isViteBuild);
|
|
972
|
+
if (bridgeOptions.i18n) {
|
|
973
|
+
const nextResult = injectNuxtI18nHelpers(result);
|
|
974
|
+
if (nextResult !== result) {
|
|
975
|
+
result = nextResult;
|
|
976
|
+
changed = true;
|
|
908
977
|
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
buildDir: nuxt.options.buildDir,
|
|
917
|
-
moduleNames: nuxt.options.modules.filter((moduleName) => typeof moduleName === "string"),
|
|
918
|
-
rootDir: nuxt.options.rootDir
|
|
919
|
-
}) : null;
|
|
920
|
-
if (nuxtComponentResolver) nuxt.hook("components:extend", (comps) => {
|
|
921
|
-
nuxtComponentResolver.register(comps);
|
|
922
|
-
});
|
|
923
|
-
if (usesVizeCompiler && (bridgeOptions.autoImports || bridgeOptions.components || bridgeOptions.i18n || bridgeOptions.stableInjectedKeys)) addVitePlugin({
|
|
924
|
-
name: "vizejs:nuxt-transform-bridge",
|
|
925
|
-
enforce: "post",
|
|
926
|
-
async transform(code, id, ...args) {
|
|
927
|
-
if (!isVizeGeneratedVueModuleId(id) && !isVizeJsxModuleId(id)) return;
|
|
928
|
-
let result = code;
|
|
929
|
-
let changed = false;
|
|
930
|
-
if (nuxtComponentResolver) {
|
|
931
|
-
const nextComponentResult = injectNuxtComponentImports(result, (name) => {
|
|
932
|
-
return nuxtComponentResolver.resolve(name);
|
|
933
|
-
});
|
|
934
|
-
if (nextComponentResult !== result) {
|
|
935
|
-
result = nextComponentResult;
|
|
936
|
-
changed = true;
|
|
937
|
-
}
|
|
978
|
+
}
|
|
979
|
+
if (unimportCtx) try {
|
|
980
|
+
const beforeUnimport = result;
|
|
981
|
+
const injected = await unimportCtx.injectImports(result, id);
|
|
982
|
+
if (injected.imports && injected.imports.length > 0) {
|
|
983
|
+
result = preserveExplicitVueImportsFromNuxtAutoImports(beforeUnimport, injected.code);
|
|
984
|
+
changed = true;
|
|
938
985
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
986
|
+
} catch {}
|
|
987
|
+
if (bridgeOptions.autoImports) {
|
|
988
|
+
const nextResult = preserveExplicitVueImportsFromVizeModuleSource(id, result);
|
|
989
|
+
if (nextResult !== result) {
|
|
990
|
+
result = nextResult;
|
|
991
|
+
changed = true;
|
|
945
992
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
} catch {}
|
|
954
|
-
if (bridgeOptions.autoImports) {
|
|
955
|
-
const nextResult = preserveExplicitVueImportsFromVizeModuleSource(id, result);
|
|
956
|
-
if (nextResult !== result) {
|
|
957
|
-
result = nextResult;
|
|
958
|
-
changed = true;
|
|
959
|
-
}
|
|
993
|
+
}
|
|
994
|
+
if (bridgeOptions.stableInjectedKeys) {
|
|
995
|
+
const stableKeyResult = stabilizeNuxtInjectedKeysForVizeVirtualModule(result, id);
|
|
996
|
+
if (stableKeyResult !== result) {
|
|
997
|
+
result = stableKeyResult;
|
|
998
|
+
changed = true;
|
|
960
999
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1000
|
+
}
|
|
1001
|
+
if (isViteBuild && !isViteSsrTransform(args)) {
|
|
1002
|
+
const clientRuntimeResult = rewriteBareVueImportsToClientRuntime(result);
|
|
1003
|
+
if (clientRuntimeResult !== result) {
|
|
1004
|
+
result = clientRuntimeResult;
|
|
1005
|
+
changed = true;
|
|
967
1006
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1007
|
+
}
|
|
1008
|
+
if (changed) return {
|
|
1009
|
+
code: result,
|
|
1010
|
+
map: null
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
if (usesVizeCompiler && unocssOptions !== false) await addNuxtVitePlugin({
|
|
1015
|
+
name: "vizejs:unocss-bridge",
|
|
1016
|
+
configResolved(config) {
|
|
1017
|
+
for (const plugin of config.plugins) if (plugin.name?.startsWith("unocss:") && typeof plugin.transform === "function") {
|
|
1018
|
+
const origTransform = plugin.transform;
|
|
1019
|
+
const isExtractionOnly = plugin.name.startsWith("unocss:global");
|
|
1020
|
+
plugin.transform = function(code, id, ...args) {
|
|
1021
|
+
if (isVizeVirtualVueModuleId(id)) {
|
|
1022
|
+
const normalizedId = normalizeVizeVirtualVueModuleId(id);
|
|
1023
|
+
let effectiveCode = code;
|
|
1024
|
+
if (isExtractionOnly && unocssOptions.originalSource !== false) effectiveCode = appendOriginalVueSourceForUnoCss(code, normalizedId, { maxBytes: unocssOptions.originalSource.maxBytes });
|
|
1025
|
+
return origTransform.call(this, effectiveCode, normalizedId, ...args);
|
|
973
1026
|
}
|
|
974
|
-
|
|
975
|
-
if (changed) return {
|
|
976
|
-
code: result,
|
|
977
|
-
map: null
|
|
1027
|
+
return origTransform.call(this, code, id, ...args);
|
|
978
1028
|
};
|
|
979
1029
|
}
|
|
980
|
-
});
|
|
981
|
-
if (usesVizeCompiler && unocssOptions !== false) addVitePlugin({
|
|
982
|
-
name: "vizejs:unocss-bridge",
|
|
983
|
-
configResolved(config) {
|
|
984
|
-
for (const plugin of config.plugins) if (plugin.name?.startsWith("unocss:") && typeof plugin.transform === "function") {
|
|
985
|
-
const origTransform = plugin.transform;
|
|
986
|
-
const isExtractionOnly = plugin.name.startsWith("unocss:global");
|
|
987
|
-
plugin.transform = function(code, id, ...args) {
|
|
988
|
-
if (isVizeVirtualVueModuleId(id)) {
|
|
989
|
-
const normalizedId = normalizeVizeVirtualVueModuleId(id);
|
|
990
|
-
let effectiveCode = code;
|
|
991
|
-
if (isExtractionOnly && unocssOptions.originalSource !== false) effectiveCode = appendOriginalVueSourceForUnoCss(code, normalizedId, { maxBytes: unocssOptions.originalSource.maxBytes });
|
|
992
|
-
return origTransform.call(this, effectiveCode, normalizedId, ...args);
|
|
993
|
-
}
|
|
994
|
-
return origTransform.call(this, code, id, ...args);
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
if (museaOptions !== false && supportsViteCompiler) {
|
|
1000
|
-
const { musea } = await import("@vizejs/vite-plugin-musea");
|
|
1001
|
-
const museaBasePath = "basePath" in museaOptions ? museaOptions.basePath : "/__musea__";
|
|
1002
|
-
nuxt.options.vite ||= {};
|
|
1003
|
-
nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
|
|
1004
|
-
nuxt.options.vite.plugins.push(...musea(museaOptions));
|
|
1005
|
-
nuxt.hook("listen", (_server, listener) => {
|
|
1006
|
-
const url = listener.url?.replace(/\/$/, "") || "http://localhost:3000";
|
|
1007
|
-
console.log(` \x1b[36m➜\x1b[0m \x1b[1mMusea Gallery:\x1b[0m \x1b[36m${url}${museaBasePath}\x1b[0m`);
|
|
1008
|
-
});
|
|
1009
1030
|
}
|
|
1031
|
+
});
|
|
1032
|
+
if (museaOptions !== false && supportsViteCompiler) {
|
|
1033
|
+
const { musea } = await import("@vizejs/vite-plugin-musea");
|
|
1034
|
+
const museaBasePath = "basePath" in museaOptions ? museaOptions.basePath : "/__musea__";
|
|
1035
|
+
nuxt.options.vite ||= {};
|
|
1036
|
+
nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
|
|
1037
|
+
nuxt.options.vite.plugins.push(...musea(museaOptions));
|
|
1038
|
+
nuxt.hook("listen", (_server, listener) => {
|
|
1039
|
+
const url = listener.url?.replace(/\/$/, "") || "http://localhost:3000";
|
|
1040
|
+
console.log(` \x1b[36m➜\x1b[0m \x1b[1mMusea Gallery:\x1b[0m \x1b[36m${url}${museaBasePath}\x1b[0m`);
|
|
1041
|
+
});
|
|
1010
1042
|
}
|
|
1043
|
+
}
|
|
1044
|
+
const vizeNuxtModule = Object.assign(async function vizeNuxtModule(inlineOptions = {}, nuxtArg) {
|
|
1045
|
+
const nuxt = nuxtArg ?? this?.nuxt;
|
|
1046
|
+
if (!nuxt) throw new Error("@vizejs/nuxt requires a Nuxt instance");
|
|
1047
|
+
markNuxtRequiredModule(nuxt);
|
|
1048
|
+
registerNuxt2CompatibilityHooks(nuxt);
|
|
1049
|
+
await setupVizeNuxtModule(resolveModuleOptions(inlineOptions, nuxt), nuxt);
|
|
1050
|
+
}, {
|
|
1051
|
+
getMeta: () => moduleMeta,
|
|
1052
|
+
getOptions: (inlineOptions = {}, nuxt) => resolveModuleOptions(inlineOptions, nuxt),
|
|
1053
|
+
meta: moduleMeta,
|
|
1054
|
+
defaults: moduleDefaults
|
|
1011
1055
|
});
|
|
1012
1056
|
//#endregion
|
|
1013
|
-
export {
|
|
1057
|
+
export { vizeNuxtModule as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.250.0",
|
|
4
4
|
"description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@nuxt/kit": "3.11.2",
|
|
45
|
-
"@vizejs/vite-plugin": "0.
|
|
46
|
-
"@vizejs/vite-plugin-musea": "0.
|
|
47
|
-
"vize": "0.
|
|
45
|
+
"@vizejs/vite-plugin": "0.250.0",
|
|
46
|
+
"@vizejs/vite-plugin-musea": "0.250.0",
|
|
47
|
+
"vize": "0.251.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"typescript": "6.0.3",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"nuxt": "^2.16.0 || ^3.0.0 || ^4.0.0",
|
|
58
|
-
"vite": "^8.0.0"
|
|
58
|
+
"vite": "^7.3.0 || ^8.0.0"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22"
|