@supraio/client-daemon-js 1.0.0-mzbrightsigndecoder.489 → 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 +1 -1
- package/daemon.js +52 -14
- package/daemon.js.map +2 -2
- package/package.json +1 -1
- package/screen/options.d.ts +1 -0
- package/screen.html +1 -1
- package/screen.js +183 -20
- package/screen.js.map +2 -2
- package/sdk.js +185 -22
- package/sdk.js.map +2 -2
- package/supra-client-daemon.js +8664 -8667
- package/supra-client-daemon.js.map +1 -1
- package/supra-client-daemon.wasm +0 -0
- package/supra-client-screen.js +11967 -11981
- package/supra-client-screen.js.map +1 -1
- package/supra-client-screen.wasm +0 -0
package/package.json
CHANGED
package/screen/options.d.ts
CHANGED
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.
|
|
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
|
@@ -26280,6 +26280,22 @@
|
|
|
26280
26280
|
var import_brightsign_decoder = __toESM(require_dist());
|
|
26281
26281
|
var BRIGHTSIGN_TCP_DRIVER = "brightsign_tcp";
|
|
26282
26282
|
var teardownRegistered = false;
|
|
26283
|
+
var backendInitialization;
|
|
26284
|
+
var ownedDecoder;
|
|
26285
|
+
var ownedTCP;
|
|
26286
|
+
var unloading = false;
|
|
26287
|
+
var teardownPromise;
|
|
26288
|
+
function resolvePlaybackProtocol(streamProtocol) {
|
|
26289
|
+
switch (streamProtocol) {
|
|
26290
|
+
case void 0:
|
|
26291
|
+
case "udp":
|
|
26292
|
+
return "udp";
|
|
26293
|
+
case "http":
|
|
26294
|
+
return "http";
|
|
26295
|
+
default:
|
|
26296
|
+
throw new RangeError(`Unsupported BrightSign playback protocol: ${streamProtocol}`);
|
|
26297
|
+
}
|
|
26298
|
+
}
|
|
26283
26299
|
function isBrightSignRuntimeAvailable() {
|
|
26284
26300
|
return (0, import_brightsign_decoder.detectCapabilities)().native;
|
|
26285
26301
|
}
|
|
@@ -26288,7 +26304,8 @@
|
|
|
26288
26304
|
return true;
|
|
26289
26305
|
}
|
|
26290
26306
|
try {
|
|
26291
|
-
|
|
26307
|
+
ownedTCP = (0, import_brightsign_decoder.createBrightSignTCP)();
|
|
26308
|
+
window.brightSignTCP = ownedTCP;
|
|
26292
26309
|
registerTeardown();
|
|
26293
26310
|
return true;
|
|
26294
26311
|
} catch (error) {
|
|
@@ -26297,16 +26314,64 @@
|
|
|
26297
26314
|
}
|
|
26298
26315
|
}
|
|
26299
26316
|
async function initBrightSignBackend(options) {
|
|
26300
|
-
var _a;
|
|
26301
26317
|
if (options.screenDriver !== BRIGHTSIGN_TCP_DRIVER) {
|
|
26302
26318
|
return false;
|
|
26303
26319
|
}
|
|
26320
|
+
if (unloading) {
|
|
26321
|
+
console.error("BrightSign backend cannot initialize during unload");
|
|
26322
|
+
return false;
|
|
26323
|
+
}
|
|
26324
|
+
let streamProtocol;
|
|
26325
|
+
try {
|
|
26326
|
+
streamProtocol = resolvePlaybackProtocol(options.streamProtocol);
|
|
26327
|
+
} catch (error) {
|
|
26328
|
+
console.error("Failed to initialize BrightSign backend", error);
|
|
26329
|
+
return false;
|
|
26330
|
+
}
|
|
26331
|
+
if (backendInitialization) {
|
|
26332
|
+
if (backendInitialization.protocol !== streamProtocol) {
|
|
26333
|
+
console.error(`BrightSign backend is already initializing with protocol ${backendInitialization.protocol}`);
|
|
26334
|
+
return false;
|
|
26335
|
+
}
|
|
26336
|
+
return backendInitialization.promise;
|
|
26337
|
+
}
|
|
26338
|
+
if (ownedTCP && window.brightSignTCP !== ownedTCP || ownedDecoder && window.brightSignDecoder !== ownedDecoder) {
|
|
26339
|
+
console.error("BrightSign backend resources owned by the adapter were externally replaced");
|
|
26340
|
+
return false;
|
|
26341
|
+
}
|
|
26304
26342
|
if (window.brightSignTCP && window.brightSignDecoder) {
|
|
26343
|
+
let existingProtocol;
|
|
26344
|
+
try {
|
|
26345
|
+
existingProtocol = window.brightSignDecoder.getDiagnostics().protocol;
|
|
26346
|
+
} catch (error) {
|
|
26347
|
+
console.error("Failed to inspect existing BrightSign backend", error);
|
|
26348
|
+
return false;
|
|
26349
|
+
}
|
|
26350
|
+
if (existingProtocol !== streamProtocol) {
|
|
26351
|
+
console.error(`BrightSign backend is already initialized with protocol ${existingProtocol}`);
|
|
26352
|
+
return false;
|
|
26353
|
+
}
|
|
26305
26354
|
return true;
|
|
26306
26355
|
}
|
|
26356
|
+
if (window.brightSignDecoder) {
|
|
26357
|
+
console.error("BrightSign decoder exists without its transport");
|
|
26358
|
+
return false;
|
|
26359
|
+
}
|
|
26307
26360
|
if (!isBrightSignRuntimeAvailable()) {
|
|
26308
26361
|
return false;
|
|
26309
26362
|
}
|
|
26363
|
+
const promise = initializeBrightSignBackend(options, streamProtocol);
|
|
26364
|
+
backendInitialization = { protocol: streamProtocol, promise };
|
|
26365
|
+
try {
|
|
26366
|
+
return await promise;
|
|
26367
|
+
} finally {
|
|
26368
|
+
backendInitialization = void 0;
|
|
26369
|
+
}
|
|
26370
|
+
}
|
|
26371
|
+
async function initializeBrightSignBackend(options, streamProtocol) {
|
|
26372
|
+
var _a;
|
|
26373
|
+
let decoder;
|
|
26374
|
+
let createdTCP;
|
|
26310
26375
|
try {
|
|
26311
26376
|
const geometry = (_a = options.geometry) != null ? _a : {
|
|
26312
26377
|
x: 0,
|
|
@@ -26314,37 +26379,132 @@
|
|
|
26314
26379
|
width: window.innerWidth,
|
|
26315
26380
|
height: window.innerHeight
|
|
26316
26381
|
};
|
|
26382
|
+
const existingTCP = window.brightSignTCP;
|
|
26317
26383
|
if (!initBrightSignTCP()) {
|
|
26318
26384
|
return false;
|
|
26319
26385
|
}
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26386
|
+
if (!existingTCP) {
|
|
26387
|
+
createdTCP = window.brightSignTCP;
|
|
26388
|
+
}
|
|
26389
|
+
const tcp = window.brightSignTCP;
|
|
26390
|
+
if (!tcp) {
|
|
26391
|
+
throw new Error("BrightSign transport was not created");
|
|
26392
|
+
}
|
|
26393
|
+
decoder = (0, import_brightsign_decoder.createBrightSignDecoder)();
|
|
26394
|
+
ownedDecoder = decoder;
|
|
26323
26395
|
registerTeardown();
|
|
26396
|
+
await decoder.initialize({
|
|
26397
|
+
...geometry,
|
|
26398
|
+
streamProtocol
|
|
26399
|
+
});
|
|
26400
|
+
if (unloading || window.brightSignTCP !== tcp || window.brightSignDecoder || ownedDecoder !== decoder) {
|
|
26401
|
+
throw new Error("BrightSign backend state changed during initialization");
|
|
26402
|
+
}
|
|
26403
|
+
window.brightSignDecoder = decoder;
|
|
26324
26404
|
return true;
|
|
26325
26405
|
} catch (error) {
|
|
26326
|
-
|
|
26406
|
+
if (unloading) {
|
|
26407
|
+
await teardownPromise;
|
|
26408
|
+
console.error("Failed to initialize BrightSign backend", error);
|
|
26409
|
+
return false;
|
|
26410
|
+
}
|
|
26411
|
+
if (window.brightSignDecoder === decoder) {
|
|
26412
|
+
window.brightSignDecoder = void 0;
|
|
26413
|
+
}
|
|
26414
|
+
if (createdTCP && window.brightSignTCP === createdTCP) {
|
|
26415
|
+
window.brightSignTCP = void 0;
|
|
26416
|
+
}
|
|
26417
|
+
const destroyDecoder = ownedDecoder === decoder ? decoder : void 0;
|
|
26418
|
+
const destroyTCP = ownedTCP === createdTCP ? createdTCP : void 0;
|
|
26419
|
+
if (destroyDecoder) {
|
|
26420
|
+
ownedDecoder = void 0;
|
|
26421
|
+
}
|
|
26422
|
+
if (destroyTCP) {
|
|
26423
|
+
ownedTCP = void 0;
|
|
26424
|
+
}
|
|
26425
|
+
await Promise.all([
|
|
26426
|
+
destroyAfterInitializationFailure(destroyDecoder, "decoder", () => {
|
|
26427
|
+
ownedDecoder = destroyDecoder;
|
|
26428
|
+
}),
|
|
26429
|
+
destroyAfterInitializationFailure(destroyTCP, "transport", () => {
|
|
26430
|
+
ownedTCP = destroyTCP;
|
|
26431
|
+
})
|
|
26432
|
+
]);
|
|
26327
26433
|
console.error("Failed to initialize BrightSign backend", error);
|
|
26328
26434
|
return false;
|
|
26329
26435
|
}
|
|
26330
26436
|
}
|
|
26437
|
+
async function destroyAfterInitializationFailure(resource, resourceName, restoreOwnership) {
|
|
26438
|
+
if (!resource) {
|
|
26439
|
+
return;
|
|
26440
|
+
}
|
|
26441
|
+
const context = { deadlineMs: 1e3 };
|
|
26442
|
+
try {
|
|
26443
|
+
await resource.destroy(context);
|
|
26444
|
+
} catch (cleanupError) {
|
|
26445
|
+
console.error(`Failed to clean up BrightSign ${resourceName} after initialization failure`, cleanupError);
|
|
26446
|
+
if (!unloading) {
|
|
26447
|
+
restoreOwnership();
|
|
26448
|
+
return;
|
|
26449
|
+
}
|
|
26450
|
+
try {
|
|
26451
|
+
await resource.destroy(context);
|
|
26452
|
+
} catch (retryError) {
|
|
26453
|
+
console.error(`Failed to clean up BrightSign ${resourceName} during unload`, retryError);
|
|
26454
|
+
restoreOwnership();
|
|
26455
|
+
}
|
|
26456
|
+
}
|
|
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
|
+
}
|
|
26331
26496
|
function registerTeardown() {
|
|
26332
26497
|
if (teardownRegistered) {
|
|
26333
26498
|
return;
|
|
26334
26499
|
}
|
|
26335
26500
|
teardownRegistered = true;
|
|
26336
26501
|
window.addEventListener("unload", () => {
|
|
26337
|
-
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26341
|
-
|
|
26342
|
-
|
|
26343
|
-
console.error("Failed to destroy BrightSign decoder", error);
|
|
26344
|
-
}));
|
|
26345
|
-
void (tcp == null ? void 0 : tcp.destroy(context).catch((error) => {
|
|
26346
|
-
console.error("Failed to destroy BrightSign transport", error);
|
|
26347
|
-
}));
|
|
26502
|
+
unloading = true;
|
|
26503
|
+
if (!teardownPromise) {
|
|
26504
|
+
teardownPromise = destroyOwnedResources().finally(() => {
|
|
26505
|
+
teardownPromise = void 0;
|
|
26506
|
+
});
|
|
26507
|
+
}
|
|
26348
26508
|
});
|
|
26349
26509
|
}
|
|
26350
26510
|
|
|
@@ -26713,6 +26873,9 @@ self.onmessage = function(event) {
|
|
|
26713
26873
|
interactive: params.interactive === "true",
|
|
26714
26874
|
netInWorker: params.netInWorker === "true"
|
|
26715
26875
|
};
|
|
26876
|
+
if (typeof params.streamProtocol === "string") {
|
|
26877
|
+
options.streamProtocol = params.streamProtocol;
|
|
26878
|
+
}
|
|
26716
26879
|
if (typeof params.forceScreenSize === "string") {
|
|
26717
26880
|
const sizeParts = params.forceScreenSize.split("x");
|
|
26718
26881
|
if (sizeParts.length !== 2) {
|
|
@@ -26780,7 +26943,7 @@ self.onmessage = function(event) {
|
|
|
26780
26943
|
}
|
|
26781
26944
|
|
|
26782
26945
|
// screen/plain.ts
|
|
26783
|
-
var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.
|
|
26946
|
+
var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.491";
|
|
26784
26947
|
async function startPlainScreen(options) {
|
|
26785
26948
|
var _a, _b, _c;
|
|
26786
26949
|
console.log("[Supra screen plain] initialization begin");
|
|
@@ -26834,7 +26997,7 @@ self.onmessage = function(event) {
|
|
|
26834
26997
|
}
|
|
26835
26998
|
|
|
26836
26999
|
// screen/h264decoder.ts
|
|
26837
|
-
var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.
|
|
27000
|
+
var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.491";
|
|
26838
27001
|
async function initH264Decoder() {
|
|
26839
27002
|
if (window.VideoDecoder !== void 0) {
|
|
26840
27003
|
return void 0;
|
|
@@ -26873,7 +27036,7 @@ self.onmessage = function(event) {
|
|
|
26873
27036
|
}
|
|
26874
27037
|
|
|
26875
27038
|
// screen/wasm.ts
|
|
26876
|
-
var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.
|
|
27039
|
+
var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.491";
|
|
26877
27040
|
async function initializePhase(name, initialize) {
|
|
26878
27041
|
const startedAt = Date.now();
|
|
26879
27042
|
console.log(`[Supra screen WASM] ${name} begin`);
|