@vizejs/vite-plugin 0.670.0 → 0.671.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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/plugin-B4z8Tx1Z.mjs +2 -0
- package/dist/{plugin-DZ3byUmi.mjs → plugin-BRR28jru.mjs} +38 -34
- package/dist/{types-mem20MPI.d.mts → types-gYK-MbLv.d.mts} +2 -5
- package/dist/vite-plus.d.mts +1 -1
- package/dist/vite-plus.mjs +1 -1
- package/package.json +4 -4
- package/dist/plugin-BzoGUulL.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-
|
|
1
|
+
import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-gYK-MbLv.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/compiler-config.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as vize } from "./plugin-
|
|
1
|
+
import { t as vize } from "./plugin-BRR28jru.mjs";
|
|
2
2
|
import { u as rewriteStaticAssetUrls } from "./vue-version-BFh0eI6J.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
|
|
@@ -88,10 +88,34 @@ function styleFingerprint(module) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
|
+
//#region ../shared/native-shape.ts
|
|
92
|
+
function utf16Offset(bytes, offset) {
|
|
93
|
+
if (offset == null || offset < 0 || !Number.isInteger(offset)) throw new Error("[vize] Missing native component export geometry.");
|
|
94
|
+
if (offset > bytes.length || offset < bytes.length && (bytes[offset] & 192) === 128) throw new Error("[vize] Invalid native component export geometry.");
|
|
95
|
+
return bytes.subarray(0, offset).toString("utf8").length;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rewrite `export default X` to `const name = X` at the span the native
|
|
99
|
+
* compiler reported, converting its UTF-8 byte offsets against `module.code`.
|
|
100
|
+
* The span must still spell `export default` there, so a UTF-16 index or a span
|
|
101
|
+
* made stale by an earlier edit throws instead of corrupting the module.
|
|
102
|
+
*/
|
|
103
|
+
function bindDefaultExport(module, shape, name) {
|
|
104
|
+
const bytes = Buffer.from(module.code);
|
|
105
|
+
const start = utf16Offset(bytes, shape.defaultExportStart);
|
|
106
|
+
const end = utf16Offset(bytes, shape.defaultExportKeywordEnd);
|
|
107
|
+
if (!/^export\s+default$/.test(module.code.slice(start, end))) throw new Error("[vize] Native component export geometry does not describe this module.");
|
|
108
|
+
module.replace(start, end, `const ${name} =`);
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
91
111
|
//#region src/utils/module-output.ts
|
|
92
112
|
const OUTPUT_PARSE_ID = "vize-output.tsx";
|
|
93
113
|
const SFC_MAIN_NAME = "_sfc_main";
|
|
94
114
|
const EXPORT_DEFAULT = "export default";
|
|
115
|
+
/** oxc and string indices count UTF-16 units; the native shape counts UTF-8 bytes. */
|
|
116
|
+
function byteOffset(code, index) {
|
|
117
|
+
return index == null ? null : Buffer.byteLength(code.slice(0, index));
|
|
118
|
+
}
|
|
95
119
|
function isNode(value) {
|
|
96
120
|
return value != null && typeof value === "object" && typeof value.type === "string";
|
|
97
121
|
}
|
|
@@ -163,8 +187,8 @@ function analyzeFastDefaultOutput(code) {
|
|
|
163
187
|
hasSfcMainDefined: false,
|
|
164
188
|
hasNamedRenderExport: false,
|
|
165
189
|
hasNamedSsrRenderExport: false,
|
|
166
|
-
defaultExportStart,
|
|
167
|
-
defaultExportKeywordEnd: defaultExportStart + 14,
|
|
190
|
+
defaultExportStart: byteOffset(code, defaultExportStart),
|
|
191
|
+
defaultExportKeywordEnd: byteOffset(code, defaultExportStart + 14),
|
|
168
192
|
defaultExportEnd: null,
|
|
169
193
|
defaultExportIsSfcMain: false
|
|
170
194
|
};
|
|
@@ -191,36 +215,12 @@ function analyzeModuleOutput(code) {
|
|
|
191
215
|
}),
|
|
192
216
|
hasNamedRenderExport: exportedNames.includes("render"),
|
|
193
217
|
hasNamedSsrRenderExport: exportedNames.includes("ssrRender"),
|
|
194
|
-
defaultExportKeywordEnd,
|
|
195
|
-
defaultExportStart,
|
|
196
|
-
defaultExportEnd: getNodeEnd(defaultExport),
|
|
218
|
+
defaultExportKeywordEnd: byteOffset(code, defaultExportKeywordEnd),
|
|
219
|
+
defaultExportStart: byteOffset(code, defaultExportStart),
|
|
220
|
+
defaultExportEnd: byteOffset(code, getNodeEnd(defaultExport)),
|
|
197
221
|
defaultExportIsSfcMain: isSfcMainDefaultExport(defaultExport)
|
|
198
222
|
};
|
|
199
223
|
}
|
|
200
|
-
function rewriteDefaultExportToSfcMain(code, moduleInfo = {
|
|
201
|
-
defaultExportKeywordEnd: null,
|
|
202
|
-
defaultExportStart: null
|
|
203
|
-
}) {
|
|
204
|
-
let exportStart = moduleInfo.defaultExportStart;
|
|
205
|
-
let keywordEnd = moduleInfo.defaultExportKeywordEnd;
|
|
206
|
-
if (exportStart == null || keywordEnd == null) {
|
|
207
|
-
const defaultExport = findDefaultExport(parseProgram(code));
|
|
208
|
-
exportStart = getNodeStart(defaultExport);
|
|
209
|
-
keywordEnd = defaultExport ? getExportDefaultKeywordEnd(code, defaultExport) : null;
|
|
210
|
-
}
|
|
211
|
-
if (exportStart == null || keywordEnd == null) return code;
|
|
212
|
-
return `${code.slice(0, exportStart)}const ${SFC_MAIN_NAME} =${code.slice(keywordEnd)}`;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Insert `insertion` before `export default _sfc_main`. `moduleInfo` must
|
|
216
|
-
* describe `code` exactly (offsets are used verbatim), so the module is never
|
|
217
|
-
* parsed again (#3425).
|
|
218
|
-
*/
|
|
219
|
-
function insertBeforeSfcMainDefaultExport(code, insertion, moduleInfo) {
|
|
220
|
-
const exportStart = moduleInfo.defaultExportStart;
|
|
221
|
-
if (!moduleInfo.defaultExportIsSfcMain || exportStart == null) return code;
|
|
222
|
-
return `${code.slice(0, exportStart)}${insertion}\n${code.slice(exportStart)}`;
|
|
223
|
-
}
|
|
224
224
|
//#endregion
|
|
225
225
|
//#region ../shared/source-map.ts
|
|
226
226
|
function isSourceMapV3(value) {
|
|
@@ -297,9 +297,9 @@ function prependMappedJsxCode(code, mapJson, prefix) {
|
|
|
297
297
|
*
|
|
298
298
|
* The native compiler returns a map for the module it emitted. `generateOutput`
|
|
299
299
|
* then rewrites that module: it prepends a `<style>` injection, splices style
|
|
300
|
-
* imports in after the last static import,
|
|
301
|
-
*
|
|
302
|
-
*
|
|
300
|
+
* imports in after the last static import, rewrites `export default` to
|
|
301
|
+
* `const _sfc_main =`, and appends `__scopeId`, CSS-module wiring and HMR
|
|
302
|
+
* code. All of those are whole-line insertions or same-line
|
|
303
303
|
* substitutions, which is exactly the class of edit a v3 `mappings` string can
|
|
304
304
|
* absorb without being decoded:
|
|
305
305
|
*
|
|
@@ -356,6 +356,10 @@ var MappedModule = class {
|
|
|
356
356
|
const startsAtLineStart = prefix === 0 || previous.charCodeAt(prefix - 1) === 10;
|
|
357
357
|
this.map = shiftMappedLines(this.map, startsAtLineStart ? editLine : editLine + 1, addedLines);
|
|
358
358
|
}
|
|
359
|
+
/** Replace `code[start, end)`, in UTF-16 indices. */
|
|
360
|
+
replace(start, end, text) {
|
|
361
|
+
this.edit(`${this.code.slice(0, start)}${text}${this.code.slice(end)}`);
|
|
362
|
+
}
|
|
359
363
|
};
|
|
360
364
|
//#endregion
|
|
361
365
|
//#region src/utils/component-output.ts
|
|
@@ -369,12 +373,12 @@ function assembleComponentOutput(compiled) {
|
|
|
369
373
|
const hasSfcMainDefined = moduleInfo.hasSfcMainDefined;
|
|
370
374
|
let exportsSfcMain = true;
|
|
371
375
|
if (hasExportDefault && !hasSfcMainDefined) {
|
|
372
|
-
|
|
376
|
+
bindDefaultExport(emitted, moduleInfo, "_sfc_main");
|
|
373
377
|
if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
|
|
374
378
|
emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
|
|
375
379
|
} else if (hasExportDefault && hasSfcMainDefined) {
|
|
376
380
|
exportsSfcMain = moduleInfo.defaultExportIsSfcMain;
|
|
377
|
-
if (compiled.hasScoped && compiled.scopeId) emitted.edit(
|
|
381
|
+
if (exportsSfcMain && compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
|
|
378
382
|
} else if (!hasExportDefault && !hasSfcMainDefined && hasNamedRenderExport) {
|
|
379
383
|
const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
|
|
380
384
|
emitted.edit(`${emitted.code}\nconst _sfc_main = { render${scope} };\nexport default _sfc_main;`);
|
|
@@ -1138,6 +1138,7 @@ interface VizeVueFeatures {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
//#endregion
|
|
1140
1140
|
//#region src/utils/module-output.d.ts
|
|
1141
|
+
/** The native `moduleShape`: offsets are UTF-8 bytes into the module. */
|
|
1141
1142
|
type ModuleOutputInfo = {
|
|
1142
1143
|
hasDefaultExport: boolean;
|
|
1143
1144
|
hasSfcMainDefined: boolean;
|
|
@@ -1145,11 +1146,7 @@ type ModuleOutputInfo = {
|
|
|
1145
1146
|
hasNamedSsrRenderExport: boolean;
|
|
1146
1147
|
defaultExportKeywordEnd: number | null;
|
|
1147
1148
|
defaultExportStart: number | null; /** End offset of the whole `export default ...` statement, or `null`. */
|
|
1148
|
-
defaultExportEnd: number | null;
|
|
1149
|
-
/**
|
|
1150
|
-
* Whether the default export's declaration is exactly the `_sfc_main`
|
|
1151
|
-
* identifier -- the only shape {@link insertBeforeSfcMainDefaultExport} acts on.
|
|
1152
|
-
*/
|
|
1149
|
+
defaultExportEnd: number | null; /** Whether the default export's declaration is exactly the `_sfc_main` identifier. */
|
|
1153
1150
|
defaultExportIsSfcMain: boolean;
|
|
1154
1151
|
};
|
|
1155
1152
|
//#endregion
|
package/dist/vite-plus.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-
|
|
1
|
+
import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-gYK-MbLv.mjs";
|
|
2
2
|
import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
|
|
3
3
|
|
|
4
4
|
//#region src/vite-plus/types.d.ts
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
400
400
|
const legacy = compiler !== false && (await import("./vue-version-DOjZaMiI.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-B4z8Tx1Z.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.671.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.671.0",
|
|
55
|
+
"@vizejs/unplugin": "0.671.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.671.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|
package/dist/plugin-BzoGUulL.mjs
DELETED