@quiesco/ui 0.0.0-stage → 0.3.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -2
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +8 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/messages.d.ts +74 -0
  8. package/dist/messages.d.ts.map +1 -0
  9. package/dist/messages.js +2 -0
  10. package/dist/messages.js.map +1 -0
  11. package/dist/server.d.ts +25 -0
  12. package/dist/server.d.ts.map +1 -0
  13. package/dist/server.js +289 -0
  14. package/dist/server.js.map +1 -0
  15. package/dist/spawn.d.ts +13 -0
  16. package/dist/spawn.d.ts.map +1 -0
  17. package/dist/spawn.js +42 -0
  18. package/dist/spawn.js.map +1 -0
  19. package/dist/targets.d.ts +24 -0
  20. package/dist/targets.d.ts.map +1 -0
  21. package/dist/targets.js +37 -0
  22. package/dist/targets.js.map +1 -0
  23. package/dist/web/assets/dm-sans-latin-ext-wght-normal-BOFOeGcA.woff2 +0 -0
  24. package/dist/web/assets/dm-sans-latin-wght-normal-Xz1IZZA0.woff2 +0 -0
  25. package/dist/web/assets/index-Blhnqd4m.css +1 -0
  26. package/dist/web/assets/index-BmpF4iJ3.js +16 -0
  27. package/dist/web/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  28. package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  29. package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  30. package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  31. package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  32. package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  33. package/dist/web/assets/space-grotesk-latin-ext-wght-normal-D9tNdqV9.woff2 +0 -0
  34. package/dist/web/assets/space-grotesk-latin-wght-normal-BhU9QXUp.woff2 +0 -0
  35. package/dist/web/assets/space-grotesk-vietnamese-wght-normal-D0rl6rjA.woff2 +0 -0
  36. package/dist/web/index.html +15 -0
  37. package/package.json +63 -3
  38. package/src/index.ts +11 -0
  39. package/src/messages.ts +44 -0
  40. package/src/server.ts +311 -0
  41. package/src/spawn.ts +52 -0
  42. package/src/targets.ts +47 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Quiesco contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @quiesco/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The test UI behind `quiesco ui`: run tests from the browser and watch them live — the test tree, run all /
