@mediabunny/prores 1.66.2 → 1.66.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.
@@ -13,17 +13,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13
13
  import { CustomVideoDecoder, Logging, registerDecoder, VideoSample } from "mediabunny";
14
14
 
15
15
  // node_modules/turbores/dist/turbores.js
16
- var p = class extends Error {
16
+ var y = class extends Error {
17
17
  constructor(e = "The decoder ran out of memory.") {
18
18
  super(e), this.name = "OutOfMemoryError";
19
19
  }
20
20
  };
21
- var H = class extends Error {
21
+ var j = class extends Error {
22
22
  constructor(e = "Invalid data: the packet ended before the decoder expected it to.") {
23
23
  super(e), this.name = "UnexpectedEofError";
24
24
  }
25
25
  };
26
- var x = class extends Error {
26
+ var E = class extends Error {
27
27
  constructor(e = "The packet contains invalid data.") {
28
28
  super(e), this.name = "InvalidDataError";
29
29
  }
@@ -33,12 +33,12 @@ var C = class extends Error {
33
33
  super(e), this.name = "NotSupportedError";
34
34
  }
35
35
  };
36
- var N = class extends Error {
36
+ var Q = class extends Error {
37
37
  constructor(e = "The decoder is in an invalid internal state. This should never happen! Please report.") {
38
38
  super(e), this.name = "InvalidStateError";
39
39
  }
40
40
  };
41
- var j = class extends Error {
41
+ var G = class extends Error {
42
42
  constructor(e = "The decoder has been closed.") {
43
43
  super(e), this.name = "DecoderClosedError";
44
44
  }
@@ -48,30 +48,35 @@ var O = class extends Error {
48
48
  super(e), this.name = "FrameLockedError";
49
49
  }
50
50
  };
51
- var W = (t, e) => {
51
+ var w = class extends Error {
52
+ constructor(e = "A worker failed to start.") {
53
+ super(e), this.name = "WorkerStartError";
54
+ }
55
+ };
56
+ var T = (t, e) => {
52
57
  switch (t) {
53
58
  case -1:
54
- return new p(e);
59
+ return new y(e);
55
60
  case -2:
56
- return new H(e);
61
+ return new j(e);
57
62
  case -3:
58
- return new x(e);
63
+ return new E(e);
59
64
  case -4:
60
65
  return new C(e);
61
66
  case -5:
62
- return new N(e);
67
+ return new Q(e);
63
68
  // Overflow is just another flavor of invalid data
64
69
  case -6:
65
- return new x(e ?? "Unexpected integer overflow.");
70
+ return new E(e ?? "Unexpected integer overflow.");
66
71
  default:
67
72
  throw new Error(`Unhandled error code: ${t}`);
68
73
  }
69
74
  };
70
- function h(t) {
75
+ function c(t) {
71
76
  if (!t)
72
77
  throw new Error("Assertion failed.");
73
78
  }
74
- var T = (t) => {
79
+ var U = (t) => {
75
80
  let e = 0, r = "";
76
81
  for (; e < t.length; ) {
77
82
  let o = t[e++];
@@ -97,7 +102,7 @@ var T = (t) => {
97
102
  }
98
103
  return r;
99
104
  };
100
- var y = class {
105
+ var _ = class {
101
106
  constructor() {
102
107
  __publicField(this, "currentPromise", Promise.resolve());
103
108
  __publicField(this, "pending", 0);
@@ -113,11 +118,11 @@ var y = class {
113
118
  return this.currentPromise = r, this.pending++, await o, e;
114
119
  }
115
120
  };
116
- var I = typeof SharedArrayBuffer < "u";
121
+ var x = typeof SharedArrayBuffer < "u";
117
122
  var L = (t) => t;
118
123
  Symbol.dispose ??= Symbol("dispose");
119
124
  Symbol.asyncDispose ??= Symbol("asyncDispose");
120
- var g = [
125
+ var p = [
121
126
  // 4:2:0 Y, U, V
122
127
  "I420",
123
128
  "I420P10",
@@ -143,14 +148,14 @@ var g = [
143
148
  "I444AP10",
144
149
  "I444AP12"
145
150
  ];
146
- var Q = {
151
+ var V = {
147
152
  1: "bt709",
148
153
  5: "bt470bg",
149
154
  6: "smpte170m",
150
155
  9: "bt2020",
151
156
  12: "smpte432"
152
157
  };
153
- var V = {
158
+ var X = {
154
159
  1: "bt709",
155
160
  6: "smpte170m",
156
161
  8: "linear",
@@ -158,17 +163,17 @@ var V = {
158
163
  16: "pq",
159
164
  18: "hlg"
160
165
  };
161
- var G = {
166
+ var Y = {
162
167
  0: "rgb",
163
168
  1: "bt709",
164
169
  5: "bt470bg",
165
170
  6: "smpte170m",
166
171
  9: "bt2020-ncl"
167
172
  };
168
- var b = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
173
+ var k = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
169
174
  t.exports.closeFrame(e);
170
175
  });
171
- var X = class {
176
+ var J = class {
172
177
  constructor() {
173
178
  /**
174
179
  * The raw data of the decoded frame, stored in the format described by `pixelFormat`. All frame data is stored in
@@ -267,15 +272,15 @@ var X = class {
267
272
  }
268
273
  /** {@link Frame.colorPrimaries} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
269
274
  get colorPrimariesString() {
270
- return this.colorPrimaries === null ? void 0 : Q[this.colorPrimaries];
275
+ return this.colorPrimaries === null ? void 0 : V[this.colorPrimaries];
271
276
  }
272
277
  /** {@link Frame.colorTransfer} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
273
278
  get colorTransferString() {
274
- return this.colorTransfer === null ? void 0 : V[this.colorTransfer];
279
+ return this.colorTransfer === null ? void 0 : X[this.colorTransfer];
275
280
  }
276
281
  /** {@link Frame.colorMatrix} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
277
282
  get colorMatrixString() {
278
- return this.colorMatrix === null ? void 0 : G[this.colorMatrix];
283
+ return this.colorMatrix === null ? void 0 : Y[this.colorMatrix];
279
284
  }
280
285
  /** Whether this frame is locked by an in-flight decoding operation. While locked, it cannot be used or cleared. */
281
286
  get isLocked() {
@@ -299,7 +304,7 @@ var X = class {
299
304
  clear() {
300
305
  if (this._locked)
301
306
  throw new O();
302
- this._ptr !== null && (h(this._runtime), b.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null), this._buffer = null, this._reset();
307
+ this._ptr !== null && (c(this._runtime), k.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null), this._buffer = null, this._reset();
303
308
  }
304
309
  /** Calls `.clear()` internally. */
305
310
  [Symbol.dispose]() {
@@ -309,9 +314,9 @@ var X = class {
309
314
  _ensureWasmFrame(e) {
310
315
  if (this._runtime === e)
311
316
  return true;
312
- this._runtime && (b.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null);
317
+ this._runtime && (k.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null);
313
318
  const r = e.exports.createFrame();
314
- return r === 0 ? false : (this._runtime = e, this._ptr = r, b.register(this, { runtime: e, ptr: r }, this), true);
319
+ return r === 0 ? false : (this._runtime = e, this._ptr = r, k.register(this, { runtime: e, ptr: r }, this), true);
315
320
  }
316
321
  /** @internal */
317
322
  _reset() {
@@ -322,24 +327,24 @@ var X = class {
322
327
  this.frameData = e.frameData, this.codedWidth = e.codedWidth, this.codedHeight = e.codedHeight, this.visibleWidth = e.visibleWidth, this.visibleHeight = e.visibleHeight, this.pixelFormat = e.pixelFormat, this.originalPixelFormat = e.originalPixelFormat, this.pixelAspectRatio = e.pixelAspectRatio, this.colorPrimaries = e.colorPrimaries, this.colorTransfer = e.colorTransfer, this.colorMatrix = e.colorMatrix, this.colorRangeFull = e.colorRangeFull, this.scanType = e.scanType;
323
328
  }
324
329
  };
325
- var Y = (t, e, r, o) => {
326
- const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), a = g[t.getFramePixelFormat(r)];
327
- h(a !== void 0);
328
- const c = g[t.getOriginalPixelFormat(o)];
329
- h(c !== void 0);
330
- const d = [
330
+ var K = (t, e, r, o) => {
331
+ const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), a = p[t.getFramePixelFormat(r)];
332
+ c(a !== void 0);
333
+ const d = p[t.getOriginalPixelFormat(o)];
334
+ c(d !== void 0);
335
+ const u = [
331
336
  "progressive",
332
337
  "interlaced-top-field-first",
333
338
  "interlaced-bottom-field-first"
334
339
  ][t.getScanType(r)];
335
- return h(d !== void 0), {
340
+ return c(u !== void 0), {
336
341
  frameData: n,
337
342
  codedWidth: t.getCodedWidth(r),
338
343
  codedHeight: t.getCodedHeight(r),
339
344
  visibleWidth: t.getVisibleWidth(r),
340
345
  visibleHeight: t.getVisibleHeight(r),
341
346
  pixelFormat: a,
342
- originalPixelFormat: c,
347
+ originalPixelFormat: d,
343
348
  pixelAspectRatio: {
344
349
  num: t.getAspectRatioNum(r),
345
350
  den: t.getAspectRatioDen(r)
@@ -349,11 +354,11 @@ var Y = (t, e, r, o) => {
349
354
  colorMatrix: t.getColorMatrix(r),
350
355
  colorRangeFull: false,
351
356
  // Always limited range, but expose it for clarity
352
- scanType: d
357
+ scanType: u
353
358
  };
354
359
  };
355
- var l = /* @__PURE__ */ ((t) => (t[t.SharedMemoryInit = 0] = "SharedMemoryInit", t[t.MessagePassingInit = 1] = "MessagePassingInit", t[t.CreateDecoder = 2] = "CreateDecoder", t[t.CloseDecoder = 3] = "CloseDecoder", t[t.Decode = 4] = "Decode", t[t.Ready = 5] = "Ready", t[t.InitOutOfMemoryError = 6] = "InitOutOfMemoryError", t[t.Decoded = 7] = "Decoded", t[t.DecodeError = 8] = "DecodeError", t))(l || {});
356
- var k = `\0asm\0\0\0\x99\`\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\0\`\x7F\0\`\0\0\`\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`
360
+ var l = /* @__PURE__ */ ((t) => (t[t.SharedMemoryInit = 0] = "SharedMemoryInit", t[t.MessagePassingInit = 1] = "MessagePassingInit", t[t.CreateDecoder = 2] = "CreateDecoder", t[t.CloseDecoder = 3] = "CloseDecoder", t[t.Decode = 4] = "Decode", t[t.Ready = 5] = "Ready", t[t.InitOutOfMemoryError = 6] = "InitOutOfMemoryError", t[t.InitError = 7] = "InitError", t[t.Decoded = 8] = "Decoded", t[t.DecodeError = 9] = "DecodeError", t))(l || {});
361
+ var S = `\0asm\0\0\0\x99\`\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\0\`\x7F\0\`\0\0\`\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`
357
362
  \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\`\x7F\x7F\x7F\x7F{{{{{{{{{{{{{{{{\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F\x7F{{{{{{{{{{{{{{{{\x7F\x7F\x7F\0\` \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\0\`\x7F\x7F\0\`\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F\`\x7F\x7F\x7F\0\`\0\x7Fenvmemory\x80\x80ML\x07\x07\b\b\b\b\b\b\b\b\b\b
358
363
  \0\v\f\v\r\0\r\v\v\v\r\r\f\f\v\vp \x7FA\x80\x80\xC0\0\v\x7FA\0\v\x7F\0A\x90\b\v\x7F\0A\v\x07\xE1!__stack_pointer\0
359
364
  __tls_base
@@ -1257,41 +1262,59 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1257
1262
  \0\xA0\0\xA0\x07\0\xA0\0\xA0\0\xA0\0\xA0\b\0\xA0\b\0\xA0\b\0\xA0\b\0\xA0
1258
1263
  \0\0\0\0\0\0\0\0\x90\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\b\0\0\0
1259
1264
  \0\0\0\f\0\0\0Frame dimensions (x) exceed the maximum supported size of 16384x16384.\0\0\0\0\0\0\0\0\x07\0\0\0\b\0\0\0Unexpected slice count: expected , found .\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`;
1260
- var J = async (t, e) => {
1265
+ var Z = async (t, e) => {
1261
1266
  const { instance: r } = await WebAssembly.instantiate(t, {
1262
1267
  env: {
1263
1268
  memory: e,
1264
1269
  externPrint: (o, i) => {
1265
1270
  const s = new Uint8Array(e.buffer, o, i);
1266
- console.log(T(s));
1271
+ console.log(U(s));
1267
1272
  }
1268
1273
  }
1269
1274
  });
1270
1275
  return r.exports;
1271
1276
  };
1272
- var D = `"use strict";var I=(e=>(e[e.OutOfMemory=-1]="OutOfMemory",e[e.UnexpectedEof=-2]="UnexpectedEof",e[e.InvalidData=-3]="InvalidData",e[e.NotSupported=-4]="NotSupported",e[e.InvalidState=-5]="InvalidState",e[e.Overflow=-6]="Overflow",e))(I||{});function f(e){if(!e)throw new Error("Assertion failed.")}const O=e=>{let t=0,r="";for(;t<e.length;){let o=e[t++];if(o>127)if(o>191&&o<224){if(t>=e.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");o=(o&31)<<6|e[t++]&63}else if(o>223&&o<240){if(t+1>=e.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");o=(o&15)<<12|(e[t++]&63)<<6|e[t++]&63}else if(o>239&&o<248){if(t+2>=e.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");o=(o&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+o.toString(16)+" at index "+(t-1));if(o<=65535)r+=String.fromCharCode(o);else if(o<=1114111)o-=65536,r+=String.fromCharCode(o>>10|55296),r+=String.fromCharCode(o&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+o.toString(16)+" exceeds UTF-16 reach")}return r};Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");const S=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"];new FinalizationRegistry(({runtime:e,ptr:t})=>{e.exports.closeFrame(t)});const _=(e,t,r,o)=>{const i=e.getFrameDataPtr(r),a=e.getFrameDataSize(r),w=new Uint8Array(t.buffer,i,a),u=S[e.getFramePixelFormat(r)];f(u!==void 0);const l=S[e.getOriginalPixelFormat(o)];f(l!==void 0);const c=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][e.getScanType(r)];return f(c!==void 0),{frameData:w,codedWidth:e.getCodedWidth(r),codedHeight:e.getCodedHeight(r),visibleWidth:e.getVisibleWidth(r),visibleHeight:e.getVisibleHeight(r),pixelFormat:u,originalPixelFormat:l,pixelAspectRatio:{num:e.getAspectRatioNum(r),den:e.getAspectRatioDen(r)},colorPrimaries:e.getColorPrimaries(r),colorTransfer:e.getColorTransfer(r),colorMatrix:e.getColorMatrix(r),colorRangeFull:!1,scanType:c}};var n=(e=>(e[e.SharedMemoryInit=0]="SharedMemoryInit",e[e.MessagePassingInit=1]="MessagePassingInit",e[e.CreateDecoder=2]="CreateDecoder",e[e.CloseDecoder=3]="CloseDecoder",e[e.Decode=4]="Decode",e[e.Ready=5]="Ready",e[e.InitOutOfMemoryError=6]="InitOutOfMemoryError",e[e.Decoded=7]="Decoded",e[e.DecodeError=8]="DecodeError",e))(n||{});const A=async(e,t)=>{const{instance:r}=await WebAssembly.instantiate(e,{env:{memory:t,externPrint:(o,i)=>{const a=new Uint8Array(t.buffer,o,i);console.log(O(a))}}});return r.exports};let s=null;const F=async e=>{switch(e.type){case n.SharedMemoryInit:{const t=await A(e.wasmBinary,e.memory);throw t.__stack_pointer.value=e.stackPointer,t.__wasm_init_tls(e.tlsPointer),t.setIsBrowserMainThread(0),t.startWorker(),new Error("Unexpected worker termination.")}case n.MessagePassingInit:{const t=new WebAssembly.Memory({initial:32,maximum:8192,shared:!0}),r=await A(e.wasmBinary,t),o=r.allocateThreadLocalState(r.__tls_size.value,r.__tls_align.value);if(o===0){d({type:n.InitOutOfMemoryError,message:"Failed to allocate thread-local state."});return}r.__wasm_init_tls(o),r.setIsBrowserMainThread(0);const i=r.createFrame();if(i===0){d({type:n.InitOutOfMemoryError,message:"Failed to create frame."});return}s={exports:r,memory:t,decoders:new Map,frame:i},d({type:n.Ready});return}case n.CreateDecoder:{f(s);const{exports:t}=s,{decoderId:r,bitDepth:o,allowedOutputFormats:i}=e,a=t.createDecoder(0,o,i);if(a===0)return;s.decoders.set(r,a);return}case n.CloseDecoder:{f(s);const{exports:t,decoders:r}=s,o=r.get(e.decoderId);o!==void 0&&(t.closeDecoder(o),r.delete(e.decoderId));return}case n.Decode:{f(s);const{exports:t,memory:r,decoders:o,frame:i}=s,{id:a,decoderId:w,packet:u,frameBuffer:l}=e,c=o.get(w);if(c===void 0){d({type:n.DecodeError,id:a,code:I.OutOfMemory});return}const g=t.allocatePacket(c,u.byteLength,0);if(g===0){d({type:n.DecodeError,id:a,code:I.OutOfMemory});return}new Uint8Array(r.buffer).set(u,g);const D=t.decodePacket(c,i,0);if(D<0){let v;const P=t.getErrorMessagePtr(c);if(P!==0){const b=t.getErrorMessageSize(c);v=O(new Uint8Array(r.buffer,P,b))}d({type:n.DecodeError,id:a,code:D,message:v});return}const m=_(t,r,i,c),y=l&&l.byteLength===m.frameData.byteLength?l:new ArrayBuffer(m.frameData.byteLength),p=new Uint8Array(y);p.set(m.frameData),m.frameData=p,d({type:n.Decoded,id:a,contents:m},[y]);return}}},d=(e,t)=>{h?h.postMessage(e,t??[]):self.postMessage(e,{transfer:t??[]})};let h=null;try{h=require("node:worker_threads").parentPort}catch{}h?h.on("message",F):self.addEventListener("message",e=>void F(e.data));
1277
+ var D = `"use strict";var w=(e=>(e[e.OutOfMemory=-1]="OutOfMemory",e[e.UnexpectedEof=-2]="UnexpectedEof",e[e.InvalidData=-3]="InvalidData",e[e.NotSupported=-4]="NotSupported",e[e.InvalidState=-5]="InvalidState",e[e.Overflow=-6]="Overflow",e))(w||{});function f(e){if(!e)throw new Error("Assertion failed.")}const O=e=>{let t=0,r="";for(;t<e.length;){let o=e[t++];if(o>127)if(o>191&&o<224){if(t>=e.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");o=(o&31)<<6|e[t++]&63}else if(o>223&&o<240){if(t+1>=e.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");o=(o&15)<<12|(e[t++]&63)<<6|e[t++]&63}else if(o>239&&o<248){if(t+2>=e.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");o=(o&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+o.toString(16)+" at index "+(t-1));if(o<=65535)r+=String.fromCharCode(o);else if(o<=1114111)o-=65536,r+=String.fromCharCode(o>>10|55296),r+=String.fromCharCode(o&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+o.toString(16)+" exceeds UTF-16 reach")}return r};Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");const v=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"];new FinalizationRegistry(({runtime:e,ptr:t})=>{e.exports.closeFrame(t)});const _=(e,t,r,o)=>{const i=e.getFrameDataPtr(r),a=e.getFrameDataSize(r),I=new Uint8Array(t.buffer,i,a),m=v[e.getFramePixelFormat(r)];f(m!==void 0);const l=v[e.getOriginalPixelFormat(o)];f(l!==void 0);const c=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][e.getScanType(r)];return f(c!==void 0),{frameData:I,codedWidth:e.getCodedWidth(r),codedHeight:e.getCodedHeight(r),visibleWidth:e.getVisibleWidth(r),visibleHeight:e.getVisibleHeight(r),pixelFormat:m,originalPixelFormat:l,pixelAspectRatio:{num:e.getAspectRatioNum(r),den:e.getAspectRatioDen(r)},colorPrimaries:e.getColorPrimaries(r),colorTransfer:e.getColorTransfer(r),colorMatrix:e.getColorMatrix(r),colorRangeFull:!1,scanType:c}};var n=(e=>(e[e.SharedMemoryInit=0]="SharedMemoryInit",e[e.MessagePassingInit=1]="MessagePassingInit",e[e.CreateDecoder=2]="CreateDecoder",e[e.CloseDecoder=3]="CloseDecoder",e[e.Decode=4]="Decode",e[e.Ready=5]="Ready",e[e.InitOutOfMemoryError=6]="InitOutOfMemoryError",e[e.InitError=7]="InitError",e[e.Decoded=8]="Decoded",e[e.DecodeError=9]="DecodeError",e))(n||{});const U=async(e,t)=>{const{instance:r}=await WebAssembly.instantiate(e,{env:{memory:t,externPrint:(o,i)=>{const a=new Uint8Array(t.buffer,o,i);console.log(O(a))}}});return r.exports};let d=null;const F=async e=>{switch(e.type){case n.SharedMemoryInit:{const t=await A(e.wasmBinary,e.memory);if(!t)return;throw t.__stack_pointer.value=e.stackPointer,t.__wasm_init_tls(e.tlsPointer),t.setIsBrowserMainThread(0),s({type:n.Ready}),t.startWorker(),new Error("Unexpected worker termination.")}case n.MessagePassingInit:{const t=new WebAssembly.Memory({initial:32,maximum:8192,shared:!0}),r=await A(e.wasmBinary,t);if(!r)return;const o=r.allocateThreadLocalState(r.__tls_size.value,r.__tls_align.value);if(o===0){s({type:n.InitOutOfMemoryError,message:"Failed to allocate thread-local state."});return}r.__wasm_init_tls(o),r.setIsBrowserMainThread(0);const i=r.createFrame();if(i===0){s({type:n.InitOutOfMemoryError,message:"Failed to create frame."});return}d={exports:r,memory:t,decoders:new Map,frame:i},s({type:n.Ready});return}case n.CreateDecoder:{f(d);const{exports:t}=d,{decoderId:r,bitDepth:o,allowedOutputFormats:i}=e,a=t.createDecoder(0,o,i);if(a===0)return;d.decoders.set(r,a);return}case n.CloseDecoder:{f(d);const{exports:t,decoders:r}=d,o=r.get(e.decoderId);o!==void 0&&(t.closeDecoder(o),r.delete(e.decoderId));return}case n.Decode:{f(d);const{exports:t,memory:r,decoders:o,frame:i}=d,{id:a,decoderId:I,packet:m,frameBuffer:l}=e,c=o.get(I);if(c===void 0){s({type:n.DecodeError,id:a,code:w.OutOfMemory});return}const g=t.allocatePacket(c,m.byteLength,0);if(g===0){s({type:n.DecodeError,id:a,code:w.OutOfMemory});return}new Uint8Array(r.buffer).set(m,g);const D=t.decodePacket(c,i,0);if(D<0){let S;const P=t.getErrorMessagePtr(c);if(P!==0){const b=t.getErrorMessageSize(c);S=O(new Uint8Array(r.buffer,P,b))}s({type:n.DecodeError,id:a,code:D,message:S});return}const h=_(t,r,i,c),y=l&&l.byteLength===h.frameData.byteLength?l:new ArrayBuffer(h.frameData.byteLength),p=new Uint8Array(y);p.set(h.frameData),h.frameData=p,s({type:n.Decoded,id:a,contents:h},[y]);return}}},A=async(e,t)=>{try{return await U(e,t)}catch(r){return s({type:n.InitError,message:String(r)}),null}},s=(e,t)=>{u?u.postMessage(e,t??[]):self.postMessage(e,{transfer:t??[]})};let u=null;try{u=require("node:worker_threads").parentPort}catch{"WorkerGlobalScope"in globalThis||(u=process.getBuiltinModule("node:worker_threads").parentPort)}u?u.on("message",F):self.addEventListener("message",e=>void F(e.data));
1273
1278
  `;
1274
- var w = null;
1275
- var P = () => {
1276
- if (w)
1277
- return w;
1278
- w = new Uint8Array(k.length);
1279
- for (let t = 0; t < k.length; t++)
1280
- w[t] = k.charCodeAt(t);
1281
- return w;
1279
+ var g = null;
1280
+ var I = () => {
1281
+ if (g)
1282
+ return g;
1283
+ g = new Uint8Array(S.length);
1284
+ for (let t = 0; t < S.length; t++)
1285
+ g[t] = S.charCodeAt(t);
1286
+ return g;
1282
1287
  };
1283
- var U = async () => {
1288
+ var q = async () => {
1289
+ const t = globalThis[Symbol.for("turbores:workerUrl")];
1290
+ if (t !== void 0 && typeof t != "string" && !(t instanceof URL))
1291
+ throw new TypeError("globalThis[Symbol.for('turbores:workerUrl')], when provided, must be a string or URL.");
1284
1292
  if (typeof Worker < "u" && !("Bun" in globalThis)) {
1285
- const e = new Blob([D], { type: "text/javascript" }), r = URL.createObjectURL(e), o = new Worker(r, { type: "module" });
1286
- return new E(o, null);
1293
+ let r = t;
1294
+ if (r === void 0) {
1295
+ const o = new Blob([D], { type: "text/javascript" });
1296
+ r = URL.createObjectURL(o);
1297
+ }
1298
+ try {
1299
+ return new F(new Worker(r, { type: "module" }), null);
1300
+ } catch (o) {
1301
+ return new w(`A worker failed to start: ${String(o)}`);
1302
+ }
1287
1303
  }
1288
- const t = await import(
1304
+ const e = await import(
1289
1305
  /* @vite-ignore */
1290
1306
  "node:" + L("worker_threads")
1291
1307
  );
1292
- return new E(null, new t.Worker(D, { eval: true }));
1308
+ try {
1309
+ return new F(
1310
+ null,
1311
+ t !== void 0 ? new e.Worker(t) : new e.Worker(D, { eval: true })
1312
+ );
1313
+ } catch (r) {
1314
+ return new w(`A worker failed to start: ${String(r)}`);
1315
+ }
1293
1316
  };
1294
- var E = class {
1317
+ var F = class {
1295
1318
  constructor(e, r) {
1296
1319
  __publicField(this, "wrappedListeners", /* @__PURE__ */ new Map());
1297
1320
  this.webWorker = e, this.nodeWorker = r;
@@ -1307,6 +1330,9 @@ var E = class {
1307
1330
  this.wrappedListeners.set(r, i), o?.once ? this.nodeWorker.once(e, i) : this.nodeWorker.on(e, i);
1308
1331
  }
1309
1332
  }
1333
+ onError(e) {
1334
+ this.webWorker ? this.webWorker.addEventListener("error", (r) => e(r.message)) : this.nodeWorker.on("error", (r) => e(r.message));
1335
+ }
1310
1336
  removeEventListener(e, r) {
1311
1337
  this.webWorker ? this.webWorker.removeEventListener(e, r) : (this.nodeWorker.off(e, this.wrappedListeners.get(r)), this.wrappedListeners.delete(r));
1312
1338
  }
@@ -1314,11 +1340,11 @@ var E = class {
1314
1340
  this.webWorker ? this.webWorker.terminate() : this.nodeWorker.terminate();
1315
1341
  }
1316
1342
  };
1317
- var F = new FinalizationRegistry((t) => {
1343
+ var M = new FinalizationRegistry((t) => {
1318
1344
  for (const e of t)
1319
1345
  e.terminate();
1320
1346
  });
1321
- var K = async () => {
1347
+ var $ = async () => {
1322
1348
  if (typeof navigator < "u" && navigator.hardwareConcurrency)
1323
1349
  return navigator.hardwareConcurrency;
1324
1350
  const t = await import(
@@ -1327,33 +1353,33 @@ var K = async () => {
1327
1353
  );
1328
1354
  return t.availableParallelism?.() ?? t.cpus().length;
1329
1355
  };
1330
- var _ = null;
1331
- var Z = new y();
1332
- var $ = async () => {
1333
- const t = await Z.acquire();
1356
+ var b = null;
1357
+ var ee = new _();
1358
+ var re = async () => {
1359
+ const t = await ee.acquire();
1334
1360
  try {
1335
- if (_) {
1336
- const r = _.deref();
1361
+ if (b) {
1362
+ const r = b.deref();
1337
1363
  if (r)
1338
1364
  return r;
1339
1365
  }
1340
1366
  const e = await v.init();
1341
- return _ = new WeakRef(e), e;
1367
+ return b = new WeakRef(e), e;
1342
1368
  } finally {
1343
1369
  t();
1344
1370
  }
1345
1371
  };
1346
- var S = null;
1347
- var ee = () => {
1348
- let t = S?.deref();
1349
- return t || (t = new re(), S = new WeakRef(t)), t;
1372
+ var P = null;
1373
+ var te = () => {
1374
+ let t = P?.deref();
1375
+ return t || (t = new oe(), P = new WeakRef(t)), t;
1350
1376
  };
1351
- var q = class {
1377
+ var z = class {
1352
1378
  constructor() {
1353
1379
  __publicField(this, "workers", []);
1354
1380
  // The number of decoders currently using this runtime
1355
1381
  __publicField(this, "refCount", 0);
1356
- F.register(this, this.workers, this);
1382
+ M.register(this, this.workers, this);
1357
1383
  }
1358
1384
  ref() {
1359
1385
  this.refCount++;
@@ -1364,15 +1390,15 @@ var q = class {
1364
1390
  destroy() {
1365
1391
  for (const e of this.workers)
1366
1392
  e.terminate();
1367
- this.workers.length = 0, F.unregister(this);
1393
+ this.workers.length = 0, M.unregister(this);
1368
1394
  }
1369
1395
  };
1370
- var v = class _v extends q {
1396
+ var v = class _v extends z {
1371
1397
  constructor(e, r) {
1372
1398
  super(), this.memory = e, this.exports = r;
1373
1399
  }
1374
1400
  static async init() {
1375
- const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await J(P(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
1401
+ const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await Z(I(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
1376
1402
  if (o === 0)
1377
1403
  throw new Error("Failed to allocate thread-local state.");
1378
1404
  r.__wasm_init_tls(o);
@@ -1380,28 +1406,39 @@ var v = class _v extends q {
1380
1406
  return r.setIsBrowserMainThread(Number(i)), new _v(e, r);
1381
1407
  }
1382
1408
  async ensureWorkers(e) {
1383
- for (; this.workers.length < e; ) {
1384
- const r = this.exports.allocateWorkerStack(), o = this.exports.allocateThreadLocalState(
1409
+ const r = [];
1410
+ let o = null;
1411
+ for (; this.workers.length + r.length < e; ) {
1412
+ const i = this.exports.allocateWorkerStack(), s = this.exports.allocateThreadLocalState(
1385
1413
  this.exports.__tls_size.value,
1386
1414
  this.exports.__tls_align.value
1387
1415
  );
1388
- if (r === 0 || o === 0)
1416
+ if (i === 0 || s === 0)
1389
1417
  throw new Error("Failed to allocate worker stack or thread-local state.");
1390
- const i = await U();
1391
- i.postMessage({
1418
+ const n = await q();
1419
+ if (n instanceof w) {
1420
+ o = n;
1421
+ break;
1422
+ }
1423
+ n.postMessage({
1392
1424
  type: l.SharedMemoryInit,
1393
- wasmBinary: P(),
1425
+ wasmBinary: I(),
1394
1426
  memory: this.memory,
1395
- stackPointer: r,
1396
- tlsPointer: o
1397
- }), this.workers.push(i);
1427
+ stackPointer: i,
1428
+ tlsPointer: s
1429
+ }), r.push({ worker: n, reply: B(n) });
1398
1430
  }
1431
+ for (const { worker: i, reply: s } of r) {
1432
+ const n = await s;
1433
+ n instanceof w ? (i.terminate(), o = n) : (c(n.type === l.Ready), this.workers.push(i));
1434
+ }
1435
+ return o;
1399
1436
  }
1400
1437
  destroy() {
1401
- super.destroy(), _ = null;
1438
+ super.destroy(), b = null;
1402
1439
  }
1403
1440
  };
1404
- var re = class extends q {
1441
+ var oe = class extends z {
1405
1442
  constructor() {
1406
1443
  super(...arguments);
1407
1444
  // How many packets each worker currently has in flight
@@ -1434,15 +1471,19 @@ var re = class extends q {
1434
1471
  return;
1435
1472
  const o = await Promise.all(
1436
1473
  Array.from({ length: r }, async () => {
1437
- const s = await U(), n = await new Promise((a) => {
1438
- s.postMessage({
1439
- type: l.MessagePassingInit,
1440
- wasmBinary: P()
1441
- }), s.addEventListener("message", (c) => a(c.data), { once: true });
1474
+ const s = await q();
1475
+ if (s instanceof w)
1476
+ return s;
1477
+ s.postMessage({
1478
+ type: l.MessagePassingInit,
1479
+ wasmBinary: I()
1442
1480
  });
1443
- return n.type === l.InitOutOfMemoryError ? (s.terminate(), new p(n.message)) : s;
1481
+ const n = await B(s);
1482
+ return n instanceof w ? (s.terminate(), n) : n.type === l.InitOutOfMemoryError ? (s.terminate(), new y(n.message)) : s;
1444
1483
  })
1445
- ), i = o.find((s) => s instanceof Error);
1484
+ ), i = o.find(
1485
+ (s) => s instanceof Error
1486
+ );
1446
1487
  if (i) {
1447
1488
  for (const s of o)
1448
1489
  s instanceof Error || s.terminate();
@@ -1450,20 +1491,28 @@ var re = class extends q {
1450
1491
  }
1451
1492
  for (const s of o) {
1452
1493
  this.workers.push(s), this.workerLoad.push(0);
1453
- for (const [n, { bitDepth: a, allowedOutputFormats: c }] of this.registeredDecoders)
1494
+ for (const [n, { bitDepth: a, allowedOutputFormats: d }] of this.registeredDecoders)
1454
1495
  s.postMessage({
1455
1496
  type: l.CreateDecoder,
1456
1497
  decoderId: n,
1457
1498
  bitDepth: a,
1458
- allowedOutputFormats: c
1499
+ allowedOutputFormats: d
1459
1500
  });
1460
1501
  }
1461
1502
  }
1462
1503
  destroy() {
1463
- super.destroy(), S = null;
1504
+ super.destroy(), P = null;
1464
1505
  }
1465
1506
  };
1466
- var M = [
1507
+ var B = (t) => new Promise((e) => {
1508
+ t.addEventListener("message", (r) => {
1509
+ const o = r.data;
1510
+ o.type === l.InitError ? e(new w(`A worker failed to start: ${o.message}`)) : e(o);
1511
+ }, { once: true }), t.onError((r) => {
1512
+ e(new w(r ? `A worker failed to start: ${r}` : void 0));
1513
+ });
1514
+ });
1515
+ var R = [
1467
1516
  "ap4x",
1468
1517
  // ProRes 4444 XQ
1469
1518
  "ap4h",
@@ -1477,7 +1526,7 @@ var M = [
1477
1526
  "apco"
1478
1527
  // ProRes 422 Proxy
1479
1528
  ];
1480
- var z = class {
1529
+ var H = class {
1481
1530
  constructor() {
1482
1531
  /** @internal */
1483
1532
  __publicField(this, "_closed", false);
@@ -1524,17 +1573,17 @@ var z = class {
1524
1573
  static async create(e) {
1525
1574
  if (typeof e != "object" || !e)
1526
1575
  throw new TypeError("options must be an object.");
1527
- if (!M.includes(e.proresFourCc))
1528
- throw new TypeError(`options.proresFourCc must be one of ${M.join(", ")}.`);
1576
+ if (!R.includes(e.proresFourCc))
1577
+ throw new TypeError(`options.proresFourCc must be one of ${R.join(", ")}.`);
1529
1578
  if (typeof e.useSharedMemory != "boolean")
1530
1579
  throw new TypeError("options.useSharedMemory must be a boolean.");
1531
1580
  if (e.concurrency !== void 0 && (!Number.isInteger(e.concurrency) || e.concurrency < 0))
1532
1581
  throw new TypeError("options.concurrency, when provided, must be a non-negative integer.");
1533
- if (e.allowedOutputFormats && !(Array.isArray(e.allowedOutputFormats) && e.allowedOutputFormats.length > 0 && e.allowedOutputFormats.every((s) => g.includes(s))))
1582
+ if (e.allowedOutputFormats && !(Array.isArray(e.allowedOutputFormats) && e.allowedOutputFormats.length > 0 && e.allowedOutputFormats.every((s) => p.includes(s))))
1534
1583
  throw new TypeError(
1535
- `options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${g.join(", ")}.`
1584
+ `options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${p.join(", ")}.`
1536
1585
  );
1537
- if (e.useSharedMemory && !I)
1586
+ if (e.useSharedMemory && !x)
1538
1587
  return new C(
1539
1588
  `Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
1540
1589
  Since it provides way better performance, you should enable it by serving the page cross-origin isolated by setting the Cross-Origin-Opener-Policy header to 'same-origin' and the Cross-Origin-Embedder-Policy header to 'credentialless' or 'require-corp' (only the latter is supported by Safari).
@@ -1544,20 +1593,23 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1544
1593
  if (e.allowedOutputFormats) {
1545
1594
  r = 0;
1546
1595
  for (const s of e.allowedOutputFormats)
1547
- r |= 1 << g.indexOf(s);
1596
+ r |= 1 << p.indexOf(s);
1548
1597
  } else
1549
1598
  r = 4294967295;
1550
- const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await K();
1599
+ const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await $();
1551
1600
  if (e.useSharedMemory || i === 0) {
1552
- const s = await $();
1553
- s.ref(), await s.ensureWorkers(i);
1554
- const n = s.exports.createDecoder(i, o, r);
1555
- return n === 0 ? (s.unref(), new p()) : new te(s, n, i);
1601
+ const s = await re();
1602
+ s.ref();
1603
+ const n = await s.ensureWorkers(i);
1604
+ if (n)
1605
+ return s.unref(), n;
1606
+ const a = s.exports.createDecoder(i, o, r);
1607
+ return a === 0 ? (s.unref(), new y()) : new se(s, a, i);
1556
1608
  } else {
1557
- const s = ee();
1609
+ const s = te();
1558
1610
  s.ref();
1559
1611
  const n = await s.ensureWorkers(i);
1560
- return n ? (s.unref(), n) : new oe(
1612
+ return n ? (s.unref(), n) : new ie(
1561
1613
  s,
1562
1614
  i,
1563
1615
  o,
@@ -1567,7 +1619,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1567
1619
  }
1568
1620
  /** Whether the environment supports proper shared-memory multithreading. */
1569
1621
  static canUseSharedMemory() {
1570
- return I;
1622
+ return x;
1571
1623
  }
1572
1624
  /**
1573
1625
  * Queues a ProRes packet for decoding with the given options. The decoded result will be stored in the passed
@@ -1578,14 +1630,14 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1578
1630
  async decode(e, r, o = {}) {
1579
1631
  if (!(e instanceof Uint8Array))
1580
1632
  throw new TypeError("packetData must be a Uint8Array.");
1581
- if (!(r instanceof X))
1633
+ if (!(r instanceof J))
1582
1634
  throw new TypeError("frame must be a Frame.");
1583
1635
  if (typeof o != "object" || !o)
1584
1636
  throw new TypeError("options must be an object.");
1585
1637
  if (o.transfer !== void 0 && typeof o.transfer != "boolean")
1586
1638
  throw new TypeError("options.transfer, when provided, must be a boolean.");
1587
1639
  if (this._closed)
1588
- return new j();
1640
+ return new G();
1589
1641
  if (r._locked)
1590
1642
  return new O();
1591
1643
  r._reset(), r._locked = true, this._decodeQueueSize++;
@@ -1624,12 +1676,12 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1624
1676
  return this.close();
1625
1677
  }
1626
1678
  };
1627
- var R = new FinalizationRegistry(
1679
+ var A = new FinalizationRegistry(
1628
1680
  ({ runtime: t, ptr: e }) => {
1629
1681
  t.exports.closeDecoder(e), t.unref();
1630
1682
  }
1631
1683
  );
1632
- var te = class extends z {
1684
+ var se = class extends H {
1633
1685
  constructor(e, r, o) {
1634
1686
  super();
1635
1687
  /** @internal */
@@ -1639,68 +1691,68 @@ var te = class extends z {
1639
1691
  /** @internal */
1640
1692
  __publicField(this, "_taskStateOffset");
1641
1693
  /** @internal */
1642
- __publicField(this, "_decodeMutex", new y());
1694
+ __publicField(this, "_decodeMutex", new _());
1643
1695
  /** @internal */
1644
1696
  __publicField(this, "_nextPacketSlot", 0);
1645
1697
  /** @internal */
1646
- __publicField(this, "_packetSlotMutexes", [new y(), new y()]);
1698
+ __publicField(this, "_packetSlotMutexes", [new _(), new _()]);
1647
1699
  /** @internal */
1648
1700
  __publicField(this, "_highWaterMark");
1649
1701
  __publicField(this, "useSharedMemory", true);
1650
1702
  __publicField(this, "concurrency");
1651
- this._highWaterMark = o === 0 ? 1 : 2, this._runtime = e, this._decoderPtr = r, this._taskStateOffset = e.exports.getTaskStateAddress(r) / 4, this.concurrency = o, R.register(this, { runtime: e, ptr: r }, this);
1703
+ this._highWaterMark = o === 0 ? 1 : 2, this._runtime = e, this._decoderPtr = r, this._taskStateOffset = e.exports.getTaskStateAddress(r) / 4, this.concurrency = o, A.register(this, { runtime: e, ptr: r }, this);
1652
1704
  }
1653
1705
  _runClose() {
1654
- h(this._runtime), R.unregister(this), this._runtime.exports.closeDecoder(this._decoderPtr), this._runtime.unref(), this._runtime = null;
1706
+ c(this._runtime), A.unregister(this), this._runtime.exports.closeDecoder(this._decoderPtr), this._runtime.unref(), this._runtime = null;
1655
1707
  }
1656
1708
  async _runDecode(e, r, o) {
1657
- h(this._runtime);
1709
+ c(this._runtime);
1658
1710
  const { exports: i, memory: s } = this._runtime;
1659
1711
  if (!r._ensureWasmFrame(this._runtime))
1660
- return new p();
1712
+ return new y();
1661
1713
  const n = r._ptr;
1662
1714
  o.transfer && (e = structuredClone(e, { transfer: [e.buffer] }));
1663
1715
  const a = this._nextPacketSlot;
1664
1716
  this._nextPacketSlot = this._nextPacketSlot + 1 & 1;
1665
- const c = await this._packetSlotMutexes[a].acquire();
1717
+ const d = await this._packetSlotMutexes[a].acquire();
1666
1718
  try {
1667
- const d = i.allocatePacket(this._decoderPtr, e.byteLength, a);
1668
- if (d === 0)
1669
- return new p();
1670
- new Uint8Array(s.buffer).set(e, d);
1671
- const u = await this._decodeMutex.acquire();
1719
+ const u = i.allocatePacket(this._decoderPtr, e.byteLength, a);
1720
+ if (u === 0)
1721
+ return new y();
1722
+ new Uint8Array(s.buffer).set(e, u);
1723
+ const h = await this._decodeMutex.acquire();
1672
1724
  try {
1673
1725
  let f = i.decodePacket(this._decoderPtr, n, a);
1674
1726
  if (f < 0)
1675
1727
  return this._createError(f);
1676
1728
  if (this.concurrency > 0 && (await Atomics.waitAsync(new Int32Array(s.buffer), this._taskStateOffset, 1).value, f = i.finalizePacketDecoding(this._decoderPtr), f < 0))
1677
1729
  return this._createError(f);
1678
- r._populate(Y(i, s, n, this._decoderPtr));
1730
+ r._populate(K(i, s, n, this._decoderPtr));
1679
1731
  } finally {
1680
- u();
1732
+ h();
1681
1733
  }
1682
1734
  } finally {
1683
- c();
1735
+ d();
1684
1736
  }
1685
1737
  return r;
1686
1738
  }
1687
1739
  /** @internal */
1688
1740
  _createError(e) {
1689
- h(this._runtime);
1741
+ c(this._runtime);
1690
1742
  const { exports: r, memory: o } = this._runtime;
1691
1743
  let i;
1692
1744
  const s = r.getErrorMessagePtr(this._decoderPtr);
1693
1745
  if (s !== 0) {
1694
1746
  const n = r.getErrorMessageSize(this._decoderPtr);
1695
- i = T(new Uint8Array(o.buffer, s, n));
1747
+ i = U(new Uint8Array(o.buffer, s, n));
1696
1748
  }
1697
- return W(e, i);
1749
+ return T(e, i);
1698
1750
  }
1699
1751
  };
1700
- var A = new FinalizationRegistry((t) => {
1752
+ var W = new FinalizationRegistry((t) => {
1701
1753
  t.unref();
1702
1754
  });
1703
- var oe = class extends z {
1755
+ var ie = class extends H {
1704
1756
  constructor(e, r, o, i) {
1705
1757
  super();
1706
1758
  /** @internal */
@@ -1711,34 +1763,34 @@ var oe = class extends z {
1711
1763
  __publicField(this, "_highWaterMark");
1712
1764
  __publicField(this, "useSharedMemory", false);
1713
1765
  __publicField(this, "concurrency");
1714
- this._highWaterMark = Math.max(r, 1), this._runtime = e, this.concurrency = r, this._decoderId = e.nextDecoderId++, e.registerDecoder(this._decoderId, o, i), A.register(this, e, this);
1766
+ this._highWaterMark = Math.max(r, 1), this._runtime = e, this.concurrency = r, this._decoderId = e.nextDecoderId++, e.registerDecoder(this._decoderId, o, i), W.register(this, e, this);
1715
1767
  }
1716
1768
  _runClose() {
1717
- h(this._runtime), this._runtime.unregisterDecoder(this._decoderId), A.unregister(this), this._runtime.unref(), this._runtime = null;
1769
+ c(this._runtime), this._runtime.unregisterDecoder(this._decoderId), W.unregister(this), this._runtime.unref(), this._runtime = null;
1718
1770
  }
1719
1771
  _runDecode(e, r, o) {
1720
- h(this._runtime);
1772
+ c(this._runtime);
1721
1773
  const i = this._runtime, s = o.transfer ? e : e.slice();
1722
1774
  let n = 0;
1723
- for (let u = 1; u < i.workerLoad.length; u++)
1724
- i.workerLoad[u] < i.workerLoad[n] && (n = u);
1775
+ for (let h = 1; h < i.workerLoad.length; h++)
1776
+ i.workerLoad[h] < i.workerLoad[n] && (n = h);
1725
1777
  const a = i.workers[n];
1726
1778
  i.workerLoad[n] = i.workerLoad[n] + 1;
1727
- const c = i.nextRequestId++, d = r._buffer;
1728
- return r._buffer = null, new Promise((u) => {
1779
+ const d = i.nextRequestId++, u = r._buffer;
1780
+ return r._buffer = null, new Promise((h) => {
1729
1781
  a.postMessage(
1730
1782
  {
1731
1783
  type: l.Decode,
1732
- id: c,
1784
+ id: d,
1733
1785
  decoderId: this._decoderId,
1734
1786
  packet: s,
1735
- frameBuffer: d
1787
+ frameBuffer: u
1736
1788
  },
1737
- d ? [s.buffer, d] : [s.buffer]
1789
+ u ? [s.buffer, u] : [s.buffer]
1738
1790
  );
1739
- const f = (B) => {
1740
- const m = B.data;
1741
- m.type !== l.Decoded && m.type !== l.DecodeError || m.id === c && (a.removeEventListener("message", f), i.workerLoad[n]--, m.type === l.DecodeError ? u(W(m.code, m.message)) : (r._buffer = m.contents.frameData.buffer, r._populate(m.contents), u(r)));
1791
+ const f = (N) => {
1792
+ const m = N.data;
1793
+ m.type !== l.Decoded && m.type !== l.DecodeError || m.id === d && (a.removeEventListener("message", f), i.workerLoad[n]--, m.type === l.DecodeError ? h(T(m.code, m.message)) : (r._buffer = m.contents.frameData.buffer, r._populate(m.contents), h(r)));
1742
1794
  };
1743
1795
  a.addEventListener("message", f);
1744
1796
  });
@@ -1786,7 +1838,7 @@ var _ProresDecoder = class _ProresDecoder extends CustomVideoDecoder {
1786
1838
  static _determineSupportedVideoFrameFormats() {
1787
1839
  const result = [];
1788
1840
  const data = new Uint8Array(32);
1789
- for (const format of g) {
1841
+ for (const format of p) {
1790
1842
  try {
1791
1843
  const frame = new VideoFrame(data, {
1792
1844
  format,
@@ -1806,9 +1858,9 @@ var _ProresDecoder = class _ProresDecoder extends CustomVideoDecoder {
1806
1858
  if (typeof VideoFrame !== "undefined") {
1807
1859
  _ProresDecoder._supportedVideoFrameFormats ??= _ProresDecoder._determineSupportedVideoFrameFormats();
1808
1860
  }
1809
- const decoder = await z.create({
1861
+ const decoder = await H.create({
1810
1862
  proresFourCc: this.config.codec,
1811
- useSharedMemory: z.canUseSharedMemory(),
1863
+ useSharedMemory: H.canUseSharedMemory(),
1812
1864
  allowedOutputFormats: _ProresDecoder._supportedVideoFrameFormats ?? void 0
1813
1865
  });
1814
1866
  if (decoder instanceof Error) {
@@ -1829,7 +1881,7 @@ var _ProresDecoder = class _ProresDecoder extends CustomVideoDecoder {
1829
1881
  if (this.framePool.length > 0) {
1830
1882
  frame = this.framePool.shift();
1831
1883
  } else {
1832
- frame = new X();
1884
+ frame = new J();
1833
1885
  }
1834
1886
  const result = await this.decoder.decode(packet.data, frame);
1835
1887
  this.framePool.push(frame);