pup-recorder 0.2.5 → 0.2.7

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.
@@ -1,9 +1,11 @@
1
1
  import { AV_SAMPLE_FMT_FLT } from 'node-av/constants';
2
2
  import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
3
+ import { AVPixelFormat } from 'node-av/constants';
3
4
  import { BrowserWindow } from 'electron';
4
5
  import { ChildProcess } from 'child_process';
5
6
  import { CodecContext } from 'node-av';
6
7
  import type { Debugger } from 'electron';
8
+ import { EventEmitter } from 'events';
7
9
  import { FFAudioEncoder } from 'node-av/constants';
8
10
  import { FFVideoEncoder } from 'node-av/constants';
9
11
  import { FormatContext } from 'node-av';
@@ -11,23 +13,30 @@ import { Frame } from 'node-av';
11
13
  import type { NativeImage } from 'electron';
12
14
  import { Packet } from 'node-av';
13
15
  import { Size } from 'electron';
16
+ import { Socket } from 'net';
14
17
  import { SpawnOptions } from 'child_process';
15
18
  import z from 'zod';
16
19
 
17
20
  export declare function advanceVirtualTime(cdp: Debugger, budget: number): Promise<void>;
18
21
 
19
22
  export declare interface AudioCapture {
20
- teardown(): Promise<AudioSpec | undefined>;
23
+ teardown(): Promise<void>;
24
+ }
25
+
26
+ export declare interface AudioCaptureOptions {
27
+ encoder: EncoderPipeline;
28
+ getVideoTimeMs: () => number;
29
+ onError: (error: Error) => void;
21
30
  }
22
31
 
