Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | 12x 12x 12x 21x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 32x 8x 8x 24x 16x 16x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 23x 23x 23x 23x 23x 23x 39x 38x 38x 38x 38x 38x 23x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 23x 23x 23x 23x 23x 23x 23x 23x 7x 16x 16x 16x 16x 24x 24x 24x 23x 22x 1x 1x 1x 23x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 38x 1184x 1184x 1184x 1184x 1184x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 37376x 114x 114x 112128x 5888x 106240x 32x 106208x 23x 5x 23x 23x 23x 23x 23x 8x 8x 8x 8x | import type { FrameMode } from './bga-frame.ts';
import { readFile } from 'node:fs/promises';
import { basename } from 'node:path';
import { Worker } from 'node:worker_threads';
import { createAbortError, isAbortError, throwIfAborted } from '@be-music/shared-utils/core';
import { loadOptionalNodeModule } from '@be-music/shared-utils/optional-node-module';
import { createSEAWorker, isSEARuntime } from './node/sea-worker.ts';
// Keep chunks small so ff_decode_multi never allocates too many full-size frames at once.
const PACKET_READ_CHUNK_BYTES = 65_536;
const MAX_PACKET_READ_ITERATIONS = 16_384;
const FALLBACK_FPS = 30;
interface LibAVPlaneLayout {
offset: number;
stride: number;
}
interface LibAVVideoFrame {
data: unknown;
format?: number;
layout?: LibAVPlaneLayout[];
pts?: number;
width?: number;
height?: number;
}
interface LibAVStream {
index: number;
codecpar: number;
codec_type: number;
codec_id: number;
time_base_num: number;
time_base_den: number;
duration: number;
}
type LibAVPacket = unknown;
interface LibAVInstance {
AVMEDIA_TYPE_VIDEO: number;
EAGAIN: number;
AVERROR_EOF: number;
AV_PIX_FMT_YUV420P?: number;
AV_PIX_FMT_YUVJ420P?: number;
AV_PIX_FMT_YUV422P?: number;
AV_PIX_FMT_YUVJ422P?: number;
AV_PIX_FMT_YUV444P?: number;
AV_PIX_FMT_YUVJ444P?: number;
AV_PIX_FMT_RGBA?: number;
AV_PIX_FMT_BGRA?: number;
AV_PIX_FMT_RGB24?: number;
AV_PIX_FMT_BGR24?: number;
writeFile(path: string, data: Uint8Array): Promise<void>;
ff_init_demuxer_file(path: string): Promise<[number, LibAVStream[]]>;
avcodec_get_name(codecId: number): Promise<string>;
ff_init_decoder(name: string | number, codecpar?: number): Promise<[number, number, number, number]>;
ff_read_frame_multi(
fmtCtx: number,
pkt: number,
config?: { limit?: number },
): Promise<[number, Record<number, LibAVPacket[]>]>;
ff_decode_multi(
ctx: number,
pkt: number,
frame: number,
packets: LibAVPacket[],
config?: boolean | { fin?: boolean; ignoreErrors?: boolean; copyoutFrame?: 'video' | 'video_packed' },
): Promise<LibAVVideoFrame[]>;
ff_free_decoder(ctx: number, pkt: number, frame: number): Promise<void>;
terminate(): void;
}
interface LibAVFactory {
LibAV(options?: { noworker?: boolean; variant?: string }): Promise<LibAVInstance>;
}
interface LibAVModule {
default: LibAVFactory;
}
export interface DecodedVideoFrame {
seconds: number;
width: number;
height: number;
rgba: Uint8Array;
}
export interface DecodedVideoStreamInfo {
codecName: string;
durationSeconds?: number;
}
export interface DecodedSourceVideoFrame {
alpha?: Uint8Array;
seconds: number;
width: number;
height: number;
rgb: Uint8Array;
opaqueMask: Uint8Array;
}
interface VideoDecodeWorkerInitData {
videoPath: string;
mode: FrameMode;
stopAfterFirstFrame: boolean;
preserveVideoBorders: boolean;
}
interface VideoDecodeWorkerReadyMessage {
kind: 'ready';
info: DecodedVideoStreamInfo;
}
interface VideoDecodeWorkerFrameMessage {
kind: 'frame';
frame: DecodedSourceVideoFrame;
}
interface VideoDecodeWorkerDoneMessage {
kind: 'done';
result?: { codecName: string; frameCount: number; durationSeconds?: number };
}
interface VideoDecodeWorkerErrorMessage {
kind: 'error';
name?: string;
message: string;
}
type VideoDecodeWorkerOutboundMessage =
| VideoDecodeWorkerReadyMessage
| VideoDecodeWorkerFrameMessage
| VideoDecodeWorkerDoneMessage
| VideoDecodeWorkerErrorMessage;
export async function decodeVideoFramesStream(
videoPath: string,
onFrame: (frame: DecodedVideoFrame) => void,
signal?: AbortSignal,
options: {
onReady?: (info: DecodedVideoStreamInfo) => void;
stopAfterFirstFrame?: boolean;
} = {},
): Promise<{ codecName: string; frameCount: number; durationSeconds?: number } | undefined> {
return await decodeVideoFramesStreamDirect(videoPath, onFrame, signal, options);
}
export async function decodeVideoFramesStreamDirect(
videoPath: string,
onFrame: (frame: DecodedVideoFrame) => void,
signal?: AbortSignal,
options: {
onReady?: (info: DecodedVideoStreamInfo) => void;
stopAfterFirstFrame?: boolean;
} = {},
): Promise<{ codecName: string; frameCount: number; durationSeconds?: number } | undefined> {
let libav: LibAVInstance | undefined;
try {
throwIfAborted(signal);
const libavInstance = await createLibAVInstance();
libav = libavInstance;
throwIfAborted(signal);
const file = await readFile(videoPath, { signal });
const fileName = basename(videoPath);
await libavInstance.writeFile(fileName, new Uint8Array(file));
throwIfAborted(signal);
const [formatContext, streams] = await libavInstance.ff_init_demuxer_file(fileName);
const videoStream = streams.find((stream) => stream.codec_type === libavInstance.AVMEDIA_TYPE_VIDEO);
Iif (!videoStream) {
return undefined;
}
const codecName = await libavInstance.avcodec_get_name(videoStream.codec_id);
const durationSeconds = resolveStreamDurationSeconds(videoStream);
options.onReady?.({
codecName,
durationSeconds,
});
const [, decoderContext, packetRef, frameRef] = await libavInstance.ff_init_decoder(
videoStream.codec_id,
videoStream.codecpar,
);
try {
const frameCount = await decodeVideoFramesWithCallback(
libavInstance,
formatContext,
videoStream,
decoderContext,
packetRef,
frameRef,
onFrame,
signal,
Boolean(options.stopAfterFirstFrame),
);
Iif (frameCount === undefined || frameCount <= 0) {
return undefined;
}
return {
codecName,
frameCount,
durationSeconds,
};
} finally {
await libavInstance.ff_free_decoder(decoderContext, packetRef, frameRef);
}
} catch (error) {
if (isAbortError(error)) {
throw error;
}
return undefined;
} finally {
libav?.terminate();
}
}
export async function decodeVideoFramesToSourceFramesInWorker(
videoPath: string,
mode: FrameMode,
onFrame: (frame: DecodedSourceVideoFrame) => void,
signal?: AbortSignal,
options: {
onReady?: (info: DecodedVideoStreamInfo) => void;
stopAfterFirstFrame?: boolean;
preserveVideoBorders?: boolean;
} = {},
): Promise<{ codecName: string; frameCount: number; durationSeconds?: number } | undefined> {
throwIfAborted(signal);
const workerInitData = {
videoPath,
mode,
stopAfterFirstFrame: Boolean(options.stopAfterFirstFrame),
preserveVideoBorders: Boolean(options.preserveVideoBorders),
} satisfies VideoDecodeWorkerInitData;
const worker = isSEARuntime()
? createSEAWorker('bga-video-worker', workerInitData)
: new Worker(resolveBGAVideoWorkerURL(), {
workerData: workerInitData,
execArgv: resolveBGAVideoWorkerExecArgv(),
});
return await new Promise((resolve, reject) => {
let settled = false;
const cleanup = (): void => {
worker.off('message', onMessage);
worker.off('error', onError);
worker.off('exit', onExit);
signal?.removeEventListener('abort', onAbort);
};
const settle = (callback: () => void): void => {
Iif (settled) {
return;
}
settled = true;
cleanup();
callback();
};
const onMessage = (message: VideoDecodeWorkerOutboundMessage): void => {
if (message.kind === 'ready') {
options.onReady?.(message.info);
return;
}
if (message.kind === 'frame') {
onFrame(message.frame);
return;
}
Eif (message.kind === 'done') {
settle(() => resolve(message.result));
return;
}
settle(() => reject(message.name === 'AbortError' ? createAbortError() : new Error(message.message)));
};
const onError = (error: Error): void => {
settle(() => reject(error));
};
const onExit = (code: number): void => {
if (settled) {
return;
}
settle(() => reject(new Error(`Video decode worker exited unexpectedly (code ${code})`)));
};
const onAbort = (): void => {
void worker.terminate();
settle(() => reject(createAbortError()));
};
worker.on('message', onMessage);
worker.on('error', onError);
worker.on('exit', onExit);
signal?.addEventListener('abort', onAbort, { once: true });
});
}
async function decodeVideoFramesWithCallback(
libav: LibAVInstance,
formatContext: number,
stream: LibAVStream,
decoderContext: number,
packetRef: number,
frameRef: number,
onFrame: (frame: DecodedVideoFrame) => void,
signal?: AbortSignal,
stopAfterFirstFrame = false,
): Promise<number | undefined> {
const timeScale = resolveTimeScale(stream);
const fallbackStep = resolveFallbackStep();
let firstPts: number | undefined;
let nextFallbackSeconds = 0;
let lastSeconds = 0;
let frameCount = 0;
const consume = (decodedFrames: LibAVVideoFrame[]): void => {
for (const frame of decodedFrames) {
throwIfAborted(signal);
const converted = convertFrameToRGBA(frame, libav);
Iif (!converted) {
continue;
}
const pts = resolveFramePts(frame);
if (typeof pts === 'number' && typeof firstPts !== 'number') {
firstPts = pts;
}
let seconds = nextFallbackSeconds;
Eif (typeof pts === 'number' && typeof firstPts === 'number') {
seconds = (pts - firstPts) * timeScale;
}
Iif (!Number.isFinite(seconds)) {
seconds = nextFallbackSeconds;
}
seconds = Math.max(0, seconds);
Iif (seconds + 1e-6 < lastSeconds) {
seconds = lastSeconds;
}
lastSeconds = seconds;
nextFallbackSeconds = seconds + fallbackStep;
onFrame({
seconds,
width: converted.width,
height: converted.height,
rgba: converted.rgba,
});
frameCount += 1;
if (stopAfterFirstFrame) return;
}
};
for (let iteration = 0; iteration < MAX_PACKET_READ_ITERATIONS; iteration += 1) {
throwIfAborted(signal);
const [readResult, packetsByStream] = await libav.ff_read_frame_multi(formatContext, packetRef, {
limit: PACKET_READ_CHUNK_BYTES,
});
const packets = packetsByStream[stream.index] ?? [];
Eif (packets.length > 0) {
const decoded = await libav.ff_decode_multi(decoderContext, packetRef, frameRef, packets, {
copyoutFrame: 'video',
ignoreErrors: true,
});
consume(decoded);
if (stopAfterFirstFrame && frameCount > 0) {
return frameCount;
}
}
Eif (readResult === libav.AVERROR_EOF) {
const flushed = await libav.ff_decode_multi(decoderContext, packetRef, frameRef, [], {
fin: true,
copyoutFrame: 'video',
ignoreErrors: true,
});
consume(flushed);
return frameCount;
}
if (readResult === 0 || readResult === -libav.EAGAIN) {
continue;
}
return undefined;
}
return undefined;
}
function resolveTimeScale(stream: LibAVStream): number {
const numerator = Number.isFinite(stream.time_base_num) ? stream.time_base_num : 1;
const denominator = Number.isFinite(stream.time_base_den) && stream.time_base_den > 0 ? stream.time_base_den : 1;
return numerator / denominator;
}
function resolveStreamDurationSeconds(stream: LibAVStream): number | undefined {
if (typeof stream.duration !== 'number' || !Number.isFinite(stream.duration) || stream.duration <= 0) {
return undefined;
}
const seconds = stream.duration * resolveTimeScale(stream);
Iif (!Number.isFinite(seconds) || seconds <= 0) {
return undefined;
}
return seconds;
}
function resolveFallbackStep(): number {
return 1 / FALLBACK_FPS;
}
function resolveFramePts(frame: LibAVVideoFrame | undefined): number | undefined {
Iif (!frame || typeof frame.pts !== 'number' || !Number.isFinite(frame.pts)) {
return undefined;
}
return frame.pts;
}
function convertFrameToRGBA(
frame: LibAVVideoFrame,
libav: LibAVInstance,
): { width: number; height: number; rgba: Uint8Array } | undefined {
Iif (!(frame.data instanceof Uint8Array)) {
return undefined;
}
const width = Math.floor(frame.width ?? 0);
const height = Math.floor(frame.height ?? 0);
Iif (width <= 0 || height <= 0) {
return undefined;
}
const format = frame.format;
Iif (typeof format !== 'number') {
return undefined;
}
const rgba = new Uint8Array(width * height * 4);
Iif (format === libav.AV_PIX_FMT_RGBA) {
copyPackedRGBA(frame.data, frame.layout, width, height, rgba, 'rgba');
return { width, height, rgba };
}
Iif (format === libav.AV_PIX_FMT_BGRA) {
copyPackedRGBA(frame.data, frame.layout, width, height, rgba, 'bgra');
return { width, height, rgba };
}
Iif (format === libav.AV_PIX_FMT_RGB24) {
copyPackedRGB24(frame.data, frame.layout, width, height, rgba, 'rgb24');
return { width, height, rgba };
}
Iif (format === libav.AV_PIX_FMT_BGR24) {
copyPackedRGB24(frame.data, frame.layout, width, height, rgba, 'bgr24');
return { width, height, rgba };
}
Eif (format === libav.AV_PIX_FMT_YUV420P || format === libav.AV_PIX_FMT_YUVJ420P) {
convertPlanarYuvToRGBA(frame.data, frame.layout, width, height, rgba, 2, 2, format === libav.AV_PIX_FMT_YUVJ420P);
return { width, height, rgba };
}
if (format === libav.AV_PIX_FMT_YUV422P || format === libav.AV_PIX_FMT_YUVJ422P) {
convertPlanarYuvToRGBA(frame.data, frame.layout, width, height, rgba, 2, 1, format === libav.AV_PIX_FMT_YUVJ422P);
return { width, height, rgba };
}
if (format === libav.AV_PIX_FMT_YUV444P || format === libav.AV_PIX_FMT_YUVJ444P) {
convertPlanarYuvToRGBA(frame.data, frame.layout, width, height, rgba, 1, 1, format === libav.AV_PIX_FMT_YUVJ444P);
return { width, height, rgba };
}
return undefined;
}
function copyPackedRGBA(
data: Uint8Array,
layout: LibAVPlaneLayout[] | undefined,
width: number,
height: number,
out: Uint8Array,
order: 'rgba' | 'bgra',
): void {
const source = resolvePlane(layout, 0, width, height, 0, width * 4);
for (let y = 0; y < height; y += 1) {
const rowOffset = source.offset + y * source.stride;
for (let x = 0; x < width; x += 1) {
const sourceOffset = rowOffset + x * 4;
const outOffset = (y * width + x) * 4;
const c0 = data[sourceOffset] ?? 0;
const c1 = data[sourceOffset + 1] ?? 0;
const c2 = data[sourceOffset + 2] ?? 0;
const c3 = data[sourceOffset + 3] ?? 255;
if (order === 'rgba') {
out[outOffset] = c0;
out[outOffset + 1] = c1;
out[outOffset + 2] = c2;
out[outOffset + 3] = c3;
} else {
out[outOffset] = c2;
out[outOffset + 1] = c1;
out[outOffset + 2] = c0;
out[outOffset + 3] = c3;
}
}
}
}
function copyPackedRGB24(
data: Uint8Array,
layout: LibAVPlaneLayout[] | undefined,
width: number,
height: number,
out: Uint8Array,
order: 'rgb24' | 'bgr24',
): void {
const source = resolvePlane(layout, 0, width, height, 0, width * 3);
for (let y = 0; y < height; y += 1) {
const rowOffset = source.offset + y * source.stride;
for (let x = 0; x < width; x += 1) {
const sourceOffset = rowOffset + x * 3;
const outOffset = (y * width + x) * 4;
const c0 = data[sourceOffset] ?? 0;
const c1 = data[sourceOffset + 1] ?? 0;
const c2 = data[sourceOffset + 2] ?? 0;
if (order === 'rgb24') {
out[outOffset] = c0;
out[outOffset + 1] = c1;
out[outOffset + 2] = c2;
} else {
out[outOffset] = c2;
out[outOffset + 1] = c1;
out[outOffset + 2] = c0;
}
out[outOffset + 3] = 255;
}
}
}
function convertPlanarYuvToRGBA(
data: Uint8Array,
layout: LibAVPlaneLayout[] | undefined,
width: number,
height: number,
out: Uint8Array,
chromaDivX: number,
chromaDivY: number,
fullRange: boolean,
): void {
const chromaWidth = Math.ceil(width / chromaDivX);
const chromaHeight = Math.ceil(height / chromaDivY);
const yPlane = resolvePlane(layout, 0, width, height, 0, width);
const uDefaultOffset = yPlane.offset + yPlane.stride * yPlane.height;
const uPlane = resolvePlane(layout, 1, chromaWidth, chromaHeight, uDefaultOffset, chromaWidth);
const vDefaultOffset = uPlane.offset + uPlane.stride * uPlane.height;
const vPlane = resolvePlane(layout, 2, chromaWidth, chromaHeight, vDefaultOffset, chromaWidth);
for (let y = 0; y < height; y += 1) {
const yRow = yPlane.offset + y * yPlane.stride;
const cRow = Math.floor(y / chromaDivY);
const uRow = uPlane.offset + cRow * uPlane.stride;
const vRow = vPlane.offset + cRow * vPlane.stride;
for (let x = 0; x < width; x += 1) {
const yValue = data[yRow + x] ?? 0;
const cX = Math.floor(x / chromaDivX);
const uValue = data[uRow + cX] ?? 128;
const vValue = data[vRow + cX] ?? 128;
const outOffset = (y * width + x) * 4;
Iif (fullRange) {
const yy = yValue;
const u = uValue - 128;
const v = vValue - 128;
out[outOffset] = clampToByte(Math.round(yy + 1.402 * v));
out[outOffset + 1] = clampToByte(Math.round(yy - 0.344_136 * u - 0.714_136 * v));
out[outOffset + 2] = clampToByte(Math.round(yy + 1.772 * u));
} else {
const c = yValue - 16;
const d = uValue - 128;
const e = vValue - 128;
out[outOffset] = clampToByte((298 * c + 409 * e + 128) >> 8);
out[outOffset + 1] = clampToByte((298 * c - 100 * d - 208 * e + 128) >> 8);
out[outOffset + 2] = clampToByte((298 * c + 516 * d + 128) >> 8);
}
out[outOffset + 3] = 255;
}
}
}
function resolvePlane(
layout: LibAVPlaneLayout[] | undefined,
index: number,
width: number,
height: number,
fallbackOffset: number,
fallbackStride: number,
): { offset: number; stride: number; width: number; height: number } {
const entry = layout?.[index];
return {
offset: entry?.offset ?? fallbackOffset,
stride: entry?.stride ?? fallbackStride,
width,
height,
};
}
function clampToByte(value: number): number {
if (value < 0) {
return 0;
}
if (value > 255) {
return 255;
}
return value;
}
async function createLibAVInstance(): Promise<LibAVInstance> {
if (typeof globalThis.self === 'undefined') {
(globalThis as { self?: unknown }).self = globalThis;
}
// In a SEA binary the bare-specifier import always fails; the helper retries from a `node_modules`
// directory next to the executable (or the working directory) before giving up.
const loadedModule = (await loadOptionalNodeModule('@uwx/libav.js-fat', () => import('@uwx/libav.js-fat'))) as
| LibAVModule
| LibAVFactory
| undefined;
Iif (!loadedModule) {
throw new Error('@uwx/libav.js-fat is unavailable; cannot decode video BGA.');
}
// `import()` wraps the CJS exports in a namespace whose `default` holds them; the createRequire fallback
// used inside a SEA returns the exports object directly. Accept both shapes.
const libavFactory = 'default' in loadedModule ? loadedModule.default : loadedModule;
Iif (typeof libavFactory.LibAV !== 'function') {
throw new Error('@uwx/libav.js-fat does not expose a LibAV factory; cannot decode video BGA.');
}
return libavFactory.LibAV({
noworker: true,
variant: 'fat',
});
}
function resolveBGAVideoWorkerURL(): URL {
return new URL(import.meta.url.endsWith('.ts') ? './bga-video-worker.ts' : './bga-video-worker.js', import.meta.url);
}
function resolveBGAVideoWorkerExecArgv(): string[] {
Iif (!import.meta.url.endsWith('.ts')) {
return process.execArgv;
}
Iif (process.execArgv.includes('--conditions=source')) {
return process.execArgv;
}
return [...process.execArgv, '--conditions=source'];
}
|