@supraio/client-daemon-js 0.0.0-jvmaster.366-jvmaster.392 → 0.0.0-jvmaster.366-jvdevelop.396

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=0.0.0-jvmaster.366-jvmaster.392"></script>
7
+ <script type="text/javascript" src="daemon.js?v=0.0.0-jvmaster.366-jvdevelop.396"></script>
8
8
  </body>
9
9
  </html>
package/daemon.js CHANGED
@@ -17585,6 +17585,387 @@
17585
17585
  }
17586
17586
  });
17587
17587
 
17588
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js
17589
+ var require_videoDecoder2 = __commonJS({
17590
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js"(exports) {
17591
+ "use strict";
17592
+ Object.defineProperty(exports, "__esModule", { value: true });
17593
+ exports.ResultStatus = void 0;
17594
+ var ResultStatus;
17595
+ (function(ResultStatus2) {
17596
+ ResultStatus2[ResultStatus2["Ok"] = 0] = "Ok";
17597
+ ResultStatus2[ResultStatus2["ErrorFailed"] = -2] = "ErrorFailed";
17598
+ ResultStatus2[ResultStatus2["ErrorBadArgument"] = -4] = "ErrorBadArgument";
17599
+ ResultStatus2[ResultStatus2["ErrorNoInit"] = -6] = "ErrorNoInit";
17600
+ })(ResultStatus || (exports.ResultStatus = ResultStatus = {}));
17601
+ }
17602
+ });
17603
+
17604
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js
17605
+ var require_wasmDecoder = __commonJS({
17606
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js"(exports) {
17607
+ "use strict";
17608
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
17609
+ function adopt(value) {
17610
+ return value instanceof P ? value : new P(function(resolve) {
17611
+ resolve(value);
17612
+ });
17613
+ }
17614
+ return new (P || (P = Promise))(function(resolve, reject) {
17615
+ function fulfilled(value) {
17616
+ try {
17617
+ step(generator.next(value));
17618
+ } catch (e) {
17619
+ reject(e);
17620
+ }
17621
+ }
17622
+ function rejected(value) {
17623
+ try {
17624
+ step(generator["throw"](value));
17625
+ } catch (e) {
17626
+ reject(e);
17627
+ }
17628
+ }
17629
+ function step(result) {
17630
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
17631
+ }
17632
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17633
+ });
17634
+ };
17635
+ var __generator = exports && exports.__generator || function(thisArg, body) {
17636
+ var _ = { label: 0, sent: function() {
17637
+ if (t[0] & 1) throw t[1];
17638
+ return t[1];
17639
+ }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
17640
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
17641
+ return this;
17642
+ }), g;
17643
+ function verb(n) {
17644
+ return function(v) {
17645
+ return step([n, v]);
17646
+ };
17647
+ }
17648
+ function step(op) {
17649
+ if (f) throw new TypeError("Generator is already executing.");
17650
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17651
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
17652
+ if (y = 0, t) op = [op[0] & 2, t.value];
17653
+ switch (op[0]) {
17654
+ case 0:
17655
+ case 1:
17656
+ t = op;
17657
+ break;
17658
+ case 4:
17659
+ _.label++;
17660
+ return { value: op[1], done: false };
17661
+ case 5:
17662
+ _.label++;
17663
+ y = op[1];
17664
+ op = [0];
17665
+ continue;
17666
+ case 7:
17667
+ op = _.ops.pop();
17668
+ _.trys.pop();
17669
+ continue;
17670
+ default:
17671
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
17672
+ _ = 0;
17673
+ continue;
17674
+ }
17675
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
17676
+ _.label = op[1];
17677
+ break;
17678
+ }
17679
+ if (op[0] === 6 && _.label < t[1]) {
17680
+ _.label = t[1];
17681
+ t = op;
17682
+ break;
17683
+ }
17684
+ if (t && _.label < t[2]) {
17685
+ _.label = t[2];
17686
+ _.ops.push(op);
17687
+ break;
17688
+ }
17689
+ if (t[2]) _.ops.pop();
17690
+ _.trys.pop();
17691
+ continue;
17692
+ }
17693
+ op = body.call(thisArg, _);
17694
+ } catch (e) {
17695
+ op = [6, e];
17696
+ y = 0;
17697
+ } finally {
17698
+ f = t = 0;
17699
+ }
17700
+ if (op[0] & 5) throw op[1];
17701
+ return { value: op[0] ? op[1] : void 0, done: true };
17702
+ }
17703
+ };
17704
+ Object.defineProperty(exports, "__esModule", { value: true });
17705
+ exports.SamsungWasmDecoder = void 0;
17706
+ var videoDecoder_1 = require_videoDecoder2();
17707
+ function detectKeyFrameAnnexB(bytes) {
17708
+ if (bytes.length === 0)
17709
+ return false;
17710
+ var nalHeaderIndex = 0;
17711
+ if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 1) {
17712
+ nalHeaderIndex = 4;
17713
+ } else if (bytes.length >= 3 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 1) {
17714
+ nalHeaderIndex = 3;
17715
+ }
17716
+ if (nalHeaderIndex >= bytes.length)
17717
+ return false;
17718
+ var nalType = bytes[nalHeaderIndex] & 31;
17719
+ if (nalType === 5 || nalType === 7 || nalType === 8)
17720
+ return true;
17721
+ for (var i = nalHeaderIndex + 1; i + 4 < bytes.length; i++) {
17722
+ var is3 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 1;
17723
+ var is4 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 0 && bytes[i + 3] === 1;
17724
+ if (!is3 && !is4)
17725
+ continue;
17726
+ var idx = i + (is3 ? 3 : 4);
17727
+ if (idx >= bytes.length)
17728
+ return false;
17729
+ var nt = bytes[idx] & 31;
17730
+ if (nt === 5 || nt === 7 || nt === 8)
17731
+ return true;
17732
+ }
17733
+ return false;
17734
+ }
17735
+ function ensureVideoElement(videoElementId) {
17736
+ var el = document.getElementById(videoElementId);
17737
+ if (!el) {
17738
+ el = document.createElement("video");
17739
+ el.id = videoElementId;
17740
+ el.style.position = "absolute";
17741
+ el.style.top = "0";
17742
+ el.style.left = "0";
17743
+ el.style.width = "1920px";
17744
+ el.style.height = "1080px";
17745
+ el.style.backgroundColor = "#000";
17746
+ document.body.appendChild(el);
17747
+ }
17748
+ el.autoplay = true;
17749
+ el.muted = true;
17750
+ el.playsInline = true;
17751
+ return el;
17752
+ }
17753
+ var SamsungWasmDecoder2 = (
17754
+ /** @class */
17755
+ function() {
17756
+ function SamsungWasmDecoder3(videoElementId) {
17757
+ this.videoElementId = videoElementId;
17758
+ this.initialized = false;
17759
+ this.destroyed = false;
17760
+ this.native = null;
17761
+ this.decoderHandle = 0;
17762
+ this.ptsSeconds = 0;
17763
+ this.frameDurationSeconds = 1 / 60;
17764
+ this.videoElement = ensureVideoElement(videoElementId);
17765
+ }
17766
+ SamsungWasmDecoder3.prototype.destroy = function() {
17767
+ return __awaiter(this, void 0, void 0, function() {
17768
+ var _a, _b;
17769
+ return __generator(this, function(_c) {
17770
+ if (this.destroyed)
17771
+ return [
17772
+ 2
17773
+ /*return*/
17774
+ ];
17775
+ this.destroyed = true;
17776
+ try {
17777
+ (_b = (_a = this.native) === null || _a === void 0 ? void 0 : _a.ccall) === null || _b === void 0 ? void 0 : _b.call(_a, "swd_destroy", "void", ["number"], [this.decoderHandle]);
17778
+ } catch (_d) {
17779
+ }
17780
+ this.decoderHandle = 0;
17781
+ this.native = null;
17782
+ return [
17783
+ 2
17784
+ /*return*/
17785
+ ];
17786
+ });
17787
+ });
17788
+ };
17789
+ SamsungWasmDecoder3.prototype.initialize = function(args) {
17790
+ return __awaiter(this, void 0, void 0, function() {
17791
+ var width, height, mod, create, init, fpsNum, fpsDen, ok, isReady, maxWaitMs, pollIntervalMs, waited;
17792
+ var _a, _b, _c;
17793
+ return __generator(this, function(_d) {
17794
+ switch (_d.label) {
17795
+ case 0:
17796
+ if (this.destroyed) {
17797
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17798
+ }
17799
+ width = (_a = args.width) !== null && _a !== void 0 ? _a : window.screen.width;
17800
+ height = (_b = args.height) !== null && _b !== void 0 ? _b : window.screen.height;
17801
+ this.videoElement.width = width;
17802
+ this.videoElement.height = height;
17803
+ mod = (_c = window.SamsungWasmDecoderModule) === null || _c === void 0 ? void 0 : _c.call(window);
17804
+ if (!mod) {
17805
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17806
+ }
17807
+ return [4, new Promise(function(resolve) {
17808
+ mod.onRuntimeInitialized = function() {
17809
+ return resolve(null);
17810
+ };
17811
+ })];
17812
+ case 1:
17813
+ _d.sent();
17814
+ this.native = mod;
17815
+ create = mod.cwrap("swd_create", "number", ["string"]);
17816
+ init = mod.cwrap("swd_init_h264", "number", ["number", "number", "number", "number"]);
17817
+ this.decoderHandle = create(this.videoElementId);
17818
+ if (!this.decoderHandle) {
17819
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17820
+ }
17821
+ fpsNum = 60;
17822
+ fpsDen = 1;
17823
+ this.frameDurationSeconds = fpsDen / fpsNum;
17824
+ this.ptsSeconds = 0;
17825
+ ok = init(this.decoderHandle, width, height, fpsNum, fpsDen);
17826
+ if (ok !== 0) {
17827
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17828
+ }
17829
+ isReady = mod.cwrap("swd_is_ready", "number", ["number"]);
17830
+ maxWaitMs = 5e3;
17831
+ pollIntervalMs = 50;
17832
+ waited = 0;
17833
+ _d.label = 2;
17834
+ case 2:
17835
+ if (!(isReady(this.decoderHandle) === 0 && waited < maxWaitMs)) return [3, 4];
17836
+ return [4, new Promise(function(resolve) {
17837
+ return setTimeout(resolve, pollIntervalMs);
17838
+ })];
17839
+ case 3:
17840
+ _d.sent();
17841
+ waited += pollIntervalMs;
17842
+ return [3, 2];
17843
+ case 4:
17844
+ if (isReady(this.decoderHandle) === 0) {
17845
+ console.error("Decoder track did not open in time");
17846
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17847
+ }
17848
+ this.initialized = true;
17849
+ return [2, videoDecoder_1.ResultStatus.Ok];
17850
+ }
17851
+ });
17852
+ });
17853
+ };
17854
+ SamsungWasmDecoder3.prototype.decodeAndRender = function(data) {
17855
+ return __awaiter(this, void 0, void 0, function() {
17856
+ var bytes, isKey, ptr, append, ok;
17857
+ return __generator(this, function(_a) {
17858
+ if (!this.initialized || this.destroyed || !this.native) {
17859
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17860
+ }
17861
+ if (!(data instanceof ArrayBuffer)) {
17862
+ return [2, videoDecoder_1.ResultStatus.ErrorBadArgument];
17863
+ }
17864
+ bytes = new Uint8Array(data);
17865
+ isKey = detectKeyFrameAnnexB(bytes);
17866
+ ptr = this.native._malloc(bytes.length);
17867
+ this.native.HEAPU8.set(bytes, ptr);
17868
+ try {
17869
+ append = this.native.cwrap("swd_append", "number", [
17870
+ "number",
17871
+ "number",
17872
+ "number",
17873
+ "number",
17874
+ "number",
17875
+ "number"
17876
+ ]);
17877
+ ok = append(this.decoderHandle, ptr, bytes.length, isKey ? 1 : 0, this.ptsSeconds, this.frameDurationSeconds);
17878
+ if (ok === 0) {
17879
+ this.ptsSeconds += this.frameDurationSeconds;
17880
+ return [2, videoDecoder_1.ResultStatus.Ok];
17881
+ }
17882
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17883
+ } finally {
17884
+ this.native._free(ptr);
17885
+ }
17886
+ return [
17887
+ 2
17888
+ /*return*/
17889
+ ];
17890
+ });
17891
+ });
17892
+ };
17893
+ SamsungWasmDecoder3.prototype.flush = function() {
17894
+ return __awaiter(this, void 0, void 0, function() {
17895
+ var flush;
17896
+ return __generator(this, function(_a) {
17897
+ if (!this.native || !this.decoderHandle)
17898
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17899
+ try {
17900
+ flush = this.native.cwrap("swd_flush", "number", ["number"]);
17901
+ return [2, flush(this.decoderHandle) === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17902
+ } catch (_b) {
17903
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17904
+ }
17905
+ return [
17906
+ 2
17907
+ /*return*/
17908
+ ];
17909
+ });
17910
+ });
17911
+ };
17912
+ SamsungWasmDecoder3.prototype.reset = function() {
17913
+ return __awaiter(this, void 0, void 0, function() {
17914
+ var reset, rc;
17915
+ return __generator(this, function(_a) {
17916
+ if (!this.native || !this.decoderHandle)
17917
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17918
+ try {
17919
+ reset = this.native.cwrap("swd_reset", "number", ["number"]);
17920
+ rc = reset(this.decoderHandle);
17921
+ this.ptsSeconds = 0;
17922
+ return [2, rc === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17923
+ } catch (_b) {
17924
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17925
+ }
17926
+ return [
17927
+ 2
17928
+ /*return*/
17929
+ ];
17930
+ });
17931
+ });
17932
+ };
17933
+ return SamsungWasmDecoder3;
17934
+ }()
17935
+ );
17936
+ exports.SamsungWasmDecoder = SamsungWasmDecoder2;
17937
+ }
17938
+ });
17939
+
17940
+ // node_modules/@signageos/samsung-wasm-decoder/dist/index.js
17941
+ var require_dist2 = __commonJS({
17942
+ "node_modules/@signageos/samsung-wasm-decoder/dist/index.js"(exports) {
17943
+ "use strict";
17944
+ Object.defineProperty(exports, "__esModule", { value: true });
17945
+ exports.SamsungWasmDecoder = exports.ResultStatus = void 0;
17946
+ exports.isSamsungWasmSupported = isSamsungWasmSupported2;
17947
+ exports.createSamsungWasmDecoder = createSamsungWasmDecoder2;
17948
+ var wasmDecoder_1 = require_wasmDecoder();
17949
+ Object.defineProperty(exports, "SamsungWasmDecoder", { enumerable: true, get: function() {
17950
+ return wasmDecoder_1.SamsungWasmDecoder;
17951
+ } });
17952
+ var videoDecoder_1 = require_videoDecoder2();
17953
+ Object.defineProperty(exports, "ResultStatus", { enumerable: true, get: function() {
17954
+ return videoDecoder_1.ResultStatus;
17955
+ } });
17956
+ function isSamsungWasmSupported2() {
17957
+ var _a;
17958
+ return typeof window.WebAssembly !== "undefined" && typeof ((_a = window.tizentvwasm) === null || _a === void 0 ? void 0 : _a.ElementaryMediaStreamSource) !== "undefined";
17959
+ }
17960
+ function createSamsungWasmDecoder2(options) {
17961
+ if (!isSamsungWasmSupported2()) {
17962
+ throw new Error("Samsung WASM decoder is not supported in this environment.");
17963
+ }
17964
+ return new wasmDecoder_1.SamsungWasmDecoder(options.videoElementId);
17965
+ }
17966
+ }
17967
+ });
17968
+
17588
17969
  // node_modules/querystring/decode.js
