@vmz/test 0.1.10 → 0.1.12
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/browser-serve.js +54 -1
- package/dist/browser.js +7 -2
- package/dist/logic.js +8 -9
- package/dist/resume.js +11 -20
- package/dist/ssr.js +10 -19
- package/package.json +3 -3
package/dist/browser-serve.js
CHANGED
|
@@ -2,9 +2,56 @@
|
|
|
2
2
|
* Browser Host U2 — real VMZ serve-host lifecycle + RouteId → path resolution.
|
|
3
3
|
*/
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
import fs from 'node:fs';
|
|
6
7
|
import net from 'node:net';
|
|
7
8
|
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
/** Same discovery as `vmz serve` / conformance `serveHostChildEnv`. */
|
|
12
|
+
function resolveNativeNodePath() {
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
let triple = `${platform}-${arch}`;
|
|
15
|
+
if (platform === 'win32' && arch === 'x64')
|
|
16
|
+
triple = 'win32-x64-msvc';
|
|
17
|
+
else if (platform === 'win32' && arch === 'arm64')
|
|
18
|
+
triple = 'win32-arm64-msvc';
|
|
19
|
+
else if (platform === 'darwin' && arch === 'arm64')
|
|
20
|
+
triple = 'darwin-arm64';
|
|
21
|
+
else if (platform === 'darwin' && arch === 'x64')
|
|
22
|
+
triple = 'darwin-x64';
|
|
23
|
+
else if (platform === 'linux' && arch === 'x64')
|
|
24
|
+
triple = 'linux-x64-gnu';
|
|
25
|
+
else if (platform === 'linux' && arch === 'arm64')
|
|
26
|
+
triple = 'linux-arm64-gnu';
|
|
27
|
+
const short = triple === 'win32-x64-msvc'
|
|
28
|
+
? 'win32-x64'
|
|
29
|
+
: triple === 'win32-arm64-msvc'
|
|
30
|
+
? 'win32-arm64'
|
|
31
|
+
: triple === 'linux-x64-gnu'
|
|
32
|
+
? 'linux-x64'
|
|
33
|
+
: triple === 'linux-arm64-gnu'
|
|
34
|
+
? 'linux-arm64'
|
|
35
|
+
: triple;
|
|
36
|
+
const name = `@vmz/vmz-${short}`;
|
|
37
|
+
/** @type {string[]} */
|
|
38
|
+
const candidates = [];
|
|
39
|
+
try {
|
|
40
|
+
const pkgJson = require.resolve(`${name}/package.json`);
|
|
41
|
+
const dir = path.dirname(pkgJson);
|
|
42
|
+
candidates.push(path.join(dir, `vmz.${triple}.node`), path.join(dir, 'vmz.node'));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* optional dep missing */
|
|
46
|
+
}
|
|
47
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
48
|
+
candidates.push(path.join(here, '..', '..', '..', 'runtimes', `vmz-${short}`, `vmz.${triple}.node`), path.join(here, '..', '..', '..', 'runtimes', `vmz-${short}`, 'vmz.node'));
|
|
49
|
+
for (const p of candidates) {
|
|
50
|
+
if (fs.existsSync(p))
|
|
51
|
+
return path.resolve(p);
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`serve host: vmz native addon not found for ${name}. Run pnpm napi:build\nLooked in:\n${candidates.map((c) => ` - ${c}`).join('\n')}`);
|
|
54
|
+
}
|
|
8
55
|
function freePort() {
|
|
9
56
|
return new Promise((resolve, reject) => {
|
|
10
57
|
const s = net.createServer();
|
|
@@ -99,7 +146,13 @@ export async function startServeHost(outDir) {
|
|
|
99
146
|
const port = await freePort();
|
|
100
147
|
const child = spawn(process.execPath, [hostJs], {
|
|
101
148
|
cwd: outDir,
|
|
102
|
-
env: {
|
|
149
|
+
env: {
|
|
150
|
+
...process.env,
|
|
151
|
+
VMZ_DIST: outDir,
|
|
152
|
+
VMZ_HOST: '127.0.0.1',
|
|
153
|
+
VMZ_PORT: String(port),
|
|
154
|
+
VMZ_NATIVE_NODE: resolveNativeNodePath(),
|
|
155
|
+
},
|
|
103
156
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
104
157
|
});
|
|
105
158
|
const kill = () => {
|
package/dist/browser.js
CHANGED
|
@@ -305,8 +305,13 @@ export async function runBrowserManifest(manifest, ctx) {
|
|
|
305
305
|
page = await browser.newPage();
|
|
306
306
|
page.setDefaultTimeout(15000);
|
|
307
307
|
page.on('console', (msg) => {
|
|
308
|
-
if (msg.type()
|
|
309
|
-
|
|
308
|
+
if (msg.type() !== 'error')
|
|
309
|
+
return;
|
|
310
|
+
const text = msg.text();
|
|
311
|
+
// Chrome also logs network 404s here; requestfailed gate carries URL + resource-type filters.
|
|
312
|
+
if (/Failed to load resource:.+404/i.test(text))
|
|
313
|
+
return;
|
|
314
|
+
consoleErrors.push(text);
|
|
310
315
|
});
|
|
311
316
|
page.on('pageerror', (err) => {
|
|
312
317
|
consoleErrors.push(err instanceof Error ? err.message : String(err));
|
package/dist/logic.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs from 'node:fs';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
|
-
import {
|
|
8
|
+
import { createRenderHost } from '@vmz/core/render-host';
|
|
9
9
|
import { resolveChunkArtifacts } from './compile.js';
|
|
10
10
|
const require = createRequire(import.meta.url);
|
|
11
11
|
function loadLinkedom() {
|
|
@@ -42,14 +42,13 @@ export async function createLogicHost(opts) {
|
|
|
42
42
|
if (!Component?.__vmzDirect || typeof Component.__vmzCreate !== 'function') {
|
|
43
43
|
throw new Error('logic host requires Direct __vmzCreate (rebuild with current compiler)');
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
45
|
+
const strict = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
|
|
46
|
+
const renderHost = await createRenderHost(opts.outDir, {
|
|
47
|
+
strictDeployment: strict,
|
|
48
|
+
preload: 'none',
|
|
49
|
+
explicit: opts.components,
|
|
50
|
+
});
|
|
51
|
+
await renderHost.ensureComponents([opts.chunkId.replace(/\\/g, '/')]);
|
|
53
52
|
if (typeof dom.__vmzPrecisionEnable === 'function') {
|
|
54
53
|
dom.__vmzPrecisionEnable(true);
|
|
55
54
|
}
|
package/dist/resume.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Resume host for `vmz test --mode resume` (/ first slice).
|
|
3
3
|
* SSR shell → resume adopt → event patch; onMount must not run.
|
|
4
4
|
*/
|
|
5
|
-
import path from 'node:path';
|
|
6
5
|
import { pathToFileURL } from 'node:url';
|
|
7
|
-
import {
|
|
6
|
+
import { createRenderHost } from '@vmz/core/render-host';
|
|
8
7
|
import { resolveChunkArtifacts } from './compile.js';
|
|
9
8
|
import { installHeadlessDocument } from './logic.js';
|
|
10
9
|
export async function runResumeManifest(manifest, ctx) {
|
|
@@ -26,32 +25,24 @@ export async function runResumeManifest(manifest, ctx) {
|
|
|
26
25
|
}
|
|
27
26
|
installHeadlessDocument();
|
|
28
27
|
globalThis.requestIdleCallback = (cb) => setTimeout(() => cb({ didTimeout: false, timeRemaining: () => 1 }), 0);
|
|
29
|
-
|
|
28
|
+
const components = program.components && typeof program.components === 'object' ? program.components : undefined;
|
|
29
|
+
let renderHost;
|
|
30
30
|
let Page;
|
|
31
|
+
let loaded = {};
|
|
31
32
|
try {
|
|
32
|
-
|
|
33
|
+
renderHost = await createRenderHost(ctx.outDir, {
|
|
34
|
+
strictDeployment: process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true',
|
|
35
|
+
preload: 'none',
|
|
36
|
+
explicit: components,
|
|
37
|
+
});
|
|
38
|
+
loaded = await renderHost.ensureComponents([chunkId.replace(/\\/g, '/')]);
|
|
33
39
|
Page = (await import(pathToFileURL(arts.clientPath).href)).default;
|
|
34
40
|
}
|
|
35
41
|
catch (e) {
|
|
36
42
|
fail(`import dist: ${e instanceof Error ? e.message : String(e)}`);
|
|
37
43
|
return { status: 'error', diagnostics, planId: null, programId };
|
|
38
44
|
}
|
|
39
|
-
const
|
|
40
|
-
const loaded = {};
|
|
41
|
-
if (typeof dom.registerComponents === 'function') {
|
|
42
|
-
try {
|
|
43
|
-
Object.assign(loaded, await bootstrapComponentRegistry(ctx.outDir, dom.registerComponents, {
|
|
44
|
-
strict: process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true',
|
|
45
|
-
closureRoots: [chunkId.replace(/\\/g, '/')],
|
|
46
|
-
explicit: components,
|
|
47
|
-
preload: 'closure',
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
fail(`bootstrap component registry: ${e instanceof Error ? e.message : String(e)}`);
|
|
52
|
-
return { status: 'error', diagnostics, planId: null, programId };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
45
|
+
const dom = renderHost.dom;
|
|
55
46
|
let html = '';
|
|
56
47
|
let island = null;
|
|
57
48
|
let inst = null;
|
package/dist/ssr.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* SSR / hydrate / stream host for `vmz test --mode ssr` .
|
|
3
3
|
* Same Direct schedule as production via linkedom + renderToString / renderToStream / hydrate.
|
|
4
4
|
*/
|
|
5
|
-
import path from 'node:path';
|
|
6
5
|
import { pathToFileURL } from 'node:url';
|
|
7
|
-
import {
|
|
6
|
+
import { createRenderHost } from '@vmz/core/render-host';
|
|
8
7
|
import { resolveChunkArtifacts } from './compile.js';
|
|
9
8
|
import { installHeadlessDocument } from './logic.js';
|
|
10
9
|
export async function runSsrManifest(manifest, ctx) {
|
|
@@ -25,31 +24,23 @@ export async function runSsrManifest(manifest, ctx) {
|
|
|
25
24
|
return { status: 'failed', diagnostics, planId: null, programId };
|
|
26
25
|
}
|
|
27
26
|
installHeadlessDocument();
|
|
28
|
-
|
|
27
|
+
const components = program.components && typeof program.components === 'object' ? program.components : undefined;
|
|
28
|
+
let renderHost;
|
|
29
29
|
let Component;
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
renderHost = await createRenderHost(ctx.outDir, {
|
|
32
|
+
strictDeployment: process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true',
|
|
33
|
+
preload: 'none',
|
|
34
|
+
explicit: components,
|
|
35
|
+
});
|
|
36
|
+
await renderHost.ensureComponents([chunkId.replace(/\\/g, '/')]);
|
|
32
37
|
Component = (await import(pathToFileURL(arts.clientPath).href)).default;
|
|
33
38
|
}
|
|
34
39
|
catch (e) {
|
|
35
40
|
fail(`import dist: ${e instanceof Error ? e.message : String(e)}`);
|
|
36
41
|
return { status: 'error', diagnostics, planId: null, programId };
|
|
37
42
|
}
|
|
38
|
-
const
|
|
39
|
-
if (typeof dom.registerComponents === 'function') {
|
|
40
|
-
try {
|
|
41
|
-
await bootstrapComponentRegistry(ctx.outDir, dom.registerComponents, {
|
|
42
|
-
strict: process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true',
|
|
43
|
-
closureRoots: [chunkId.replace(/\\/g, '/')],
|
|
44
|
-
explicit: components,
|
|
45
|
-
preload: 'closure',
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
fail(`bootstrap component registry: ${e instanceof Error ? e.message : String(e)}`);
|
|
50
|
-
return { status: 'error', diagnostics, planId: null, programId };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
43
|
+
const dom = renderHost.dom;
|
|
53
44
|
let html = '';
|
|
54
45
|
let streamChunks = [];
|
|
55
46
|
let streamAborted = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vmz/test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VMZ native test protocol + Compile/Logic/Browser/SSR/Resume/Deployment hosts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"build": "tsc -p tsconfig.json"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@vmz/core": "0.1.
|
|
31
|
-
"@vmz/protocol": "0.1.
|
|
30
|
+
"@vmz/core": "0.1.12",
|
|
31
|
+
"@vmz/protocol": "0.1.12",
|
|
32
32
|
"linkedom": "^0.18.13",
|
|
33
33
|
"puppeteer-core": "^24.11.2"
|
|
34
34
|
},
|