pup-recorder 0.2.6 → 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,14 +62,6 @@ 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
67
  export declare function buildStegoHTML(targetURL: string, size: Size): string;
@@ -101,6 +100,10 @@ declare class ConcurrencyLimiter {
101
100
  export { ConcurrencyLimiter }
102
101
  export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
103
102
 
103
+ export declare function connectIpc(socketPath: string): Promise<IpcWriter>;
104
+
105
+ export declare function createIpcServer(socketPath: string): Promise<IpcServer>;
106
+
104
107
  export declare function createStegoURL(src: string, size: Size): string;
105
108
 
106
109
  export declare function decodeStego(bitmap: Buffer, size: Size): number | undefined;
@@ -117,7 +120,7 @@ declare const DEFAULT_HEIGHT = 1080;
117
120
  export { DEFAULT_HEIGHT }
118
121
  export { DEFAULT_HEIGHT as DEFAULT_HEIGHT_alias_1 }
119
122
 
120
- declare const DEFAULT_OUT_FILE = "output.mp4";
123
+ declare const DEFAULT_OUT_FILE = "output.mov";
121
124
  export { DEFAULT_OUT_FILE }
122
125
  export { DEFAULT_OUT_FILE as DEFAULT_OUT_FILE_alias_1 }
123
126
 
@@ -135,29 +138,24 @@ export declare function doProcess(timestampMs: number): string;
135
138
 
136
139
  export declare function electronOpts(): Promise<string[]>;
137
140
 
138
- export declare function encodeBgra({ summary, outFile, signal, onProgress }: EncodeBgraOptions): Promise<RenderResult>;
139
-
140
- export declare interface EncodeBgraOptions {
141
- summary: RenderResult;
142
- outFile: string;
143
- signal?: AbortSignal;
144
- onProgress?: PupProgressCallback;
145
- }
146
-
147
141
  declare class EncoderPipeline {
148
- private readonly _state;
149
- private readonly _sws;
150
- private readonly _srcFrame;
151
- 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;
152
150
  private _disposed;
153
151
  private constructor();
154
- static create({ width, height, fps, outFile, withAudio, videoBitrate, audioBitrate, }: EncoderPipelineOptions): Promise<EncoderPipeline>;
152
+ static create(opts: EncoderPipelineOptions): Promise<EncoderPipeline>;
155
153
  setupAudio(sampleRate: number): void;
156
- encodeFrame(input: Buffer | Frame): Promise<void>;
154
+ encodeFrame(input: Buffer): Promise<void>;
157
155
  encodeAudio(pcm: Buffer): Promise<void>;
158
156
  finish(): Promise<string>;
159
157
  [Symbol.asyncDispose](): Promise<void>;
160
- private freeShared;
158
+ private free;
161
159
  }
162
160
  export { EncoderPipeline }
163
161
  export { EncoderPipeline as EncoderPipeline_alias_1 }
@@ -168,8 +166,6 @@ declare interface EncoderPipelineOptions {
168
166
  fps: number;
169
167
  outFile: string;
170
168
  withAudio?: boolean;
171
- videoBitrate?: number;
172
- audioBitrate?: number;
173
169
  }
174
170
  export { EncoderPipelineOptions }
175
171
  export { EncoderPipelineOptions as EncoderPipelineOptions_alias_1 }
@@ -193,7 +189,7 @@ export declare const FixedBufferWriter: FixedBufferWriter;
193
189
  declare class FormatMuxer {
194
190
  private readonly _ctx;
195
191
  private _opened;
196
- constructor(outPath: string);
192
+ constructor(outPath: string, formatName?: string);
197
193
  addStream(codecCtx: CodecContext, codecTag?: string): ReturnType<FormatContext["newStream"]>;
198
194
  open(): Promise<void>;
199
195
  writePacket(pkt: Packet): Promise<void>;
@@ -238,6 +234,49 @@ export declare class FrameDropStats {
238
234
  finalize(): FrameDropScore;
239
235
  }
240
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
+
241
280
  export declare function isEmpty(image: NativeImage): boolean;
242
281
 
243
282
  declare class Lazy<T> {
@@ -251,7 +290,7 @@ declare class Lazy<T> {
251
290
  export { Lazy }
252
291
  export { Lazy as Lazy_alias_1 }
253
292
 
254
- export declare function loadWindow(source: string, options: RenderOptions): Promise<BrowserWindow>;
293
+ export declare function loadWindow({ source, onCreated, renderer }: WindowOptions): Promise<BrowserWindow>;
255
294
 
256
295
  declare class Logger implements LoggerLike {
257
296
  private _level;
@@ -350,6 +389,10 @@ declare const pupDisableGPU: boolean;
350
389
  export { pupDisableGPU }
351
390
  export { pupDisableGPU as pupDisableGPU_alias_1 }
352
391
 
392
+ declare const pupIpcSocket: string | undefined;
393
+ export { pupIpcSocket }
394
+ export { pupIpcSocket as pupIpcSocket_alias_1 }
395
+
353
396
  declare const pupLogLevel: number;
354
397
  export { pupLogLevel }
355
398
  export { pupLogLevel as pupLogLevel_alias_1 }
@@ -378,7 +421,7 @@ declare const pupUseInnerProxy: boolean;
378
421
  export { pupUseInnerProxy }
379
422
  export { pupUseInnerProxy as pupUseInnerProxy_alias_1 }
380
423
 
381
- export declare function render(source: string, options: RenderOptions): Promise<void>;
424
+ export declare function render(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
382
425
 
383
426
  declare type RenderOptions = z.infer<typeof RenderSchema>;
384
427
  export { RenderOptions }
@@ -389,7 +432,6 @@ declare interface RenderResult {
389
432
  written: number;
390
433
  jank: number;
391
434
  outFile: string;
392
- audio?: AudioSpec;
393
435
  }
394
436
  export { RenderResult }
395
437
  export { RenderResult as RenderResult_alias_1 }
@@ -415,15 +457,15 @@ declare interface RetryOptions<Args extends any[], Ret> {
415
457
  export { RetryOptions }
416
458
  export { RetryOptions as RetryOptions_alias_1 }
417
459
 
418
- export declare function runElectronApp(size: Size, args: unknown[]): Promise<ProcessHandle>;
460
+ export declare function runElectronApp(size: Size, args: unknown[], ipcSocketPath: string): Promise<ProcessHandle>;
419
461
 
420
462
  export declare function setInterceptor({ source, window, useInnerProxy }: NetworkOptions): void;
421
463
 
422
- export declare function setupAudioCapture(outDir: string, getVideoTimeMs: () => number): Promise<AudioCapture>;
464
+ export declare function setupAudioCapture({ encoder, getVideoTimeMs, onError, }: AudioCaptureOptions): Promise<AudioCapture>;
423
465
 
424
466
  export declare function setupPupProtocol(): void;
425
467
 
426
- export declare function shoot(source: string, options: RenderOptions): Promise<void>;
468
+ export declare function shoot(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
427
469
 
428
470
  declare function sleep(ms: number): Promise<void>;
429
471
  export { sleep }
@@ -464,6 +506,8 @@ export declare interface VideoEncoderOptions {
464
506
  globalHeader: boolean;
465
507
  codecOpts: Record<string, string>;
466
508
  bitrate: number;
509
+ pixelFormat: AVPixelFormat;
510
+ threadCount?: number;
467
511
  muxer: FormatMuxer;
468
512
  }
469
513
 
@@ -480,4 +524,11 @@ export declare interface WaitOptions {
480
524
  onTimeout?: () => void;
481
525
  }
482
526
 
527
+ export declare interface WindowOptions {
528
+ source: string;
529
+ onCreated?: (window: BrowserWindow) => Promise<void>;
530
+ renderer: RenderOptions;
531
+ warmup?: boolean;
532
+ }
533
+
483
534
  export { }