pup-recorder 0.4.0 → 0.4.3

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.
@@ -3,36 +3,57 @@ import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
3
3
  import { AVColorRange } from 'node-av/constants';
4
4
  import { AVPixelFormat } from 'node-av/constants';
5
5
  import { BrowserWindow } from 'electron';
6
- import { ChildProcess } from 'child_process';
6
+ import { ChildProcess } from 'node:child_process';
7
7
  import { Codec } from 'node-av';
8
8
  import { CodecContext } from 'node-av';
9
- import { Debugger } from 'electron';
10
- import { EventEmitter } from 'events';
9
+ import type { Debugger } from 'electron';
10
+ import { Demuxer } from 'node-av/api';
11
+ import { EventEmitter } from 'node:events';
11
12
  import { FFAudioEncoder } from 'node-av/constants';
12
- import { FFVideoEncoder } from 'node-av/constants';
13
+ import type { FFVideoEncoder } from 'node-av/constants';
13
14
  import { FormatContext } from 'node-av';
14
15
  import { Frame } from 'node-av';
15
16
  import { HardwareContext } from 'node-av/api';
16
17
  import { HardwareFramesContext } from 'node-av';
17
18
  import type { NativeImage } from 'electron';
18
19
  import { Packet } from 'node-av';
19
- import { Size } from 'electron';
20
+ import type { Size } from 'electron';
20
21
  import { SoftwareScaleContext } from 'node-av';
21
- import { SpawnOptions } from 'child_process';
22
+ import { SpawnOptions } from 'node:child_process';
22
23
  import { Stream } from 'node-av';
23
- import { WebContents } from 'electron';
24
+ import type { WebContents } from 'electron';
24
25
  import type { WebFrameMain } from 'electron';
25
26
  import z from 'zod';
26
27
 
28
+ export declare function abortable<T>(p: Promise<T>, signal?: AbortSignal): Promise<T>;
29
+
27
30
  /** Insert emulation prevention bytes (00 00 03) for Annex B compliance. */
28
31
  export declare function addEmulationPrevention(nal: Buffer): Buffer;
29
32
 
30
- export declare function advanceVideos(frame: WebFrameMain | undefined, timestampMs: number): Promise<void>;
33
+ export declare function advance(hook: VideoHook, timestampMs: number): Promise<unknown>;
34
+
35
+ export declare interface AdvanceOptions {
36
+ frame: WebFrameMain | undefined;
37
+ timestampMs: number;
38
+ signal?: AbortSignal;
39
+ }
40
+
41
+ export declare function advanceVideos({ frame, timestampMs, signal }: AdvanceOptions): Promise<void>;
31
42
 
32
43
  export declare function advanceVirtualTime(cdp: Debugger, budget: number): Promise<void>;
33
44
 
45
+ export declare const AHEAD = 10;
46
+
34
47
  export declare const ANNEX_B_START_CODE: Buffer<ArrayBuffer>;
35
48
 
49
+ export declare interface AttachArgs {
50
+ video: HTMLVideoElement;
51
+ state: VideoState;
52
+ src: string;
53
+ birthMs: number;
54
+ native: boolean;
55
+ }
56
+
36
57
  export declare function attachAudioListeners({ wc, encoder, getVideoTimeMs, onError }: AudioListenerOptions): AudioDisposal;
37
58
 
38
59
  export declare const AUDIO_CHUNK_CHANNEL = "audio-chunk";
@@ -123,7 +144,7 @@ export declare function buildStegoHTML(targetURL: string, size: Size): string;
123
144
  export declare function buildUnifiedExtradata(opts: UnifiedExtradataOptions): Buffer;
124
145
 
125
146
  export declare interface CancelMsg {
126
- type: IpcMsgType.CANCEL;
147
+ type: IpcMsgType.Cancel;
127
148
  reason?: string;
128
149
  }
129
150
 
@@ -158,7 +179,7 @@ declare class CodecState_2 implements Disposable {
158
179
  }
159
180
  export { CodecState_2 as CodecState }
160
181
 