17589
17970
  var require_decode = __commonJS({
17590
17971
  "node_modules/querystring/decode.js"(exports, module) {
@@ -17913,7 +18294,7 @@
17913
18294
  }
17914
18295
 
17915
18296
  // daemon/plain.ts
17916
- var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-jvmaster.366-jvmaster.392";
18297
+ var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-jvmaster.366-jvdevelop.396";
17917
18298
  async function startPlainDaemon() {
17918
18299
  const fs = await initBrowserFS();
17919
18300
  window.fs = fs;
@@ -17924,7 +18305,7 @@
17924
18305
  }
17925
18306
 
17926
18307
  // daemon/wasm.ts
17927
- var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-jvmaster.366-jvmaster.392";
18308
+ var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-jvmaster.366-jvdevelop.396";
17928
18309
  async function startWasmDaemon() {
17929
18310
  await initGoEnvironment();
17930
18311
  await startGoDaemon();
@@ -17945,6 +18326,9 @@
17945
18326
  // screen/nacldecoder.ts
17946
18327
  var import_nacl_decoder = __toESM(require_dist());
17947
18328
 
18329
+ // screen/samsungwasmdecoder.ts
18330
+ var import_samsung_wasm_decoder = __toESM(require_dist2());
18331
+
17948
18332
  // screen/shared.ts
17949
18333
  var import_querystring = __toESM(require_querystring());
17950
18334