node-av-lgpl 0.0.0 → 7.1.0-beta.1

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.
Files changed (311) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +711 -0
  3. package/dist/api/audio-frame-buffer.d.ts +636 -0
  4. package/dist/api/audio-frame-buffer.js +1027 -0
  5. package/dist/api/audio-frame-buffer.js.map +1 -0
  6. package/dist/api/bitstream-filter.d.ts +938 -0
  7. package/dist/api/bitstream-filter.js +1427 -0
  8. package/dist/api/bitstream-filter.js.map +1 -0
  9. package/dist/api/constants.d.ts +44 -0
  10. package/dist/api/constants.js +45 -0
  11. package/dist/api/constants.js.map +1 -0
  12. package/dist/api/data/test_av1.ivf +0 -0
  13. package/dist/api/data/test_h264.h264 +0 -0
  14. package/dist/api/data/test_hevc.h265 +0 -0
  15. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  16. package/dist/api/data/test_vp8.ivf +0 -0
  17. package/dist/api/data/test_vp9.ivf +0 -0
  18. package/dist/api/decoder.d.ts +1413 -0
  19. package/dist/api/decoder.js +2367 -0
  20. package/dist/api/decoder.js.map +1 -0
  21. package/dist/api/demuxer.d.ts +1295 -0
  22. package/dist/api/demuxer.js +2344 -0
  23. package/dist/api/demuxer.js.map +1 -0
  24. package/dist/api/device.d.ts +589 -0
  25. package/dist/api/device.js +964 -0
  26. package/dist/api/device.js.map +1 -0
  27. package/dist/api/encoder-pool.d.ts +262 -0
  28. package/dist/api/encoder-pool.js +397 -0
  29. package/dist/api/encoder-pool.js.map +1 -0
  30. package/dist/api/encoder.d.ts +1509 -0
  31. package/dist/api/encoder.js +2619 -0
  32. package/dist/api/encoder.js.map +1 -0
  33. package/dist/api/filter-complex.d.ts +828 -0
  34. package/dist/api/filter-complex.js +1661 -0
  35. package/dist/api/filter-complex.js.map +1 -0
  36. package/dist/api/filter-presets.d.ts +800 -0
  37. package/dist/api/filter-presets.js +1554 -0
  38. package/dist/api/filter-presets.js.map +1 -0
  39. package/dist/api/filter.d.ts +1339 -0
  40. package/dist/api/filter.js +2075 -0
  41. package/dist/api/filter.js.map +1 -0
  42. package/dist/api/fmp4-stream.d.ts +797 -0
  43. package/dist/api/fmp4-stream.js +1428 -0
  44. package/dist/api/fmp4-stream.js.map +1 -0
  45. package/dist/api/hardware.d.ts +677 -0
  46. package/dist/api/hardware.js +1300 -0
  47. package/dist/api/hardware.js.map +1 -0
  48. package/dist/api/index.d.ts +21 -0
  49. package/dist/api/index.js +38 -0
  50. package/dist/api/index.js.map +1 -0
  51. package/dist/api/io-stream.d.ts +308 -0
  52. package/dist/api/io-stream.js +358 -0
  53. package/dist/api/io-stream.js.map +1 -0
  54. package/dist/api/muxer.d.ts +1311 -0
  55. package/dist/api/muxer.js +2672 -0
  56. package/dist/api/muxer.js.map +1 -0
  57. package/dist/api/pipeline.d.ts +801 -0
  58. package/dist/api/pipeline.js +1344 -0
  59. package/dist/api/pipeline.js.map +1 -0
  60. package/dist/api/probe.d.ts +128 -0
  61. package/dist/api/probe.js +227 -0
  62. package/dist/api/probe.js.map +1 -0
  63. package/dist/api/rtp-stream.d.ts +497 -0
  64. package/dist/api/rtp-stream.js +1131 -0
  65. package/dist/api/rtp-stream.js.map +1 -0
  66. package/dist/api/scaler.d.ts +561 -0
  67. package/dist/api/scaler.js +918 -0
  68. package/dist/api/scaler.js.map +1 -0
  69. package/dist/api/types.d.ts +17 -0
  70. package/dist/api/types.js +2 -0
  71. package/dist/api/types.js.map +1 -0
  72. package/dist/api/utilities/async-queue.d.ts +149 -0
  73. package/dist/api/utilities/async-queue.js +254 -0
  74. package/dist/api/utilities/async-queue.js.map +1 -0
  75. package/dist/api/utilities/audio-sample.d.ts +117 -0
  76. package/dist/api/utilities/audio-sample.js +112 -0
  77. package/dist/api/utilities/audio-sample.js.map +1 -0
  78. package/dist/api/utilities/audio-transcode.d.ts +20 -0
  79. package/dist/api/utilities/audio-transcode.js +27 -0
  80. package/dist/api/utilities/audio-transcode.js.map +1 -0
  81. package/dist/api/utilities/channel-layout.d.ts +76 -0
  82. package/dist/api/utilities/channel-layout.js +80 -0
  83. package/dist/api/utilities/channel-layout.js.map +1 -0
  84. package/dist/api/utilities/codec-format.d.ts +87 -0
  85. package/dist/api/utilities/codec-format.js +117 -0
  86. package/dist/api/utilities/codec-format.js.map +1 -0
  87. package/dist/api/utilities/context-options.d.ts +25 -0
  88. package/dist/api/utilities/context-options.js +23 -0
  89. package/dist/api/utilities/context-options.js.map +1 -0
  90. package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
  91. package/dist/api/utilities/electron-shared-texture.js +540 -0
  92. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  93. package/dist/api/utilities/image.d.ts +207 -0
  94. package/dist/api/utilities/image.js +213 -0
  95. package/dist/api/utilities/image.js.map +1 -0
  96. package/dist/api/utilities/index.d.ts +14 -0
  97. package/dist/api/utilities/index.js +27 -0
  98. package/dist/api/utilities/index.js.map +1 -0
  99. package/dist/api/utilities/live-decoding.d.ts +15 -0
  100. package/dist/api/utilities/live-decoding.js +32 -0
  101. package/dist/api/utilities/live-decoding.js.map +1 -0
  102. package/dist/api/utilities/media-type.d.ts +49 -0
  103. package/dist/api/utilities/media-type.js +53 -0
  104. package/dist/api/utilities/media-type.js.map +1 -0
  105. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  106. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  107. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  108. package/dist/api/utilities/pixel-format.d.ts +89 -0
  109. package/dist/api/utilities/pixel-format.js +97 -0
  110. package/dist/api/utilities/pixel-format.js.map +1 -0
  111. package/dist/api/utilities/sample-format.d.ts +129 -0
  112. package/dist/api/utilities/sample-format.js +141 -0
  113. package/dist/api/utilities/sample-format.js.map +1 -0
  114. package/dist/api/utilities/scale-size.d.ts +51 -0
  115. package/dist/api/utilities/scale-size.js +55 -0
  116. package/dist/api/utilities/scale-size.js.map +1 -0
  117. package/dist/api/utilities/scheduler.d.ts +138 -0
  118. package/dist/api/utilities/scheduler.js +98 -0
  119. package/dist/api/utilities/scheduler.js.map +1 -0
  120. package/dist/api/utilities/streaming.d.ts +186 -0
  121. package/dist/api/utilities/streaming.js +309 -0
  122. package/dist/api/utilities/streaming.js.map +1 -0
  123. package/dist/api/utilities/timestamp.d.ts +193 -0
  124. package/dist/api/utilities/timestamp.js +206 -0
  125. package/dist/api/utilities/timestamp.js.map +1 -0
  126. package/dist/api/utilities/video-transcode.d.ts +218 -0
  127. package/dist/api/utilities/video-transcode.js +624 -0
  128. package/dist/api/utilities/video-transcode.js.map +1 -0
  129. package/dist/api/utilities/whisper-model.d.ts +330 -0
  130. package/dist/api/utilities/whisper-model.js +587 -0
  131. package/dist/api/utilities/whisper-model.js.map +1 -0
  132. package/dist/api/utils.d.ts +19 -0
  133. package/dist/api/utils.js +39 -0
  134. package/dist/api/utils.js.map +1 -0
  135. package/dist/api/webrtc-stream.d.ts +294 -0
  136. package/dist/api/webrtc-stream.js +546 -0
  137. package/dist/api/webrtc-stream.js.map +1 -0
  138. package/dist/api/whisper.d.ts +326 -0
  139. package/dist/api/whisper.js +402 -0
  140. package/dist/api/whisper.js.map +1 -0
  141. package/dist/constants/bsf-options.d.ts +364 -0
  142. package/dist/constants/bsf-options.js +7 -0
  143. package/dist/constants/bsf-options.js.map +1 -0
  144. package/dist/constants/channel-layouts.d.ts +53 -0
  145. package/dist/constants/channel-layouts.js +57 -0
  146. package/dist/constants/channel-layouts.js.map +1 -0
  147. package/dist/constants/constants.d.ts +2435 -0
  148. package/dist/constants/constants.js +1989 -0
  149. package/dist/constants/constants.js.map +1 -0
  150. package/dist/constants/decoders.d.ts +651 -0
  151. package/dist/constants/decoders.js +641 -0
  152. package/dist/constants/decoders.js.map +1 -0
  153. package/dist/constants/encoders.d.ts +314 -0
  154. package/dist/constants/encoders.js +309 -0
  155. package/dist/constants/encoders.js.map +1 -0
  156. package/dist/constants/filter-options.d.ts +12099 -0
  157. package/dist/constants/filter-options.js +7 -0
  158. package/dist/constants/filter-options.js.map +1 -0
  159. package/dist/constants/format-options.d.ts +4319 -0
  160. package/dist/constants/format-options.js +7 -0
  161. package/dist/constants/format-options.js.map +1 -0
  162. package/dist/constants/formats.d.ts +18 -0
  163. package/dist/constants/formats.js +7 -0
  164. package/dist/constants/formats.js.map +1 -0
  165. package/dist/constants/hardware.d.ts +26 -0
  166. package/dist/constants/hardware.js +27 -0
  167. package/dist/constants/hardware.js.map +1 -0
  168. package/dist/constants/index.d.ts +10 -0
  169. package/dist/constants/index.js +6 -0
  170. package/dist/constants/index.js.map +1 -0
  171. package/dist/constants/options.d.ts +6217 -0
  172. package/dist/constants/options.js +7 -0
  173. package/dist/constants/options.js.map +1 -0
  174. package/dist/ffmpeg/index.d.ts +101 -0
  175. package/dist/ffmpeg/index.js +161 -0
  176. package/dist/ffmpeg/index.js.map +1 -0
  177. package/dist/ffmpeg/version.d.ts +6 -0
  178. package/dist/ffmpeg/version.js +7 -0
  179. package/dist/ffmpeg/version.js.map +1 -0
  180. package/dist/index.d.ts +4 -0
  181. package/dist/index.js +9 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/lib/audio-fifo.d.ts +399 -0
  184. package/dist/lib/audio-fifo.js +431 -0
  185. package/dist/lib/audio-fifo.js.map +1 -0
  186. package/dist/lib/binding.d.ts +242 -0
  187. package/dist/lib/binding.js +102 -0
  188. package/dist/lib/binding.js.map +1 -0
  189. package/dist/lib/bitstream-filter-context.d.ts +381 -0
  190. package/dist/lib/bitstream-filter-context.js +443 -0
  191. package/dist/lib/bitstream-filter-context.js.map +1 -0
  192. package/dist/lib/bitstream-filter.d.ts +140 -0
  193. package/dist/lib/bitstream-filter.js +154 -0
  194. package/dist/lib/bitstream-filter.js.map +1 -0
  195. package/dist/lib/codec-context.d.ts +1069 -0
  196. package/dist/lib/codec-context.js +1336 -0
  197. package/dist/lib/codec-context.js.map +1 -0
  198. package/dist/lib/codec-parameters.d.ts +664 -0
  199. package/dist/lib/codec-parameters.js +813 -0
  200. package/dist/lib/codec-parameters.js.map +1 -0
  201. package/dist/lib/codec-parser.d.ts +201 -0
  202. package/dist/lib/codec-parser.js +213 -0
  203. package/dist/lib/codec-parser.js.map +1 -0
  204. package/dist/lib/codec.d.ts +617 -0
  205. package/dist/lib/codec.js +746 -0
  206. package/dist/lib/codec.js.map +1 -0
  207. package/dist/lib/device.d.ts +294 -0
  208. package/dist/lib/device.js +326 -0
  209. package/dist/lib/device.js.map +1 -0
  210. package/dist/lib/dictionary.d.ts +333 -0
  211. package/dist/lib/dictionary.js +372 -0
  212. package/dist/lib/dictionary.js.map +1 -0
  213. package/dist/lib/error.d.ts +311 -0
  214. package/dist/lib/error.js +395 -0
  215. package/dist/lib/error.js.map +1 -0
  216. package/dist/lib/fifo.d.ts +416 -0
  217. package/dist/lib/fifo.js +453 -0
  218. package/dist/lib/fifo.js.map +1 -0
  219. package/dist/lib/filter-context.d.ts +714 -0
  220. package/dist/lib/filter-context.js +783 -0
  221. package/dist/lib/filter-context.js.map +1 -0
  222. package/dist/lib/filter-graph-segment.d.ts +161 -0
  223. package/dist/lib/filter-graph-segment.js +172 -0
  224. package/dist/lib/filter-graph-segment.js.map +1 -0
  225. package/dist/lib/filter-graph.d.ts +641 -0
  226. package/dist/lib/filter-graph.js +704 -0
  227. package/dist/lib/filter-graph.js.map +1 -0
  228. package/dist/lib/filter-inout.d.ts +202 -0
  229. package/dist/lib/filter-inout.js +261 -0
  230. package/dist/lib/filter-inout.js.map +1 -0
  231. package/dist/lib/filter.d.ts +243 -0
  232. package/dist/lib/filter.js +272 -0
  233. package/dist/lib/filter.js.map +1 -0
  234. package/dist/lib/format-context.d.ts +1335 -0
  235. package/dist/lib/format-context.js +1455 -0
  236. package/dist/lib/format-context.js.map +1 -0
  237. package/dist/lib/frame-utils.d.ts +116 -0
  238. package/dist/lib/frame-utils.js +98 -0
  239. package/dist/lib/frame-utils.js.map +1 -0
  240. package/dist/lib/frame.d.ts +1315 -0
  241. package/dist/lib/frame.js +1535 -0
  242. package/dist/lib/frame.js.map +1 -0
  243. package/dist/lib/hardware-device-context.d.ts +362 -0
  244. package/dist/lib/hardware-device-context.js +383 -0
  245. package/dist/lib/hardware-device-context.js.map +1 -0
  246. package/dist/lib/hardware-frames-context.d.ts +418 -0
  247. package/dist/lib/hardware-frames-context.js +471 -0
  248. package/dist/lib/hardware-frames-context.js.map +1 -0
  249. package/dist/lib/index.d.ts +35 -0
  250. package/dist/lib/index.js +60 -0
  251. package/dist/lib/index.js.map +1 -0
  252. package/dist/lib/input-format.d.ts +249 -0
  253. package/dist/lib/input-format.js +306 -0
  254. package/dist/lib/input-format.js.map +1 -0
  255. package/dist/lib/io-context.d.ts +698 -0
  256. package/dist/lib/io-context.js +771 -0
  257. package/dist/lib/io-context.js.map +1 -0
  258. package/dist/lib/log.d.ts +174 -0
  259. package/dist/lib/log.js +184 -0
  260. package/dist/lib/log.js.map +1 -0
  261. package/dist/lib/native-types.d.ts +1024 -0
  262. package/dist/lib/native-types.js +2 -0
  263. package/dist/lib/native-types.js.map +1 -0
  264. package/dist/lib/option.d.ts +953 -0
  265. package/dist/lib/option.js +1607 -0
  266. package/dist/lib/option.js.map +1 -0
  267. package/dist/lib/output-format.d.ts +222 -0
  268. package/dist/lib/output-format.js +259 -0
  269. package/dist/lib/output-format.js.map +1 -0
  270. package/dist/lib/packet.d.ts +521 -0
  271. package/dist/lib/packet.js +613 -0
  272. package/dist/lib/packet.js.map +1 -0
  273. package/dist/lib/rational.d.ts +251 -0
  274. package/dist/lib/rational.js +278 -0
  275. package/dist/lib/rational.js.map +1 -0
  276. package/dist/lib/software-resample-context.d.ts +552 -0
  277. package/dist/lib/software-resample-context.js +592 -0
  278. package/dist/lib/software-resample-context.js.map +1 -0
  279. package/dist/lib/software-scale-context.d.ts +344 -0
  280. package/dist/lib/software-scale-context.js +366 -0
  281. package/dist/lib/software-scale-context.js.map +1 -0
  282. package/dist/lib/stream.d.ts +383 -0
  283. package/dist/lib/stream.js +524 -0
  284. package/dist/lib/stream.js.map +1 -0
  285. package/dist/lib/sync-queue.d.ts +179 -0
  286. package/dist/lib/sync-queue.js +197 -0
  287. package/dist/lib/sync-queue.js.map +1 -0
  288. package/dist/lib/types.d.ts +34 -0
  289. package/dist/lib/types.js +2 -0
  290. package/dist/lib/types.js.map +1 -0
  291. package/dist/lib/utilities.d.ts +1198 -0
  292. package/dist/lib/utilities.js +1302 -0
  293. package/dist/lib/utilities.js.map +1 -0
  294. package/dist/utils/electron.d.ts +49 -0
  295. package/dist/utils/electron.js +63 -0
  296. package/dist/utils/electron.js.map +1 -0
  297. package/dist/utils/index.d.ts +6 -0
  298. package/dist/utils/index.js +7 -0
  299. package/dist/utils/index.js.map +1 -0
  300. package/dist/utils/libc.d.ts +11 -0
  301. package/dist/utils/libc.js +35 -0
  302. package/dist/utils/libc.js.map +1 -0
  303. package/dist/utils/variant.d.ts +26 -0
  304. package/dist/utils/variant.js +31 -0
  305. package/dist/utils/variant.js.map +1 -0
  306. package/dist/webrtc/index.d.ts +4 -0
  307. package/dist/webrtc/index.js +7 -0
  308. package/dist/webrtc/index.js.map +1 -0
  309. package/install/check.js +124 -0
  310. package/install/ffmpeg.js +66 -0
  311. package/package.json +165 -3
