@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/daemon.html CHANGED
@@ -4,6 +4,6 @@
4
4
  <title>Supra daemon</title>
5
5
  </head>
6
6
  <body>
7
- <script type="text/javascript" src="daemon.js?v=1.0.0-mzbrightsigndecoder.490"></script>
7
+ <script type="text/javascript" src="daemon.js?v=1.0.0-mzbrightsigndecoder.491"></script>
8
8
  </body>
9
9
  </html>
package/daemon.js CHANGED
@@ -26282,6 +26282,7 @@
26282
26282
  var ownedDecoder;
26283
26283
  var ownedTCP;
26284
26284
  var unloading = false;
26285
+ var teardownPromise;
26285
26286
  function isBrightSignRuntimeAvailable() {
26286
26287
  return (0, import_brightsign_decoder.detectCapabilities)().native;
26287
26288
  }
@@ -26299,6 +26300,44 @@
26299
26300
  return false;
26300
26301
  }
26301
26302
  }
26303
+ async function destroyOwnedResources() {
26304
+ const context = { deadlineMs: 1e3 };
26305
+ const decoder = ownedDecoder;
26306
+ const destroyDecoder = async () => {
26307
+ if (!decoder) {
26308
+ return;
26309
+ }
26310
+ try {
26311
+ await decoder.destroy(context);
26312
+ if (ownedDecoder === decoder) {
26313
+ ownedDecoder = void 0;
26314
+ }
26315
+ if (window.brightSignDecoder === decoder) {
26316
+ window.brightSignDecoder = void 0;
26317
+ }
26318
+ } catch (error) {
26319
+ console.error("Failed to destroy BrightSign decoder", error);
26320
+ }
26321
+ };
26322
+ const tcp = ownedTCP;
26323
+ const destroyTCP = async () => {
26324
+ if (!tcp) {
26325
+ return;
26326
+ }
26327
+ try {
26328
+ await tcp.destroy(context);
26329
+ if (ownedTCP === tcp) {
26330
+ ownedTCP = void 0;
26331
+ }
26332
+ if (window.brightSignTCP === tcp) {
26333
+ window.brightSignTCP = void 0;
26334
+ }
26335
+ } catch (error) {
26336
+ console.error("Failed to destroy BrightSign transport", error);
26337
+ }
26338
+ };
26339
+ await Promise.all([destroyDecoder(), destroyTCP()]);
26340
+ }
26302
26341
  function registerTeardown() {
26303
26342
  if (teardownRegistered) {
26304
26343
  return;
@@ -26306,23 +26345,11 @@
26306
26345
  teardownRegistered = true;
26307
26346
  window.addEventListener("unload", () => {
26308
26347
  unloading = true;
26309
- const decoder = ownedDecoder;
26310
- const tcp = ownedTCP;
26311
- const context = { deadlineMs: 1e3 };
26312
- if (window.brightSignDecoder === decoder) {
26313
- window.brightSignDecoder = void 0;
26314
- }
26315
- if (window.brightSignTCP === tcp) {
26316
- window.brightSignTCP = void 0;
26348
+ if (!teardownPromise) {
26349
+ teardownPromise = destroyOwnedResources().finally(() => {
26350
+ teardownPromise = void 0;
26351
+ });
26317
26352
  }
26318
- ownedDecoder = void 0;
26319
- ownedTCP = void 0;
26320
- void (decoder == null ? void 0 : decoder.destroy(context).catch((error) => {
26321
- console.error("Failed to destroy BrightSign decoder", error);
26322
- }));
26323
- void (tcp == null ? void 0 : tcp.destroy(context).catch((error) => {
26324
- console.error("Failed to destroy BrightSign transport", error);
26325
- }));
26326
26353
  });
26327
26354
  }
26328
26355
 
@@ -26355,7 +26382,7 @@
26355
26382
  }
26356
26383
 
26357
26384
  // daemon/plain.ts
26358
- var DAEMON_JS_URL = "supra-client-daemon.js?v=1.0.0-mzbrightsigndecoder.490";
26385
+ var DAEMON_JS_URL = "supra-client-daemon.js?v=1.0.0-mzbrightsigndecoder.491";
26359
26386
  async function startPlainDaemon() {
26360
26387
  initBrightSignTCP();
26361
26388
  await initNaClTCP();
@@ -26369,7 +26396,7 @@
26369
26396
  }
26370
26397
 
26371
26398
  // daemon/wasm.ts
26372
- var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=1.0.0-mzbrightsigndecoder.490";
26399
+ var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=1.0.0-mzbrightsigndecoder.491";
26373
26400
  async function startWasmDaemon() {
26374
26401
  initBrightSignTCP();
26375
26402
  await initNaClTCP();