@supraio/client-daemon-js 1.0.0-mzbrightsigndecoder.490 → 1.0.0-mzbrightsigndecoder.491

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supraio/client-daemon-js",
3
- "version": "1.0.0-mzbrightsigndecoder.490",
3
+ "version": "1.0.0-mzbrightsigndecoder.491",
4
4
  "description": "",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
package/screen.html CHANGED
@@ -5,6 +5,6 @@
5
5
  <link rel="stylesheet" href="screen.css"></link>
6
6
  </head>
7
7
  <body>
8
- <script type="text/javascript" src="screen.js?v=1.0.0-mzbrightsigndecoder.490"></script>
8
+ <script type="text/javascript" src="screen.js?v=1.0.0-mzbrightsigndecoder.491"></script>
9
9
  </body>
10
10
  </html>
package/screen.js CHANGED
@@ -26284,6 +26284,7 @@
26284
26284
  var ownedDecoder;
26285
26285
  var ownedTCP;
26286
26286
  var unloading = false;
26287
+ var teardownPromise;
26287
26288
  function resolvePlaybackProtocol(streamProtocol) {
26288
26289
  switch (streamProtocol) {
26289
26290
  case void 0:
@@ -26316,6 +26317,10 @@
26316
26317
  if (options.screenDriver !== BRIGHTSIGN_TCP_DRIVER) {
26317
26318
  return false;
26318
26319
  }
26320
+ if (unloading) {
26321
+ console.error("BrightSign backend cannot initialize during unload");
26322
+ return false;
26323
+ }
26319
26324
  let streamProtocol;
26320
26325
  try {
26321
26326
  streamProtocol = resolvePlaybackProtocol(options.streamProtocol);
@@ -26392,12 +26397,17 @@
26392
26397
  ...geometry,
26393
26398
  streamProtocol
26394
26399
  });
26395
- if (window.brightSignTCP !== tcp || window.brightSignDecoder || ownedDecoder !== decoder) {
26400
+ if (unloading || window.brightSignTCP !== tcp || window.brightSignDecoder || ownedDecoder !== decoder) {
26396
26401
  throw new Error("BrightSign backend state changed during initialization");
26397
26402
  }
26398
26403
  window.brightSignDecoder = decoder;
26399
26404
  return true;
26400
26405
  } catch (error) {
26406
+ if (unloading) {
26407
+ await teardownPromise;
26408
+ console.error("Failed to initialize BrightSign backend", error);
26409
+ return false;
26410
+ }
26401
26411
  if (window.brightSignDecoder === decoder) {
26402
26412
  window.brightSignDecoder = void 0;
26403
26413
  }
@@ -26412,12 +26422,14 @@
26412
26422
  if (destroyTCP) {
26413
26423
  ownedTCP = void 0;
26414
26424
  }
26415
- await destroyAfterInitializationFailure(destroyDecoder, "decoder", () => {
26416
- ownedDecoder = destroyDecoder;
26417
- });
26418
- await destroyAfterInitializationFailure(destroyTCP, "transport", () => {
26419
- ownedTCP = destroyTCP;
26420
- });
26425
+ await Promise.all([
26426
+ destroyAfterInitializationFailure(destroyDecoder, "decoder", () => {
26427
+ ownedDecoder = destroyDecoder;
26428
+ }),
26429
+ destroyAfterInitializationFailure(destroyTCP, "transport", () => {
26430
+ ownedTCP = destroyTCP;
26431
+ })
26432
+ ]);
26421
26433
  console.error("Failed to initialize BrightSign backend", error);
26422
26434
  return false;
26423
26435
  }
@@ -26439,9 +26451,48 @@
26439
26451
  await resource.destroy(context);
26440
26452
  } catch (retryError) {
26441
26453
  console.error(`Failed to clean up BrightSign ${resourceName} during unload`, retryError);
26454
+ restoreOwnership();
26442
26455
  }
26443
26456
  }
26444
26457
  }
