@vmz/vmz 0.3.14 → 0.3.15
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.
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
{ "src": "browser/unknown-component.js", "out": "unknown-component.js" },
|
|
13
13
|
{ "src": "shared/dom-attr-normalize.js", "out": "dom-attr-normalize.js" },
|
|
14
14
|
{ "src": "shared/html-digest.js", "out": "html-digest.js" },
|
|
15
|
+
{ "src": "shared/row-key.js", "out": "row-key.js" },
|
|
15
16
|
{ "src": "faces/http.js", "out": "vmz-http.js" },
|
|
16
17
|
{ "src": "browser/client-nav.js", "out": "vmz-client-nav.js" }
|
|
17
18
|
],
|
package/dist/cli/cli.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* Node CLI command implementations .
|
|
3
3
|
*/
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import { existsSync, statSync } from 'node:fs';
|
|
5
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { createCli } from '@vmz/commander';
|
|
8
8
|
import { registerApplicationCommands } from './application-cmd.js';
|
|
9
9
|
import { assembleDelivery, emitBuildProof } from '../workspace/build-assemble.js';
|
|
10
|
+
import { listenLocalStaticHost } from '../workspace/cdn-policy.js';
|
|
10
11
|
import { resolveCliLocalesRoot } from './cli-localize.js';
|
|
11
12
|
import { normalizeDeliveryAuthoring, resolveProfileArtifactDir, selectBuildProfile } from '../delivery/delivery-profile.js';
|
|
12
13
|
import { createDevSession } from '../dev/dev-session.js';
|
|
@@ -401,6 +402,14 @@ async function cmdServe(args) {
|
|
|
401
402
|
return 1;
|
|
402
403
|
}
|
|
403
404
|
const outDir = resolveProfileArtifactDir(outDirRoot, selected.profile);
|
|
405
|
+
const host = typeof args.host === 'string' ? args.host : '127.0.0.1';
|
|
406
|
+
const port = Number(args.port ?? 5173);
|
|
407
|
+
// `web-static` assemblies are pruned for delivery: the Node runtime face, page
|
|
408
|
+
// modules and `_vmz/pack-node/` are deliberately absent, so spawning the SSR
|
|
409
|
+
// host here fails with `ERR_MODULE_NOT_FOUND`. Serve the emitted HTML instead.
|
|
410
|
+
if (readAssembleAssembly(outDir) === 'web-static') {
|
|
411
|
+
return await serveWebStaticArtifact(outDir, host, port);
|
|
412
|
+
}
|
|
404
413
|
const hostJs = path.join(outDir, 'vmz-serve-host.mjs');
|
|
405
414
|
{
|
|
406
415
|
try {
|
|
@@ -412,8 +421,6 @@ async function cmdServe(args) {
|
|
|
412
421
|
return 1;
|
|
413
422
|
}
|
|
414
423
|
}
|
|
415
|
-
const host = typeof args.host === 'string' ? args.host : '127.0.0.1';
|
|
416
|
-
const port = Number(args.port ?? 5173);
|
|
417
424
|
log.info(`serve http://${host}:${port}`);
|
|
418
425
|
const node = process.env.VMZ_NODE || process.execPath;
|
|
419
426
|
const child = spawn(node, [hostJs], {
|
|
@@ -444,6 +451,45 @@ async function cmdServe(args) {
|
|
|
444
451
|
});
|
|
445
452
|
});
|
|
446
453
|
}
|
|
454
|
+
/** `assembly` recorded by the last build at this artifact dir, or `''` when absent. */
|
|
455
|
+
function readAssembleAssembly(outDir) {
|
|
456
|
+
try {
|
|
457
|
+
const raw = JSON.parse(readFileSync(path.join(outDir, '_vmz', 'assemble-manifest.json'), 'utf8'));
|
|
458
|
+
return typeof raw?.assembly === 'string' ? raw.assembly : '';
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
return '';
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Preview a pruned `web-static` artifact through the CDN policy of the build:
|
|
466
|
+
* per-route HTML, real 404 document, cache headers. No SSR host is involved.
|
|
467
|
+
*/
|
|
468
|
+
async function serveWebStaticArtifact(outDir, host, port) {
|
|
469
|
+
if (!existsSync(path.join(outDir, 'index.html'))) {
|
|
470
|
+
log.error(`missing ${path.join(outDir, 'index.html')} — run \`vmz build --profile static\` first`);
|
|
471
|
+
return 1;
|
|
472
|
+
}
|
|
473
|
+
let policy = {};
|
|
474
|
+
const policyPath = path.join(outDir, '_vmz', 'cdn-policy-manifest.json');
|
|
475
|
+
if (existsSync(policyPath)) {
|
|
476
|
+
try {
|
|
477
|
+
policy = JSON.parse(readFileSync(policyPath, 'utf8'));
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
policy = {};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const server = await listenLocalStaticHost(outDir, policy, { host, port });
|
|
484
|
+
log.info(`serve static ${server.baseUrl} (web-static artifact, no SSR host)`);
|
|
485
|
+
return await new Promise((resolve) => {
|
|
486
|
+
const shutdown = () => {
|
|
487
|
+
server.close().then(() => resolve(0), () => resolve(1));
|
|
488
|
+
};
|
|
489
|
+
process.once('SIGINT', shutdown);
|
|
490
|
+
process.once('SIGTERM', shutdown);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
447
493
|
async function cmdDev(args) {
|
|
448
494
|
const pathArg = args._[0] ?? '.';
|
|
449
495
|
const { project, outDir: outDirRoot } = resolveWorkspaceDirs({
|
|
@@ -42,6 +42,12 @@ interface LocalStaticHostOpts {
|
|
|
42
42
|
host?: string;
|
|
43
43
|
port?: number;
|
|
44
44
|
}
|
|
45
|
+
export interface LocalStaticHost {
|
|
46
|
+
host: string;
|
|
47
|
+
port: number;
|
|
48
|
+
baseUrl: string;
|
|
49
|
+
close: () => Promise<void>;
|
|
50
|
+
}
|
|
45
51
|
export declare function buildCdnPolicyManifest(staticManifest: Record<string, unknown>, opts?: BuildCdnPolicyOpts): CdnPolicyManifest;
|
|
46
52
|
/**
|
|
47
53
|
* Write CDN policy + adapter projections under dist/_vmz.
|
|
@@ -165,7 +171,7 @@ export declare function projectCdnAdapter(policy: CdnPolicyManifest, adapterId:
|
|
|
165
171
|
* @param {{ host?: string, port?: number }} [opts]
|
|
166
172
|
* @returns {Promise<{ host: string, port: number, baseUrl: string, close: () => Promise<void> }>}
|
|
167
173
|
*/
|
|
168
|
-
export declare function listenLocalStaticHost(distDir: string, policy: Record<string, unknown>, opts?: LocalStaticHostOpts): Promise<
|
|
174
|
+
export declare function listenLocalStaticHost(distDir: string, policy: Record<string, unknown>, opts?: LocalStaticHostOpts): Promise<LocalStaticHost>;
|
|
169
175
|
/**
|
|
170
176
|
* @param {string} distDir
|
|
171
177
|
* @param {Record<string, any>} policy
|
|
@@ -22,6 +22,7 @@ function rewriteFlatDeliveryImports(text) {
|
|
|
22
22
|
['../browser/unknown-component.js', './unknown-component.js'],
|
|
23
23
|
['../shared/dom-attr-normalize.js', './dom-attr-normalize.js'],
|
|
24
24
|
['../shared/html-digest.js', './html-digest.js'],
|
|
25
|
+
['../shared/row-key.js', './row-key.js'],
|
|
25
26
|
['../browser/client-nav.js', './vmz-client-nav.js'],
|
|
26
27
|
['../ssr/dom-ssr.js', './dom-ssr.js'],
|
|
27
28
|
['../faces/server.js', './vmz-runtime.js'],
|
|
@@ -39,6 +40,7 @@ function rewriteNestedSsrDelivery(text) {
|
|
|
39
40
|
// reach the root copy one level up.
|
|
40
41
|
out = replaceImportPath(out, '../shared/dom-attr-normalize.js', '../dom-attr-normalize.js');
|
|
41
42
|
out = replaceImportPath(out, '../shared/html-digest.js', '../html-digest.js');
|
|
43
|
+
out = replaceImportPath(out, '../shared/row-key.js', '../row-key.js');
|
|
42
44
|
for (const [from, to] of [
|
|
43
45
|
['../browser/dom-core.js', '../dom-core.js'],
|
|
44
46
|
['../browser/direct-host-box.js', '../direct-host-box.js'],
|
|
@@ -51,6 +53,7 @@ function rewriteNestedSsrDelivery(text) {
|
|
|
51
53
|
function rewriteNestedBrowserDelivery(text) {
|
|
52
54
|
let out = replaceImportPath(text, '../../shared/dom-attr-normalize.js', '../../dom-attr-normalize.js');
|
|
53
55
|
out = replaceImportPath(out, '../../shared/html-digest.js', '../../html-digest.js');
|
|
56
|
+
out = replaceImportPath(out, '../../shared/row-key.js', '../../row-key.js');
|
|
54
57
|
// `dom-ssr.js` 只交付在根(flat barrel),nested `ssr/` 下没有它:
|
|
55
58
|
// island resume 的动态边必须指向根级产物。
|
|
56
59
|
out = replaceImportPath(out, '../../ssr/dom-ssr.js', '../../dom-ssr.js');
|
package/locales/en-US/diag.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"vmz::template::illegal_directive": "Illegal or unsupported directive in `<template>`: {detail}",
|
|
11
11
|
"vmz::template::parse_failed": "Failed to parse `<template>`: {detail}",
|
|
12
12
|
"vmz::template::invalid_expr": "Invalid template expression: {detail}",
|
|
13
|
+
|
|
13
14
|
"vmz::template::v_model_invalid_target": "`v-model` target must be an assignable identifier or member expression: `{expr}`",
|
|
14
15
|
"vmz::template::v_model_on_file_input": "`v-model` cannot bind an `<input type=\"file\">`",
|
|
15
16
|
"vmz::template::each_missing_key": "`v-for` on `<{tag}>` should declare a `:key`",
|
package/locales/zh-CN/diag.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"vmz::template::illegal_directive": "`<template>` 中存在非法或不支持的指令:{detail}",
|
|
7
7
|
"vmz::template::parse_failed": "解析 `<template>` 失败:{detail}",
|
|
8
8
|
"vmz::template::invalid_expr": "模板表达式无效:{detail}",
|
|
9
|
+
|
|
9
10
|
"vmz::template::v_model_invalid_target": "`v-model` 的目标必须是可赋值的标识符或成员表达式:`{expr}`",
|
|
10
11
|
"vmz::template::v_model_on_file_input": "`v-model` 不能绑定到 `<input type=\"file\">`",
|
|
11
12
|
"vmz::template::each_missing_key": "`<{tag}>` 上的 `v-for` 应声明 `:key`",
|
package/package.json
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
"vmz": "./bin/vmz.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@vmz/commander": "0.3.
|
|
7
|
-
"@vmz/core": "0.3.
|
|
8
|
-
"@vmz/diagnostic": "0.3.
|
|
9
|
-
"@vmz/plugin": "0.3.
|
|
10
|
-
"@vmz/protocol": "0.3.
|
|
6
|
+
"@vmz/commander": "0.3.15",
|
|
7
|
+
"@vmz/core": "0.3.15",
|
|
8
|
+
"@vmz/diagnostic": "0.3.15",
|
|
9
|
+
"@vmz/plugin": "0.3.15",
|
|
10
|
+
"@vmz/protocol": "0.3.15"
|
|
11
11
|
},
|
|
12
12
|
"description": "VMZ Node toolchain — N-API workspace session + CLI (publish name @vmz/vmz)",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/node": "^22.15.0",
|
|
15
|
-
"@vmz/plugin": "0.3.
|
|
16
|
-
"@vmz/plugin-katex": "0.3.
|
|
17
|
-
"@vmz/plugin-markdown-it": "0.3.
|
|
18
|
-
"@vmz/plugin-shiki": "0.3.
|
|
19
|
-
"@vmz/test": "0.3.
|
|
15
|
+
"@vmz/plugin": "0.3.15",
|
|
16
|
+
"@vmz/plugin-katex": "0.3.15",
|
|
17
|
+
"@vmz/plugin-markdown-it": "0.3.15",
|
|
18
|
+
"@vmz/plugin-shiki": "0.3.15",
|
|
19
|
+
"@vmz/test": "0.3.15",
|
|
20
20
|
"linkedom": "^0.18.13",
|
|
21
21
|
"typescript": "^5.8.3",
|
|
22
|
-
"vmz-plugin-conformance": "0.3.
|
|
22
|
+
"vmz-plugin-conformance": "0.3.15"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=24.12.0"
|
|
@@ -80,16 +80,16 @@
|
|
|
80
80
|
"main": "./dist/index.js",
|
|
81
81
|
"name": "@vmz/vmz",
|
|
82
82
|
"optionalDependencies": {
|
|
83
|
-
"@vmz/vmz-darwin-arm64": "0.3.
|
|
84
|
-
"@vmz/vmz-darwin-x64": "0.3.
|
|
85
|
-
"@vmz/vmz-linux-arm64": "0.3.
|
|
86
|
-
"@vmz/vmz-linux-x64": "0.3.
|
|
87
|
-
"@vmz/vmz-win32-arm64": "0.3.
|
|
88
|
-
"@vmz/vmz-win32-x64": "0.3.
|
|
83
|
+
"@vmz/vmz-darwin-arm64": "0.3.15",
|
|
84
|
+
"@vmz/vmz-darwin-x64": "0.3.15",
|
|
85
|
+
"@vmz/vmz-linux-arm64": "0.3.15",
|
|
86
|
+
"@vmz/vmz-linux-x64": "0.3.15",
|
|
87
|
+
"@vmz/vmz-win32-arm64": "0.3.15",
|
|
88
|
+
"@vmz/vmz-win32-x64": "0.3.15"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
|
-
"@vmz/plugin-markdown-it": "0.3.
|
|
92
|
-
"@vmz/test": "0.3.
|
|
91
|
+
"@vmz/plugin-markdown-it": "0.3.15",
|
|
92
|
+
"@vmz/test": "0.3.15",
|
|
93
93
|
"typescript": "^5.8.3"
|
|
94
94
|
},
|
|
95
95
|
"peerDependenciesMeta": {
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
},
|
|
123
123
|
"type": "module",
|
|
124
124
|
"types": "./dist/index.d.ts",
|
|
125
|
-
"version": "0.3.
|
|
125
|
+
"version": "0.3.15"
|
|
126
126
|
}
|