pup-recorder 0.1.13 → 0.1.14

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/Cargo.lock CHANGED
@@ -32,6 +32,31 @@ dependencies = [
32
32
  "unicode-segmentation",
33
33
  ]
34
34
 
35
+ [[package]]
36
+ name = "crossbeam-deque"
37
+ version = "0.8.6"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
40
+ dependencies = [
41
+ "crossbeam-epoch",
42
+ "crossbeam-utils",
43
+ ]
44
+
45
+ [[package]]
46
+ name = "crossbeam-epoch"
47
+ version = "0.9.18"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
50
+ dependencies = [
51
+ "crossbeam-utils",
52
+ ]
53
+
54
+ [[package]]
55
+ name = "crossbeam-utils"
56
+ version = "0.8.21"
57
+ source = "registry+https://github.com/rust-lang/crates.io-index"
58
+ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
59
+
35
60
  [[package]]
36
61
  name = "ctor"
37
62
  version = "0.2.9"
@@ -42,6 +67,12 @@ dependencies = [
42
67
  "syn",
43
68
  ]
44
69
 
70
+ [[package]]
71
+ name = "either"
72
+ version = "1.15.0"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
75
+
45
76
  [[package]]
46
77
  name = "libloading"
47
78
  version = "0.8.9"
@@ -123,7 +154,7 @@ dependencies = [
123
154
  "napi",
124
155
  "napi-build",
125
156
  "napi-derive",
126
- "tokio",
157
+ "rayon",
127
158
  ]
128
159
 
129
160
  [[package]]
@@ -134,9 +165,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
134
165
 
135
166
  [[package]]
136
167
  name = "pin-project-lite"
137
- version = "0.2.16"
168
+ version = "0.2.17"
138
169
  source = "registry+https://github.com/rust-lang/crates.io-index"
139
- checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
170
+ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
140
171
 
141
172
  [[package]]
142
173
  name = "proc-macro2"
@@ -156,6 +187,26 @@ dependencies = [
156
187
  "proc-macro2",
157
188
  ]
158
189
 
190
+ [[package]]
191
+ name = "rayon"
192
+ version = "1.11.0"
193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
194
+ checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f"
195
+ dependencies = [
196
+ "either",
197
+ "rayon-core",
198
+ ]
199
+
200
+ [[package]]
201
+ name = "rayon-core"
202
+ version = "1.13.0"
203
+ source = "registry+https://github.com/rust-lang/crates.io-index"
204
+ checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
205
+ dependencies = [
206
+ "crossbeam-deque",
207
+ "crossbeam-utils",
208
+ ]
209
+
159
210
  [[package]]
160
211
  name = "regex"
161
212
  version = "1.12.2"
