@supraio/client-daemon-js 0.0.0-jvmaster.374 → 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/screen.js CHANGED
@@ -31,6 +31,7 @@
31
31
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
32
  mod
33
33
  ));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35
 
35
36
  // node_modules/browserfs/dist/browserfs.js
36
37
  var require_browserfs = __commonJS({
@@ -17592,6 +17593,387 @@
17592
17593
  }
17593
17594
  });
17594
17595
 
17596
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js
17597
+ var require_videoDecoder2 = __commonJS({
17598
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js"(exports) {
17599
+ "use strict";
17600
+ Object.defineProperty(exports, "__esModule", { value: true });
17601
+ exports.ResultStatus = void 0;
17602
+ var ResultStatus;
17603
+ (function(ResultStatus2) {
17604
+ ResultStatus2[ResultStatus2["Ok"] = 0] = "Ok";
17605
+ ResultStatus2[ResultStatus2["ErrorFailed"] = -2] = "ErrorFailed";
17606
+ ResultStatus2[ResultStatus2["ErrorBadArgument"] = -4] = "ErrorBadArgument";
17607
+ ResultStatus2[ResultStatus2["ErrorNoInit"] = -6] = "ErrorNoInit";
17608
+ })(ResultStatus || (exports.ResultStatus = ResultStatus = {}));
17609
+ }
17610
+ });
17611
+
17612
+ // node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js
17613
+ var require_wasmDecoder = __commonJS({
17614
+ "node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js"(exports) {
17615
+ "use strict";
17616
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
17617
+ function adopt(value) {
17618
+ return value instanceof P ? value : new P(function(resolve) {
17619
+ resolve(value);
17620
+ });
17621
+ }
17622
+ return new (P || (P = Promise))(function(resolve, reject) {
17623
+ function fulfilled(value) {
17624
+ try {
17625
+ step(generator.next(value));
17626
+ } catch (e) {
17627
+ reject(e);
17628
+ }
17629
+ }
17630
+ function rejected(value) {
17631
+ try {
17632
+ step(generator["throw"](value));
17633
+ } catch (e) {
17634
+ reject(e);
17635
+ }
17636
+ }
17637
+ function step(result) {
17638
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
17639
+ }
17640
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17641
+ });
17642
+ };
17643
+ var __generator = exports && exports.__generator || function(thisArg, body) {
17644
+ var _ = { label: 0, sent: function() {
17645
+ if (t[0] & 1) throw t[1];
17646
+ return t[1];
17647
+ }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
17648
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
17649
+ return this;
17650
+ }), g;
17651
+ function verb(n) {
17652
+ return function(v) {
17653
+ return step([n, v]);
17654
+ };
17655
+ }
17656
+ function step(op) {
17657
+ if (f) throw new TypeError("Generator is already executing.");
17658
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17659
+ 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;
17660
+ if (y = 0, t) op = [op[0] & 2, t.value];
17661
+ switch (op[0]) {
17662
+ case 0:
17663
+ case 1:
17664
+ t = op;
17665
+ break;
17666
+ case 4:
17667
+ _.label++;
17668
+ return { value: op[1], done: false };
17669
+ case 5:
17670
+ _.label++;
17671
+ y = op[1];
17672
+ op = [0];
17673
+ continue;
17674
+ case 7:
17675
+ op = _.ops.pop();
17676
+ _.trys.pop();
17677
+ continue;
17678
+ default:
17679
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
17680
+ _ = 0;
17681
+ continue;
17682
+ }
17683
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
17684
+ _.label = op[1];
17685
+ break;
17686
+ }
17687
+ if (op[0] === 6 && _.label < t[1]) {
17688
+ _.label = t[1];
17689
+ t = op;
17690
+ break;
17691
+ }
17692
+ if (t && _.label < t[2]) {
17693
+ _.label = t[2];
17694
+ _.ops.push(op);
17695
+ break;
17696
+ }
17697
+ if (t[2]) _.ops.pop();
17698
+ _.trys.pop();
17699
+ continue;
17700
+ }
17701
+ op = body.call(thisArg, _);
17702
+ } catch (e) {
17703
+ op = [6, e];
17704
+ y = 0;
17705
+ } finally {
17706
+ f = t = 0;
17707
+ }
17708
+ if (op[0] & 5) throw op[1];
17709
+ return { value: op[0] ? op[1] : void 0, done: true };
17710
+ }
17711
+ };
17712
+ Object.defineProperty(exports, "__esModule", { value: true });
17713
+ exports.SamsungWasmDecoder = void 0;
17714
+ var videoDecoder_1 = require_videoDecoder2();
17715
+ function detectKeyFrameAnnexB(bytes) {
17716
+ if (bytes.length === 0)
17717
+ return false;
17718
+ var nalHeaderIndex = 0;
17719
+ if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 1) {
17720
+ nalHeaderIndex = 4;
17721
+ } else if (bytes.length >= 3 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 1) {
17722
+ nalHeaderIndex = 3;
17723
+ }
17724
+ if (nalHeaderIndex >= bytes.length)
17725
+ return false;
17726
+ var nalType = bytes[nalHeaderIndex] & 31;
17727
+ if (nalType === 5 || nalType === 7 || nalType === 8)
17728
+ return true;
17729
+ for (var i = nalHeaderIndex + 1; i + 4 < bytes.length; i++) {
17730
+ var is3 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 1;
17731
+ var is4 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 0 && bytes[i + 3] === 1;
17732
+ if (!is3 && !is4)
17733
+ continue;
17734
+ var idx = i + (is3 ? 3 : 4);
17735
+ if (idx >= bytes.length)
17736
+ return false;
17737
+ var nt = bytes[idx] & 31;
17738
+ if (nt === 5 || nt === 7 || nt === 8)
17739
+ return true;
17740
+ }
17741
+ return false;
17742
+ }
17743
+ function ensureVideoElement(videoElementId) {
17744
+ var el = document.getElementById(videoElementId);
17745
+ if (!el) {
17746
+ el = document.createElement("video");
17747
+ el.id = videoElementId;
17748
+ el.style.position = "absolute";
17749
+ el.style.top = "0";
17750
+ el.style.left = "0";
17751
+ el.style.width = "1920px";
17752
+ el.style.height = "1080px";
17753
+ el.style.backgroundColor = "#000";
17754
+ document.body.appendChild(el);
17755
+ }
17756
+ el.autoplay = true;
17757
+ el.muted = true;
17758
+ el.playsInline = true;
17759
+ return el;
17760
+ }
17761
+ var SamsungWasmDecoder2 = (
17762
+ /** @class */
17763
+ function() {
17764
+ function SamsungWasmDecoder3(videoElementId) {
17765
+ this.videoElementId = videoElementId;
17766
+ this.initialized = false;
17767
+ this.destroyed = false;
17768
+ this.native = null;
17769
+ this.decoderHandle = 0;
17770
+ this.ptsSeconds = 0;
17771
+ this.frameDurationSeconds = 1 / 60;
17772
+ this.videoElement = ensureVideoElement(videoElementId);
17773
+ }
17774
+ SamsungWasmDecoder3.prototype.destroy = function() {
17775
+ return __awaiter(this, void 0, void 0, function() {
17776
+ var _a, _b;
17777
+ return __generator(this, function(_c) {
17778
+ if (this.destroyed)
17779
+ return [
17780
+ 2
17781
+ /*return*/
17782
+ ];
17783
+ this.destroyed = true;
17784
+ try {
17785
+ (_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]);
17786
+ } catch (_d) {
17787
+ }
17788
+ this.decoderHandle = 0;
17789
+ this.native = null;
17790
+ return [
17791
+ 2
17792
+ /*return*/
17793
+ ];
17794
+ });
17795
+ });
17796
+ };
17797
+ SamsungWasmDecoder3.prototype.initialize = function(args) {
17798
+ return __awaiter(this, void 0, void 0, function() {
17799
+ var width, height, mod, create, init, fpsNum, fpsDen, ok, isReady, maxWaitMs, pollIntervalMs, waited;
17800
+ var _a, _b, _c;
17801
+ return __generator(this, function(_d) {
17802
+ switch (_d.label) {
17803
+ case 0:
17804
+ if (this.destroyed) {
17805
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17806
+ }
17807
+ width = (_a = args.width) !== null && _a !== void 0 ? _a : window.screen.width;
17808
+ height = (_b = args.height) !== null && _b !== void 0 ? _b : window.screen.height;
17809
+ this.videoElement.width = width;
17810
+ this.videoElement.height = height;
17811
+ mod = (_c = window.SamsungWasmDecoderModule) === null || _c === void 0 ? void 0 : _c.call(window);
17812
+ if (!mod) {
17813
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17814
+ }
17815
+ return [4, new Promise(function(resolve) {
17816
+ mod.onRuntimeInitialized = function() {
17817
+ return resolve(null);
17818
+ };
17819
+ })];
17820
+ case 1:
17821
+ _d.sent();
17822
+ this.native = mod;
17823
+ create = mod.cwrap("swd_create", "number", ["string"]);
17824
+ init = mod.cwrap("swd_init_h264", "number", ["number", "number", "number", "number"]);
17825
+ this.decoderHandle = create(this.videoElementId);
17826
+ if (!this.decoderHandle) {
17827
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17828
+ }
17829
+ fpsNum = 60;
17830
+ fpsDen = 1;
17831
+ this.frameDurationSeconds = fpsDen / fpsNum;
17832
+ this.ptsSeconds = 0;
17833
+ ok = init(this.decoderHandle, width, height, fpsNum, fpsDen);
17834
+ if (ok !== 0) {
17835
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17836
+ }
17837
+ isReady = mod.cwrap("swd_is_ready", "number", ["number"]);
17838
+ maxWaitMs = 5e3;
17839
+ pollIntervalMs = 50;
17840
+ waited = 0;
17841
+ _d.label = 2;
17842
+ case 2:
17843
+ if (!(isReady(this.decoderHandle) === 0 && waited < maxWaitMs)) return [3, 4];
17844
+ return [4, new Promise(function(resolve) {
17845
+ return setTimeout(resolve, pollIntervalMs);
17846
+ })];
17847
+ case 3:
17848
+ _d.sent();
17849
+ waited += pollIntervalMs;
17850
+ return [3, 2];
17851
+ case 4:
17852
+ if (isReady(this.decoderHandle) === 0) {
17853
+ console.error("Decoder track did not open in time");
17854
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17855
+ }
17856
+ this.initialized = true;
17857
+ return [2, videoDecoder_1.ResultStatus.Ok];
17858
+ }
17859
+ });
17860
+ });
17861
+ };
17862
+ SamsungWasmDecoder3.prototype.decodeAndRender = function(data) {
17863
+ return __awaiter(this, void 0, void 0, function() {
17864
+ var bytes, isKey, ptr, append, ok;
17865
+ return __generator(this, function(_a) {
17866
+ if (!this.initialized || this.destroyed || !this.native) {
17867
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17868
+ }
17869
+ if (!(data instanceof ArrayBuffer)) {
17870
+ return [2, videoDecoder_1.ResultStatus.ErrorBadArgument];
17871
+ }
17872
+ bytes = new Uint8Array(data);
17873
+ isKey = detectKeyFrameAnnexB(bytes);
17874
+ ptr = this.native._malloc(bytes.length);
17875
+ this.native.HEAPU8.set(bytes, ptr);
17876
+ try {
17877
+ append = this.native.cwrap("swd_append", "number", [
17878
+ "number",
17879
+ "number",
17880
+ "number",
17881
+ "number",
17882
+ "number",
17883
+ "number"
17884
+ ]);
17885
+ ok = append(this.decoderHandle, ptr, bytes.length, isKey ? 1 : 0, this.ptsSeconds, this.frameDurationSeconds);
17886
+ if (ok === 0) {
17887
+ this.ptsSeconds += this.frameDurationSeconds;
17888
+ return [2, videoDecoder_1.ResultStatus.Ok];
17889
+ }
17890
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17891
+ } finally {
17892
+ this.native._free(ptr);
17893
+ }
17894
+ return [
17895
+ 2
17896
+ /*return*/
17897
+ ];
17898
+ });
17899
+ });
17900
+ };
17901
+ SamsungWasmDecoder3.prototype.flush = function() {
17902
+ return __awaiter(this, void 0, void 0, function() {
17903
+ var flush;
17904
+ return __generator(this, function(_a) {
17905
+ if (!this.native || !this.decoderHandle)
17906
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17907
+ try {
17908
+ flush = this.native.cwrap("swd_flush", "number", ["number"]);
17909
+ return [2, flush(this.decoderHandle) === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17910
+ } catch (_b) {
17911
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17912
+ }
17913
+ return [
17914
+ 2
17915
+ /*return*/
17916
+ ];
17917
+ });
17918
+ });
17919
+ };
17920
+ SamsungWasmDecoder3.prototype.reset = function() {
17921
+ return __awaiter(this, void 0, void 0, function() {
17922
+ var reset, rc;
17923
+ return __generator(this, function(_a) {
17924
+ if (!this.native || !this.decoderHandle)
17925
+ return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
17926
+ try {
17927
+ reset = this.native.cwrap("swd_reset", "number", ["number"]);
17928
+ rc = reset(this.decoderHandle);
17929
+ this.ptsSeconds = 0;
17930
+ return [2, rc === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
17931
+ } catch (_b) {
17932
+ return [2, videoDecoder_1.ResultStatus.ErrorFailed];
17933
+ }
17934
+ return [
17935
+ 2
17936
+ /*return*/
17937
+ ];
17938
+ });
17939
+ });
17940
+ };
17941
+ return SamsungWasmDecoder3;
17942
+ }()
17943
+ );
17944
+ exports.SamsungWasmDecoder = SamsungWasmDecoder2;
17945
+ }
17946
+ });
17947
+
17948
+ // node_modules/@signageos/samsung-wasm-decoder/dist/index.js
17949
+ var require_dist2 = __commonJS({
17950
+ "node_modules/@signageos/samsung-wasm-decoder/dist/index.js"(exports) {
17951
+ "use strict";
17952
+ Object.defineProperty(exports, "__esModule", { value: true });
17953
+ exports.SamsungWasmDecoder = exports.ResultStatus = void 0;
17954
+ exports.isSamsungWasmSupported = isSamsungWasmSupported2;
17955
+ exports.createSamsungWasmDecoder = createSamsungWasmDecoder2;
17956
+ var wasmDecoder_1 = require_wasmDecoder();
17957
+ Object.defineProperty(exports, "SamsungWasmDecoder", { enumerable: true, get: function() {
17958
+ return wasmDecoder_1.SamsungWasmDecoder;
17959
+ } });
17960
+ var videoDecoder_1 = require_videoDecoder2();
17961
+ Object.defineProperty(exports, "ResultStatus", { enumerable: true, get: function() {
17962
+ return videoDecoder_1.ResultStatus;
17963
+ } });
17964
+ function isSamsungWasmSupported2() {
17965
+ var _a;
17966
+ return typeof window.WebAssembly !== "undefined" && typeof ((_a = window.tizentvwasm) === null || _a === void 0 ? void 0 : _a.ElementaryMediaStreamSource) !== "undefined";
17967
+ }
17968
+ function createSamsungWasmDecoder2(options) {
17969
+ if (!isSamsungWasmSupported2()) {
17970
+ throw new Error("Samsung WASM decoder is not supported in this environment.");
17971
+ }
17972
+ return new wasmDecoder_1.SamsungWasmDecoder(options.videoElementId);
17973
+ }
17974
+ }
17975
+ });
17976
+
17595
17977
  // node_modules/querystring/decode.js
