@saptools/cf-inspector 0.7.1 → 0.8.1
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 +54 -1
- package/dist/cli.js +236 -27
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +28 -6
- package/dist/index.js +61 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -193,6 +193,15 @@ type InspectorIsolate = {
|
|
|
193
193
|
readonly kind: "worker";
|
|
194
194
|
readonly workerId: string;
|
|
195
195
|
};
|
|
196
|
+
type ArmedCommand = "snapshot" | "watch" | "exception" | "log";
|
|
197
|
+
interface ArmedEvent {
|
|
198
|
+
readonly event: "breakpoint-armed";
|
|
199
|
+
readonly schemaVersion: 1;
|
|
200
|
+
readonly command: ArmedCommand;
|
|
201
|
+
readonly sessions: number;
|
|
202
|
+
readonly resolvedLocations: number | null;
|
|
203
|
+
readonly timeoutMs: number | null;
|
|
204
|
+
}
|
|
196
205
|
interface ScriptInfo {
|
|
197
206
|
readonly scriptId: string;
|
|
198
207
|
readonly url: string;
|
|
@@ -210,6 +219,9 @@ interface ScriptInfo {
|
|
|
210
219
|
readonly length?: number;
|
|
211
220
|
readonly stackTrace?: StackTraceInfo;
|
|
212
221
|
}
|
|
222
|
+
interface ListedScriptInfo extends ScriptInfo {
|
|
223
|
+
readonly isolate: InspectorIsolate;
|
|
224
|
+
}
|
|
213
225
|
interface InspectorConnectOptions {
|
|
214
226
|
readonly port: number;
|
|
215
227
|
readonly host?: string;
|
|
@@ -409,6 +421,14 @@ declare function waitForPause(session: InspectorSession, options: WaitForPauseOp
|
|
|
409
421
|
interface SessionBreakpointSetup {
|
|
410
422
|
readonly handles: readonly BreakpointHandle[];
|
|
411
423
|
}
|
|
424
|
+
interface SessionBreakpointOutcome {
|
|
425
|
+
readonly session: InspectorSession;
|
|
426
|
+
readonly setup: SessionBreakpointSetup;
|
|
427
|
+
}
|
|
428
|
+
interface FanoutReadyOptions {
|
|
429
|
+
readonly includeNewSessions?: boolean;
|
|
430
|
+
readonly onReady?: (outcomes: readonly SessionBreakpointOutcome[]) => void;
|
|
431
|
+
}
|
|
412
432
|
interface IsolatePause {
|
|
413
433
|
readonly session: InspectorSession;
|
|
414
434
|
readonly pause: PauseEvent;
|
|
@@ -426,13 +446,14 @@ declare class BreakpointFanout {
|
|
|
426
446
|
private readonly detachError;
|
|
427
447
|
private activeRace;
|
|
428
448
|
private pauseReasons;
|
|
449
|
+
private pendingSetupError;
|
|
450
|
+
private preserveReadinessErrors;
|
|
429
451
|
constructor(group: InspectorSessionGroup, setupSession: (session: InspectorSession, trackHandle: (handle: BreakpointHandle) => void) => Promise<SessionBreakpointSetup>, pauseReasons?: readonly string[]);
|
|
430
|
-
ready(): Promise<void>;
|
|
452
|
+
ready(options?: FanoutReadyOptions): Promise<void>;
|
|
431
453
|
trackHandle(session: InspectorSession, handle: BreakpointHandle): void;
|
|
432
|
-
availableOutcomes(): readonly
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}[];
|
|
454
|
+
availableOutcomes(): readonly SessionBreakpointOutcome[];
|
|
455
|
+
private outcomesFor;
|
|
456
|
+
private takePendingSetupError;
|
|
436
457
|
waitForFirst(timeoutMs: number, options?: Omit<WaitForPauseOptions, "timeoutMs" | "breakpointIds" | "signal">, signal?: AbortSignal): Promise<IsolatePause>;
|
|
437
458
|
resumePaused(except?: InspectorSession): Promise<number>;
|
|
438
459
|
cleanup(timeoutMs?: number, preservePaused?: InspectorSession): Promise<FanoutCleanupSummary>;
|
|
@@ -516,6 +537,7 @@ interface LogpointStreamOptions {
|
|
|
516
537
|
readonly condition?: string;
|
|
517
538
|
readonly maxValueLength?: number;
|
|
518
539
|
readonly signal?: AbortSignal;
|
|
540
|
+
readonly eventGate?: () => boolean;
|
|
519
541
|
readonly onEvent: (event: LogpointEvent) => void;
|
|
520
542
|
readonly onBreakpointSet?: (handle: BreakpointHandle) => void;
|
|
521
543
|
}
|
|
@@ -551,4 +573,4 @@ interface OpenedTunnel {
|
|
|
551
573
|
declare function openOwnedCfTunnel(target: TunnelTarget): Promise<OpenedTunnel>;
|
|
552
574
|
declare function openCfTunnel(target: TunnelTarget): Promise<OpenedTunnel>;
|
|
553
575
|
|
|
554
|
-
export { type BreakLocation, BreakpointFanout, type BreakpointHandle, type BreakpointLocation, type CallFrameInfo, type CaptureSnapshotOptions, type CapturedExpression, CfInspectorError, type CfInspectorErrorCode, type DebuggerState, type EvaluateOnFrameOptions, type ExactBreakpointHandle, type ExceptionSnapshot, type FrameSnapshot, type GetPossibleBreakpointsOptions, type InspectorConnectOptions, type InspectorIsolate, type InspectorSession, type InspectorSessionGroup, type InspectorTarget, type InspectorWorkerTarget, type LogpointConditionOptions, type LogpointEvent, type LogpointStopReason, type LogpointStreamOptions, type LogpointStreamResult, type OpenedTunnel, type PauseEvent, type PauseOnExceptionsState, type RemoteObjectInfo, type RemoteRootSetting, type ResolvedLocation, type ScopeInfo, type ScopeSnapshot, type ScriptInfo, type ScriptLocation, type SetBreakpointAtLocationInput, type SetBreakpointInput, type SnapshotCaptureResult, type SnapshotResult, type StackTraceFrameInfo, type StackTraceIdInfo, type StackTraceInfo, type StepIntoOptions, type TunnelTarget, type VariableSnapshot, type WaitForPauseOptions, type WalkStackOptions, type WatchEvent, buildBreakpointUrlRegex, buildHitCountedCondition, buildLogpointCondition, captureException, captureSnapshot, connectInspector, connectInspectorGroup, discoverInspectorTargets, evaluateGlobal, evaluateOnFrame, fetchInspectorVersion, getPossibleBreakpoints, getProperties, getScriptSource, listScripts, openCfTunnel, openOwnedCfTunnel, parseBreakpointSpec, parseRemoteRoot, releaseObject, releaseObjectGroup, removeBreakpoint, resume, runSetupEvals, setAsyncCallStackDepth, setBreakpoint, setBreakpointAtLocation, setPauseOnExceptions, startInspectorKeepalive, stepInto, stepOut, stepOver, streamLogpoint, validateExpression, waitForPause, walkStack };
|
|
576
|
+
export { type ArmedCommand, type ArmedEvent, type BreakLocation, BreakpointFanout, type BreakpointHandle, type BreakpointLocation, type CallFrameInfo, type CaptureSnapshotOptions, type CapturedExpression, CfInspectorError, type CfInspectorErrorCode, type DebuggerState, type EvaluateOnFrameOptions, type ExactBreakpointHandle, type ExceptionSnapshot, type FanoutReadyOptions, type FrameSnapshot, type GetPossibleBreakpointsOptions, type InspectorConnectOptions, type InspectorIsolate, type InspectorSession, type InspectorSessionGroup, type InspectorTarget, type InspectorWorkerTarget, type ListedScriptInfo, type LogpointConditionOptions, type LogpointEvent, type LogpointStopReason, type LogpointStreamOptions, type LogpointStreamResult, type OpenedTunnel, type PauseEvent, type PauseOnExceptionsState, type RemoteObjectInfo, type RemoteRootSetting, type ResolvedLocation, type ScopeInfo, type ScopeSnapshot, type ScriptInfo, type ScriptLocation, type SessionBreakpointOutcome, type SetBreakpointAtLocationInput, type SetBreakpointInput, type SnapshotCaptureResult, type SnapshotResult, type StackTraceFrameInfo, type StackTraceIdInfo, type StackTraceInfo, type StepIntoOptions, type TunnelTarget, type VariableSnapshot, type WaitForPauseOptions, type WalkStackOptions, type WatchEvent, buildBreakpointUrlRegex, buildHitCountedCondition, buildLogpointCondition, captureException, captureSnapshot, connectInspector, connectInspectorGroup, discoverInspectorTargets, evaluateGlobal, evaluateOnFrame, fetchInspectorVersion, getPossibleBreakpoints, getProperties, getScriptSource, listScripts, openCfTunnel, openOwnedCfTunnel, parseBreakpointSpec, parseRemoteRoot, releaseObject, releaseObjectGroup, removeBreakpoint, resume, runSetupEvals, setAsyncCallStackDepth, setBreakpoint, setBreakpointAtLocation, setPauseOnExceptions, startInspectorKeepalive, stepInto, stepOut, stepOver, streamLogpoint, validateExpression, waitForPause, walkStack };
|
package/dist/index.js
CHANGED
|
@@ -1220,6 +1220,8 @@ var BreakpointFanout = class {
|
|
|
1220
1220
|
detachError;
|
|
1221
1221
|
activeRace;
|
|
1222
1222
|
pauseReasons = [];
|
|
1223
|
+
pendingSetupError;
|
|
1224
|
+
preserveReadinessErrors = false;
|
|
1223
1225
|
constructor(group, setupSession, pauseReasons = []) {
|
|
1224
1226
|
this.pauseReasons = pauseReasons;
|
|
1225
1227
|
this.detach = group.onSession((session) => {
|
|
@@ -1245,13 +1247,51 @@ var BreakpointFanout = class {
|
|
|
1245
1247
|
this.activeRace?.remove(session);
|
|
1246
1248
|
});
|
|
1247
1249
|
this.detachError = group.onError((error) => {
|
|
1250
|
+
if (this.setupErrors.length === 0 && this.pendingSetupError === void 0) {
|
|
1251
|
+
this.pendingSetupError = error;
|
|
1252
|
+
}
|
|
1248
1253
|
for (const reject of this.setupErrors) {
|
|
1249
1254
|
reject(error);
|
|
1250
1255
|
}
|
|
1251
1256
|
});
|
|
1252
1257
|
}
|
|
1253
|
-
async ready() {
|
|
1254
|
-
|
|
1258
|
+
async ready(options = {}) {
|
|
1259
|
+
if (options.includeNewSessions !== true) {
|
|
1260
|
+
const records = [...this.records.values()];
|
|
1261
|
+
await Promise.all(records.map((record) => record.setup));
|
|
1262
|
+
options.onReady?.(this.outcomesFor(records));
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
this.preserveReadinessErrors = true;
|
|
1266
|
+
const pendingError = this.takePendingSetupError();
|
|
1267
|
+
if (pendingError !== void 0) {
|
|
1268
|
+
throw pendingError;
|
|
1269
|
+
}
|
|
1270
|
+
let rejectGroupError = () => void 0;
|
|
1271
|
+
const groupError = new Promise((_resolve, reject) => {
|
|
1272
|
+
rejectGroupError = reject;
|
|
1273
|
+
});
|
|
1274
|
+
this.setupErrors.push(rejectGroupError);
|
|
1275
|
+
try {
|
|
1276
|
+
let stableRecords;
|
|
1277
|
+
while (stableRecords === void 0) {
|
|
1278
|
+
const records = [...this.records.values()];
|
|
1279
|
+
await Promise.race([
|
|
1280
|
+
Promise.all(records.map((record) => record.setup)),
|
|
1281
|
+
groupError
|
|
1282
|
+
]);
|
|
1283
|
+
const stable = records.length === this.records.size && records.every((record) => this.records.get(record.session) === record);
|
|
1284
|
+
if (stable) {
|
|
1285
|
+
stableRecords = records;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
options.onReady?.(this.outcomesFor(stableRecords));
|
|
1289
|
+
} finally {
|
|
1290
|
+
const index = this.setupErrors.indexOf(rejectGroupError);
|
|
1291
|
+
if (index >= 0) {
|
|
1292
|
+
this.setupErrors.splice(index, 1);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1255
1295
|
}
|
|
1256
1296
|
trackHandle(session, handle) {
|
|
1257
1297
|
const record = this.records.get(session);
|
|
@@ -1260,11 +1300,19 @@ var BreakpointFanout = class {
|
|
|
1260
1300
|
}
|
|
1261
1301
|
}
|
|
1262
1302
|
availableOutcomes() {
|
|
1263
|
-
return [...this.records.values()]
|
|
1303
|
+
return this.outcomesFor([...this.records.values()]);
|
|
1304
|
+
}
|
|
1305
|
+
outcomesFor(records) {
|
|
1306
|
+
return records.map((record) => ({
|
|
1264
1307
|
session: record.session,
|
|
1265
1308
|
setup: { handles: record.handles }
|
|
1266
1309
|
}));
|
|
1267
1310
|
}
|
|
1311
|
+
takePendingSetupError() {
|
|
1312
|
+
const error = this.pendingSetupError;
|
|
1313
|
+
this.pendingSetupError = void 0;
|
|
1314
|
+
return error;
|
|
1315
|
+
}
|
|
1268
1316
|
async waitForFirst(timeoutMs, options = {}, signal) {
|
|
1269
1317
|
if (this.activeRace !== void 0) {
|
|
1270
1318
|
throw new CfInspectorError("INVALID_ARGUMENT", "A fan-out pause race is already active");
|
|
@@ -1273,6 +1321,12 @@ var BreakpointFanout = class {
|
|
|
1273
1321
|
this.pauseReasons = options.pauseReasons ?? [];
|
|
1274
1322
|
this.activeRace = race;
|
|
1275
1323
|
this.setupErrors.push(race.reject);
|
|
1324
|
+
if (this.preserveReadinessErrors) {
|
|
1325
|
+
const pendingError = this.takePendingSetupError();
|
|
1326
|
+
if (pendingError !== void 0) {
|
|
1327
|
+
race.reject(pendingError);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1276
1330
|
for (const record of this.records.values()) {
|
|
1277
1331
|
race.add(record);
|
|
1278
1332
|
}
|
|
@@ -1472,7 +1526,7 @@ import { performance as performance4 } from "perf_hooks";
|
|
|
1472
1526
|
// src/cdp/client.ts
|
|
1473
1527
|
init_types();
|
|
1474
1528
|
import { EventEmitter } from "events";
|
|
1475
|
-
var DEFAULT_REQUEST_TIMEOUT_MS =
|
|
1529
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
|
|
1476
1530
|
function parseMessage(raw) {
|
|
1477
1531
|
try {
|
|
1478
1532
|
const value = JSON.parse(raw);
|
|
@@ -3227,6 +3281,9 @@ async function streamLogpoint(session, options) {
|
|
|
3227
3281
|
if (event === void 0) {
|
|
3228
3282
|
return;
|
|
3229
3283
|
}
|
|
3284
|
+
if (options.eventGate?.() === false) {
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
3230
3287
|
emitted += 1;
|
|
3231
3288
|
try {
|
|
3232
3289
|
options.onEvent(event);
|