@@ -204,9 +255,9 @@ dependencies = [
204
255
 
205
256
  [[package]]
206
257
  name = "tokio"
207
- version = "1.49.0"
258
+ version = "1.50.0"
208
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
209
- checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
260
+ checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d"
210
261
  dependencies = [
211
262
  "pin-project-lite",
212
263
  ]
package/Cargo.toml CHANGED
@@ -20,4 +20,4 @@ napi-build = "2"
20
20
  [dependencies]
21
21
  napi = { version = "2", features = ["napi4", "tokio_rt"] }
22
22
  napi-derive = "2"
23
- tokio = { version = "1", features = ["rt"] }
23
+ rayon = "1"
@@ -1,6 +1,11 @@
1
1
  import { BrowserWindow } from 'electron';
2
2
  import { ChildProcess } from 'child_process';
3
3
  import type { Debugger } from 'electron';
4
+ import type { EncodedAudioChunk as EncodedAudioChunk_2 } from '@napi-rs/webcodecs';
5
+ import type { EncodedAudioChunkMetadataJs } from '@napi-rs/webcodecs';
6
+ import type { EncodedVideoChunk as EncodedVideoChunk_2 } from '@napi-rs/webcodecs';
7
+ import type { EncodedVideoChunkMetadataJs } from '@napi-rs/webcodecs';
8
+ import { IsobmffOutputFormat } from 'mediabunny';
4
9
  import type { NativeImage } from 'electron';
5
10
  import { Size } from 'electron';
6
11
  import { SpawnOptions } from 'child_process';
@@ -37,26 +42,18 @@ export { AsyncTask }
37
42
  export { AsyncTask as AsyncTask_alias_1 }
38
43
 
39
44
  export declare interface AudioCapture {
40
- sampleRate?: number;
41
45
  teardown(): Promise<void>;
42
46
  }
43
47
 
44
- declare interface AudioSpec {
45
- pcmPath: string;
46
- sampleRate: number;
47
- }
48
- export { AudioSpec }
49
- export { AudioSpec as AudioSpec_alias_1 }
50
-
51
48
  export declare const basedir: string;
52
49
 
53
- export declare interface BGRAFileOptions {
54
- bgra: string;
55
- outFile: string;
56
- spec: VideoSpec;
57
- audio?: AudioSpec;
50
+ export declare interface BgraConverter {
51
+ new (width: number, height: number): BgraConverter;
52
+ convert(bgra: Buffer): Promise<Buffer>;
58
53
  }
59
54
 
55
+ export declare const BgraConverter: BgraConverter;
56
+
60
57
  export declare function buildRust(): Promise<void>;
61
58
 
62
59
  export declare function buildWrapperHTML(targetURL: string, size: Size): string;
@@ -67,11 +64,6 @@ export declare function checkHTML(source: string): void;
67
64
 
68
65
  export declare type CLICallback = (source: string, options: RenderOptions) => Promise<unknown>;
69
66
 
70
- declare interface Command {
71
- command: string;
72
- args: string[];
73
- }
74
-
75
67
  declare class ConcurrencyLimiter {
76
68
  readonly maxConcurrency: number;
77
69
  private _active;
@@ -88,12 +80,6 @@ declare class ConcurrencyLimiter {
88
80
  export { ConcurrencyLimiter }
89
81
  export { ConcurrencyLimiter as ConcurrencyLimiter_alias_1 }
90
82
 
91
- export declare function createBGRA2MOVPipeline(x265: string, options: BGRAFileOptions): X265Pipeline;
92
-
93
- export declare function createBGRAFileCommand(options: BGRAFileOptions): Command;
94
-
95
- export declare function createCoverCommand(src: string, dst: string): Command;
96
-
97
83
  export declare function decodeTimestamp(bitmap: Buffer, size: Size): number | undefined;
98
84
 
99
85
  declare const DEFAULT_DURATION = 5;
@@ -118,9 +104,27 @@ export { DEFAULT_WIDTH as DEFAULT_WIDTH_alias_1 }
118
104
 
119
105
  export declare function electronOpts(): Promise<string[]>;
120
106
 
121
- export declare function encodeBGRAFile(options: BGRAFileOptions): ProcessHandle;
107
+ export declare class EncoderPipeline {
108
+ private readonly _width;
109
+ private readonly _height;
110
+ private readonly _fps;
111
+ private readonly _entries;
112
+ private readonly _converter;
113
+ private _frameIndex;
114
+ constructor({ width, height, fps, formats }: EncoderPipelineOptions);
115
+ setupAudio(sampleRate: number): void;
116
+ encodeFrame(bgraBuffer: Buffer, timestampUs: number): Promise<void>;
117
+ encodeAudio(interleavedFloat32Buffer: Buffer, sampleRate: number): void;
118
+ flush(): Promise<void>;
119
+ finalize(outDir: string): Promise<Partial<Record<VideoFormat, string>>>;
120
+ }
122
121
 
123
- export declare function encodeBgraToMov(options: BGRAFileOptions): ProcessHandle;
122
+ export declare interface EncoderPipelineOptions {
123
+ width: number;
124
+ height: number;
125
+ fps: number;
126
+ formats: VideoFormat[];
127
+ }
124
128
 
125
129
  declare type EnvParser<T> = (value: unknown) => T;
126
130
  export { EnvParser }
@@ -130,18 +134,38 @@ declare function exec(cmd: string, options?: SpawnOptions): ProcessHandle;
130
134
  export { exec }
131
135
  export { exec as exec_alias_1 }
132
136
 
133
- export declare interface FixedBufferWriter {
134
- new (path: string, bufferSize: number, queueDepth?: number): FixedBufferWriter;
135
- write(buffer: Buffer): void;
136
- close(): Promise<void>;
137
- }
138
-
139
- export declare const FixedBufferWriter: FixedBufferWriter;
140
-
141
137
  export declare const FRAME_SYNC_MARKER_HEIGHT = 1;
142
138
 
143
139
  export declare const FRAME_SYNC_MARKER_WIDTH = 32;
144
140
 
141
+ declare class HEVCIsobmffMuxer implements MediaMuxer {
142
+ private readonly _width;
143
+ private readonly _height;
144
+ private readonly _format;
145
+ private _videoChunks;
146
+ private _audioChunks;
147
+ private _videoDesc?;
148
+ private _audioInit?;
149
+ constructor(width: number, height: number, format: IsobmffOutputFormat);
150
+ addVideoChunk(chunk: EncodedVideoChunk_2, meta?: EncodedVideoChunkMetadataJs): void;
151
+ addAudioChunk(chunk: EncodedAudioChunk_2, meta?: EncodedAudioChunkMetadataJs): void;
152
+ finalize(): Promise<Uint8Array>;
153
+ }
154
+ export { HEVCIsobmffMuxer }
155
+ export { HEVCIsobmffMuxer as HEVCIsobmffMuxer_alias_1 }
156
+
157
+ declare class HEVCMovMuxer extends HEVCIsobmffMuxer {
158
+ constructor(width: number, height: number);
159
+ }
160
+ export { HEVCMovMuxer }
161
+ export { HEVCMovMuxer as HEVCMovMuxer_alias_1 }
162
+
163
+ declare class HEVCMp4Muxer extends HEVCIsobmffMuxer {
164
+ constructor(width: number, height: number);
165
+ }
166
+ export { HEVCMp4Muxer }
167
+ export { HEVCMp4Muxer as HEVCMp4Muxer_alias_1 }
168
+
145
169
  export declare function isEmpty(image: NativeImage): boolean;
146
170
 
147
171
  declare function isVideoFormat(s: string): s is VideoFormat;
@@ -162,10 +186,13 @@ export { Lazy as Lazy_alias_1 }
162
186
  export declare function loadWindow(source: string, options: RenderOptions): Promise<BrowserWindow>;
163
187
 
164
188
  declare class Logger implements LoggerLike {
189
+ private _level;
165
190
  private _impl?;
191
+ get level(): number;
192
+ set level(value: number);
166
193
  get impl(): LoggerLike | undefined;
167
194
  set impl(value: LoggerLike);
168
- constructor();
195
+ constructor(_level?: number);
169
196
  debug(...messages: unknown[]): void;
170
197
  info(...messages: unknown[]): void;
171
198
  warn(...messages: unknown[]): void;
@@ -174,6 +201,8 @@ declare class Logger implements LoggerLike {
174
201
  private dispatch;
175
202
  attach(proc: ChildProcess, name: string): Promise<void>;
176
203
  }
204
+ export { Logger }
205
+ export { Logger as Logger_alias_1 }
177
206
 
178
207
  declare const logger: Logger;
179
208
  export { logger }
@@ -190,7 +219,13 @@ export { LoggerLike as LoggerLike_alias_1 }
190
219
 
191
220
  export declare function makeCLI(name: string, callback: CLICallback): Promise<void>;
192
221
 
193
- export declare function mountX265(): string;
222
+ declare interface MediaMuxer {
223
+ addVideoChunk(chunk: EncodedVideoChunk_2, meta?: EncodedVideoChunkMetadataJs): void;
224
+ addAudioChunk(chunk: EncodedAudioChunk_2, meta?: EncodedAudioChunkMetadataJs): void;
225
+ finalize(): Promise<Uint8Array>;
226
+ }
227
+ export { MediaMuxer }
228
+ export { MediaMuxer as MediaMuxer_alias_1 }
194
229
 
195
230
  export declare interface NetworkOptions {
196
231
  source: string;
@@ -253,10 +288,6 @@ declare const pupLogLevel: number;
253
288
  export { pupLogLevel }
254
289
  export { pupLogLevel as pupLogLevel_alias_1 }
255
290
 
256
- declare const pupNoCleanup: boolean;
257
- export { pupNoCleanup }
258
- export { pupNoCleanup as pupNoCleanup_alias_1 }
259
-
260
291
  declare interface PupOptions extends Partial<RenderOptions> {
261
292
  cancelQuery?: AbortQuery;
262
293
  onProgress?: PupProgressCallback;
@@ -268,9 +299,7 @@ declare type PupProgressCallback = (progress: number) => Promise<void> | void;
268
299
  export { PupProgressCallback }
269
300
  export { PupProgressCallback as PupProgressCallback_alias_1 }
270
301
 
271
- declare interface PupResult {
272
- options: RenderOptions;
273
- files: VideoFilesWithCover;
302
+ declare interface PupResult extends RenderResult {
274
303
  }
275
304
  export { PupResult }
276
305
  export { PupResult as PupResult_alias_1 }
@@ -288,8 +317,7 @@ export { RenderOptions as RenderOptions_alias_1 }
288
317
  declare interface RenderResult {
289
318
  options: RenderOptions;
290
319
  written: number;
291
- bgra: string;
292
- audio?: AudioSpec;
320
+ files: VideoFiles;
293
321
  }
294
322
  export { RenderResult }
295
323
  export { RenderResult as RenderResult_alias_1 }
@@ -324,7 +352,7 @@ export declare function runElectronApp(size: Size, args: unknown[]): Promise<Pro
324
352
 
325
353
  export declare function setInterceptor({ source, window, useInnerProxy, }: NetworkOptions): void;
326
354
 
327
- export declare function setupAudioCapture(pcmPath: string): Promise<AudioCapture>;
355
+ export declare function setupAudioCapture(pipeline: EncoderPipeline): Promise<AudioCapture>;
328
356
 
329
357
  export declare function shoot(source: string, options: RenderOptions): Promise<void>;
330
358
 
@@ -336,8 +364,6 @@ export declare function startSync(cdp: Debugger): Promise<any>;
336
364
 
337
365
  export declare function stopSync(cdp: Debugger): Promise<any>;
338
366
 
339
- export declare function unmountX265(path: string): void;
340
-
341
367
  export declare function unsetInterceptor(window: BrowserWindow): void;
342
368
 
343
369
  declare function useRetry<Args extends any[], Ret>({ fn, maxAttempts, timeout, }: RetryOptions<Args, Ret>): (...args: Args) => Promise<Ret>;
@@ -349,30 +375,32 @@ export { VIDEO_FORMATS }
349
375
  export { VIDEO_FORMATS as VIDEO_FORMATS_alias_1 }
350
376
 
351
377
  declare interface VideoFiles {
378
+ cover: string;
352
379
  mp4?: string;
353
- webm?: string;
354
380
  mov?: string;
381
+ webm?: string;
355
382
  }
356
383
  export { VideoFiles }
357
384
  export { VideoFiles as VideoFiles_alias_1 }
358
385
 
359
- declare interface VideoFilesWithCover extends VideoFiles {
360
- cover: string;
361
- }
362
- export { VideoFilesWithCover }
363
- export { VideoFilesWithCover as VideoFilesWithCover_alias_1 }
364
-
365
386
  declare type VideoFormat = (typeof VIDEO_FORMATS)[number];
366
387
  export { VideoFormat }
367
388
  export { VideoFormat as VideoFormat_alias_1 }
368
389
 
369
- declare interface VideoSpec {
370
- fps: number;
371
- frames: number;
372
- size: Size;
390
+ declare class Vp9WebMMuxer implements MediaMuxer {
391
+ private readonly _width;
392
+ private readonly _height;
393
+ private _videoChunks;
394
+ private _audioChunks;
395
+ private _videoDesc?;
396
+ private _audioInit?;
397
+ constructor(width: number, height: number);
398
+ addVideoChunk(chunk: EncodedVideoChunk_2, meta?: EncodedVideoChunkMetadataJs): void;
399
+ addAudioChunk(chunk: EncodedAudioChunk_2, meta?: EncodedAudioChunkMetadataJs): void;
400
+ finalize(): Promise<Uint8Array>;
373
401
  }
374
- export { VideoSpec }
375
- export { VideoSpec as VideoSpec_alias_1 }
402
+ export { Vp9WebMMuxer }
403
+ export { Vp9WebMMuxer as Vp9WebMMuxer_alias_1 }
376
404
 
377
405
  export declare class WaitableEvent {
378
406
  private _promise?;
@@ -387,10 +415,4 @@ export declare interface WaitOptions {
387
415
  onTimeout?: () => void;
388
416
  }
389
417
 
390
- declare interface X265Pipeline {
391
- raw: Command;
392
- x265: Command;
393
- mux: Command;
394
- }
395
-
396
418
  export { }