@supraio/client-daemon-js 0.0.0-master.322 → 0.0.0-master.429
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 +2843 -274
- package/daemon.js.map +4 -4
- package/nacl-decoder_armv7.nexe +0 -0
- package/nacl-decoder_i686.nexe +0 -0
- package/nacl-decoder_x86-64.nexe +0 -0
- package/package.json +3 -2
- package/samsung-wasm-decoder.js +22 -0
- package/samsung-wasm-decoder.js.mem +0 -0
- package/samsung-wasm-decoder.wasm +0 -0
- package/samsung-wasm-decoder.worker.js +228 -0
- package/screen/control.d.ts +72 -0
- package/screen/nacltcp.d.ts +9 -0
- package/screen/options.d.ts +14 -0
- package/screen/samsungwasmdecoder.d.ts +9 -0
- package/screen/samsungwasmtcp.d.ts +9 -0
- package/screen/workerFrameConnection.d.ts +18 -0
- package/screen.css +13 -0
- package/screen.html +1 -1
- package/screen.js +3075 -238
- package/screen.js.map +4 -4
- package/sdk.d.ts +2 -1
- package/sdk.js +3117 -240
- package/sdk.js.map +4 -4
- package/supra-client-daemon.js +49045 -47387
- package/supra-client-daemon.js.map +1 -1
- package/supra-client-daemon.wasm +0 -0
- package/supra-client-screen.js +110378 -107636
- package/supra-client-screen.js.map +1 -1
- package/supra-client-screen.wasm +0 -0
package/sdk.js
CHANGED
|
@@ -16921,6 +16921,20 @@ var require_messages = __commonJS({
|
|
|
16921
16921
|
JSToNaClMessageType2[JSToNaClMessageType2["Reset"] = 5] = "Reset";
|
|
16922
16922
|
JSToNaClMessageType2[JSToNaClMessageType2["RecyclePicture"] = 6] = "RecyclePicture";
|
|
16923
16923
|
JSToNaClMessageType2[JSToNaClMessageType2["DecodeAndRender"] = 7] = "DecodeAndRender";
|
|
16924
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPConnect"] = 16] = "TCPConnect";
|
|
16925
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPSend"] = 17] = "TCPSend";
|
|
16926
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPRecv"] = 18] = "TCPRecv";
|
|
16927
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPStreamWrite"] = 19] = "TCPStreamWrite";
|
|
16928
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPStreamRead"] = 20] = "TCPStreamRead";
|
|
16929
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPClose"] = 21] = "TCPClose";
|
|
16930
|
+
JSToNaClMessageType2[JSToNaClMessageType2["TCPIsConnected"] = 22] = "TCPIsConnected";
|
|
16931
|
+
JSToNaClMessageType2[JSToNaClMessageType2["CollectorCreate"] = 23] = "CollectorCreate";
|
|
16932
|
+
JSToNaClMessageType2[JSToNaClMessageType2["CollectorStart"] = 24] = "CollectorStart";
|
|
16933
|
+
JSToNaClMessageType2[JSToNaClMessageType2["CollectorStop"] = 25] = "CollectorStop";
|
|
16934
|
+
JSToNaClMessageType2[JSToNaClMessageType2["CollectorDestroy"] = 26] = "CollectorDestroy";
|
|
16935
|
+
JSToNaClMessageType2[JSToNaClMessageType2["CollectFrame"] = 27] = "CollectFrame";
|
|
16936
|
+
JSToNaClMessageType2[JSToNaClMessageType2["FrameRelease"] = 28] = "FrameRelease";
|
|
16937
|
+
JSToNaClMessageType2[JSToNaClMessageType2["DecodeAndRenderRef"] = 29] = "DecodeAndRenderRef";
|
|
16924
16938
|
})(JSToNaClMessageType || (exports.JSToNaClMessageType = JSToNaClMessageType = {}));
|
|
16925
16939
|
var NaClToJSMessageType;
|
|
16926
16940
|
(function(NaClToJSMessageType2) {
|
|
@@ -16931,6 +16945,20 @@ var require_messages = __commonJS({
|
|
|
16931
16945
|
NaClToJSMessageType2[NaClToJSMessageType2["FlushResult"] = 4] = "FlushResult";
|
|
16932
16946
|
NaClToJSMessageType2[NaClToJSMessageType2["ResetResult"] = 5] = "ResetResult";
|
|
16933
16947
|
NaClToJSMessageType2[NaClToJSMessageType2["DecodeAndRenderResult"] = 7] = "DecodeAndRenderResult";
|
|
16948
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPConnect"] = 16] = "TCPConnect";
|
|
16949
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPSend"] = 17] = "TCPSend";
|
|
16950
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPRecv"] = 18] = "TCPRecv";
|
|
16951
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPStreamWrite"] = 19] = "TCPStreamWrite";
|
|
16952
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPStreamRead"] = 20] = "TCPStreamRead";
|
|
16953
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPClose"] = 21] = "TCPClose";
|
|
16954
|
+
NaClToJSMessageType2[NaClToJSMessageType2["TCPIsConnected"] = 22] = "TCPIsConnected";
|
|
16955
|
+
NaClToJSMessageType2[NaClToJSMessageType2["CollectorCreate"] = 23] = "CollectorCreate";
|
|
16956
|
+
NaClToJSMessageType2[NaClToJSMessageType2["CollectorStart"] = 24] = "CollectorStart";
|
|
16957
|
+
NaClToJSMessageType2[NaClToJSMessageType2["CollectorStop"] = 25] = "CollectorStop";
|
|
16958
|
+
NaClToJSMessageType2[NaClToJSMessageType2["CollectorDestroy"] = 26] = "CollectorDestroy";
|
|
16959
|
+
NaClToJSMessageType2[NaClToJSMessageType2["CollectFrame"] = 27] = "CollectFrame";
|
|
16960
|
+
NaClToJSMessageType2[NaClToJSMessageType2["FrameRelease"] = 28] = "FrameRelease";
|
|
16961
|
+
NaClToJSMessageType2[NaClToJSMessageType2["DecodeAndRenderRef"] = 29] = "DecodeAndRenderRef";
|
|
16934
16962
|
NaClToJSMessageType2[NaClToJSMessageType2["UnknownDataType"] = 254] = "UnknownDataType";
|
|
16935
16963
|
NaClToJSMessageType2[NaClToJSMessageType2["UnknownMessageType"] = 255] = "UnknownMessageType";
|
|
16936
16964
|
})(NaClToJSMessageType || (exports.NaClToJSMessageType = NaClToJSMessageType = {}));
|
|
@@ -17045,9 +17073,41 @@ var require_messageSender = __commonJS({
|
|
|
17045
17073
|
/** @class */
|
|
17046
17074
|
function() {
|
|
17047
17075
|
function MessageSender2(naclModuleEl, messageListeners, timeoutMs) {
|
|
17076
|
+
var _this = this;
|
|
17048
17077
|
this.naclModuleEl = naclModuleEl;
|
|
17049
17078
|
this.messageListeners = messageListeners;
|
|
17050
17079
|
this.timeoutMs = timeoutMs;
|
|
17080
|
+
this.nextRequestId = 1;
|
|
17081
|
+
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
17082
|
+
this.timedOutConnectRequests = /* @__PURE__ */ new Set();
|
|
17083
|
+
this.handleRequestMessage = function(message) {
|
|
17084
|
+
if (message.type < messages_1.NaClToJSMessageType.TCPConnect || message.type > messages_1.NaClToJSMessageType.DecodeAndRenderRef) {
|
|
17085
|
+
return;
|
|
17086
|
+
}
|
|
17087
|
+
if (message.payload.byteLength < 8) {
|
|
17088
|
+
return;
|
|
17089
|
+
}
|
|
17090
|
+
var view = new DataView(message.payload);
|
|
17091
|
+
var requestId = view.getUint32(0, true);
|
|
17092
|
+
var status = view.getInt32(4, true);
|
|
17093
|
+
var payload = message.payload.slice(8);
|
|
17094
|
+
var pending = _this.pendingRequests.get(requestId);
|
|
17095
|
+
if (!pending) {
|
|
17096
|
+
_this.handleLateResult(message.type, requestId, status, payload);
|
|
17097
|
+
return;
|
|
17098
|
+
}
|
|
17099
|
+
if (message.type !== pending.resultMessageType) {
|
|
17100
|
+
return;
|
|
17101
|
+
}
|
|
17102
|
+
window.clearTimeout(pending.timeoutHandler);
|
|
17103
|
+
_this.pendingRequests.delete(requestId);
|
|
17104
|
+
if (status !== 0) {
|
|
17105
|
+
pending.reject(new Error(_this.decodeErrorPayload(payload, status)));
|
|
17106
|
+
return;
|
|
17107
|
+
}
|
|
17108
|
+
pending.resolve({ requestId, status, payload });
|
|
17109
|
+
};
|
|
17110
|
+
this.messageListeners.add(this.handleRequestMessage);
|
|
17051
17111
|
}
|
|
17052
17112
|
MessageSender2.prototype.sendWithoutResult = function(message) {
|
|
17053
17113
|
this.naclModuleEl.postMessage((0, messageConvertor_1.convertMessageToArrayBuffer)(message));
|
|
@@ -17077,6 +17137,75 @@ var require_messageSender = __commonJS({
|
|
|
17077
17137
|
});
|
|
17078
17138
|
});
|
|
17079
17139
|
};
|
|
17140
|
+
MessageSender2.prototype.sendWithRequestId = function(messageType_1, payload_1, resultMessageType_1) {
|
|
17141
|
+
return __awaiter(this, arguments, void 0, function(messageType, payload, resultMessageType, timeoutMs) {
|
|
17142
|
+
var requestId, payloadLength, requestPayload, requestView, message;
|
|
17143
|
+
var _this = this;
|
|
17144
|
+
var _a;
|
|
17145
|
+
if (timeoutMs === void 0) {
|
|
17146
|
+
timeoutMs = this.timeoutMs;
|
|
17147
|
+
}
|
|
17148
|
+
return __generator(this, function(_b) {
|
|
17149
|
+
requestId = this.nextRequestId++;
|
|
17150
|
+
if (this.nextRequestId > 4294967295) {
|
|
17151
|
+
this.nextRequestId = 1;
|
|
17152
|
+
}
|
|
17153
|
+
payloadLength = (_a = payload === null || payload === void 0 ? void 0 : payload.byteLength) !== null && _a !== void 0 ? _a : 0;
|
|
17154
|
+
requestPayload = new ArrayBuffer(4 + payloadLength);
|
|
17155
|
+
requestView = new DataView(requestPayload);
|
|
17156
|
+
requestView.setUint32(0, requestId, true);
|
|
17157
|
+
if (payload) {
|
|
17158
|
+
new Uint8Array(requestPayload, 4).set(new Uint8Array(payload));
|
|
17159
|
+
}
|
|
17160
|
+
message = {
|
|
17161
|
+
type: messageType,
|
|
17162
|
+
payload: requestPayload
|
|
17163
|
+
};
|
|
17164
|
+
return [2, new Promise(function(resolve, reject) {
|
|
17165
|
+
var timeoutHandler = window.setTimeout(function() {
|
|
17166
|
+
_this.pendingRequests.delete(requestId);
|
|
17167
|
+
if (messageType === messages_1.JSToNaClMessageType.TCPConnect) {
|
|
17168
|
+
_this.timedOutConnectRequests.add(requestId);
|
|
17169
|
+
}
|
|
17170
|
+
reject(new Error("Timeout of message ".concat(messages_1.JSToNaClMessageType[messageType])));
|
|
17171
|
+
}, timeoutMs);
|
|
17172
|
+
_this.pendingRequests.set(requestId, {
|
|
17173
|
+
resultMessageType,
|
|
17174
|
+
resolve,
|
|
17175
|
+
reject,
|
|
17176
|
+
timeoutHandler,
|
|
17177
|
+
sourceMessageType: messageType
|
|
17178
|
+
});
|
|
17179
|
+
_this.naclModuleEl.postMessage((0, messageConvertor_1.convertMessageToArrayBuffer)(message));
|
|
17180
|
+
})];
|
|
17181
|
+
});
|
|
17182
|
+
});
|
|
17183
|
+
};
|
|
17184
|
+
MessageSender2.prototype.handleLateResult = function(messageType, requestId, status, payload) {
|
|
17185
|
+
if (messageType === messages_1.NaClToJSMessageType.TCPConnect && status === 0 && this.timedOutConnectRequests.has(requestId) && payload.byteLength >= 4) {
|
|
17186
|
+
this.timedOutConnectRequests.delete(requestId);
|
|
17187
|
+
var handle = new DataView(payload).getUint32(0, true);
|
|
17188
|
+
var closePayload = new ArrayBuffer(4);
|
|
17189
|
+
new DataView(closePayload).setUint32(0, handle, true);
|
|
17190
|
+
void this.sendWithRequestId(messages_1.JSToNaClMessageType.TCPClose, closePayload, messages_1.NaClToJSMessageType.TCPClose).catch(function() {
|
|
17191
|
+
return void 0;
|
|
17192
|
+
});
|
|
17193
|
+
}
|
|
17194
|
+
};
|
|
17195
|
+
MessageSender2.prototype.decodeErrorPayload = function(payload, status) {
|
|
17196
|
+
if (payload.byteLength === 0) {
|
|
17197
|
+
return "NaCl request failed with status ".concat(status);
|
|
17198
|
+
}
|
|
17199
|
+
var bytes = new Uint8Array(payload);
|
|
17200
|
+
var message = "";
|
|
17201
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
17202
|
+
if (bytes[i] === 0) {
|
|
17203
|
+
break;
|
|
17204
|
+
}
|
|
17205
|
+
message += String.fromCharCode(bytes[i]);
|
|
17206
|
+
}
|
|
17207
|
+
return message || "NaCl request failed with status ".concat(status);
|
|
17208
|
+
};
|
|
17080
17209
|
return MessageSender2;
|
|
17081
17210
|
}()
|
|
17082
17211
|
);
|
|
@@ -17129,9 +17258,9 @@ var require_module = __commonJS({
|
|
|
17129
17258
|
}
|
|
17130
17259
|
});
|
|
17131
17260
|
|
|
17132
|
-
// node_modules/@signageos/nacl-decoder/dist/NaClDecoder/
|
|
17133
|
-
var
|
|
17134
|
-
"node_modules/@signageos/nacl-decoder/dist/NaClDecoder/
|
|
17261
|
+
// node_modules/@signageos/nacl-decoder/dist/NaClDecoder/naclTCP.js
|
|
17262
|
+
var require_naclTCP = __commonJS({
|
|
17263
|
+
"node_modules/@signageos/nacl-decoder/dist/NaClDecoder/naclTCP.js"(exports) {
|
|
17135
17264
|
"use strict";
|
|
17136
17265
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
17137
17266
|
function adopt(value) {
|
|
@@ -17229,265 +17358,872 @@ var require_naclDecoder = __commonJS({
|
|
|
17229
17358
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
17230
17359
|
}
|
|
17231
17360
|
};
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17243
|
-
} finally {
|
|
17244
|
-
if (e) throw e.error;
|
|
17361
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17362
|
+
exports.NaClTCPStream = exports.NaClTCPPacket = exports.NaClTCPStreamConnection = exports.NaClTCPPacketConnection = exports.NaClFrameCollector = void 0;
|
|
17363
|
+
var messages_1 = require_messages();
|
|
17364
|
+
var DEFAULT_MAX_PACKET_SIZE = 65535;
|
|
17365
|
+
var CONNECT_LATE_RESULT_GRACE_MS = 2e3;
|
|
17366
|
+
function parseHost(host) {
|
|
17367
|
+
if (host.startsWith("[")) {
|
|
17368
|
+
var end = host.indexOf("]");
|
|
17369
|
+
if (end < 0 || host[end + 1] !== ":") {
|
|
17370
|
+
throw new Error('Invalid host "'.concat(host, '". Expected "[IPv6]:port".'));
|
|
17245
17371
|
}
|
|
17372
|
+
return {
|
|
17373
|
+
hostname: host.slice(1, end),
|
|
17374
|
+
port: parsePort(host.slice(end + 2), host)
|
|
17375
|
+
};
|
|
17246
17376
|
}
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17377
|
+
var separator = host.lastIndexOf(":");
|
|
17378
|
+
if (separator <= 0 || separator === host.length - 1) {
|
|
17379
|
+
throw new Error('Invalid host "'.concat(host, '". Expected "hostname:port".'));
|
|
17380
|
+
}
|
|
17381
|
+
var hostname = host.slice(0, separator);
|
|
17382
|
+
if (hostname.indexOf(":") >= 0) {
|
|
17383
|
+
throw new Error('Invalid host "'.concat(host, '". IPv6 literals must use "[IPv6]:port".'));
|
|
17384
|
+
}
|
|
17385
|
+
return {
|
|
17386
|
+
hostname,
|
|
17387
|
+
port: parsePort(host.slice(separator + 1), host)
|
|
17388
|
+
};
|
|
17389
|
+
}
|
|
17390
|
+
function parsePort(portValue, host) {
|
|
17391
|
+
if (!/^[0-9]+$/.test(portValue)) {
|
|
17392
|
+
throw new Error('Invalid port in host "'.concat(host, '".'));
|
|
17393
|
+
}
|
|
17394
|
+
var port = Number(portValue);
|
|
17395
|
+
if (port < 1 || port > 65535) {
|
|
17396
|
+
throw new Error('Port out of range in host "'.concat(host, '".'));
|
|
17397
|
+
}
|
|
17398
|
+
return port;
|
|
17399
|
+
}
|
|
17400
|
+
function createConnectPayload(mode, options) {
|
|
17401
|
+
var parsed = parseHost(options.host);
|
|
17402
|
+
var hostBytes = encodeAscii(parsed.hostname);
|
|
17403
|
+
if (hostBytes.byteLength > 255) {
|
|
17404
|
+
throw new Error('Host name is too long: "'.concat(parsed.hostname, '".'));
|
|
17405
|
+
}
|
|
17406
|
+
var payload = new ArrayBuffer(10 + hostBytes.byteLength);
|
|
17407
|
+
var view = new DataView(payload);
|
|
17408
|
+
view.setUint8(0, mode);
|
|
17409
|
+
view.setUint8(1, options.secure ? 1 : 0);
|
|
17410
|
+
view.setUint32(2, options.timeoutMs, true);
|
|
17411
|
+
view.setUint16(6, parsed.port, true);
|
|
17412
|
+
view.setUint16(8, hostBytes.byteLength, true);
|
|
17413
|
+
new Uint8Array(payload, 10).set(hostBytes);
|
|
17414
|
+
return payload;
|
|
17415
|
+
}
|
|
17416
|
+
function encodeAscii(value) {
|
|
17417
|
+
var bytes = new Uint8Array(value.length);
|
|
17418
|
+
for (var i = 0; i < value.length; i++) {
|
|
17419
|
+
var code = value.charCodeAt(i);
|
|
17420
|
+
if (code > 127) {
|
|
17421
|
+
throw new Error('Only ASCII host names are supported: "'.concat(value, '".'));
|
|
17254
17422
|
}
|
|
17423
|
+
bytes[i] = code;
|
|
17255
17424
|
}
|
|
17256
|
-
return
|
|
17257
|
-
}
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17425
|
+
return bytes;
|
|
17426
|
+
}
|
|
17427
|
+
function createHandlePayload(handle) {
|
|
17428
|
+
var payload = new ArrayBuffer(4);
|
|
17429
|
+
new DataView(payload).setUint32(0, handle, true);
|
|
17430
|
+
return payload;
|
|
17431
|
+
}
|
|
17432
|
+
function createHandleAndSizePayload(handle, size) {
|
|
17433
|
+
var payload = new ArrayBuffer(8);
|
|
17434
|
+
var view = new DataView(payload);
|
|
17435
|
+
view.setUint32(0, handle, true);
|
|
17436
|
+
view.setUint32(4, size, true);
|
|
17437
|
+
return payload;
|
|
17438
|
+
}
|
|
17439
|
+
function createHandleAndDataPayload(handle, data) {
|
|
17440
|
+
var payload = new ArrayBuffer(4 + data.byteLength);
|
|
17441
|
+
new DataView(payload).setUint32(0, handle, true);
|
|
17442
|
+
new Uint8Array(payload, 4).set(new Uint8Array(data));
|
|
17443
|
+
return payload;
|
|
17444
|
+
}
|
|
17445
|
+
var NaClFrameCollector = (
|
|
17263
17446
|
/** @class */
|
|
17264
17447
|
function() {
|
|
17265
|
-
function
|
|
17448
|
+
function NaClFrameCollector2(messageSender, collectorHandle) {
|
|
17266
17449
|
this.messageSender = messageSender;
|
|
17267
|
-
this.
|
|
17450
|
+
this.collectorHandle = collectorHandle;
|
|
17451
|
+
this.destroyed = false;
|
|
17268
17452
|
}
|
|
17269
|
-
|
|
17270
|
-
return
|
|
17271
|
-
return __generator(this, function(_a) {
|
|
17272
|
-
(0, module_1.removeNaClModule)(this.naclModuleEl);
|
|
17273
|
-
return [
|
|
17274
|
-
2
|
|
17275
|
-
/*return*/
|
|
17276
|
-
];
|
|
17277
|
-
});
|
|
17278
|
-
});
|
|
17453
|
+
NaClFrameCollector2.prototype.getHandle = function() {
|
|
17454
|
+
return this.collectorHandle;
|
|
17279
17455
|
};
|
|
17280
|
-
|
|
17456
|
+
NaClFrameCollector2.prototype.collectFrame = function(options) {
|
|
17281
17457
|
return __awaiter(this, void 0, void 0, function() {
|
|
17282
|
-
var
|
|
17458
|
+
var result, view;
|
|
17283
17459
|
var _a, _b;
|
|
17284
17460
|
return __generator(this, function(_c) {
|
|
17285
17461
|
switch (_c.label) {
|
|
17286
17462
|
case 0:
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
args.profile,
|
|
17293
|
-
args.acceleration
|
|
17294
|
-
], __read(new Uint8Array(new Uint32Array([args.minPictureCount]).buffer)), false), __read(new Uint8Array(new Int32Array([width, height]).buffer)), false)).buffer
|
|
17295
|
-
};
|
|
17296
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.InitializeResult)];
|
|
17463
|
+
if (this.destroyed) {
|
|
17464
|
+
throw new Error("Frame collector destroyed");
|
|
17465
|
+
}
|
|
17466
|
+
(_a = options === null || options === void 0 ? void 0 : options.onStart) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
17467
|
+
_c.label = 1;
|
|
17297
17468
|
case 1:
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17469
|
+
_c.trys.push([1, , 3, 4]);
|
|
17470
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.CollectFrame, createHandlePayload(this.collectorHandle), messages_1.NaClToJSMessageType.CollectFrame, 2147483647)];
|
|
17471
|
+
case 2:
|
|
17472
|
+
result = _c.sent();
|
|
17473
|
+
view = new DataView(result.payload);
|
|
17474
|
+
return [2, {
|
|
17475
|
+
dataRef: view.getUint32(0, true),
|
|
17476
|
+
frameType: view.getUint8(4),
|
|
17477
|
+
timestamp: {
|
|
17478
|
+
lo: view.getUint32(5, true),
|
|
17479
|
+
hi: view.getUint32(9, true)
|
|
17480
|
+
}
|
|
17481
|
+
}];
|
|
17482
|
+
case 3:
|
|
17483
|
+
(_b = options === null || options === void 0 ? void 0 : options.onEnd) === null || _b === void 0 ? void 0 : _b.call(options);
|
|
17484
|
+
return [
|
|
17485
|
+
7
|
|
17486
|
+
/*endfinally*/
|
|
17487
|
+
];
|
|
17488
|
+
case 4:
|
|
17489
|
+
return [
|
|
17490
|
+
2
|
|
17491
|
+
/*return*/
|
|
17492
|
+
];
|
|
17301
17493
|
}
|
|
17302
17494
|
});
|
|
17303
17495
|
});
|
|
17304
17496
|
};
|
|
17305
|
-
|
|
17497
|
+
NaClFrameCollector2.prototype.destroy = function() {
|
|
17306
17498
|
return __awaiter(this, void 0, void 0, function() {
|
|
17307
|
-
var message, resultMessage, resultStatus;
|
|
17308
17499
|
return __generator(this, function(_a) {
|
|
17309
17500
|
switch (_a.label) {
|
|
17310
17501
|
case 0:
|
|
17311
|
-
if (
|
|
17312
|
-
|
|
17502
|
+
if (this.destroyed) {
|
|
17503
|
+
return [
|
|
17504
|
+
2
|
|
17505
|
+
/*return*/
|
|
17506
|
+
];
|
|
17507
|
+
}
|
|
17508
|
+
this.destroyed = true;
|
|
17509
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.CollectorDestroy, createHandlePayload(this.collectorHandle), messages_1.NaClToJSMessageType.CollectorDestroy)];
|
|
17510
|
+
case 1:
|
|
17511
|
+
_a.sent();
|
|
17512
|
+
return [
|
|
17513
|
+
2
|
|
17514
|
+
/*return*/
|
|
17515
|
+
];
|
|
17516
|
+
}
|
|
17517
|
+
});
|
|
17518
|
+
});
|
|
17519
|
+
};
|
|
17520
|
+
return NaClFrameCollector2;
|
|
17521
|
+
}()
|
|
17522
|
+
);
|
|
17523
|
+
exports.NaClFrameCollector = NaClFrameCollector;
|
|
17524
|
+
var NaClTCPPacketConnection = (
|
|
17525
|
+
/** @class */
|
|
17526
|
+
function() {
|
|
17527
|
+
function NaClTCPPacketConnection2(messageSender, handle, maxPacketSize) {
|
|
17528
|
+
this.messageSender = messageSender;
|
|
17529
|
+
this.handle = handle;
|
|
17530
|
+
this.maxPacketSize = maxPacketSize;
|
|
17531
|
+
this.frameCollector = null;
|
|
17532
|
+
this.frameCollectorStarted = false;
|
|
17533
|
+
}
|
|
17534
|
+
NaClTCPPacketConnection2.prototype.getHandle = function() {
|
|
17535
|
+
return this.handle;
|
|
17536
|
+
};
|
|
17537
|
+
NaClTCPPacketConnection2.prototype.isConnected = function() {
|
|
17538
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17539
|
+
var result;
|
|
17540
|
+
return __generator(this, function(_a) {
|
|
17541
|
+
switch (_a.label) {
|
|
17542
|
+
case 0:
|
|
17543
|
+
if (this.handle === 0) {
|
|
17544
|
+
return [2, false];
|
|
17313
17545
|
}
|
|
17314
|
-
|
|
17315
|
-
type: messages_1.JSToNaClMessageType.DecodeAndRender,
|
|
17316
|
-
payload: data
|
|
17317
|
-
};
|
|
17318
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.DecodeAndRenderResult)];
|
|
17546
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPIsConnected, createHandlePayload(this.handle), messages_1.NaClToJSMessageType.TCPIsConnected)];
|
|
17319
17547
|
case 1:
|
|
17320
|
-
|
|
17321
|
-
|
|
17322
|
-
return [2, resultStatus];
|
|
17548
|
+
result = _a.sent();
|
|
17549
|
+
return [2, new Int8Array(result.payload)[0] === 1];
|
|
17323
17550
|
}
|
|
17324
17551
|
});
|
|
17325
17552
|
});
|
|
17326
17553
|
};
|
|
17327
|
-
|
|
17554
|
+
NaClTCPPacketConnection2.prototype.isConnecting = function() {
|
|
17328
17555
|
return __awaiter(this, void 0, void 0, function() {
|
|
17329
|
-
var
|
|
17556
|
+
var result;
|
|
17330
17557
|
return __generator(this, function(_a) {
|
|
17331
17558
|
switch (_a.label) {
|
|
17332
17559
|
case 0:
|
|
17333
|
-
if (
|
|
17334
|
-
|
|
17560
|
+
if (this.handle === 0) {
|
|
17561
|
+
return [2, false];
|
|
17335
17562
|
}
|
|
17336
|
-
|
|
17337
|
-
type: messages_1.JSToNaClMessageType.Decode,
|
|
17338
|
-
// TODO decodeId (not used in the NaCl module now)
|
|
17339
|
-
payload: args.data
|
|
17340
|
-
};
|
|
17341
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.DecodeResult)];
|
|
17563
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPIsConnected, createHandlePayload(this.handle), messages_1.NaClToJSMessageType.TCPIsConnected)];
|
|
17342
17564
|
case 1:
|
|
17343
|
-
|
|
17344
|
-
|
|
17345
|
-
return [2, resultStatus];
|
|
17565
|
+
result = _a.sent();
|
|
17566
|
+
return [2, new Int8Array(result.payload)[0] === -1];
|
|
17346
17567
|
}
|
|
17347
17568
|
});
|
|
17348
17569
|
});
|
|
17349
17570
|
};
|
|
17350
|
-
|
|
17571
|
+
NaClTCPPacketConnection2.prototype.send = function(data) {
|
|
17351
17572
|
return __awaiter(this, void 0, void 0, function() {
|
|
17352
|
-
var message, resultMessage, resultFirstUInt32Array, resultSecondInt32Array, picture;
|
|
17353
17573
|
return __generator(this, function(_a) {
|
|
17354
17574
|
switch (_a.label) {
|
|
17355
17575
|
case 0:
|
|
17356
|
-
|
|
17357
|
-
type: messages_1.JSToNaClMessageType.GetPicture
|
|
17358
|
-
};
|
|
17359
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.GetPictureResult)];
|
|
17576
|
+
return [4, this.ensureConnected()];
|
|
17360
17577
|
case 1:
|
|
17361
|
-
|
|
17362
|
-
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
width: resultSecondInt32Array[0],
|
|
17370
|
-
height: resultSecondInt32Array[1]
|
|
17371
|
-
},
|
|
17372
|
-
visibleRect: {
|
|
17373
|
-
x: resultSecondInt32Array[2],
|
|
17374
|
-
y: resultSecondInt32Array[3],
|
|
17375
|
-
width: resultSecondInt32Array[4],
|
|
17376
|
-
height: resultSecondInt32Array[5]
|
|
17377
|
-
}
|
|
17378
|
-
};
|
|
17379
|
-
return [2, picture];
|
|
17578
|
+
_a.sent();
|
|
17579
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPSend, createHandleAndDataPayload(this.handle, data), messages_1.NaClToJSMessageType.TCPSend)];
|
|
17580
|
+
case 2:
|
|
17581
|
+
_a.sent();
|
|
17582
|
+
return [
|
|
17583
|
+
2
|
|
17584
|
+
/*return*/
|
|
17585
|
+
];
|
|
17380
17586
|
}
|
|
17381
17587
|
});
|
|
17382
17588
|
});
|
|
17383
17589
|
};
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17402
|
-
|
|
17590
|
+
NaClTCPPacketConnection2.prototype.recv = function() {
|
|
17591
|
+
return __awaiter(this, arguments, void 0, function(maxSize) {
|
|
17592
|
+
var result;
|
|
17593
|
+
if (maxSize === void 0) {
|
|
17594
|
+
maxSize = DEFAULT_MAX_PACKET_SIZE;
|
|
17595
|
+
}
|
|
17596
|
+
return __generator(this, function(_a) {
|
|
17597
|
+
switch (_a.label) {
|
|
17598
|
+
case 0:
|
|
17599
|
+
return [4, this.ensureConnected()];
|
|
17600
|
+
case 1:
|
|
17601
|
+
_a.sent();
|
|
17602
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPRecv, createHandleAndSizePayload(this.handle, maxSize), messages_1.NaClToJSMessageType.TCPRecv, 2147483647)];
|
|
17603
|
+
case 2:
|
|
17604
|
+
result = _a.sent();
|
|
17605
|
+
return [2, result.payload];
|
|
17606
|
+
}
|
|
17607
|
+
});
|
|
17608
|
+
});
|
|
17403
17609
|
};
|
|
17404
|
-
|
|
17610
|
+
NaClTCPPacketConnection2.prototype.collectFrame = function(options) {
|
|
17405
17611
|
return __awaiter(this, void 0, void 0, function() {
|
|
17406
|
-
var
|
|
17612
|
+
var createResult;
|
|
17407
17613
|
return __generator(this, function(_a) {
|
|
17408
17614
|
switch (_a.label) {
|
|
17409
17615
|
case 0:
|
|
17410
|
-
|
|
17411
|
-
type: messages_1.JSToNaClMessageType.Flush
|
|
17412
|
-
};
|
|
17413
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.FlushResult)];
|
|
17616
|
+
return [4, this.ensureConnected()];
|
|
17414
17617
|
case 1:
|
|
17415
|
-
|
|
17416
|
-
|
|
17417
|
-
return [
|
|
17618
|
+
_a.sent();
|
|
17619
|
+
if (!!this.frameCollector) return [3, 3];
|
|
17620
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.CollectorCreate, createHandleAndSizePayload(this.handle, this.maxPacketSize), messages_1.NaClToJSMessageType.CollectorCreate)];
|
|
17621
|
+
case 2:
|
|
17622
|
+
createResult = _a.sent();
|
|
17623
|
+
this.frameCollector = new NaClFrameCollector(this.messageSender, new DataView(createResult.payload).getUint32(0, true));
|
|
17624
|
+
_a.label = 3;
|
|
17625
|
+
case 3:
|
|
17626
|
+
if (!!this.frameCollectorStarted) return [3, 5];
|
|
17627
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.CollectorStart, createHandlePayload(this.frameCollector.getHandle()), messages_1.NaClToJSMessageType.CollectorStart)];
|
|
17628
|
+
case 4:
|
|
17629
|
+
_a.sent();
|
|
17630
|
+
this.frameCollectorStarted = true;
|
|
17631
|
+
_a.label = 5;
|
|
17632
|
+
case 5:
|
|
17633
|
+
return [2, this.frameCollector.collectFrame(options)];
|
|
17418
17634
|
}
|
|
17419
17635
|
});
|
|
17420
17636
|
});
|
|
17421
17637
|
};
|
|
17422
|
-
|
|
17638
|
+
NaClTCPPacketConnection2.prototype.close = function() {
|
|
17423
17639
|
return __awaiter(this, void 0, void 0, function() {
|
|
17424
|
-
var
|
|
17640
|
+
var handle;
|
|
17425
17641
|
return __generator(this, function(_a) {
|
|
17426
17642
|
switch (_a.label) {
|
|
17427
17643
|
case 0:
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
};
|
|
17431
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.ResetResult)];
|
|
17644
|
+
if (!this.frameCollector) return [3, 2];
|
|
17645
|
+
return [4, this.frameCollector.destroy()];
|
|
17432
17646
|
case 1:
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17647
|
+
_a.sent();
|
|
17648
|
+
this.frameCollector = null;
|
|
17649
|
+
_a.label = 2;
|
|
17650
|
+
case 2:
|
|
17651
|
+
if (!(this.handle !== 0)) return [3, 4];
|
|
17652
|
+
handle = this.handle;
|
|
17653
|
+
this.handle = 0;
|
|
17654
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPClose, createHandlePayload(handle), messages_1.NaClToJSMessageType.TCPClose)];
|
|
17655
|
+
case 3:
|
|
17656
|
+
_a.sent();
|
|
17657
|
+
_a.label = 4;
|
|
17658
|
+
case 4:
|
|
17659
|
+
return [
|
|
17660
|
+
2
|
|
17661
|
+
/*return*/
|
|
17662
|
+
];
|
|
17436
17663
|
}
|
|
17437
17664
|
});
|
|
17438
17665
|
});
|
|
17439
17666
|
};
|
|
17440
|
-
|
|
17667
|
+
NaClTCPPacketConnection2.prototype.ensureConnected = function() {
|
|
17441
17668
|
return __awaiter(this, void 0, void 0, function() {
|
|
17442
|
-
var firstUint32Array, secondInt32Array, message, resultMessage, resultStatus;
|
|
17443
17669
|
return __generator(this, function(_a) {
|
|
17444
17670
|
switch (_a.label) {
|
|
17445
17671
|
case 0:
|
|
17446
|
-
|
|
17447
|
-
picture.decodeId,
|
|
17448
|
-
picture.textureId,
|
|
17449
|
-
picture.textureTarget
|
|
17450
|
-
]);
|
|
17451
|
-
secondInt32Array = new Int32Array([
|
|
17452
|
-
picture.textureSize.width,
|
|
17453
|
-
picture.textureSize.height,
|
|
17454
|
-
picture.visibleRect.x,
|
|
17455
|
-
picture.visibleRect.y,
|
|
17456
|
-
picture.visibleRect.width,
|
|
17457
|
-
picture.visibleRect.height
|
|
17458
|
-
]);
|
|
17459
|
-
message = {
|
|
17460
|
-
type: messages_1.JSToNaClMessageType.Render,
|
|
17461
|
-
payload: new Uint8Array(__spreadArray(__spreadArray([], __read(new Uint8Array(firstUint32Array.buffer)), false), __read(new Uint8Array(secondInt32Array.buffer)), false)).buffer
|
|
17462
|
-
};
|
|
17463
|
-
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.RenderResult)];
|
|
17672
|
+
return [4, this.isConnecting()];
|
|
17464
17673
|
case 1:
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17674
|
+
if (_a.sent()) {
|
|
17675
|
+
throw new Error("Connection is still in progress");
|
|
17676
|
+
}
|
|
17677
|
+
return [4, this.isConnected()];
|
|
17678
|
+
case 2:
|
|
17679
|
+
if (!_a.sent()) {
|
|
17680
|
+
throw new Error("Connection is not active");
|
|
17681
|
+
}
|
|
17682
|
+
return [
|
|
17683
|
+
2
|
|
17684
|
+
/*return*/
|
|
17685
|
+
];
|
|
17468
17686
|
}
|
|
17469
17687
|
});
|
|
17470
17688
|
});
|
|
17471
17689
|
};
|
|
17472
|
-
return
|
|
17690
|
+
return NaClTCPPacketConnection2;
|
|
17473
17691
|
}()
|
|
17474
17692
|
);
|
|
17475
|
-
exports.
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
|
|
17693
|
+
exports.NaClTCPPacketConnection = NaClTCPPacketConnection;
|
|
17694
|
+
var NaClTCPStreamConnection = (
|
|
17695
|
+
/** @class */
|
|
17696
|
+
function() {
|
|
17697
|
+
function NaClTCPStreamConnection2(messageSender, handle) {
|
|
17698
|
+
this.messageSender = messageSender;
|
|
17699
|
+
this.handle = handle;
|
|
17700
|
+
}
|
|
17701
|
+
NaClTCPStreamConnection2.prototype.write = function(data) {
|
|
17702
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17703
|
+
return __generator(this, function(_a) {
|
|
17704
|
+
switch (_a.label) {
|
|
17705
|
+
case 0:
|
|
17706
|
+
return [4, this.ensureConnected()];
|
|
17707
|
+
case 1:
|
|
17708
|
+
_a.sent();
|
|
17709
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPStreamWrite, createHandleAndDataPayload(this.handle, data), messages_1.NaClToJSMessageType.TCPStreamWrite)];
|
|
17710
|
+
case 2:
|
|
17711
|
+
_a.sent();
|
|
17712
|
+
return [
|
|
17713
|
+
2
|
|
17714
|
+
/*return*/
|
|
17715
|
+
];
|
|
17716
|
+
}
|
|
17717
|
+
});
|
|
17718
|
+
});
|
|
17719
|
+
};
|
|
17720
|
+
NaClTCPStreamConnection2.prototype.read = function() {
|
|
17721
|
+
return __awaiter(this, arguments, void 0, function(maxSize) {
|
|
17722
|
+
var result;
|
|
17723
|
+
if (maxSize === void 0) {
|
|
17724
|
+
maxSize = DEFAULT_MAX_PACKET_SIZE;
|
|
17725
|
+
}
|
|
17726
|
+
return __generator(this, function(_a) {
|
|
17727
|
+
switch (_a.label) {
|
|
17728
|
+
case 0:
|
|
17729
|
+
return [4, this.ensureConnected()];
|
|
17730
|
+
case 1:
|
|
17731
|
+
_a.sent();
|
|
17732
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPStreamRead, createHandleAndSizePayload(this.handle, maxSize), messages_1.NaClToJSMessageType.TCPStreamRead, 2147483647)];
|
|
17733
|
+
case 2:
|
|
17734
|
+
result = _a.sent();
|
|
17735
|
+
return [2, result.payload];
|
|
17736
|
+
}
|
|
17737
|
+
});
|
|
17738
|
+
});
|
|
17739
|
+
};
|
|
17740
|
+
NaClTCPStreamConnection2.prototype.close = function() {
|
|
17741
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17742
|
+
var handle;
|
|
17743
|
+
return __generator(this, function(_a) {
|
|
17744
|
+
switch (_a.label) {
|
|
17745
|
+
case 0:
|
|
17746
|
+
if (!(this.handle !== 0)) return [3, 2];
|
|
17747
|
+
handle = this.handle;
|
|
17748
|
+
this.handle = 0;
|
|
17749
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPClose, createHandlePayload(handle), messages_1.NaClToJSMessageType.TCPClose)];
|
|
17750
|
+
case 1:
|
|
17751
|
+
_a.sent();
|
|
17752
|
+
_a.label = 2;
|
|
17753
|
+
case 2:
|
|
17754
|
+
return [
|
|
17755
|
+
2
|
|
17756
|
+
/*return*/
|
|
17757
|
+
];
|
|
17758
|
+
}
|
|
17759
|
+
});
|
|
17760
|
+
});
|
|
17761
|
+
};
|
|
17762
|
+
NaClTCPStreamConnection2.prototype.ensureConnected = function() {
|
|
17763
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17764
|
+
var result, state;
|
|
17765
|
+
return __generator(this, function(_a) {
|
|
17766
|
+
switch (_a.label) {
|
|
17767
|
+
case 0:
|
|
17768
|
+
if (this.handle === 0) {
|
|
17769
|
+
throw new Error("Connection is not active");
|
|
17770
|
+
}
|
|
17771
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPIsConnected, createHandlePayload(this.handle), messages_1.NaClToJSMessageType.TCPIsConnected)];
|
|
17772
|
+
case 1:
|
|
17773
|
+
result = _a.sent();
|
|
17774
|
+
state = new Int8Array(result.payload)[0];
|
|
17775
|
+
if (state === -1) {
|
|
17776
|
+
throw new Error("Connection is still in progress");
|
|
17777
|
+
}
|
|
17778
|
+
if (state !== 1) {
|
|
17779
|
+
throw new Error("Connection is not active");
|
|
17780
|
+
}
|
|
17781
|
+
return [
|
|
17782
|
+
2
|
|
17783
|
+
/*return*/
|
|
17784
|
+
];
|
|
17785
|
+
}
|
|
17786
|
+
});
|
|
17787
|
+
});
|
|
17788
|
+
};
|
|
17789
|
+
return NaClTCPStreamConnection2;
|
|
17790
|
+
}()
|
|
17791
|
+
);
|
|
17792
|
+
exports.NaClTCPStreamConnection = NaClTCPStreamConnection;
|
|
17793
|
+
var NaClTCPPacket2 = (
|
|
17794
|
+
/** @class */
|
|
17795
|
+
function() {
|
|
17796
|
+
function NaClTCPPacket3(messageSender) {
|
|
17797
|
+
this.messageSender = messageSender;
|
|
17798
|
+
}
|
|
17799
|
+
NaClTCPPacket3.prototype.connect = function(options) {
|
|
17800
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17801
|
+
var result;
|
|
17802
|
+
var _a;
|
|
17803
|
+
return __generator(this, function(_b) {
|
|
17804
|
+
switch (_b.label) {
|
|
17805
|
+
case 0:
|
|
17806
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPConnect, createConnectPayload(0, options), messages_1.NaClToJSMessageType.TCPConnect, options.timeoutMs + CONNECT_LATE_RESULT_GRACE_MS)];
|
|
17807
|
+
case 1:
|
|
17808
|
+
result = _b.sent();
|
|
17809
|
+
return [2, new NaClTCPPacketConnection(this.messageSender, new DataView(result.payload).getUint32(0, true), (_a = options.maxPacketSize) !== null && _a !== void 0 ? _a : DEFAULT_MAX_PACKET_SIZE)];
|
|
17810
|
+
}
|
|
17811
|
+
});
|
|
17812
|
+
});
|
|
17813
|
+
};
|
|
17814
|
+
return NaClTCPPacket3;
|
|
17815
|
+
}()
|
|
17816
|
+
);
|
|
17817
|
+
exports.NaClTCPPacket = NaClTCPPacket2;
|
|
17818
|
+
var NaClTCPStream2 = (
|
|
17819
|
+
/** @class */
|
|
17820
|
+
function() {
|
|
17821
|
+
function NaClTCPStream3(messageSender) {
|
|
17822
|
+
this.messageSender = messageSender;
|
|
17823
|
+
}
|
|
17824
|
+
NaClTCPStream3.prototype.connect = function(options) {
|
|
17825
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17826
|
+
var result;
|
|
17827
|
+
return __generator(this, function(_a) {
|
|
17828
|
+
switch (_a.label) {
|
|
17829
|
+
case 0:
|
|
17830
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.TCPConnect, createConnectPayload(1, options), messages_1.NaClToJSMessageType.TCPConnect, options.timeoutMs + CONNECT_LATE_RESULT_GRACE_MS)];
|
|
17831
|
+
case 1:
|
|
17832
|
+
result = _a.sent();
|
|
17833
|
+
return [2, new NaClTCPStreamConnection(this.messageSender, new DataView(result.payload).getUint32(0, true))];
|
|
17834
|
+
}
|
|
17835
|
+
});
|
|
17836
|
+
});
|
|
17837
|
+
};
|
|
17838
|
+
return NaClTCPStream3;
|
|
17839
|
+
}()
|
|
17840
|
+
);
|
|
17841
|
+
exports.NaClTCPStream = NaClTCPStream2;
|
|
17842
|
+
}
|
|
17843
|
+
});
|
|
17844
|
+
|
|
17845
|
+
// node_modules/@signageos/nacl-decoder/dist/NaClDecoder/naclDecoder.js
|
|
17846
|
+
var require_naclDecoder = __commonJS({
|
|
17847
|
+
"node_modules/@signageos/nacl-decoder/dist/NaClDecoder/naclDecoder.js"(exports) {
|
|
17848
|
+
"use strict";
|
|
17849
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
17850
|
+
function adopt(value) {
|
|
17851
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
17852
|
+
resolve(value);
|
|
17853
|
+
});
|
|
17854
|
+
}
|
|
17855
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
17856
|
+
function fulfilled(value) {
|
|
17857
|
+
try {
|
|
17858
|
+
step(generator.next(value));
|
|
17859
|
+
} catch (e) {
|
|
17860
|
+
reject(e);
|
|
17861
|
+
}
|
|
17862
|
+
}
|
|
17863
|
+
function rejected(value) {
|
|
17864
|
+
try {
|
|
17865
|
+
step(generator["throw"](value));
|
|
17866
|
+
} catch (e) {
|
|
17867
|
+
reject(e);
|
|
17868
|
+
}
|
|
17869
|
+
}
|
|
17870
|
+
function step(result) {
|
|
17871
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
17872
|
+
}
|
|
17873
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17874
|
+
});
|
|
17875
|
+
};
|
|
17876
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
17877
|
+
var _ = { label: 0, sent: function() {
|
|
17878
|
+
if (t[0] & 1) throw t[1];
|
|
17879
|
+
return t[1];
|
|
17880
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
17881
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
17882
|
+
return this;
|
|
17883
|
+
}), g;
|
|
17884
|
+
function verb(n) {
|
|
17885
|
+
return function(v) {
|
|
17886
|
+
return step([n, v]);
|
|
17887
|
+
};
|
|
17888
|
+
}
|
|
17889
|
+
function step(op) {
|
|
17890
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17891
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17892
|
+
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;
|
|
17893
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
17894
|
+
switch (op[0]) {
|
|
17895
|
+
case 0:
|
|
17896
|
+
case 1:
|
|
17897
|
+
t = op;
|
|
17898
|
+
break;
|
|
17899
|
+
case 4:
|
|
17900
|
+
_.label++;
|
|
17901
|
+
return { value: op[1], done: false };
|
|
17902
|
+
case 5:
|
|
17903
|
+
_.label++;
|
|
17904
|
+
y = op[1];
|
|
17905
|
+
op = [0];
|
|
17906
|
+
continue;
|
|
17907
|
+
case 7:
|
|
17908
|
+
op = _.ops.pop();
|
|
17909
|
+
_.trys.pop();
|
|
17910
|
+
continue;
|
|
17911
|
+
default:
|
|
17912
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
17913
|
+
_ = 0;
|
|
17914
|
+
continue;
|
|
17915
|
+
}
|
|
17916
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
17917
|
+
_.label = op[1];
|
|
17918
|
+
break;
|
|
17919
|
+
}
|
|
17920
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
17921
|
+
_.label = t[1];
|
|
17922
|
+
t = op;
|
|
17923
|
+
break;
|
|
17924
|
+
}
|
|
17925
|
+
if (t && _.label < t[2]) {
|
|
17926
|
+
_.label = t[2];
|
|
17927
|
+
_.ops.push(op);
|
|
17928
|
+
break;
|
|
17929
|
+
}
|
|
17930
|
+
if (t[2]) _.ops.pop();
|
|
17931
|
+
_.trys.pop();
|
|
17932
|
+
continue;
|
|
17933
|
+
}
|
|
17934
|
+
op = body.call(thisArg, _);
|
|
17935
|
+
} catch (e) {
|
|
17936
|
+
op = [6, e];
|
|
17937
|
+
y = 0;
|
|
17938
|
+
} finally {
|
|
17939
|
+
f = t = 0;
|
|
17940
|
+
}
|
|
17941
|
+
if (op[0] & 5) throw op[1];
|
|
17942
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
17943
|
+
}
|
|
17944
|
+
};
|
|
17945
|
+
var __read = exports && exports.__read || function(o, n) {
|
|
17946
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
17947
|
+
if (!m) return o;
|
|
17948
|
+
var i = m.call(o), r, ar = [], e;
|
|
17949
|
+
try {
|
|
17950
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
17951
|
+
} catch (error) {
|
|
17952
|
+
e = { error };
|
|
17953
|
+
} finally {
|
|
17954
|
+
try {
|
|
17955
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17956
|
+
} finally {
|
|
17957
|
+
if (e) throw e.error;
|
|
17958
|
+
}
|
|
17959
|
+
}
|
|
17960
|
+
return ar;
|
|
17961
|
+
};
|
|
17962
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
17963
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
17964
|
+
if (ar || !(i in from)) {
|
|
17965
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17966
|
+
ar[i] = from[i];
|
|
17967
|
+
}
|
|
17968
|
+
}
|
|
17969
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
17970
|
+
};
|
|
17971
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17972
|
+
exports.NaClDecoder = void 0;
|
|
17973
|
+
var messages_1 = require_messages();
|
|
17974
|
+
var module_1 = require_module();
|
|
17975
|
+
var naclTCP_1 = require_naclTCP();
|
|
17976
|
+
var NaClDecoder = (
|
|
17977
|
+
/** @class */
|
|
17978
|
+
function() {
|
|
17979
|
+
function NaClDecoder2(messageSender, naclModuleEl) {
|
|
17980
|
+
this.messageSender = messageSender;
|
|
17981
|
+
this.naclModuleEl = naclModuleEl;
|
|
17982
|
+
}
|
|
17983
|
+
NaClDecoder2.prototype.destroy = function() {
|
|
17984
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17985
|
+
return __generator(this, function(_a) {
|
|
17986
|
+
(0, module_1.removeNaClModule)(this.naclModuleEl);
|
|
17987
|
+
return [
|
|
17988
|
+
2
|
|
17989
|
+
/*return*/
|
|
17990
|
+
];
|
|
17991
|
+
});
|
|
17992
|
+
});
|
|
17993
|
+
};
|
|
17994
|
+
NaClDecoder2.prototype.initialize = function(args) {
|
|
17995
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
17996
|
+
var width, height, message, resultMessage, resultStatus;
|
|
17997
|
+
var _a, _b;
|
|
17998
|
+
return __generator(this, function(_c) {
|
|
17999
|
+
switch (_c.label) {
|
|
18000
|
+
case 0:
|
|
18001
|
+
width = (_a = args.graphics3DContext.width) !== null && _a !== void 0 ? _a : window.screen.width;
|
|
18002
|
+
height = (_b = args.graphics3DContext.height) !== null && _b !== void 0 ? _b : window.screen.height;
|
|
18003
|
+
message = {
|
|
18004
|
+
type: messages_1.JSToNaClMessageType.Initialize,
|
|
18005
|
+
payload: new Uint8Array(__spreadArray(__spreadArray([
|
|
18006
|
+
args.profile,
|
|
18007
|
+
args.acceleration
|
|
18008
|
+
], __read(new Uint8Array(new Uint32Array([args.minPictureCount]).buffer)), false), __read(new Uint8Array(new Int32Array([width, height]).buffer)), false)).buffer
|
|
18009
|
+
};
|
|
18010
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.InitializeResult)];
|
|
18011
|
+
case 1:
|
|
18012
|
+
resultMessage = _c.sent();
|
|
18013
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18014
|
+
return [2, resultStatus];
|
|
18015
|
+
}
|
|
18016
|
+
});
|
|
18017
|
+
});
|
|
18018
|
+
};
|
|
18019
|
+
NaClDecoder2.prototype.decodeAndRender = function(data) {
|
|
18020
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18021
|
+
var message, resultMessage, resultStatus;
|
|
18022
|
+
return __generator(this, function(_a) {
|
|
18023
|
+
switch (_a.label) {
|
|
18024
|
+
case 0:
|
|
18025
|
+
if (!(data instanceof ArrayBuffer)) {
|
|
18026
|
+
throw new Error("Unexpected data type. Only ArrayBuffer is supported.");
|
|
18027
|
+
}
|
|
18028
|
+
message = {
|
|
18029
|
+
type: messages_1.JSToNaClMessageType.DecodeAndRender,
|
|
18030
|
+
payload: data
|
|
18031
|
+
};
|
|
18032
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.DecodeAndRenderResult)];
|
|
18033
|
+
case 1:
|
|
18034
|
+
resultMessage = _a.sent();
|
|
18035
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18036
|
+
return [2, resultStatus];
|
|
18037
|
+
}
|
|
18038
|
+
});
|
|
18039
|
+
});
|
|
18040
|
+
};
|
|
18041
|
+
NaClDecoder2.prototype.decodeAndRenderRef = function(dataRef) {
|
|
18042
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18043
|
+
var payload, resultMessage;
|
|
18044
|
+
return __generator(this, function(_a) {
|
|
18045
|
+
switch (_a.label) {
|
|
18046
|
+
case 0:
|
|
18047
|
+
payload = new ArrayBuffer(4);
|
|
18048
|
+
new DataView(payload).setUint32(0, dataRef, true);
|
|
18049
|
+
return [4, this.messageSender.sendWithRequestId(messages_1.JSToNaClMessageType.DecodeAndRenderRef, payload, messages_1.NaClToJSMessageType.DecodeAndRenderRef)];
|
|
18050
|
+
case 1:
|
|
18051
|
+
resultMessage = _a.sent();
|
|
18052
|
+
return [2, resultMessage.status];
|
|
18053
|
+
}
|
|
18054
|
+
});
|
|
18055
|
+
});
|
|
18056
|
+
};
|
|
18057
|
+
NaClDecoder2.prototype.createTCP = function() {
|
|
18058
|
+
return {
|
|
18059
|
+
tcpPacket: new naclTCP_1.NaClTCPPacket(this.messageSender),
|
|
18060
|
+
tcpStream: new naclTCP_1.NaClTCPStream(this.messageSender)
|
|
18061
|
+
};
|
|
18062
|
+
};
|
|
18063
|
+
NaClDecoder2.prototype.decode = function(args) {
|
|
18064
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18065
|
+
var message, resultMessage, resultStatus;
|
|
18066
|
+
return __generator(this, function(_a) {
|
|
18067
|
+
switch (_a.label) {
|
|
18068
|
+
case 0:
|
|
18069
|
+
if (!(args.data instanceof ArrayBuffer)) {
|
|
18070
|
+
throw new Error("Unexpected data type. Only ArrayBuffer is supported.");
|
|
18071
|
+
}
|
|
18072
|
+
message = {
|
|
18073
|
+
type: messages_1.JSToNaClMessageType.Decode,
|
|
18074
|
+
// TODO decodeId (not used in the NaCl module now)
|
|
18075
|
+
payload: args.data
|
|
18076
|
+
};
|
|
18077
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.DecodeResult)];
|
|
18078
|
+
case 1:
|
|
18079
|
+
resultMessage = _a.sent();
|
|
18080
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18081
|
+
return [2, resultStatus];
|
|
18082
|
+
}
|
|
18083
|
+
});
|
|
18084
|
+
});
|
|
18085
|
+
};
|
|
18086
|
+
NaClDecoder2.prototype.getPicture = function() {
|
|
18087
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18088
|
+
var message, resultMessage, resultFirstUInt32Array, resultSecondInt32Array, picture;
|
|
18089
|
+
return __generator(this, function(_a) {
|
|
18090
|
+
switch (_a.label) {
|
|
18091
|
+
case 0:
|
|
18092
|
+
message = {
|
|
18093
|
+
type: messages_1.JSToNaClMessageType.GetPicture
|
|
18094
|
+
};
|
|
18095
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.GetPictureResult)];
|
|
18096
|
+
case 1:
|
|
18097
|
+
resultMessage = _a.sent();
|
|
18098
|
+
resultFirstUInt32Array = new Uint32Array(resultMessage.payload.slice(0, 12));
|
|
18099
|
+
resultSecondInt32Array = new Int32Array(resultMessage.payload.slice(12, 36));
|
|
18100
|
+
picture = {
|
|
18101
|
+
decodeId: resultFirstUInt32Array[0],
|
|
18102
|
+
textureId: resultFirstUInt32Array[1],
|
|
18103
|
+
textureTarget: resultFirstUInt32Array[2],
|
|
18104
|
+
textureSize: {
|
|
18105
|
+
width: resultSecondInt32Array[0],
|
|
18106
|
+
height: resultSecondInt32Array[1]
|
|
18107
|
+
},
|
|
18108
|
+
visibleRect: {
|
|
18109
|
+
x: resultSecondInt32Array[2],
|
|
18110
|
+
y: resultSecondInt32Array[3],
|
|
18111
|
+
width: resultSecondInt32Array[4],
|
|
18112
|
+
height: resultSecondInt32Array[5]
|
|
18113
|
+
}
|
|
18114
|
+
};
|
|
18115
|
+
return [2, picture];
|
|
18116
|
+
}
|
|
18117
|
+
});
|
|
18118
|
+
});
|
|
18119
|
+
};
|
|
18120
|
+
NaClDecoder2.prototype.recyclePicture = function(picture) {
|
|
18121
|
+
var firstUint32Array = new Uint32Array([
|
|
18122
|
+
picture.decodeId,
|
|
18123
|
+
picture.textureId,
|
|
18124
|
+
picture.textureTarget
|
|
18125
|
+
]);
|
|
18126
|
+
var secondInt32Array = new Int32Array([
|
|
18127
|
+
picture.textureSize.width,
|
|
18128
|
+
picture.textureSize.height,
|
|
18129
|
+
picture.visibleRect.x,
|
|
18130
|
+
picture.visibleRect.y,
|
|
18131
|
+
picture.visibleRect.width,
|
|
18132
|
+
picture.visibleRect.height
|
|
18133
|
+
]);
|
|
18134
|
+
var message = {
|
|
18135
|
+
type: messages_1.JSToNaClMessageType.RecyclePicture,
|
|
18136
|
+
payload: new Uint8Array(__spreadArray(__spreadArray([], __read(new Uint8Array(firstUint32Array.buffer)), false), __read(new Uint8Array(secondInt32Array.buffer)), false)).buffer
|
|
18137
|
+
};
|
|
18138
|
+
this.messageSender.sendWithoutResult(message);
|
|
18139
|
+
};
|
|
18140
|
+
NaClDecoder2.prototype.flush = function() {
|
|
18141
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18142
|
+
var message, resultMessage, resultStatus;
|
|
18143
|
+
return __generator(this, function(_a) {
|
|
18144
|
+
switch (_a.label) {
|
|
18145
|
+
case 0:
|
|
18146
|
+
message = {
|
|
18147
|
+
type: messages_1.JSToNaClMessageType.Flush
|
|
18148
|
+
};
|
|
18149
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.FlushResult)];
|
|
18150
|
+
case 1:
|
|
18151
|
+
resultMessage = _a.sent();
|
|
18152
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18153
|
+
return [2, resultStatus];
|
|
18154
|
+
}
|
|
18155
|
+
});
|
|
18156
|
+
});
|
|
18157
|
+
};
|
|
18158
|
+
NaClDecoder2.prototype.reset = function() {
|
|
18159
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18160
|
+
var message, resultMessage, resultStatus;
|
|
18161
|
+
return __generator(this, function(_a) {
|
|
18162
|
+
switch (_a.label) {
|
|
18163
|
+
case 0:
|
|
18164
|
+
message = {
|
|
18165
|
+
type: messages_1.JSToNaClMessageType.Reset
|
|
18166
|
+
};
|
|
18167
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.ResetResult)];
|
|
18168
|
+
case 1:
|
|
18169
|
+
resultMessage = _a.sent();
|
|
18170
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18171
|
+
return [2, resultStatus];
|
|
18172
|
+
}
|
|
18173
|
+
});
|
|
18174
|
+
});
|
|
18175
|
+
};
|
|
18176
|
+
NaClDecoder2.prototype.render = function(picture) {
|
|
18177
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18178
|
+
var firstUint32Array, secondInt32Array, message, resultMessage, resultStatus;
|
|
18179
|
+
return __generator(this, function(_a) {
|
|
18180
|
+
switch (_a.label) {
|
|
18181
|
+
case 0:
|
|
18182
|
+
firstUint32Array = new Uint32Array([
|
|
18183
|
+
picture.decodeId,
|
|
18184
|
+
picture.textureId,
|
|
18185
|
+
picture.textureTarget
|
|
18186
|
+
]);
|
|
18187
|
+
secondInt32Array = new Int32Array([
|
|
18188
|
+
picture.textureSize.width,
|
|
18189
|
+
picture.textureSize.height,
|
|
18190
|
+
picture.visibleRect.x,
|
|
18191
|
+
picture.visibleRect.y,
|
|
18192
|
+
picture.visibleRect.width,
|
|
18193
|
+
picture.visibleRect.height
|
|
18194
|
+
]);
|
|
18195
|
+
message = {
|
|
18196
|
+
type: messages_1.JSToNaClMessageType.Render,
|
|
18197
|
+
payload: new Uint8Array(__spreadArray(__spreadArray([], __read(new Uint8Array(firstUint32Array.buffer)), false), __read(new Uint8Array(secondInt32Array.buffer)), false)).buffer
|
|
18198
|
+
};
|
|
18199
|
+
return [4, this.messageSender.sendWithResult(message, messages_1.NaClToJSMessageType.RenderResult)];
|
|
18200
|
+
case 1:
|
|
18201
|
+
resultMessage = _a.sent();
|
|
18202
|
+
resultStatus = new Int32Array(resultMessage.payload)[0];
|
|
18203
|
+
return [2, resultStatus];
|
|
18204
|
+
}
|
|
18205
|
+
});
|
|
18206
|
+
});
|
|
18207
|
+
};
|
|
18208
|
+
return NaClDecoder2;
|
|
18209
|
+
}()
|
|
18210
|
+
);
|
|
18211
|
+
exports.NaClDecoder = NaClDecoder;
|
|
18212
|
+
}
|
|
18213
|
+
});
|
|
18214
|
+
|
|
18215
|
+
// node_modules/@signageos/nacl-decoder/dist/NaClDecoder/videoDecoder.js
|
|
18216
|
+
var require_videoDecoder = __commonJS({
|
|
18217
|
+
"node_modules/@signageos/nacl-decoder/dist/NaClDecoder/videoDecoder.js"(exports) {
|
|
18218
|
+
"use strict";
|
|
18219
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18220
|
+
exports.ResultStatus = exports.GLTexture = exports.HWAcceleration = exports.VideoProfile = void 0;
|
|
18221
|
+
var VideoProfile;
|
|
18222
|
+
(function(VideoProfile2) {
|
|
18223
|
+
VideoProfile2[VideoProfile2["H264Baseline"] = 0] = "H264Baseline";
|
|
18224
|
+
VideoProfile2[VideoProfile2["H264Main"] = 1] = "H264Main";
|
|
18225
|
+
VideoProfile2[VideoProfile2["H264Extended"] = 2] = "H264Extended";
|
|
18226
|
+
VideoProfile2[VideoProfile2["H264High"] = 3] = "H264High";
|
|
17491
18227
|
VideoProfile2[VideoProfile2["H264High10Profile"] = 4] = "H264High10Profile";
|
|
17492
18228
|
VideoProfile2[VideoProfile2["H264High422Profile"] = 5] = "H264High422Profile";
|
|
17493
18229
|
VideoProfile2[VideoProfile2["H264High444PredictiveProfile"] = 6] = "H264High444PredictiveProfile";
|
|
@@ -17532,62 +18268,1859 @@ var require_videoDecoder = __commonJS({
|
|
|
17532
18268
|
}
|
|
17533
18269
|
});
|
|
17534
18270
|
|
|
17535
|
-
// node_modules/@signageos/nacl-decoder/dist/index.js
|
|
17536
|
-
var require_dist = __commonJS({
|
|
17537
|
-
"node_modules/@signageos/nacl-decoder/dist/index.js"(exports) {
|
|
18271
|
+
// node_modules/@signageos/nacl-decoder/dist/index.js
|
|
18272
|
+
var require_dist = __commonJS({
|
|
18273
|
+
"node_modules/@signageos/nacl-decoder/dist/index.js"(exports) {
|
|
18274
|
+
"use strict";
|
|
18275
|
+
var __assign = exports && exports.__assign || function() {
|
|
18276
|
+
__assign = Object.assign || function(t) {
|
|
18277
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18278
|
+
s = arguments[i];
|
|
18279
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18280
|
+
t[p] = s[p];
|
|
18281
|
+
}
|
|
18282
|
+
return t;
|
|
18283
|
+
};
|
|
18284
|
+
return __assign.apply(this, arguments);
|
|
18285
|
+
};
|
|
18286
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18287
|
+
exports.NaClTCPStreamConnection = exports.NaClTCPStream = exports.NaClTCPPacketConnection = exports.NaClTCPPacket = exports.NaClFrameCollector = exports.VideoProfile = exports.ResultStatus = exports.HWAcceleration = exports.NaClDecoder = void 0;
|
|
18288
|
+
exports.isNaClSupported = isNaClSupported3;
|
|
18289
|
+
exports.createNaClDecoder = createNaClDecoder2;
|
|
18290
|
+
exports.createNaClTCP = createNaClTCP2;
|
|
18291
|
+
var messageListeners_1 = require_messageListeners();
|
|
18292
|
+
var messageReceiver_1 = require_messageReceiver();
|
|
18293
|
+
var messageSender_1 = require_messageSender();
|
|
18294
|
+
var module_1 = require_module();
|
|
18295
|
+
var naclDecoder_1 = require_naclDecoder();
|
|
18296
|
+
Object.defineProperty(exports, "NaClDecoder", { enumerable: true, get: function() {
|
|
18297
|
+
return naclDecoder_1.NaClDecoder;
|
|
18298
|
+
} });
|
|
18299
|
+
var naclTCP_1 = require_naclTCP();
|
|
18300
|
+
Object.defineProperty(exports, "NaClFrameCollector", { enumerable: true, get: function() {
|
|
18301
|
+
return naclTCP_1.NaClFrameCollector;
|
|
18302
|
+
} });
|
|
18303
|
+
Object.defineProperty(exports, "NaClTCPPacket", { enumerable: true, get: function() {
|
|
18304
|
+
return naclTCP_1.NaClTCPPacket;
|
|
18305
|
+
} });
|
|
18306
|
+
Object.defineProperty(exports, "NaClTCPPacketConnection", { enumerable: true, get: function() {
|
|
18307
|
+
return naclTCP_1.NaClTCPPacketConnection;
|
|
18308
|
+
} });
|
|
18309
|
+
Object.defineProperty(exports, "NaClTCPStream", { enumerable: true, get: function() {
|
|
18310
|
+
return naclTCP_1.NaClTCPStream;
|
|
18311
|
+
} });
|
|
18312
|
+
Object.defineProperty(exports, "NaClTCPStreamConnection", { enumerable: true, get: function() {
|
|
18313
|
+
return naclTCP_1.NaClTCPStreamConnection;
|
|
18314
|
+
} });
|
|
18315
|
+
var videoDecoder_1 = require_videoDecoder();
|
|
18316
|
+
Object.defineProperty(exports, "HWAcceleration", { enumerable: true, get: function() {
|
|
18317
|
+
return videoDecoder_1.HWAcceleration;
|
|
18318
|
+
} });
|
|
18319
|
+
Object.defineProperty(exports, "ResultStatus", { enumerable: true, get: function() {
|
|
18320
|
+
return videoDecoder_1.ResultStatus;
|
|
18321
|
+
} });
|
|
18322
|
+
Object.defineProperty(exports, "VideoProfile", { enumerable: true, get: function() {
|
|
18323
|
+
return videoDecoder_1.VideoProfile;
|
|
18324
|
+
} });
|
|
18325
|
+
var DEFAULT_OPTIONS = {
|
|
18326
|
+
timeoutMs: 1e3
|
|
18327
|
+
};
|
|
18328
|
+
var naclRuntime = null;
|
|
18329
|
+
function isNaClSupported3() {
|
|
18330
|
+
return (
|
|
18331
|
+
// Keyed by mime type supported in older versions of Chrome that uses NaCl.
|
|
18332
|
+
navigator.mimeTypes["application/x-nacl"] !== void 0
|
|
18333
|
+
);
|
|
18334
|
+
}
|
|
18335
|
+
function createNaClDecoder2(options) {
|
|
18336
|
+
var requiredOptions = __assign(__assign({}, DEFAULT_OPTIONS), options);
|
|
18337
|
+
if (!isNaClSupported3()) {
|
|
18338
|
+
throw new Error("NaCl is not supported in this browser.");
|
|
18339
|
+
}
|
|
18340
|
+
var runtime = getNaClRuntime(requiredOptions.timeoutMs);
|
|
18341
|
+
return new naclDecoder_1.NaClDecoder(runtime.messageSender, runtime.naclModuleEl);
|
|
18342
|
+
}
|
|
18343
|
+
function createNaClTCP2(options) {
|
|
18344
|
+
var decoder = createNaClDecoder2(options);
|
|
18345
|
+
return decoder.createTCP();
|
|
18346
|
+
}
|
|
18347
|
+
function getNaClRuntime(timeoutMs) {
|
|
18348
|
+
if (naclRuntime) {
|
|
18349
|
+
return naclRuntime;
|
|
18350
|
+
}
|
|
18351
|
+
var messageListeners = (0, messageListeners_1.createMessageListeners)();
|
|
18352
|
+
var messageReceiver = new messageReceiver_1.MessageReceiver(messageListeners);
|
|
18353
|
+
var naclModuleEl = (0, module_1.createNaClModule)(messageReceiver.handleMessage.bind(messageReceiver));
|
|
18354
|
+
var messageSender = new messageSender_1.MessageSender(naclModuleEl, messageListeners, timeoutMs);
|
|
18355
|
+
naclRuntime = {
|
|
18356
|
+
messageSender,
|
|
18357
|
+
naclModuleEl
|
|
18358
|
+
};
|
|
18359
|
+
return naclRuntime;
|
|
18360
|
+
}
|
|
18361
|
+
}
|
|
18362
|
+
});
|
|
18363
|
+
|
|
18364
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js
|
|
18365
|
+
var require_videoDecoder2 = __commonJS({
|
|
18366
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/videoDecoder.js"(exports) {
|
|
18367
|
+
"use strict";
|
|
18368
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18369
|
+
exports.LatencyMode = exports.ResultStatus = void 0;
|
|
18370
|
+
var ResultStatus;
|
|
18371
|
+
(function(ResultStatus2) {
|
|
18372
|
+
ResultStatus2[ResultStatus2["Ok"] = 0] = "Ok";
|
|
18373
|
+
ResultStatus2[ResultStatus2["ErrorFailed"] = -2] = "ErrorFailed";
|
|
18374
|
+
ResultStatus2[ResultStatus2["ErrorBadArgument"] = -4] = "ErrorBadArgument";
|
|
18375
|
+
ResultStatus2[ResultStatus2["ErrorNoInit"] = -6] = "ErrorNoInit";
|
|
18376
|
+
})(ResultStatus || (exports.ResultStatus = ResultStatus = {}));
|
|
18377
|
+
var LatencyMode2;
|
|
18378
|
+
(function(LatencyMode3) {
|
|
18379
|
+
LatencyMode3[LatencyMode3["Normal"] = 0] = "Normal";
|
|
18380
|
+
LatencyMode3[LatencyMode3["Low"] = 1] = "Low";
|
|
18381
|
+
LatencyMode3[LatencyMode3["UltraLow"] = 2] = "UltraLow";
|
|
18382
|
+
})(LatencyMode2 || (exports.LatencyMode = LatencyMode2 = {}));
|
|
18383
|
+
}
|
|
18384
|
+
});
|
|
18385
|
+
|
|
18386
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/dom/script.js
|
|
18387
|
+
var require_script = __commonJS({
|
|
18388
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/dom/script.js"(exports) {
|
|
18389
|
+
"use strict";
|
|
18390
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
18391
|
+
function adopt(value) {
|
|
18392
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
18393
|
+
resolve(value);
|
|
18394
|
+
});
|
|
18395
|
+
}
|
|
18396
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
18397
|
+
function fulfilled(value) {
|
|
18398
|
+
try {
|
|
18399
|
+
step(generator.next(value));
|
|
18400
|
+
} catch (e) {
|
|
18401
|
+
reject(e);
|
|
18402
|
+
}
|
|
18403
|
+
}
|
|
18404
|
+
function rejected(value) {
|
|
18405
|
+
try {
|
|
18406
|
+
step(generator["throw"](value));
|
|
18407
|
+
} catch (e) {
|
|
18408
|
+
reject(e);
|
|
18409
|
+
}
|
|
18410
|
+
}
|
|
18411
|
+
function step(result) {
|
|
18412
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
18413
|
+
}
|
|
18414
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18415
|
+
});
|
|
18416
|
+
};
|
|
18417
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
18418
|
+
var _ = { label: 0, sent: function() {
|
|
18419
|
+
if (t[0] & 1) throw t[1];
|
|
18420
|
+
return t[1];
|
|
18421
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
18422
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
18423
|
+
return this;
|
|
18424
|
+
}), g;
|
|
18425
|
+
function verb(n) {
|
|
18426
|
+
return function(v) {
|
|
18427
|
+
return step([n, v]);
|
|
18428
|
+
};
|
|
18429
|
+
}
|
|
18430
|
+
function step(op) {
|
|
18431
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18432
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18433
|
+
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;
|
|
18434
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
18435
|
+
switch (op[0]) {
|
|
18436
|
+
case 0:
|
|
18437
|
+
case 1:
|
|
18438
|
+
t = op;
|
|
18439
|
+
break;
|
|
18440
|
+
case 4:
|
|
18441
|
+
_.label++;
|
|
18442
|
+
return { value: op[1], done: false };
|
|
18443
|
+
case 5:
|
|
18444
|
+
_.label++;
|
|
18445
|
+
y = op[1];
|
|
18446
|
+
op = [0];
|
|
18447
|
+
continue;
|
|
18448
|
+
case 7:
|
|
18449
|
+
op = _.ops.pop();
|
|
18450
|
+
_.trys.pop();
|
|
18451
|
+
continue;
|
|
18452
|
+
default:
|
|
18453
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
18454
|
+
_ = 0;
|
|
18455
|
+
continue;
|
|
18456
|
+
}
|
|
18457
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
18458
|
+
_.label = op[1];
|
|
18459
|
+
break;
|
|
18460
|
+
}
|
|
18461
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
18462
|
+
_.label = t[1];
|
|
18463
|
+
t = op;
|
|
18464
|
+
break;
|
|
18465
|
+
}
|
|
18466
|
+
if (t && _.label < t[2]) {
|
|
18467
|
+
_.label = t[2];
|
|
18468
|
+
_.ops.push(op);
|
|
18469
|
+
break;
|
|
18470
|
+
}
|
|
18471
|
+
if (t[2]) _.ops.pop();
|
|
18472
|
+
_.trys.pop();
|
|
18473
|
+
continue;
|
|
18474
|
+
}
|
|
18475
|
+
op = body.call(thisArg, _);
|
|
18476
|
+
} catch (e) {
|
|
18477
|
+
op = [6, e];
|
|
18478
|
+
y = 0;
|
|
18479
|
+
} finally {
|
|
18480
|
+
f = t = 0;
|
|
18481
|
+
}
|
|
18482
|
+
if (op[0] & 5) throw op[1];
|
|
18483
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
18484
|
+
}
|
|
18485
|
+
};
|
|
18486
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18487
|
+
exports.injectScript = injectScript2;
|
|
18488
|
+
function injectScript2(url) {
|
|
18489
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18490
|
+
return __generator(this, function(_a) {
|
|
18491
|
+
return [2, new Promise(function(resolve, reject) {
|
|
18492
|
+
var scriptEl = document.createElement("script");
|
|
18493
|
+
scriptEl.src = url;
|
|
18494
|
+
document.head.appendChild(scriptEl);
|
|
18495
|
+
scriptEl.onerror = function(error) {
|
|
18496
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18497
|
+
return __generator(this, function(_a2) {
|
|
18498
|
+
reject(error);
|
|
18499
|
+
return [
|
|
18500
|
+
2
|
|
18501
|
+
/*return*/
|
|
18502
|
+
];
|
|
18503
|
+
});
|
|
18504
|
+
});
|
|
18505
|
+
};
|
|
18506
|
+
scriptEl.onload = function() {
|
|
18507
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18508
|
+
return __generator(this, function(_a2) {
|
|
18509
|
+
resolve();
|
|
18510
|
+
return [
|
|
18511
|
+
2
|
|
18512
|
+
/*return*/
|
|
18513
|
+
];
|
|
18514
|
+
});
|
|
18515
|
+
});
|
|
18516
|
+
};
|
|
18517
|
+
})];
|
|
18518
|
+
});
|
|
18519
|
+
});
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
});
|
|
18523
|
+
|
|
18524
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmLoader.js
|
|
18525
|
+
var require_wasmLoader = __commonJS({
|
|
18526
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmLoader.js"(exports) {
|
|
18527
|
+
"use strict";
|
|
18528
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
18529
|
+
function adopt(value) {
|
|
18530
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
18531
|
+
resolve(value);
|
|
18532
|
+
});
|
|
18533
|
+
}
|
|
18534
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
18535
|
+
function fulfilled(value) {
|
|
18536
|
+
try {
|
|
18537
|
+
step(generator.next(value));
|
|
18538
|
+
} catch (e) {
|
|
18539
|
+
reject(e);
|
|
18540
|
+
}
|
|
18541
|
+
}
|
|
18542
|
+
function rejected(value) {
|
|
18543
|
+
try {
|
|
18544
|
+
step(generator["throw"](value));
|
|
18545
|
+
} catch (e) {
|
|
18546
|
+
reject(e);
|
|
18547
|
+
}
|
|
18548
|
+
}
|
|
18549
|
+
function step(result) {
|
|
18550
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
18551
|
+
}
|
|
18552
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18553
|
+
});
|
|
18554
|
+
};
|
|
18555
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
18556
|
+
var _ = { label: 0, sent: function() {
|
|
18557
|
+
if (t[0] & 1) throw t[1];
|
|
18558
|
+
return t[1];
|
|
18559
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
18560
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
18561
|
+
return this;
|
|
18562
|
+
}), g;
|
|
18563
|
+
function verb(n) {
|
|
18564
|
+
return function(v) {
|
|
18565
|
+
return step([n, v]);
|
|
18566
|
+
};
|
|
18567
|
+
}
|
|
18568
|
+
function step(op) {
|
|
18569
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18570
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18571
|
+
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;
|
|
18572
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
18573
|
+
switch (op[0]) {
|
|
18574
|
+
case 0:
|
|
18575
|
+
case 1:
|
|
18576
|
+
t = op;
|
|
18577
|
+
break;
|
|
18578
|
+
case 4:
|
|
18579
|
+
_.label++;
|
|
18580
|
+
return { value: op[1], done: false };
|
|
18581
|
+
case 5:
|
|
18582
|
+
_.label++;
|
|
18583
|
+
y = op[1];
|
|
18584
|
+
op = [0];
|
|
18585
|
+
continue;
|
|
18586
|
+
case 7:
|
|
18587
|
+
op = _.ops.pop();
|
|
18588
|
+
_.trys.pop();
|
|
18589
|
+
continue;
|
|
18590
|
+
default:
|
|
18591
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
18592
|
+
_ = 0;
|
|
18593
|
+
continue;
|
|
18594
|
+
}
|
|
18595
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
18596
|
+
_.label = op[1];
|
|
18597
|
+
break;
|
|
18598
|
+
}
|
|
18599
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
18600
|
+
_.label = t[1];
|
|
18601
|
+
t = op;
|
|
18602
|
+
break;
|
|
18603
|
+
}
|
|
18604
|
+
if (t && _.label < t[2]) {
|
|
18605
|
+
_.label = t[2];
|
|
18606
|
+
_.ops.push(op);
|
|
18607
|
+
break;
|
|
18608
|
+
}
|
|
18609
|
+
if (t[2]) _.ops.pop();
|
|
18610
|
+
_.trys.pop();
|
|
18611
|
+
continue;
|
|
18612
|
+
}
|
|
18613
|
+
op = body.call(thisArg, _);
|
|
18614
|
+
} catch (e) {
|
|
18615
|
+
op = [6, e];
|
|
18616
|
+
y = 0;
|
|
18617
|
+
} finally {
|
|
18618
|
+
f = t = 0;
|
|
18619
|
+
}
|
|
18620
|
+
if (op[0] & 5) throw op[1];
|
|
18621
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
18622
|
+
}
|
|
18623
|
+
};
|
|
18624
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18625
|
+
exports.loadWasmModule = loadWasmModule;
|
|
18626
|
+
exports.ensureNativeModule = ensureNativeModule;
|
|
18627
|
+
exports.destroyNativeModule = destroyNativeModule;
|
|
18628
|
+
var script_1 = require_script();
|
|
18629
|
+
function loadWasmModule() {
|
|
18630
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18631
|
+
var memoryInitializer, memInitXHR;
|
|
18632
|
+
return __generator(this, function(_a) {
|
|
18633
|
+
switch (_a.label) {
|
|
18634
|
+
case 0:
|
|
18635
|
+
if (window.Module) {
|
|
18636
|
+
return [
|
|
18637
|
+
2
|
|
18638
|
+
/*return*/
|
|
18639
|
+
];
|
|
18640
|
+
}
|
|
18641
|
+
window.Module = {};
|
|
18642
|
+
memoryInitializer = "samsung-wasm-decoder.js.mem";
|
|
18643
|
+
if (window.Module.locateFile) {
|
|
18644
|
+
memoryInitializer = window.Module.locateFile(memoryInitializer, "");
|
|
18645
|
+
}
|
|
18646
|
+
window.Module.memoryInitializerRequestURL = memoryInitializer;
|
|
18647
|
+
memInitXHR = new XMLHttpRequest();
|
|
18648
|
+
window.Module.memoryInitializerRequest = memInitXHR;
|
|
18649
|
+
memInitXHR.open("GET", memoryInitializer, true);
|
|
18650
|
+
memInitXHR.responseType = "arraybuffer";
|
|
18651
|
+
memInitXHR.send(null);
|
|
18652
|
+
return [4, (0, script_1.injectScript)("samsung-wasm-decoder.js")];
|
|
18653
|
+
case 1:
|
|
18654
|
+
_a.sent();
|
|
18655
|
+
return [
|
|
18656
|
+
2
|
|
18657
|
+
/*return*/
|
|
18658
|
+
];
|
|
18659
|
+
}
|
|
18660
|
+
});
|
|
18661
|
+
});
|
|
18662
|
+
}
|
|
18663
|
+
var native;
|
|
18664
|
+
function ensureNativeModule() {
|
|
18665
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18666
|
+
var mod;
|
|
18667
|
+
var _a;
|
|
18668
|
+
return __generator(this, function(_b) {
|
|
18669
|
+
switch (_b.label) {
|
|
18670
|
+
case 0:
|
|
18671
|
+
if (native) {
|
|
18672
|
+
return [2, native];
|
|
18673
|
+
}
|
|
18674
|
+
mod = (_a = window.SamsungWasmDecoderModule) === null || _a === void 0 ? void 0 : _a.call(window);
|
|
18675
|
+
if (!mod) {
|
|
18676
|
+
throw new Error("Samsung Wasm Decoder native module not available");
|
|
18677
|
+
}
|
|
18678
|
+
delete mod.then;
|
|
18679
|
+
return [4, new Promise(function(resolve) {
|
|
18680
|
+
mod.onRuntimeInitialized = function() {
|
|
18681
|
+
return resolve(null);
|
|
18682
|
+
};
|
|
18683
|
+
})];
|
|
18684
|
+
case 1:
|
|
18685
|
+
_b.sent();
|
|
18686
|
+
native = mod;
|
|
18687
|
+
return [2, mod];
|
|
18688
|
+
}
|
|
18689
|
+
});
|
|
18690
|
+
});
|
|
18691
|
+
}
|
|
18692
|
+
function destroyNativeModule() {
|
|
18693
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18694
|
+
return __generator(this, function(_a) {
|
|
18695
|
+
native = void 0;
|
|
18696
|
+
return [
|
|
18697
|
+
2
|
|
18698
|
+
/*return*/
|
|
18699
|
+
];
|
|
18700
|
+
});
|
|
18701
|
+
});
|
|
18702
|
+
}
|
|
18703
|
+
}
|
|
18704
|
+
});
|
|
18705
|
+
|
|
18706
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmTCP.js
|
|
18707
|
+
var require_wasmTCP = __commonJS({
|
|
18708
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmTCP.js"(exports) {
|
|
18709
|
+
"use strict";
|
|
18710
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
18711
|
+
function adopt(value) {
|
|
18712
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
18713
|
+
resolve(value);
|
|
18714
|
+
});
|
|
18715
|
+
}
|
|
18716
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
18717
|
+
function fulfilled(value) {
|
|
18718
|
+
try {
|
|
18719
|
+
step(generator.next(value));
|
|
18720
|
+
} catch (e) {
|
|
18721
|
+
reject(e);
|
|
18722
|
+
}
|
|
18723
|
+
}
|
|
18724
|
+
function rejected(value) {
|
|
18725
|
+
try {
|
|
18726
|
+
step(generator["throw"](value));
|
|
18727
|
+
} catch (e) {
|
|
18728
|
+
reject(e);
|
|
18729
|
+
}
|
|
18730
|
+
}
|
|
18731
|
+
function step(result) {
|
|
18732
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
18733
|
+
}
|
|
18734
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18735
|
+
});
|
|
18736
|
+
};
|
|
18737
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
18738
|
+
var _ = { label: 0, sent: function() {
|
|
18739
|
+
if (t[0] & 1) throw t[1];
|
|
18740
|
+
return t[1];
|
|
18741
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
18742
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
18743
|
+
return this;
|
|
18744
|
+
}), g;
|
|
18745
|
+
function verb(n) {
|
|
18746
|
+
return function(v) {
|
|
18747
|
+
return step([n, v]);
|
|
18748
|
+
};
|
|
18749
|
+
}
|
|
18750
|
+
function step(op) {
|
|
18751
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18752
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18753
|
+
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;
|
|
18754
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
18755
|
+
switch (op[0]) {
|
|
18756
|
+
case 0:
|
|
18757
|
+
case 1:
|
|
18758
|
+
t = op;
|
|
18759
|
+
break;
|
|
18760
|
+
case 4:
|
|
18761
|
+
_.label++;
|
|
18762
|
+
return { value: op[1], done: false };
|
|
18763
|
+
case 5:
|
|
18764
|
+
_.label++;
|
|
18765
|
+
y = op[1];
|
|
18766
|
+
op = [0];
|
|
18767
|
+
continue;
|
|
18768
|
+
case 7:
|
|
18769
|
+
op = _.ops.pop();
|
|
18770
|
+
_.trys.pop();
|
|
18771
|
+
continue;
|
|
18772
|
+
default:
|
|
18773
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
18774
|
+
_ = 0;
|
|
18775
|
+
continue;
|
|
18776
|
+
}
|
|
18777
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
18778
|
+
_.label = op[1];
|
|
18779
|
+
break;
|
|
18780
|
+
}
|
|
18781
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
18782
|
+
_.label = t[1];
|
|
18783
|
+
t = op;
|
|
18784
|
+
break;
|
|
18785
|
+
}
|
|
18786
|
+
if (t && _.label < t[2]) {
|
|
18787
|
+
_.label = t[2];
|
|
18788
|
+
_.ops.push(op);
|
|
18789
|
+
break;
|
|
18790
|
+
}
|
|
18791
|
+
if (t[2]) _.ops.pop();
|
|
18792
|
+
_.trys.pop();
|
|
18793
|
+
continue;
|
|
18794
|
+
}
|
|
18795
|
+
op = body.call(thisArg, _);
|
|
18796
|
+
} catch (e) {
|
|
18797
|
+
op = [6, e];
|
|
18798
|
+
y = 0;
|
|
18799
|
+
} finally {
|
|
18800
|
+
f = t = 0;
|
|
18801
|
+
}
|
|
18802
|
+
if (op[0] & 5) throw op[1];
|
|
18803
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
18804
|
+
}
|
|
18805
|
+
};
|
|
18806
|
+
var __values = exports && exports.__values || function(o) {
|
|
18807
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
18808
|
+
if (m) return m.call(o);
|
|
18809
|
+
if (o && typeof o.length === "number") return {
|
|
18810
|
+
next: function() {
|
|
18811
|
+
if (o && i >= o.length) o = void 0;
|
|
18812
|
+
return { value: o && o[i++], done: !o };
|
|
18813
|
+
}
|
|
18814
|
+
};
|
|
18815
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
18816
|
+
};
|
|
18817
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18818
|
+
exports.SamsungWasmTCPPacket = exports.SamsungWasmTCPStream = exports.SamsungWasmTCPStreamConnection = exports.SamsungWasmTCPPacketConnection = exports.SamsungWasmFrameCollector = void 0;
|
|
18819
|
+
var wasmLoader_1 = require_wasmLoader();
|
|
18820
|
+
function ensureCallbackStorage() {
|
|
18821
|
+
if (typeof window !== "undefined") {
|
|
18822
|
+
if (!window._swtConnectCallbacks) {
|
|
18823
|
+
window._swtConnectCallbacks = {};
|
|
18824
|
+
}
|
|
18825
|
+
if (!window._swtSendCallbacks) {
|
|
18826
|
+
window._swtSendCallbacks = {};
|
|
18827
|
+
}
|
|
18828
|
+
if (!window._swtRecvCallbacks) {
|
|
18829
|
+
window._swtRecvCallbacks = {};
|
|
18830
|
+
}
|
|
18831
|
+
if (!window._swtFrameCallbacks) {
|
|
18832
|
+
window._swtFrameCallbacks = {};
|
|
18833
|
+
}
|
|
18834
|
+
}
|
|
18835
|
+
}
|
|
18836
|
+
var SamsungWasmFrameCollector = (
|
|
18837
|
+
/** @class */
|
|
18838
|
+
function() {
|
|
18839
|
+
function SamsungWasmFrameCollector2(_connection, _maxPacketSize) {
|
|
18840
|
+
if (_maxPacketSize === void 0) {
|
|
18841
|
+
_maxPacketSize = 65535;
|
|
18842
|
+
}
|
|
18843
|
+
this._connection = _connection;
|
|
18844
|
+
this._maxPacketSize = _maxPacketSize;
|
|
18845
|
+
this._collectorHandle = 0;
|
|
18846
|
+
this._frameQueue = [];
|
|
18847
|
+
this._frameResolvers = [];
|
|
18848
|
+
this._error = null;
|
|
18849
|
+
}
|
|
18850
|
+
SamsungWasmFrameCollector2.prototype.initialize = function() {
|
|
18851
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18852
|
+
var native, swtFrameCollectorCreate;
|
|
18853
|
+
var _this = this;
|
|
18854
|
+
return __generator(this, function(_a) {
|
|
18855
|
+
switch (_a.label) {
|
|
18856
|
+
case 0:
|
|
18857
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
18858
|
+
case 1:
|
|
18859
|
+
native = _a.sent();
|
|
18860
|
+
ensureCallbackStorage();
|
|
18861
|
+
swtFrameCollectorCreate = native.cwrap("swt_frame_collector_create", "number", ["number", "number"]);
|
|
18862
|
+
this._collectorHandle = swtFrameCollectorCreate(this._connection.getHandle(), this._maxPacketSize);
|
|
18863
|
+
if (this._collectorHandle === 0) {
|
|
18864
|
+
throw new Error("Failed to create frame collector");
|
|
18865
|
+
}
|
|
18866
|
+
window._swtFrameCallbacks[this._collectorHandle] = {
|
|
18867
|
+
onFrame: function(frame) {
|
|
18868
|
+
return _this._handleFrame(frame);
|
|
18869
|
+
},
|
|
18870
|
+
onError: function(error) {
|
|
18871
|
+
return _this._handleError(error);
|
|
18872
|
+
}
|
|
18873
|
+
};
|
|
18874
|
+
return [
|
|
18875
|
+
2
|
|
18876
|
+
/*return*/
|
|
18877
|
+
];
|
|
18878
|
+
}
|
|
18879
|
+
});
|
|
18880
|
+
});
|
|
18881
|
+
};
|
|
18882
|
+
SamsungWasmFrameCollector2.prototype.start = function() {
|
|
18883
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18884
|
+
var native, swtFrameCollectorStart, result;
|
|
18885
|
+
return __generator(this, function(_a) {
|
|
18886
|
+
switch (_a.label) {
|
|
18887
|
+
case 0:
|
|
18888
|
+
if (this._collectorHandle === 0) {
|
|
18889
|
+
throw new Error("Frame collector not initialized");
|
|
18890
|
+
}
|
|
18891
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
18892
|
+
case 1:
|
|
18893
|
+
native = _a.sent();
|
|
18894
|
+
swtFrameCollectorStart = native.cwrap("swt_frame_collector_start", "number", ["number"]);
|
|
18895
|
+
result = swtFrameCollectorStart(this._collectorHandle);
|
|
18896
|
+
if (result < 0) {
|
|
18897
|
+
throw new Error("Failed to start frame collector: ".concat(result));
|
|
18898
|
+
}
|
|
18899
|
+
return [
|
|
18900
|
+
2
|
|
18901
|
+
/*return*/
|
|
18902
|
+
];
|
|
18903
|
+
}
|
|
18904
|
+
});
|
|
18905
|
+
});
|
|
18906
|
+
};
|
|
18907
|
+
SamsungWasmFrameCollector2.prototype.stop = function() {
|
|
18908
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18909
|
+
var native, swtFrameCollectorStop;
|
|
18910
|
+
return __generator(this, function(_a) {
|
|
18911
|
+
switch (_a.label) {
|
|
18912
|
+
case 0:
|
|
18913
|
+
if (this._collectorHandle === 0)
|
|
18914
|
+
return [
|
|
18915
|
+
2
|
|
18916
|
+
/*return*/
|
|
18917
|
+
];
|
|
18918
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
18919
|
+
case 1:
|
|
18920
|
+
native = _a.sent();
|
|
18921
|
+
swtFrameCollectorStop = native.cwrap("swt_frame_collector_stop", "void", ["number"]);
|
|
18922
|
+
swtFrameCollectorStop(this._collectorHandle);
|
|
18923
|
+
return [
|
|
18924
|
+
2
|
|
18925
|
+
/*return*/
|
|
18926
|
+
];
|
|
18927
|
+
}
|
|
18928
|
+
});
|
|
18929
|
+
});
|
|
18930
|
+
};
|
|
18931
|
+
SamsungWasmFrameCollector2.prototype.destroy = function() {
|
|
18932
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18933
|
+
var native, swtFrameCollectorDestroy, error, _a, _b, resolver;
|
|
18934
|
+
var e_1, _c;
|
|
18935
|
+
return __generator(this, function(_d) {
|
|
18936
|
+
switch (_d.label) {
|
|
18937
|
+
case 0:
|
|
18938
|
+
if (this._collectorHandle === 0)
|
|
18939
|
+
return [
|
|
18940
|
+
2
|
|
18941
|
+
/*return*/
|
|
18942
|
+
];
|
|
18943
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
18944
|
+
case 1:
|
|
18945
|
+
native = _d.sent();
|
|
18946
|
+
swtFrameCollectorDestroy = native.cwrap("swt_frame_collector_destroy", "void", ["number"]);
|
|
18947
|
+
if (window._swtFrameCallbacks) {
|
|
18948
|
+
delete window._swtFrameCallbacks[this._collectorHandle];
|
|
18949
|
+
}
|
|
18950
|
+
swtFrameCollectorDestroy(this._collectorHandle);
|
|
18951
|
+
this._collectorHandle = 0;
|
|
18952
|
+
error = new Error("Frame collector destroyed");
|
|
18953
|
+
try {
|
|
18954
|
+
for (_a = __values(this._frameResolvers), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
18955
|
+
resolver = _b.value;
|
|
18956
|
+
resolver.reject(error);
|
|
18957
|
+
}
|
|
18958
|
+
} catch (e_1_1) {
|
|
18959
|
+
e_1 = { error: e_1_1 };
|
|
18960
|
+
} finally {
|
|
18961
|
+
try {
|
|
18962
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
18963
|
+
} finally {
|
|
18964
|
+
if (e_1) throw e_1.error;
|
|
18965
|
+
}
|
|
18966
|
+
}
|
|
18967
|
+
this._frameResolvers = [];
|
|
18968
|
+
return [
|
|
18969
|
+
2
|
|
18970
|
+
/*return*/
|
|
18971
|
+
];
|
|
18972
|
+
}
|
|
18973
|
+
});
|
|
18974
|
+
});
|
|
18975
|
+
};
|
|
18976
|
+
SamsungWasmFrameCollector2.prototype.collectFrame = function(options) {
|
|
18977
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18978
|
+
var frame;
|
|
18979
|
+
var _this = this;
|
|
18980
|
+
var _a, _b;
|
|
18981
|
+
return __generator(this, function(_c) {
|
|
18982
|
+
if (this._error) {
|
|
18983
|
+
throw this._error;
|
|
18984
|
+
}
|
|
18985
|
+
if (this._frameQueue.length > 0) {
|
|
18986
|
+
frame = this._frameQueue.shift();
|
|
18987
|
+
(_a = options === null || options === void 0 ? void 0 : options.onStart) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
18988
|
+
(_b = options === null || options === void 0 ? void 0 : options.onEnd) === null || _b === void 0 ? void 0 : _b.call(options);
|
|
18989
|
+
return [2, frame];
|
|
18990
|
+
}
|
|
18991
|
+
return [2, new Promise(function(resolve, reject) {
|
|
18992
|
+
_this._frameResolvers.push({ resolve, reject, options });
|
|
18993
|
+
})];
|
|
18994
|
+
});
|
|
18995
|
+
});
|
|
18996
|
+
};
|
|
18997
|
+
SamsungWasmFrameCollector2.getFrameDataPointer = function(refId) {
|
|
18998
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
18999
|
+
var native, swtFrameGetData;
|
|
19000
|
+
return __generator(this, function(_a) {
|
|
19001
|
+
switch (_a.label) {
|
|
19002
|
+
case 0:
|
|
19003
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19004
|
+
case 1:
|
|
19005
|
+
native = _a.sent();
|
|
19006
|
+
swtFrameGetData = native.cwrap("swt_frame_get_data", "number", [
|
|
19007
|
+
"number"
|
|
19008
|
+
]);
|
|
19009
|
+
return [2, swtFrameGetData(refId)];
|
|
19010
|
+
}
|
|
19011
|
+
});
|
|
19012
|
+
});
|
|
19013
|
+
};
|
|
19014
|
+
SamsungWasmFrameCollector2.getFrameSize = function(refId) {
|
|
19015
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19016
|
+
var native, swtFrameGetSize;
|
|
19017
|
+
return __generator(this, function(_a) {
|
|
19018
|
+
switch (_a.label) {
|
|
19019
|
+
case 0:
|
|
19020
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19021
|
+
case 1:
|
|
19022
|
+
native = _a.sent();
|
|
19023
|
+
swtFrameGetSize = native.cwrap("swt_frame_get_size", "number", [
|
|
19024
|
+
"number"
|
|
19025
|
+
]);
|
|
19026
|
+
return [2, swtFrameGetSize(refId)];
|
|
19027
|
+
}
|
|
19028
|
+
});
|
|
19029
|
+
});
|
|
19030
|
+
};
|
|
19031
|
+
SamsungWasmFrameCollector2.getFrameType = function(refId) {
|
|
19032
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19033
|
+
var native, swtFrameGetType;
|
|
19034
|
+
return __generator(this, function(_a) {
|
|
19035
|
+
switch (_a.label) {
|
|
19036
|
+
case 0:
|
|
19037
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19038
|
+
case 1:
|
|
19039
|
+
native = _a.sent();
|
|
19040
|
+
swtFrameGetType = native.cwrap("swt_frame_get_type", "number", [
|
|
19041
|
+
"number"
|
|
19042
|
+
]);
|
|
19043
|
+
return [2, swtFrameGetType(refId)];
|
|
19044
|
+
}
|
|
19045
|
+
});
|
|
19046
|
+
});
|
|
19047
|
+
};
|
|
19048
|
+
SamsungWasmFrameCollector2.getFrameTimestamp = function(refId) {
|
|
19049
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19050
|
+
var native, swtFrameGetTimestampLo, swtFrameGetTimestampHi, lo, hi;
|
|
19051
|
+
return __generator(this, function(_a) {
|
|
19052
|
+
switch (_a.label) {
|
|
19053
|
+
case 0:
|
|
19054
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19055
|
+
case 1:
|
|
19056
|
+
native = _a.sent();
|
|
19057
|
+
swtFrameGetTimestampLo = native.cwrap("swt_frame_get_timestamp_lo", "number", ["number"]);
|
|
19058
|
+
swtFrameGetTimestampHi = native.cwrap("swt_frame_get_timestamp_hi", "number", ["number"]);
|
|
19059
|
+
lo = swtFrameGetTimestampLo(refId);
|
|
19060
|
+
hi = swtFrameGetTimestampHi(refId);
|
|
19061
|
+
return [2, { lo, hi }];
|
|
19062
|
+
}
|
|
19063
|
+
});
|
|
19064
|
+
});
|
|
19065
|
+
};
|
|
19066
|
+
SamsungWasmFrameCollector2.releaseFrame = function(refId) {
|
|
19067
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19068
|
+
var native, swtFrameRelease;
|
|
19069
|
+
return __generator(this, function(_a) {
|
|
19070
|
+
switch (_a.label) {
|
|
19071
|
+
case 0:
|
|
19072
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19073
|
+
case 1:
|
|
19074
|
+
native = _a.sent();
|
|
19075
|
+
swtFrameRelease = native.cwrap("swt_frame_release", "void", [
|
|
19076
|
+
"number"
|
|
19077
|
+
]);
|
|
19078
|
+
swtFrameRelease(refId);
|
|
19079
|
+
return [
|
|
19080
|
+
2
|
|
19081
|
+
/*return*/
|
|
19082
|
+
];
|
|
19083
|
+
}
|
|
19084
|
+
});
|
|
19085
|
+
});
|
|
19086
|
+
};
|
|
19087
|
+
SamsungWasmFrameCollector2.prototype._handleFrame = function(frame) {
|
|
19088
|
+
var _a, _b, _c, _d;
|
|
19089
|
+
if (this._frameResolvers.length > 0) {
|
|
19090
|
+
var resolver = this._frameResolvers.shift();
|
|
19091
|
+
(_b = (_a = resolver.options) === null || _a === void 0 ? void 0 : _a.onStart) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
19092
|
+
(_d = (_c = resolver.options) === null || _c === void 0 ? void 0 : _c.onEnd) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
19093
|
+
resolver.resolve(frame);
|
|
19094
|
+
} else {
|
|
19095
|
+
this._frameQueue.push(frame);
|
|
19096
|
+
}
|
|
19097
|
+
};
|
|
19098
|
+
SamsungWasmFrameCollector2.prototype._handleError = function(error) {
|
|
19099
|
+
var e_2, _a;
|
|
19100
|
+
this._error = error;
|
|
19101
|
+
try {
|
|
19102
|
+
for (var _b = __values(this._frameResolvers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19103
|
+
var resolver = _c.value;
|
|
19104
|
+
resolver.reject(error);
|
|
19105
|
+
}
|
|
19106
|
+
} catch (e_2_1) {
|
|
19107
|
+
e_2 = { error: e_2_1 };
|
|
19108
|
+
} finally {
|
|
19109
|
+
try {
|
|
19110
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
19111
|
+
} finally {
|
|
19112
|
+
if (e_2) throw e_2.error;
|
|
19113
|
+
}
|
|
19114
|
+
}
|
|
19115
|
+
this._frameResolvers = [];
|
|
19116
|
+
};
|
|
19117
|
+
return SamsungWasmFrameCollector2;
|
|
19118
|
+
}()
|
|
19119
|
+
);
|
|
19120
|
+
exports.SamsungWasmFrameCollector = SamsungWasmFrameCollector;
|
|
19121
|
+
var SamsungWasmTCPPacketConnection = (
|
|
19122
|
+
/** @class */
|
|
19123
|
+
function() {
|
|
19124
|
+
function SamsungWasmTCPPacketConnection2(handle, _maxPacketSize) {
|
|
19125
|
+
if (_maxPacketSize === void 0) {
|
|
19126
|
+
_maxPacketSize = 65535;
|
|
19127
|
+
}
|
|
19128
|
+
this._maxPacketSize = _maxPacketSize;
|
|
19129
|
+
this._nextRequestId = 1;
|
|
19130
|
+
this._frameCollector = null;
|
|
19131
|
+
this._frameCollectorStarted = false;
|
|
19132
|
+
this._handle = handle;
|
|
19133
|
+
}
|
|
19134
|
+
SamsungWasmTCPPacketConnection2.prototype.getHandle = function() {
|
|
19135
|
+
return this._handle;
|
|
19136
|
+
};
|
|
19137
|
+
SamsungWasmTCPPacketConnection2.prototype.isConnected = function() {
|
|
19138
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19139
|
+
var native, swtIsConnected;
|
|
19140
|
+
return __generator(this, function(_a) {
|
|
19141
|
+
switch (_a.label) {
|
|
19142
|
+
case 0:
|
|
19143
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19144
|
+
case 1:
|
|
19145
|
+
native = _a.sent();
|
|
19146
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19147
|
+
"number"
|
|
19148
|
+
]);
|
|
19149
|
+
return [2, swtIsConnected(this._handle) === 1];
|
|
19150
|
+
}
|
|
19151
|
+
});
|
|
19152
|
+
});
|
|
19153
|
+
};
|
|
19154
|
+
SamsungWasmTCPPacketConnection2.prototype.isConnecting = function() {
|
|
19155
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19156
|
+
var native, swtIsConnected;
|
|
19157
|
+
return __generator(this, function(_a) {
|
|
19158
|
+
switch (_a.label) {
|
|
19159
|
+
case 0:
|
|
19160
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19161
|
+
case 1:
|
|
19162
|
+
native = _a.sent();
|
|
19163
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19164
|
+
"number"
|
|
19165
|
+
]);
|
|
19166
|
+
return [2, swtIsConnected(this._handle) === -1];
|
|
19167
|
+
}
|
|
19168
|
+
});
|
|
19169
|
+
});
|
|
19170
|
+
};
|
|
19171
|
+
SamsungWasmTCPPacketConnection2.prototype.send = function(data) {
|
|
19172
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19173
|
+
var native, swtIsConnected, connStatus, requestId, callbackKey, sendPromise, ptr, swtPacketSendAsync, result;
|
|
19174
|
+
return __generator(this, function(_a) {
|
|
19175
|
+
switch (_a.label) {
|
|
19176
|
+
case 0:
|
|
19177
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19178
|
+
case 1:
|
|
19179
|
+
native = _a.sent();
|
|
19180
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19181
|
+
"number"
|
|
19182
|
+
]);
|
|
19183
|
+
connStatus = swtIsConnected(this._handle);
|
|
19184
|
+
if (connStatus !== 1) {
|
|
19185
|
+
if (connStatus === -1) {
|
|
19186
|
+
throw new Error("Connection is still in progress");
|
|
19187
|
+
}
|
|
19188
|
+
throw new Error("Connection is not active");
|
|
19189
|
+
}
|
|
19190
|
+
ensureCallbackStorage();
|
|
19191
|
+
requestId = this._nextRequestId++;
|
|
19192
|
+
callbackKey = "".concat(this._handle, "_").concat(requestId);
|
|
19193
|
+
sendPromise = new Promise(function(resolve, reject) {
|
|
19194
|
+
window._swtSendCallbacks[callbackKey] = { resolve, reject };
|
|
19195
|
+
});
|
|
19196
|
+
ptr = native._malloc(data.byteLength);
|
|
19197
|
+
try {
|
|
19198
|
+
native.HEAPU8.set(new Uint8Array(data), ptr);
|
|
19199
|
+
swtPacketSendAsync = native.cwrap("swt_packet_send_async", "number", ["number", "number", "number", "number"]);
|
|
19200
|
+
result = swtPacketSendAsync(this._handle, ptr, data.byteLength, requestId);
|
|
19201
|
+
if (result !== 0) {
|
|
19202
|
+
delete window._swtSendCallbacks[callbackKey];
|
|
19203
|
+
throw new Error("Failed to start send operation, error code: ".concat(result));
|
|
19204
|
+
}
|
|
19205
|
+
} catch (e) {
|
|
19206
|
+
native._free(ptr);
|
|
19207
|
+
throw e;
|
|
19208
|
+
}
|
|
19209
|
+
native._free(ptr);
|
|
19210
|
+
return [2, sendPromise];
|
|
19211
|
+
}
|
|
19212
|
+
});
|
|
19213
|
+
});
|
|
19214
|
+
};
|
|
19215
|
+
SamsungWasmTCPPacketConnection2.prototype.recv = function() {
|
|
19216
|
+
return __awaiter(this, arguments, void 0, function(maxSize) {
|
|
19217
|
+
var native, swtIsConnected, connStatus, requestId, callbackKey, recvPromise, swtPacketRecvAsync, result;
|
|
19218
|
+
if (maxSize === void 0) {
|
|
19219
|
+
maxSize = 65535;
|
|
19220
|
+
}
|
|
19221
|
+
return __generator(this, function(_a) {
|
|
19222
|
+
switch (_a.label) {
|
|
19223
|
+
case 0:
|
|
19224
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19225
|
+
case 1:
|
|
19226
|
+
native = _a.sent();
|
|
19227
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19228
|
+
"number"
|
|
19229
|
+
]);
|
|
19230
|
+
connStatus = swtIsConnected(this._handle);
|
|
19231
|
+
if (connStatus !== 1) {
|
|
19232
|
+
if (connStatus === -1) {
|
|
19233
|
+
throw new Error("Connection is still in progress");
|
|
19234
|
+
}
|
|
19235
|
+
throw new Error("Connection is not active");
|
|
19236
|
+
}
|
|
19237
|
+
ensureCallbackStorage();
|
|
19238
|
+
requestId = this._nextRequestId++;
|
|
19239
|
+
callbackKey = "".concat(this._handle, "_").concat(requestId);
|
|
19240
|
+
recvPromise = new Promise(function(resolve, reject) {
|
|
19241
|
+
window._swtRecvCallbacks[callbackKey] = { resolve, reject };
|
|
19242
|
+
});
|
|
19243
|
+
swtPacketRecvAsync = native.cwrap("swt_packet_recv_async", "number", [
|
|
19244
|
+
"number",
|
|
19245
|
+
"number",
|
|
19246
|
+
"number"
|
|
19247
|
+
]);
|
|
19248
|
+
result = swtPacketRecvAsync(this._handle, maxSize, requestId);
|
|
19249
|
+
if (result !== 0) {
|
|
19250
|
+
delete window._swtRecvCallbacks[callbackKey];
|
|
19251
|
+
throw new Error("Failed to start recv operation, error code: ".concat(result));
|
|
19252
|
+
}
|
|
19253
|
+
return [2, recvPromise];
|
|
19254
|
+
}
|
|
19255
|
+
});
|
|
19256
|
+
});
|
|
19257
|
+
};
|
|
19258
|
+
SamsungWasmTCPPacketConnection2.prototype.collectFrame = function(options) {
|
|
19259
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19260
|
+
return __generator(this, function(_a) {
|
|
19261
|
+
switch (_a.label) {
|
|
19262
|
+
case 0:
|
|
19263
|
+
if (!!this._frameCollector) return [3, 2];
|
|
19264
|
+
this._frameCollector = new SamsungWasmFrameCollector(this, this._maxPacketSize);
|
|
19265
|
+
return [4, this._frameCollector.initialize()];
|
|
19266
|
+
case 1:
|
|
19267
|
+
_a.sent();
|
|
19268
|
+
_a.label = 2;
|
|
19269
|
+
case 2:
|
|
19270
|
+
if (!!this._frameCollectorStarted) return [3, 4];
|
|
19271
|
+
return [4, this._frameCollector.start()];
|
|
19272
|
+
case 3:
|
|
19273
|
+
_a.sent();
|
|
19274
|
+
this._frameCollectorStarted = true;
|
|
19275
|
+
_a.label = 4;
|
|
19276
|
+
case 4:
|
|
19277
|
+
return [2, this._frameCollector.collectFrame(options)];
|
|
19278
|
+
}
|
|
19279
|
+
});
|
|
19280
|
+
});
|
|
19281
|
+
};
|
|
19282
|
+
SamsungWasmTCPPacketConnection2.prototype.createFrameCollector = function() {
|
|
19283
|
+
return __awaiter(this, arguments, void 0, function(maxPacketSize) {
|
|
19284
|
+
var collector;
|
|
19285
|
+
if (maxPacketSize === void 0) {
|
|
19286
|
+
maxPacketSize = 65535;
|
|
19287
|
+
}
|
|
19288
|
+
return __generator(this, function(_a) {
|
|
19289
|
+
switch (_a.label) {
|
|
19290
|
+
case 0:
|
|
19291
|
+
collector = new SamsungWasmFrameCollector(this, maxPacketSize);
|
|
19292
|
+
return [4, collector.initialize()];
|
|
19293
|
+
case 1:
|
|
19294
|
+
_a.sent();
|
|
19295
|
+
return [2, collector];
|
|
19296
|
+
}
|
|
19297
|
+
});
|
|
19298
|
+
});
|
|
19299
|
+
};
|
|
19300
|
+
SamsungWasmTCPPacketConnection2.prototype.close = function() {
|
|
19301
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19302
|
+
var native, swtClose;
|
|
19303
|
+
return __generator(this, function(_a) {
|
|
19304
|
+
switch (_a.label) {
|
|
19305
|
+
case 0:
|
|
19306
|
+
if (!this._frameCollector) return [3, 3];
|
|
19307
|
+
return [4, this._frameCollector.stop()];
|
|
19308
|
+
case 1:
|
|
19309
|
+
_a.sent();
|
|
19310
|
+
return [4, this._frameCollector.destroy()];
|
|
19311
|
+
case 2:
|
|
19312
|
+
_a.sent();
|
|
19313
|
+
this._frameCollector = null;
|
|
19314
|
+
this._frameCollectorStarted = false;
|
|
19315
|
+
_a.label = 3;
|
|
19316
|
+
case 3:
|
|
19317
|
+
if (!(this._handle !== 0)) return [3, 5];
|
|
19318
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19319
|
+
case 4:
|
|
19320
|
+
native = _a.sent();
|
|
19321
|
+
swtClose = native.cwrap("swt_close", "void", [
|
|
19322
|
+
"number"
|
|
19323
|
+
]);
|
|
19324
|
+
swtClose(this._handle);
|
|
19325
|
+
this._handle = 0;
|
|
19326
|
+
_a.label = 5;
|
|
19327
|
+
case 5:
|
|
19328
|
+
return [
|
|
19329
|
+
2
|
|
19330
|
+
/*return*/
|
|
19331
|
+
];
|
|
19332
|
+
}
|
|
19333
|
+
});
|
|
19334
|
+
});
|
|
19335
|
+
};
|
|
19336
|
+
return SamsungWasmTCPPacketConnection2;
|
|
19337
|
+
}()
|
|
19338
|
+
);
|
|
19339
|
+
exports.SamsungWasmTCPPacketConnection = SamsungWasmTCPPacketConnection;
|
|
19340
|
+
var SamsungWasmTCPStreamConnection = (
|
|
19341
|
+
/** @class */
|
|
19342
|
+
function() {
|
|
19343
|
+
function SamsungWasmTCPStreamConnection2(handle) {
|
|
19344
|
+
this._nextRequestId = 1;
|
|
19345
|
+
this._handle = handle;
|
|
19346
|
+
}
|
|
19347
|
+
SamsungWasmTCPStreamConnection2.prototype.getHandle = function() {
|
|
19348
|
+
return this._handle;
|
|
19349
|
+
};
|
|
19350
|
+
SamsungWasmTCPStreamConnection2.prototype.isConnected = function() {
|
|
19351
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19352
|
+
var native, swtIsConnected;
|
|
19353
|
+
return __generator(this, function(_a) {
|
|
19354
|
+
switch (_a.label) {
|
|
19355
|
+
case 0:
|
|
19356
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19357
|
+
case 1:
|
|
19358
|
+
native = _a.sent();
|
|
19359
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19360
|
+
"number"
|
|
19361
|
+
]);
|
|
19362
|
+
return [2, swtIsConnected(this._handle) === 1];
|
|
19363
|
+
}
|
|
19364
|
+
});
|
|
19365
|
+
});
|
|
19366
|
+
};
|
|
19367
|
+
SamsungWasmTCPStreamConnection2.prototype.write = function(data) {
|
|
19368
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19369
|
+
var native, swtIsConnected, connStatus, requestId, callbackKey, sendPromise, ptr, swtStreamSendAsync, result;
|
|
19370
|
+
return __generator(this, function(_a) {
|
|
19371
|
+
switch (_a.label) {
|
|
19372
|
+
case 0:
|
|
19373
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19374
|
+
case 1:
|
|
19375
|
+
native = _a.sent();
|
|
19376
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19377
|
+
"number"
|
|
19378
|
+
]);
|
|
19379
|
+
connStatus = swtIsConnected(this._handle);
|
|
19380
|
+
if (connStatus !== 1) {
|
|
19381
|
+
if (connStatus === -1) {
|
|
19382
|
+
throw new Error("Connection is still in progress");
|
|
19383
|
+
}
|
|
19384
|
+
throw new Error("Connection is not active");
|
|
19385
|
+
}
|
|
19386
|
+
ensureCallbackStorage();
|
|
19387
|
+
requestId = this._nextRequestId++;
|
|
19388
|
+
callbackKey = "".concat(this._handle, "_").concat(requestId);
|
|
19389
|
+
sendPromise = new Promise(function(resolve, reject) {
|
|
19390
|
+
window._swtSendCallbacks[callbackKey] = { resolve, reject };
|
|
19391
|
+
});
|
|
19392
|
+
ptr = native._malloc(data.byteLength);
|
|
19393
|
+
try {
|
|
19394
|
+
native.HEAPU8.set(new Uint8Array(data), ptr);
|
|
19395
|
+
swtStreamSendAsync = native.cwrap("swt_stream_send_async", "number", ["number", "number", "number", "number"]);
|
|
19396
|
+
result = swtStreamSendAsync(this._handle, ptr, data.byteLength, requestId);
|
|
19397
|
+
if (result !== 0) {
|
|
19398
|
+
delete window._swtSendCallbacks[callbackKey];
|
|
19399
|
+
throw new Error("Failed to start stream write operation, error code: ".concat(result));
|
|
19400
|
+
}
|
|
19401
|
+
} catch (e) {
|
|
19402
|
+
native._free(ptr);
|
|
19403
|
+
throw e;
|
|
19404
|
+
}
|
|
19405
|
+
native._free(ptr);
|
|
19406
|
+
return [2, sendPromise];
|
|
19407
|
+
}
|
|
19408
|
+
});
|
|
19409
|
+
});
|
|
19410
|
+
};
|
|
19411
|
+
SamsungWasmTCPStreamConnection2.prototype.read = function() {
|
|
19412
|
+
return __awaiter(this, arguments, void 0, function(maxSize) {
|
|
19413
|
+
var native, swtIsConnected, connStatus, requestId, callbackKey, recvPromise, swtStreamRecvAsync, result;
|
|
19414
|
+
if (maxSize === void 0) {
|
|
19415
|
+
maxSize = 65535;
|
|
19416
|
+
}
|
|
19417
|
+
return __generator(this, function(_a) {
|
|
19418
|
+
switch (_a.label) {
|
|
19419
|
+
case 0:
|
|
19420
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19421
|
+
case 1:
|
|
19422
|
+
native = _a.sent();
|
|
19423
|
+
swtIsConnected = native.cwrap("swt_is_connected", "number", [
|
|
19424
|
+
"number"
|
|
19425
|
+
]);
|
|
19426
|
+
connStatus = swtIsConnected(this._handle);
|
|
19427
|
+
if (connStatus !== 1) {
|
|
19428
|
+
if (connStatus === -1) {
|
|
19429
|
+
throw new Error("Connection is still in progress");
|
|
19430
|
+
}
|
|
19431
|
+
throw new Error("Connection is not active");
|
|
19432
|
+
}
|
|
19433
|
+
ensureCallbackStorage();
|
|
19434
|
+
requestId = this._nextRequestId++;
|
|
19435
|
+
callbackKey = "".concat(this._handle, "_").concat(requestId);
|
|
19436
|
+
recvPromise = new Promise(function(resolve, reject) {
|
|
19437
|
+
window._swtRecvCallbacks[callbackKey] = { resolve, reject };
|
|
19438
|
+
});
|
|
19439
|
+
swtStreamRecvAsync = native.cwrap("swt_stream_recv_async", "number", [
|
|
19440
|
+
"number",
|
|
19441
|
+
"number",
|
|
19442
|
+
"number"
|
|
19443
|
+
]);
|
|
19444
|
+
result = swtStreamRecvAsync(this._handle, maxSize, requestId);
|
|
19445
|
+
if (result !== 0) {
|
|
19446
|
+
delete window._swtRecvCallbacks[callbackKey];
|
|
19447
|
+
throw new Error("Failed to start stream read operation, error code: ".concat(result));
|
|
19448
|
+
}
|
|
19449
|
+
return [2, recvPromise];
|
|
19450
|
+
}
|
|
19451
|
+
});
|
|
19452
|
+
});
|
|
19453
|
+
};
|
|
19454
|
+
SamsungWasmTCPStreamConnection2.prototype.close = function() {
|
|
19455
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19456
|
+
var native, swtClose;
|
|
19457
|
+
return __generator(this, function(_a) {
|
|
19458
|
+
switch (_a.label) {
|
|
19459
|
+
case 0:
|
|
19460
|
+
if (!(this._handle !== 0)) return [3, 2];
|
|
19461
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19462
|
+
case 1:
|
|
19463
|
+
native = _a.sent();
|
|
19464
|
+
swtClose = native.cwrap("swt_close", "void", [
|
|
19465
|
+
"number"
|
|
19466
|
+
]);
|
|
19467
|
+
swtClose(this._handle);
|
|
19468
|
+
this._handle = 0;
|
|
19469
|
+
_a.label = 2;
|
|
19470
|
+
case 2:
|
|
19471
|
+
return [
|
|
19472
|
+
2
|
|
19473
|
+
/*return*/
|
|
19474
|
+
];
|
|
19475
|
+
}
|
|
19476
|
+
});
|
|
19477
|
+
});
|
|
19478
|
+
};
|
|
19479
|
+
return SamsungWasmTCPStreamConnection2;
|
|
19480
|
+
}()
|
|
19481
|
+
);
|
|
19482
|
+
exports.SamsungWasmTCPStreamConnection = SamsungWasmTCPStreamConnection;
|
|
19483
|
+
var SamsungWasmTCPStream2 = (
|
|
19484
|
+
/** @class */
|
|
19485
|
+
function() {
|
|
19486
|
+
function SamsungWasmTCPStream3() {
|
|
19487
|
+
}
|
|
19488
|
+
SamsungWasmTCPStream3.prototype.connect = function(options) {
|
|
19489
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19490
|
+
var native, swtConnectAsync, handle, connectPromise, connectedHandle;
|
|
19491
|
+
return __generator(this, function(_a) {
|
|
19492
|
+
switch (_a.label) {
|
|
19493
|
+
case 0:
|
|
19494
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19495
|
+
case 1:
|
|
19496
|
+
native = _a.sent();
|
|
19497
|
+
ensureCallbackStorage();
|
|
19498
|
+
swtConnectAsync = native.cwrap("swt_connect_async", "number", [
|
|
19499
|
+
"string",
|
|
19500
|
+
"number",
|
|
19501
|
+
"number"
|
|
19502
|
+
]);
|
|
19503
|
+
connectPromise = new Promise(function(resolve, reject) {
|
|
19504
|
+
handle = swtConnectAsync(options.host, options.timeoutMs, options.secure ? 1 : 0);
|
|
19505
|
+
if (handle === 0) {
|
|
19506
|
+
reject(new Error("Failed to start connection to ".concat(options.host)));
|
|
19507
|
+
return;
|
|
19508
|
+
}
|
|
19509
|
+
window._swtConnectCallbacks[handle] = { resolve, reject };
|
|
19510
|
+
});
|
|
19511
|
+
return [4, connectPromise];
|
|
19512
|
+
case 2:
|
|
19513
|
+
connectedHandle = _a.sent();
|
|
19514
|
+
return [2, new SamsungWasmTCPStreamConnection(connectedHandle)];
|
|
19515
|
+
}
|
|
19516
|
+
});
|
|
19517
|
+
});
|
|
19518
|
+
};
|
|
19519
|
+
return SamsungWasmTCPStream3;
|
|
19520
|
+
}()
|
|
19521
|
+
);
|
|
19522
|
+
exports.SamsungWasmTCPStream = SamsungWasmTCPStream2;
|
|
19523
|
+
var SamsungWasmTCPPacket2 = (
|
|
19524
|
+
/** @class */
|
|
19525
|
+
function() {
|
|
19526
|
+
function SamsungWasmTCPPacket3() {
|
|
19527
|
+
}
|
|
19528
|
+
SamsungWasmTCPPacket3.prototype.connect = function(options) {
|
|
19529
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19530
|
+
var native, swtConnectAsync, handle, connectPromise, connectedHandle;
|
|
19531
|
+
var _a;
|
|
19532
|
+
return __generator(this, function(_b) {
|
|
19533
|
+
switch (_b.label) {
|
|
19534
|
+
case 0:
|
|
19535
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19536
|
+
case 1:
|
|
19537
|
+
native = _b.sent();
|
|
19538
|
+
ensureCallbackStorage();
|
|
19539
|
+
swtConnectAsync = native.cwrap("swt_connect_async", "number", [
|
|
19540
|
+
"string",
|
|
19541
|
+
"number",
|
|
19542
|
+
"number"
|
|
19543
|
+
]);
|
|
19544
|
+
connectPromise = new Promise(function(resolve, reject) {
|
|
19545
|
+
handle = swtConnectAsync(options.host, options.timeoutMs, options.secure ? 1 : 0);
|
|
19546
|
+
if (handle === 0) {
|
|
19547
|
+
reject(new Error("Failed to start connection to ".concat(options.host)));
|
|
19548
|
+
return;
|
|
19549
|
+
}
|
|
19550
|
+
window._swtConnectCallbacks[handle] = { resolve, reject };
|
|
19551
|
+
});
|
|
19552
|
+
return [4, connectPromise];
|
|
19553
|
+
case 2:
|
|
19554
|
+
connectedHandle = _b.sent();
|
|
19555
|
+
return [2, new SamsungWasmTCPPacketConnection(connectedHandle, (_a = options.maxPacketSize) !== null && _a !== void 0 ? _a : 65535)];
|
|
19556
|
+
}
|
|
19557
|
+
});
|
|
19558
|
+
});
|
|
19559
|
+
};
|
|
19560
|
+
return SamsungWasmTCPPacket3;
|
|
19561
|
+
}()
|
|
19562
|
+
);
|
|
19563
|
+
exports.SamsungWasmTCPPacket = SamsungWasmTCPPacket2;
|
|
19564
|
+
}
|
|
19565
|
+
});
|
|
19566
|
+
|
|
19567
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js
|
|
19568
|
+
var require_wasmDecoder = __commonJS({
|
|
19569
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/WasmDecoder/wasmDecoder.js"(exports) {
|
|
19570
|
+
"use strict";
|
|
19571
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
19572
|
+
function adopt(value) {
|
|
19573
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
19574
|
+
resolve(value);
|
|
19575
|
+
});
|
|
19576
|
+
}
|
|
19577
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
19578
|
+
function fulfilled(value) {
|
|
19579
|
+
try {
|
|
19580
|
+
step(generator.next(value));
|
|
19581
|
+
} catch (e) {
|
|
19582
|
+
reject(e);
|
|
19583
|
+
}
|
|
19584
|
+
}
|
|
19585
|
+
function rejected(value) {
|
|
19586
|
+
try {
|
|
19587
|
+
step(generator["throw"](value));
|
|
19588
|
+
} catch (e) {
|
|
19589
|
+
reject(e);
|
|
19590
|
+
}
|
|
19591
|
+
}
|
|
19592
|
+
function step(result) {
|
|
19593
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
19594
|
+
}
|
|
19595
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19596
|
+
});
|
|
19597
|
+
};
|
|
19598
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
19599
|
+
var _ = { label: 0, sent: function() {
|
|
19600
|
+
if (t[0] & 1) throw t[1];
|
|
19601
|
+
return t[1];
|
|
19602
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
19603
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
19604
|
+
return this;
|
|
19605
|
+
}), g;
|
|
19606
|
+
function verb(n) {
|
|
19607
|
+
return function(v) {
|
|
19608
|
+
return step([n, v]);
|
|
19609
|
+
};
|
|
19610
|
+
}
|
|
19611
|
+
function step(op) {
|
|
19612
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
19613
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19614
|
+
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;
|
|
19615
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19616
|
+
switch (op[0]) {
|
|
19617
|
+
case 0:
|
|
19618
|
+
case 1:
|
|
19619
|
+
t = op;
|
|
19620
|
+
break;
|
|
19621
|
+
case 4:
|
|
19622
|
+
_.label++;
|
|
19623
|
+
return { value: op[1], done: false };
|
|
19624
|
+
case 5:
|
|
19625
|
+
_.label++;
|
|
19626
|
+
y = op[1];
|
|
19627
|
+
op = [0];
|
|
19628
|
+
continue;
|
|
19629
|
+
case 7:
|
|
19630
|
+
op = _.ops.pop();
|
|
19631
|
+
_.trys.pop();
|
|
19632
|
+
continue;
|
|
19633
|
+
default:
|
|
19634
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
19635
|
+
_ = 0;
|
|
19636
|
+
continue;
|
|
19637
|
+
}
|
|
19638
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
19639
|
+
_.label = op[1];
|
|
19640
|
+
break;
|
|
19641
|
+
}
|
|
19642
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
19643
|
+
_.label = t[1];
|
|
19644
|
+
t = op;
|
|
19645
|
+
break;
|
|
19646
|
+
}
|
|
19647
|
+
if (t && _.label < t[2]) {
|
|
19648
|
+
_.label = t[2];
|
|
19649
|
+
_.ops.push(op);
|
|
19650
|
+
break;
|
|
19651
|
+
}
|
|
19652
|
+
if (t[2]) _.ops.pop();
|
|
19653
|
+
_.trys.pop();
|
|
19654
|
+
continue;
|
|
19655
|
+
}
|
|
19656
|
+
op = body.call(thisArg, _);
|
|
19657
|
+
} catch (e) {
|
|
19658
|
+
op = [6, e];
|
|
19659
|
+
y = 0;
|
|
19660
|
+
} finally {
|
|
19661
|
+
f = t = 0;
|
|
19662
|
+
}
|
|
19663
|
+
if (op[0] & 5) throw op[1];
|
|
19664
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
19665
|
+
}
|
|
19666
|
+
};
|
|
19667
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19668
|
+
exports.SamsungWasmDecoder = void 0;
|
|
19669
|
+
var videoDecoder_1 = require_videoDecoder2();
|
|
19670
|
+
var wasmLoader_1 = require_wasmLoader();
|
|
19671
|
+
var wasmTCP_1 = require_wasmTCP();
|
|
19672
|
+
function detectKeyFrameAnnexB(bytes) {
|
|
19673
|
+
if (bytes.length === 0)
|
|
19674
|
+
return false;
|
|
19675
|
+
var nalHeaderIndex = 0;
|
|
19676
|
+
if (bytes.length >= 4 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 1) {
|
|
19677
|
+
nalHeaderIndex = 4;
|
|
19678
|
+
} else if (bytes.length >= 3 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 1) {
|
|
19679
|
+
nalHeaderIndex = 3;
|
|
19680
|
+
}
|
|
19681
|
+
if (nalHeaderIndex >= bytes.length)
|
|
19682
|
+
return false;
|
|
19683
|
+
var nalType = bytes[nalHeaderIndex] & 31;
|
|
19684
|
+
if (nalType === 5 || nalType === 7 || nalType === 8)
|
|
19685
|
+
return true;
|
|
19686
|
+
for (var i = nalHeaderIndex + 1; i + 4 < bytes.length; i++) {
|
|
19687
|
+
var is3 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 1;
|
|
19688
|
+
var is4 = bytes[i] === 0 && bytes[i + 1] === 0 && bytes[i + 2] === 0 && bytes[i + 3] === 1;
|
|
19689
|
+
if (!is3 && !is4)
|
|
19690
|
+
continue;
|
|
19691
|
+
var idx = i + (is3 ? 3 : 4);
|
|
19692
|
+
if (idx >= bytes.length)
|
|
19693
|
+
return false;
|
|
19694
|
+
var nt = bytes[idx] & 31;
|
|
19695
|
+
if (nt === 5 || nt === 7 || nt === 8)
|
|
19696
|
+
return true;
|
|
19697
|
+
}
|
|
19698
|
+
return false;
|
|
19699
|
+
}
|
|
19700
|
+
function ensureVideoElement(videoElementId) {
|
|
19701
|
+
var el = document.getElementById(videoElementId);
|
|
19702
|
+
if (!el) {
|
|
19703
|
+
el = document.createElement("video");
|
|
19704
|
+
el.id = videoElementId;
|
|
19705
|
+
el.style.position = "absolute";
|
|
19706
|
+
el.style.top = "0";
|
|
19707
|
+
el.style.left = "0";
|
|
19708
|
+
el.style.width = "1920px";
|
|
19709
|
+
el.style.height = "1080px";
|
|
19710
|
+
el.style.backgroundColor = "#000";
|
|
19711
|
+
document.body.appendChild(el);
|
|
19712
|
+
}
|
|
19713
|
+
el.autoplay = true;
|
|
19714
|
+
el.muted = true;
|
|
19715
|
+
el.playsInline = true;
|
|
19716
|
+
return el;
|
|
19717
|
+
}
|
|
19718
|
+
var SamsungWasmDecoder2 = (
|
|
19719
|
+
/** @class */
|
|
19720
|
+
function() {
|
|
19721
|
+
function SamsungWasmDecoder3(videoElementId) {
|
|
19722
|
+
this.videoElementId = videoElementId;
|
|
19723
|
+
this.initialized = false;
|
|
19724
|
+
this.destroyed = false;
|
|
19725
|
+
this.decoderHandle = 0;
|
|
19726
|
+
this.ptsSeconds = 0;
|
|
19727
|
+
this.frameDurationSeconds = 0;
|
|
19728
|
+
this.videoElement = ensureVideoElement(videoElementId);
|
|
19729
|
+
}
|
|
19730
|
+
SamsungWasmDecoder3.prototype.destroy = function() {
|
|
19731
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19732
|
+
var native;
|
|
19733
|
+
return __generator(this, function(_a) {
|
|
19734
|
+
switch (_a.label) {
|
|
19735
|
+
case 0:
|
|
19736
|
+
if (this.destroyed)
|
|
19737
|
+
return [
|
|
19738
|
+
2
|
|
19739
|
+
/*return*/
|
|
19740
|
+
];
|
|
19741
|
+
this.destroyed = true;
|
|
19742
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19743
|
+
case 1:
|
|
19744
|
+
native = _a.sent();
|
|
19745
|
+
try {
|
|
19746
|
+
native.ccall("swd_destroy", "void", ["number"], [this.decoderHandle]);
|
|
19747
|
+
} catch (_b) {
|
|
19748
|
+
}
|
|
19749
|
+
this.decoderHandle = 0;
|
|
19750
|
+
return [4, (0, wasmLoader_1.destroyNativeModule)()];
|
|
19751
|
+
case 2:
|
|
19752
|
+
_a.sent();
|
|
19753
|
+
return [
|
|
19754
|
+
2
|
|
19755
|
+
/*return*/
|
|
19756
|
+
];
|
|
19757
|
+
}
|
|
19758
|
+
});
|
|
19759
|
+
});
|
|
19760
|
+
};
|
|
19761
|
+
SamsungWasmDecoder3.prototype.initialize = function(args) {
|
|
19762
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19763
|
+
var width, height, native, latencyMode, create, init, fpsNum, fpsDen, ok, isReady, maxWaitMs, pollIntervalMs, waited;
|
|
19764
|
+
var _a, _b, _c;
|
|
19765
|
+
return __generator(this, function(_d) {
|
|
19766
|
+
switch (_d.label) {
|
|
19767
|
+
case 0:
|
|
19768
|
+
if (this.destroyed) {
|
|
19769
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19770
|
+
}
|
|
19771
|
+
width = (_a = args.width) !== null && _a !== void 0 ? _a : window.screen.width;
|
|
19772
|
+
height = (_b = args.height) !== null && _b !== void 0 ? _b : window.screen.height;
|
|
19773
|
+
this.videoElement.width = width;
|
|
19774
|
+
this.videoElement.height = height;
|
|
19775
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19776
|
+
case 1:
|
|
19777
|
+
native = _d.sent();
|
|
19778
|
+
latencyMode = (_c = args.latencyMode) !== null && _c !== void 0 ? _c : videoDecoder_1.LatencyMode.Low;
|
|
19779
|
+
create = native.cwrap("swd_create", "number", ["string", "number"]);
|
|
19780
|
+
init = native.cwrap("swd_init_h264", "number", [
|
|
19781
|
+
"number",
|
|
19782
|
+
"number",
|
|
19783
|
+
"number",
|
|
19784
|
+
"number"
|
|
19785
|
+
]);
|
|
19786
|
+
this.decoderHandle = create(this.videoElementId, latencyMode);
|
|
19787
|
+
if (!this.decoderHandle) {
|
|
19788
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19789
|
+
}
|
|
19790
|
+
fpsNum = 1;
|
|
19791
|
+
fpsDen = 1;
|
|
19792
|
+
this.frameDurationSeconds = fpsDen / fpsNum;
|
|
19793
|
+
this.ptsSeconds = 0;
|
|
19794
|
+
ok = init(this.decoderHandle, width, height, fpsNum, fpsDen);
|
|
19795
|
+
if (ok !== 0) {
|
|
19796
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19797
|
+
}
|
|
19798
|
+
isReady = native.cwrap("swd_is_ready", "number", ["number"]);
|
|
19799
|
+
maxWaitMs = 5e3;
|
|
19800
|
+
pollIntervalMs = 50;
|
|
19801
|
+
waited = 0;
|
|
19802
|
+
_d.label = 2;
|
|
19803
|
+
case 2:
|
|
19804
|
+
if (!(isReady(this.decoderHandle) === 0 && waited < maxWaitMs)) return [3, 4];
|
|
19805
|
+
return [4, new Promise(function(resolve) {
|
|
19806
|
+
return setTimeout(resolve, pollIntervalMs);
|
|
19807
|
+
})];
|
|
19808
|
+
case 3:
|
|
19809
|
+
_d.sent();
|
|
19810
|
+
waited += pollIntervalMs;
|
|
19811
|
+
return [3, 2];
|
|
19812
|
+
case 4:
|
|
19813
|
+
if (isReady(this.decoderHandle) === 0) {
|
|
19814
|
+
console.error("Decoder track did not open in time");
|
|
19815
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19816
|
+
}
|
|
19817
|
+
this.initialized = true;
|
|
19818
|
+
return [2, videoDecoder_1.ResultStatus.Ok];
|
|
19819
|
+
}
|
|
19820
|
+
});
|
|
19821
|
+
});
|
|
19822
|
+
};
|
|
19823
|
+
SamsungWasmDecoder3.prototype.decodeAndRender = function(data) {
|
|
19824
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19825
|
+
var bytes, isKey, native, ptr, append, ok;
|
|
19826
|
+
return __generator(this, function(_a) {
|
|
19827
|
+
switch (_a.label) {
|
|
19828
|
+
case 0:
|
|
19829
|
+
if (!this.initialized || this.destroyed) {
|
|
19830
|
+
return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
|
|
19831
|
+
}
|
|
19832
|
+
if (!(data instanceof ArrayBuffer)) {
|
|
19833
|
+
return [2, videoDecoder_1.ResultStatus.ErrorBadArgument];
|
|
19834
|
+
}
|
|
19835
|
+
bytes = new Uint8Array(data);
|
|
19836
|
+
isKey = detectKeyFrameAnnexB(bytes);
|
|
19837
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19838
|
+
case 1:
|
|
19839
|
+
native = _a.sent();
|
|
19840
|
+
ptr = native._malloc(bytes.length);
|
|
19841
|
+
native.HEAPU8.set(bytes, ptr);
|
|
19842
|
+
try {
|
|
19843
|
+
append = native.cwrap("swd_append", "number", [
|
|
19844
|
+
"number",
|
|
19845
|
+
"number",
|
|
19846
|
+
"number",
|
|
19847
|
+
"number",
|
|
19848
|
+
"number",
|
|
19849
|
+
"number"
|
|
19850
|
+
]);
|
|
19851
|
+
ok = append(this.decoderHandle, ptr, bytes.length, isKey ? 1 : 0, this.ptsSeconds, this.frameDurationSeconds);
|
|
19852
|
+
if (ok === 0) {
|
|
19853
|
+
this.ptsSeconds += this.frameDurationSeconds;
|
|
19854
|
+
return [2, videoDecoder_1.ResultStatus.Ok];
|
|
19855
|
+
}
|
|
19856
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19857
|
+
} finally {
|
|
19858
|
+
native._free(ptr);
|
|
19859
|
+
}
|
|
19860
|
+
return [
|
|
19861
|
+
2
|
|
19862
|
+
/*return*/
|
|
19863
|
+
];
|
|
19864
|
+
}
|
|
19865
|
+
});
|
|
19866
|
+
});
|
|
19867
|
+
};
|
|
19868
|
+
SamsungWasmDecoder3.prototype.decodeAndRenderRef = function(ref) {
|
|
19869
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19870
|
+
var ptr, size, native, isKey, append, ok;
|
|
19871
|
+
return __generator(this, function(_a) {
|
|
19872
|
+
switch (_a.label) {
|
|
19873
|
+
case 0:
|
|
19874
|
+
if (!this.initialized || this.destroyed) {
|
|
19875
|
+
return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
|
|
19876
|
+
}
|
|
19877
|
+
return [4, wasmTCP_1.SamsungWasmFrameCollector.getFrameDataPointer(ref)];
|
|
19878
|
+
case 1:
|
|
19879
|
+
ptr = _a.sent();
|
|
19880
|
+
return [4, wasmTCP_1.SamsungWasmFrameCollector.getFrameSize(ref)];
|
|
19881
|
+
case 2:
|
|
19882
|
+
size = _a.sent();
|
|
19883
|
+
if (ptr === 0 || size === 0) {
|
|
19884
|
+
return [2, videoDecoder_1.ResultStatus.ErrorBadArgument];
|
|
19885
|
+
}
|
|
19886
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19887
|
+
case 3:
|
|
19888
|
+
native = _a.sent();
|
|
19889
|
+
isKey = detectKeyFrameAnnexB(native.HEAPU8.subarray(ptr, ptr + size));
|
|
19890
|
+
_a.label = 4;
|
|
19891
|
+
case 4:
|
|
19892
|
+
_a.trys.push([4, , 5, 7]);
|
|
19893
|
+
append = native.cwrap("swd_append", "number", [
|
|
19894
|
+
"number",
|
|
19895
|
+
"number",
|
|
19896
|
+
"number",
|
|
19897
|
+
"number",
|
|
19898
|
+
"number",
|
|
19899
|
+
"number"
|
|
19900
|
+
]);
|
|
19901
|
+
ok = append(this.decoderHandle, ptr, size, isKey ? 1 : 0, this.ptsSeconds, this.frameDurationSeconds);
|
|
19902
|
+
if (ok === 0) {
|
|
19903
|
+
this.ptsSeconds += this.frameDurationSeconds;
|
|
19904
|
+
return [2, videoDecoder_1.ResultStatus.Ok];
|
|
19905
|
+
}
|
|
19906
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19907
|
+
case 5:
|
|
19908
|
+
return [4, wasmTCP_1.SamsungWasmFrameCollector.releaseFrame(ref)];
|
|
19909
|
+
case 6:
|
|
19910
|
+
_a.sent();
|
|
19911
|
+
return [
|
|
19912
|
+
7
|
|
19913
|
+
/*endfinally*/
|
|
19914
|
+
];
|
|
19915
|
+
case 7:
|
|
19916
|
+
return [
|
|
19917
|
+
2
|
|
19918
|
+
/*return*/
|
|
19919
|
+
];
|
|
19920
|
+
}
|
|
19921
|
+
});
|
|
19922
|
+
});
|
|
19923
|
+
};
|
|
19924
|
+
SamsungWasmDecoder3.prototype.flush = function() {
|
|
19925
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
19926
|
+
var native, flush;
|
|
19927
|
+
return __generator(this, function(_a) {
|
|
19928
|
+
switch (_a.label) {
|
|
19929
|
+
case 0:
|
|
19930
|
+
if (!this.decoderHandle)
|
|
19931
|
+
return [2, videoDecoder_1.ResultStatus.ErrorNoInit];
|
|
19932
|
+
return [4, (0, wasmLoader_1.ensureNativeModule)()];
|
|
19933
|
+
case 1:
|
|
19934
|
+
native = _a.sent();
|
|
19935
|
+
try {
|
|
19936
|
+
flush = native.cwrap("swd_flush", "number", ["number"]);
|
|
19937
|
+
return [2, flush(this.decoderHandle) === 0 ? videoDecoder_1.ResultStatus.Ok : videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19938
|
+
} catch (_b) {
|
|
19939
|
+
return [2, videoDecoder_1.ResultStatus.ErrorFailed];
|
|
19940
|
+
}
|
|
19941
|
+
return [
|
|
19942
|
+
2
|
|
19943
|
+
/*return*/
|
|
19944
|
+
];
|
|
19945
|
+
}
|
|
19946
|
+
});
|
|
19947
|
+
});
|
|
19948
|
+
};
|
|
19949
|
+
return SamsungWasmDecoder3;
|
|
19950
|
+
}()
|
|
19951
|
+
);
|
|
19952
|
+
exports.SamsungWasmDecoder = SamsungWasmDecoder2;
|
|
19953
|
+
}
|
|
19954
|
+
});
|
|
19955
|
+
|
|
19956
|
+
// node_modules/@signageos/samsung-wasm-decoder/dist/index.js
|
|
19957
|
+
var require_dist2 = __commonJS({
|
|
19958
|
+
"node_modules/@signageos/samsung-wasm-decoder/dist/index.js"(exports) {
|
|
17538
19959
|
"use strict";
|
|
17539
|
-
var
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
19960
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
19961
|
+
function adopt(value) {
|
|
19962
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
19963
|
+
resolve(value);
|
|
19964
|
+
});
|
|
19965
|
+
}
|
|
19966
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
19967
|
+
function fulfilled(value) {
|
|
19968
|
+
try {
|
|
19969
|
+
step(generator.next(value));
|
|
19970
|
+
} catch (e) {
|
|
19971
|
+
reject(e);
|
|
19972
|
+
}
|
|
17545
19973
|
}
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
19974
|
+
function rejected(value) {
|
|
19975
|
+
try {
|
|
19976
|
+
step(generator["throw"](value));
|
|
19977
|
+
} catch (e) {
|
|
19978
|
+
reject(e);
|
|
19979
|
+
}
|
|
19980
|
+
}
|
|
19981
|
+
function step(result) {
|
|
19982
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
19983
|
+
}
|
|
19984
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19985
|
+
});
|
|
19986
|
+
};
|
|
19987
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
19988
|
+
var _ = { label: 0, sent: function() {
|
|
19989
|
+
if (t[0] & 1) throw t[1];
|
|
19990
|
+
return t[1];
|
|
19991
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
19992
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
19993
|
+
return this;
|
|
19994
|
+
}), g;
|
|
19995
|
+
function verb(n) {
|
|
19996
|
+
return function(v) {
|
|
19997
|
+
return step([n, v]);
|
|
19998
|
+
};
|
|
19999
|
+
}
|
|
20000
|
+
function step(op) {
|
|
20001
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
20002
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20003
|
+
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;
|
|
20004
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20005
|
+
switch (op[0]) {
|
|
20006
|
+
case 0:
|
|
20007
|
+
case 1:
|
|
20008
|
+
t = op;
|
|
20009
|
+
break;
|
|
20010
|
+
case 4:
|
|
20011
|
+
_.label++;
|
|
20012
|
+
return { value: op[1], done: false };
|
|
20013
|
+
case 5:
|
|
20014
|
+
_.label++;
|
|
20015
|
+
y = op[1];
|
|
20016
|
+
op = [0];
|
|
20017
|
+
continue;
|
|
20018
|
+
case 7:
|
|
20019
|
+
op = _.ops.pop();
|
|
20020
|
+
_.trys.pop();
|
|
20021
|
+
continue;
|
|
20022
|
+
default:
|
|
20023
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
20024
|
+
_ = 0;
|
|
20025
|
+
continue;
|
|
20026
|
+
}
|
|
20027
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
20028
|
+
_.label = op[1];
|
|
20029
|
+
break;
|
|
20030
|
+
}
|
|
20031
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
20032
|
+
_.label = t[1];
|
|
20033
|
+
t = op;
|
|
20034
|
+
break;
|
|
20035
|
+
}
|
|
20036
|
+
if (t && _.label < t[2]) {
|
|
20037
|
+
_.label = t[2];
|
|
20038
|
+
_.ops.push(op);
|
|
20039
|
+
break;
|
|
20040
|
+
}
|
|
20041
|
+
if (t[2]) _.ops.pop();
|
|
20042
|
+
_.trys.pop();
|
|
20043
|
+
continue;
|
|
20044
|
+
}
|
|
20045
|
+
op = body.call(thisArg, _);
|
|
20046
|
+
} catch (e) {
|
|
20047
|
+
op = [6, e];
|
|
20048
|
+
y = 0;
|
|
20049
|
+
} finally {
|
|
20050
|
+
f = t = 0;
|
|
20051
|
+
}
|
|
20052
|
+
if (op[0] & 5) throw op[1];
|
|
20053
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
20054
|
+
}
|
|
17549
20055
|
};
|
|
17550
20056
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17551
|
-
exports.
|
|
17552
|
-
exports.
|
|
17553
|
-
exports.
|
|
17554
|
-
|
|
17555
|
-
var
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
var naclDecoder_1 = require_naclDecoder();
|
|
17559
|
-
Object.defineProperty(exports, "NaClDecoder", { enumerable: true, get: function() {
|
|
17560
|
-
return naclDecoder_1.NaClDecoder;
|
|
17561
|
-
} });
|
|
17562
|
-
var videoDecoder_1 = require_videoDecoder();
|
|
17563
|
-
Object.defineProperty(exports, "HWAcceleration", { enumerable: true, get: function() {
|
|
17564
|
-
return videoDecoder_1.HWAcceleration;
|
|
20057
|
+
exports.SamsungWasmTCPStreamConnection = exports.SamsungWasmTCPStream = exports.SamsungWasmTCPPacketConnection = exports.SamsungWasmTCPPacket = exports.SamsungWasmFrameCollector = exports.SamsungWasmDecoder = exports.ResultStatus = void 0;
|
|
20058
|
+
exports.isSamsungWasmSupported = isSamsungWasmSupported3;
|
|
20059
|
+
exports.createSamsungWasmDecoder = createSamsungWasmDecoder2;
|
|
20060
|
+
exports.createSamsungWasmTCP = createSamsungWasmTCP2;
|
|
20061
|
+
var wasmDecoder_1 = require_wasmDecoder();
|
|
20062
|
+
Object.defineProperty(exports, "SamsungWasmDecoder", { enumerable: true, get: function() {
|
|
20063
|
+
return wasmDecoder_1.SamsungWasmDecoder;
|
|
17565
20064
|
} });
|
|
20065
|
+
var videoDecoder_1 = require_videoDecoder2();
|
|
17566
20066
|
Object.defineProperty(exports, "ResultStatus", { enumerable: true, get: function() {
|
|
17567
20067
|
return videoDecoder_1.ResultStatus;
|
|
17568
20068
|
} });
|
|
17569
|
-
|
|
17570
|
-
|
|
20069
|
+
var wasmLoader_1 = require_wasmLoader();
|
|
20070
|
+
var wasmTCP_1 = require_wasmTCP();
|
|
20071
|
+
Object.defineProperty(exports, "SamsungWasmFrameCollector", { enumerable: true, get: function() {
|
|
20072
|
+
return wasmTCP_1.SamsungWasmFrameCollector;
|
|
17571
20073
|
} });
|
|
17572
|
-
|
|
17573
|
-
|
|
17574
|
-
};
|
|
17575
|
-
function
|
|
17576
|
-
return
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
|
|
20074
|
+
Object.defineProperty(exports, "SamsungWasmTCPPacket", { enumerable: true, get: function() {
|
|
20075
|
+
return wasmTCP_1.SamsungWasmTCPPacket;
|
|
20076
|
+
} });
|
|
20077
|
+
Object.defineProperty(exports, "SamsungWasmTCPPacketConnection", { enumerable: true, get: function() {
|
|
20078
|
+
return wasmTCP_1.SamsungWasmTCPPacketConnection;
|
|
20079
|
+
} });
|
|
20080
|
+
Object.defineProperty(exports, "SamsungWasmTCPStream", { enumerable: true, get: function() {
|
|
20081
|
+
return wasmTCP_1.SamsungWasmTCPStream;
|
|
20082
|
+
} });
|
|
20083
|
+
Object.defineProperty(exports, "SamsungWasmTCPStreamConnection", { enumerable: true, get: function() {
|
|
20084
|
+
return wasmTCP_1.SamsungWasmTCPStreamConnection;
|
|
20085
|
+
} });
|
|
20086
|
+
function isSamsungWasmSupported3() {
|
|
20087
|
+
var _a;
|
|
20088
|
+
return typeof window.WebAssembly !== "undefined" && typeof ((_a = window.tizentvwasm) === null || _a === void 0 ? void 0 : _a.ElementaryMediaStreamSource) !== "undefined";
|
|
17580
20089
|
}
|
|
17581
|
-
function
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17589
|
-
|
|
17590
|
-
|
|
20090
|
+
function createSamsungWasmDecoder2(options) {
|
|
20091
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
20092
|
+
return __generator(this, function(_a) {
|
|
20093
|
+
switch (_a.label) {
|
|
20094
|
+
case 0:
|
|
20095
|
+
if (!isSamsungWasmSupported3()) {
|
|
20096
|
+
throw new Error("Samsung WASM decoder is not supported in this environment.");
|
|
20097
|
+
}
|
|
20098
|
+
return [4, (0, wasmLoader_1.loadWasmModule)()];
|
|
20099
|
+
case 1:
|
|
20100
|
+
_a.sent();
|
|
20101
|
+
return [2, new wasmDecoder_1.SamsungWasmDecoder(options.videoElementId)];
|
|
20102
|
+
}
|
|
20103
|
+
});
|
|
20104
|
+
});
|
|
20105
|
+
}
|
|
20106
|
+
function createSamsungWasmTCP2() {
|
|
20107
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
20108
|
+
return __generator(this, function(_a) {
|
|
20109
|
+
switch (_a.label) {
|
|
20110
|
+
case 0:
|
|
20111
|
+
if (!isSamsungWasmSupported3()) {
|
|
20112
|
+
throw new Error("Samsung WASM TCP is not supported in this environment.");
|
|
20113
|
+
}
|
|
20114
|
+
return [4, (0, wasmLoader_1.loadWasmModule)()];
|
|
20115
|
+
case 1:
|
|
20116
|
+
_a.sent();
|
|
20117
|
+
return [2, {
|
|
20118
|
+
tcpPacket: new wasmTCP_1.SamsungWasmTCPPacket(),
|
|
20119
|
+
tcpStream: new wasmTCP_1.SamsungWasmTCPStream()
|
|
20120
|
+
}];
|
|
20121
|
+
}
|
|
20122
|
+
});
|
|
20123
|
+
});
|
|
17591
20124
|
}
|
|
17592
20125
|
}
|
|
17593
20126
|
});
|
|
@@ -17845,6 +20378,7 @@ var init_dist = __esm({
|
|
|
17845
20378
|
// sdk.ts
|
|
17846
20379
|
var sdk_exports = {};
|
|
17847
20380
|
__export(sdk_exports, {
|
|
20381
|
+
createScreenControl: () => createScreenControl,
|
|
17848
20382
|
startDaemon: () => startDaemon,
|
|
17849
20383
|
startScreen: () => startScreen
|
|
17850
20384
|
});
|
|
@@ -18080,9 +20614,39 @@ async function initGoEnvironment() {
|
|
|
18080
20614
|
}
|
|
18081
20615
|
}
|
|
18082
20616
|
|
|
20617
|
+
// screen/nacltcp.ts
|
|
20618
|
+
var import_nacl_decoder = __toESM(require_dist());
|
|
20619
|
+
async function initNaClTCP() {
|
|
20620
|
+
if ((0, import_nacl_decoder.isNaClSupported)()) {
|
|
20621
|
+
const { tcpPacket, tcpStream } = (0, import_nacl_decoder.createNaClTCP)();
|
|
20622
|
+
if (!window.naclTCPPacket) {
|
|
20623
|
+
window.naclTCPPacket = tcpPacket;
|
|
20624
|
+
}
|
|
20625
|
+
if (!window.naclTCPStream) {
|
|
20626
|
+
window.naclTCPStream = tcpStream;
|
|
20627
|
+
}
|
|
20628
|
+
}
|
|
20629
|
+
}
|
|
20630
|
+
|
|
20631
|
+
// screen/samsungwasmtcp.ts
|
|
20632
|
+
var import_samsung_wasm_decoder = __toESM(require_dist2());
|
|
20633
|
+
async function initSamsungWasmTCP() {
|
|
20634
|
+
if ((0, import_samsung_wasm_decoder.isSamsungWasmSupported)()) {
|
|
20635
|
+
const { tcpPacket, tcpStream } = await (0, import_samsung_wasm_decoder.createSamsungWasmTCP)();
|
|
20636
|
+
if (!window.samsungWasmTCPStream) {
|
|
20637
|
+
window.samsungWasmTCPStream = tcpStream;
|
|
20638
|
+
}
|
|
20639
|
+
if (!window.samsungWasmTCPPacket) {
|
|
20640
|
+
window.samsungWasmTCPPacket = tcpPacket;
|
|
20641
|
+
}
|
|
20642
|
+
}
|
|
20643
|
+
}
|
|
20644
|
+
|
|
18083
20645
|
// daemon/plain.ts
|
|
18084
|
-
var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-master.
|
|
20646
|
+
var DAEMON_JS_URL = "supra-client-daemon.js?v=0.0.0-master.429";
|
|
18085
20647
|
async function startPlainDaemon() {
|
|
20648
|
+
await initNaClTCP();
|
|
20649
|
+
await initSamsungWasmTCP();
|
|
18086
20650
|
const fs = await initBrowserFS();
|
|
18087
20651
|
window.fs = fs;
|
|
18088
20652
|
process.argv = ["go", DAEMON_JS_URL];
|
|
@@ -18092,8 +20656,10 @@ async function startPlainDaemon() {
|
|
|
18092
20656
|
}
|
|
18093
20657
|
|
|
18094
20658
|
// daemon/wasm.ts
|
|
18095
|
-
var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-master.
|
|
20659
|
+
var DAEMON_WASM_URL = "supra-client-daemon.wasm?v=0.0.0-master.429";
|
|
18096
20660
|
async function startWasmDaemon() {
|
|
20661
|
+
await initNaClTCP();
|
|
20662
|
+
await initSamsungWasmTCP();
|
|
18097
20663
|
await initGoEnvironment();
|
|
18098
20664
|
await startGoDaemon();
|
|
18099
20665
|
}
|
|
@@ -18111,10 +20677,235 @@ function getGoArgv() {
|
|
|
18111
20677
|
}
|
|
18112
20678
|
|
|
18113
20679
|
// screen/nacldecoder.ts
|
|
18114
|
-
var
|
|
20680
|
+
var import_nacl_decoder2 = __toESM(require_dist());
|
|
18115
20681
|
function initNaCLDecoder() {
|
|
18116
|
-
if ((0,
|
|
18117
|
-
window.createNaClDecoder =
|
|
20682
|
+
if ((0, import_nacl_decoder2.isNaClSupported)()) {
|
|
20683
|
+
window.createNaClDecoder = import_nacl_decoder2.createNaClDecoder;
|
|
20684
|
+
}
|
|
20685
|
+
}
|
|
20686
|
+
|
|
20687
|
+
// screen/workerFrameConnection.ts
|
|
20688
|
+
var workerScript = `
|
|
20689
|
+
var socket = null;
|
|
20690
|
+
var pendingRead = null;
|
|
20691
|
+
var latestFrame = null;
|
|
20692
|
+
var frames = {};
|
|
20693
|
+
var closed = false;
|
|
20694
|
+
var GENERAL_HEADER_SIZE = 6;
|
|
20695
|
+
var FIRST_HEADER_SIZE = GENERAL_HEADER_SIZE + 9;
|
|
20696
|
+
var MAX_PACKET_SIZE = 32768;
|
|
20697
|
+
var DATA_PART_SIZE = MAX_PACKET_SIZE - GENERAL_HEADER_SIZE;
|
|
20698
|
+
|
|
20699
|
+
function postError(id, error) {
|
|
20700
|
+
self.postMessage({ type: 'error', id: id, error: error && error.message ? error.message : String(error) });
|
|
20701
|
+
}
|
|
20702
|
+
|
|
20703
|
+
function resolveFrame() {
|
|
20704
|
+
if (!pendingRead || !latestFrame) {
|
|
20705
|
+
return;
|
|
20706
|
+
}
|
|
20707
|
+
var frame = latestFrame;
|
|
20708
|
+
var id = pendingRead;
|
|
20709
|
+
pendingRead = null;
|
|
20710
|
+
latestFrame = null;
|
|
20711
|
+
self.postMessage({
|
|
20712
|
+
type: 'frame',
|
|
20713
|
+
id: id,
|
|
20714
|
+
frameType: frame.frameType,
|
|
20715
|
+
timestamp: frame.timestamp,
|
|
20716
|
+
length: frame.length,
|
|
20717
|
+
data: frame.data
|
|
20718
|
+
}, [frame.data]);
|
|
20719
|
+
}
|
|
20720
|
+
|
|
20721
|
+
function u16(view, offset) {
|
|
20722
|
+
return view.getUint16(offset, false);
|
|
20723
|
+
}
|
|
20724
|
+
|
|
20725
|
+
function u64AsNumber(view, offset) {
|
|
20726
|
+
var hi = view.getUint32(offset, false);
|
|
20727
|
+
var lo = view.getUint32(offset + 4, false);
|
|
20728
|
+
return hi * 4294967296 + lo;
|
|
20729
|
+
}
|
|
20730
|
+
|
|
20731
|
+
function handlePacket(buffer) {
|
|
20732
|
+
var length = buffer.byteLength;
|
|
20733
|
+
if (length < GENERAL_HEADER_SIZE) {
|
|
20734
|
+
return;
|
|
20735
|
+
}
|
|
20736
|
+
var view = new DataView(buffer);
|
|
20737
|
+
var frameID = u16(view, 0);
|
|
20738
|
+
var seq = u16(view, 2);
|
|
20739
|
+
var total = u16(view, 4);
|
|
20740
|
+
var headerSize = GENERAL_HEADER_SIZE;
|
|
20741
|
+
var item = frames[frameID];
|
|
20742
|
+
if (!item || seq === 0 || item.total !== total) {
|
|
20743
|
+
item = {
|
|
20744
|
+
buffer: new Uint8Array(total * DATA_PART_SIZE),
|
|
20745
|
+
frameType: 0,
|
|
20746
|
+
timestamp: 0,
|
|
20747
|
+
total: total,
|
|
20748
|
+
received: 0
|
|
20749
|
+
};
|
|
20750
|
+
frames[frameID] = item;
|
|
20751
|
+
if (seq === 0) {
|
|
20752
|
+
if (length < FIRST_HEADER_SIZE) {
|
|
20753
|
+
delete frames[frameID];
|
|
20754
|
+
return;
|
|
20755
|
+
}
|
|
20756
|
+
item.frameType = view.getUint8(GENERAL_HEADER_SIZE);
|
|
20757
|
+
item.timestamp = u64AsNumber(view, GENERAL_HEADER_SIZE + 1);
|
|
20758
|
+
headerSize = FIRST_HEADER_SIZE;
|
|
20759
|
+
}
|
|
20760
|
+
}
|
|
20761
|
+
|
|
20762
|
+
var dataStartsAt = seq * DATA_PART_SIZE;
|
|
20763
|
+
if (seq > 0) {
|
|
20764
|
+
dataStartsAt -= FIRST_HEADER_SIZE - GENERAL_HEADER_SIZE;
|
|
20765
|
+
}
|
|
20766
|
+
var packetData = new Uint8Array(buffer, headerSize);
|
|
20767
|
+
item.buffer.set(packetData, dataStartsAt);
|
|
20768
|
+
item.received++;
|
|
20769
|
+
|
|
20770
|
+
if (seq + 1 === total) {
|
|
20771
|
+
delete frames[frameID];
|
|
20772
|
+
if (item.received !== item.total) {
|
|
20773
|
+
return;
|
|
20774
|
+
}
|
|
20775
|
+
var dataEndsAt = dataStartsAt + length - headerSize;
|
|
20776
|
+
latestFrame = {
|
|
20777
|
+
frameType: item.frameType,
|
|
20778
|
+
timestamp: item.timestamp,
|
|
20779
|
+
length: dataEndsAt,
|
|
20780
|
+
data: item.buffer.buffer
|
|
20781
|
+
};
|
|
20782
|
+
resolveFrame();
|
|
20783
|
+
}
|
|
20784
|
+
}
|
|
20785
|
+
|
|
20786
|
+
self.onmessage = function(event) {
|
|
20787
|
+
var message = event.data;
|
|
20788
|
+
try {
|
|
20789
|
+
if (message.type === 'open') {
|
|
20790
|
+
socket = new WebSocket(message.url);
|
|
20791
|
+
socket.binaryType = 'arraybuffer';
|
|
20792
|
+
socket.onopen = function() {
|
|
20793
|
+
self.postMessage({ type: 'open', id: message.id });
|
|
20794
|
+
};
|
|
20795
|
+
socket.onerror = function() {
|
|
20796
|
+
postError(null, 'WebSocket error');
|
|
20797
|
+
};
|
|
20798
|
+
socket.onclose = function() {
|
|
20799
|
+
closed = true;
|
|
20800
|
+
self.postMessage({ type: 'closed' });
|
|
20801
|
+
};
|
|
20802
|
+
socket.onmessage = function(socketEvent) {
|
|
20803
|
+
if (socketEvent.data instanceof ArrayBuffer) {
|
|
20804
|
+
handlePacket(socketEvent.data);
|
|
20805
|
+
}
|
|
20806
|
+
};
|
|
20807
|
+
} else if (message.type === 'read') {
|
|
20808
|
+
if (closed) {
|
|
20809
|
+
postError(message.id, 'WebSocket closed');
|
|
20810
|
+
return;
|
|
20811
|
+
}
|
|
20812
|
+
pendingRead = message.id;
|
|
20813
|
+
resolveFrame();
|
|
20814
|
+
} else if (message.type === 'write') {
|
|
20815
|
+
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
|
20816
|
+
postError(message.id, 'WebSocket is not open');
|
|
20817
|
+
return;
|
|
20818
|
+
}
|
|
20819
|
+
socket.send(message.data);
|
|
20820
|
+
self.postMessage({ type: 'write', id: message.id, bytes: message.data.byteLength });
|
|
20821
|
+
} else if (message.type === 'close') {
|
|
20822
|
+
closed = true;
|
|
20823
|
+
if (socket) {
|
|
20824
|
+
socket.close(1000, 'Closed by client');
|
|
20825
|
+
}
|
|
20826
|
+
self.postMessage({ type: 'close', id: message.id });
|
|
20827
|
+
}
|
|
20828
|
+
} catch (error) {
|
|
20829
|
+
postError(message.id, error);
|
|
20830
|
+
}
|
|
20831
|
+
};
|
|
20832
|
+
`;
|
|
20833
|
+
function createWorker() {
|
|
20834
|
+
const blob = new Blob([workerScript], { type: "application/javascript" });
|
|
20835
|
+
return new Worker(URL.createObjectURL(blob));
|
|
20836
|
+
}
|
|
20837
|
+
var createSupraFrameWorkerConnection = (url) => {
|
|
20838
|
+
const worker = createWorker();
|
|
20839
|
+
let nextId = 1;
|
|
20840
|
+
const pending = /* @__PURE__ */ new Map();
|
|
20841
|
+
worker.onmessage = (event) => {
|
|
20842
|
+
const message = event.data;
|
|
20843
|
+
if (message.type === "closed") {
|
|
20844
|
+
pending.forEach(({ reject }) => reject(new Error("WebSocket worker closed")));
|
|
20845
|
+
pending.clear();
|
|
20846
|
+
return;
|
|
20847
|
+
}
|
|
20848
|
+
const request2 = pending.get(message.id);
|
|
20849
|
+
if (!request2) {
|
|
20850
|
+
return;
|
|
20851
|
+
}
|
|
20852
|
+
if (message.type === "error") {
|
|
20853
|
+
pending.delete(message.id);
|
|
20854
|
+
request2.reject(new Error(message.error));
|
|
20855
|
+
} else if (message.type === "open" || message.type === "close") {
|
|
20856
|
+
pending.delete(message.id);
|
|
20857
|
+
request2.resolve();
|
|
20858
|
+
} else if (message.type === "write") {
|
|
20859
|
+
pending.delete(message.id);
|
|
20860
|
+
request2.resolve(message.bytes);
|
|
20861
|
+
} else if (message.type === "frame") {
|
|
20862
|
+
pending.delete(message.id);
|
|
20863
|
+
request2.resolve({
|
|
20864
|
+
frameType: message.frameType,
|
|
20865
|
+
timestamp: message.timestamp,
|
|
20866
|
+
length: message.length,
|
|
20867
|
+
data: message.data
|
|
20868
|
+
});
|
|
20869
|
+
}
|
|
20870
|
+
};
|
|
20871
|
+
worker.onerror = (event) => {
|
|
20872
|
+
pending.forEach(({ reject }) => reject(new Error(event.message)));
|
|
20873
|
+
pending.clear();
|
|
20874
|
+
};
|
|
20875
|
+
function request(type, payload = {}, transfer) {
|
|
20876
|
+
const id = nextId++;
|
|
20877
|
+
const promise = new Promise((resolve, reject) => pending.set(id, { resolve, reject }));
|
|
20878
|
+
worker.postMessage({ ...payload, id, type }, transfer || []);
|
|
20879
|
+
return promise;
|
|
20880
|
+
}
|
|
20881
|
+
const ready = request("open", { url });
|
|
20882
|
+
ready.catch((error) => console.error("Cannot open screen worker WebSocket", error));
|
|
20883
|
+
return {
|
|
20884
|
+
collectFrame: () => ready.then(() => request("read")),
|
|
20885
|
+
write: (data) => ready.then(() => request("write", { data }, [data])),
|
|
20886
|
+
close: async () => {
|
|
20887
|
+
await ready.catch(() => void 0);
|
|
20888
|
+
await request("close");
|
|
20889
|
+
worker.terminate();
|
|
20890
|
+
}
|
|
20891
|
+
};
|
|
20892
|
+
};
|
|
20893
|
+
function initWorkerFrameConnection() {
|
|
20894
|
+
if (typeof Worker !== "undefined") {
|
|
20895
|
+
window.createSupraFrameWorkerConnection = createSupraFrameWorkerConnection;
|
|
20896
|
+
}
|
|
20897
|
+
}
|
|
20898
|
+
|
|
20899
|
+
// screen/samsungwasmdecoder.ts
|
|
20900
|
+
var import_samsung_wasm_decoder2 = __toESM(require_dist2());
|
|
20901
|
+
var import_videoDecoder = __toESM(require_videoDecoder2());
|
|
20902
|
+
async function initSamsungWasmDecoder(options) {
|
|
20903
|
+
if ((0, import_samsung_wasm_decoder2.isSamsungWasmSupported)()) {
|
|
20904
|
+
window.samsungWasmDecoder = await (0, import_samsung_wasm_decoder2.createSamsungWasmDecoder)({
|
|
20905
|
+
videoElementId: "samsung-wasm-video"
|
|
20906
|
+
});
|
|
20907
|
+
const latencyMode = options.interactive ? import_videoDecoder.LatencyMode.UltraLow : import_videoDecoder.LatencyMode.Low;
|
|
20908
|
+
await window.samsungWasmDecoder.initialize({ latencyMode });
|
|
18118
20909
|
}
|
|
18119
20910
|
}
|
|
18120
20911
|
|
|
@@ -18143,10 +20934,52 @@ function parseQueryOptions() {
|
|
|
18143
20934
|
if (typeof params.clientSecret !== "string") {
|
|
18144
20935
|
throw new Error(`Invalid clientSecret query param`);
|
|
18145
20936
|
}
|
|
18146
|
-
|
|
18147
|
-
|
|
20937
|
+
const options = {
|
|
20938
|
+
screenID: params.screenID,
|
|
20939
|
+
screenDriver: params.screenDriver,
|
|
20940
|
+
screenHost: params.screenHost,
|
|
20941
|
+
metadataDriver: params.metadataDriver,
|
|
20942
|
+
metadataHost: params.metadataHost,
|
|
20943
|
+
clientID: params.clientID,
|
|
20944
|
+
clientSecret: params.clientSecret,
|
|
20945
|
+
secure: params.secure !== "false",
|
|
20946
|
+
interactive: params.interactive === "true"
|
|
20947
|
+
};
|
|
20948
|
+
if (typeof params.forceScreenSize === "string") {
|
|
20949
|
+
const sizeParts = params.forceScreenSize.split("x");
|
|
20950
|
+
if (sizeParts.length !== 2) {
|
|
20951
|
+
throw new Error(`Invalid forceScreenSize query param`);
|
|
20952
|
+
}
|
|
20953
|
+
const width = Number(sizeParts[0]);
|
|
20954
|
+
const height = Number(sizeParts[1]);
|
|
20955
|
+
if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) {
|
|
20956
|
+
throw new Error(`Invalid forceScreenSize query param`);
|
|
20957
|
+
}
|
|
20958
|
+
options.forceScreenSize = { width, height };
|
|
20959
|
+
}
|
|
20960
|
+
const encodingPreferences = {};
|
|
20961
|
+
if (params.preferredPreset) {
|
|
20962
|
+
encodingPreferences.preferredPreset = params.preferredPreset;
|
|
20963
|
+
}
|
|
20964
|
+
if (params.preferredTune) {
|
|
20965
|
+
encodingPreferences.preferredTune = params.preferredTune;
|
|
20966
|
+
}
|
|
20967
|
+
if (params.preferredProfile) {
|
|
20968
|
+
encodingPreferences.preferredProfile = params.preferredProfile;
|
|
20969
|
+
}
|
|
20970
|
+
if (params.preferredQualityIndex) {
|
|
20971
|
+
encodingPreferences.preferredQualityIndex = Number(params.preferredQualityIndex);
|
|
20972
|
+
}
|
|
20973
|
+
if (params.preferredBitrateKbps) {
|
|
20974
|
+
encodingPreferences.preferredBitrateKbps = Number(params.preferredBitrateKbps);
|
|
20975
|
+
}
|
|
20976
|
+
if (Object.keys(encodingPreferences).length > 0) {
|
|
20977
|
+
options.encodingPreferences = encodingPreferences;
|
|
20978
|
+
}
|
|
20979
|
+
return options;
|
|
18148
20980
|
}
|
|
18149
20981
|
function getGoArgv2(binFile, options) {
|
|
20982
|
+
const encodingPrefsJson = options.encodingPreferences ? JSON.stringify(options.encodingPreferences) : "";
|
|
18150
20983
|
return [
|
|
18151
20984
|
binFile,
|
|
18152
20985
|
options.screenID,
|
|
@@ -18156,15 +20989,21 @@ function getGoArgv2(binFile, options) {
|
|
|
18156
20989
|
options.metadataHost,
|
|
18157
20990
|
options.clientID,
|
|
18158
20991
|
options.clientSecret,
|
|
18159
|
-
options.secure ? "1" : "0"
|
|
20992
|
+
options.secure ? "1" : "0",
|
|
20993
|
+
options.forceScreenSize ? `${options.forceScreenSize.width}x${options.forceScreenSize.height}` : "",
|
|
20994
|
+
encodingPrefsJson
|
|
18160
20995
|
];
|
|
18161
20996
|
}
|
|
18162
20997
|
|
|
18163
20998
|
// screen/plain.ts
|
|
18164
|
-
var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-master.
|
|
20999
|
+
var SCREEN_JS_URL = "supra-client-screen.js?v=0.0.0-master.429";
|
|
18165
21000
|
async function startPlainScreen(options) {
|
|
18166
21001
|
options = options != null ? options : parseQueryOptions();
|
|
18167
21002
|
initNaCLDecoder();
|
|
21003
|
+
initWorkerFrameConnection();
|
|
21004
|
+
await initNaClTCP();
|
|
21005
|
+
await initSamsungWasmTCP();
|
|
21006
|
+
await initSamsungWasmDecoder(options);
|
|
18168
21007
|
const fs = await initBrowserFS();
|
|
18169
21008
|
window.fs = fs;
|
|
18170
21009
|
process.argv = ["go", ...getGoArgv2(SCREEN_JS_URL, options)];
|
|
@@ -18187,9 +21026,12 @@ async function createH264Decoder() {
|
|
|
18187
21026
|
}
|
|
18188
21027
|
|
|
18189
21028
|
// screen/wasm.ts
|
|
18190
|
-
var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-master.
|
|
21029
|
+
var SCREEN_WASM_URL = "supra-client-screen.wasm?v=0.0.0-master.429";
|
|
18191
21030
|
async function startWasmScreen(options) {
|
|
18192
21031
|
options = options != null ? options : parseQueryOptions();
|
|
21032
|
+
initWorkerFrameConnection();
|
|
21033
|
+
await initSamsungWasmTCP();
|
|
21034
|
+
await initSamsungWasmDecoder(options);
|
|
18193
21035
|
await initH264Decoder();
|
|
18194
21036
|
await initGoEnvironment();
|
|
18195
21037
|
await startGoScreen(options);
|
|
@@ -18203,6 +21045,41 @@ async function startGoScreen(options) {
|
|
|
18203
21045
|
await go.run(result.instance);
|
|
18204
21046
|
}
|
|
18205
21047
|
|
|
21048
|
+
// screen/control.ts
|
|
21049
|
+
function createScreenControl(initialPreferences) {
|
|
21050
|
+
let currentPreferences = { ...initialPreferences };
|
|
21051
|
+
function pushToGoBridge(prefs) {
|
|
21052
|
+
var _a;
|
|
21053
|
+
if (typeof window !== "undefined" && ((_a = window.__supra) == null ? void 0 : _a.setEncodingPreferences)) {
|
|
21054
|
+
window.__supra.setEncodingPreferences(JSON.stringify(prefs));
|
|
21055
|
+
}
|
|
21056
|
+
}
|
|
21057
|
+
return {
|
|
21058
|
+
setEncodingPreferences(prefs) {
|
|
21059
|
+
currentPreferences = { ...currentPreferences, ...prefs };
|
|
21060
|
+
pushToGoBridge(currentPreferences);
|
|
21061
|
+
},
|
|
21062
|
+
getEncodingPreferences() {
|
|
21063
|
+
return { ...currentPreferences };
|
|
21064
|
+
},
|
|
21065
|
+
getCurrentStats() {
|
|
21066
|
+
var _a;
|
|
21067
|
+
if (typeof window === "undefined" || !((_a = window.__supra) == null ? void 0 : _a.getCurrentStats)) {
|
|
21068
|
+
return null;
|
|
21069
|
+
}
|
|
21070
|
+
const json = window.__supra.getCurrentStats();
|
|
21071
|
+
if (!json) {
|
|
21072
|
+
return null;
|
|
21073
|
+
}
|
|
21074
|
+
try {
|
|
21075
|
+
return JSON.parse(json);
|
|
21076
|
+
} catch {
|
|
21077
|
+
return null;
|
|
21078
|
+
}
|
|
21079
|
+
}
|
|
21080
|
+
};
|
|
21081
|
+
}
|
|
21082
|
+
|
|
18206
21083
|
// sdk.ts
|
|
18207
21084
|
async function startDaemon(options) {
|
|
18208
21085
|
if (shouldUsePlainJS(options)) {
|