pup-recorder 0.3.3 → 0.3.5

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.
@@ -6,21 +6,21 @@ import { BrowserWindow } from 'electron';
6
6
  import { ChildProcess } from 'child_process';
7
7
  import { Codec } from 'node-av';
8
8
  import { CodecContext } from 'node-av';
9
- import type { Debugger } from 'electron';
9
+ import { Debugger } from 'electron';
10
10
  import { EventEmitter } from 'events';
11
11
  import { FFAudioEncoder } from 'node-av/constants';
12
12
  import { FFVideoEncoder } from 'node-av/constants';
13
13
  import { FormatContext } from 'node-av';
14
14
  import { Frame } from 'node-av';
15
15
  import { HardwareContext } from 'node-av/api';
16
+ import { HardwareFramesContext } from 'node-av';
16
17
  import type { NativeImage } from 'electron';
17
18
  import { Packet } from 'node-av';
18
19
  import { Size } from 'electron';
19
- import { Socket } from 'net';
20
20
  import { SoftwareScaleContext } from 'node-av';
21
21
  import { SpawnOptions } from 'child_process';
22
22
  import { Stream } from 'node-av';
23
- import { WebFrameMain } from 'electron';
23
+ import type { WebFrameMain } from 'electron';
24
24
  import z from 'zod';
25
25
 
26
26
  /** Insert emulation prevention bytes (00 00 03) for Annex B compliance. */