26458
+ async function destroyOwnedResources() {
26459
+ const context = { deadlineMs: 1e3 };
26460
+ const decoder = ownedDecoder;
26461
+ const destroyDecoder = async () => {
26462
+ if (!decoder) {
26463
+ return;
26464
+ }
26465
+ try {
26466
+ await decoder.destroy(context);
26467
+ if (ownedDecoder === decoder) {
26468
+ ownedDecoder = void 0;
26469
+ }
26470
+ if (window.brightSignDecoder === decoder) {
26471
+ window.brightSignDecoder = void 0;
26472
+ }
26473
+ } catch (error) {
26474
+ console.error("Failed to destroy BrightSign decoder", error);
26475
+ }
26476
+ };
26477
+ const tcp = ownedTCP;
26478
+ const destroyTCP = async () => {
26479
+ if (!tcp) {
26480
+ return;
26481
+ }
26482
+ try {
26483
+ await tcp.destroy(context);
26484
+ if (ownedTCP === tcp) {
26485
+ ownedTCP = void 0;
26486
+ }
26487
+ if (window.brightSignTCP === tcp) {
26488
+ window.brightSignTCP = void 0;
26489
+ }
26490
+ } catch (error) {
26491
+ console.error("Failed to destroy BrightSign transport", error);
26492
+ }
26493
+ };
26494
+ await Promise.all([destroyDecoder(), destroyTCP()]);
26495
+ }
26445
26496
  function registerTeardown() {
26446
26497
  if (teardownRegistered) {
26447
26498
  return;
@@ -26449,23 +26500,11 @@
26449
26500
  teardownRegistered = true;
26450
26501
  window.addEventListener("unload", () => {
26451
26502
  unloading = true;
26452
- const decoder = ownedDecoder;
26453
- const tcp = ownedTCP;
26454
- const context = { deadlineMs: 1e3 };
26455
- if (window.brightSignDecoder === decoder) {
26456
- window.brightSignDecoder = void 0;
26457
- }
26458
- if (window.brightSignTCP === tcp) {
26459
- window.brightSignTCP = void 0;
26503
+ if (!teardownPromise) {
26504
+ teardownPromise = destroyOwnedResources().finally(() => {
26505
+ teardownPromise = void 0;
26506
+ });
26460
26507
  }
26461
- ownedDecoder = void 0;
26462
- ownedTCP = void 0;
26463
- void (decoder == null ? void 0 : decoder.destroy(context).catch((error) => {
26464
- console.error("Failed to destroy BrightSign decoder", error);
26465
- }));
26466
- void (tcp == null ? void 0 : tcp.destroy(context).catch((error) => {
26467
- console.error("Failed to destroy BrightSign transport", error);
26468
- }));
26469
26508
  });
26470
26509
  }
26471
26510
 
@@ -26904,7 +26943,7 @@ self.onmessage = function(event) {
26904
26943
  }
26905
26944
 
26906
26945
  // screen/plain.ts
26907
- var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.490";
26946
+ var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.491";
26908
26947
  async function startPlainScreen(options) {
26909
26948
  var _a, _b, _c;
26910
26949
  console.log("[Supra screen plain] initialization begin");
@@ -26958,7 +26997,7 @@ self.onmessage = function(event) {
26958
26997
  }
26959
26998
 
26960
26999
  // screen/h264decoder.ts
26961
- var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.490";
27000
+ var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.491";
26962
27001
  async function initH264Decoder() {
26963
27002
  if (window.VideoDecoder !== void 0) {
26964
27003
  return void 0;
@@ -26997,7 +27036,7 @@ self.onmessage = function(event) {
26997
27036
  }
26998
27037
 
26999
27038
  // screen/wasm.ts
27000
- var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.490";
27039
+ var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.491";
27001
27040
  async function initializePhase(name, initialize) {
27002
27041
  const startedAt = Date.now();
27003
27042
  console.log(`[Supra screen WASM] ${name} begin`);