@vforsh/argus-watcher 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/cdp/dom/selector.d.ts +10 -0
- package/dist/cdp/dom/selector.d.ts.map +1 -1
- package/dist/cdp/dom/selector.js +12 -0
- package/dist/cdp/dom/selector.js.map +1 -1
- package/dist/cdp/mouse.d.ts.map +1 -1
- package/dist/cdp/mouse.js +2 -11
- package/dist/cdp/mouse.js.map +1 -1
- package/dist/cdp/pageIndicator.d.ts +1 -1
- package/dist/cdp/pageIndicator.d.ts.map +1 -1
- package/dist/cdp/text-filter.js.map +1 -1
- package/dist/cdp/watcher.d.ts +3 -21
- package/dist/cdp/watcher.d.ts.map +1 -1
- package/dist/cdp/watcher.js +2 -278
- package/dist/cdp/watcher.js.map +1 -1
- package/dist/cdp/watcherEvents.d.ts +18 -0
- package/dist/cdp/watcherEvents.d.ts.map +1 -0
- package/dist/cdp/watcherEvents.js +169 -0
- package/dist/cdp/watcherEvents.js.map +1 -0
- package/dist/cdp/watcherTargets.d.ts +18 -0
- package/dist/cdp/watcherTargets.d.ts.map +1 -0
- package/dist/cdp/watcherTargets.js +95 -0
- package/dist/cdp/watcherTargets.js.map +1 -0
- package/dist/http/router.d.ts.map +1 -1
- package/dist/http/router.js +3 -77
- package/dist/http/router.js.map +1 -1
- package/dist/http/routes/domSelectorRoute.d.ts +16 -0
- package/dist/http/routes/domSelectorRoute.d.ts.map +1 -0
- package/dist/http/routes/domSelectorRoute.js +31 -0
- package/dist/http/routes/domSelectorRoute.js.map +1 -0
- package/dist/http/routes/index.d.ts +9 -0
- package/dist/http/routes/index.d.ts.map +1 -0
- package/dist/http/routes/index.js +78 -0
- package/dist/http/routes/index.js.map +1 -0
- package/dist/http/routes/postDomClick.d.ts.map +1 -1
- package/dist/http/routes/postDomClick.js +11 -21
- package/dist/http/routes/postDomClick.js.map +1 -1
- package/dist/http/routes/postDomFill.d.ts.map +1 -1
- package/dist/http/routes/postDomFill.js +9 -23
- package/dist/http/routes/postDomFill.js.map +1 -1
- package/dist/http/routes/postDomFocus.d.ts.map +1 -1
- package/dist/http/routes/postDomFocus.js +6 -17
- package/dist/http/routes/postDomFocus.js.map +1 -1
- package/dist/http/routes/postDomHover.d.ts.map +1 -1
- package/dist/http/routes/postDomHover.js +6 -17
- package/dist/http/routes/postDomHover.js.map +1 -1
- package/dist/http/routes/postDomInfo.d.ts.map +1 -1
- package/dist/http/routes/postDomInfo.js +6 -18
- package/dist/http/routes/postDomInfo.js.map +1 -1
- package/dist/http/routes/postDomRemove.d.ts.map +1 -1
- package/dist/http/routes/postDomRemove.js +6 -17
- package/dist/http/routes/postDomRemove.js.map +1 -1
- package/dist/http/routes/postDomScroll.d.ts.map +1 -1
- package/dist/http/routes/postDomScroll.js +2 -7
- package/dist/http/routes/postDomScroll.js.map +1 -1
- package/dist/http/routes/postDomScrollTo.d.ts.map +1 -1
- package/dist/http/routes/postDomScrollTo.js +2 -7
- package/dist/http/routes/postDomScrollTo.js.map +1 -1
- package/dist/http/routes/postDomSetFile.d.ts.map +1 -1
- package/dist/http/routes/postDomSetFile.js +9 -23
- package/dist/http/routes/postDomSetFile.js.map +1 -1
- package/dist/http/routes/postDomTree.d.ts.map +1 -1
- package/dist/http/routes/postDomTree.js +6 -18
- package/dist/http/routes/postDomTree.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -396
- package/dist/index.js.map +1 -1
- package/dist/runtime/watcherInject.d.ts +15 -0
- package/dist/runtime/watcherInject.d.ts.map +1 -0
- package/dist/runtime/watcherInject.js +21 -0
- package/dist/runtime/watcherInject.js.map +1 -0
- package/dist/runtime/watcherServices.d.ts +32 -0
- package/dist/runtime/watcherServices.d.ts.map +1 -0
- package/dist/runtime/watcherServices.js +64 -0
- package/dist/runtime/watcherServices.js.map +1 -0
- package/dist/runtime/watcherSetup.d.ts +35 -0
- package/dist/runtime/watcherSetup.d.ts.map +1 -0
- package/dist/runtime/watcherSetup.js +96 -0
- package/dist/runtime/watcherSetup.js.map +1 -0
- package/dist/sources/extension-delegating-session.d.ts +21 -0
- package/dist/sources/extension-delegating-session.d.ts.map +1 -0
- package/dist/sources/extension-delegating-session.js +62 -0
- package/dist/sources/extension-delegating-session.js.map +1 -0
- package/dist/sources/extension-frame-runtime.d.ts +11 -0
- package/dist/sources/extension-frame-runtime.d.ts.map +1 -0
- package/dist/sources/extension-frame-runtime.js +129 -0
- package/dist/sources/extension-frame-runtime.js.map +1 -0
- package/dist/sources/extension-session-events.d.ts +21 -0
- package/dist/sources/extension-session-events.d.ts.map +1 -0
- package/dist/sources/extension-session-events.js +103 -0
- package/dist/sources/extension-session-events.js.map +1 -0
- package/dist/sources/extension-source.d.ts +0 -4
- package/dist/sources/extension-source.d.ts.map +1 -1
- package/dist/sources/extension-source.js +39 -285
- package/dist/sources/extension-source.js.map +1 -1
- package/dist/startWatcherRuntime.d.ts +6 -0
- package/dist/startWatcherRuntime.d.ts.map +1 -0
- package/dist/startWatcherRuntime.js +251 -0
- package/dist/startWatcherRuntime.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import os from 'node:os';
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
import Emittery from 'emittery';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { startHttpServer } from './http/server.js';
|
|
7
|
-
import { announceWatcher, removeWatcher, startRegistryHeartbeat, resolveUniqueWatcherId } from './registry/registry.js';
|
|
8
|
-
import { WatcherFileLogger } from './fileLogs/WatcherFileLogger.js';
|
|
9
|
-
import { buildIgnoreMatcher } from './cdp/ignoreList.js';
|
|
10
|
-
import { createNetworkCapture } from './cdp/networkCapture.js';
|
|
11
|
-
import { createTraceRecorder } from './cdp/tracing.js';
|
|
12
|
-
import { createScreenshotter } from './cdp/screenshot.js';
|
|
13
|
-
import { createRuntimeEditor } from './cdp/editor.js';
|
|
14
|
-
import { createCdpSessionHandle } from './cdp/connection.js';
|
|
15
|
-
import { createPageIndicatorController, validatePageIndicatorOptions, } from './cdp/pageIndicator.js';
|
|
16
|
-
import { createEmulationController } from './emulation/EmulationController.js';
|
|
17
|
-
import { createThrottleController } from './throttle/ThrottleController.js';
|
|
18
|
-
import { createCdpSource } from './sources/cdp-source.js';
|
|
19
|
-
import { createExtensionSource } from './sources/extension-source.js';
|
|
2
|
+
import { resolveUniqueWatcherId } from './registry/registry.js';
|
|
3
|
+
import { createWatcherHandle } from './startWatcherRuntime.js';
|
|
20
4
|
/**
|
|
21
5
|
* Start a watcher that connects to Chrome (via CDP or extension), buffers console logs, and exposes the HTTP API.
|
|
22
6
|
* @param options - Configuration for binding, source mode, and buffering.
|
|
@@ -27,383 +11,6 @@ export const startWatcher = async (options) => {
|
|
|
27
11
|
throw new Error('Watcher id is required');
|
|
28
12
|
}
|
|
29
13
|
const watcherId = await resolveUniqueWatcherId(options.id);
|
|
30
|
-
|
|
31
|
-
const host = options.host ?? '127.0.0.1';
|
|
32
|
-
const port = options.port ?? 0;
|
|
33
|
-
const chrome = options.chrome ?? { host: '127.0.0.1', port: 9222 };
|
|
34
|
-
const bufferSize = options.bufferSize ?? 50_000;
|
|
35
|
-
const netBufferSize = options.bufferSize ?? 50_000;
|
|
36
|
-
const startedAt = Date.now();
|
|
37
|
-
const ignoreMatcher = buildIgnoreMatcher(options.ignoreList);
|
|
38
|
-
const stripUrlPrefixes = options.location?.stripUrlPrefixes;
|
|
39
|
-
// Resolve artifacts configuration
|
|
40
|
-
const artifactsBaseDir = resolveArtifactsBaseDir(options.artifacts?.base, watcherId);
|
|
41
|
-
const logsEnabled = options.artifacts?.logs?.enabled === true;
|
|
42
|
-
const logsDir = path.join(artifactsBaseDir, 'logs');
|
|
43
|
-
const includeTimestamps = options.artifacts?.logs?.includeTimestamps ?? false;
|
|
44
|
-
const maxFiles = resolveMaxFiles(options.artifacts?.logs?.maxFiles);
|
|
45
|
-
// Network capture is opt-in (disabled by default) and supported in both direct CDP and extension mode.
|
|
46
|
-
const netEnabled = options.net?.enabled === true;
|
|
47
|
-
// Page console logging (default: minimal)
|
|
48
|
-
const pageConsoleLogging = options.pageConsoleLogging ?? 'minimal';
|
|
49
|
-
const events = new Emittery();
|
|
50
|
-
const buffer = new LogBuffer(bufferSize);
|
|
51
|
-
const netBuffer = netEnabled ? new NetBuffer(netBufferSize) : null;
|
|
52
|
-
let closing = false;
|
|
53
|
-
let readyForShutdown = false;
|
|
54
|
-
let shutdownRequested = false;
|
|
55
|
-
let closeOnce = null;
|
|
56
|
-
let cdpStatus = { attached: false, target: null };
|
|
57
|
-
const fileLogger = logsEnabled
|
|
58
|
-
? new WatcherFileLogger({
|
|
59
|
-
watcherId,
|
|
60
|
-
startedAt,
|
|
61
|
-
logsDir,
|
|
62
|
-
chrome: sourceMode === 'cdp' ? chrome : undefined,
|
|
63
|
-
match: options.match,
|
|
64
|
-
maxFiles,
|
|
65
|
-
includeTimestamps,
|
|
66
|
-
buildFilename: options.artifacts?.logs?.buildFilename,
|
|
67
|
-
})
|
|
68
|
-
: null;
|
|
69
|
-
const record = {
|
|
70
|
-
id: watcherId,
|
|
71
|
-
host,
|
|
72
|
-
port,
|
|
73
|
-
pid: process.pid,
|
|
74
|
-
cwd: process.cwd(),
|
|
75
|
-
startedAt,
|
|
76
|
-
updatedAt: Date.now(),
|
|
77
|
-
match: sourceMode === 'cdp' ? options.match : undefined,
|
|
78
|
-
chrome: sourceMode === 'cdp' ? chrome : undefined,
|
|
79
|
-
includeTimestamps,
|
|
80
|
-
source: sourceMode,
|
|
81
|
-
};
|
|
82
|
-
// Create session handle for CDP mode (used by network capture, tracing, etc.)
|
|
83
|
-
const sessionHandle = createCdpSessionHandle();
|
|
84
|
-
// Emulation controller (shared across CDP and extension modes)
|
|
85
|
-
const emulationController = createEmulationController();
|
|
86
|
-
// Throttle controller (CPU, network, cache — shared across CDP and extension modes)
|
|
87
|
-
const throttleController = createThrottleController();
|
|
88
|
-
const logToPageConsole = (message) => {
|
|
89
|
-
if (pageConsoleLogging === 'none') {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (!sourceHandle?.session.isAttached()) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const fullMessage = `[ARGUS] ${watcherId} :: ${message}`;
|
|
96
|
-
queueMicrotask(() => {
|
|
97
|
-
sourceHandle?.session
|
|
98
|
-
.sendAndWait('Runtime.evaluate', {
|
|
99
|
-
expression: `console.log(${JSON.stringify(fullMessage)})`,
|
|
100
|
-
silent: true,
|
|
101
|
-
})
|
|
102
|
-
.catch(() => { });
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
validatePageIndicatorOptions(options.pageIndicator);
|
|
106
|
-
const indicatorEnabled = options.pageIndicator?.enabled === true;
|
|
107
|
-
let indicatorController = null;
|
|
108
|
-
let indicatorAttachedAt = null;
|
|
109
|
-
if (indicatorEnabled) {
|
|
110
|
-
indicatorController = createPageIndicatorController(options.pageIndicator);
|
|
111
|
-
}
|
|
112
|
-
const updateCdpStatus = (status) => {
|
|
113
|
-
const prevAttached = cdpStatus.attached;
|
|
114
|
-
cdpStatus = status;
|
|
115
|
-
if (status.attached && !prevAttached) {
|
|
116
|
-
const url = status.target?.url ?? 'unknown';
|
|
117
|
-
logToPageConsole(`attached (url=${url})`);
|
|
118
|
-
void events.emit('cdpAttached', {
|
|
119
|
-
ts: Date.now(),
|
|
120
|
-
watcherId,
|
|
121
|
-
target: status.target,
|
|
122
|
-
});
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (!status.attached && prevAttached) {
|
|
126
|
-
void events.emit('cdpDetached', {
|
|
127
|
-
ts: Date.now(),
|
|
128
|
-
watcherId,
|
|
129
|
-
target: status.target,
|
|
130
|
-
reason: status.reason ?? 'unknown',
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
const buildIndicatorInfo = (target) => ({
|
|
135
|
-
watcherId,
|
|
136
|
-
watcherHost: host,
|
|
137
|
-
watcherPort: record.port,
|
|
138
|
-
watcherPid: process.pid,
|
|
139
|
-
targetTitle: target?.title ?? null,
|
|
140
|
-
targetUrl: target?.url ?? null,
|
|
141
|
-
attachedAt: indicatorAttachedAt ?? Date.now(),
|
|
142
|
-
});
|
|
143
|
-
const onIndicatorNavigation = (session, info) => {
|
|
144
|
-
if (!indicatorController) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
indicatorController.onNavigation(session, buildIndicatorInfo({ title: null, url: info.url }));
|
|
148
|
-
};
|
|
149
|
-
const onIndicatorLoad = () => {
|
|
150
|
-
indicatorController?.reinstall();
|
|
151
|
-
};
|
|
152
|
-
const getIndicatorSession = () => sourceHandle.pageSession ?? sourceHandle.session;
|
|
153
|
-
const onIndicatorAttach = (session, target) => {
|
|
154
|
-
if (!indicatorController) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
indicatorAttachedAt = Date.now();
|
|
158
|
-
indicatorController.onAttach(session, {
|
|
159
|
-
id: target.id,
|
|
160
|
-
title: target.title,
|
|
161
|
-
url: target.url,
|
|
162
|
-
type: target.type ?? 'page',
|
|
163
|
-
parentId: target.parentId ?? null,
|
|
164
|
-
webSocketDebuggerUrl: '',
|
|
165
|
-
}, buildIndicatorInfo({ title: target.title, url: target.url }));
|
|
166
|
-
};
|
|
167
|
-
const maybeInjectOnAttach = async (session, target) => {
|
|
168
|
-
if (!options.inject?.script) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (!session.isAttached()) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const trimmedScript = options.inject.script.trim();
|
|
175
|
-
if (trimmedScript === '') {
|
|
176
|
-
console.warn(`[Watcher] Inject script is empty for watcher ${record.id}. Skipping.`);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const attachedAt = Date.now();
|
|
180
|
-
const exposeArgus = options.inject.exposeArgus ?? true;
|
|
181
|
-
const argusPayload = exposeArgus
|
|
182
|
-
? {
|
|
183
|
-
watcherId: record.id,
|
|
184
|
-
watcherHost: record.host,
|
|
185
|
-
watcherPort: record.port,
|
|
186
|
-
watcherPid: record.pid,
|
|
187
|
-
attachedAt,
|
|
188
|
-
target: {
|
|
189
|
-
title: target.title ?? null,
|
|
190
|
-
url: target.url ?? null,
|
|
191
|
-
type: target.type ?? 'page',
|
|
192
|
-
parentId: target.parentId ?? null,
|
|
193
|
-
},
|
|
194
|
-
}
|
|
195
|
-
: null;
|
|
196
|
-
const expression = buildInjectExpression(trimmedScript, argusPayload);
|
|
197
|
-
try {
|
|
198
|
-
await session.sendAndWait('Page.addScriptToEvaluateOnNewDocument', { source: expression });
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
console.warn(`[Watcher] Failed to register inject script for watcher ${record.id}: ${formatError(error)}`);
|
|
202
|
-
}
|
|
203
|
-
try {
|
|
204
|
-
await session.sendAndWait('Runtime.evaluate', { expression, silent: true });
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
console.warn(`[Watcher] Failed to run inject script for watcher ${record.id}: ${formatError(error)}`);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const handleSourceLog = (event) => {
|
|
211
|
-
buffer.add(event);
|
|
212
|
-
fileLogger?.writeEvent(event);
|
|
213
|
-
};
|
|
214
|
-
const handlePageNavigation = (info) => {
|
|
215
|
-
fileLogger?.rotate(info);
|
|
216
|
-
onIndicatorNavigation(getIndicatorSession(), info);
|
|
217
|
-
runtimeEditor?.reset();
|
|
218
|
-
};
|
|
219
|
-
const handlePageIntl = (info) => {
|
|
220
|
-
fileLogger?.setPageIntl(info);
|
|
221
|
-
};
|
|
222
|
-
const handleSourceAttach = async (session, target) => {
|
|
223
|
-
runtimeEditor?.rebind();
|
|
224
|
-
await emulationController.onAttach(session);
|
|
225
|
-
await throttleController.onAttach(session);
|
|
226
|
-
await networkCapture?.onAttached();
|
|
227
|
-
onIndicatorAttach(session, target);
|
|
228
|
-
await maybeInjectOnAttach(session, target);
|
|
229
|
-
};
|
|
230
|
-
const handleTargetChanged = (session, target) => {
|
|
231
|
-
onIndicatorAttach(session, target);
|
|
232
|
-
};
|
|
233
|
-
const handleSourceDetach = (reason) => {
|
|
234
|
-
runtimeEditor?.rebind();
|
|
235
|
-
networkCapture?.onDetached();
|
|
236
|
-
indicatorController?.onDetach();
|
|
237
|
-
if (reason != null) {
|
|
238
|
-
traceRecorder.onDetached(reason);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
// Create the appropriate source based on mode
|
|
242
|
-
let sourceHandle;
|
|
243
|
-
let networkCapture = null;
|
|
244
|
-
let traceRecorder;
|
|
245
|
-
let screenshotter;
|
|
246
|
-
let runtimeEditor;
|
|
247
|
-
if (sourceMode === 'extension') {
|
|
248
|
-
// Extension mode
|
|
249
|
-
sourceHandle = createExtensionSource({
|
|
250
|
-
events: {
|
|
251
|
-
onLog: handleSourceLog,
|
|
252
|
-
onStatus: updateCdpStatus,
|
|
253
|
-
onPageNavigation: handlePageNavigation,
|
|
254
|
-
onPageLoad: onIndicatorLoad,
|
|
255
|
-
onPageIntl: handlePageIntl,
|
|
256
|
-
onAttach: handleSourceAttach,
|
|
257
|
-
onTargetChanged: handleTargetChanged,
|
|
258
|
-
onDetach: () => {
|
|
259
|
-
handleSourceDetach();
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
watcherId,
|
|
263
|
-
watcherHost: host,
|
|
264
|
-
watcherPort: record.port,
|
|
265
|
-
ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
|
|
266
|
-
stripUrlPrefixes,
|
|
267
|
-
});
|
|
268
|
-
networkCapture = netBuffer ? createNetworkCapture({ session: sourceHandle.pageSession ?? sourceHandle.session, buffer: netBuffer }) : null;
|
|
269
|
-
// Create trace/screenshot with proxy session
|
|
270
|
-
traceRecorder = createTraceRecorder({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
|
|
271
|
-
screenshotter = createScreenshotter({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
|
|
272
|
-
runtimeEditor = createRuntimeEditor(sourceHandle.session);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
// CDP mode
|
|
276
|
-
networkCapture = netBuffer ? createNetworkCapture({ session: sessionHandle.session, buffer: netBuffer }) : null;
|
|
277
|
-
traceRecorder = createTraceRecorder({ session: sessionHandle.session, artifactsDir: artifactsBaseDir });
|
|
278
|
-
screenshotter = createScreenshotter({ session: sessionHandle.session, artifactsDir: artifactsBaseDir });
|
|
279
|
-
runtimeEditor = createRuntimeEditor(sessionHandle.session);
|
|
280
|
-
sourceHandle = createCdpSource({
|
|
281
|
-
chrome,
|
|
282
|
-
match: options.match,
|
|
283
|
-
sessionHandle,
|
|
284
|
-
events: {
|
|
285
|
-
onLog: handleSourceLog,
|
|
286
|
-
onStatus: updateCdpStatus,
|
|
287
|
-
onPageNavigation: handlePageNavigation,
|
|
288
|
-
onPageLoad: onIndicatorLoad,
|
|
289
|
-
onPageIntl: handlePageIntl,
|
|
290
|
-
onAttach: handleSourceAttach,
|
|
291
|
-
onDetach: (reason) => {
|
|
292
|
-
handleSourceDetach(reason);
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
watcherId,
|
|
296
|
-
ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
|
|
297
|
-
stripUrlPrefixes,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
const server = await startHttpServer({
|
|
301
|
-
host,
|
|
302
|
-
port,
|
|
303
|
-
buffer,
|
|
304
|
-
netBuffer,
|
|
305
|
-
getWatcher: () => record,
|
|
306
|
-
getCdpStatus: () => cdpStatus,
|
|
307
|
-
pageCdpSession: sourceHandle.pageSession ?? sourceHandle.session,
|
|
308
|
-
cdpSession: sourceHandle.session,
|
|
309
|
-
traceRecorder,
|
|
310
|
-
screenshotter,
|
|
311
|
-
runtimeEditor,
|
|
312
|
-
emulationController,
|
|
313
|
-
throttleController,
|
|
314
|
-
// Extension mode endpoints
|
|
315
|
-
sourceHandle: sourceMode === 'extension' ? sourceHandle : undefined,
|
|
316
|
-
onRequest: (event) => {
|
|
317
|
-
if (pageConsoleLogging === 'full') {
|
|
318
|
-
logToPageConsole(`http ${event.endpoint}`);
|
|
319
|
-
}
|
|
320
|
-
void events.emit('httpRequested', {
|
|
321
|
-
...event,
|
|
322
|
-
watcherId,
|
|
323
|
-
});
|
|
324
|
-
},
|
|
325
|
-
onShutdown: () => {
|
|
326
|
-
if (!readyForShutdown || !closeOnce) {
|
|
327
|
-
shutdownRequested = true;
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
void closeOnce();
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
record.port = server.port;
|
|
334
|
-
sourceHandle.syncWatcherInfo?.({
|
|
335
|
-
watcherId,
|
|
336
|
-
watcherHost: host,
|
|
337
|
-
watcherPort: record.port,
|
|
338
|
-
watcherPid: process.pid,
|
|
339
|
-
});
|
|
340
|
-
await announceWatcher(record);
|
|
341
|
-
const heartbeat = startRegistryHeartbeat(() => record, options.heartbeatMs ?? 15_000);
|
|
342
|
-
closeOnce = async () => {
|
|
343
|
-
if (closing) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
closing = true;
|
|
347
|
-
heartbeat.stop();
|
|
348
|
-
indicatorController?.stop();
|
|
349
|
-
if (cdpStatus.attached) {
|
|
350
|
-
logToPageConsole('detached (reason=watcher_stopped)');
|
|
351
|
-
}
|
|
352
|
-
await sourceHandle.stop();
|
|
353
|
-
await fileLogger?.close();
|
|
354
|
-
traceRecorder.onDetached('watcher_stopped');
|
|
355
|
-
await server.close();
|
|
356
|
-
await removeWatcher(record.id);
|
|
357
|
-
events.clearListeners();
|
|
358
|
-
};
|
|
359
|
-
readyForShutdown = true;
|
|
360
|
-
if (shutdownRequested) {
|
|
361
|
-
void closeOnce();
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
watcher: record,
|
|
365
|
-
events,
|
|
366
|
-
close: async () => {
|
|
367
|
-
await closeOnce?.();
|
|
368
|
-
},
|
|
369
|
-
};
|
|
370
|
-
};
|
|
371
|
-
const resolveArtifactsBaseDir = (base, watcherId) => {
|
|
372
|
-
if (base !== undefined && base !== null) {
|
|
373
|
-
if (typeof base !== 'string' || base.trim() === '') {
|
|
374
|
-
throw new Error('artifacts.base must be a non-empty string when provided');
|
|
375
|
-
}
|
|
376
|
-
return path.resolve(base);
|
|
377
|
-
}
|
|
378
|
-
return path.join(os.tmpdir(), 'argus', watcherId);
|
|
379
|
-
};
|
|
380
|
-
const resolveMaxFiles = (maxFiles) => {
|
|
381
|
-
if (maxFiles === undefined) {
|
|
382
|
-
return 5;
|
|
383
|
-
}
|
|
384
|
-
if (!Number.isInteger(maxFiles) || maxFiles < 1) {
|
|
385
|
-
throw new Error('artifacts.logs.maxFiles must be an integer >= 1');
|
|
386
|
-
}
|
|
387
|
-
return maxFiles;
|
|
388
|
-
};
|
|
389
|
-
const buildInjectExpression = (script, argusPayload) => {
|
|
390
|
-
const lines = ['(() => {'];
|
|
391
|
-
if (argusPayload) {
|
|
392
|
-
lines.push(`window.__ARGUS__ = ${JSON.stringify(argusPayload)};`);
|
|
393
|
-
}
|
|
394
|
-
lines.push(`const __argusScript = ${JSON.stringify(script)};`);
|
|
395
|
-
lines.push('const __argusFn = new Function(__argusScript);');
|
|
396
|
-
lines.push('__argusFn();');
|
|
397
|
-
lines.push('})();');
|
|
398
|
-
return lines.join('\n');
|
|
399
|
-
};
|
|
400
|
-
const formatError = (error) => {
|
|
401
|
-
if (!error) {
|
|
402
|
-
return 'Unknown error';
|
|
403
|
-
}
|
|
404
|
-
if (error instanceof Error) {
|
|
405
|
-
return error.message;
|
|
406
|
-
}
|
|
407
|
-
return String(error);
|
|
14
|
+
return createWatcherHandle(options, watcherId);
|
|
408
15
|
};
|
|
409
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACvH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EACN,6BAA6B,EAC7B,4BAA4B,GAG5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AA6JrE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAA4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CAAA;IACvB,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AA6J9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAA4B,EAA0B,EAAE;IAC1F,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC1D,OAAO,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAC/C,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const buildInjectExpression: (script: string, argusPayload: {
|
|
2
|
+
watcherId: string;
|
|
3
|
+
watcherHost: string;
|
|
4
|
+
watcherPort: number;
|
|
5
|
+
watcherPid: number;
|
|
6
|
+
attachedAt: number;
|
|
7
|
+
target: {
|
|
8
|
+
title: string | null;
|
|
9
|
+
url: string | null;
|
|
10
|
+
type: string;
|
|
11
|
+
parentId: string | null;
|
|
12
|
+
};
|
|
13
|
+
} | null) => string;
|
|
14
|
+
export declare const formatWatcherError: (error: unknown) => string;
|
|
15
|
+
//# sourceMappingURL=watcherInject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcherInject.d.ts","sourceRoot":"","sources":["../../src/runtime/watcherInject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GACjC,QAAQ,MAAM,EACd,cAAc;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAC3F,GAAG,IAAI,KACN,MAUF,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,MAQnD,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const buildInjectExpression = (script, argusPayload) => {
|
|
2
|
+
const lines = ['(() => {'];
|
|
3
|
+
if (argusPayload) {
|
|
4
|
+
lines.push(`window.__ARGUS__ = ${JSON.stringify(argusPayload)};`);
|
|
5
|
+
}
|
|
6
|
+
lines.push(`const __argusScript = ${JSON.stringify(script)};`);
|
|
7
|
+
lines.push('const __argusFn = new Function(__argusScript);');
|
|
8
|
+
lines.push('__argusFn();');
|
|
9
|
+
lines.push('})();');
|
|
10
|
+
return lines.join('\n');
|
|
11
|
+
};
|
|
12
|
+
export const formatWatcherError = (error) => {
|
|
13
|
+
if (!error) {
|
|
14
|
+
return 'Unknown error';
|
|
15
|
+
}
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
return error.message;
|
|
18
|
+
}
|
|
19
|
+
return String(error);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=watcherInject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcherInject.js","sourceRoot":"","sources":["../../src/runtime/watcherInject.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACpC,MAAc,EACd,YAOQ,EACC,EAAE;IACX,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,CAAA;IAC1B,IAAI,YAAY,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IAClE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC9D,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAA;IAC5D,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC1B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,eAAe,CAAA;IACvB,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createNetworkCapture } from '../cdp/networkCapture.js';
|
|
2
|
+
import { createTraceRecorder } from '../cdp/tracing.js';
|
|
3
|
+
import { createScreenshotter } from '../cdp/screenshot.js';
|
|
4
|
+
import { createRuntimeEditor } from '../cdp/editor.js';
|
|
5
|
+
import type { CdpSourceHandle, CdpSourceStatus, CdpSourceTarget } from '../sources/types.js';
|
|
6
|
+
import type { StartWatcherOptions } from '../index.js';
|
|
7
|
+
import type { NormalizedWatcherSetup } from './watcherSetup.js';
|
|
8
|
+
export type WatcherSourceCallbacks = {
|
|
9
|
+
onLog: (event: Omit<import('@vforsh/argus-core').LogEvent, 'id'>) => void;
|
|
10
|
+
onStatus: (status: CdpSourceStatus) => void;
|
|
11
|
+
onPageNavigation: (info: {
|
|
12
|
+
url: string;
|
|
13
|
+
title: string | null;
|
|
14
|
+
}) => void;
|
|
15
|
+
onPageLoad: () => void;
|
|
16
|
+
onPageIntl: (info: {
|
|
17
|
+
timezone: string | null;
|
|
18
|
+
locale: string | null;
|
|
19
|
+
}) => void;
|
|
20
|
+
onAttach: (session: CdpSourceHandle['session'], target: CdpSourceTarget) => Promise<void>;
|
|
21
|
+
onTargetChanged?: (session: CdpSourceHandle['session'], target: CdpSourceTarget) => void;
|
|
22
|
+
onDetach: (reason?: string) => void;
|
|
23
|
+
};
|
|
24
|
+
export type WatcherRuntimeServices = {
|
|
25
|
+
sourceHandle: CdpSourceHandle;
|
|
26
|
+
networkCapture: Awaited<ReturnType<typeof createNetworkCapture>> | null;
|
|
27
|
+
traceRecorder: ReturnType<typeof createTraceRecorder>;
|
|
28
|
+
screenshotter: ReturnType<typeof createScreenshotter>;
|
|
29
|
+
runtimeEditor: ReturnType<typeof createRuntimeEditor>;
|
|
30
|
+
};
|
|
31
|
+
export declare const createWatcherRuntimeServices: (options: StartWatcherOptions, setup: NormalizedWatcherSetup, callbacks: WatcherSourceCallbacks) => WatcherRuntimeServices;
|
|
32
|
+
//# sourceMappingURL=watcherServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcherServices.d.ts","sourceRoot":"","sources":["../../src/runtime/watcherServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAGtD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,e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,CAAC,CAAA;IACrD,aAAa,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;CACrD,CAAA;AAED,eAAO,MAAM,4BAA4B,GACxC,SAAS,mBAAmB,EAC5B,OAAO,sBAAsB,EAC7B,WAAW,sBAAsB,KAC/B,sBA4DF,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createNetworkCapture } from '../cdp/networkCapture.js';
|
|
2
|
+
import { createTraceRecorder } from '../cdp/tracing.js';
|
|
3
|
+
import { createScreenshotter } from '../cdp/screenshot.js';
|
|
4
|
+
import { createRuntimeEditor } from '../cdp/editor.js';
|
|
5
|
+
import { createCdpSource } from '../sources/cdp-source.js';
|
|
6
|
+
import { createExtensionSource } from '../sources/extension-source.js';
|
|
7
|
+
export const createWatcherRuntimeServices = (options, setup, callbacks) => {
|
|
8
|
+
const { sourceMode, chrome, artifactsBaseDir, netBuffer, sessionHandle, ignoreMatcher, stripUrlPrefixes, watcherId, host, record } = setup;
|
|
9
|
+
if (sourceMode === 'extension') {
|
|
10
|
+
const sourceHandle = createExtensionSource({
|
|
11
|
+
events: {
|
|
12
|
+
onLog: callbacks.onLog,
|
|
13
|
+
onStatus: callbacks.onStatus,
|
|
14
|
+
onPageNavigation: callbacks.onPageNavigation,
|
|
15
|
+
onPageLoad: callbacks.onPageLoad,
|
|
16
|
+
onPageIntl: callbacks.onPageIntl,
|
|
17
|
+
onAttach: callbacks.onAttach,
|
|
18
|
+
onTargetChanged: callbacks.onTargetChanged,
|
|
19
|
+
onDetach: () => {
|
|
20
|
+
callbacks.onDetach();
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
watcherId,
|
|
24
|
+
watcherHost: host,
|
|
25
|
+
watcherPort: record.port,
|
|
26
|
+
ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
|
|
27
|
+
stripUrlPrefixes,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
sourceHandle,
|
|
31
|
+
networkCapture: netBuffer ? createNetworkCapture({ session: sourceHandle.pageSession ?? sourceHandle.session, buffer: netBuffer }) : null,
|
|
32
|
+
traceRecorder: createTraceRecorder({ session: sourceHandle.session, artifactsDir: artifactsBaseDir }),
|
|
33
|
+
screenshotter: createScreenshotter({ session: sourceHandle.session, artifactsDir: artifactsBaseDir }),
|
|
34
|
+
runtimeEditor: createRuntimeEditor(sourceHandle.session),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const sourceHandle = createCdpSource({
|
|
38
|
+
chrome,
|
|
39
|
+
match: options.match,
|
|
40
|
+
sessionHandle,
|
|
41
|
+
events: {
|
|
42
|
+
onLog: callbacks.onLog,
|
|
43
|
+
onStatus: callbacks.onStatus,
|
|
44
|
+
onPageNavigation: callbacks.onPageNavigation,
|
|
45
|
+
onPageLoad: callbacks.onPageLoad,
|
|
46
|
+
onPageIntl: callbacks.onPageIntl,
|
|
47
|
+
onAttach: callbacks.onAttach,
|
|
48
|
+
onDetach: (reason) => {
|
|
49
|
+
callbacks.onDetach(reason);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
watcherId,
|
|
53
|
+
ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
|
|
54
|
+
stripUrlPrefixes,
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
sourceHandle,
|
|
58
|
+
networkCapture: netBuffer ? createNetworkCapture({ session: sessionHandle.session, buffer: netBuffer }) : null,
|
|
59
|
+
traceRecorder: createTraceRecorder({ session: sessionHandle.session, artifactsDir: artifactsBaseDir }),
|
|
60
|
+
screenshotter: createScreenshotter({ session: sessionHandle.session, artifactsDir: artifactsBaseDir }),
|
|
61
|
+
runtimeEditor: createRuntimeEditor(sessionHandle.session),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=watcherServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcherServices.js","sourceRoot":"","sources":["../../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E,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;QAC9G,aAAa,EAAE,mBAAmB,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;QACtG,aAAa,EAAE,mBAAmB,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;QACtG,aAAa,EAAE,mBAAmB,CAAC,aAAa,CAAC,OAAO,CAAC;KACzD,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WatcherChrome, WatcherRecord } from '@vforsh/argus-core';
|
|
2
|
+
import Emittery from 'emittery';
|
|
3
|
+
import { LogBuffer } from '../buffer/LogBuffer.js';
|
|
4
|
+
import { NetBuffer } from '../buffer/NetBuffer.js';
|
|
5
|
+
import { WatcherFileLogger } from '../fileLogs/WatcherFileLogger.js';
|
|
6
|
+
import { buildIgnoreMatcher } from '../cdp/ignoreList.js';
|
|
7
|
+
import { createCdpSessionHandle } from '../cdp/connection.js';
|
|
8
|
+
import { createEmulationController } from '../emulation/EmulationController.js';
|
|
9
|
+
import { createThrottleController } from '../throttle/ThrottleController.js';
|
|
10
|
+
import type { ArgusWatcherEventMap } from '../events.js';
|
|
11
|
+
import type { StartWatcherOptions } from '../index.js';
|
|
12
|
+
export type NormalizedWatcherSetup = {
|
|
13
|
+
sourceMode: NonNullable<StartWatcherOptions['source']>;
|
|
14
|
+
host: string;
|
|
15
|
+
port: number;
|
|
16
|
+
chrome: WatcherChrome;
|
|
17
|
+
watcherId: string;
|
|
18
|
+
startedAt: number;
|
|
19
|
+
artifactsBaseDir: string;
|
|
20
|
+
includeTimestamps: boolean;
|
|
21
|
+
netEnabled: boolean;
|
|
22
|
+
pageConsoleLogging: NonNullable<StartWatcherOptions['pageConsoleLogging']>;
|
|
23
|
+
ignoreMatcher: ReturnType<typeof buildIgnoreMatcher>;
|
|
24
|
+
stripUrlPrefixes: string[] | undefined;
|
|
25
|
+
events: Emittery<ArgusWatcherEventMap>;
|
|
26
|
+
buffer: LogBuffer;
|
|
27
|
+
netBuffer: NetBuffer | null;
|
|
28
|
+
record: WatcherRecord;
|
|
29
|
+
fileLogger: WatcherFileLogger | null;
|
|
30
|
+
sessionHandle: ReturnType<typeof createCdpSessionHandle>;
|
|
31
|
+
emulationController: ReturnType<typeof createEmulationController>;
|
|
32
|
+
throttleController: ReturnType<typeof createThrottleController>;
|
|
33
|
+
};
|
|
34
|
+
export declare const normalizeWatcherSetup: (options: StartWatcherOptions, watcherId: string) => NormalizedWatcherSetup;
|
|
35
|
+
//# sourceMappingURL=watcherSetup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcherSetup.d.ts","sourceRoot":"","sources":["../../src/runtime/watcherSetup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGtE,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,C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