@vizejs/vite-plugin 0.677.0 → 0.678.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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as vize } from "./plugin-
|
|
1
|
+
import { t as vize } from "./plugin-DeTv2aMw.mjs";
|
|
2
2
|
import { u as rewriteStaticAssetUrls } from "./vue-version-B0qUneRk.mjs";
|
|
3
3
|
import { a as resolveViteConfigExport, i as resolveConfigExport, n as defineConfig, o as vizeConfigStore, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-LlMZcDZI.mjs";
|
|
4
4
|
//#region src/index.ts
|
|
@@ -94,17 +94,34 @@ function utf16Offset(bytes, offset) {
|
|
|
94
94
|
if (offset > bytes.length || offset < bytes.length && (bytes[offset] & 192) === 128) throw new Error("[vize] Invalid native component export geometry.");
|
|
95
95
|
return bytes.subarray(0, offset).toString("utf8").length;
|
|
96
96
|
}
|
|
97
|
+
/** Locate the keyword boundary through ECMAScript whitespace and comments. */
|
|
98
|
+
function findExportDefaultKeywordEnd(code, start) {
|
|
99
|
+
if (!code.startsWith("export", start)) return null;
|
|
100
|
+
const gapStart = start + 6;
|
|
101
|
+
let cursor = gapStart;
|
|
102
|
+
while (cursor < code.length) if (/\s/u.test(code[cursor])) cursor++;
|
|
103
|
+
else if (code.startsWith("/*", cursor)) {
|
|
104
|
+
const end = code.indexOf("*/", cursor + 2);
|
|
105
|
+
if (end === -1) return null;
|
|
106
|
+
cursor = end + 2;
|
|
107
|
+
} else if (code.startsWith("//", cursor)) {
|
|
108
|
+
cursor += 2;
|
|
109
|
+
while (cursor < code.length && !/[\r\n\u2028\u2029]/u.test(code[cursor])) cursor++;
|
|
110
|
+
} else break;
|
|
111
|
+
return cursor > gapStart && code.startsWith("default", cursor) ? cursor + 7 : null;
|
|
112
|
+
}
|
|
97
113
|
/**
|
|
98
114
|
* Rewrite `export default X` to `const name = X` at the span the native
|
|
99
115
|
* compiler reported, converting its UTF-8 byte offsets against `module.code`.
|
|
100
|
-
* The span must still
|
|
101
|
-
* made stale by an earlier edit throws instead of
|
|
116
|
+
* The span must still contain the two keywords and only trivia between them,
|
|
117
|
+
* so a UTF-16 index or a span made stale by an earlier edit throws instead of
|
|
118
|
+
* corrupting the module.
|
|
102
119
|
*/
|
|
103
120
|
function bindDefaultExport(module, shape, name) {
|
|
104
121
|
const bytes = Buffer.from(module.code);
|
|
105
122
|
const start = utf16Offset(bytes, shape.defaultExportStart);
|
|
106
123
|
const end = utf16Offset(bytes, shape.defaultExportKeywordEnd);
|
|
107
|
-
if (
|
|
124
|
+
if (findExportDefaultKeywordEnd(module.code, start) !== end) throw new Error("[vize] Native component export geometry does not describe this module.");
|
|
108
125
|
module.replace(start, end, `const ${name} =`);
|
|
109
126
|
}
|
|
110
127
|
//#endregion
|
|
@@ -193,12 +210,6 @@ function analyzeFastDefaultOutput(code) {
|
|
|
193
210
|
defaultExportIsSfcMain: false
|
|
194
211
|
};
|
|
195
212
|
}
|
|
196
|
-
function getExportDefaultKeywordEnd(code, defaultExport) {
|
|
197
|
-
const exportStart = getNodeStart(defaultExport);
|
|
198
|
-
if (exportStart == null) return null;
|
|
199
|
-
const match = /^export\s+default\b/.exec(code.slice(exportStart));
|
|
200
|
-
return match ? exportStart + match[0].length : null;
|
|
201
|
-
}
|
|
202
213
|
function analyzeModuleOutput(code) {
|
|
203
214
|
const fastOutput = analyzeFastDefaultOutput(code);
|
|
204
215
|
if (fastOutput) return fastOutput;
|
|
@@ -206,7 +217,7 @@ function analyzeModuleOutput(code) {
|
|
|
206
217
|
const body = getProgramBody(program);
|
|
207
218
|
const defaultExport = findDefaultExport(program);
|
|
208
219
|
const defaultExportStart = getNodeStart(defaultExport);
|
|
209
|
-
const defaultExportKeywordEnd =
|
|
220
|
+
const defaultExportKeywordEnd = defaultExportStart != null ? findExportDefaultKeywordEnd(code, defaultExportStart) : null;
|
|
210
221
|
const exportedNames = body.filter((statement) => statement.type === "ExportNamedDeclaration").flatMap(getExportedNames);
|
|
211
222
|
return {
|
|
212
223
|
hasDefaultExport: defaultExport != null,
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
400
400
|
const legacy = compiler !== false && (await import("./vue-version-DL5NF2G-.mjs")).isLegacyVueCompatibilityMode(compiler);
|
|
401
401
|
const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
|
|
402
402
|
if (compiler !== false) {
|
|
403
|
-
const { vize } = await import("./plugin-
|
|
403
|
+
const { vize } = await import("./plugin-B3_BaqVE.mjs");
|
|
404
404
|
plugins.push(vize({
|
|
405
405
|
...plugin,
|
|
406
406
|
configMode: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.678.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vizejs/native": "0.
|
|
55
|
-
"@vizejs/unplugin": "0.
|
|
54
|
+
"@vizejs/native": "0.678.0",
|
|
55
|
+
"@vizejs/unplugin": "0.678.0",
|
|
56
56
|
"jsonc-parser": "^3.3.1",
|
|
57
57
|
"oxc-parser": "0.144.0",
|
|
58
58
|
"picomatch": "4.0.5",
|
|
59
59
|
"tinyglobby": "0.2.17",
|
|
60
|
-
"vize": "0.
|
|
60
|
+
"vize": "0.678.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|
package/dist/plugin-CKHGV6Rv.mjs
DELETED