4
+ a file / a test with a click, progress per device, failures with Quiesco's evidence (screenshot with the
5
+ asserted element outlined, element tree, idle state, logs), console output and the test's source. In
6
+ English, 简体中文 and 日本語, dark or light.
7
+
8
+ ```sh
9
+ npm i -D @quiesco/ui
10
+ npx quiesco ui --platform web
11
+ ```
12
+
13
+ The CLI loads this package; it is not used directly. Works with cucumber-js, Vitest (add `quiescoPlugin()`
14
+ from `@quiesco/vitest/config`) and Jest (the `@quiesco/jest` preset). Served on 127.0.0.1 only, behind a
15
+ token. Details: [test UI](https://shift-14cc7601.mintlify.site/ui).
16
+
17
+ Part of [Quiesco](https://github.com/h2nology/quiesco): gray-box end-to-end testing for Expo apps on iOS, Android and the web. Setup: `npx quiesco init` ([quick start](https://github.com/h2nology/quiesco#quick-start-web-about-10-minutes)).
18
+
19
+ ## License
20
+
21
+ MIT
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @quiesco/ui: the test UI behind `quiesco ui` — run tests from the browser and watch them live.
3
+ * The CLI loads it; it is not meant to be used directly.
4
+ */
5
+ export { startUiServer } from './server.js';
6
+ export type { UiServer, UiServerOptions } from './server.js';
7
+ export { spawnRun } from './spawn.js';
8
+ export type { RunHandle, SpawnRunOptions } from './spawn.js';
9
+ export { targetArgs } from './targets.js';
10
+ export type { RunTarget } from './targets.js';
11
+ export type { ClientMessage, NoticeCode, RunningInfo, ServerMessage, UiInfo } from './messages.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @quiesco/ui: the test UI behind `quiesco ui` — run tests from the browser and watch them live.
3
+ * The CLI loads it; it is not meant to be used directly.
4
+ */
5
+ export { startUiServer } from './server.js';
6
+ export { spawnRun } from './spawn.js';
7
+ export { targetArgs } from './targets.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Messages between the `quiesco ui` server and the browser, over a WebSocket at `/ws` (JSON, one
3
+ * message per frame). Types only: the web app imports them too.
4
+ */
5
+ import type { RunStateSnapshot } from '@quiesco/core/run-state';
6
+ import type { RunEvent, RunnerName, TestList } from '@quiesco/protocol';
7
+ import type { RunTarget } from './targets.js';
8
+ export type { RunTarget };
9
+ export interface UiInfo {
10
+ /** The project directory's name. */
11
+ project: string;
12
+ runner: RunnerName;
13
+ platform: string;
14
+ /** Version of @quiesco/ui. */
15
+ version: string;
16
+ }
17
+ export type ServerMessage =
18
+ /** First message on a connection, with everything needed to draw the page. */
19
+ {
20
+ type: 'welcome';
21
+ info: UiInfo;
22
+ list: TestList | null;
23
+ listing: boolean;
24
+ state: RunStateSnapshot;
25
+ running: RunningInfo | null;
26
+ output: string;
27
+ }
28
+ /** Listing the tests started (`listing: true`) or finished (with the list). */
29
+ | {
30
+ type: 'list';
31
+ list: TestList | null;
32
+ listing: boolean;
33
+ }
34
+ /** A run event from the runner (apply it to the RunState). */
35
+ | {
36
+ type: 'event';
37
+ event: RunEvent;
38
+ }
39
+ /** A run started (`running` set) or ended (`running: null`, the final state). */
40
+ | {
41
+ type: 'run';
42
+ running: RunningInfo | null;
43
+ exitCode?: number;
44
+ state?: RunStateSnapshot;
45
+ }
46
+ /** The runner's own output (stdout / stderr). */
47
+ | {
48
+ type: 'output';
49
+ stream: 'stdout' | 'stderr';
50
+ text: string;
51
+ }
52
+ /** `code` lets the page show the notice in its language; `message` is the English text. */
53
+ | {
54
+ type: 'notice';
55
+ level: 'info' | 'error';
56
+ code?: NoticeCode;
57
+ message: string;
58
+ };
59
+ export type NoticeCode = 'busy' | 'unknown-tests';
60
+ export interface RunningInfo {
61
+ target: RunTarget;
62
+ /** The runner arguments chosen for the target. */
63
+ args: string[];
64
+ startedAt: number;
65
+ }
66
+ export type ClientMessage = {
67
+ type: 'run';
68
+ target: RunTarget;
69
+ } | {
70
+ type: 'cancel';
71
+ } | {
72
+ type: 'list';
73
+ };
74
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,MAAM,WAAW,MAAM;IACrB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;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EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { RunnerName, TestList } from '@quiesco/protocol';
2
+ import type { RunHandle } from './spawn.js';
3
+ export interface UiServerOptions {
4
+ cwd: string;
5
+ runner: RunnerName;
6
+ platform: string;
7
+ /** Start the runner with `args` added (the target) and `env` added (QUIESCO_EVENTS). */
8
+ startRun(args: string[], env: Record<string, string>, onOutput: (stream: 'stdout' | 'stderr', text: string) => void): RunHandle;
9
+ listTests(): Promise<TestList>;
10
+ /** Absolute path of the artifacts directory (evidence files). */
11
+ artifactsDir: string;
12
+ /** The built web app; null serves a minimal page (tests of the server). */
13
+ staticDir: string | null;
14
+ port?: number;
15
+ host?: string;
16
+ token?: string;
17
+ }
18
+ export interface UiServer {
19
+ readonly url: string;
20
+ readonly port: number;
21
+ readonly token: string;
22
+ close(): Promise<void>;
23
+ }
24
+ export declare function startUiServer(options: UiServerOptions): Promise<UiServer>;
25
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAY,UAAU,EAAE,QAAQ,EAAW,MAAM,mBAAmB,CAAC;AAKjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;IAChI,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAwCD,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiO/E"}
package/dist/server.js ADDED
@@ -0,0 +1,289 @@
1
+ /**
2
+ * The `quiesco ui` server (P5): serves the web app, lists the tests, runs what the browser asks for
3
+ * (one run at a time: one device), and streams the run events to every open page.
4
+ *
5
+ * Local only: it listens on 127.0.0.1, refuses other Host / Origin headers (DNS rebinding) and requires
6
+ * the token from the URL it prints (kept in a cookie after the first page load). Files are served only
7
+ * from the artifacts directory (evidence) and the listed test files (source view).
8
+ */
9
+ import { randomBytes } from 'node:crypto';
10
+ import fs from 'node:fs';
11
+ import http from 'node:http';
12
+ import { createRequire } from 'node:module';
13
+ import path from 'node:path';
14
+ import { RunEventServer, RunState } from '@quiesco/core';
15
+ import { WebSocketServer } from 'ws';
16
+ import { targetArgs } from './targets.js';
17
+ const OUTPUT_KEEP = 200_000;
18
+ const COOKIE = 'quiesco_ui';
19
+ const MIME = {
20
+ '.html': 'text/html; charset=utf-8',
21
+ '.js': 'text/javascript; charset=utf-8',
22
+ '.css': 'text/css; charset=utf-8',
23
+ '.svg': 'image/svg+xml',
24
+ '.woff2': 'font/woff2',
25
+ '.png': 'image/png',
26
+ '.jpg': 'image/jpeg',
27
+ '.jpeg': 'image/jpeg',
28
+ '.webp': 'image/webp',
29
+ '.mp4': 'video/mp4',
30
+ '.webm': 'video/webm',
31
+ '.json': 'application/json; charset=utf-8',
32
+ '.ico': 'image/x-icon',
33
+ };
34
+ /** Evidence and source files: media as such, everything else as plain text (never HTML: no script). */
35
+ function fileType(file) {
36
+ const ext = path.extname(file).toLowerCase();
37
+ return ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.webm', '.json'].includes(ext) ? MIME[ext] : 'text/plain; charset=utf-8';
38
+ }
39
+ function version() {
40
+ return createRequire(import.meta.url)('../package.json').version;
41
+ }
42
+ /** `child` is `root` or inside it, after resolving symlinks. */
43
+ function inside(root, child) {
44
+ try {
45
+ const r = fs.realpathSync(root);
46
+ const c = fs.realpathSync(child);
47
+ return c === r || c.startsWith(r + path.sep);
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ }
53
+ export async function startUiServer(options) {
54
+ const host = options.host ?? '127.0.0.1';
55
+ const token = options.token ?? randomBytes(16).toString('hex');
56
+ const info = { project: path.basename(options.cwd), runner: options.runner, platform: options.platform, version: version() };
57
+ const state = new RunState();
58
+ const clients = new Set();
59
+ let list = null;
60
+ let listing = false;
61
+ let relistQueued = false;
62
+ let running = null;
63
+ let handle = null;
64
+ let output = '';
65
+ let port = 0;
66
+ const send = (ws, m) => {
67
+ if (ws.readyState === ws.OPEN)
68
+ ws.send(JSON.stringify(m));
69
+ };
70
+ const broadcast = (m) => {
71
+ const data = JSON.stringify(m);
72
+ for (const ws of clients)
73
+ if (ws.readyState === ws.OPEN)
74
+ ws.send(data);
75
+ };
76
+ /**
77
+ * Running chosen tests: Vitest and Jest report the other tests of their files as skipped (filtered
78
+ * out). Those reports are dropped, so a test keeps its last real result, and the total is the
79
+ * number of chosen tests.
80
+ */
81
+ let chosen = null;
82
+ const filtered = (event) => {
83
+ if (chosen === null)
84
+ return event;
85
+ if (event.type === 'run:start' || event.type === 'total:update')
86
+ return { ...event, total: chosen.size, totalIsEstimate: false };
87
+ if ((event.type === 'test:start' || event.type === 'test:end') && !chosen.has(event.test.id)) {
88
+ if (event.type === 'test:start' || event.status === 'skipped')
89
+ return null;
90
+ }
91
+ return event;
92
+ };
93
+ const events = new RunEventServer({
94
+ onEvent: (raw) => {
95
+ const event = filtered(raw);
96
+ if (event === null)
97
+ return;
98
+ state.apply(event);
99
+ broadcast({ type: 'event', event });
100
+ },
101
+ });
102
+ await events.listen();
103
+ const knownTests = () => {
104
+ const m = new Map();
105
+ for (const t of list?.tests ?? [])
106
+ m.set(t.id, t);
107
+ for (const t of state.tests.values())
108
+ m.set(t.test.id, { ...m.get(t.test.id), ...t.test });
109
+ return m;
110
+ };
111
+ const relist = async () => {
112
+ if (listing || running !== null) {
113
+ relistQueued = true;
114
+ return;
115
+ }
116
+ listing = true;
117
+ broadcast({ type: 'list', list, listing: true });
118
+ try {
119
+ list = await options.listTests();
120
+ }
121
+ catch (e) {
122
+ list = { runner: options.runner, files: [], tests: [], errors: [{ message: e.message }] };
123
+ }
124
+ listing = false;
125
+ broadcast({ type: 'list', list, listing: false });
126
+ watchFiles();
127
+ };
128
+ const run = (target) => {
129
+ if (running !== null)
130
+ return { code: 'busy', message: 'A run is already in progress (one device: one run at a time).' };
131
+ let args;
132
+ try {
133
+ args = targetArgs(options.runner, target, knownTests());
134
+ }
135
+ catch (e) {
136
+ return { code: 'unknown-tests', message: e.message };
137
+ }
138
+ output = '';
139
+ chosen = target.kind === 'tests' ? new Set(target.ids) : null;
140
+ running = { target, args, startedAt: Date.now() };
141
+ broadcast({ type: 'run', running });
142
+ const h = options.startRun(args, events.env(), (stream, text) => {
143
+ output = (output + text).slice(-OUTPUT_KEEP);
144
+ broadcast({ type: 'output', stream, text });
145
+ });
146
+ handle = h;
147
+ void h.exited.then(async (code) => {
148
+ await events.drain();
149
+ state.runnerExited(code);
150
+ running = null;
151
+ handle = null;
152
+ broadcast({ type: 'run', running: null, exitCode: code, state: state.snapshot() });
153
+ if (relistQueued) {
154
+ relistQueued = false;
155
+ void relist();
156
+ }
157
+ });
158
+ return null;
159
+ };
160
+ // Test files changed: list again (debounced).
161
+ let watchers = [];
162
+ let relistTimer = null;
163
+ function watchFiles() {
164
+ for (const w of watchers)
165
+ w.close();
166
+ watchers = [];
167
+ const dirs = new Set((list?.files ?? []).map((f) => path.dirname(path.resolve(options.cwd, f))));
168
+ for (const dir of dirs) {
169
+ try {
170
+ const w = fs.watch(dir, () => {
171
+ if (relistTimer !== null)
172
+ clearTimeout(relistTimer);
173
+ relistTimer = setTimeout(() => void relist(), 400);
174
+ });
175
+ w.unref();
176
+ watchers.push(w);
177
+ }
178
+ catch {
179
+ // A directory that went away: the next listing drops it.
180
+ }
181
+ }
182
+ }
183
+ const allowedHost = (h) => h !== undefined && [`127.0.0.1:${port}`, `localhost:${port}`, `[::1]:${port}`].includes(h);
184
+ const cookieToken = (req) => /(?:^|;\s*)quiesco_ui=([0-9a-f]+)/.exec(req.headers.cookie ?? '')?.[1];
185
+ const httpServer = http.createServer((req, res) => {
186
+ const url = new URL(req.url ?? '/', `http://${req.headers.host ?? host}`);
187
+ const headers = { 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'no-referrer', 'Cache-Control': 'no-store' };
188
+ if (!allowedHost(req.headers.host)) {
189
+ res.writeHead(403, headers).end('Forbidden host');
190
+ return;
191
+ }
192
+ const queryToken = url.searchParams.get('token');
193
+ const authorized = queryToken === token || cookieToken(req) === token;
194
+ if (!authorized) {
195
+ res.writeHead(401, { ...headers, 'Content-Type': 'text/plain; charset=utf-8' }).end('Open the URL quiesco ui printed (it carries the token).');
196
+ return;
197
+ }
198
+ const setCookie = queryToken === token ? { 'Set-Cookie': `${COOKIE}=${token}; HttpOnly; SameSite=Strict; Path=/` } : {};
199
+ if (url.pathname === '/api/file' || url.pathname === '/api/source') {
200
+ const p = url.searchParams.get('path') ?? '';
201
+ const file = path.resolve(options.cwd, p);
202
+ const ok = url.pathname === '/api/file'
203
+ ? inside(options.artifactsDir, file)
204
+ : (list?.files ?? []).some((f) => path.resolve(options.cwd, f) === file) && inside(options.cwd, file);
205
+ if (!ok || !fs.existsSync(file) || !fs.statSync(file).isFile()) {
206
+ res.writeHead(404, headers).end('Not found');
207
+ return;
208
+ }
209
+ res.writeHead(200, { ...headers, 'Content-Type': fileType(file), 'Content-Security-Policy': "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'" });
210
+ fs.createReadStream(file).pipe(res);
211
+ return;
212
+ }
213
+ const csp = `default-src 'self'; connect-src 'self' ws://${req.headers.host}; img-src 'self' data: blob:; media-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; frame-ancestors 'none'`;
214
+ if (options.staticDir === null) {
215
+ res.writeHead(200, { ...headers, ...setCookie, 'Content-Type': 'text/html; charset=utf-8', 'Content-Security-Policy': csp }).end('<!doctype html><title>Quiesco</title><p>Quiesco UI</p>');
216
+ return;
217
+ }
218
+ const rel = decodeURIComponent(url.pathname).replace(/^\/+/, '');
219
+ let file = path.join(options.staticDir, rel === '' ? 'index.html' : rel);
220
+ if (!inside(options.staticDir, file) || !fs.existsSync(file) || fs.statSync(file).isDirectory())
221
+ file = path.join(options.staticDir, 'index.html');
222
+ const type = MIME[path.extname(file).toLowerCase()] ?? 'application/octet-stream';
223
+ res.writeHead(200, { ...headers, ...setCookie, 'Content-Type': type, 'Content-Security-Policy': csp });
224
+ fs.createReadStream(file).pipe(res);
225
+ });
226
+ const wss = new WebSocketServer({ noServer: true, maxPayload: 64 * 1024 });
227
+ httpServer.on('upgrade', (req, socket, head) => {
228
+ const url = new URL(req.url ?? '/', `http://${req.headers.host ?? host}`);
229
+ const origin = req.headers.origin;
230
+ const originOk = origin === undefined || [`http://127.0.0.1:${port}`, `http://localhost:${port}`, `http://[::1]:${port}`].includes(origin);
231
+ const tokenOk = url.searchParams.get('token') === token || cookieToken(req) === token;
232
+ if (url.pathname !== '/ws' || !allowedHost(req.headers.host) || !originOk || !tokenOk) {
233
+ socket.write('HTTP/1.1 403 Forbidden\r\n\r\n');
234
+ socket.destroy();
235
+ return;
236
+ }
237
+ wss.handleUpgrade(req, socket, head, (ws) => {
238
+ clients.add(ws);
239
+ ws.on('close', () => clients.delete(ws));
240
+ ws.on('message', (data) => {
241
+ let m;
242
+ try {
243
+ m = JSON.parse(String(data));
244
+ }
245
+ catch {
246
+ return;
247
+ }
248
+ if (m.type === 'run') {
249
+ const problem = run(m.target);
250
+ if (problem !== null)
251
+ send(ws, { type: 'notice', level: 'error', ...problem });
252
+ }
253
+ else if (m.type === 'cancel') {
254
+ handle?.stop();
255
+ }
256
+ else if (m.type === 'list') {
257
+ void relist();
258
+ }
259
+ });
260
+ send(ws, { type: 'welcome', info, list, listing, state: state.snapshot(), running, output });
261
+ });
262
+ });
263
+ await new Promise((resolve, reject) => {
264
+ httpServer.once('error', reject);
265
+ httpServer.listen(options.port ?? 0, host, () => resolve());
266
+ });
267
+ port = httpServer.address().port;
268
+ void relist();
269
+ return {
270
+ url: `http://${host === '127.0.0.1' ? '127.0.0.1' : host}:${port}/?token=${token}`,
271
+ port,
272
+ token,
273
+ async close() {
274
+ handle?.stop(2000);
275
+ if (handle !== null)
276
+ await handle.exited;
277
+ for (const w of watchers)
278
+ w.close();
279
+ if (relistTimer !== null)
280
+ clearTimeout(relistTimer);
281
+ for (const ws of clients)
282
+ ws.terminate();
283
+ wss.close();
284
+ await new Promise((resolve) => httpServer.close(() => resolve()));
285
+ await events.close();
286
+ },
287
+ };
288
+ }
289
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings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,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACxE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface RunHandle {
2
+ /** Resolves with the exit code (130 when stopped with SIGINT). */
3
+ readonly exited: Promise<number>;
4
+ /** Ctrl-C to the whole process tree; SIGKILL after `graceMs` if it is still there. */
5
+ stop(graceMs?: number): void;
6
+ }
7
+ export interface SpawnRunOptions {
8
+ cwd: string;
9
+ env: NodeJS.ProcessEnv;
10
+ onOutput: (stream: 'stdout' | 'stderr', text: string) => void;
11
+ }
12
+ export declare function spawnRun(command: string, args: readonly string[], options: SpawnRunOptions): RunHandle;
13
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS;IACxB,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,sFAAsF;IACtF,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAID,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,SAAS,CA8BtG"}
package/dist/spawn.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Start a test run as a child process: its output to a callback, stoppable as a whole (the runner runs
3
+ * under npx, so stopping must reach the runner and its workers, not only npx).
4
+ */
5
+ import { spawn } from 'node:child_process';
6
+ const isWindows = process.platform === 'win32';
7
+ export function spawnRun(command, args, options) {
8
+ // Its own process group (POSIX), so stop() reaches npx, the runner and its workers.
9
+ const child = spawn(command, [...args], { cwd: options.cwd, env: options.env, stdio: ['ignore', 'pipe', 'pipe'], detached: !isWindows, shell: isWindows });
10
+ child.stdout.setEncoding('utf8').on('data', (t) => options.onOutput('stdout', t));
11
+ child.stderr.setEncoding('utf8').on('data', (t) => options.onOutput('stderr', t));
12
+ const exited = new Promise((resolve) => {
13
+ child.on('error', (e) => {
14
+ options.onOutput('stderr', `${e.message}\n`);
15
+ resolve(127);
16
+ });
17
+ child.on('close', (code, signal) => resolve(code ?? (signal === 'SIGINT' ? 130 : signal !== null ? 143 : 1)));
18
+ });
19
+ const signal = (s) => {
20
+ if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null)
21
+ return;
22
+ try {
23
+ if (isWindows)
24
+ spawn('taskkill', ['/pid', String(child.pid), '/T', ...(s === 'SIGKILL' ? ['/F'] : [])]);
25
+ else
26
+ process.kill(-child.pid, s);
27
+ }
28
+ catch {
29
+ // Already gone.
30
+ }
31
+ };
32
+ return {
33
+ exited,
34
+ stop(graceMs = 10_000) {
35
+ signal('SIGINT');
36
+ const timer = setTimeout(() => signal('SIGKILL'), graceMs);
37
+ timer.unref();
38
+ void exited.then(() => clearTimeout(timer));
39
+ },
40
+ };
41
+ }
42
+ //# sourceMappingURL=spawn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAe3C,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAE/C,M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C,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,CAAC,CAAiB,EAAE,EAAE;QACnC,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO;QAC5F,IAAI,CAAC;YACH,IAAI,SAAS;gBAAE,KAAK,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;gBACnG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;IACH,CAAC,CAAC;IACF,OAAO;QACL,MAAM;QACN,IAAI,CAAC,OAAO,GAAG,MAAM;YACnB,MAAM,CAAC,QAAQ,CAAC,CAAC;YACjB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;YAC3D,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What to run, as runner arguments (findings P0): the UI asks for all tests, one file, or some tests;
3
+ * each runner selects them its own way.
4
+ *
5
+ * - cucumber: `file:line[:line…]` (a Scenario line, or an Examples row's line). NOTE: cucumber-js adds
6
+ * command line paths to the `paths` of its config instead of replacing them, so a config with `paths`
7
+ * runs more than asked (Quiesco's init no longer writes `paths`).
8
+ * - vitest: `file:line` (a `test.each` line runs every row).
9
+ * - jest: `--runTestsByPath <files>` and `-t '^(full name|…)$'` (titles joined with spaces; Jest matches
10
+ * case-insensitively, so a test with the same name in another chosen file runs too).
11
+ */
12
+ import type { RunnerName, TestRef } from '@quiesco/protocol';
13
+ export type RunTarget = {
14
+ kind: 'all';
15
+ } | {
16
+ kind: 'file';
17
+ file: string;
18
+ } | {
19
+ kind: 'tests';
20
+ ids: readonly string[];
21
+ };
22
+ /** Runner arguments selecting `target`; `tests` resolves test ids to their file and line. */
23
+ export declare function targetArgs(runner: RunnerName, target: RunTarget, tests: ReadonlyMap<string, TestRef>): string[];
24
+ //# sourceMappingURL=targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAIrH,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CA4B/G"}
@@ -0,0 +1,37 @@
1
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2
+ /** Runner arguments selecting `target`; `tests` resolves test ids to their file and line. */
3
+ export function targetArgs(runner, target, tests) {
4
+ if (target.kind === 'all')
5
+ return [];
6
+ if (target.kind === 'file')
7
+ return runner === 'jest' ? ['--runTestsByPath', target.file] : [target.file];
8
+ const refs = target.ids.flatMap((id) => {
9
+ const t = tests.get(id);
10
+ return t !== undefined ? [t] : [];
11
+ });
12
+ if (refs.length === 0)
13
+ throw new Error('none of the chosen tests is known (list the tests again)');
14
+ const byFile = new Map();
15
+ for (const t of refs)
16
+ byFile.set(t.file, [...(byFile.get(t.file) ?? []), t]);
17
+ if (runner === 'jest') {
18
+ const names = [...new Set(refs.map((t) => escapeRegExp(t.path.join(' '))))];
19
+ return ['--runTestsByPath', ...byFile.keys(), '-t', `^(${names.join('|')})$`];
20
+ }
21
+ const out = [];
22
+ for (const [file, ts] of byFile) {
23
+ const lines = [...new Set(ts.flatMap((t) => (t.line !== undefined ? [t.line] : [])))].sort((a, b) => a - b);
24
+ if (lines.length === 0 || lines.length < ts.length) {
25
+ out.push(file); // a test without a line: the whole file
26
+ }
27
+ else if (runner === 'cucumber') {
28
+ out.push(`${file}:${lines.join(':')}`);
29
+ }
30
+ else {
31
+ for (const l of lines)
32
+ out.push(`${file}:${l}`);
33
+ }
34
+ }
35
+ return out;
36
+ }
37
+ //# sourceMappingURL=targets.js.map