pup-recorder 0.4.3 → 0.4.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.
package/biome.json CHANGED
@@ -15,6 +15,7 @@
15
15
  "strictCase": false,
16
16
  "conventions": [
17
17
  { "selector": { "kind": "classProperty", "modifiers": ["private"] }, "match": "_(.+)" },
18
+ { "selector": { "kind": "classMethod", "modifiers": ["private"] }, "match": "[^_].*" },
18
19
  { "selector": { "kind": "typeProperty" }, "match": "__.+|[a-z][A-Za-z0-9]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*|[A-Z][A-Za-z0-9]*|[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*" },
19
20
  { "selector": { "kind": "objectLiteralProperty" }, "formats": ["camelCase", "snake_case", "PascalCase", "CONSTANT_CASE"] },
20
21
  { "selector": { "kind": "variable" }, "formats": ["camelCase", "snake_case", "PascalCase", "CONSTANT_CASE"] },
package/build.ts CHANGED
@@ -7,12 +7,12 @@ import { dependencies } from "./package.json";
7
7
 
8
8
  const require = createRequire(import.meta.url);
9
9
  const tsPath = require.resolve("@typescript/native-preview/package.json");
10
- const tsgo = join(tsPath, "..", "bin", "tsgo.js");
10
+ const tsgo = join(tsPath, "..", require(tsPath).bin.tsgo);
11
11
  const biomePath = require.resolve("@biomejs/biome/package.json");
12
12
  const biome = join(biomePath, "..", "bin", "biome");
13
13
 
14
14
  await $`${tsgo}`;
15
- await $`${biome} check --write src`;
15
+ await $`${biome} check --write --error-on-warnings`;
16
16
  await rm("dist", { recursive: true, force: true });
17
17
 
18
18
  const common: Options = {
@@ -10,8 +10,7 @@ import type { Debugger } from 'electron';
10
10
  import { Demuxer } from 'node-av/api';
11
11
  import { EventEmitter } from 'node:events';
12
12
  import { FFAudioEncoder } from 'node-av/constants';
13
- import type { FFVideoEncoder } from 'node-av/constants';
14
- import { FormatContext } from 'node-av';
13
+ import { FFVideoEncoder } from 'node-av/constants';
15
14
  import { Frame } from 'node-av';
16
15
  import { HardwareContext } from 'node-av/api';
17
16
  import { HardwareFramesContext } from 'node-av';
@@ -130,6 +129,18 @@ export declare class BitWriter {
130
129
  copy(src: number[], start: number, len: number): void;
131
130
  }
132
131
 
132
+ export declare const BLANK_WARN_RATIO = 0.5;
133
+
134
+ export declare class BlankFrameStats {
135
+ private readonly _width;
136
+ private readonly _height;
137
+ private _total;
138
+ private _blank;
139
+ constructor(width: number, height: number);
140
+ sample(frame: Buffer): void;
141
+ finalize(): number;
142
+ }
143
+
133
144
  export declare function buildAlphaChannelInfoSEI(): Buffer;
134
145
 
135
146
  /**
@@ -231,14 +242,16 @@ export declare class DecodeSession {
231
242
  private _restart;
232
243
  private readonly _leadFrames;
233
244
  private readonly _keepCount;
245
+ private readonly _pumpDone;
234
246
  constructor(meta: VideoMeta, _src: string);
235
247
  getFrame(idx: number): Promise<Buffer>;
236
- close(): void;
248
+ close(): Promise<void>;
237
249
  private wait;
238
250
  private wake;
239
251
  private requestRestart;
240
252
  private pump;
241
253
  private decodePass;
254
+ private get demand();
242
255
  private pause;
243
256
  private untilRestart;
244
257
  private evict;
@@ -329,6 +342,8 @@ export declare interface EncoderPipelineOptions {
329
342
  disableHwCodec?: boolean;
330
343
  }
331
344
 
345
+ export declare function encodeStubWebm({ width, height, duration }: StubEncodeOptions): Promise<Buffer>;
346
+
332
347
  export declare type EnvParser<T> = (value: unknown) => T;
333
348
 
334
349
  export declare interface ErrorMsg {
@@ -342,6 +357,8 @@ export declare function exec(cmd: string, options?: SpawnOptions): ProcessHandle
342
357
 
343
358
  export declare function extractAlphaToYuv420pBuffer(bgraFrame: Frame, buf: Buffer): void;
344
359
 
360
+ export declare const FF_ENCODER_LIBVPX_VP9: FFVideoEncoder;
361
+
345
362
  export declare function fire(el: EventTarget, type: string): void;
346
363
 
347
364
  export declare function fitRect(srcW: number, srcH: number, dstW: number, dstH: number, fit: string): Vec4;
@@ -349,8 +366,9 @@ export declare function fitRect(srcW: number, srcH: number, dstW: number, dstH:
349
366
  export declare class FormatMuxer {
350
367
  private readonly _ctx;
351
368
  private _opened;
369
+ private _disposed;
352
370
  constructor(outPath: string, formatName?: string);
353
- addStream(codecCtx: CodecContext, codecTag?: string): ReturnType<FormatContext["newStream"]>;
371
+ addStream(codecCtx: CodecContext, codecTag?: string): Stream;
354
372
  open(): Promise<void>;
355
373
  writePacket(pkt: Packet): Promise<void>;
356
374
  [Symbol.asyncDispose](): Promise<void>;
@@ -363,7 +381,7 @@ export declare const FRAME_SYNC_MARKER_WIDTH = 32;
363
381
  export declare class FrameCache {
364
382
  private _caches;
365
383
  cacheOf(id: string): VideoCache;
366
- fetch(state: VideoState, idx: number): Promise<ImageBitmap | null>;
384
+ fetch(state: VideoState, idx: number): Promise<ImageBitmap | undefined>;
367
385
  prefetch(state: VideoState, fromIdx: number, count: number): void;
368
386
  evict(c: VideoCache): void;
369
387
  release(id: string, state: VideoState): void;
@@ -404,16 +422,20 @@ export declare class FrameDropStats {
404
422
  }
405
423
 
406
424
  export declare class FrameServer {
425
+ private readonly _useInnerProxy;
407
426
  private _sessions;
427
+ private _probes;
428
+ private _stubs;
408
429
  private _closed;
430
+ constructor(_useInnerProxy: boolean);
409
431
  open(opts: OpenOptions): Promise<VideoMeta>;
432
+ stub(src: string): Promise<Buffer>;
410
433
  getFrame(id: string, idx: number): Promise<Buffer>;
411
- close(id: string): void;
412
- closeAll(): void;
434
+ close(id: string): Promise<void>;
435
+ private probeCached;
436
+ closeAll(): Promise<void>;
413
437
  }
414
438
 
415
- export declare const frameServer: FrameServer;
416
-
417
439
  export declare const HAVE_ENOUGH_DATA = 4;
418
440
 
419
441
  export declare const HAVE_METADATA = 1;
@@ -452,6 +474,7 @@ export declare interface IpcDonePayload {
452
474
  written: number;
453
475
  jank: number;
454
476
  outFile: string;
477
+ blank: number;
455
478
  }
456
479
 
457
480
  export declare interface IpcEvents {
@@ -491,6 +514,8 @@ export declare class IpcWriter {
491
514
  private send;
492
515
  }
493
516
 
517
+ export declare function isBlankFrame(bgra: Buffer, width: number, height: number): boolean;
518
+
494
519
  export declare function isEmpty(image: NativeImage): boolean;
495
520
 
496
521
  declare class Lazy<T> {
@@ -593,7 +618,7 @@ export declare interface NetworkOptions {
593
618
  source: string;
594
619
  window: BrowserWindow;
595
620
  useInnerProxy?: boolean;
596
- cancelMedia?: boolean;
621
+ stubMedia?: boolean;
597
622
  }
598
623
 
599
624
  export declare function newVideoState(video: HTMLVideoElement, cv: HTMLCanvasElement): VideoState;
@@ -637,7 +662,7 @@ export declare interface OpenOptions {
637
662
  fit?: string;
638
663
  }
639
664
 
640
- export declare function openSession(hook: VideoHook, args: AttachArgs): Promise<VideoState | null>;
665
+ export declare function openSession(hook: VideoHook, args: AttachArgs): Promise<VideoState | undefined>;
641
666
 
642
667
  export declare function openVideoCtx(opts: VideoCtxOptions, label: string): Promise<CodecContext>;
643
668
 
@@ -682,7 +707,7 @@ declare function penv<T>(name: string, parser: EnvParser<T>, defaultValue?: T):
682
707
  export { penv }
683
708
  export { penv as penv_alias_1 }
684
709
 
685
- declare function periodical(callback: (count: number) => Promise<void> | void, ms: number): () => void;
710
+ declare function periodical(callback: (count: number) => Promise<number | undefined> | undefined, ms: number): () => void;
686
711
  export { periodical }
687
712
  export { periodical as periodical_alias_1 }
688
713
 
@@ -777,6 +802,7 @@ declare interface RenderResult {
777
802
  written: number;
778
803
  jank: number;
779
804
  outFile: string;
805
+ blank: number;
780
806
  }
781
807
  export { RenderResult }
782
808
  export { RenderResult as RenderResult_alias_1 }
@@ -836,12 +862,10 @@ export declare const SCHEME = "pup-frame://";
836
862
 
837
863
  export declare function send(cdp: Debugger, method: string, params?: object): Promise<unknown>;
838
864
 
839
- export declare function setInterceptor({ source, window, useInnerProxy, cancelMedia }: NetworkOptions): void;
865
+ export declare function setInterceptor({ source, window, useInnerProxy, stubMedia }: NetworkOptions): void;
840
866
 
841
867
  export declare function setupCanvas(video: HTMLVideoElement, snap: OffscreenCanvas | undefined): HTMLCanvasElement;
842
868
 
843
- export declare function setupFrameProtocol(): void;
844
-
845
869
  export declare function setupPupProtocol(): void;
846
870
 
847
871
  export declare function shoot(options: IPCRenderOptions): Promise<IpcDonePayload>;
@@ -876,6 +900,12 @@ export declare const STEGO_TICK_CHANNEL = "stego-tick";
876
900
 
877
901
  export declare function stopStego(cdp: Debugger): Promise<unknown>;
878
902
 
903
+ export declare interface StubEncodeOptions {
904
+ width: number;
905
+ height: number;
906
+ duration: number;
907
+ }
908
+
879
909
  export declare function swapBuffer(wc: WebContents, expected: number, interval: number): Promise<void>;
880
910
 
881
911
  export declare function syncOverlay(video: HTMLVideoElement, cv: HTMLCanvasElement): void;
@@ -903,6 +933,8 @@ export declare interface UnifiedExtradataOptions {
903
933
 
904
934
  export declare function unsetInterceptor(window: BrowserWindow): void;
905
935
 
936
+ export declare function useFrameProtocol(useInnerProxy: boolean): AsyncDisposable;
937
+
906
938
  declare function useRetry<Args extends unknown[], Ret>({ fn, maxAttempts, timeout, signal, }: RetryOptions<Args, Ret>): (...args: Args) => Promise<Ret>;
907
939
  export { useRetry }
908
940
  export { useRetry as useRetry_alias_1 }
@@ -911,7 +943,7 @@ declare type Vec4 = [number, number, number, number];
911
943
 
912
944
  export declare interface VideoCache {
913
945
  bitmaps: Map<number, ImageBitmap>;
914
- inFlight: Map<number, Promise<ImageBitmap | null>>;
946
+ inFlight: Map<number, Promise<ImageBitmap | undefined>>;
915
947
  readers: Map<VideoState, number>;
916
948
  }
917
949
 
@@ -965,14 +997,14 @@ export declare interface VideoFrameMeta {
965
997
 
966
998
  export declare class VideoHook {
967
999
  readonly sessions: WeakMap<HTMLVideoElement, VideoState>;
968
- readonly attaching: WeakMap<HTMLVideoElement, Promise<VideoState | null>>;
1000
+ readonly attaching: WeakMap<HTMLVideoElement, Promise<VideoState | undefined>>;
969
1001
  readonly opening: Set<Promise<unknown>>;
970
1002
  readonly cache: FrameCache;
971
1003
  rvfcSeq: number;
972
1004
  currMs: number;
973
1005
  private _lastSnapshot;
974
1006
  install(): void;
975
- attach(video: HTMLVideoElement, native?: boolean): Promise<VideoState | null>;
1007
+ attach(video: HTMLVideoElement, native?: boolean): Promise<VideoState | undefined>;
976
1008
  ready(): Promise<void>;
977
1009
  resume(video: HTMLVideoElement, state: VideoState): void;
978
1010
  detach(video: HTMLVideoElement): void;
@@ -1014,7 +1046,7 @@ export declare interface VideoSetup {
1014
1046
  }
1015
1047
 
1016
1048
  export declare interface VideoState {
1017
- meta: VideoMeta_alias_1 | null;
1049
+ meta?: VideoMeta_alias_1;
1018
1050
  cv: HTMLCanvasElement;
1019
1051
  ctx: CanvasRenderingContext2D;
1020
1052
  paused: boolean;