@@ -0,0 +1,112 @@
1
+ import { bindings } from '../../lib/binding.js';
2
+ import { FFmpegError } from '../../lib/error.js';
3
+ /**
4
+ * Audio sample buffer utilities.
5
+ *
6
+ * Provides static methods for allocating and managing audio sample buffers.
7
+ * These utilities handle the memory layout for various sample formats,
8
+ * including planar formats where each channel has its own buffer.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { AudioSampleUtils } from 'node-av';
13
+ * import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16 } from 'node-av/constants';
14
+ *
15
+ * // Allocate audio buffers for stereo float planar
16
+ * const audio = AudioSampleUtils.alloc(2, 1024, AV_SAMPLE_FMT_FLTP, 0);
17
+ * console.log(`Allocated ${audio.size} bytes`);
18
+ * console.log(`${audio.data.length} buffers (one per channel)`);
19
+ *
20
+ * // Get buffer size for packed format
21
+ * const size = AudioSampleUtils.getBufferSize(2, 1024, AV_SAMPLE_FMT_S16, 0);
22
+ * console.log(`S16 stereo needs ${size.size} bytes`);
23
+ * ```
24
+ */
25
+ export class AudioSampleUtils {
26
+ // Private constructor to prevent instantiation
27
+ constructor() { }
28
+ /**
29
+ * Allocate audio sample buffers.
30
+ *
31
+ * Allocates buffers for audio samples. For planar formats, allocates
32
+ * separate buffers for each channel. For packed formats, allocates
33
+ * a single interleaved buffer.
34
+ * Direct mapping to av_samples_alloc()
35
+ *
36
+ * @param nbChannels - Number of audio channels
37
+ *
38
+ * @param nbSamples - Number of samples per channel
39
+ *
40
+ * @param sampleFmt - Audio sample format
41
+ *
42
+ * @param align - Buffer alignment (0 for default)
43
+ *
44
+ * @returns Allocation result with buffers and size information
45
+ *
46
+ * @throws {FFmpegError} On allocation failure
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { AudioSampleUtils } from 'node-av';
51
+ * import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16 } from 'node-av/constants';
52
+ *
53
+ * // Allocate for planar format (separate buffer per channel)
54
+ * const planar = AudioSampleUtils.alloc(2, 1024, AV_SAMPLE_FMT_FLTP, 0);
55
+ * console.log(`Planar: ${planar.data.length} buffers`); // 2 buffers
56
+ *
57
+ * // Allocate for packed format (single interleaved buffer)
58
+ * const packed = AudioSampleUtils.alloc(2, 1024, AV_SAMPLE_FMT_S16, 0);
59
+ * console.log(`Packed: ${packed.data.length} buffer`); // 1 buffer
60
+ * ```
61
+ */
62
+ static alloc(nbChannels, nbSamples, sampleFmt, align) {
63
+ const result = bindings.avSamplesAlloc(nbChannels, nbSamples, sampleFmt, align);
64
+ if (typeof result === 'number') {
65
+ FFmpegError.throwIfError(result, 'Failed to allocate audio samples');
66
+ }
67
+ return result;
68
+ }
69
+ /**
70
+ * Get required buffer size for audio samples.
71
+ *
72
+ * Calculates the buffer size needed to store audio samples with the
73
+ * given parameters. Does not allocate any memory.
74
+ * Direct mapping to av_samples_get_buffer_size()
75
+ *
76
+ * @param nbChannels - Number of audio channels
77
+ *
78
+ * @param nbSamples - Number of samples per channel
79
+ *
80
+ * @param sampleFmt - Audio sample format
81
+ *
82
+ * @param align - Buffer alignment (0 for default)
83
+ *
84
+ * @returns Buffer size and line size information
85
+ *
86
+ * @throws {FFmpegError} On invalid parameters
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * import { AudioSampleUtils } from 'node-av';
91
+ * import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
92
+ *
93
+ * // Calculate size for packed float (32-bit) stereo
94
+ * const floatSize = AudioSampleUtils.getBufferSize(2, 1024, AV_SAMPLE_FMT_FLT, 0);
95
+ * console.log(`Float stereo: ${floatSize.size} bytes total`);
96
+ * console.log(`Line size: ${floatSize.linesize} bytes`);
97
+ *
98
+ * // Calculate size for planar 16-bit stereo
99
+ * const planarSize = AudioSampleUtils.getBufferSize(2, 1024, AV_SAMPLE_FMT_S16P, 0);
100
+ * console.log(`S16 planar: ${planarSize.size} bytes total`);
101
+ * console.log(`Per channel: ${planarSize.linesize} bytes`);
102
+ * ```
103
+ */
104
+ static getBufferSize(nbChannels, nbSamples, sampleFmt, align) {
105
+ const result = bindings.avSamplesGetBufferSize(nbChannels, nbSamples, sampleFmt, align);
106
+ if (typeof result === 'number') {
107
+ FFmpegError.throwIfError(result, 'Failed to get audio buffer size');
108
+ }
109
+ return result;
110
+ }
111
+ }
112
+ //# sourceMappingURL=audio-sample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-sample.js","sourceRoot":"","sources":["../../../src/api/utilities/audio-sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0BjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,gBAAgB;IAC3B,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,CAAC,KAAK,CAAC,UAAkB,EAAE,SAAiB,EAAE,SAAyB,EAAE,KAAa;QAC1F,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAChF,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,MAA+B,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,aAAa,CAAC,UAAkB,EAAE,SAAiB,EAAE,SAAyB,EAAE,KAAa;QAClG,MAAM,MAAM,GAAG,QAAQ,CAAC,sBAAsB,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACxF,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,MAA+B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { Decoder } from '../decoder.js';
2
+ import type { Stream } from '../../lib/stream.js';
3
+ import type { DecoderOptions } from '../decoder.js';
4
+ /**
5
+ * Open the audio decoder of a transcode.
6
+ *
7
+ * Opus is decoded with libopus when the build has it. FFmpeg's own Opus decoder
8
+ * loses sync on in-band FEC (LBRR) frames and turns the rest of the packet into
9
+ * loud noise without reporting an error. Cameras that send SILK with FEC, such as
10
+ * Ring, crackle through it.
11
+ *
12
+ * @param stream - The audio stream
13
+ *
14
+ * @param options - Decoder options
15
+ *
16
+ * @returns The decoder
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function openAudioDecoder(stream: Stream, options: DecoderOptions): Promise<Decoder>;
@@ -0,0 +1,27 @@
1
+ import { AV_CODEC_ID_OPUS } from '../../constants/constants.js';
2
+ import { FF_DECODER_LIBOPUS } from '../../constants/decoders.js';
3
+ import { Codec } from '../../lib/codec.js';
4
+ import { Decoder } from '../decoder.js';
5
+ /**
6
+ * Open the audio decoder of a transcode.
7
+ *
8
+ * Opus is decoded with libopus when the build has it. FFmpeg's own Opus decoder
9
+ * loses sync on in-band FEC (LBRR) frames and turns the rest of the packet into
10
+ * loud noise without reporting an error. Cameras that send SILK with FEC, such as
11
+ * Ring, crackle through it.
12
+ *
13
+ * @param stream - The audio stream
14
+ *
15
+ * @param options - Decoder options
16
+ *
17
+ * @returns The decoder
18
+ *
19
+ * @internal
20
+ */
21
+ export async function openAudioDecoder(stream, options) {
22
+ if (stream.codecpar.codecId === AV_CODEC_ID_OPUS && Codec.findDecoderByName(FF_DECODER_LIBOPUS)) {
23
+ return await Decoder.create(stream, FF_DECODER_LIBOPUS, options);
24
+ }
25
+ return await Decoder.create(stream, options);
26
+ }
27
+ //# sourceMappingURL=audio-transcode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio-transcode.js","sourceRoot":"","sources":["../../../src/api/utilities/audio-transcode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKxC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAc,EAAE,OAAuB;IAC5E,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAK,gBAAgB,IAAI,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChG,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { ChannelLayout } from '../../lib/types.js';
2
+ /**
3
+ * Audio channel layout utilities.
4
+ *
5
+ * Provides static methods for describing and working with audio channel layouts.
6
+ * Channel layouts define the arrangement and meaning of audio channels in
7
+ * multi-channel audio.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { ChannelLayoutUtils } from 'node-av';
12
+ * import { AV_CHANNEL_ORDER_NATIVE } from 'node-av/constants';
13
+ *
14
+ * // Describe a stereo layout
15
+ * const stereo: ChannelLayout = {
16
+ * order: AV_CHANNEL_ORDER_NATIVE,
17
+ * nb_channels: 2,
18
+ * u: { mask: 0x3n } // FL | FR
19
+ * };
20
+ *
21
+ * const description = ChannelLayoutUtils.describe(stereo);
22
+ * console.log(description); // "stereo"
23
+ *
24
+ * // Describe a 5.1 layout
25
+ * const surround: ChannelLayout = {
26
+ * order: AV_CHANNEL_ORDER_NATIVE,
27
+ * nb_channels: 6,
28
+ * u: { mask: 0x3Fn } // FL | FR | FC | LFE | BL | BR
29
+ * };
30
+ *
31
+ * console.log(ChannelLayoutUtils.describe(surround)); // "5.1"
32
+ * ```
33
+ */
34
+ export declare class ChannelLayoutUtils {
35
+ private constructor();
36
+ /**
37
+ * Get string description of channel layout.
38
+ *
39
+ * Returns a human-readable string describing the channel layout.
40
+ * Direct mapping to av_channel_layout_describe()
41
+ *
42
+ * @param channelLayout - Channel layout to describe
43
+ *
44
+ * @returns String description, or null on error
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { ChannelLayoutUtils } from 'node-av';
49
+ * import { AV_CHANNEL_ORDER_NATIVE, AV_CHANNEL_ORDER_CUSTOM } from 'node-av/constants';
50
+ *
51
+ * // Standard layouts
52
+ * const mono: ChannelLayout = {
53
+ * order: AV_CHANNEL_ORDER_NATIVE,
54
+ * nb_channels: 1,
55
+ * u: { mask: 0x4n } // FC
56
+ * };
57
+ * console.log(ChannelLayoutUtils.describe(mono)); // "mono"
58
+ *
59
+ * const stereo: ChannelLayout = {
60
+ * order: AV_CHANNEL_ORDER_NATIVE,
61
+ * nb_channels: 2,
62
+ * u: { mask: 0x3n } // FL | FR
63
+ * };
64
+ * console.log(ChannelLayoutUtils.describe(stereo)); // "stereo"
65
+ *
66
+ * // Custom layout
67
+ * const custom: ChannelLayout = {
68
+ * order: AV_CHANNEL_ORDER_CUSTOM,
69
+ * nb_channels: 3,
70
+ * u: { map: null }
71
+ * };
72
+ * console.log(ChannelLayoutUtils.describe(custom)); // "3 channels"
73
+ * ```
74
+ */
75
+ static describe(channelLayout: Partial<ChannelLayout>): string | null;
76
+ }
@@ -0,0 +1,80 @@
1
+ import { bindings } from '../../lib/binding.js';
2
+ /**
3
+ * Audio channel layout utilities.
4
+ *
5
+ * Provides static methods for describing and working with audio channel layouts.
6
+ * Channel layouts define the arrangement and meaning of audio channels in
7
+ * multi-channel audio.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { ChannelLayoutUtils } from 'node-av';
12
+ * import { AV_CHANNEL_ORDER_NATIVE } from 'node-av/constants';
13
+ *
14
+ * // Describe a stereo layout
15
+ * const stereo: ChannelLayout = {
16
+ * order: AV_CHANNEL_ORDER_NATIVE,
17
+ * nb_channels: 2,
18
+ * u: { mask: 0x3n } // FL | FR
19
+ * };
20
+ *
21
+ * const description = ChannelLayoutUtils.describe(stereo);
22
+ * console.log(description); // "stereo"
23
+ *
24
+ * // Describe a 5.1 layout
25
+ * const surround: ChannelLayout = {
26
+ * order: AV_CHANNEL_ORDER_NATIVE,
27
+ * nb_channels: 6,
28
+ * u: { mask: 0x3Fn } // FL | FR | FC | LFE | BL | BR
29
+ * };
30
+ *
31
+ * console.log(ChannelLayoutUtils.describe(surround)); // "5.1"
32
+ * ```
33
+ */
34
+ export class ChannelLayoutUtils {
35
+ // Private constructor to prevent instantiation
36
+ constructor() { }
37
+ /**
38
+ * Get string description of channel layout.
39
+ *
40
+ * Returns a human-readable string describing the channel layout.
41
+ * Direct mapping to av_channel_layout_describe()
42
+ *
43
+ * @param channelLayout - Channel layout to describe
44
+ *
45
+ * @returns String description, or null on error
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * import { ChannelLayoutUtils } from 'node-av';
50
+ * import { AV_CHANNEL_ORDER_NATIVE, AV_CHANNEL_ORDER_CUSTOM } from 'node-av/constants';
51
+ *
52
+ * // Standard layouts
53
+ * const mono: ChannelLayout = {
54
+ * order: AV_CHANNEL_ORDER_NATIVE,
55
+ * nb_channels: 1,
56
+ * u: { mask: 0x4n } // FC
57
+ * };
58
+ * console.log(ChannelLayoutUtils.describe(mono)); // "mono"
59
+ *
60
+ * const stereo: ChannelLayout = {
61
+ * order: AV_CHANNEL_ORDER_NATIVE,
62
+ * nb_channels: 2,
63
+ * u: { mask: 0x3n } // FL | FR
64
+ * };
65
+ * console.log(ChannelLayoutUtils.describe(stereo)); // "stereo"
66
+ *
67
+ * // Custom layout
68
+ * const custom: ChannelLayout = {
69
+ * order: AV_CHANNEL_ORDER_CUSTOM,
70
+ * nb_channels: 3,
71
+ * u: { map: null }
72
+ * };
73
+ * console.log(ChannelLayoutUtils.describe(custom)); // "3 channels"
74
+ * ```
75
+ */
76
+ static describe(channelLayout) {
77
+ return bindings.avChannelLayoutDescribe(channelLayout);
78
+ }
79
+ }
80
+ //# sourceMappingURL=channel-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-layout.js","sourceRoot":"","sources":["../../../src/api/utilities/channel-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,OAAO,kBAAkB;IAC7B,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAqC;QACnD,OAAO,QAAQ,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACzD,CAAC;CACF"}
@@ -0,0 +1,87 @@
1
+ import type { AVPixelFormat, AVSampleFormat } from '../../constants/index.js';
2
+ import type { ChannelLayout } from '../../lib/types.js';
3
+ /**
4
+ * Pick a codec-supported sample rate, keeping the input rate when accepted and
5
+ * otherwise choosing the numerically nearest supported one.
6
+ *
7
+ * @param rate - Input sample rate in Hz
8
+ *
9
+ * @param supported - Codec's supported sample rates, or null when unrestricted
10
+ *
11
+ * @returns A sample rate the codec accepts
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * pickSupportedRate(48000, [44100, 48000]); // 48000 (kept)
16
+ * pickSupportedRate(96000, [44100, 48000]); // 48000 (nearest supported)
17
+ * pickSupportedRate(48000, null); // 48000 (codec unrestricted)
18
+ * ```
19
+ */
20
+ export declare function pickSupportedRate(rate: number, supported: number[] | null): number;
21
+ /**
22
+ * Pick a codec-supported sample format, keeping the input when accepted.
23
+ *
24
+ * When the input format is unsupported, prefers the lowest-precision supported
25
+ * format that still meets the input's bit depth (so converting incurs no silent
26
+ * precision loss); if none reach it, takes the highest-precision one available.
27
+ * Ties break toward matching planar/packed layout. This improves on FFmpeg CLI's
28
+ * naive "first supported format" fallback without any downside.
29
+ *
30
+ * @param fmt - Input sample format
31
+ *
32
+ * @param supported - Codec's supported sample formats, or null when unrestricted
33
+ *
34
+ * @returns A sample format the codec accepts
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
39
+ *
40
+ * // s32 input: prefer fltp (preserves bit depth) over the lossy s16 a naive pick would take
41
+ * pickSupportedSampleFormat(AV_SAMPLE_FMT_S32, [AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP]); // fltp
42
+ * ```
43
+ */
44
+ export declare function pickSupportedSampleFormat(fmt: AVSampleFormat, supported: AVSampleFormat[] | null): AVSampleFormat;
45
+ /**
46
+ * Pick a codec-supported channel layout.
47
+ *
48
+ * Keeps the input layout when the codec accepts its channel count, otherwise picks
49
+ * the supported layout with the nearest channel count (rather than blindly the
50
+ * first), minimizing how much up/down-mixing the resampler must perform.
51
+ *
52
+ * @param layout - Input channel layout
53
+ *
54
+ * @param supported - Codec's supported channel layouts, or null when unrestricted
55
+ *
56
+ * @returns A channel layout the codec accepts
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * import { avChannelLayoutDefault } from 'node-av';
61
+ *
62
+ * // 7.1 (8ch) input into a codec supporting stereo + 5.1 -> nearest count is 5.1 (6ch)
63
+ * const picked = pickSupportedLayout(avChannelLayoutDefault(8), [avChannelLayoutDefault(2), avChannelLayoutDefault(6)]);
64
+ * console.log(picked.nbChannels); // 6
65
+ * ```
66
+ */
67
+ export declare function pickSupportedLayout(layout: ChannelLayout, supported: ChannelLayout[] | null): ChannelLayout;
68
+ /**
69
+ * Pick a codec-supported pixel format, keeping the input when accepted and
70
+ * otherwise the least-loss supported format (via `avcodec_find_best_pix_fmt_of_list`,
71
+ * which weighs color depth, chroma subsampling, and alpha).
72
+ *
73
+ * @param fmt - Input pixel format
74
+ *
75
+ * @param supported - Codec's supported pixel formats, or null when unrestricted
76
+ *
77
+ * @returns A pixel format the codec accepts
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P } from 'node-av/constants';
82
+ *
83
+ * // rgb24 into a codec's formats -> yuv444p (least chroma loss, not the first entry)
84
+ * pickSupportedPixelFormat(AV_PIX_FMT_RGB24, [AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P]); // yuv444p
85
+ * ```
86
+ */
87
+ export declare function pickSupportedPixelFormat(fmt: AVPixelFormat, supported: AVPixelFormat[] | null): AVPixelFormat;
@@ -0,0 +1,117 @@
1
+ import { avcodecFindBestPixFmtOfList, avGetBytesPerSample, avSampleFmtIsPlanar } from '../../lib/utilities.js';
2
+ /**
3
+ * Pick a codec-supported sample rate, keeping the input rate when accepted and
4
+ * otherwise choosing the numerically nearest supported one.
5
+ *
6
+ * @param rate - Input sample rate in Hz
7
+ *
8
+ * @param supported - Codec's supported sample rates, or null when unrestricted
9
+ *
10
+ * @returns A sample rate the codec accepts
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * pickSupportedRate(48000, [44100, 48000]); // 48000 (kept)
15
+ * pickSupportedRate(96000, [44100, 48000]); // 48000 (nearest supported)
16
+ * pickSupportedRate(48000, null); // 48000 (codec unrestricted)
17
+ * ```
18
+ */
19
+ export function pickSupportedRate(rate, supported) {
20
+ if (!supported || supported.length === 0 || supported.includes(rate)) {
21
+ return rate;
22
+ }
23
+ return supported.reduce((best, r) => (Math.abs(r - rate) < Math.abs(best - rate) ? r : best), supported[0]);
24
+ }
25
+ /**
26
+ * Pick a codec-supported sample format, keeping the input when accepted.
27
+ *
28
+ * When the input format is unsupported, prefers the lowest-precision supported
29
+ * format that still meets the input's bit depth (so converting incurs no silent
30
+ * precision loss); if none reach it, takes the highest-precision one available.
31
+ * Ties break toward matching planar/packed layout. This improves on FFmpeg CLI's
32
+ * naive "first supported format" fallback without any downside.
33
+ *
34
+ * @param fmt - Input sample format
35
+ *
36
+ * @param supported - Codec's supported sample formats, or null when unrestricted
37
+ *
38
+ * @returns A sample format the codec accepts
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
43
+ *
44
+ * // s32 input: prefer fltp (preserves bit depth) over the lossy s16 a naive pick would take
45
+ * pickSupportedSampleFormat(AV_SAMPLE_FMT_S32, [AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP]); // fltp
46
+ * ```
47
+ */
48
+ export function pickSupportedSampleFormat(fmt, supported) {
49
+ if (!supported || supported.length === 0 || supported.includes(fmt)) {
50
+ return fmt;
51
+ }
52
+ const inBytes = avGetBytesPerSample(fmt);
53
+ const inPlanar = avSampleFmtIsPlanar(fmt);
54
+ // Reaching the input's bit depth dominates the score; among those the smallest
55
+ // excess wins (and among formats that fall short, the highest depth). The planar
56
+ // match is a final tie-break.
57
+ const score = (cand) => {
58
+ const bytes = avGetBytesPerSample(cand);
59
+ const planar = avSampleFmtIsPlanar(cand) === inPlanar ? 1 : 0;
60
+ return (bytes >= inBytes ? 1_000_000 - (bytes - inBytes) * 1000 : bytes * 1000) + planar;
61
+ };
62
+ return supported.reduce((best, cand) => (score(cand) > score(best) ? cand : best), supported[0]);
63
+ }
64
+ /**
65
+ * Pick a codec-supported channel layout.
66
+ *
67
+ * Keeps the input layout when the codec accepts its channel count, otherwise picks
68
+ * the supported layout with the nearest channel count (rather than blindly the
69
+ * first), minimizing how much up/down-mixing the resampler must perform.
70
+ *
71
+ * @param layout - Input channel layout
72
+ *
73
+ * @param supported - Codec's supported channel layouts, or null when unrestricted
74
+ *
75
+ * @returns A channel layout the codec accepts
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * import { avChannelLayoutDefault } from 'node-av';
80
+ *
81
+ * // 7.1 (8ch) input into a codec supporting stereo + 5.1 -> nearest count is 5.1 (6ch)
82
+ * const picked = pickSupportedLayout(avChannelLayoutDefault(8), [avChannelLayoutDefault(2), avChannelLayoutDefault(6)]);
83
+ * console.log(picked.nbChannels); // 6
84
+ * ```
85
+ */
86
+ export function pickSupportedLayout(layout, supported) {
87
+ if (!supported || supported.length === 0 || supported.some((l) => l.nbChannels === layout.nbChannels)) {
88
+ return layout;
89
+ }
90
+ return supported.reduce((best, l) => (Math.abs(l.nbChannels - layout.nbChannels) < Math.abs(best.nbChannels - layout.nbChannels) ? l : best), supported[0]);
91
+ }
92
+ /**
93
+ * Pick a codec-supported pixel format, keeping the input when accepted and
94
+ * otherwise the least-loss supported format (via `avcodec_find_best_pix_fmt_of_list`,
95
+ * which weighs color depth, chroma subsampling, and alpha).
96
+ *
97
+ * @param fmt - Input pixel format
98
+ *
99
+ * @param supported - Codec's supported pixel formats, or null when unrestricted
100
+ *
101
+ * @returns A pixel format the codec accepts
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P } from 'node-av/constants';
106
+ *
107
+ * // rgb24 into a codec's formats -> yuv444p (least chroma loss, not the first entry)
108
+ * pickSupportedPixelFormat(AV_PIX_FMT_RGB24, [AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P]); // yuv444p
109
+ * ```
110
+ */
111
+ export function pickSupportedPixelFormat(fmt, supported) {
112
+ if (!supported || supported.length === 0 || supported.includes(fmt)) {
113
+ return fmt;
114
+ }
115
+ return avcodecFindBestPixFmtOfList(supported, fmt);
116
+ }
117
+ //# sourceMappingURL=codec-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-format.js","sourceRoot":"","sources":["../../../src/api/utilities/codec-format.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,25 @@
1
+ type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
2
+ type WritableKeys<T> = {
3
+ [P in keyof T]-?: IfEquals<{
4
+ [Q in P]: T[P];
5
+ }, {
6
+ -readonly [Q in P]: T[P];
7
+ }, P, never>;
8
+ }[keyof T];
9
+ export type ContextOptions<T> = Partial<{
10
+ [K in WritableKeys<T> as K extends string ? (T[K] extends (...args: never[]) => unknown ? never : K) : never]: T[K];
11
+ }>;
12
+ /**
13
+ * Apply a {@link ContextOptions} bag onto a native context wrapper.
14
+ *
15
+ * Assigns each provided (defined) field via the wrapper's setter. No-ops when
16
+ * `options` is undefined.
17
+ *
18
+ * @param target - The native context wrapper to mutate
19
+ *
20
+ * @param options - The field/value bag to apply
21
+ *
22
+ * @internal
23
+ */
24
+ export declare function applyContextOptions<T extends object>(target: T, options: ContextOptions<T> | undefined): void;
25
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Apply a {@link ContextOptions} bag onto a native context wrapper.
3
+ *
4
+ * Assigns each provided (defined) field via the wrapper's setter. No-ops when
5
+ * `options` is undefined.
6
+ *
7
+ * @param target - The native context wrapper to mutate
8
+ *
9
+ * @param options - The field/value bag to apply
10
+ *
11
+ * @internal
12
+ */
13
+ export function applyContextOptions(target, options) {
14
+ if (!options) {
15
+ return;
16
+ }
17
+ for (const [key, value] of Object.entries(options)) {
18
+ if (value !== undefined) {
19
+ target[key] = value;
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=context-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-options.js","sourceRoot":"","sources":["../../../src/api/utilities/context-options.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAmB,MAAS,EAAE,OAAsC;IACrG,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC"}