161
- declare class ConcurrencyLimiter {
182
+ export declare class ConcurrencyLimiter {
162
183
  readonly maxConcurrency: number;
163
184
  private _active;
164
185
  private _queue;
@@ -173,15 +194,11 @@ declare class ConcurrencyLimiter {
173
194
  private flush;
174
195
  private next;
175
196
  }
176
- export { ConcurrencyLimiter }
177
- export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
178
197
 
179
- declare type ConsoleCallback = (level: string, message: string) => void;
180
- export { ConsoleCallback }
181
- export { ConsoleCallback as ConsoleCallback_alias_1 }
198
+ export declare type ConsoleCallback = (level: string, message: string) => void;
182
199
 
183
200
  export declare interface ConsoleMsg {
184
- type: IpcMsgType.CONSOLE;
201
+ type: IpcMsgType.Console;
185
202
  level: string;
186
203
  message: string;
187
204
  }
@@ -192,21 +209,39 @@ export declare function createStegoURL(src: string, size: Size): string;
192
209
 
193
210
  export declare function debounce<T extends (...args: unknown[]) => void>(fn: T, delay?: number): T;
194
211
 
212
+ export declare interface DecodedFrame {
213
+ idx: number;
214
+ buf: Buffer;
215
+ }
216
+
217
+ export declare function decodeFrames(src: string, meta: VideoMeta, signal: AbortSignal): AsyncGenerator<DecodedFrame>;
218
+
195
219
  export declare class DecodeSession {
196
220
  readonly meta: VideoMeta;
197
- private readonly src;
198
- private readonly framesDir;
199
- private proc;
200
- private ready;
201
- private done;
202
- private waiters;
203
- private watcher;
204
- constructor(meta: VideoMeta, src: string, framesDir: string);
221
+ private readonly _src;
222
+ private _buf;
223
+ private _ready;
224
+ private _want;
225
+ private _done;
226
+ private _closed;
227
+ private _gen;
228
+ private _ctrl;
229
+ private _waiters;
230
+ private _resume;
231
+ private _restart;
232
+ private readonly _leadFrames;
233
+ private readonly _keepCount;
234
+ constructor(meta: VideoMeta, _src: string);
205
235
  getFrame(idx: number): Promise<Buffer>;
206
236
  close(): void;
207
237
  private wait;
208
- private spawn;
209
- private poll;
238
+ private wake;
239
+ private requestRestart;
240
+ private pump;
241
+ private decodePass;
242
+ private pause;
243
+ private untilRestart;
244
+ private evict;
210
245
  private drainWaiters;
211
246
  }
212
247
 
@@ -224,22 +259,22 @@ declare const DEFAULT_HEIGHT = 1080;
224
259
  export { DEFAULT_HEIGHT }
225
260
  export { DEFAULT_HEIGHT as DEFAULT_HEIGHT_alias_1 }
226
261
 
227
- declare const DEFAULT_OUT_FILE = "out/html.mp4,out/html.webm";
228
- export { DEFAULT_OUT_FILE }
229
- export { DEFAULT_OUT_FILE as DEFAULT_OUT_FILE_alias_1 }
262
+ export declare const DEFAULT_OUT_FILE = "out/html.mp4,out/html.webm";
230
263
 
231
264
  declare const DEFAULT_WIDTH = 1920;
232
265
  export { DEFAULT_WIDTH }
233
266
  export { DEFAULT_WIDTH as DEFAULT_WIDTH_alias_1 }
234
267
 
235
- declare const defaultRenderOptions: RenderOptions;
236
- export { defaultRenderOptions }
237
- export { defaultRenderOptions as defaultRenderOptions_alias_1 }
268
+ declare const DEFAULT_WINDOW_TIMEOUT = 10;
269
+ export { DEFAULT_WINDOW_TIMEOUT }
270
+ export { DEFAULT_WINDOW_TIMEOUT as DEFAULT_WINDOW_TIMEOUT_alias_1 }
271
+
272
+ export declare const defaultRenderOptions: RenderOptions;
238
273
 
239
274
  export declare function disposeWindow(win: BrowserWindow): Promise<void>;
240
275
 
241
276
  export declare interface DoneMsg {
242
- type: IpcMsgType.DONE;
277
+ type: IpcMsgType.Done;
243
278
  payload: IpcDonePayload;
244
279
  }
245
280
 
@@ -270,7 +305,7 @@ export declare function electronOpts(disableGpu: boolean): Promise<string[]>;
270
305
 
271
306
  export declare function encodeNalHeader(type: number, layerId: number, temporalId: number): [number, number];
272
307
 
273
- declare class EncoderPipeline {
308
+ export declare class EncoderPipeline {
274
309
  private _s;
275
310
  private _disposed;
276
311
  private constructor();
@@ -284,10 +319,8 @@ declare class EncoderPipeline {
284
319
  private free;
285
320
  private bgraFrame;
286
321
  }
287
- export { EncoderPipeline }
288
- export { EncoderPipeline as EncoderPipeline_alias_1 }
289
322
 
290
- declare interface EncoderPipelineOptions {
323
+ export declare interface EncoderPipelineOptions {
291
324
  width: number;
292
325
  height: number;
293
326
  fps: number;
@@ -295,27 +328,25 @@ declare interface EncoderPipelineOptions {
295
328
  withAudio?: boolean;
296
329
  disableHwCodec?: boolean;
297
330
  }
298
- export { EncoderPipelineOptions }
299
- export { EncoderPipelineOptions as EncoderPipelineOptions_alias_1 }
300
331
 
301
- declare type EnvParser<T> = (value: unknown) => T;
302
- export { EnvParser }
303
- export { EnvParser as EnvParser_alias_1 }
332
+ export declare type EnvParser<T> = (value: unknown) => T;
304
333
 
305
334
  export declare interface ErrorMsg {
306
- type: IpcMsgType.ERROR;
335
+ type: IpcMsgType.Error;
307
336
  error: string;
308
337
  }
309
338
 
310
339
  export declare function evalIn(cdp: Debugger, expression: string): Promise<unknown>;
311
340
 
312
- declare function exec(cmd: string, options?: SpawnOptions): ProcessHandle;
313
- export { exec }
314
- export { exec as exec_alias_1 }
341
+ export declare function exec(cmd: string, options?: SpawnOptions): ProcessHandle;
315
342
 
316
343
  export declare function extractAlphaToYuv420pBuffer(bgraFrame: Frame, buf: Buffer): void;
317
344
 
318
- declare class FormatMuxer {
345
+ export declare function fire(el: EventTarget, type: string): void;
346
+
347
+ export declare function fitRect(srcW: number, srcH: number, dstW: number, dstH: number, fit: string): Vec4;
348
+
349
+ export declare class FormatMuxer {
319
350
  private readonly _ctx;
320
351
  private _opened;
321
352
  constructor(outPath: string, formatName?: string);
@@ -324,13 +355,22 @@ declare class FormatMuxer {
324
355
  writePacket(pkt: Packet): Promise<void>;
325
356
  [Symbol.asyncDispose](): Promise<void>;
326
357
  }
327
- export { FormatMuxer }
328
- export { FormatMuxer as FormatMuxer_alias_1 }
329
358
 
330
359
  export declare const FRAME_SYNC_MARKER_HEIGHT = 1;
331
360
 
332
361
  export declare const FRAME_SYNC_MARKER_WIDTH = 32;
333
362
 
363
+ export declare class FrameCache {
364
+ private _caches;
365
+ cacheOf(id: string): VideoCache;
366
+ fetch(state: VideoState, idx: number): Promise<ImageBitmap | null>;
367
+ prefetch(state: VideoState, fromIdx: number, count: number): void;
368
+ evict(c: VideoCache): void;
369
+ release(id: string, state: VideoState): void;
370
+ }
371
+
372
+ export declare type FrameCb = (now: number, meta: VideoFrameMeta) => void;
373
+
334
374
  /**
335
375
  * Frame drop quality score (0 = perfect, 1 = worst).
336
376
  *
@@ -364,7 +404,8 @@ export declare class FrameDropStats {
364
404
  }
365
405
 
366
406
  export declare class FrameServer {
367
- private sessions;
407
+ private _sessions;
408
+ private _closed;
368
409
  open(opts: OpenOptions): Promise<VideoMeta>;
369
410
  getFrame(id: string, idx: number): Promise<Buffer>;
370
411
  close(id: string): void;
@@ -373,6 +414,12 @@ export declare class FrameServer {
373
414
 
374
415
  export declare const frameServer: FrameServer;
375
416
 
417
+ export declare const HAVE_ENOUGH_DATA = 4;
418
+
419
+ export declare const HAVE_METADATA = 1;
420
+
421
+ export declare const HAVE_NOTHING = 0;
422
+
376
423
  export declare type HwEncoder = VideoToolboxEncoder | NvencDualLayerEncoder;
377
424
 
378
425
  export declare interface HwVideoEncoderOptions {
@@ -393,6 +440,8 @@ export declare interface HwVideoFactoryOptions {
393
440
  sharedHw?: HardwareContext;
394
441
  }
395
442
 
443
+ export declare function installMediaShim(hook: VideoHook): void;
444
+
396
445
  export declare function installTickHook(): void;
397
446
 
398
447
  export declare function installVideoHook(): void;
@@ -415,26 +464,24 @@ export declare interface IpcEvents {
415
464
 
416
465
  export declare type IpcMsg = ConsoleMsg | ProgressMsg | DoneMsg | ErrorMsg | CancelMsg;
417
466
 
418
- export declare const enum IpcMsgType {
419
- CONSOLE = "console",
420
- PROGRESS = "progress",
421
- DONE = "done",
422
- ERROR = "error",
423
- CANCEL = "cancel"
467
+ export declare enum IpcMsgType {
468
+ Console = "console",
469
+ Progress = "progress",
470
+ Done = "done",
471
+ Error = "error",
472
+ Cancel = "cancel"
424
473
  }
425
474
 
426
475
  export declare class IpcReader extends EventEmitter<IpcEvents> {
427
476
  constructor(child: ChildProcess);
428
477
  }
429
478
 
430
- declare interface IPCRenderOptions extends RenderOptions {
479
+ export declare interface IPCRenderOptions extends RenderOptions {
431
480
  source: string;
432
481
  signal: AbortSignal;
433
482
  onProgress: ProgressCallback;
434
483
  onConsole: ConsoleCallback;
435
484
  }
436
- export { IPCRenderOptions }
437
- export { IPCRenderOptions as IPCRenderOptions_alias_1 }
438
485
 
439
486
  export declare class IpcWriter {
440
487
  writeConsole(level: string, message: string): void;
@@ -459,8 +506,6 @@ export { Lazy as Lazy_alias_1 }
459
506
 
460
507
  export declare function loadWindow({ source, renderer, onCreated, signal }: WindowOptions): Promise<BrowserWindow>;
461
508
 
462
- export declare function localize(src: string): Promise<string>;
463
-
464
509
  declare class Logger implements LoggerLike {
465
510
  private _level;
466
511
  private _impl?;
@@ -501,6 +546,15 @@ export declare function makePacket(): Packet;
501
546
 
502
547
  export declare const MAX_RENDER_ATTEMPTS = 3;
503
548
 
549
+ export declare const MEDIA_ERR_DECODE = 3;
550
+
551
+ export declare const MEDIA_ERR_NETWORK = 2;
552
+
553
+ export declare interface MediaErrorLike {
554
+ code: number;
555
+ message: string;
556
+ }
557
+
504
558
  export declare const NAL_BLA_W_LP = 16;
505
559
 
506
560
  export declare const NAL_HEADER_SIZE = 2;
@@ -527,13 +581,24 @@ export declare interface NalUnit {
527
581
  data: Buffer;
528
582
  }
529
583
 
584
+ export declare const NETWORK_EMPTY = 0;
585
+
586
+ export declare const NETWORK_IDLE = 1;
587
+
588
+ export declare const NETWORK_LOADING = 2;
589
+
590
+ export declare const NETWORK_NO_SOURCE = 3;
591
+
530
592
  export declare interface NetworkOptions {
531
593
  source: string;
532
594
  window: BrowserWindow;
533
595
  useInnerProxy?: boolean;
596
+ cancelMedia?: boolean;
534
597
  }
535
598
 
536
- declare function noerr<Fn extends (...args: any[]) => any, D>(fn: Fn, defaultValue: D): (...args: Parameters<Fn>) => ReturnType<Fn> | D;
599
+ export declare function newVideoState(video: HTMLVideoElement, cv: HTMLCanvasElement): VideoState;
600
+
601
+ declare function noerr<A extends unknown[], R, D>(fn: (...args: A) => R, defaultValue: D): (...args: A) => R | D;
537
602
  export { noerr }
538
603
  export { noerr as noerr_alias_1 }
539
604
 
@@ -560,11 +625,20 @@ export declare interface NvencHevcConfig {
560
625
  ppsHasLoopFilterAcrossSlicesFlag: boolean;
561
626
  }
562
627
 
628
+ export declare function openInput(src: string, signal?: AbortSignal): Promise<Demuxer>;
629
+
563
630
  export declare interface OpenOptions {
564
631
  src: string;
565
632
  fps: number;
633
+ /** Display-box pixels (canvas backing store); decode is downscaled to cover this, never upscaled. */
634
+ dstW?: number;
635
+ dstH?: number;
636
+ /** objectFit; "none" needs 1:1 native pixels so it skips downscale. */
637
+ fit?: string;
566
638
  }
567
639
 
640
+ export declare function openSession(hook: VideoHook, args: AttachArgs): Promise<VideoState | null>;
641
+
568
642
  export declare function openVideoCtx(opts: VideoCtxOptions, label: string): Promise<CodecContext>;
569
643
 
570
644
  export declare class OutputSink implements AsyncDisposable {
@@ -587,9 +661,7 @@ export declare class OutputSink implements AsyncDisposable {
587
661
 
588
662
  export declare function packBits(bits: number[]): Buffer;
589
663
 
590
- declare function pargs(): string[];
591
- export { pargs }
592
- export { pargs as pargs_alias_1 }
664
+ export declare function pargs(): string[];
593
665
 
594
666
  declare function parseNumber(x: unknown): number;
595
667
  export { parseNumber }
@@ -597,9 +669,7 @@ export { parseNumber as parseNumber_alias_1 }
597
669
 
598
670
  export declare function parseNvencHevcConfig(extradata: Buffer): NvencHevcConfig;
599
671
 
600
- declare function parseString(x: unknown): string;
601
- export { parseString }
602
- export { parseString as parseString_alias_1 }
672
+ export declare function parseString(x: unknown): string;
603
673
 
604
674
  /** Patch every VPS/SPS NAL in an Annex B bitstream so PTL matches Apple/x265. */
605
675
  export declare function patchHevcAlphaPtl(bitstream: Buffer): Buffer;
@@ -622,16 +692,16 @@ export declare interface ProbeResult {
622
692
  width: number;
623
693
  height: number;
624
694
  duration: number;
695
+ /** PTS (s) of the first decodable frame; a corrupt/empty leading run is held on it, like Chrome. */
696
+ leadGap: number;
625
697
  }
626
698
 
627
- declare interface ProcessHandle {
699
+ export declare interface ProcessHandle {
628
700
  process: ChildProcess;
629
701
  wait: Promise<void>;
630
702
  get killed(): boolean;
631
703
  kill(): void;
632
704
  }
633
- export { ProcessHandle }
634
- export { ProcessHandle as ProcessHandle_alias_1 }
635
705
 
636
706
  declare class ProgressBar {
637
707
  private _written;
@@ -658,7 +728,7 @@ export { ProgressCallback }
658
728
  export { ProgressCallback as ProgressCallback_alias_1 }
659
729
 
660
730
  export declare interface ProgressMsg {
661
- type: IpcMsgType.PROGRESS;
731
+ type: IpcMsgType.Progress;
662
732
  value: number;
663
733
  }
664
734
 
@@ -668,25 +738,15 @@ declare function pup(source: string, options: Partial<PupOptions>): Promise<PupR
668
738
  export { pup }
669
739
  export { pup as pup_alias_1 }
670
740
 
671
- declare const PUP_ARGS_KEY = "--pup-priv-args";
672
- export { PUP_ARGS_KEY }
673
- export { PUP_ARGS_KEY as PUP_ARGS_KEY_alias_1 }
741
+ export declare const PUP_ARGS_KEY = "--pup-priv-args";
674
742
 
675
- declare const pupApp: string;
676
- export { pupApp }
677
- export { pupApp as pupApp_alias_1 }
743
+ export declare const pupApp: string;
678
744
 
679
- declare const pupAudioPreload: string;
680
- export { pupAudioPreload }
681
- export { pupAudioPreload as pupAudioPreload_alias_1 }
745
+ export declare const pupAudioPreload: string;
682
746
 
683
- declare const pupIframePreload: string;
684
- export { pupIframePreload }
685
- export { pupIframePreload as pupIframePreload_alias_1 }
747
+ export declare const pupIframePreload: string;
686
748
 
687
- declare const pupLogLevel: number;
688
- export { pupLogLevel }
689
- export { pupLogLevel as pupLogLevel_alias_1 }
749
+ export declare const pupLogLevel: number;
690
750
 
691
751
  declare interface PupOptions extends Partial<RenderOptions> {
692
752
  signal?: AbortSignal;
@@ -696,9 +756,7 @@ declare interface PupOptions extends Partial<RenderOptions> {
696
756
  export { PupOptions }
697
757
  export { PupOptions as PupOptions_alias_1 }
698
758
 
699
- declare const pupPkgRoot: string;
700
- export { pupPkgRoot }
701
- export { pupPkgRoot as pupPkgRoot_alias_1 }
759
+ export declare const pupPkgRoot: string;
702
760
 
703
761
  declare interface PupResult extends RenderResult {
704
762
  }
@@ -710,7 +768,7 @@ export declare function removeEmulationPrevention(data: Buffer): Buffer;
710
768
 
711
769
  export declare function render(options: IPCRenderOptions): Promise<IpcDonePayload>;
712
770
 
713
- declare type RenderOptions = z.infer<typeof RenderSchema>;
771
+ declare type RenderOptions = z.infer<typeof renderSchema>;
714
772
  export { RenderOptions }
715
773
  export { RenderOptions as RenderOptions_alias_1 }
716
774
 
@@ -723,7 +781,7 @@ declare interface RenderResult {
723
781
  export { RenderResult }
724
782
  export { RenderResult as RenderResult_alias_1 }
725
783
 
726
- declare const RenderSchema: z.ZodObject<{
784
+ export declare const renderSchema: z.ZodObject<{
727
785
  duration: z.ZodNumber;
728
786
  width: z.ZodNumber;
729
787
  height: z.ZodNumber;
@@ -735,13 +793,12 @@ declare const RenderSchema: z.ZodObject<{
735
793
  disableGpu: z.ZodBoolean;
736
794
  disableHwCodec: z.ZodBoolean;
737
795
  windowTolerant: z.ZodBoolean;
796
+ windowTimeout: z.ZodNumber;
738
797
  }, z.core.$strip>;
739
- export { RenderSchema }
740
- export { RenderSchema as RenderSchema_alias_1 }
741
798
 
742
799
  export declare function resizeDrawable(cdp: Debugger, size: Size): Promise<void>;
743
800
 
744
- declare interface RetryOptions<Args extends any[], Ret> {
801
+ declare interface RetryOptions<Args extends unknown[], Ret> {
745
802
  fn: (...args: Args) => Promise<Ret>;
746
803
  maxAttempts?: number;
747
804
  timeout?: number;
@@ -775,9 +832,13 @@ export declare interface RunElectronAppOptions {
775
832
  args: unknown[];
776
833
  }
777
834
 
835
+ export declare const SCHEME = "pup-frame://";
836
+
778
837
  export declare function send(cdp: Debugger, method: string, params?: object): Promise<unknown>;
779
838
 
780
- export declare function setInterceptor({ source, window, useInnerProxy }: NetworkOptions): void;
839
+ export declare function setInterceptor({ source, window, useInnerProxy, cancelMedia }: NetworkOptions): void;
840
+
841
+ export declare function setupCanvas(video: HTMLVideoElement, snap: OffscreenCanvas | undefined): HTMLCanvasElement;
781
842
 
782
843
  export declare function setupFrameProtocol(): void;
783
844
 
@@ -817,10 +878,22 @@ export declare function stopStego(cdp: Debugger): Promise<unknown>;
817
878
 
818
879
  export declare function swapBuffer(wc: WebContents, expected: number, interval: number): Promise<void>;
819
880
 
820
- export declare function tick(frame: WebFrameMain | undefined, timestampMs: number): Promise<void>;
881
+ export declare function syncOverlay(video: HTMLVideoElement, cv: HTMLCanvasElement): void;
882
+
883
+ export declare const TAG = "[VideoHook]";
884
+
885
+ export declare function tick(args: AdvanceOptions): Promise<void>;
821
886
 
822
887
  export declare const TICK_SYMBOL = "__pup_tick__";
823
888
 
889
+ export declare function timeRanges(end: number): TimeRangesLike;
890
+
891
+ export declare interface TimeRangesLike {
892
+ length: number;
893
+ start(i: number): number;
894
+ end(i: number): number;
895
+ }
896
+
824
897
  export declare interface UnifiedExtradataOptions {
825
898
  baseExtradata: Buffer;
826
899
  alphaExtradata: Buffer;
@@ -830,11 +903,17 @@ export declare interface UnifiedExtradataOptions {
830
903
 
831
904
  export declare function unsetInterceptor(window: BrowserWindow): void;
832
905
 
833
- declare function useRetry<Args extends any[], Ret>({ fn, maxAttempts, timeout, signal }: RetryOptions<Args, Ret>): (...args: Args) => Promise<Ret>;
906
+ declare function useRetry<Args extends unknown[], Ret>({ fn, maxAttempts, timeout, signal, }: RetryOptions<Args, Ret>): (...args: Args) => Promise<Ret>;
834
907
  export { useRetry }
835
908
  export { useRetry as useRetry_alias_1 }
836
909
 
837
- export declare const VIDEO_SYMBOL = "__pup_video__";
910
+ declare type Vec4 = [number, number, number, number];
911
+
912
+ export declare interface VideoCache {
913
+ bitmaps: Map<number, ImageBitmap>;
914
+ inFlight: Map<number, Promise<ImageBitmap | null>>;
915
+ readers: Map<VideoState, number>;
916
+ }
838
917
 
839
918
  export declare interface VideoCtxOptions {
840
919
  codec: Codec;
@@ -875,12 +954,55 @@ export declare interface VideoEncoderOptions {
875
954
  muxer: FormatMuxer;
876
955
  }
877
956
 
957
+ export declare interface VideoFrameMeta {
958
+ presentationTime: number;
959
+ expectedDisplayTime: number;
960
+ width: number;
961
+ height: number;
962
+ mediaTime: number;
963
+ presentedFrames: number;
964
+ }
965
+
966
+ export declare class VideoHook {
967
+ readonly sessions: WeakMap<HTMLVideoElement, VideoState>;
968
+ readonly attaching: WeakMap<HTMLVideoElement, Promise<VideoState | null>>;
969
+ readonly opening: Set<Promise<unknown>>;
970
+ readonly cache: FrameCache;
971
+ rvfcSeq: number;
972
+ currMs: number;
973
+ private _lastSnapshot;
974
+ install(): void;
975
+ attach(video: HTMLVideoElement, native?: boolean): Promise<VideoState | null>;
976
+ ready(): Promise<void>;
977
+ resume(video: HTMLVideoElement, state: VideoState): void;
978
+ detach(video: HTMLVideoElement): void;
979
+ onSrcChange(video: HTMLVideoElement): void;
980
+ reattach(video: HTMLVideoElement, state: VideoState): void;
981
+ private scan;
982
+ }
983
+
878
984
  export declare interface VideoMeta {
879
985
  id: string;
986
+ /** Intrinsic source dimensions (reported as videoWidth/videoHeight). */
880
987
  width: number;
881
988
  height: number;
989
+ /** Decoded+scaled frame dimensions actually served (≤ source; capped to the display box). */
990
+ frameWidth: number;
991
+ frameHeight: number;
882
992
  fps: number;
883
993
  duration: number;
994
+ /** Seconds of corrupt/empty leading content held on the first decodable frame. */
995
+ leadGap: number;
996
+ }
997
+
998
+ export declare interface VideoMeta_alias_1 {
999
+ id: string;
1000
+ width: number;
1001
+ height: number;
1002
+ frameWidth: number;
1003
+ frameHeight: number;
1004
+ duration: number;
1005
+ fps: number;
884
1006
  }
885
1007
 
886
1008
  export declare interface VideoSetup {
@@ -891,6 +1013,26 @@ export declare interface VideoSetup {
891
1013
  ownsHw: boolean;
892
1014
  }
893
1015
 
1016
+ export declare interface VideoState {
1017
+ meta: VideoMeta_alias_1 | null;
1018
+ cv: HTMLCanvasElement;
1019
+ ctx: CanvasRenderingContext2D;
1020
+ paused: boolean;
1021
+ currentTime: number;
1022
+ ended: boolean;
1023
+ lastDrawnIdx: number;
1024
+ dead: boolean;
1025
+ objectFit: string;
1026
+ readyState: number;
1027
+ networkState: number;
1028
+ seeking: boolean;
1029
+ waiting: boolean;
1030
+ error: MediaErrorLike | undefined;
1031
+ presentedFrames: number;
1032
+ maxReached: number;
1033
+ rvfc: Map<number, FrameCb>;
1034
+ }
1035
+
894
1036
  export declare class VideoToolboxEncoder implements Disposable {
895
1037
  private _ctx;
896
1038
  private _pkt;
@@ -929,8 +1071,6 @@ export declare interface WindowOptions {
929
1071
 
930
1072
  export declare function withRerender<T>(signal: AbortSignal, action: () => Promise<T>): Promise<T>;
931
1073
 
932
- declare function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T>;
933
- export { withTimeout }
934
- export { withTimeout as withTimeout_alias_1 }
1074
+ export declare function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T>;
935
1075
 
936
1076
  export { }