@nasti-toolchain/nasti 2.4.2 → 2.4.3
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/README.md +34 -1
- package/dist/cli.cjs +64 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +64 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +62 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +62 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -4354,8 +4354,10 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4354
4354
|
});
|
|
4355
4355
|
const scopeId = hashId(id);
|
|
4356
4356
|
const wantsSourceMap = !!config.build.sourcemap || transformedSfc.map != null;
|
|
4357
|
+
const vapor = resolveVaporMode(descriptor, vueOptions, sfc, config);
|
|
4357
4358
|
let scriptCode = "";
|
|
4358
4359
|
let scriptMap;
|
|
4360
|
+
let scriptBindings;
|
|
4359
4361
|
if (descriptor.script || descriptor.scriptSetup) {
|
|
4360
4362
|
const inlineTemplate = vueOptions.script?.inlineTemplate !== false;
|
|
4361
4363
|
const compiled = sfc.compileScript(descriptor, {
|
|
@@ -4367,9 +4369,11 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4367
4369
|
// 让 compileScript 产出 `const __sfc__ = ...`(而非默认的 `export default {...}`)。
|
|
4368
4370
|
// 否则下方追加的 `__sfc__.render` / `__sfc__.__scopeId` / HMR 记录会引用一个
|
|
4369
4371
|
// 不存在的 `__sfc__`,并与 compileScript 自带的 `export default` 形成双重默认导出。
|
|
4370
|
-
genDefaultAs: "__sfc__"
|
|
4372
|
+
genDefaultAs: "__sfc__",
|
|
4373
|
+
vapor
|
|
4371
4374
|
});
|
|
4372
4375
|
scriptCode = compiled.content;
|
|
4376
|
+
scriptBindings = compiled.bindings;
|
|
4373
4377
|
scriptMap = composeSourceMapChain(
|
|
4374
4378
|
[compiled.map, transformedSfc.map],
|
|
4375
4379
|
{ filename: id, environmentName, type: "sfc" }
|
|
@@ -4383,7 +4387,9 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4383
4387
|
}
|
|
4384
4388
|
let templateCode = "";
|
|
4385
4389
|
let templateMap;
|
|
4390
|
+
let templateMultiRoot;
|
|
4386
4391
|
const scriptSetupIsInline = !!descriptor.scriptSetup && vueOptions.script?.inlineTemplate !== false;
|
|
4392
|
+
const isTemplateOnlyVapor = vapor && !descriptor.script && !descriptor.scriptSetup;
|
|
4387
4393
|
if (descriptor.template && !scriptSetupIsInline) {
|
|
4388
4394
|
const transformedTemplate = await applySourceTransform(
|
|
4389
4395
|
vueOptions.transformTemplate,
|
|
@@ -4405,12 +4411,16 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4405
4411
|
filename: id,
|
|
4406
4412
|
id: scopeId,
|
|
4407
4413
|
inMap: templateInputMap,
|
|
4414
|
+
vapor,
|
|
4408
4415
|
compilerOptions: {
|
|
4409
4416
|
...customCompilerOptions,
|
|
4417
|
+
// Vapor 在 bindingMetadata 缺失时需要空对象(与 Vite / compiler-sfc 一致)
|
|
4418
|
+
bindingMetadata: customCompilerOptions.bindingMetadata ?? scriptBindings ?? (vapor ? {} : void 0),
|
|
4410
4419
|
scopeId: `data-v-${scopeId}`
|
|
4411
4420
|
}
|
|
4412
4421
|
});
|
|
4413
4422
|
templateCode = compiled.code;
|
|
4423
|
+
templateMultiRoot = compiled.multiRoot;
|
|
4414
4424
|
if (wantsSourceMap || transformedTemplate.map != null) {
|
|
4415
4425
|
templateMap = compiled.map;
|
|
4416
4426
|
}
|
|
@@ -4448,12 +4458,20 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4448
4458
|
outputNode.add(fragment);
|
|
4449
4459
|
}
|
|
4450
4460
|
};
|
|
4451
|
-
append(
|
|
4461
|
+
append(
|
|
4462
|
+
scriptCode || (vapor ? "const __sfc__ = { __vapor: true }" : "const __sfc__ = {}"),
|
|
4463
|
+
scriptMap
|
|
4464
|
+
);
|
|
4452
4465
|
if (templateCode) {
|
|
4453
4466
|
append("\n");
|
|
4454
4467
|
append(templateCode, templateMap);
|
|
4455
4468
|
append("\n");
|
|
4456
4469
|
append("\n__sfc__.render = render\n");
|
|
4470
|
+
if (isTemplateOnlyVapor && templateMultiRoot !== void 0) {
|
|
4471
|
+
append(`
|
|
4472
|
+
__sfc__.__multiRoot = ${JSON.stringify(templateMultiRoot)}
|
|
4473
|
+
`);
|
|
4474
|
+
}
|
|
4457
4475
|
}
|
|
4458
4476
|
if (descriptor.styles.length > 0) {
|
|
4459
4477
|
for (let i = 0; i < descriptor.styles.length; i++) {
|
|
@@ -4462,6 +4480,16 @@ import "${id}?vue&type=style&index=${i}&lang.css"
|
|
|
4462
4480
|
`);
|
|
4463
4481
|
}
|
|
4464
4482
|
}
|
|
4483
|
+
if (vapor) {
|
|
4484
|
+
append(
|
|
4485
|
+
`
|
|
4486
|
+
if (!globalThis.__NASTI_VAPOR_BETA_WARNED__) {
|
|
4487
|
+
globalThis.__NASTI_VAPOR_BETA_WARNED__ = true
|
|
4488
|
+
console.warn(${JSON.stringify(VAPOR_BETA_WARNING)})
|
|
4489
|
+
}
|
|
4490
|
+
`
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4465
4493
|
append(`
|
|
4466
4494
|
__sfc__.__scopeId = "data-v-${scopeId}"
|
|
4467
4495
|
`);
|
|
@@ -4521,6 +4549,32 @@ if (import.meta.hot) {
|
|
|
4521
4549
|
}
|
|
4522
4550
|
};
|
|
4523
4551
|
}
|
|
4552
|
+
function resolveVaporMode(descriptor, vueOptions, sfc, config) {
|
|
4553
|
+
const requested = !!descriptor.vapor || !!vueOptions.features?.vapor && canForceVaporMode(descriptor);
|
|
4554
|
+
if (!requested) return false;
|
|
4555
|
+
if (!supportsVaporCompiler(sfc)) {
|
|
4556
|
+
config.logger.warnOnce(
|
|
4557
|
+
"[nasti:vue] Vapor Mode requires @vue/compiler-sfc >= 3.6. Install it: npm install @vue/compiler-sfc@^3.6.0-0"
|
|
4558
|
+
);
|
|
4559
|
+
return false;
|
|
4560
|
+
}
|
|
4561
|
+
config.logger.warnOnce(VAPOR_BETA_WARNING);
|
|
4562
|
+
return true;
|
|
4563
|
+
}
|
|
4564
|
+
function canForceVaporMode(descriptor) {
|
|
4565
|
+
if (typeof descriptor.filename === "string" && descriptor.filename.endsWith(".vue")) {
|
|
4566
|
+
if (descriptor.script && !descriptor.scriptSetup) return false;
|
|
4567
|
+
return !!(descriptor.scriptSetup || descriptor.template);
|
|
4568
|
+
}
|
|
4569
|
+
return true;
|
|
4570
|
+
}
|
|
4571
|
+
function supportsVaporCompiler(sfc) {
|
|
4572
|
+
const version = sfc.version;
|
|
4573
|
+
if (!version) return false;
|
|
4574
|
+
const [major, minor] = version.split(".").map((part) => Number.parseInt(part, 10));
|
|
4575
|
+
if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
|
|
4576
|
+
return major > 3 || major === 3 && minor >= 6;
|
|
4577
|
+
}
|
|
4524
4578
|
async function applySourceTransform(transform2, source, context) {
|
|
4525
4579
|
if (!transform2) return { code: source };
|
|
4526
4580
|
const result = await transform2(source, context);
|
|
@@ -4581,7 +4635,7 @@ function warnUnchainableMap(context, reason) {
|
|
|
4581
4635
|
function hashId(filename) {
|
|
4582
4636
|
return crypto2.createHash("sha256").update(filename).digest("hex").slice(0, 8);
|
|
4583
4637
|
}
|
|
4584
|
-
var VUE_FILE_RE, VUE_QUERY_RE, debug3, compiler;
|
|
4638
|
+
var VUE_FILE_RE, VUE_QUERY_RE, debug3, VAPOR_BETA_WARNING, compiler;
|
|
4585
4639
|
var init_vue = __esm({
|
|
4586
4640
|
"src/plugins/vue.ts"() {
|
|
4587
4641
|
"use strict";
|
|
@@ -4590,6 +4644,7 @@ var init_vue = __esm({
|
|
|
4590
4644
|
VUE_FILE_RE = /\.vue$/;
|
|
4591
4645
|
VUE_QUERY_RE = /\.vue\?vue&type=(script|template|style)(&index=\d+)?(&lang[.=]\w+)?/;
|
|
4592
4646
|
debug3 = createDebugger("nasti:vue");
|
|
4647
|
+
VAPOR_BETA_WARNING = "Vapor Mode is a beta feature; Zixiao Labs and the Vue team do not provide guarantees against crashes in production environments, and it is not suitable for server-side rendering environments.";
|
|
4593
4648
|
compiler = null;
|
|
4594
4649
|
}
|
|
4595
4650
|
});
|
|
@@ -5392,7 +5447,7 @@ async function build(inlineConfig = {}) {
|
|
|
5392
5447
|
const startTime = performance.now();
|
|
5393
5448
|
logger.info(
|
|
5394
5449
|
pc6.cyan(`
|
|
5395
|
-
nasti v${"2.4.
|
|
5450
|
+
nasti v${"2.4.3"} `) + pc6.green(`building for ${config.mode}...`)
|
|
5396
5451
|
);
|
|
5397
5452
|
debug6?.(`root: ${config.root}`);
|
|
5398
5453
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -6417,7 +6472,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6417
6472
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6418
6473
|
logger.info(
|
|
6419
6474
|
`
|
|
6420
|
-
${pc8.cyan(pc8.bold("NASTI"))} ${pc8.cyan(`v${"2.4.
|
|
6475
|
+
${pc8.cyan(pc8.bold("NASTI"))} ${pc8.cyan(`v${"2.4.3"}`)} ${pc8.dim("ready in")} ${pc8.bold(readyIn)} ${pc8.dim("ms")}
|
|
6421
6476
|
`
|
|
6422
6477
|
);
|
|
6423
6478
|
printServerUrls(
|
|
@@ -6611,7 +6666,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6611
6666
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
6612
6667
|
const startTime = performance.now();
|
|
6613
6668
|
assertElectronVersion(config);
|
|
6614
|
-
console.log(pc9.cyan("\n\u26A1 nasti build (electron)") + pc9.dim(` v${"2.4.
|
|
6669
|
+
console.log(pc9.cyan("\n\u26A1 nasti build (electron)") + pc9.dim(` v${"2.4.3"}`));
|
|
6615
6670
|
console.log(pc9.dim(` root: ${config.root}`));
|
|
6616
6671
|
console.log(pc9.dim(` mode: ${config.mode}`));
|
|
6617
6672
|
console.log(pc9.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -6792,7 +6847,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
6792
6847
|
const { noSpawn, ...rest } = inlineConfig;
|
|
6793
6848
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
6794
6849
|
warnElectronVersion(config);
|
|
6795
|
-
console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.4.
|
|
6850
|
+
console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.4.3"}`));
|
|
6796
6851
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
6797
6852
|
const server = await createServer2({
|
|
6798
6853
|
...rest,
|
|
@@ -7149,7 +7204,7 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7149
7204
|
const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
|
|
7150
7205
|
http2.createServer(app).listen(port, host, () => {
|
|
7151
7206
|
logger.info(`
|
|
7152
|
-
${pc11.cyan(pc11.bold("NASTI"))} ${pc11.cyan(`v${"2.4.
|
|
7207
|
+
${pc11.cyan(pc11.bold("NASTI"))} ${pc11.cyan(`v${"2.4.3"}`)} ${pc11.dim("preview")}
|
|
7153
7208
|
`);
|
|
7154
7209
|
printServerUrls2(
|
|
7155
7210
|
{
|
|
@@ -7166,6 +7221,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7166
7221
|
}
|
|
7167
7222
|
});
|
|
7168
7223
|
cli.help();
|
|
7169
|
-
cli.version("2.4.
|
|
7224
|
+
cli.version("2.4.3");
|
|
7170
7225
|
cli.parse();
|
|
7171
7226
|
//# sourceMappingURL=cli.js.map
|