@supraio/client-daemon-js 1.0.0-mzbrightsigndecoder.480 → 1.0.0-mzbrightsigndecoder.482

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.480",
3
+ "version": "1.0.0-mzbrightsigndecoder.482",
4
4
  "description": "",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
@@ -5,8 +5,17 @@ declare global {
5
5
  brightSignDecoder?: H264Decoder;
6
6
  brightSignTCP?: TCPCommunication;
7
7
  brightSignReleaseFrameReference?: (reference: FrameReference) => void;
8
+ __supraNativeState?: BrightSignNativeState;
8
9
  }
9
10
  }
11
+ interface BrightSignNativeState {
12
+ tcp: string;
13
+ decoder: string;
14
+ lastEvent: string;
15
+ lastError: string;
16
+ unloadCount: number;
17
+ }
10
18
  export declare function isBrightSignRuntimeAvailable(): boolean;
11
19
  export declare function initBrightSignTCP(): boolean;
12
20
  export declare function initBrightSignDecoder(options: IScreenOptions): Promise<boolean>;
21
+ export {};
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.480"></script>
8
+ <script type="text/javascript" src="screen.js?v=1.0.0-mzbrightsigndecoder.482"></script>
9
9
  </body>
10
10
  </html>
package/screen.js CHANGED
@@ -24752,19 +24752,27 @@
24752
24752
  function initBrightSignTCP() {
24753
24753
  registerStreamErrorListener();
24754
24754
  if (window.brightSignTCP) {
24755
+ updateNativeState({ lastEvent: "tcp-reused" });
24755
24756
  console.log("BrightSign TCP already initialized");
24756
24757
  return true;
24757
24758
  }
24758
24759
  try {
24760
+ updateNativeState({ lastEvent: "tcp-init-begin", tcp: "initializing" });
24759
24761
  const registry = getReferenceRegistry();
24760
24762
  window.brightSignTCP = (0, import_brightsign_decoder.createBrightSignTCP)({
24761
24763
  refRegistry: registry,
24762
24764
  maxPacketSize: 65535
24763
24765
  });
24764
24766
  registerTeardown();
24767
+ updateNativeState({ lastEvent: "tcp-init-complete", tcp: "ready" });
24765
24768
  console.log("BrightSign TCP initialized");
24766
24769
  return true;
24767
24770
  } catch (error) {
24771
+ updateNativeState({
24772
+ lastEvent: "tcp-init-failed",
24773
+ tcp: "failed",
24774
+ lastError: describeError(error)
24775
+ });
24768
24776
  console.log("BrightSign TCP is not available", error);
24769
24777
  return false;
24770
24778
  }
@@ -24772,10 +24780,15 @@
24772
24780
  async function initBrightSignDecoder(options) {
24773
24781
  var _a, _b, _c;
24774
24782
  if (window.brightSignDecoder) {
24783
+ updateNativeState({ lastEvent: "decoder-reused" });
24775
24784
  console.log("BrightSign decoder already initialized");
24776
24785
  return true;
24777
24786
  }
24778
24787
  const runtimeAvailable = (0, import_brightsign_decoder.isBrightSignDecoderSupported)();
24788
+ updateNativeState({
24789
+ lastEvent: "decoder-runtime-check",
24790
+ decoder: runtimeAvailable ? "available" : "unsupported"
24791
+ });
24779
24792
  console.log("BrightSign decoder runtime availability", runtimeAvailable);
24780
24793
  if (!runtimeAvailable) {
24781
24794
  return false;
@@ -24792,6 +24805,7 @@
24792
24805
  streamProtocol: (_b = options.brightSignDecoderStreamProtocol) != null ? _b : "default",
24793
24806
  streamOptions: (_c = options.brightSignStreamOptions) != null ? _c : null
24794
24807
  });
24808
+ updateNativeState({ lastEvent: "decoder-init-begin", decoder: "initializing" });
24795
24809
  const decoder = (0, import_brightsign_decoder.createBrightSignDecoder)({
24796
24810
  refRegistry: getReferenceRegistry()
24797
24811
  });
@@ -24802,9 +24816,15 @@
24802
24816
  });
24803
24817
  window.brightSignDecoder = decoder;
24804
24818
  registerTeardown();
24819
+ updateNativeState({ lastEvent: "decoder-init-complete", decoder: "ready" });
24805
24820
  console.log("BrightSign decoder initialization complete");
24806
24821
  return true;
24807
24822
  } catch (error) {
24823
+ updateNativeState({
24824
+ lastEvent: "decoder-init-failed",
24825
+ decoder: "failed",
24826
+ lastError: describeError(error)
24827
+ });
24808
24828
  console.error("Failed to initialize BrightSign decoder", error);
24809
24829
  return false;
24810
24830
  }
@@ -24826,9 +24846,16 @@
24826
24846
  return;
24827
24847
  }
