@vforsh/argus-client 0.2.0 → 0.4.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 +65 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/client/context.d.ts +31 -0
- package/dist/client/context.d.ts.map +1 -0
- package/dist/client/context.js +20 -0
- package/dist/client/context.js.map +1 -0
- package/dist/client/createArgusClient.d.ts +12 -2
- package/dist/client/createArgusClient.d.ts.map +1 -1
- package/dist/client/createArgusClient.js +26 -165
- package/dist/client/createArgusClient.js.map +1 -1
- package/dist/client/methods/capture.d.ts +12 -0
- package/dist/client/methods/capture.d.ts.map +1 -0
- package/dist/client/methods/capture.js +66 -0
- package/dist/client/methods/capture.js.map +1 -0
- package/dist/client/methods/evalMethods.d.ts +9 -0
- package/dist/client/methods/evalMethods.d.ts.map +1 -0
- package/dist/client/methods/evalMethods.js +119 -0
- package/dist/client/methods/evalMethods.js.map +1 -0
- package/dist/client/methods/inspect.d.ts +19 -0
- package/dist/client/methods/inspect.d.ts.map +1 -0
- package/dist/client/methods/inspect.js +102 -0
- package/dist/client/methods/inspect.js.map +1 -0
- package/dist/client/methods/page.d.ts +9 -0
- package/dist/client/methods/page.d.ts.map +1 -0
- package/dist/client/methods/page.js +38 -0
- package/dist/client/methods/page.js.map +1 -0
- package/dist/client/queryParams.d.ts +2 -0
- package/dist/client/queryParams.d.ts.map +1 -1
- package/dist/client/queryParams.js +68 -103
- package/dist/client/queryParams.js.map +1 -1
- package/dist/client/watcherHandle.d.ts +9 -0
- package/dist/client/watcherHandle.d.ts.map +1 -0
- package/dist/client/watcherHandle.js +29 -0
- package/dist/client/watcherHandle.js.map +1 -0
- package/dist/client/watcherRequest.d.ts +11 -1
- package/dist/client/watcherRequest.d.ts.map +1 -1
- package/dist/client/watcherRequest.js +21 -15
- package/dist/client/watcherRequest.js.map +1 -1
- package/dist/eval/ArgusEvalError.d.ts +30 -0
- package/dist/eval/ArgusEvalError.d.ts.map +1 -0
- package/dist/eval/ArgusEvalError.js +37 -0
- package/dist/eval/ArgusEvalError.js.map +1 -0
- package/dist/eval/pollEval.d.ts +81 -0
- package/dist/eval/pollEval.d.ts.map +1 -0
- package/dist/eval/pollEval.js +65 -0
- package/dist/eval/pollEval.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +164 -73
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/registry/readAndPruneRegistry.d.ts +0 -11
- package/dist/registry/readAndPruneRegistry.d.ts.map +0 -1
- package/dist/registry/readAndPruneRegistry.js +0 -14
- package/dist/registry/readAndPruneRegistry.js.map +0 -1
- package/dist/time/parseDurationMs.d.ts +0 -2
- package/dist/time/parseDurationMs.d.ts.map +0 -1
- package/dist/time/parseDurationMs.js +0 -18
- package/dist/time/parseDurationMs.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic eval polling loop shared by the CLI (`eval --interval`,
|
|
3
|
+
* `eval-until`) and the SDK (`evalUntil`), so loop semantics stay identical.
|
|
4
|
+
*
|
|
5
|
+
* The loop owns only timing and stop conditions. Everything environment-specific —
|
|
6
|
+
* how an eval is performed, retry policy, signal handling, output — is injected by
|
|
7
|
+
* the caller. In particular this module installs no process listeners: cancellation
|
|
8
|
+
* is an `AbortSignal` so it stays safe to use inside a library.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Poll `runEval` until a stop condition matches, the budget runs out, or the signal aborts.
|
|
12
|
+
*
|
|
13
|
+
* Results are reported to `onResult` before stop conditions are checked, so streaming
|
|
14
|
+
* callers print the matching iteration too.
|
|
15
|
+
*/
|
|
16
|
+
export const pollEval = async (input) => {
|
|
17
|
+
const startTime = Date.now();
|
|
18
|
+
let iteration = 0;
|
|
19
|
+
while (!input.signal?.aborted) {
|
|
20
|
+
if (input.totalTimeoutMs != null) {
|
|
21
|
+
const elapsedMs = Date.now() - startTime;
|
|
22
|
+
if (elapsedMs >= input.totalTimeoutMs) {
|
|
23
|
+
return { kind: 'timeout', elapsedMs };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
iteration += 1;
|
|
27
|
+
const result = await input.runEval(iteration);
|
|
28
|
+
if (!result.ok) {
|
|
29
|
+
return { kind: 'eval-error', failure: result.failure };
|
|
30
|
+
}
|
|
31
|
+
const context = { response: result.response, iteration, attempt: result.attempt };
|
|
32
|
+
// Streaming callers print the matched iteration too, so emit before checking stop conditions.
|
|
33
|
+
await input.onResult?.(result.response, context);
|
|
34
|
+
const decision = input.shouldStop?.(context);
|
|
35
|
+
if (decision) {
|
|
36
|
+
if (!decision.ok) {
|
|
37
|
+
return { kind: 'condition-error', error: decision.error };
|
|
38
|
+
}
|
|
39
|
+
if (decision.matched) {
|
|
40
|
+
return { kind: 'matched', response: result.response, iteration, attempt: result.attempt };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (input.count != null && iteration >= input.count) {
|
|
44
|
+
return { kind: 'exhausted', iterations: iteration };
|
|
45
|
+
}
|
|
46
|
+
await sleep(input.intervalMs, input.signal);
|
|
47
|
+
}
|
|
48
|
+
return { kind: 'interrupted' };
|
|
49
|
+
};
|
|
50
|
+
/** Resolve after `durationMs`, or immediately once `signal` aborts. */
|
|
51
|
+
const sleep = async (durationMs, signal) => {
|
|
52
|
+
if (signal?.aborted) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await new Promise((resolve) => {
|
|
56
|
+
const finish = () => {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
signal?.removeEventListener('abort', finish);
|
|
59
|
+
resolve();
|
|
60
|
+
};
|
|
61
|
+
const timer = setTimeout(finish, durationMs);
|
|
62
|
+
signal?.addEventListener('abort', finish, { once: true });
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=pollEval.js.map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AAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export type { ArgusClient, ArgusClientOptions, EvalOptions, EvalResult, ListOptions, ListResult, LogsMode, LogsOptions, LogsResult, LogCursorResult, LogEpochResult, NetOptions, NetResult, ScreenshotOptions, ScreenshotResult, TraceStartOptions, TraceStartResult, TraceStopOptions, TraceStopResult, } from './types.js';
|
|
1
|
+
export type { ArgusClient, ArgusClientOptions, DomClickOptions, DomClickResult, EvalOptions, EvalResult, EvalUntilOptions, EvalUntilResult, EvalValueOptions, ListOptions, ListResult, LogsMode, LogsOptions, LogsResult, LogCursorResult, LogEpochResult, NetClearResult, NetOptions, NetResult, RecordCaptureOptions, RecordOptions, RecordStartResult, RecordStopOptions, RecordStopResult, ReloadOptions, ScreenshotOptions, ScreenshotResult, TraceStartOptions, TraceStartResult, TraceStopOptions, TraceStopResult, VisibilityOptions, VisibilityResult, WatcherClient, } from './types.js';
|
|
2
2
|
export { createArgusClient } from './client/createArgusClient.js';
|
|
3
|
+
export { ArgusEvalError } from './eval/ArgusEvalError.js';
|
|
4
|
+
export { pollEval } from './eval/pollEval.js';
|
|
5
|
+
export type { EvalPollAttempt, EvalPollContext, EvalPollInput, EvalPollOutcome, EvalPollStopDecision } from './eval/pollEval.js';
|
|
3
6
|
export type { LogEpoch } from '@vforsh/argus-core';
|
|
4
7
|
export type { NetworkRequestDetail } from '@vforsh/argus-core';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACb,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAChI,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LogEvent, LogEpoch, LogLevel, NetworkRequestDetail,
|
|
1
|
+
import type { DomClickRequest, DomClickResponse, EvalRequest, EvalResponse, LogEvent, LogEpoch, LogLevel, NetClearResponse, NetQuery, NetResponse, NetworkRequestDetail, RecordRequest, RecordStartRequest, RecordStartResponse, RecordStopRequest, RecordStopResponse, ReloadRequest, ResponseData, ScreenshotRequest, ScreenshotResponse, StatusResponse, TraceStartRequest, TraceStartResponse, TraceStopRequest, TraceStopResponse, VisibilityRequest, VisibilityResponse, WatcherRecord } from '@vforsh/argus-core';
|
|
2
2
|
/** Options for configuring the Argus client. */
|
|
3
3
|
export type ArgusClientOptions = {
|
|
4
4
|
/** Override registry path instead of using `ARGUS_REGISTRY_PATH` / default. */
|
|
@@ -23,6 +23,13 @@ export type ListResult = {
|
|
|
23
23
|
status?: StatusResponse;
|
|
24
24
|
/** Error message when unreachable. */
|
|
25
25
|
error?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Set when the watcher answered but speaks an incompatible protocol version.
|
|
28
|
+
*
|
|
29
|
+
* The watcher is still reachable and `status` is still populated, but commands issued
|
|
30
|
+
* against it may fail in ways this SDK cannot interpret.
|
|
31
|
+
*/
|
|
32
|
+
protocolMismatch?: string;
|
|
26
33
|
};
|
|
27
34
|
/** Controls how log event args are returned. */
|
|
28
35
|
export type LogsMode = 'preview' | 'full';
|
|
@@ -62,92 +69,116 @@ export type LogEpochResult = {
|
|
|
62
69
|
epoch: LogEpoch;
|
|
63
70
|
};
|
|
64
71
|
/** Options for fetching network request summaries. */
|
|
65
|
-
export type NetOptions = {
|
|
66
|
-
after?: number;
|
|
67
|
-
limit?: number;
|
|
72
|
+
export type NetOptions = Omit<NetQuery, 'sinceTs' | 'timeoutMs'> & {
|
|
68
73
|
/**
|
|
69
74
|
* Filter by time window.
|
|
70
75
|
* - If string: parsed like CLI (e.g. "10m", "2h")
|
|
71
76
|
* - If number: treated as durationMs
|
|
77
|
+
*
|
|
78
|
+
* Sugar over the wire's absolute `sinceTs`.
|
|
72
79
|
*/
|
|
73
80
|
since?: string | number;
|
|
74
|
-
/** Substring match over redacted URLs. */
|
|
75
|
-
grep?: string;
|
|
76
|
-
/** Ignore requests by host name (exact host or subdomain match). */
|
|
77
|
-
ignoreHost?: string[];
|
|
78
|
-
/** Ignore requests whose URL contains one of these substrings. */
|
|
79
|
-
ignorePattern?: string[];
|
|
80
81
|
};
|
|
81
82
|
/** Network request summary results with pagination cursor. */
|
|
82
|
-
export type NetResult =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/** String-only values exposed to the expression as `args`. */
|
|
91
|
-
args?: Record<string, string>;
|
|
92
|
-
/** Await promises before returning. Defaults to true. */
|
|
93
|
-
awaitPromise?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Enable Chrome's REPL mode for console-style evaluation.
|
|
96
|
-
* Defaults to true and allows native top-level `await`.
|
|
97
|
-
*/
|
|
98
|
-
replMode?: boolean;
|
|
99
|
-
/** Command timeout in milliseconds. */
|
|
100
|
-
timeoutMs?: number;
|
|
101
|
-
/** Return by value when possible. Defaults to true. */
|
|
102
|
-
returnByValue?: boolean;
|
|
103
|
-
/** Install the temporary host bridge expected by bundled Argus scenario code. */
|
|
104
|
-
scenario?: boolean;
|
|
105
|
-
};
|
|
83
|
+
export type NetResult = ResponseData<NetResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Options for evaluating a JS expression in the connected page.
|
|
86
|
+
*
|
|
87
|
+
* This *is* the POST /eval body — it is sent verbatim — so it aliases the protocol
|
|
88
|
+
* request type rather than restating it.
|
|
89
|
+
*/
|
|
90
|
+
export type EvalOptions = EvalRequest;
|
|
106
91
|
/** Result of a remote evaluation. */
|
|
107
|
-
export type EvalResult =
|
|
108
|
-
result: unknown;
|
|
109
|
-
type: string | null;
|
|
110
|
-
exception: {
|
|
111
|
-
text: string;
|
|
112
|
-
details?: unknown;
|
|
113
|
-
} | null;
|
|
114
|
-
};
|
|
92
|
+
export type EvalResult = ResponseData<EvalResponse>;
|
|
115
93
|
/** Options for starting a Chrome trace. */
|
|
116
|
-
export type TraceStartOptions =
|
|
117
|
-
outFile?: string;
|
|
118
|
-
categories?: string;
|
|
119
|
-
options?: string;
|
|
120
|
-
};
|
|
94
|
+
export type TraceStartOptions = TraceStartRequest;
|
|
121
95
|
/** Trace start result metadata. */
|
|
122
|
-
export type TraceStartResult =
|
|
123
|
-
traceId: string;
|
|
124
|
-
sessionName: string;
|
|
125
|
-
outFile: string;
|
|
126
|
-
};
|
|
96
|
+
export type TraceStartResult = ResponseData<TraceStartResponse>;
|
|
127
97
|
/** Options for stopping an active trace. */
|
|
128
|
-
export type TraceStopOptions =
|
|
129
|
-
traceId?: string;
|
|
130
|
-
outFile?: string;
|
|
131
|
-
};
|
|
98
|
+
export type TraceStopOptions = TraceStopRequest;
|
|
132
99
|
/** Trace stop result metadata. */
|
|
133
|
-
export type TraceStopResult =
|
|
134
|
-
sessionName: string;
|
|
135
|
-
outFile: string;
|
|
136
|
-
eventCount: number;
|
|
137
|
-
durationMs: number;
|
|
138
|
-
};
|
|
100
|
+
export type TraceStopResult = ResponseData<TraceStopResponse>;
|
|
139
101
|
/** Options for capturing a screenshot. */
|
|
140
|
-
export type ScreenshotOptions =
|
|
141
|
-
outFile?: string;
|
|
142
|
-
selector?: string;
|
|
143
|
-
/** Viewport-relative crop rectangle in CSS pixels. Mutually exclusive with `selector`. */
|
|
144
|
-
clip?: ScreenshotClipRegion;
|
|
145
|
-
format?: 'png';
|
|
146
|
-
};
|
|
102
|
+
export type ScreenshotOptions = ScreenshotRequest;
|
|
147
103
|
/** Screenshot result metadata. */
|
|
148
|
-
export type ScreenshotResult =
|
|
149
|
-
|
|
150
|
-
|
|
104
|
+
export type ScreenshotResult = ResponseData<ScreenshotResponse>;
|
|
105
|
+
/** Options for clicking in the connected page. Mirrors CLI `argus click` semantics. */
|
|
106
|
+
export type DomClickOptions = DomClickRequest;
|
|
107
|
+
/** Result of a click, reporting selector matches separately from actual clicks. */
|
|
108
|
+
export type DomClickResult = ResponseData<DomClickResponse>;
|
|
109
|
+
/** Result of clearing the watcher's buffered network log. */
|
|
110
|
+
export type NetClearResult = ResponseData<NetClearResponse>;
|
|
111
|
+
/** Options for the page visibility lock. */
|
|
112
|
+
export type VisibilityOptions = VisibilityRequest;
|
|
113
|
+
/**
|
|
114
|
+
* Visibility lock result. The desired lock is sticky across detach/reattach:
|
|
115
|
+
* the watcher remembers it and re-applies on the next attach when `attached` is false.
|
|
116
|
+
*/
|
|
117
|
+
export type VisibilityResult = ResponseData<VisibilityResponse>;
|
|
118
|
+
/** Options for reloading the connected page. */
|
|
119
|
+
export type ReloadOptions = ReloadRequest;
|
|
120
|
+
/** Shared options for video recording requests. */
|
|
121
|
+
export type RecordOptions = RecordStartRequest;
|
|
122
|
+
/** Options for a fixed-duration one-shot recording. */
|
|
123
|
+
export type RecordCaptureOptions = RecordRequest;
|
|
124
|
+
/** Metadata returned when a recording starts. */
|
|
125
|
+
export type RecordStartResult = ResponseData<RecordStartResponse>;
|
|
126
|
+
/** Metadata returned when a recording is finalized. */
|
|
127
|
+
export type RecordStopResult = ResponseData<RecordStopResponse>;
|
|
128
|
+
/** Options for stopping an active recording. */
|
|
129
|
+
export type RecordStopOptions = RecordStopRequest;
|
|
130
|
+
/**
|
|
131
|
+
* Options for {@link ArgusClient.evalValue}.
|
|
132
|
+
*
|
|
133
|
+
* Omits `returnByValue` (always true) and adds {@link EvalValueOptions.jsonValue}.
|
|
134
|
+
*/
|
|
135
|
+
export type EvalValueOptions = Omit<EvalOptions, 'expression' | 'returnByValue' | 'jsonValue'> & {
|
|
136
|
+
/**
|
|
137
|
+
* Have the page serialize the result, so the JSON string — not a structured object —
|
|
138
|
+
* crosses the transport. Defaults to true.
|
|
139
|
+
*
|
|
140
|
+
* This exists because transports disagree about raw `returnByValue` results: the
|
|
141
|
+
* extension relay (Chrome's `chrome.debugger` serialization) returns object keys
|
|
142
|
+
* sorted alphabetically at every nesting level, while a direct CDP watcher preserves
|
|
143
|
+
* insertion order. Values are identical either way, but structural comparisons of the
|
|
144
|
+
* same page state produce different bytes per transport — which silently breaks
|
|
145
|
+
* snapshot assertions in verification runners. Serializing in the page normalizes both
|
|
146
|
+
* to insertion order, and makes `Date` round-trip as an ISO string (via `toJSON`)
|
|
147
|
+
* instead of `{}`.
|
|
148
|
+
*
|
|
149
|
+
* Evaluation semantics are unaffected: statement lists, top-level `await`, REPL-mode
|
|
150
|
+
* redeclaration, and promise unwrapping behave the same either way.
|
|
151
|
+
*
|
|
152
|
+
* Set to false for the raw transport-native value — one less serialization round-trip
|
|
153
|
+
* for large payloads you never compare structurally, at the cost of transport-dependent
|
|
154
|
+
* key order.
|
|
155
|
+
*/
|
|
156
|
+
jsonValue?: boolean;
|
|
157
|
+
};
|
|
158
|
+
/** Options for {@link ArgusClient.evalUntil}. */
|
|
159
|
+
export type EvalUntilOptions = EvalValueOptions & {
|
|
160
|
+
/** Delay between polls in milliseconds. Defaults to 250. */
|
|
161
|
+
intervalMs?: number;
|
|
162
|
+
/** Give up after this much wall-clock time. Defaults to 30000. */
|
|
163
|
+
totalTimeoutMs?: number;
|
|
164
|
+
/** Give up after this many polls. Unlimited when omitted. */
|
|
165
|
+
count?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Stop condition evaluated against each poll's value.
|
|
168
|
+
* Defaults to a truthiness check on the returned value.
|
|
169
|
+
*/
|
|
170
|
+
predicate?: (value: unknown, iteration: number) => boolean;
|
|
171
|
+
/** Abort the poll loop early. The returned promise rejects when aborted. */
|
|
172
|
+
signal?: AbortSignal;
|
|
173
|
+
};
|
|
174
|
+
/** Result of a successful {@link ArgusClient.evalUntil} poll. */
|
|
175
|
+
export type EvalUntilResult = {
|
|
176
|
+
/** The value that satisfied the predicate. */
|
|
177
|
+
value: unknown;
|
|
178
|
+
/** 1-based poll iteration that matched. */
|
|
179
|
+
iteration: number;
|
|
180
|
+
/** Wall-clock milliseconds spent polling. */
|
|
181
|
+
elapsedMs: number;
|
|
151
182
|
};
|
|
152
183
|
/** Argus client API. */
|
|
153
184
|
export type ArgusClient = {
|
|
@@ -163,13 +194,73 @@ export type ArgusClient = {
|
|
|
163
194
|
net: (watcherId: string, options?: NetOptions) => Promise<NetResult>;
|
|
164
195
|
/** Fetch the detailed record for one buffered network request. */
|
|
165
196
|
netRequest: (watcherId: string, request: number | string) => Promise<NetworkRequestDetail>;
|
|
166
|
-
/**
|
|
197
|
+
/** Clear the watcher's buffered network log. */
|
|
198
|
+
netClear: (watcherId: string) => Promise<NetClearResult>;
|
|
199
|
+
/**
|
|
200
|
+
* Evaluate a JS expression in the connected page and return the raw envelope.
|
|
201
|
+
* Page-side exceptions are reported in `exception`, not thrown.
|
|
202
|
+
*/
|
|
167
203
|
eval: (watcherId: string, options: EvalOptions) => Promise<EvalResult>;
|
|
204
|
+
/**
|
|
205
|
+
* Evaluate a JS expression and return its value directly.
|
|
206
|
+
*
|
|
207
|
+
* Unlike {@link ArgusClient.eval}, a page-side exception rejects with an `Error`
|
|
208
|
+
* carrying `exception.text` as its message. Results are normalized across transports
|
|
209
|
+
* by default — see {@link EvalValueOptions.jsonValue}.
|
|
210
|
+
*
|
|
211
|
+
* @throws {Error} When the expression throws in the page.
|
|
212
|
+
*/
|
|
213
|
+
evalValue: <T = unknown>(watcherId: string, expression: string, options?: EvalValueOptions) => Promise<T>;
|
|
214
|
+
/**
|
|
215
|
+
* Poll an expression until it satisfies a predicate (truthy by default).
|
|
216
|
+
*
|
|
217
|
+
* @throws {Error} On page-side exceptions, total-timeout expiry, poll-count
|
|
218
|
+
* exhaustion, or abort via {@link EvalUntilOptions.signal}.
|
|
219
|
+
*/
|
|
220
|
+
evalUntil: (watcherId: string, expression: string, options?: EvalUntilOptions) => Promise<EvalUntilResult>;
|
|
221
|
+
/** Click in the connected page by selector, element ref, or viewport coordinates. */
|
|
222
|
+
domClick: (watcherId: string, options: DomClickOptions) => Promise<DomClickResult>;
|
|
223
|
+
/** Lock the page shown+focused, or release the lock. */
|
|
224
|
+
visibility: (watcherId: string, options: VisibilityOptions) => Promise<VisibilityResult>;
|
|
225
|
+
/** Reload the connected page. Page-scoped even when the active target is an iframe. */
|
|
226
|
+
reload: (watcherId: string, options?: ReloadOptions) => Promise<void>;
|
|
168
227
|
/** Start Chrome tracing and write to disk on the watcher. */
|
|
169
228
|
traceStart: (watcherId: string, options?: TraceStartOptions) => Promise<TraceStartResult>;
|
|
170
229
|
/** Stop an active Chrome trace and finalize the file. */
|
|
171
230
|
traceStop: (watcherId: string, options?: TraceStopOptions) => Promise<TraceStopResult>;
|
|
172
231
|
/** Capture a screenshot and write to disk on the watcher. */
|
|
173
232
|
screenshot: (watcherId: string, options?: ScreenshotOptions) => Promise<ScreenshotResult>;
|
|
233
|
+
/** Capture a fixed-duration silent video and write it to disk on the watcher. */
|
|
234
|
+
record: (watcherId: string, options: RecordCaptureOptions) => Promise<RecordStopResult>;
|
|
235
|
+
/** Begin an open-ended silent video recording. Finalize with `recordStop`. */
|
|
236
|
+
recordStart: (watcherId: string, options?: RecordOptions) => Promise<RecordStartResult>;
|
|
237
|
+
/** Stop the active recording and finalize the file. */
|
|
238
|
+
recordStop: (watcherId: string, options?: RecordStopOptions) => Promise<RecordStopResult>;
|
|
239
|
+
/** Bind every watcher-scoped method to `watcherId`, removing id-threading at call sites. */
|
|
240
|
+
watcher: (watcherId: string) => WatcherClient;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Watcher-scoped subset of {@link ArgusClient}: everything that takes a watcher id first.
|
|
244
|
+
* `evalValue` is excluded because a mapped type erases its generic type parameter;
|
|
245
|
+
* {@link WatcherClient} redeclares it explicitly.
|
|
246
|
+
*/
|
|
247
|
+
type WatcherScopedApi = Omit<ArgusClient, 'list' | 'watcher' | 'evalValue'>;
|
|
248
|
+
/**
|
|
249
|
+
* The same API as {@link ArgusClient} with `watcherId` pre-bound.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* const page = client.watcher('playground')
|
|
253
|
+
* const count = await page.evalValue<number>('document.querySelectorAll("li").length')
|
|
254
|
+
*/
|
|
255
|
+
export type WatcherClient = {
|
|
256
|
+
[K in keyof WatcherScopedApi]: WatcherScopedApi[K] extends (watcherId: string, ...rest: infer A) => infer R ? (...args: A) => R : never;
|
|
257
|
+
} & {
|
|
258
|
+
/**
|
|
259
|
+
* Evaluate a JS expression and return its value directly.
|
|
260
|
+
*
|
|
261
|
+
* @throws {Error} When the expression throws in the page.
|
|
262
|
+
*/
|
|
263
|
+
evalValue: <T = unknown>(expression: string, options?: EvalValueOptions) => Promise<T>;
|
|
174
264
|
};
|
|
265
|
+
export {};
|
|
175
266
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kB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uDAAuD;IACvD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACzF,4FAA4F;IAC5F,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,aAAa,CAAA;CAC7C,CAAA;AAED;;;;GAIG;AACH,KAAK,gBAAgB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,CAAA;AAE3E;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;KAC1B,CAAC,IAAI,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK;CACvI,GAAG;IACH;;;;OAIG;IACH,SAAS,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;CACtF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vforsh/argus-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/vforsh/argus.git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@vforsh/argus-core": "^0.
|
|
25
|
+
"@vforsh/argus-core": "^0.4.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"clean": "node ../../scripts/clean-dist.mjs",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RegistryV1 } from '@vforsh/argus-core';
|
|
2
|
-
type RegistryOptions = {
|
|
3
|
-
registryPath?: string;
|
|
4
|
-
ttlMs?: number;
|
|
5
|
-
};
|
|
6
|
-
/** Read + prune stale entries atomically (locked read-modify-write). */
|
|
7
|
-
export declare const readAndPruneRegistry: (options?: RegistryOptions) => Promise<RegistryV1>;
|
|
8
|
-
/** Remove a watcher entry atomically (locked read-modify-write). */
|
|
9
|
-
export declare const removeWatcherAndPersist: (id: string, registryPath?: string) => Promise<RegistryV1>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=readAndPruneRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readAndPruneRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/readAndPruneRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,KAAK,eAAe,GAAG;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,GAAU,UAAS,eAAoB,KAAG,OAAO,CAAC,UAAU,CAM5F,CAAA;AAED,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,GAAU,IAAI,MAAM,EAAE,eAAe,MAAM,KAAG,OAAO,CAAC,UAAU,CAEnG,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_TTL_MS, pruneStaleWatchers, removeWatcherEntry, updateRegistry } from '@vforsh/argus-core';
|
|
2
|
-
/** Read + prune stale entries atomically (locked read-modify-write). */
|
|
3
|
-
export const readAndPruneRegistry = async (options = {}) => {
|
|
4
|
-
const ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
|
|
5
|
-
return updateRegistry((registry) => {
|
|
6
|
-
const { registry: pruned } = pruneStaleWatchers(registry, Date.now(), ttlMs);
|
|
7
|
-
return pruned;
|
|
8
|
-
}, options.registryPath);
|
|
9
|
-
};
|
|
10
|
-
/** Remove a watcher entry atomically (locked read-modify-write). */
|
|
11
|
-
export const removeWatcherAndPersist = async (id, registryPath) => {
|
|
12
|
-
return updateRegistry((registry) => removeWatcherEntry(registry, id), registryPath);
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=readAndPruneRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readAndPruneRegistry.js","sourceRoot":"","sources":["../../src/registry/readAndPruneRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAQ3G,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,UAA2B,EAAE,EAAuB,EAAE;IAChG,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,CAAA;IAC7C,OAAO,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAA;QAC5E,OAAO,MAAM,CAAA;IACd,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAAU,EAAE,YAAqB,EAAuB,EAAE;IACvG,OAAO,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,YAAY,CAAC,CAAA;AACpF,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDurationMs.d.ts","sourceRoot":"","sources":["../../src/time/parseDurationMs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IAoBxD,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const parseDurationMs = (value) => {
|
|
2
|
-
const trimmed = value.trim();
|
|
3
|
-
if (!trimmed) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
const match = trimmed.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m|h|d)?$/);
|
|
7
|
-
if (!match) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const amount = Number(match[1]);
|
|
11
|
-
if (!Number.isFinite(amount)) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const unit = match[2] ?? 's';
|
|
15
|
-
const multiplier = unit === 'ms' ? 1 : unit === 's' ? 1_000 : unit === 'm' ? 60_000 : unit === 'h' ? 3_600_000 : 86_400_000;
|
|
16
|
-
return amount * multiplier;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=parseDurationMs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDurationMs.js","sourceRoot":"","sources":["../../src/time/parseDurationMs.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAiB,EAAE;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAA;IAC5B,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;IAE3H,OAAO,MAAM,GAAG,UAAU,CAAA;AAC3B,CAAC,CAAA"}
|