17596
17978
  var require_decode = __commonJS({
17597
17979
  "node_modules/querystring/decode.js"(exports, module) {
@@ -18080,6 +18462,17 @@
18080
18462
  }
18081
18463
  }
18082
18464
 
18465
+ // screen/samsungwasmdecoder.ts
18466
+ var import_samsung_wasm_decoder = __toESM(require_dist2());
18467
+ async function initSamsungWasmDecoder() {
18468
+ if ((0, import_samsung_wasm_decoder.isSamsungWasmSupported)()) {
18469
+ window.samsungWasmDecoder = (0, import_samsung_wasm_decoder.createSamsungWasmDecoder)({
18470
+ videoElementId: "samsung-wasm-video"
18471
+ });
18472
+ await window.samsungWasmDecoder.initialize({});
18473
+ }
18474
+ }
18475
+
18083
18476
  // screen/shared.ts
18084
18477
  var import_querystring = __toESM(require_querystring());
18085
18478
  function parseQueryOptions() {
@@ -18123,10 +18516,11 @@
18123
18516
  }
18124
18517
 
18125
18518
  // screen/plain.ts
18126
- var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-jvmaster.374";
18519
+ var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-jvtouches.393";
18127
18520
  async function startPlainScreen(options) {
18128
18521
  options = options != null ? options : parseQueryOptions();
18129
18522
  initNaCLDecoder();
18523
+ await initSamsungWasmDecoder();
18130
18524
  const fs = await initBrowserFS();
18131
18525
  window.fs = fs;
18132
18526
  process.argv = ["go", ...getGoArgv(SCREEN_JS_URL, options)];
@@ -18140,17 +18534,19 @@
18140
18534
  window.h264Decoder = await createH264Decoder();
18141
18535
  }
18142
18536
  async function createH264Decoder() {
18143
- const { H264Decoder: H264Decoder2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
18537
+ const { H264Decoder: H264Decoder2 } = (init_dist(), __toCommonJS(dist_exports));
18144
18538
  if (!H264Decoder2.isReady) {
18145
18539
  await H264Decoder2.readyPromise;
18146
18540
  }
18147
- return new H264Decoder2();
18541
+ const h264Decoder = new H264Decoder2();
18542
+ return h264Decoder;
18148
18543
  }
18149
18544
 
18150
18545
  // screen/wasm.ts
18151
- var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-jvmaster.374";
18546
+ var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-jvtouches.393";
18152
18547
  async function startWasmScreen(options) {
18153
18548
  options = options != null ? options : parseQueryOptions();
18549
+ await initSamsungWasmDecoder();
18154
18550
  await initH264Decoder();
18155
18551
  await initGoEnvironment();
18156
18552
  await startGoScreen(options);