vouchington-tooling 0.53.0 → 0.54.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.
- package/README.md +76 -12
- package/dist/agent-blackboard/index.d.mts +0 -1
- package/dist/agent-blackboard/index.mjs +0 -23
- package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
- package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
- package/dist/cli/commands/agent-blackboard.d.mts +0 -2
- package/dist/cli/commands/agent-blackboard.mjs +7 -121
- package/dist/cli/commands/story-coverage.d.mts +2 -0
- package/dist/cli/commands/story-coverage.mjs +56 -0
- package/dist/cli/index.mjs +6 -0
- package/dist/cli/parse-forwarded-commands.d.mts +3 -0
- package/dist/cli/parse-forwarded-commands.mjs +2 -0
- package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
- package/dist/cli/parse-story-coverage-fields.mjs +69 -0
- package/dist/cli/parse-story-coverage.d.mts +8 -0
- package/dist/cli/parse-story-coverage.mjs +34 -0
- package/dist/cli/parse.d.mts +5 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +8 -7
- package/dist/host-storage/check.d.mts +38 -0
- package/dist/host-storage/check.mjs +109 -0
- package/dist/host-storage/cli.d.mts +7 -0
- package/dist/host-storage/cli.mjs +102 -0
- package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
- package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
- package/dist/host-storage/index.d.mts +3 -0
- package/dist/host-storage/index.mjs +3 -0
- package/dist/host-storage/preflight.d.mts +22 -0
- package/dist/host-storage/preflight.mjs +105 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/playwright/assertions.d.mts +1 -0
- package/dist/playwright/assertions.mjs +5 -0
- package/dist/playwright/blocked-external-network.d.mts +15 -0
- package/dist/playwright/blocked-external-network.mjs +73 -0
- package/dist/playwright/browser-dialog-issues.d.mts +12 -0
- package/dist/playwright/browser-dialog-issues.mjs +29 -0
- package/dist/playwright/browser-errors.d.mts +22 -0
- package/dist/playwright/browser-errors.mjs +130 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
- package/dist/playwright/browser-issue-records.d.mts +42 -0
- package/dist/playwright/browser-issue-records.mjs +148 -0
- package/dist/playwright/browser-test.d.mts +21 -0
- package/dist/playwright/browser-test.mjs +68 -0
- package/dist/playwright/expect-no-broken-images.d.mts +17 -0
- package/dist/playwright/expect-no-broken-images.mjs +39 -0
- package/dist/playwright/index.d.mts +30 -0
- package/dist/playwright/index.mjs +22 -0
- package/dist/playwright/mobile-assertions.d.mts +14 -0
- package/dist/playwright/mobile-assertions.mjs +43 -0
- package/dist/playwright/navigate-to.d.mts +27 -0
- package/dist/playwright/navigate-to.mjs +39 -0
- package/dist/playwright/radix-select.d.mts +18 -0
- package/dist/playwright/radix-select.mjs +19 -0
- package/dist/playwright/random-id.d.mts +34 -0
- package/dist/playwright/random-id.mjs +37 -0
- package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
- package/dist/playwright/retry-on-connection-lost.mjs +107 -0
- package/dist/playwright/scroll-to-load-more.d.mts +37 -0
- package/dist/playwright/scroll-to-load-more.mjs +158 -0
- package/dist/playwright/storybook.d.mts +2 -0
- package/dist/playwright/storybook.mjs +13 -0
- package/dist/playwright/test-fixtures.d.mts +1 -0
- package/dist/playwright/test-fixtures.mjs +2 -0
- package/dist/playwright/test-lifecycle-reporter.d.mts +11 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +35 -0
- package/dist/playwright/totp.d.mts +6 -0
- package/dist/playwright/totp.mjs +37 -0
- package/dist/playwright/turnstile-stub.d.mts +8 -0
- package/dist/playwright/turnstile-stub.mjs +61 -0
- package/dist/playwright/viewport-constants.d.mts +30 -0
- package/dist/playwright/viewport-constants.mjs +9 -0
- package/dist/playwright/virtual-authenticator.d.mts +5 -0
- package/dist/playwright/virtual-authenticator.mjs +15 -0
- package/dist/playwright/wait-for-hydration.d.mts +29 -0
- package/dist/playwright/wait-for-hydration.mjs +81 -0
- package/dist/shell-parse/ansi-c-string.d.mts +12 -0
- package/dist/shell-parse/ansi-c-string.mjs +80 -0
- package/dist/shell-parse/index.d.mts +20 -0
- package/dist/shell-parse/index.mjs +15 -0
- package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
- package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
- package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
- package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
- package/dist/shell-parse/shell-commands.d.mts +24 -0
- package/dist/shell-parse/shell-commands.mjs +155 -0
- package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
- package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
- package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
- package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
- package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
- package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
- package/dist/shell-parse/shell-heredoc.d.mts +10 -0
- package/dist/shell-parse/shell-heredoc.mjs +90 -0
- package/dist/shell-parse/shell-redirections.d.mts +5 -0
- package/dist/shell-parse/shell-redirections.mjs +34 -0
- package/dist/shell-parse/shell-script-operand.d.mts +13 -0
- package/dist/shell-parse/shell-script-operand.mjs +103 -0
- package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
- package/dist/shell-parse/shell-stdin-script.mjs +61 -0
- package/dist/shell-parse/shell-token-utils.d.mts +9 -0
- package/dist/shell-parse/shell-token-utils.mjs +33 -0
- package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
- package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
- package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
- package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
- package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
- package/dist/shell-parse/shell-tokenizer.mjs +104 -0
- package/dist/story-coverage/analyze.d.mts +8 -0
- package/dist/story-coverage/analyze.mjs +24 -0
- package/dist/story-coverage/check.d.mts +11 -0
- package/dist/story-coverage/check.mjs +42 -0
- package/dist/story-coverage/components.d.mts +10 -0
- package/dist/story-coverage/components.mjs +40 -0
- package/dist/story-coverage/coverage.d.mts +10 -0
- package/dist/story-coverage/coverage.mjs +43 -0
- package/dist/story-coverage/index.d.mts +13 -0
- package/dist/story-coverage/index.mjs +7 -0
- package/dist/story-coverage/messages.d.mts +10 -0
- package/dist/story-coverage/messages.mjs +42 -0
- package/dist/story-coverage/options.d.mts +27 -0
- package/dist/story-coverage/options.mjs +51 -0
- package/dist/story-coverage/workspace.d.mts +2 -0
- package/dist/story-coverage/workspace.mjs +27 -0
- package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
- package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
- package/dist/vitest-diagnostics/index.d.mts +9 -1
- package/dist/vitest-diagnostics/index.mjs +5 -1
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +10 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +43 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +50 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +69 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
- package/dist/vitest-diagnostics/vitest-process-resources.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +51 -0
- package/dist/vitest-effective-timeout/cap.d.mts +9 -0
- package/dist/vitest-effective-timeout/cap.mjs +28 -0
- package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
- package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
- package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
- package/dist/vitest-effective-timeout/config-file.mjs +23 -0
- package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
- package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
- package/dist/vitest-effective-timeout/index.d.mts +7 -0
- package/dist/vitest-effective-timeout/index.mjs +4 -0
- package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
- package/dist/vitest-effective-timeout/profiles.mjs +33 -0
- package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
- package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
- package/docs/mcp-server.md +2 -13
- package/package.json +32 -2
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/chromium-launch-probe.d.mts +7 -0
- package/scripts/chromium-launch-probe.mjs +101 -0
- package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
- package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
- package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
- package/scripts/run-bounded.py +199 -0
- package/scripts/run_bounded_process.py +129 -0
- package/scripts/worktree/git-index-lock.sh +16 -0
- package/scripts/worktree/git-worktrees.sh +23 -20
- package/scripts/worktree/reset-worktree-run.sh +199 -0
- package/scripts/worktree/reset-worktree.sh +122 -0
- package/skills/blackboard/SKILL.md +4 -64
- package/skills/stacked-prs/SKILL.md +1 -1
- package/skills/stacked-prs/references/drain.md +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export async function storybookBundleHasStory(page, id) {
|
|
2
|
+
let response;
|
|
3
|
+
try {
|
|
4
|
+
response = await page.request.get('/storybook/index.json', { timeout: 5000 });
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (!response.ok())
|
|
10
|
+
return false;
|
|
11
|
+
const storyIndex = (await response.json());
|
|
12
|
+
return id in (storyIndex.entries ?? {});
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TEST_PNG: Buffer<ArrayBuffer>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FullConfig, Reporter, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
export default class TestLifecycleReporter implements Reporter {
|
|
3
|
+
static readonly modulePath: string;
|
|
4
|
+
private rootDir;
|
|
5
|
+
private shard;
|
|
6
|
+
onBegin(config: FullConfig): void;
|
|
7
|
+
onTestBegin(test: TestCase, result: TestResult): void;
|
|
8
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
9
|
+
printsToStdio(): boolean;
|
|
10
|
+
private record;
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
export default class TestLifecycleReporter {
|
|
3
|
+
static modulePath = import.meta.filename;
|
|
4
|
+
rootDir = '';
|
|
5
|
+
shard = null;
|
|
6
|
+
onBegin(config) {
|
|
7
|
+
this.rootDir = config.rootDir;
|
|
8
|
+
this.shard = config.shard;
|
|
9
|
+
}
|
|
10
|
+
onTestBegin(test, result) {
|
|
11
|
+
this.record('begin', test, result);
|
|
12
|
+
}
|
|
13
|
+
onTestEnd(test, result) {
|
|
14
|
+
this.record('end', test, result);
|
|
15
|
+
}
|
|
16
|
+
printsToStdio() {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
record(event, test, result) {
|
|
20
|
+
process.stdout.write(`${JSON.stringify({
|
|
21
|
+
marker: 'playwright-test-lifecycle',
|
|
22
|
+
event,
|
|
23
|
+
observedAt: new Date().toISOString(),
|
|
24
|
+
testId: test.id,
|
|
25
|
+
file: relative(this.rootDir, test.location.file),
|
|
26
|
+
line: test.location.line,
|
|
27
|
+
project: test.parent.project()?.name,
|
|
28
|
+
shard: this.shard,
|
|
29
|
+
retry: result.retry,
|
|
30
|
+
workerIndex: result.workerIndex,
|
|
31
|
+
parallelIndex: result.parallelIndex,
|
|
32
|
+
...(event === 'end' ? { status: result.status, durationMs: result.duration } : {}),
|
|
33
|
+
})}\n`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a TOTP code using WebCrypto in the browser context.
|
|
4
|
+
* Uses SHA-1 HMAC with 6-digit output and 30-second period (RFC 6238).
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateTotpCode(page: Page, base32Secret: string): Promise<string>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a TOTP code using WebCrypto in the browser context.
|
|
3
|
+
* Uses SHA-1 HMAC with 6-digit output and 30-second period (RFC 6238).
|
|
4
|
+
*/
|
|
5
|
+
export function generateTotpCode(page, base32Secret) {
|
|
6
|
+
return page.evaluate(async (secret) => {
|
|
7
|
+
const BASE32 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
8
|
+
const BASE32_MAP = new Map(Array.from(BASE32).map((ch, i) => [ch, i]));
|
|
9
|
+
const upper = secret.toUpperCase().replace(/=+$/, '').replace(/\s/g, '');
|
|
10
|
+
let bits = '';
|
|
11
|
+
for (const c of upper) {
|
|
12
|
+
const idx = BASE32_MAP.get(c);
|
|
13
|
+
if (idx !== undefined)
|
|
14
|
+
bits += idx.toString(2).padStart(5, '0');
|
|
15
|
+
}
|
|
16
|
+
const bytes = [];
|
|
17
|
+
for (let i = 0; i + 8 <= bits.length; i += 8) {
|
|
18
|
+
bytes.push(parseInt(bits.slice(i, i + 8), 2));
|
|
19
|
+
}
|
|
20
|
+
const counter = Math.floor(Date.now() / 1000 / 30);
|
|
21
|
+
const counterBytes = new Uint8Array(8);
|
|
22
|
+
let rem = counter;
|
|
23
|
+
for (let i = 7; i >= 0; i--) {
|
|
24
|
+
counterBytes[i] = rem & 0xff;
|
|
25
|
+
rem = Math.floor(rem / 256);
|
|
26
|
+
}
|
|
27
|
+
const key = await crypto.subtle.importKey('raw', new Uint8Array(bytes), { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']);
|
|
28
|
+
const sig = new Uint8Array(await crypto.subtle.sign('HMAC', key, counterBytes));
|
|
29
|
+
const offset = sig[19] & 0x0f;
|
|
30
|
+
const code = (((sig[offset] & 0x7f) << 24) |
|
|
31
|
+
((sig[offset + 1] & 0xff) << 16) |
|
|
32
|
+
((sig[offset + 2] & 0xff) << 8) |
|
|
33
|
+
(sig[offset + 3] & 0xff)) %
|
|
34
|
+
1_000_000;
|
|
35
|
+
return String(code).padStart(6, '0');
|
|
36
|
+
}, base32Secret);
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
export declare const DEFAULT_TURNSTILE_STUB_TOKEN = "PLAYWRIGHT_TURNSTILE_TOKEN";
|
|
3
|
+
export declare const DEFAULT_TURNSTILE_STUB_ATTRIBUTE = "data-pw";
|
|
4
|
+
export interface TurnstileStubOptions {
|
|
5
|
+
attributeName?: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function installTurnstileStub(page: Page, options?: TurnstileStubOptions): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fulfill the Cloudflare Turnstile script with a synthetic `window.turnstile`
|
|
3
|
+
* that resolves the widget synchronously. Background traffic from the real
|
|
4
|
+
* script can keep `networkidle` from settling. The synthetic widget implements
|
|
5
|
+
* render, reset, remove, and getResponse. Callers that reject the token on
|
|
6
|
+
* the server should mock that request.
|
|
7
|
+
*/
|
|
8
|
+
const TURNSTILE_API_PATTERN = '**/turnstile/v0/api.js**';
|
|
9
|
+
export const DEFAULT_TURNSTILE_STUB_TOKEN = 'PLAYWRIGHT_TURNSTILE_TOKEN';
|
|
10
|
+
export const DEFAULT_TURNSTILE_STUB_ATTRIBUTE = 'data-pw';
|
|
11
|
+
function renderTurnstileStubScript(token, attributeName) {
|
|
12
|
+
return `
|
|
13
|
+
;(function () {
|
|
14
|
+
if (window.turnstile) return
|
|
15
|
+
var fakeToken = ${JSON.stringify(token)}
|
|
16
|
+
var handlers = new Map()
|
|
17
|
+
window.turnstile = {
|
|
18
|
+
render: function (container, params) {
|
|
19
|
+
var id = 'pw-' + Math.random().toString(36).slice(2)
|
|
20
|
+
if (typeof container === 'string') container = document.querySelector(container)
|
|
21
|
+
if (!container) throw new Error('Turnstile container not found')
|
|
22
|
+
container.replaceChildren()
|
|
23
|
+
var widget = document.createElement('div')
|
|
24
|
+
widget.setAttribute('role', 'group')
|
|
25
|
+
widget.setAttribute('aria-label', 'Cloudflare Turnstile verification')
|
|
26
|
+
widget.setAttribute(${JSON.stringify(attributeName)}, 'turnstile-widget')
|
|
27
|
+
widget.textContent = 'Cloudflare Turnstile verification'
|
|
28
|
+
container.appendChild(widget)
|
|
29
|
+
handlers.set(id, params)
|
|
30
|
+
queueMicrotask(function () {
|
|
31
|
+
try { params && params.callback && params.callback(fakeToken) } catch (_) {}
|
|
32
|
+
})
|
|
33
|
+
return id
|
|
34
|
+
},
|
|
35
|
+
reset: function (id) {
|
|
36
|
+
var params = handlers.get(id)
|
|
37
|
+
if (!params) return
|
|
38
|
+
queueMicrotask(function () {
|
|
39
|
+
try { params.callback && params.callback(fakeToken) } catch (_) {}
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
remove: function (id) { handlers.delete(id) },
|
|
43
|
+
getResponse: function () { return fakeToken },
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
const stubbedPages = new WeakSet();
|
|
49
|
+
export async function installTurnstileStub(page, options = {}) {
|
|
50
|
+
if (stubbedPages.has(page))
|
|
51
|
+
return;
|
|
52
|
+
const token = options.token ?? DEFAULT_TURNSTILE_STUB_TOKEN;
|
|
53
|
+
const attributeName = options.attributeName ?? DEFAULT_TURNSTILE_STUB_ATTRIBUTE;
|
|
54
|
+
const body = renderTurnstileStubScript(token, attributeName);
|
|
55
|
+
await page.route(TURNSTILE_API_PATTERN, (route) => route.fulfill({
|
|
56
|
+
status: 200,
|
|
57
|
+
contentType: 'application/javascript',
|
|
58
|
+
body,
|
|
59
|
+
}));
|
|
60
|
+
stubbedPages.add(page);
|
|
61
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const MOBILE_VIEWPORTS: {
|
|
2
|
+
readonly 'iphone-se': {
|
|
3
|
+
readonly width: 375;
|
|
4
|
+
readonly height: 667;
|
|
5
|
+
};
|
|
6
|
+
readonly 'iphone-14-pro': {
|
|
7
|
+
readonly width: 393;
|
|
8
|
+
readonly height: 852;
|
|
9
|
+
};
|
|
10
|
+
readonly 'pixel-7': {
|
|
11
|
+
readonly width: 412;
|
|
12
|
+
readonly height: 915;
|
|
13
|
+
};
|
|
14
|
+
readonly 'iphone-14-plus': {
|
|
15
|
+
readonly width: 428;
|
|
16
|
+
readonly height: 926;
|
|
17
|
+
};
|
|
18
|
+
readonly 'galaxy-s21': {
|
|
19
|
+
readonly width: 360;
|
|
20
|
+
readonly height: 800;
|
|
21
|
+
};
|
|
22
|
+
readonly smallest: {
|
|
23
|
+
readonly width: 320;
|
|
24
|
+
readonly height: 568;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const DESKTOP_VIEWPORT: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const MOBILE_VIEWPORTS = {
|
|
2
|
+
'iphone-se': { width: 375, height: 667 },
|
|
3
|
+
'iphone-14-pro': { width: 393, height: 852 },
|
|
4
|
+
'pixel-7': { width: 412, height: 915 },
|
|
5
|
+
'iphone-14-plus': { width: 428, height: 926 },
|
|
6
|
+
'galaxy-s21': { width: 360, height: 800 },
|
|
7
|
+
smallest: { width: 320, height: 568 },
|
|
8
|
+
};
|
|
9
|
+
export const DESKTOP_VIEWPORT = { width: 1280, height: 720 };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function setupVirtualAuthenticator(page) {
|
|
2
|
+
const client = await page.context().newCDPSession(page);
|
|
3
|
+
await client.send('WebAuthn.enable', { enableUI: false });
|
|
4
|
+
const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', {
|
|
5
|
+
options: {
|
|
6
|
+
protocol: 'ctap2',
|
|
7
|
+
transport: 'internal',
|
|
8
|
+
hasResidentKey: true,
|
|
9
|
+
hasUserVerification: true,
|
|
10
|
+
isUserVerified: true,
|
|
11
|
+
automaticPresenceSimulation: true,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
return { client, authenticatorId };
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Wait for React hydration of below-fold streaming components.
|
|
4
|
+
*
|
|
5
|
+
* React 19 prioritises above-fold hydration; components scrolled out of
|
|
6
|
+
* view receive lower-priority MessageChannel callbacks. The idle/animation
|
|
7
|
+
* probe is a bounded readiness heuristic, not proof that every client handler
|
|
8
|
+
* is attached. A control that cannot accept an early interaction must expose
|
|
9
|
+
* its own disabled-until-hydrated state; tests then wait for that state.
|
|
10
|
+
*
|
|
11
|
+
* Use this when navigateTo() alone is insufficient because the element you
|
|
12
|
+
* need to interact with lives inside a below-fold streaming boundary. Prefer
|
|
13
|
+
* scrolling the element into view first (element.scrollIntoViewIfNeeded())
|
|
14
|
+
* so React has a chance to bump its hydration priority before you call this.
|
|
15
|
+
*
|
|
16
|
+
* Tolerates a client-side redirect arriving mid-wait: the document the
|
|
17
|
+
* readiness probe started in can be replaced before the probe resolves, which
|
|
18
|
+
* destroys its execution context. Rather than failing, the wait restarts
|
|
19
|
+
* against the document that replaced it, so hydration is always measured
|
|
20
|
+
* against the document the caller ends up on. `waitUntil` is the load state to
|
|
21
|
+
* settle that replacement document to; callers that navigated under a stricter
|
|
22
|
+
* state should pass their own so a redirect does not silently weaken it.
|
|
23
|
+
*
|
|
24
|
+
* If you find yourself calling this frequently, consider fixing navigate-to.mts
|
|
25
|
+
* to use a more deterministic hydration signal instead.
|
|
26
|
+
*/
|
|
27
|
+
export declare function waitForBelowFoldHydration(page: Page, { waitUntil }?: {
|
|
28
|
+
waitUntil?: "load" | "networkidle" | undefined;
|
|
29
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Playwright rejects an in-flight page.evaluate() with this message when a
|
|
2
|
+
// navigation replaces the document that evaluate was running in.
|
|
3
|
+
const DESTROYED_EXECUTION_CONTEXT_PATTERN = /Execution context was destroyed/i;
|
|
4
|
+
// A redirect chain can replace the document more than once, so re-waiting is
|
|
5
|
+
// bounded: a redirect loop has to fail the test rather than hang it.
|
|
6
|
+
const MAX_DOCUMENT_REPLACEMENTS = 2;
|
|
7
|
+
function isDestroyedExecutionContextError(error) {
|
|
8
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9
|
+
return DESTROYED_EXECUTION_CONTEXT_PATTERN.test(message);
|
|
10
|
+
}
|
|
11
|
+
function evaluateHydrationSettled(page) {
|
|
12
|
+
return page.evaluate(() => new Promise((resolve) => {
|
|
13
|
+
const requestIdleCallbackMaybe = globalThis.window.requestIdleCallback;
|
|
14
|
+
if (requestIdleCallbackMaybe) {
|
|
15
|
+
requestIdleCallbackMaybe(() => resolve(), { timeout: 500 });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// When requestIdleCallback is unavailable, wait for two animation
|
|
19
|
+
// frames so React has had paint cycles to hydrate below-fold
|
|
20
|
+
// components. Race double-RAF against a short timeout so
|
|
21
|
+
// throttled/hidden tabs cannot hang indefinitely; the timeout is a
|
|
22
|
+
// completion bound, not the primary readiness signal.
|
|
23
|
+
let timeoutId;
|
|
24
|
+
let isResolved = false;
|
|
25
|
+
const resolveOnce = () => {
|
|
26
|
+
if (isResolved)
|
|
27
|
+
return;
|
|
28
|
+
isResolved = true;
|
|
29
|
+
if (timeoutId !== undefined) {
|
|
30
|
+
clearTimeout(timeoutId);
|
|
31
|
+
}
|
|
32
|
+
// `isResolved` makes the RAF/timeout race first-winner-only
|
|
33
|
+
resolve();
|
|
34
|
+
};
|
|
35
|
+
const requestFrame = globalThis.requestAnimationFrame;
|
|
36
|
+
requestFrame(() => requestFrame(resolveOnce));
|
|
37
|
+
timeoutId = setTimeout(resolveOnce, 50);
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async function waitForHydrationSettled(page, waitUntil, remainingReplacements) {
|
|
41
|
+
try {
|
|
42
|
+
await evaluateHydrationSettled(page);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (!isDestroyedExecutionContextError(err) || remainingReplacements <= 0)
|
|
46
|
+
throw err;
|
|
47
|
+
// A client-side redirect landed after the first document had already gone
|
|
48
|
+
// quiet, destroying the context this evaluate was waiting in. Wait for the
|
|
49
|
+
// document that replaced it, then measure hydration against that one.
|
|
50
|
+
await page.waitForLoadState(waitUntil);
|
|
51
|
+
await waitForHydrationSettled(page, waitUntil, remainingReplacements - 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Wait for React hydration of below-fold streaming components.
|
|
56
|
+
*
|
|
57
|
+
* React 19 prioritises above-fold hydration; components scrolled out of
|
|
58
|
+
* view receive lower-priority MessageChannel callbacks. The idle/animation
|
|
59
|
+
* probe is a bounded readiness heuristic, not proof that every client handler
|
|
60
|
+
* is attached. A control that cannot accept an early interaction must expose
|
|
61
|
+
* its own disabled-until-hydrated state; tests then wait for that state.
|
|
62
|
+
*
|
|
63
|
+
* Use this when navigateTo() alone is insufficient because the element you
|
|
64
|
+
* need to interact with lives inside a below-fold streaming boundary. Prefer
|
|
65
|
+
* scrolling the element into view first (element.scrollIntoViewIfNeeded())
|
|
66
|
+
* so React has a chance to bump its hydration priority before you call this.
|
|
67
|
+
*
|
|
68
|
+
* Tolerates a client-side redirect arriving mid-wait: the document the
|
|
69
|
+
* readiness probe started in can be replaced before the probe resolves, which
|
|
70
|
+
* destroys its execution context. Rather than failing, the wait restarts
|
|
71
|
+
* against the document that replaced it, so hydration is always measured
|
|
72
|
+
* against the document the caller ends up on. `waitUntil` is the load state to
|
|
73
|
+
* settle that replacement document to; callers that navigated under a stricter
|
|
74
|
+
* state should pass their own so a redirect does not silently weaken it.
|
|
75
|
+
*
|
|
76
|
+
* If you find yourself calling this frequently, consider fixing navigate-to.mts
|
|
77
|
+
* to use a more deterministic hydration signal instead.
|
|
78
|
+
*/
|
|
79
|
+
export async function waitForBelowFoldHydration(page, { waitUntil = 'load' } = {}) {
|
|
80
|
+
await waitForHydrationSettled(page, waitUntil, MAX_DOCUMENT_REPLACEMENTS);
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function readAnsiCString(command: string, startIndex: number): {
|
|
2
|
+
value: string;
|
|
3
|
+
endIndex: number;
|
|
4
|
+
} | null;
|
|
5
|
+
export declare function decodeAnsiCStringEscape(command: string, escapeIndex: number): {
|
|
6
|
+
value: string;
|
|
7
|
+
endIndex: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function decodeNumericAnsiEscape(command: string, startIndex: number, maxLength: number, radix: 8 | 16, fallbackPrefix: string): {
|
|
10
|
+
value: string;
|
|
11
|
+
endIndex: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export function readAnsiCString(command, startIndex) {
|
|
2
|
+
let value = '';
|
|
3
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
4
|
+
const char = command[index];
|
|
5
|
+
if (char === "'") {
|
|
6
|
+
return { value, endIndex: index };
|
|
7
|
+
}
|
|
8
|
+
if (char !== '\\') {
|
|
9
|
+
value += char;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (index === command.length - 1) {
|
|
13
|
+
value += '\\';
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const escape = decodeAnsiCStringEscape(command, index + 1);
|
|
17
|
+
value += escape.value;
|
|
18
|
+
index = escape.endIndex;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export function decodeAnsiCStringEscape(command, escapeIndex) {
|
|
23
|
+
const char = command[escapeIndex];
|
|
24
|
+
switch (char) {
|
|
25
|
+
case 'a':
|
|
26
|
+
return { value: '\u0007', endIndex: escapeIndex };
|
|
27
|
+
case 'b':
|
|
28
|
+
return { value: '\b', endIndex: escapeIndex };
|
|
29
|
+
case 'e':
|
|
30
|
+
case 'E':
|
|
31
|
+
return { value: '\u001b', endIndex: escapeIndex };
|
|
32
|
+
case 'f':
|
|
33
|
+
return { value: '\f', endIndex: escapeIndex };
|
|
34
|
+
case 'n':
|
|
35
|
+
return { value: '\n', endIndex: escapeIndex };
|
|
36
|
+
case 'r':
|
|
37
|
+
return { value: '\r', endIndex: escapeIndex };
|
|
38
|
+
case 't':
|
|
39
|
+
return { value: '\t', endIndex: escapeIndex };
|
|
40
|
+
case 'v':
|
|
41
|
+
return { value: '\v', endIndex: escapeIndex };
|
|
42
|
+
case '\\':
|
|
43
|
+
case "'":
|
|
44
|
+
case '"':
|
|
45
|
+
case '?':
|
|
46
|
+
return { value: char, endIndex: escapeIndex };
|
|
47
|
+
case '\n':
|
|
48
|
+
return { value: '', endIndex: escapeIndex };
|
|
49
|
+
case 'x':
|
|
50
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 2, 16, '\\x');
|
|
51
|
+
case 'u':
|
|
52
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 4, 16, '\\u');
|
|
53
|
+
case 'U':
|
|
54
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 8, 16, '\\U');
|
|
55
|
+
default:
|
|
56
|
+
if (/[0-7]/.test(char)) {
|
|
57
|
+
return decodeNumericAnsiEscape(command, escapeIndex, 3, 8, '\\');
|
|
58
|
+
}
|
|
59
|
+
return { value: char, endIndex: escapeIndex };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function decodeNumericAnsiEscape(command, startIndex, maxLength, radix, fallbackPrefix) {
|
|
63
|
+
const pattern = radix === 16 ? /[0-9a-fA-F]/ : /[0-7]/;
|
|
64
|
+
let digits = '';
|
|
65
|
+
let endIndex = startIndex - 1;
|
|
66
|
+
for (let index = startIndex; index < command.length && digits.length < maxLength && pattern.test(command[index]); index += 1) {
|
|
67
|
+
digits += command[index];
|
|
68
|
+
endIndex = index;
|
|
69
|
+
}
|
|
70
|
+
if (digits.length === 0) {
|
|
71
|
+
return { value: fallbackPrefix, endIndex: startIndex - 1 };
|
|
72
|
+
}
|
|
73
|
+
const codePoint = Number.parseInt(digits, radix);
|
|
74
|
+
try {
|
|
75
|
+
return { value: String.fromCodePoint(codePoint), endIndex };
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return { value: `${fallbackPrefix}${digits}`, endIndex };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { decodeAnsiCStringEscape, decodeNumericAnsiEscape, readAnsiCString, } from './ansi-c-string.mts';
|
|
2
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution, } from './shell-command-substitution-reads.mts';
|
|
3
|
+
export { extractShellCommandSubstitutions } from './shell-command-substitutions.mts';
|
|
4
|
+
export { parseCommandPrefix, readCommandPrefix, withoutRedirections, } from './shell-command-wrappers.mts';
|
|
5
|
+
export type { CommandPrefix } from './shell-command-wrappers.mts';
|
|
6
|
+
export { commandsToInspectForGitPolicy, commandsToInspectPreservingQuotes, envPrefixSetsEditor, extractShellCommandArguments, isInteractiveRebaseContinue, shellCommandInheritsEditor, stripGitGlobalOptionsForPolicy, stripQuotedShellText, } from './shell-commands.mts';
|
|
7
|
+
export type { ShellCommandArgument } from './shell-commands.mts';
|
|
8
|
+
export { readHeredocDelimiter } from './shell-heredoc-delimiter.mts';
|
|
9
|
+
export { heredocSpecsFromLine } from './shell-heredoc-parser.mts';
|
|
10
|
+
export type { HeredocSpec } from './shell-heredoc-parser.mts';
|
|
11
|
+
export { stripNonShellHeredocBodies } from './shell-heredoc.mts';
|
|
12
|
+
export { isRedirectionFd, isShellRedirectionOperatorToken, redirectionOperatorOf, SHELL_REDIRECTION_OPERATORS, shellRedirectionOperatorAt, } from './shell-redirections.mts';
|
|
13
|
+
export { findShellScriptArguments, isShellWord, shellScriptOperandIndex, } from './shell-script-operand.mts';
|
|
14
|
+
export type { ShellScriptArgument } from './shell-script-operand.mts';
|
|
15
|
+
export { shellReadsStdinAt } from './shell-stdin-script.mts';
|
|
16
|
+
export { commandSegmentStart, isShellAssignment, isShellCommandSeparator, nextShellCommandSeparatorIndex, plainShellAssignment, } from './shell-token-utils.mts';
|
|
17
|
+
export { stripUnquotedShellComments } from './shell-tokenizer-comments.mts';
|
|
18
|
+
export { consumeShellSeparator } from './shell-tokenizer-operators.mts';
|
|
19
|
+
export { tokenizeShellWords, tokenizeShellWordsDetailed } from './shell-tokenizer.mts';
|
|
20
|
+
export type { ShellWord } from './shell-tokenizer.mts';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { decodeAnsiCStringEscape, decodeNumericAnsiEscape, readAnsiCString, } from "./ansi-c-string.mjs";
|
|
2
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution, } from "./shell-command-substitution-reads.mjs";
|
|
3
|
+
export { extractShellCommandSubstitutions } from "./shell-command-substitutions.mjs";
|
|
4
|
+
export { parseCommandPrefix, readCommandPrefix, withoutRedirections, } from "./shell-command-wrappers.mjs";
|
|
5
|
+
export { commandsToInspectForGitPolicy, commandsToInspectPreservingQuotes, envPrefixSetsEditor, extractShellCommandArguments, isInteractiveRebaseContinue, shellCommandInheritsEditor, stripGitGlobalOptionsForPolicy, stripQuotedShellText, } from "./shell-commands.mjs";
|
|
6
|
+
export { readHeredocDelimiter } from "./shell-heredoc-delimiter.mjs";
|
|
7
|
+
export { heredocSpecsFromLine } from "./shell-heredoc-parser.mjs";
|
|
8
|
+
export { stripNonShellHeredocBodies } from "./shell-heredoc.mjs";
|
|
9
|
+
export { isRedirectionFd, isShellRedirectionOperatorToken, redirectionOperatorOf, SHELL_REDIRECTION_OPERATORS, shellRedirectionOperatorAt, } from "./shell-redirections.mjs";
|
|
10
|
+
export { findShellScriptArguments, isShellWord, shellScriptOperandIndex, } from "./shell-script-operand.mjs";
|
|
11
|
+
export { shellReadsStdinAt } from "./shell-stdin-script.mjs";
|
|
12
|
+
export { commandSegmentStart, isShellAssignment, isShellCommandSeparator, nextShellCommandSeparatorIndex, plainShellAssignment, } from "./shell-token-utils.mjs";
|
|
13
|
+
export { stripUnquotedShellComments } from "./shell-tokenizer-comments.mjs";
|
|
14
|
+
export { consumeShellSeparator } from "./shell-tokenizer-operators.mjs";
|
|
15
|
+
export { tokenizeShellWords, tokenizeShellWordsDetailed } from "./shell-tokenizer.mjs";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function readParenthesizedSubstitution(command: string, startIndex: number): {
|
|
2
|
+
command: string;
|
|
3
|
+
endIndex: number;
|
|
4
|
+
} | null;
|
|
5
|
+
export declare function readBacktickSubstitution(command: string, startIndex: number): {
|
|
6
|
+
command: string;
|
|
7
|
+
endIndex: number;
|
|
8
|
+
} | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function readParenthesizedSubstitution(command, startIndex) {
|
|
2
|
+
let depth = 1;
|
|
3
|
+
let quote = null;
|
|
4
|
+
let escaping = false;
|
|
5
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
6
|
+
const char = command[index];
|
|
7
|
+
if (escaping) {
|
|
8
|
+
escaping = false;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (char === '\\' && quote !== "'") {
|
|
12
|
+
escaping = true;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (char === "'" && quote !== '"') {
|
|
16
|
+
quote = quote === "'" ? null : "'";
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === '"' && quote !== "'") {
|
|
20
|
+
quote = quote === '"' ? null : '"';
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (quote === null && char === '(') {
|
|
24
|
+
depth += 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (quote === null && char === ')' && --depth === 0) {
|
|
28
|
+
return { command: command.slice(startIndex, index), endIndex: index };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function readBacktickSubstitution(command, startIndex) {
|
|
34
|
+
let value = '';
|
|
35
|
+
let escaping = false;
|
|
36
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
37
|
+
const char = command[index];
|
|
38
|
+
if (escaping) {
|
|
39
|
+
value += char === '`' || char === '\\' || char === '$' ? char : `\\${char}`;
|
|
40
|
+
escaping = false;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (char === '\\') {
|
|
44
|
+
escaping = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === '`') {
|
|
48
|
+
return { command: value, endIndex: index };
|
|
49
|
+
}
|
|
50
|
+
value += char;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { readBacktickSubstitution, readParenthesizedSubstitution } from './shell-command-substitution-reads.mts';
|
|
2
|
+
/**
|
|
3
|
+
* The command substitutions a command's text runs. Heredoc bodies follow other quoting rules, so
|
|
4
|
+
* the caller blanks them first and reads their substitutions from the heredoc scan
|
|
5
|
+
* (shell-heredoc.mts).
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractShellCommandSubstitutions(textWithoutBodies: string): string[];
|
|
8
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readBacktickSubstitution, readParenthesizedSubstitution, } from "./shell-command-substitution-reads.mjs";
|
|
2
|
+
import { stripUnquotedShellComments } from "./shell-tokenizer.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The command substitutions a command's text runs. Heredoc bodies follow other quoting rules, so
|
|
5
|
+
* the caller blanks them first and reads their substitutions from the heredoc scan
|
|
6
|
+
* (shell-heredoc.mts).
|
|
7
|
+
*/
|
|
8
|
+
export function extractShellCommandSubstitutions(textWithoutBodies) {
|
|
9
|
+
const source = stripUnquotedShellComments(textWithoutBodies);
|
|
10
|
+
const substitutions = [];
|
|
11
|
+
let quote = null;
|
|
12
|
+
let escaping = false;
|
|
13
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
14
|
+
const char = source[index];
|
|
15
|
+
if (escaping) {
|
|
16
|
+
escaping = false;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === '\\' && quote !== "'") {
|
|
20
|
+
escaping = true;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (char === "'" && quote !== '"') {
|
|
24
|
+
quote = quote === "'" ? null : "'";
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (char === '"' && quote !== "'") {
|
|
28
|
+
quote = quote === '"' ? null : '"';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (quote === "'") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (char === '$' && source[index + 1] === '(') {
|
|
35
|
+
const substitution = readParenthesizedSubstitution(source, index + 2);
|
|
36
|
+
if (substitution !== null) {
|
|
37
|
+
substitutions.push(substitution.command);
|
|
38
|
+
index = substitution.endIndex;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === '`') {
|
|
43
|
+
const substitution = readBacktickSubstitution(source, index + 1);
|
|
44
|
+
if (substitution !== null) {
|
|
45
|
+
substitutions.push(substitution.command);
|
|
46
|
+
index = substitution.endIndex;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return substitutions;
|
|
51
|
+
}
|
|
52
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What a recognized wrapper chain before a command word changes about how that command runs. */
|
|
2
|
+
export type CommandPrefix = {
|
|
3
|
+
/** The effective `env -C` directory of each `env` in the chain, outermost first. */
|
|
4
|
+
chdir: string[];
|
|
5
|
+
/** Assignments and `env -u` unsets the command sees. */
|
|
6
|
+
env: Record<string, string | undefined>;
|
|
7
|
+
/** Wrapper basenames, outermost first. */
|
|
8
|
+
wrappers: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Parses the words between a command segment's start and a command word. Returns null when they
|
|
12
|
+
* are not a recognized wrapper chain, i.e. the command word is an argument rather than the
|
|
13
|
+
* program the shell runs. Wrappers chain in any order (`nohup env -C /tmp gh`) and match by
|
|
14
|
+
* basename (`/usr/bin/env`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseCommandPrefix(prefixWords: readonly string[]): CommandPrefix | null;
|
|
17
|
+
/**
|
|
18
|
+
* Reads the wrapper chain that opens a simple command's words (redirections already removed) and
|
|
19
|
+
* finds the command word it runs. Returns null when a wrapper's options are unrecognized or only
|
|
20
|
+
* describe the command (`command -v gh`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function readCommandPrefix(words: readonly string[]): {
|
|
23
|
+
commandIndex: number;
|
|
24
|
+
prefix: CommandPrefix;
|
|
25
|
+
} | null;
|
|
26
|
+
export declare function withoutRedirections(words: readonly string[]): string[] | null;
|