23
32
  declare class AudioEncoder_2 implements Disposable {
24
- private readonly _ctx;
25
- private readonly _stream;
26
- private readonly _outRate;
27
- private readonly _outFmt;
28
- private readonly _frameSize;
29
- private readonly _pkt;
30
- private readonly _filterFrame;
33
+ private _ctx;
34
+ private _stream;
35
+ private _pkt;
36
+ private _outRate;
37
+ private _outFmt;
38
+ private _frameSize;
39
+ private _filterFrame;
31
40
  private _graph?;
32
41
  private _bufSrc?;
33
42
  private _bufSink?;
@@ -35,14 +44,12 @@ declare class AudioEncoder_2 implements Disposable {
35
44
  private _pts;
36
45
  private constructor();
37
46
  static create(opts: AudioEncoderOptions): Promise<AudioEncoder_2>;
38
- /** Must be called once when the page's actual sample rate is known. */
39
47
  setInputRate(inSampleRate: number): void;
40
48
  encode(pcm: Buffer, muxer: FormatMuxer): Promise<void>;
41
49
  flush(muxer: FormatMuxer): Promise<void>;
42
50
  [Symbol.dispose](): void;
43
- private drainFilter;
51
+ private drain;
44
52
  private drainCodec;
45
- private disposeGraph;
46
53
  }
47
54
  export { AudioEncoder_2 as AudioEncoder }
48
55
 
@@ -55,23 +62,27 @@ export declare interface AudioEncoderOptions {
55
62
  muxer: FormatMuxer;
56
63
  }
57
64
 
58
- declare interface AudioSpec {
59
- pcmFile: string;
60
- pcmStartMs: number;
61
- pcmSampleRate: number;
62
- }
63
- export { AudioSpec }
64
- export { AudioSpec as AudioSpec_alias_1 }
65
-
66
65
  export declare function buildRust(): Promise<void>;
67
66
 
68
- export declare function buildWrapperHTML(targetURL: string, size: Size): string;
67
+ export declare function buildStegoHTML(targetURL: string, size: Size): string;
68
+
69
+ /**
70
+ * Builds the JS injector that hooks all time-related globals in the target iframe.
71
+ * Guards against running in the wrapper (top-level) frame so the stego canvas is unaffected.
72
+ * Must be injected via Page.addScriptToEvaluateOnNewDocument AND directly into
73
+ * already-loaded sub-frames.
74
+ */
75
+ export declare function buildTickInjector(): string;
69
76
 
70
77
  export declare const canIUseGPU: Promise<boolean>;
71
78
 
72
79
  export declare function checkHTML(source: string): void;
73
80
 
74
- export declare type CLICallback = (source: string, options: RenderOptions) => Promise<unknown>;
81
+ export declare interface CLIOptions {
82
+ name: string;
83
+ defaults: RenderOptions;
84
+ run: (source: string, options: RenderOptions) => Promise<unknown>;
85
+ }
75
86
 
76
87
  declare class ConcurrencyLimiter {
77
88
  readonly maxConcurrency: number;
@@ -89,7 +100,13 @@ declare class ConcurrencyLimiter {
89
100
  export { ConcurrencyLimiter }
90
101
  export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
91
102
 
92
- export declare function decodeTimestamp(bitmap: Buffer, size: Size): number | undefined;
103
+ export declare function connectIpc(socketPath: string): Promise<IpcWriter>;
104
+
105
+ export declare function createIpcServer(socketPath: string): Promise<IpcServer>;
106
+
107
+ export declare function createStegoURL(src: string, size: Size): string;
108
+
109
+ export declare function decodeStego(bitmap: Buffer, size: Size): number | undefined;
93
110
 
94
111
  declare const DEFAULT_DURATION = 5;
95
112
  export { DEFAULT_DURATION }
@@ -103,7 +120,7 @@ declare const DEFAULT_HEIGHT = 1080;
103
120
  export { DEFAULT_HEIGHT }
104
121
  export { DEFAULT_HEIGHT as DEFAULT_HEIGHT_alias_1 }
105
122
 
106
- declare const DEFAULT_OUT_FILE = "output.mp4";
123
+ declare const DEFAULT_OUT_FILE = "output.mov";
107
124
  export { DEFAULT_OUT_FILE }
108
125
  export { DEFAULT_OUT_FILE as DEFAULT_OUT_FILE_alias_1 }
109
126
 
@@ -111,31 +128,34 @@ declare const DEFAULT_WIDTH = 1920;
111
128
  export { DEFAULT_WIDTH }
112
129
  export { DEFAULT_WIDTH as DEFAULT_WIDTH_alias_1 }
113
130
 
114
- export declare function electronOpts(): Promise<string[]>;
131
+ declare const defaultRenderOptions: RenderOptions;
132
+ export { defaultRenderOptions }
133
+ export { defaultRenderOptions as defaultRenderOptions_alias_1 }
115
134
 
116
- export declare function encodeBgra({ summary, outFile, signal, onProgress }: EncodeBgraOptions): Promise<RenderResult>;
135
+ export declare function doEject(): string;
117
136
 
118
- export declare interface EncodeBgraOptions {
119
- summary: RenderResult;
120
- outFile: string;
121
- signal?: AbortSignal;
122
- onProgress?: PupProgressCallback;
123
- }
137
+ export declare function doProcess(timestampMs: number): string;
138
+
139
+ export declare function electronOpts(): Promise<string[]>;
124
140
 
125
141
  declare class EncoderPipeline {
126
- private readonly _state;
127
- private readonly _sws;
128
- private readonly _srcFrame;
129
- private readonly _yuvaFrame;
142
+ private _video;
143
+ private _audio;
144
+ private _muxer;
145
+ private _limiter;
146
+ private _outFile;
147
+ private _sws;
148
+ private _srcFrame;
149
+ private _dstFrame;
130
150
  private _disposed;
131
151
  private constructor();
132
- static create({ width, height, fps, outFile, withAudio, videoBitrate, audioBitrate, }: EncoderPipelineOptions): Promise<EncoderPipeline>;
152
+ static create(opts: EncoderPipelineOptions): Promise<EncoderPipeline>;
133
153
  setupAudio(sampleRate: number): void;
134
- encodeFrame(input: Buffer | Frame): Promise<void>;
154
+ encodeFrame(input: Buffer): Promise<void>;
135
155
  encodeAudio(pcm: Buffer): Promise<void>;
136
156
  finish(): Promise<string>;
137
157
  [Symbol.asyncDispose](): Promise<void>;
138
- private freeShared;
158
+ private free;
139
159
  }
140
160
  export { EncoderPipeline }
141
161
  export { EncoderPipeline as EncoderPipeline_alias_1 }
@@ -146,8 +166,6 @@ declare interface EncoderPipelineOptions {
146
166
  fps: number;
147
167
  outFile: string;
148
168
  withAudio?: boolean;
149
- videoBitrate?: number;
150
- audioBitrate?: number;
151
169
  }
152
170
  export { EncoderPipelineOptions }
153
171
  export { EncoderPipelineOptions as EncoderPipelineOptions_alias_1 }
@@ -171,7 +189,7 @@ export declare const FixedBufferWriter: FixedBufferWriter;
171
189
  declare class FormatMuxer {
172
190
  private readonly _ctx;
173
191
  private _opened;
174
- constructor(outPath: string);
192
+ constructor(outPath: string, formatName?: string);
175
193
  addStream(codecCtx: CodecContext, codecTag?: string): ReturnType<FormatContext["newStream"]>;
176
194
  open(): Promise<void>;
177
195
  writePacket(pkt: Packet): Promise<void>;
@@ -216,6 +234,49 @@ export declare class FrameDropStats {
216
234
  finalize(): FrameDropScore;
217
235
  }
218
236
 
237
+ export declare interface IpcDonePayload {
238
+ written: number;
239
+ jank: number;
240
+ outFile: string;
241
+ }
242
+
243
+ export declare const enum IpcMsgType {
244
+ PROGRESS = 1,
245
+ DONE = 2,
246
+ ERROR = 3
247
+ }
248
+
249
+ export declare class IpcReader extends EventEmitter<{
250
+ progress: [value: number];
251
+ message: [type: IpcMsgType, buffer: Buffer];
252
+ done: [payload: IpcDonePayload];
253
+ error: [error: Error];
254
+ close: [];
255
+ }> {
256
+ private readonly _socket;
257
+ private _chunks;
258
+ private _buffered;
259
+ constructor(_socket: Socket);
260
+ private onData;
261
+ private flush;
262
+ private peek;
263
+ private consume;
264
+ }
265
+
266
+ export declare interface IpcServer {
267
+ waitForConnection(): Promise<IpcReader>;
268
+ close(): void;
269
+ }
270
+
271
+ export declare class IpcWriter {
272
+ private readonly _socket;
273
+ constructor(_socket: Socket);
274
+ writeProgress(value: number): void;
275
+ writeError(error: string): void;
276
+ writeDone(payload: IpcDonePayload): void;
277
+ private write;
278
+ }
279
+
219
280
  export declare function isEmpty(image: NativeImage): boolean;
220
281
 
221
282
  declare class Lazy<T> {
@@ -229,7 +290,7 @@ declare class Lazy<T> {
229
290
  export { Lazy }
230
291
  export { Lazy as Lazy_alias_1 }
231
292
 
232
- export declare function loadWindow(source: string, options: RenderOptions): Promise<BrowserWindow>;
293
+ export declare function loadWindow({ source, onCreated, renderer }: WindowOptions): Promise<BrowserWindow>;
233
294
 
234
295
  declare class Logger implements LoggerLike {
235
296
  private _level;
@@ -263,7 +324,7 @@ declare interface LoggerLike {
263
324
  export { LoggerLike }
264
325
  export { LoggerLike as LoggerLike_alias_1 }
265
326
 
266
- export declare function makeCLI(name: string, callback: CLICallback): Promise<void>;
327
+ export declare function makeCLI(options: CLIOptions): Promise<void>;
267
328
 
268
329
  export declare interface NetworkOptions {
269
330
  source: string;
@@ -287,6 +348,8 @@ declare function parseString(x: unknown): string;
287
348
  export { parseString }
288
349
  export { parseString as parseString_alias_1 }
289
350
 
351
+ export declare function pauseVirtualTime(cdp: Debugger): Promise<void>;
352
+
290
353
  declare function penv<T>(name: string, parser: EnvParser<T>, defaultValue: T): T;
291
354
 
292
355
  declare function penv<T>(name: string, parser: EnvParser<T>, defaultValue?: T): T | undefined;
@@ -306,7 +369,7 @@ export { ProcessHandle as ProcessHandle_alias_1 }
306
369
 
307
370
  export declare function proxiedUrl(url: string): string;
308
371
 
309
- declare function pup(source: string, options: PupOptions): Promise<PupResult>;
372
+ declare function pup(source: string, options: Partial<PupOptions>): Promise<PupResult>;
310
373
  export { pup }
311
374
  export { pup as pup_alias_1 }
312
375
 
@@ -326,6 +389,10 @@ declare const pupDisableGPU: boolean;
326
389
  export { pupDisableGPU }
327
390
  export { pupDisableGPU as pupDisableGPU_alias_1 }
328
391
 
392
+ declare const pupIpcSocket: string | undefined;
393
+ export { pupIpcSocket }
394
+ export { pupIpcSocket as pupIpcSocket_alias_1 }
395
+
329
396
  declare const pupLogLevel: number;
330
397
  export { pupLogLevel }
331
398
  export { pupLogLevel as pupLogLevel_alias_1 }
@@ -354,7 +421,7 @@ declare const pupUseInnerProxy: boolean;
354
421
  export { pupUseInnerProxy }
355
422
  export { pupUseInnerProxy as pupUseInnerProxy_alias_1 }
356
423
 
357
- export declare function render(source: string, options: RenderOptions): Promise<void>;
424
+ export declare function render(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
358
425
 
359
426
  declare type RenderOptions = z.infer<typeof RenderSchema>;
360
427
  export { RenderOptions }
@@ -365,20 +432,19 @@ declare interface RenderResult {
365
432
  written: number;
366
433
  jank: number;
367
434
  outFile: string;
368
- audio?: AudioSpec;
369
435
  }
370
436
  export { RenderResult }
371
437
  export { RenderResult as RenderResult_alias_1 }
372
438
 
373
439
  declare const RenderSchema: z.ZodObject<{
374
- duration: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
375
- width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
376
- height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
377
- fps: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
378
- withAudio: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
379
- outFile: z.ZodDefault<z.ZodOptional<z.ZodString>>;
380
- useInnerProxy: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
381
- deterministic: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
440
+ duration: z.ZodNumber;
441
+ width: z.ZodNumber;
442
+ height: z.ZodNumber;
443
+ fps: z.ZodNumber;
444
+ withAudio: z.ZodBoolean;
445
+ outFile: z.ZodString;
446
+ useInnerProxy: z.ZodBoolean;
447
+ deterministic: z.ZodBoolean;
382
448
  }, z.core.$strip>;
383
449
  export { RenderSchema }
384
450
  export { RenderSchema as RenderSchema_alias_1 }
@@ -391,21 +457,25 @@ declare interface RetryOptions<Args extends any[], Ret> {
391
457
  export { RetryOptions }
392
458
  export { RetryOptions as RetryOptions_alias_1 }
393
459
 
394
- export declare function runElectronApp(size: Size, args: unknown[]): Promise<ProcessHandle>;
460
+ export declare function runElectronApp(size: Size, args: unknown[], ipcSocketPath: string): Promise<ProcessHandle>;
395
461
 
396
462
  export declare function setInterceptor({ source, window, useInnerProxy }: NetworkOptions): void;
397
463
 
398
- export declare function setupAudioCapture(outDir: string, getVideoTimeMs: () => number): Promise<AudioCapture>;
464
+ export declare function setupAudioCapture({ encoder, getVideoTimeMs, onError, }: AudioCaptureOptions): Promise<AudioCapture>;
399
465
 
400
- export declare function shoot(source: string, options: RenderOptions): Promise<void>;
466
+ export declare function setupPupProtocol(): void;
467
+
468
+ export declare function shoot(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
401
469
 
402
470
  declare function sleep(ms: number): Promise<void>;
403
471
  export { sleep }
404
472
  export { sleep as sleep_alias_1 }
405
473
 
406
- export declare function startSync(cdp: Debugger): Promise<any>;
474
+ export declare function startStego(cdp: Debugger): Promise<any>;
475
+
476
+ export declare function stopStego(cdp: Debugger): Promise<any>;
407
477
 
408
- export declare function stopSync(cdp: Debugger): Promise<any>;
478
+ export declare const TICK_SYMBOL = "__pup_tick__";
409
479
 
410
480
  export declare function unsetInterceptor(window: BrowserWindow): void;
411
481
 
@@ -436,6 +506,8 @@ export declare interface VideoEncoderOptions {
436
506
  globalHeader: boolean;
437
507
  codecOpts: Record<string, string>;
438
508
  bitrate: number;
509
+ pixelFormat: AVPixelFormat;
510
+ threadCount?: number;
439
511
  muxer: FormatMuxer;
440
512
  }
441
513
 
@@ -452,4 +524,11 @@ export declare interface WaitOptions {
452
524
  onTimeout?: () => void;
453
525
  }
454
526
 
527
+ export declare interface WindowOptions {
528
+ source: string;
529
+ onCreated?: (window: BrowserWindow) => Promise<void>;
530
+ renderer: RenderOptions;
531
+ warmup?: boolean;
532
+ }
533
+
455
534
  export { }