24828
24848
  Reflect.apply(onError, stream, [
24829
- (event) => console.error("BrightSign native stream error", event)
24849
+ (event) => {
24850
+ updateNativeState({
24851
+ lastEvent: "stream-error",
24852
+ lastError: describeError(event)
24853
+ });
24854
+ console.error("BrightSign native stream error", event);
24855
+ }
24830
24856
  ]);
24831
24857
  streamErrorListenerRegistered = true;
24858
+ updateNativeState({ lastEvent: "stream-error-listener-registered" });
24832
24859
  console.log("BrightSign native stream error listener registered");
24833
24860
  }
24834
24861
  function getReferenceRegistry() {
@@ -24846,16 +24873,70 @@
24846
24873
  }
24847
24874
  teardownRegistered = true;
24848
24875
  window.addEventListener("unload", () => {
24876
+ const nativeState = ensureNativeState();
24877
+ nativeState.unloadCount += 1;
24878
+ updateNativeState({
24879
+ lastEvent: "unload-begin",
24880
+ decoder: window.brightSignDecoder ? "destroying" : "missing",
24881
+ tcp: window.brightSignTCP ? "destroying" : "missing"
24882
+ });
24849
24883
  console.log("BrightSign teardown begin");
24850
24884
  const decoder = window.brightSignDecoder;
24851
24885
  const tcp = window.brightSignTCP;
24852
24886
  window.brightSignDecoder = void 0;
24853
24887
  window.brightSignTCP = void 0;
24854
- void (decoder == null ? void 0 : decoder.destroy());
24855
- void (tcp == null ? void 0 : tcp.destroy());
24888
+ void (decoder == null ? void 0 : decoder.destroy().then(() => {
24889
+ updateNativeState({ lastEvent: "decoder-destroyed", decoder: "destroyed" });
24890
+ }).catch((error) => {
24891
+ updateNativeState({
24892
+ lastEvent: "decoder-destroy-failed",
24893
+ decoder: "destroy-failed",
24894
+ lastError: describeError(error)
24895
+ });
24896
+ }));
24897
+ void (tcp == null ? void 0 : tcp.destroy().then(() => {
24898
+ updateNativeState({ lastEvent: "tcp-destroyed", tcp: "destroyed" });
24899
+ }).catch((error) => {
24900
+ updateNativeState({
24901
+ lastEvent: "tcp-destroy-failed",
24902
+ tcp: "destroy-failed",
24903
+ lastError: describeError(error)
24904
+ });
24905
+ }));
24906
+ updateNativeState({ lastEvent: "unload-dispatched" });
24856
24907
  console.log("BrightSign teardown dispatched");
24857
24908
  });
24858
24909
  }
24910
+ function ensureNativeState() {
24911
+ if (window.__supraNativeState) {
24912
+ return window.__supraNativeState;
24913
+ }
24914
+ const state = {
24915
+ tcp: "missing",
24916
+ decoder: "missing",
24917
+ lastEvent: "init",
24918
+ lastError: "",
24919
+ unloadCount: 0
24920
+ };
24921
+ window.__supraNativeState = state;
24922
+ return state;
24923
+ }
24924
+ function updateNativeState(partialState) {
24925
+ Object.assign(ensureNativeState(), partialState);
24926
+ }
24927
+ function describeError(value) {
24928
+ if (value instanceof Error) {
24929
+ return value.message;
24930
+ }
24931
+ if (typeof value === "string") {
24932
+ return value;
24933
+ }
24934
+ try {
24935
+ return JSON.stringify(value);
24936
+ } catch {
24937
+ return String(value);
24938
+ }
24939
+ }
24859
24940
 
24860
24941
  // screen/nacltcp.ts
24861
24942
  var import_nacl_decoder = __toESM(require_dist2());
@@ -25289,7 +25370,7 @@ self.onmessage = function(event) {
25289
25370
  }
25290
25371
 
25291
25372
  // screen/plain.ts
25292
- var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.480";
25373
+ var SCREEN_JS_URL = "supra-client-screen.js?v=1.0.0-mzbrightsigndecoder.482";
25293
25374
  async function startPlainScreen(options) {
25294
25375
  var _a, _b, _c, _d;
25295
25376
  console.log("[Supra screen plain] initialization begin");
@@ -25351,7 +25432,7 @@ self.onmessage = function(event) {
25351
25432
  }
25352
25433
 
25353
25434
  // screen/h264decoder.ts
25354
- var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.480";
25435
+ var H264_DECODER_URL = "h264decoder.js?v=1.0.0-mzbrightsigndecoder.482";
25355
25436
  async function initH264Decoder() {
25356
25437
  if (window.VideoDecoder !== void 0) {
25357
25438
  return void 0;
@@ -25390,7 +25471,7 @@ self.onmessage = function(event) {
25390
25471
  }
25391
25472
 
25392
25473
  // screen/wasm.ts
25393
- var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.480";
25474
+ var SCREEN_WASM_URL = "supra-client-screen.wasm?v=1.0.0-mzbrightsigndecoder.482";
25394
25475
  async function initializePhase(name, initialize) {
25395
25476
  const startedAt = Date.now();
25396
25477
  console.log(`[Supra screen WASM] ${name} begin`);