@supraio/client-daemon-js 0.0.0-jvmaster.371 → 0.0.0-jvtouches.393

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/sdk.js CHANGED
@@ -17592,6 +17592,387 @@ var require_dist = __commonJS({
17592
17592
  }
17593
17593
  });
17594
17594
 
17595
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js
17596
+ var require_videoDecoder2 = __commonJS({
17597
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js"(exports) {
17598
+ "use strict";
17599
+ Object.defineProperty(exports, "__esModule", { value: true });
17600
+ exports.ResultStatus = void 0;
17601
+ var ResultStatus;
17602
+ (function(ResultStatus2) {
17603
+ ResultStatus2[ResultStatus2["Ok"] = 0] = "Ok";
17604
+ ResultStatus2[ResultStatus2["ErrorFailed"] = -2] = "ErrorFailed";
17605
+ ResultStatus2[ResultStatus2["ErrorBadArgument"] = -4] = "ErrorBadArgument";
17606
+ ResultStatus2[ResultStatus2["ErrorNoInit"] = -6] = "ErrorNoInit";
17607
+ })(ResultStatus || (exports.ResultStatus = ResultStatus = {}));
17608
+ }
17609
+ });
17610
+
17611
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js
17612
+ var require_wasmDecoder = __commonJS({
17613
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js"(exports) {
17614
+ "use strict";
17615
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
17616
+ function adopt(value) {
17617
+ return value instanceof P ? value : new P(function(resolve) {
17618
+ resolve(value);
17619
+ });
17620
+ }
17621
+ return new (P || (P = Promise))(function(resolve, reject) {
17622
+ function fulfilled(value) {
17623
+ try {
17624
+ step(generator.next(value));
17625
+ } catch (e) {
17626
+ reject(e);
17627
+ }
17628
+ }
17629
+ function rejected(value) {
17630
+ try {
17631
+ step(generator["throw"](value));
17632
+ } catch (e) {
17633
+ reject(e);
17634
+ }
17635
+ }
17636
+ function step(result) {
17637
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
17638
+ }
17639
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17640
+ });
17641
+ };
17642
+ var __generator = exports && exports.__generator || function(thisArg, body) {
17643
+ var _ = { label: 0, sent: function() {
17644
+ if (t[0] & 1) throw t[1];
17645
+ return t[1];
17646
+ }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
17647
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
17648
+ return this;
17649
+ }), g;
17650
+ function verb(n) {
17651
+ return function(v) {
17652
+ return step([n, v]);
17653
+ };
17654
+ }
17655
+ function step(op) {
17656
+ if (f) throw new TypeError("Generator is already executing.");
17657
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17658
+ 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;
17659
+ if (y = 0, t) op = [op[0] & 2, t.value];
17660
+ switch (op[0]) {
17661
+ case 0:
17662
+ case 1:
17663
+ t = op;
17664
+ break;
17665
+ case 4:
17666
+ _.label++;
17667
+ return { value: op[1], done: false };
17668
+ case 5:
17669
+ _.label++;
17670
+ y = op[1];
17671
+ op = [0];
17672
+ continue;
17673
+ case 7:
17674
+ op = _.ops.pop();
17675
+ _.trys.pop();
17676
+ continue;
17677
+ default:
17678
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
17679
+ _ = 0;
17680
+ continue;
17681
+ }
17682
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
17683
+ _.label = op[1];
17684
+ break;
17685
+ }
17686
+ if (op[0] === 6 && _.label < t[1]) {
17687
+ _.label = t[1];
17688
+ t = op;
17689
+ break;
17690
+ }
17691
+ if (t && _.label < t[2]) {
17692
+ _.label = t[2];
17693
+ _.ops.push(op);
17694
+ break;
17695
+ }
17696
+ if (t[2]) _.ops.pop();
17697
+ _.trys.pop();
17698
+ continue;
17699
+ }
17700
+ op = body.call(thisArg, _);
17701
+ } catch (e) {
17702
+ op = [6, e];
17703
+ y = 0;
17704
+ } finally {
17705
+ f = t = 0;
17706
+ }
17707
+ if (op[0] & 5) throw op[1];
17708
+ return { value: op[0] ? op[1] : void 0, done: true };
17709
+ }
17710
+ };
17711
+ Object.defineProperty(exports, "__esModule", { value: true });
17712
+ exports.SamsungWasmDecoder = void 0;
17713
+ var videoDecoder_1 = require_videoDecoder2();
17714
+ function detectKeyFrameAnnexB(bytes) {
17715
+ if (bytes.length === 0)
17716
+ return false;
17717
+ var nalHeaderIndex = 0;
17718
+ if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 1) {
17719
+ nalHeaderIndex = 4;
17720
+ } else if (bytes.length >= 3 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 1) {
17721
+ nalHeaderIndex = 3;
17722
+ }
17723
+ if (nalHeaderIndex >= bytes.length)
17724
+ return false;
17725
+ var nalType = bytes[nalHeaderIndex] & 31;
17726
+ if (nalType === 5 || nalType === 7 || nalType === 8)
17727
+ return true;
17728
+ for (var i = nalHeaderIndex + 1; i + 4 < bytes.length; i++) {
17729
+ var is3 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 1;
17730
+ var is4 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 0 && bytes[i + 3] === 1;
17731
+ if (!is3 && !is4)
17732
+ continue;
17733
+ var idx = i + (is3 ? 3 : 4);
17734
+ if (idx >= bytes.length)
17735
+ return false;
17736
+ var nt = bytes[idx] & 31;
17737
+ if (nt === 5 || nt === 7 || nt === 8)
17738
+ return true;
17739
+ }
17740
+ return false;
17741
+ }
17742
+ function ensureVideoElement(videoElementId) {
17743
+ var el = document.getElementById(videoElementId);
17744
+ if (!el) {
17745
+ el = document.createElement("video");
17746
+ el.id = videoElementId;
17747
+ el.style.position = "absolute";
17748
+ el.style.top = "0";
17749
+ el.style.left = "0";
17750
+ el.style.width = "1920px";
17751
+ el.style.height = "1080px";
17752
+ el.style.backgroundColor = "#000";
17753
+ document.body.appendChild(el);
17754
+ }
17755
+ el.autoplay = true;
17756
+ el.muted = true;
17757
+ el.playsInline = true;
17758
+ return el;
17759
+ }
17760
+ var SamsungWasmDecoder2 = (
17761
+ /** @class */
17762
+ function() {
17763
+ function SamsungWasmDecoder3(videoElementId) {
17764
+ this.videoElementId = videoElementId;
17765
+ this.initialized = false;
17766
+ this.destroyed = false;
17767
+ this.native = null;
17768
+ this.decoderHandle = 0;
17769
+ this.ptsSeconds = 0;
17770
+ this.frameDurationSeconds = 1 / 60;
17771
+ this.videoElement = ensureVideoElement(videoElementId);
17772
+ }
17773
+ SamsungWasmDecoder3.prototype.destroy = function() {
17774
+ return __awaiter(this, void 0, void 0, function() {
17775
+ var _a, _b;
17776
+ return __generator(this, function(_c) {
17777
+ if (this.destroyed)
17778
+ return [
17779
+ 2
17780
+ /*return*/
17781
+ ];
17782
+ this.destroyed = true;
17783
+ try {
17784
+ (_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]);
17785
+ } catch (_d) {
17786
+ }
17787
+ this.decoderHandle = 0;
17788
+ this.native = null;
17789
+ return [
17790
+ 2
17791
+ /*return*/
17792
+ ];
17793
+ });
17794
+ });
17795
+ };
17796
+ SamsungWasmDecoder3.prototype.initialize = function(args) {
17797
+ return __awaiter(this, void 0, void 0, function() {
17798
+ var width, height, mod, create, init, fpsNum, fpsDen, ok, isReady, maxWaitMs, pollIntervalMs, waited;
17799
+ var _a, _b, _c;
17800
+ return __generator(this, function(_d) {
17801
+ switch (_d.label) {
17802
+ case 0:
17803
+ if (this.destroyed) {
17804
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17805
+ }
17806
+ width = (_a = args.width) !== null && _a !== void 0 ? _a : window.screen.width;
17807
+ height = (_b = args.height) !== null && _b !== void 0 ? _b : window.screen.height;
17808
+ this.videoElement.width = width;
17809
+ this.videoElement.height = height;
17810
+ mod = (_c = window.SamsungWasmDecoderModule) === null || _c === void 0 ? void 0 : _c.call(window);
17811
+ if (!mod) {
17812
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17813
+ }
17814
+ return [4, new Promise(function(resolve) {
17815
+ mod.onRuntimeInitialized = function() {
17816
+ return resolve(null);
17817
+ };
17818
+ })];
17819
+ case 1:
17820
+ _d.sent();
17821
+ this.native = mod;
17822
+ create = mod.cwrap("swd_create", "number", ["string"]);
17823
+ init = mod.cwrap("swd_init_h264", "number", ["number", "number", "number", "number"]);
17824
+ this.decoderHandle = create(this.videoElementId);
17825
+ if (!this.decoderHandle) {
17826
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17827
+ }
17828
+ fpsNum = 60;
17829
+ fpsDen = 1;
17830
+ this.frameDurationSeconds = fpsDen / fpsNum;
17831
+ this.ptsSeconds = 0;
17832
+ ok = init(this.decoderHandle, width, height, fpsNum, fpsDen);
17833
+ if (ok !== 0) {
17834
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17835
+ }
17836
+ isReady = mod.cwrap("swd_is_ready", "number", ["number"]);
17837
+ maxWaitMs = 5e3;
17838
+ pollIntervalMs = 50;
17839
+ waited = 0;
17840
+ _d.label = 2;
17841
+ case 2:
17842
+ if (!(isReady(this.decoderHandle) === 0 && waited < maxWaitMs)) return [3, 4];
17843
+ return [4, new Promise(function(resolve) {
17844
+ return setTimeout(resolve, pollIntervalMs);
17845
+ })];
17846
+ case 3:
17847
+ _d.sent();
17848
+ waited += pollIntervalMs;
17849
+ return [3, 2];
17850
+ case 4:
17851
+ if (isReady(this.decoderHandle) === 0) {
17852
+ console.error("Decoder track did not open in time");
17853
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17854
+ }
17855
+ this.initialized = true;
17856
+ return [2, videoDecoder_1.ResultStatus.Ok];
17857
+ }
17858
+ });
17859
+ });
17860
+ };
17861
+ SamsungWasmDecoder3.prototype.decodeAndRender = function(data) {
17862
+ return __awaiter(this, void 0, void 0, function() {
17863
+ var bytes, isKey, ptr, append, ok;
17864
+ return __generator(this, function(_a) {
17865
+ if (!this.initialized || this.destroyed || !this.native) {
17866
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17867
+ }
17868
+ if (!(data instanceof ArrayBuffer)) {
17869
+ return [2, videoDecoder_1.ResultStatus.ErrorBadArgument];
17870
+ }
17871
+ bytes = new Uint8Array(data);
17872
+ isKey = detectKeyFrameAnnexB(bytes);
17873
+ ptr = this.native._malloc(bytes.length);
17874
+ this.native.HEAPU8.set(bytes, ptr);
17875
+ try {
17876
+ append = this.native.cwrap("swd_append", "number", [
17877
+ "number",
17878
+ "number",
17879
+ "number",
17880
+ "number",
17881
+ "number",
17882
+ "number"
17883
+ ]);
17884
+ ok = append(this.decoderHandle, ptr, bytes.length, isKey ? 1 : 0, this.ptsSeconds, this.frameDurationSeconds);
17885
+ if (ok === 0) {
17886
+ this.ptsSeconds += this.frameDurationSeconds;
17887
+ return [2, videoDecoder_1.ResultStatus.Ok];
17888
+ }
17889
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17890
+ } finally {
17891
+ this.native._free(ptr);
17892
+ }
17893
+ return [
17894
+ 2
17895
+ /*return*/
17896
+ ];
17897
+ });
17898
+ });
17899
+ };
17900
+ SamsungWasmDecoder3.prototype.flush = function() {
17901
+ return __awaiter(this, void 0, void 0, function() {
17902
+ var flush;
17903
+ return __generator(this, function(_a) {
17904
+ if (!this.native || !this.decoderHandle)
17905
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17906
+ try {
17907
+ flush = this.native.cwrap("swd_flush", "number", ["number"]);
17908
+ return [2, flush(this.decoderHandle) === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17909
+ } catch (_b) {
17910
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17911
+ }
17912
+ return [
17913
+ 2
17914
+ /*return*/
17915
+ ];
17916
+ });
17917
+ });
17918
+ };
17919
+ SamsungWasmDecoder3.prototype.reset = function() {
17920
+ return __awaiter(this, void 0, void 0, function() {
17921
+ var reset, rc;
17922
+ return __generator(this, function(_a) {
17923
+ if (!this.native || !this.decoderHandle)
17924
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17925
+ try {
17926
+ reset = this.native.cwrap("swd_reset", "number", ["number"]);
17927
+ rc = reset(this.decoderHandle);
17928
+ this.ptsSeconds = 0;
17929
+ return [2, rc === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17930
+ } catch (_b) {
17931
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17932
+ }
17933
+ return [
17934
+ 2
17935
+ /*return*/
17936
+ ];
17937
+ });
17938
+ });
17939
+ };
17940
+ return SamsungWasmDecoder3;
17941
+ }()
17942
+ );
17943
+ exports.SamsungWasmDecoder = SamsungWasmDecoder2;
17944
+ }
17945
+ });
17946
+
17947
+ // node_modules/@signageos/samsung-wasm-decoder/dist/index.js
17948
+ var require_dist2 = __commonJS({
17949
+ "node_modules/@signageos/samsung-wasm-decoder/dist/index.js"(exports) {
17950
+ "use strict";
17951
+ Object.defineProperty(exports, "__esModule", { value: true });
17952
+ exports.SamsungWasmDecoder = exports.ResultStatus = void 0;
17953
+ exports.isSamsungWasmSupported = isSamsungWasmSupported2;
17954
+ exports.createSamsungWasmDecoder = createSamsungWasmDecoder2;
17955
+ var wasmDecoder_1 = require_wasmDecoder();
17956
+ Object.defineProperty(exports, "SamsungWasmDecoder", { enumerable: true, get: function() {
17957
+ return wasmDecoder_1.SamsungWasmDecoder;
17958
+ } });
17959
+ var videoDecoder_1 = require_videoDecoder2();
17960
+ Object.defineProperty(exports, "ResultStatus", { enumerable: true, get: function() {
17961
+ return videoDecoder_1.ResultStatus;
17962
+ } });
17963
+ function isSamsungWasmSupported2() {
17964
+ var _a;
17965
+ return typeof window.WebAssembly !== "undefined" && typeof ((_a = window.tizentvwasm) === null || _a === void 0 ? void 0 : _a.ElementaryMediaStreamSource) !== "undefined";
17966
+ }
17967
+ function createSamsungWasmDecoder2(options) {
17968
+ if (!isSamsungWasmSupported2()) {
17969
+ throw new Error("Samsung WASM decoder is not supported in this environment.");
17970
+ }
17971
+ return new wasmDecoder_1.SamsungWasmDecoder(options.videoElementId);
17972
+ }
17973
+ }
17974
+ });
17975
+
17595
17976
  // node_modules/querystring/decode.js