@@ -156,14 +156,10 @@ declare class ConcurrencyLimiter {
156
156
  export { ConcurrencyLimiter }
157
157
  export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
158
158
 
159
- export declare function connectIpc(socketPath: string): Promise<IpcWriter>;
160
-
161
- export declare function createIpcServer(socketPath: string): Promise<IpcServer>;
159
+ export declare function createHwVideoEncoder(opts: HwVideoFactoryOptions, muxer: FormatMuxer): Promise<VideoSetup>;
162
160
 
163
161
  export declare function createStegoURL(src: string, size: Size): string;
164
162
 
165
- export declare function createVideoEncoder(opts: VideoFactoryOptions, muxer: FormatMuxer): Promise<VideoSetup>;
166
-
167
163
  export declare function debounce<T extends (...args: unknown[]) => void>(fn: T, delay?: number): T;
168
164
 
169
165
  export declare function decodeStego(bitmap: Buffer, size: Size): number | undefined;
@@ -192,6 +188,13 @@ declare const defaultRenderOptions: RenderOptions;
192
188
  export { defaultRenderOptions }
193
189
  export { defaultRenderOptions as defaultRenderOptions_alias_1 }
194
190
 
191
+ export declare function disposeWindow(win: BrowserWindow): Promise<void>;
192
+
193
+ export declare interface DoneMsg {
194
+ type: IpcMsgType.DONE;
195
+ payload: IpcDonePayload;
196
+ }
197
+
195
198
  export declare function drainPackets(ctx: CodecContext, pkt: Packet, stream: Stream, muxer: FormatMuxer): Promise<void>;
196
199
 
197
200
  export declare function electronOpts(disableGpu: boolean): Promise<string[]>;
@@ -207,7 +210,7 @@ declare class EncoderPipeline {
207
210
  encodeBGRA(input: Buffer): Promise<void>;
208
211
  encodePNG(pngData: Buffer): Promise<void>;
209
212
  encodeAudio(pcm: Buffer): Promise<void>;
210
- finish(): Promise<string>;
213
+ finish(): Promise<string[]>;
211
214
  [Symbol.asyncDispose](): Promise<void>;
212
215
  private free;
213
216
  private bgraFrame;
@@ -230,10 +233,17 @@ declare type EnvParser<T> = (value: unknown) => T;
230
233
  export { EnvParser }
231
234
  export { EnvParser as EnvParser_alias_1 }
232
235
 
236
+ export declare interface ErrorMsg {
237
+ type: IpcMsgType.ERROR;
238
+ error: string;
239
+ }
240
+
233
241
  declare function exec(cmd: string, options?: SpawnOptions): ProcessHandle;
234
242
  export { exec }
235
243
  export { exec as exec_alias_1 }
236
244
 
245
+ export declare function extractAlphaToYuv420pBuffer(bgraFrame: Frame, buf: Buffer): void;
246
+
237
247
  export declare interface FixedBufferWriter {
238
248
  new (path: string, bufferSize: number, queueDepth?: number): FixedBufferWriter;
239
249
  write(buffer: Buffer): void;
@@ -301,6 +311,15 @@ export declare interface HwVideoEncoderOptions {
301
311
  muxer: FormatMuxer;
302
312
  }
303
313
 
314
+ export declare interface HwVideoFactoryOptions {
315
+ width: number;
316
+ height: number;
317
+ fps: number;
318
+ bitrate?: number;
319
+ disableHwCodec?: boolean;
320
+ sharedHw?: HardwareContext;
321
+ }
322
+
304
323
  export declare function interleaveAccessUnits(baseNals: NalUnit[], alphaNals: NalUnit[]): Buffer;
305
324
 
306
325
  export declare interface IpcDonePayload {
@@ -309,41 +328,31 @@ export declare interface IpcDonePayload {
309
328
  outFile: string;
310
329
  }
311
330
 
312
- export declare const enum IpcMsgType {
313
- PROGRESS = 1,
314
- DONE = 2,
315
- ERROR = 3
316
- }
317
-
318
- export declare class IpcReader extends EventEmitter<{
331
+ export declare interface IpcEvents {
319
332
  progress: [value: number];
320
- message: [type: IpcMsgType, buffer: Buffer];
333
+ message: [msg: IpcMsg];
321
334
  done: [payload: IpcDonePayload];
322
335
  error: [error: Error];
323
- close: [];
324
- }> {
325
- private readonly _socket;
326
- private _chunks;
327
- private _buffered;
328
- constructor(_socket: Socket);
329
- private onData;
330
- private flush;
331
- private peek;
332
- private consume;
336
+ close: [code: number | null];
333
337
  }
334
338
 
335
- export declare interface IpcServer {
336
- waitForConnection(): Promise<IpcReader>;
337
- close(): void;
339
+ export declare type IpcMsg = ProgressMsg | DoneMsg | ErrorMsg;
340
+
341
+ export declare const enum IpcMsgType {
342
+ PROGRESS = "progress",
343
+ DONE = "done",
344
+ ERROR = "error"
345
+ }
346
+
347
+ export declare class IpcReader extends EventEmitter<IpcEvents> {
348
+ constructor(child: ChildProcess);
338
349
  }
339
350
 
340
351
  export declare class IpcWriter {
341
- private readonly _socket;
342
- constructor(_socket: Socket);
343
352
  writeProgress(value: number): void;
344
- writeError(error: string): void;
345
- writeDone(payload: IpcDonePayload): void;
346
- private write;
353
+ writeError(error: string): Promise<void>;
354
+ writeDone(payload: IpcDonePayload): Promise<void>;
355
+ private send;
347
356
  }
348
357
 
349
358
  export declare function isEmpty(image: NativeImage): boolean;
@@ -422,8 +431,6 @@ export declare class NvencDualLayerEncoder implements Disposable {
422
431
  private _seiBuffer;
423
432
  private _pts;
424
433
  private _seiInjected;
425
- private _alphaBuf?;
426
- private _alphaFrame?;
427
434
  private constructor();
428
435
  static create(opts: HwVideoEncoderOptions): Promise<NvencDualLayerEncoder>;
429
436
  encode(bgraFrame: Frame, muxer: FormatMuxer): Promise<void>;
@@ -434,6 +441,24 @@ export declare class NvencDualLayerEncoder implements Disposable {
434
441
 
435
442
  export declare function openVideoCtx(opts: VideoCtxOptions, label: string): Promise<CodecContext>;
436
443
 
444
+ export declare class OutputSink implements AsyncDisposable {
445
+ private _s;
446
+ private _disposed;
447
+ private constructor();
448
+ static kindFromPath(path: string): SinkKind;
449
+ static create(opts: SinkOptions): Promise<OutputSink>;
450
+ private static mp4Video;
451
+ private static webmVideo;
452
+ private static audioFor;
453
+ setInputRate(sampleRate: number): void;
454
+ encodeBGRA(bgraFrame: Frame): Promise<void>;
455
+ encodeDecodedFrame(src: Frame): Promise<void>;
456
+ encodeAudio(pcm: Buffer): Promise<void>;
457
+ flush(): Promise<void>;
458
+ [Symbol.asyncDispose](): Promise<void>;
459
+ private swEncode;
460
+ }
461
+
437
462
  export declare function packBits(bits: number[]): Buffer;
438
463
 
439
464
  declare function pargs(): string[];
@@ -463,11 +488,17 @@ export { periodical as periodical_alias_1 }
463
488
  declare interface ProcessHandle {
464
489
  process: ChildProcess;
465
490
  wait: Promise<void>;
491
+ get killed(): boolean;
466
492
  kill(): void;
467
493
  }
468
494
  export { ProcessHandle }
469
495
  export { ProcessHandle as ProcessHandle_alias_1 }
470
496
 
497
+ export declare interface ProgressMsg {
498
+ type: IpcMsgType.PROGRESS;
499
+ value: number;
500
+ }
501
+
471
502
  export declare function proxiedUrl(url: string): string;
472
503
 
473
504
  declare function pup(source: string, options: Partial<PupOptions>): Promise<PupResult>;
@@ -494,10 +525,6 @@ declare const pupDisableHwCodec: boolean;
494
525
  export { pupDisableHwCodec }
495
526
  export { pupDisableHwCodec as pupDisableHwCodec_alias_1 }
496
527
 
497
- declare const pupIpcSocket: string | undefined;
498
- export { pupIpcSocket }
499
- export { pupIpcSocket as pupIpcSocket_alias_1 }
500
-
501
528
  declare const pupLogLevel: number;
502
529
  export { pupLogLevel }
503
530
  export { pupLogLevel as pupLogLevel_alias_1 }
@@ -564,6 +591,8 @@ declare const RenderSchema: z.ZodObject<{
564
591
  export { RenderSchema }
565
592
  export { RenderSchema as RenderSchema_alias_1 }
566
593
 
594
+ export declare function resizeDrawable(cdp: Debugger, size: Size): Promise<void>;
595
+
567
596
  declare interface RetryOptions<Args extends any[], Ret> {
568
597
  fn: (...args: Args) => Promise<Ret>;
569
598
  maxAttempts?: number;
@@ -575,7 +604,13 @@ export { RetryOptions as RetryOptions_alias_1 }
575
604
  /** Rewrite nuh_layer_id in a NAL unit (returns copy). */
576
605
  export declare function rewriteNalLayerId(nal: Buffer, layerId: number): Buffer;
577
606
 
578
- export declare function runElectronApp(size: Size, args: unknown[], ipcSocketPath: string): Promise<ProcessHandle>;
607
+ export declare function runElectronApp({ args }: RunElectronAppOptions): Promise<ProcessHandle>;
608
+
609
+ export declare interface RunElectronAppOptions {
610
+ args: unknown[];
611
+ }
612
+
613
+ export declare function send(cdp: Debugger, method: string, params?: object): Promise<unknown>;
579
614
 
580
615
  export declare function setInterceptor({ source, window, useInnerProxy }: NetworkOptions): void;
581
616
 
@@ -585,6 +620,21 @@ export declare function setupPupProtocol(): void;
585
620
 
586
621
  export declare function shoot(writer: IpcWriter, source: string, options: RenderOptions): Promise<IpcDonePayload>;
587
622
 
623
+ export declare type SinkKind = "mp4" | "webm";
624
+
625
+ export declare interface SinkOptions {
626
+ outFile: string;
627
+ kind: SinkKind;
628
+ width: number;
629
+ height: number;
630
+ fps: number;
631
+ withAudio: boolean;
632
+ disableHwCodec: boolean;
633
+ sharedHw?: HardwareContext;
634
+ }
635
+
636
+ export declare function sizeEquals(a: Size, b: Size): boolean;
637
+
588
638
  declare function sleep(ms: number): Promise<void>;
589
639
  export { sleep }
590
640
  export { sleep as sleep_alias_1 }
@@ -592,13 +642,15 @@ export { sleep as sleep_alias_1 }
592
642
  /** Split Annex B bitstream into NAL units. */
593
643
  export declare function splitNalUnits(bitstream: Buffer): NalUnit[];
594
644
 
595
- export declare function startStego(frame: WebFrameMain): Promise<void>;
645
+ export declare function startElectronCrashReporter(): void;
646
+
647
+ export declare function startStego(cdp: Debugger): Promise<void>;
596
648
 
597
649
  export declare const STEGO_TICK_CHANNEL = "stego-tick";
598
650
 
599
- export declare function stopStego(frame: WebFrameMain): Promise<void>;
651
+ export declare function stopStego(cdp: Debugger): Promise<void>;
600
652
 
601
- export declare function swapBuffer(frame: WebFrameMain, expected: number): Promise<void>;
653
+ export declare function swapBuffer(cdp: Debugger, expected: number): Promise<void>;
602
654
 
603
655
  export declare function tick(frame: WebFrameMain | undefined, timestampMs: number): Promise<void>;
604
656
 
@@ -627,6 +679,7 @@ export declare interface VideoCtxOptions {
627
679
  codecTag?: string;
628
680
  colorRange?: AVColorRange;
629
681
  options?: Record<string, string>;
682
+ hwFramesCtx?: HardwareFramesContext;
630
683
  }
631
684
 
632
685
  declare class VideoEncoder_2 implements Disposable {
@@ -655,19 +708,12 @@ export declare interface VideoEncoderOptions {
655
708
  muxer: FormatMuxer;
656
709
  }
657
710
 
658
- export declare interface VideoFactoryOptions {
659
- width: number;
660
- height: number;
661
- fps: number;
662
- bitrate?: number;
663
- disableHwCodec?: boolean;
664
- }
665
-
666
711
  export declare interface VideoSetup {
667
712
  video?: VideoEncoder_2;
668
713
  hwVideo?: HwEncoder;
669
714
  codec?: CodecState_2;
670
715
  hw?: HardwareContext;
716
+ ownsHw: boolean;
671
717
  }
672
718
 
673
719
  export declare class VideoToolboxEncoder implements Disposable {
@@ -704,4 +750,8 @@ export declare interface WindowOptions {
704
750
  tolerant?: boolean;
705
751
  }
706
752
 
753
+ declare function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T>;
754
+ export { withTimeout }
755
+ export { withTimeout as withTimeout_alias_1 }
756
+
707
757
  export { }