@vizejs/nuxt 0.164.0 → 0.166.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 +71 -14
- package/package.json +7 -6
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ const COMPONENT_CALL_RE = /_?resolveComponent\s*\(\s*["'`]([^"'`]+)["'`]\s*(?:,\
|
|
|
10
10
|
const COMPONENTS_IMPORT_RE = /import\s+(?!type\b)\{([^}]*)\}\s+from\s+(["'])#components\2\s*;?/g;
|
|
11
11
|
const COMPONENT_EXT_RE = /\.(?:[cm]?js|ts|vue)$/;
|
|
12
12
|
const DTS_COMPONENT_RE = /^export const (\w+): (?:LazyComponent<)?typeof import\((["'])(.+?)\2\)(?:\.([A-Za-z_$][\w$]*)|\[['"]([A-Za-z_$][\w$]*)['"]\])>?/;
|
|
13
|
+
const DTS_GLOBAL_COMPONENT_RE = /^(?:"([^"]+)"|'([^']+)'|([A-Za-z_$][\w$]*))\??:\s*(?:LazyComponent<)?typeof import\((["'])(.+?)\4\)(?:\.([A-Za-z_$][\w$]*)|\[['"]([A-Za-z_$][\w$]*)['"]\])>?;?$/;
|
|
13
14
|
const DTS_EXT_RE = /\.d\.ts$/;
|
|
14
15
|
const FILE_EXTS = [
|
|
15
16
|
".js",
|
|
@@ -19,6 +20,7 @@ const FILE_EXTS = [
|
|
|
19
20
|
];
|
|
20
21
|
const CLIENT_COMPONENT_RE = /\.client\.(?:[cm]?js|ts|vue)$/;
|
|
21
22
|
const SERVER_COMPONENT_RE = /\.server\.(?:[cm]?js|ts|vue)$/;
|
|
23
|
+
const NUXT_ROUTE_ANNOUNCER_RE = /(?:^|[/\\])nuxt-route-announcer\.(?:[cm]?js|ts|vue)$/;
|
|
22
24
|
const RUNTIME_COMPONENT_DIRS = [
|
|
23
25
|
"dist/runtime/components",
|
|
24
26
|
"dist/runtime/components/nuxt4",
|
|
@@ -61,6 +63,10 @@ function detectComponentMode(filePath) {
|
|
|
61
63
|
function normalizeComponentMode(mode) {
|
|
62
64
|
return mode === "client" || mode === "server" ? mode : void 0;
|
|
63
65
|
}
|
|
66
|
+
function needsClientOnlyWrapper(resolved) {
|
|
67
|
+
if (resolved.mode !== "client") return false;
|
|
68
|
+
return !NUXT_ROUTE_ANNOUNCER_RE.test(resolved.filePath);
|
|
69
|
+
}
|
|
64
70
|
function parseComponentImportSpecifier(raw) {
|
|
65
71
|
const trimmed = raw.trim();
|
|
66
72
|
if (!trimmed) return null;
|
|
@@ -89,10 +95,11 @@ function createComponentImport(filePath, exportName, lazy, mode) {
|
|
|
89
95
|
function addResolvedComponentBinding(componentImports, resolved, variableName, rawVariableName) {
|
|
90
96
|
let needsCreateClientOnly = false;
|
|
91
97
|
let needsDefineAsyncComponent = false;
|
|
98
|
+
const wrapClientOnly = needsClientOnlyWrapper(resolved);
|
|
92
99
|
if (resolved.lazy) {
|
|
93
100
|
needsDefineAsyncComponent = true;
|
|
94
101
|
const exportAccessor = resolved.exportName === "default" ? "module.default" : `module[${JSON.stringify(resolved.exportName)}]`;
|
|
95
|
-
if (
|
|
102
|
+
if (wrapClientOnly) {
|
|
96
103
|
needsCreateClientOnly = true;
|
|
97
104
|
componentImports.push(`const ${variableName} = __nuxt_define_async_component(() => import(${JSON.stringify(resolved.filePath)}).then((module) => __nuxt_create_client_only(${exportAccessor})));`);
|
|
98
105
|
} else componentImports.push(`const ${variableName} = __nuxt_define_async_component(() => import(${JSON.stringify(resolved.filePath)}).then((module) => ${exportAccessor}));`);
|
|
@@ -102,7 +109,7 @@ function addResolvedComponentBinding(componentImports, resolved, variableName, r
|
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
111
|
if (resolved.exportName === "default") {
|
|
105
|
-
if (
|
|
112
|
+
if (wrapClientOnly) {
|
|
106
113
|
needsCreateClientOnly = true;
|
|
107
114
|
componentImports.push(`import ${rawVariableName} from ${JSON.stringify(resolved.filePath)};`);
|
|
108
115
|
componentImports.push(`const ${variableName} = __nuxt_create_client_only(${rawVariableName});`);
|
|
@@ -112,7 +119,7 @@ function addResolvedComponentBinding(componentImports, resolved, variableName, r
|
|
|
112
119
|
needsDefineAsyncComponent
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
|
-
if (
|
|
122
|
+
if (wrapClientOnly) {
|
|
116
123
|
needsCreateClientOnly = true;
|
|
117
124
|
componentImports.push(`import { ${resolved.exportName} as ${rawVariableName} } from ${JSON.stringify(resolved.filePath)};`);
|
|
118
125
|
componentImports.push(`const ${variableName} = __nuxt_create_client_only(${rawVariableName});`);
|
|
@@ -144,18 +151,58 @@ function forEachLine(content, visit) {
|
|
|
144
151
|
}
|
|
145
152
|
function loadDtsComponents(rootDir, buildDir) {
|
|
146
153
|
const resolved = /* @__PURE__ */ new Map();
|
|
147
|
-
for (const filePath of getNuxtComponentDtsFiles(rootDir, buildDir))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
for (const filePath of getNuxtComponentDtsFiles(rootDir, buildDir)) {
|
|
155
|
+
let inGlobalComponents = false;
|
|
156
|
+
let braceDepth = 0;
|
|
157
|
+
forEachLine(fs.readFileSync(filePath, "utf-8"), (line) => {
|
|
158
|
+
const trimmed = line.trim();
|
|
159
|
+
if (!inGlobalComponents && trimmed.includes("interface GlobalComponents")) {
|
|
160
|
+
inGlobalComponents = true;
|
|
161
|
+
braceDepth = countBraceDelta(trimmed);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (inGlobalComponents) {
|
|
165
|
+
braceDepth += countBraceDelta(trimmed);
|
|
166
|
+
if (braceDepth <= 0) {
|
|
167
|
+
inGlobalComponents = false;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const globalMatch = trimmed.match(DTS_GLOBAL_COMPONENT_RE);
|
|
171
|
+
if (globalMatch) {
|
|
172
|
+
const doubleQuotedName = globalMatch[1];
|
|
173
|
+
const singleQuotedName = globalMatch[2];
|
|
174
|
+
const bareName = globalMatch[3];
|
|
175
|
+
const importPath = globalMatch[5];
|
|
176
|
+
const exportNameDot = globalMatch[6];
|
|
177
|
+
const exportNameBracket = globalMatch[7];
|
|
178
|
+
const name = doubleQuotedName || singleQuotedName || bareName;
|
|
179
|
+
const exportName = exportNameDot || exportNameBracket;
|
|
180
|
+
if (name && exportName) {
|
|
181
|
+
const componentImport = createComponentImport(resolveImportPath(path.resolve(path.dirname(filePath), importPath)), exportName, name.startsWith("Lazy"));
|
|
182
|
+
addComponentAlias(resolved, name, componentImport);
|
|
183
|
+
addLazyComponentAlias(resolved, name, componentImport);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const match = trimmed.match(DTS_COMPONENT_RE);
|
|
189
|
+
if (!match) return;
|
|
190
|
+
const [, name, , importPath, exportNameDot, exportNameBracket] = match;
|
|
191
|
+
const exportName = exportNameDot || exportNameBracket;
|
|
192
|
+
if (!exportName) return;
|
|
193
|
+
const componentImport = createComponentImport(resolveImportPath(path.resolve(path.dirname(filePath), importPath)), exportName, name.startsWith("Lazy"));
|
|
194
|
+
addComponentAlias(resolved, name, componentImport);
|
|
195
|
+
addLazyComponentAlias(resolved, name, componentImport);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
157
198
|
return resolved;
|
|
158
199
|
}
|
|
200
|
+
function countBraceDelta(line) {
|
|
201
|
+
let delta = 0;
|
|
202
|
+
for (const ch of line) if (ch === "{") delta++;
|
|
203
|
+
else if (ch === "}") delta--;
|
|
204
|
+
return delta;
|
|
205
|
+
}
|
|
159
206
|
function getProjectPackageNames(moduleNames) {
|
|
160
207
|
const packageNames = new Set(["nuxt"]);
|
|
161
208
|
for (const name of moduleNames || []) packageNames.add(name);
|
|
@@ -346,6 +393,7 @@ function injectNuxtI18nHelpers(code) {
|
|
|
346
393
|
}
|
|
347
394
|
//#endregion
|
|
348
395
|
//#region src/utils.ts
|
|
396
|
+
const NUXT_OG_IMAGE_RENDERER_SFC_EXCLUDE = /\.takumi\.vue(?:\?|$)/;
|
|
349
397
|
function normalizeUrlPrefix(value) {
|
|
350
398
|
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
351
399
|
return withLeadingSlash.endsWith("/") ? withLeadingSlash : `${withLeadingSlash}/`;
|
|
@@ -361,9 +409,18 @@ function buildNuxtCompilerOptions(rootDir, baseURL = "/", buildAssetsDir = "/_nu
|
|
|
361
409
|
root: rootDir,
|
|
362
410
|
scanPatterns: []
|
|
363
411
|
};
|
|
364
|
-
|
|
412
|
+
if (overrides.customRenderer === true && overrides.exclude !== void 0) defaults.exclude = overrides.exclude;
|
|
413
|
+
else if (overrides.customRenderer !== true) defaults.exclude = mergeNuxtCompilerPatterns(NUXT_OG_IMAGE_RENDERER_SFC_EXCLUDE, overrides.exclude);
|
|
414
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
415
|
+
if (key === "exclude") continue;
|
|
416
|
+
if (value !== void 0) defaults[key] = value;
|
|
417
|
+
}
|
|
365
418
|
return defaults;
|
|
366
419
|
}
|
|
420
|
+
function mergeNuxtCompilerPatterns(defaultPattern, userPattern) {
|
|
421
|
+
if (userPattern == null) return defaultPattern;
|
|
422
|
+
return [defaultPattern, ...Array.isArray(userPattern) ? userPattern : [userPattern]];
|
|
423
|
+
}
|
|
367
424
|
function isVizeVirtualVueModuleId(id) {
|
|
368
425
|
return id.startsWith("\0") && /\.vue\.ts(?:\?|$)/.test(id);
|
|
369
426
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.166.0",
|
|
4
4
|
"description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@nuxt/kit": "4.4.6",
|
|
44
|
-
"@vizejs/musea-nuxt": "0.
|
|
45
|
-
"@vizejs/vite-plugin": "0.
|
|
46
|
-
"@vizejs/vite-plugin-musea": "0.
|
|
47
|
-
"vize": "0.
|
|
44
|
+
"@vizejs/musea-nuxt": "0.166.0",
|
|
45
|
+
"@vizejs/vite-plugin": "0.166.0",
|
|
46
|
+
"@vizejs/vite-plugin-musea": "0.166.0",
|
|
47
|
+
"vize": "0.166.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"typescript": "6.0.3",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"vue-router": "4.5.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"nuxt": "^2.16.0 || ^3.0.0 || ^4.0.0"
|
|
57
|
+
"nuxt": "^2.16.0 || ^3.0.0 || ^4.0.0",
|
|
58
|
+
"vite": "^8.0.0"
|
|
58
59
|
},
|
|
59
60
|
"engines": {
|
|
60
61
|
"node": ">=22"
|