@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/index.cjs
CHANGED
|
@@ -2308,8 +2308,10 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2308
2308
|
});
|
|
2309
2309
|
const scopeId = hashId(id);
|
|
2310
2310
|
const wantsSourceMap = !!config.build.sourcemap || transformedSfc.map != null;
|
|
2311
|
+
const vapor = resolveVaporMode(descriptor, vueOptions, sfc, config);
|
|
2311
2312
|
let scriptCode = "";
|
|
2312
2313
|
let scriptMap;
|
|
2314
|
+
let scriptBindings;
|
|
2313
2315
|
if (descriptor.script || descriptor.scriptSetup) {
|
|
2314
2316
|
const inlineTemplate = vueOptions.script?.inlineTemplate !== false;
|
|
2315
2317
|
const compiled = sfc.compileScript(descriptor, {
|
|
@@ -2321,9 +2323,11 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2321
2323
|
// 让 compileScript 产出 `const __sfc__ = ...`(而非默认的 `export default {...}`)。
|
|
2322
2324
|
// 否则下方追加的 `__sfc__.render` / `__sfc__.__scopeId` / HMR 记录会引用一个
|
|
2323
2325
|
// 不存在的 `__sfc__`,并与 compileScript 自带的 `export default` 形成双重默认导出。
|
|
2324
|
-
genDefaultAs: "__sfc__"
|
|
2326
|
+
genDefaultAs: "__sfc__",
|
|
2327
|
+
vapor
|
|
2325
2328
|
});
|
|
2326
2329
|
scriptCode = compiled.content;
|
|
2330
|
+
scriptBindings = compiled.bindings;
|
|
2327
2331
|
scriptMap = composeSourceMapChain(
|
|
2328
2332
|
[compiled.map, transformedSfc.map],
|
|
2329
2333
|
{ filename: id, environmentName, type: "sfc" }
|
|
@@ -2337,7 +2341,9 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2337
2341
|
}
|
|
2338
2342
|
let templateCode = "";
|
|
2339
2343
|
let templateMap;
|
|
2344
|
+
let templateMultiRoot;
|
|
2340
2345
|
const scriptSetupIsInline = !!descriptor.scriptSetup && vueOptions.script?.inlineTemplate !== false;
|
|
2346
|
+
const isTemplateOnlyVapor = vapor && !descriptor.script && !descriptor.scriptSetup;
|
|
2341
2347
|
if (descriptor.template && !scriptSetupIsInline) {
|
|
2342
2348
|
const transformedTemplate = await applySourceTransform(
|
|
2343
2349
|
vueOptions.transformTemplate,
|
|
@@ -2359,12 +2365,16 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2359
2365
|
filename: id,
|
|
2360
2366
|
id: scopeId,
|
|
2361
2367
|
inMap: templateInputMap,
|
|
2368
|
+
vapor,
|
|
2362
2369
|
compilerOptions: {
|
|
2363
2370
|
...customCompilerOptions,
|
|
2371
|
+
// Vapor 在 bindingMetadata 缺失时需要空对象(与 Vite / compiler-sfc 一致)
|
|
2372
|
+
bindingMetadata: customCompilerOptions.bindingMetadata ?? scriptBindings ?? (vapor ? {} : void 0),
|
|
2364
2373
|
scopeId: `data-v-${scopeId}`
|
|
2365
2374
|
}
|
|
2366
2375
|
});
|
|
2367
2376
|
templateCode = compiled.code;
|
|
2377
|
+
templateMultiRoot = compiled.multiRoot;
|
|
2368
2378
|
if (wantsSourceMap || transformedTemplate.map != null) {
|
|
2369
2379
|
templateMap = compiled.map;
|
|
2370
2380
|
}
|
|
@@ -2402,12 +2412,20 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2402
2412
|
outputNode.add(fragment);
|
|
2403
2413
|
}
|
|
2404
2414
|
};
|
|
2405
|
-
append(
|
|
2415
|
+
append(
|
|
2416
|
+
scriptCode || (vapor ? "const __sfc__ = { __vapor: true }" : "const __sfc__ = {}"),
|
|
2417
|
+
scriptMap
|
|
2418
|
+
);
|
|
2406
2419
|
if (templateCode) {
|
|
2407
2420
|
append("\n");
|
|
2408
2421
|
append(templateCode, templateMap);
|
|
2409
2422
|
append("\n");
|
|
2410
2423
|
append("\n__sfc__.render = render\n");
|
|
2424
|
+
if (isTemplateOnlyVapor && templateMultiRoot !== void 0) {
|
|
2425
|
+
append(`
|
|
2426
|
+
__sfc__.__multiRoot = ${JSON.stringify(templateMultiRoot)}
|
|
2427
|
+
`);
|
|
2428
|
+
}
|
|
2411
2429
|
}
|
|
2412
2430
|
if (descriptor.styles.length > 0) {
|
|
2413
2431
|
for (let i = 0; i < descriptor.styles.length; i++) {
|
|
@@ -2416,6 +2434,16 @@ import "${id}?vue&type=style&index=${i}&lang.css"
|
|
|
2416
2434
|
`);
|
|
2417
2435
|
}
|
|
2418
2436
|
}
|
|
2437
|
+
if (vapor) {
|
|
2438
|
+
append(
|
|
2439
|
+
`
|
|
2440
|
+
if (!globalThis.__NASTI_VAPOR_BETA_WARNED__) {
|
|
2441
|
+
globalThis.__NASTI_VAPOR_BETA_WARNED__ = true
|
|
2442
|
+
console.warn(${JSON.stringify(VAPOR_BETA_WARNING)})
|
|
2443
|
+
}
|
|
2444
|
+
`
|
|
2445
|
+
);
|
|
2446
|
+
}
|
|
2419
2447
|
append(`
|
|
2420
2448
|
__sfc__.__scopeId = "data-v-${scopeId}"
|
|
2421
2449
|
`);
|
|
@@ -2475,6 +2503,32 @@ if (import.meta.hot) {
|
|
|
2475
2503
|
}
|
|
2476
2504
|
};
|
|
2477
2505
|
}
|
|
2506
|
+
function resolveVaporMode(descriptor, vueOptions, sfc, config) {
|
|
2507
|
+
const requested = !!descriptor.vapor || !!vueOptions.features?.vapor && canForceVaporMode(descriptor);
|
|
2508
|
+
if (!requested) return false;
|
|
2509
|
+
if (!supportsVaporCompiler(sfc)) {
|
|
2510
|
+
config.logger.warnOnce(
|
|
2511
|
+
"[nasti:vue] Vapor Mode requires @vue/compiler-sfc >= 3.6. Install it: npm install @vue/compiler-sfc@^3.6.0-0"
|
|
2512
|
+
);
|
|
2513
|
+
return false;
|
|
2514
|
+
}
|
|
2515
|
+
config.logger.warnOnce(VAPOR_BETA_WARNING);
|
|
2516
|
+
return true;
|
|
2517
|
+
}
|
|
2518
|
+
function canForceVaporMode(descriptor) {
|
|
2519
|
+
if (typeof descriptor.filename === "string" && descriptor.filename.endsWith(".vue")) {
|
|
2520
|
+
if (descriptor.script && !descriptor.scriptSetup) return false;
|
|
2521
|
+
return !!(descriptor.scriptSetup || descriptor.template);
|
|
2522
|
+
}
|
|
2523
|
+
return true;
|
|
2524
|
+
}
|
|
2525
|
+
function supportsVaporCompiler(sfc) {
|
|
2526
|
+
const version = sfc.version;
|
|
2527
|
+
if (!version) return false;
|
|
2528
|
+
const [major, minor] = version.split(".").map((part) => Number.parseInt(part, 10));
|
|
2529
|
+
if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
|
|
2530
|
+
return major > 3 || major === 3 && minor >= 6;
|
|
2531
|
+
}
|
|
2478
2532
|
async function applySourceTransform(transform2, source, context) {
|
|
2479
2533
|
if (!transform2) return { code: source };
|
|
2480
2534
|
const result = await transform2(source, context);
|
|
@@ -2535,7 +2589,7 @@ function warnUnchainableMap(context, reason) {
|
|
|
2535
2589
|
function hashId(filename) {
|
|
2536
2590
|
return import_node_crypto2.default.createHash("sha256").update(filename).digest("hex").slice(0, 8);
|
|
2537
2591
|
}
|
|
2538
|
-
var import_node_crypto2, import_source_map_js2, VUE_FILE_RE, VUE_QUERY_RE, debug2, compiler;
|
|
2592
|
+
var import_node_crypto2, import_source_map_js2, VUE_FILE_RE, VUE_QUERY_RE, debug2, VAPOR_BETA_WARNING, compiler;
|
|
2539
2593
|
var init_vue = __esm({
|
|
2540
2594
|
"src/plugins/vue.ts"() {
|
|
2541
2595
|
"use strict";
|
|
@@ -2546,6 +2600,7 @@ var init_vue = __esm({
|
|
|
2546
2600
|
VUE_FILE_RE = /\.vue$/;
|
|
2547
2601
|
VUE_QUERY_RE = /\.vue\?vue&type=(script|template|style)(&index=\d+)?(&lang[.=]\w+)?/;
|
|
2548
2602
|
debug2 = createDebugger("nasti:vue");
|
|
2603
|
+
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.";
|
|
2549
2604
|
compiler = null;
|
|
2550
2605
|
}
|
|
2551
2606
|
});
|
|
@@ -3802,7 +3857,7 @@ async function build(inlineConfig = {}) {
|
|
|
3802
3857
|
const startTime = performance.now();
|
|
3803
3858
|
logger.info(
|
|
3804
3859
|
import_picocolors4.default.cyan(`
|
|
3805
|
-
nasti v${"2.4.
|
|
3860
|
+
nasti v${"2.4.3"} `) + import_picocolors4.default.green(`building for ${config.mode}...`)
|
|
3806
3861
|
);
|
|
3807
3862
|
debug5?.(`root: ${config.root}`);
|
|
3808
3863
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -6406,7 +6461,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6406
6461
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6407
6462
|
logger.info(
|
|
6408
6463
|
`
|
|
6409
|
-
${import_picocolors9.default.cyan(import_picocolors9.default.bold("NASTI"))} ${import_picocolors9.default.cyan(`v${"2.4.
|
|
6464
|
+
${import_picocolors9.default.cyan(import_picocolors9.default.bold("NASTI"))} ${import_picocolors9.default.cyan(`v${"2.4.3"}`)} ${import_picocolors9.default.dim("ready in")} ${import_picocolors9.default.bold(readyIn)} ${import_picocolors9.default.dim("ms")}
|
|
6410
6465
|
`
|
|
6411
6466
|
);
|
|
6412
6467
|
printServerUrls(
|
|
@@ -6631,7 +6686,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6631
6686
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
6632
6687
|
const startTime = performance.now();
|
|
6633
6688
|
assertElectronVersion(config);
|
|
6634
|
-
console.log(import_picocolors5.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors5.default.dim(` v${"2.4.
|
|
6689
|
+
console.log(import_picocolors5.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors5.default.dim(` v${"2.4.3"}`));
|
|
6635
6690
|
console.log(import_picocolors5.default.dim(` root: ${config.root}`));
|
|
6636
6691
|
console.log(import_picocolors5.default.dim(` mode: ${config.mode}`));
|
|
6637
6692
|
console.log(import_picocolors5.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -6804,7 +6859,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
6804
6859
|
const { noSpawn, ...rest } = inlineConfig;
|
|
6805
6860
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
6806
6861
|
warnElectronVersion(config);
|
|
6807
|
-
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.4.
|
|
6862
|
+
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.4.3"}`));
|
|
6808
6863
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
6809
6864
|
const server = await createServer2({
|
|
6810
6865
|
...rest,
|