17596
17977
  var require_decode = __commonJS({
17597
17978
  "node_modules/querystring/decode.js"(exports, module2) {
@@ -18081,7 +18462,7 @@ async function initGoEnvironment() {
18081
18462
  }
18082
18463
 
18083
18464
  // daemon/plain.ts
18084
- var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-jvmaster.371";
18465
+ var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-jvtouches.393";
18085
18466
  async function startPlainDaemon() {
18086
18467
  const fs = await initBrowserFS();
18087
18468
  window.fs = fs;
@@ -18092,7 +18473,7 @@ async function startPlainDaemon() {
18092
18473
  }
18093
18474
 
18094
18475
  // daemon/wasm.ts
18095
- var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-jvmaster.371";
18476
+ var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-jvtouches.393";
18096
18477
  async function startWasmDaemon() {
18097
18478
  await initGoEnvironment();
18098
18479
  await startGoDaemon();
@@ -18118,6 +18499,17 @@ function initNaCLDecoder() {
18118
18499
  }
18119
18500
  }
18120
18501
 
18502
+ // screen/samsungwasmdecoder.ts
18503
+ var import_samsung_wasm_decoder = __toESM(require_dist2());
18504
+ async function initSamsungWasmDecoder() {
18505
+ if ((0, import_samsung_wasm_decoder.isSamsungWasmSupported)()) {
18506
+ window.samsungWasmDecoder = (0, import_samsung_wasm_decoder.createSamsungWasmDecoder)({
18507
+ videoElementId: "samsung-wasm-video"
18508
+ });
18509
+ await window.samsungWasmDecoder.initialize({});
18510
+ }
18511
+ }
18512
+
18121
18513
  // screen/shared.ts
18122
18514
  var import_querystring = __toESM(require_querystring());
18123
18515
  function parseQueryOptions() {
@@ -18161,10 +18553,11 @@ function getGoArgv2(binFile, options) {
18161
18553
  }
18162
18554
 
18163
18555
  // screen/plain.ts
18164
- var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-jvmaster.371";
18556
+ var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-jvtouches.393";
18165
18557
  async function startPlainScreen(options) {
18166
18558
  options = options != null ? options : parseQueryOptions();
18167
18559
  initNaCLDecoder();
18560
+ await initSamsungWasmDecoder();
18168
18561
  const fs = await initBrowserFS();
18169
18562
  window.fs = fs;
18170
18563
  process.argv = ["go", ...getGoArgv2(SCREEN_JS_URL, options)];
@@ -18176,21 +18569,21 @@ async function startPlainScreen(options) {
18176
18569
  // screen/h264decoder.ts
18177
18570
  async function initH264Decoder() {
18178
18571
  window.h264Decoder = await createH264Decoder();
18179
- console.log("ASDF[TS] initH264Decoder done, window.h264Decoder: " + window.h264Decoder);
18180
18572
  }
18181
18573
  async function createH264Decoder() {
18182
- const { H264Decoder: H264Decoder2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
18574
+ const { H264Decoder: H264Decoder2 } = (init_dist(), __toCommonJS(dist_exports));
18183
18575
  if (!H264Decoder2.isReady) {
18184
18576
  await H264Decoder2.readyPromise;
18185
18577
  }
18186
- return new H264Decoder2();
18578
+ const h264Decoder = new H264Decoder2();
18579
+ return h264Decoder;
18187
18580
  }
18188
18581
 
18189
18582
  // screen/wasm.ts
18190
- var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-jvmaster.371";
18583
+ var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-jvtouches.393";
18191
18584
  async function startWasmScreen(options) {
18192
18585
  options = options != null ? options : parseQueryOptions();
18193
- console.log("ASDF[TS] startWasmScreen, options: " + options);
18586
+ await initSamsungWasmDecoder();
18194
18587
  await initH264Decoder();
18195
18588
  await initGoEnvironment();
18196
18589
  await startGoScreen(options);
@@ -18207,19 +18600,15 @@ async function startGoScreen(options) {
18207
18600
  // sdk.ts
18208
18601
  async function startDaemon(options) {
18209
18602
  if (shouldUsePlainJS(options)) {
18210
- console.log("ASDF[TS] startDaemon: starting plain daemon");
18211
18603
  startPlainDaemon();
18212
18604
  } else {
18213
- console.log("ASDF[TS] startDaemon: starting wasm daemon");
18214
18605
  startWasmDaemon();
18215
18606
  }
18216
18607
  }
18217
18608
  async function startScreen(options) {
18218
18609
  if (shouldUsePlainJS(options)) {
18219
- console.log("ASDF[TS] startScreen: starting plain screen");
18220
18610
  await startPlainScreen(options);
18221
18611
  } else {
18222
- console.log("ASDF[TS] startScreen: starting wasm screen");
18223
18612
  await startWasmScreen(options);
18224
18613
  }
18225
18614
  }