Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

3
VApp/node_modules/mqtt/build/lib/connect/ali.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { StreamBuilder } from '../shared';
declare const buildStream: StreamBuilder;
export default buildStream;

108
VApp/node_modules/mqtt/build/lib/connect/ali.js generated vendored Normal file
View File

@ -0,0 +1,108 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer");
const readable_stream_1 = require("readable-stream");
const BufferedDuplex_1 = require("../BufferedDuplex");
let my;
let proxy;
let stream;
let isInitialized = false;
function buildProxy() {
const _proxy = new readable_stream_1.Transform();
_proxy._write = (chunk, encoding, next) => {
my.sendSocketMessage({
data: chunk.buffer,
success() {
next();
},
fail() {
next(new Error());
},
});
};
_proxy._flush = (done) => {
my.closeSocket({
success() {
done();
},
});
};
return _proxy;
}
function setDefaultOpts(opts) {
if (!opts.hostname) {
opts.hostname = 'localhost';
}
if (!opts.path) {
opts.path = '/';
}
if (!opts.wsOptions) {
opts.wsOptions = {};
}
}
function buildUrl(opts, client) {
const protocol = opts.protocol === 'alis' ? 'wss' : 'ws';
let url = `${protocol}://${opts.hostname}${opts.path}`;
if (opts.port && opts.port !== 80 && opts.port !== 443) {
url = `${protocol}://${opts.hostname}:${opts.port}${opts.path}`;
}
if (typeof opts.transformWsUrl === 'function') {
url = opts.transformWsUrl(url, opts, client);
}
return url;
}
function bindEventHandler() {
if (isInitialized)
return;
isInitialized = true;
my.onSocketOpen(() => {
stream.socketReady();
});
my.onSocketMessage((res) => {
if (typeof res.data === 'string') {
const buffer = buffer_1.Buffer.from(res.data, 'base64');
proxy.push(buffer);
}
else {
const reader = new FileReader();
reader.addEventListener('load', () => {
let data = reader.result;
if (data instanceof ArrayBuffer)
data = buffer_1.Buffer.from(data);
else
data = buffer_1.Buffer.from(data, 'utf8');
proxy.push(data);
});
reader.readAsArrayBuffer(res.data);
}
});
my.onSocketClose(() => {
stream.end();
stream.destroy();
});
my.onSocketError((err) => {
stream.destroy(err);
});
}
const buildStream = (client, opts) => {
opts.hostname = opts.hostname || opts.host;
if (!opts.hostname) {
throw new Error('Could not determine host. Specify host manually.');
}
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
? 'mqttv3.1'
: 'mqtt';
setDefaultOpts(opts);
const url = buildUrl(opts, client);
my = opts.my;
my.connectSocket({
url,
protocols: websocketSubProtocol,
});
proxy = buildProxy();
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, my);
bindEventHandler();
return stream;
};
exports.default = buildStream;
//# sourceMappingURL=ali.js.map

1
VApp/node_modules/mqtt/build/lib/connect/ali.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"ali.js","sourceRoot":"","sources":["../../../src/lib/connect/ali.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAC/B,qDAA2C;AAG3C,sDAAkD;AAElD,IAAI,EAAO,CAAA;AACX,IAAI,KAAgB,CAAA;AACpB,IAAI,MAAsB,CAAA;AAC1B,IAAI,aAAa,GAAG,KAAK,CAAA;AAEzB,SAAS,UAAU;IAClB,MAAM,MAAM,GAAG,IAAI,2BAAS,EAAE,CAAA;IAC9B,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QACzC,EAAE,CAAC,iBAAiB,CAAC;YACpB,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;YACD,IAAI;gBACH,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;YAClB,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAA;IACD,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;QACxB,EAAE,CAAC,WAAW,CAAC;YACd,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;SACD,CA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AkD,CAAC,CAAA;KACnE;IAED,MAAM,oBAAoB,GACzB,IAAI,CAAC,UAAU,KAAK,QAAQ,IAAI,IAAI,CAAC,eAAe,KAAK,CAAC;QACzD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,MAAM,CAAA;IAEV,cAAc,CAAC,IAAI,CAAC,CAAA;IAEpB,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAEZ,EAAE,CAAC,aAAa,CAAC;QAChB,GAAG;QACH,SAAS,EAAE,oBAAoB;KAC/B,CAAC,CAAA;IAEF,KAAK,GAAG,UAAU,EAAE,CAAA;IACpB,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IAE5C,gBAAgB,EAAE,CAAA;IAElB,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}

9
VApp/node_modules/mqtt/build/lib/connect/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import MqttClient, { IClientOptions } from '../client';
declare function connect(brokerUrl: string): MqttClient;
declare function connect(opts: IClientOptions): MqttClient;
declare function connect(brokerUrl: string, opts?: IClientOptions): MqttClient;
declare function connectAsync(brokerUrl: string): Promise<MqttClient>;
declare function connectAsync(opts: IClientOptions): Promise<MqttClient>;
declare function connectAsync(brokerUrl: string, opts?: IClientOptions): Promise<MqttClient>;
export default connect;
export { connectAsync };

169
VApp/node_modules/mqtt/build/lib/connect/index.js generated vendored Normal file
View File

@ -0,0 +1,169 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.connectAsync = void 0;
const debug_1 = __importDefault(require("debug"));
const url_1 = __importDefault(require("url"));
const client_1 = __importDefault(require("../client"));
const is_browser_1 = __importDefault(require("../is-browser"));
const debug = (0, debug_1.default)('mqttjs');
const protocols = {};
if (!is_browser_1.default) {
protocols.mqtt = require('./tcp').default;
protocols.tcp = require('./tcp').default;
protocols.ssl = require('./tls').default;
protocols.tls = protocols.ssl;
protocols.mqtts = require('./tls').default;
}
else {
protocols.wx = require('./wx').default;
protocols.wxs = require('./wx').default;
protocols.ali = require('./ali').default;
protocols.alis = require('./ali').default;
}
protocols.ws = require('./ws').default;
protocols.wss = require('./ws').default;
function parseAuthOptions(opts) {
let matches;
if (opts.auth) {
matches = opts.auth.match(/^(.+):(.+)$/);
if (matches) {
opts.username = matches[1];
opts.password = matches[2];
}
else {
opts.username = opts.auth;
}
}
}
function connect(brokerUrl, opts) {
debug('connecting to an MQTT broker...');
if (typeof brokerUrl === 'object' && !opts) {
opts = brokerUrl;
brokerUrl = '';
}
opts = opts || {};
if (brokerUrl && typeof brokerUrl === 'string') {
const parsed = url_1.default.parse(brokerUrl, true);
if (parsed.port != null) {
parsed.port = Number(parsed.port);
}
opts = Object.assign(Object.assign({}, parsed), opts);
if (opts.protocol === null) {
throw new Error('Missing protocol');
}
opts.protocol = opts.protocol.replace(/:$/, '');
}
parseAuthOptions(opts);
if (opts.query && typeof opts.query.clientId === 'string') {
opts.clientId = opts.query.clientId;
}
if (opts.cert && opts.key) {
if (opts.protocol) {
if (['mqtts', 'wss', 'wxs', 'alis'].indexOf(opts.protocol) === -1) {
switch (opts.protocol) {
case 'mqtt':
opts.protocol = 'mqtts';
break;
case 'ws':
opts.protocol = 'wss';
break;
case 'wx':
opts.protocol = 'wxs';
break;
case 'ali':
opts.protocol = 'alis';
break;
default:
throw new Error(`Unknown protocol for secure connection: "${opts.protocol}"!`);
}
}
}
else {
throw new Error('Missing secure protocol key');
}
}
if (!protocols[opts.protocol]) {
const isSecure = ['mqtts', 'wss'].indexOf(opts.protocol) !== -1;
opts.protocol = [
'mqtt',
'mqtts',
'ws',
'wss',
'wx',
'wxs',
'ali',
'alis',
].filter((key, index) => {
if (isSecure && index % 2 === 0) {
return false;
}
return typeof protocols[key] === 'function';
})[0];
}
if (opts.clean === false && !opts.clientId) {
throw new Error('Missing clientId for unclean clients');
}
if (opts.protocol) {
opts.defaultProtocol = opts.protocol;
}
function wrapper(client) {
if (opts.servers) {
if (!client._reconnectCount ||
client._reconnectCount === opts.servers.length) {
client._reconnectCount = 0;
}
opts.host = opts.servers[client._reconnectCount].host;
opts.port = opts.servers[client._reconnectCount].port;
opts.protocol = !opts.servers[client._reconnectCount].protocol
? opts.defaultProtocol
: opts.servers[client._reconnectCount].protocol;
opts.hostname = opts.host;
client._reconnectCount++;
}
debug('calling streambuilder for', opts.protocol);
return protocols[opts.protocol](client, opts);
}
const client = new client_1.default(wrapper, opts);
client.on('error', () => {
});
return client;
}
function connectAsync(brokerUrl, opts, allowRetries = true) {
return new Promise((resolve, reject) => {
const client = connect(brokerUrl, opts);
const promiseResolutionListeners = {
connect: (connack) => {
removePromiseResolutionListeners();
resolve(client);
},
end: () => {
removePromiseResolutionListeners();
resolve(client);
},
error: (err) => {
removePromiseResolutionListeners();
client.end();
reject(err);
},
};
if (allowRetries === false) {
promiseResolutionListeners.close = () => {
promiseResolutionListeners.error(new Error("Couldn't connect to server"));
};
}
function removePromiseResolutionListeners() {
Object.keys(promiseResolutionListeners).forEach((eventName) => {
client.off(eventName, promiseResolutionListeners[eventName]);
});
}
Object.keys(promiseResolutionListeners).forEach((eventName) => {
client.on(eventName, promiseResolutionListeners[eventName]);
});
});
}
exports.connectAsync = connectAsync;
exports.default = connect;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

3
VApp/node_modules/mqtt/build/lib/connect/tcp.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { StreamBuilder } from '../shared';
declare const buildStream: StreamBuilder;
export default buildStream;

18
VApp/node_modules/mqtt/build/lib/connect/tcp.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const net_1 = __importDefault(require("net"));
const debug_1 = __importDefault(require("debug"));
const debug = (0, debug_1.default)('mqttjs:tcp');
const buildStream = (client, opts) => {
opts.port = opts.port || 1883;
opts.hostname = opts.hostname || opts.host || 'localhost';
const { port } = opts;
const host = opts.hostname;
debug('port %d and host %s', port, host);
return net_1.default.createConnection(port, host);
};
exports.default = buildStream;
//# sourceMappingURL=tcp.js.map

1
VApp/node_modules/mqtt/build/lib/connect/tcp.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/lib/connect/tcp.ts"],"names":[],"mappings":";;;;;AAEA,8CAAqB;AACrB,kDAA0B;AAG1B,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;AAKlC,MAAM,WAAW,GAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAA;IAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,WAAW,CAAA;IAEzD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE1B,KAAK,CAAC,qBAAqB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACxC,OAAO,aAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}

3
VApp/node_modules/mqtt/build/lib/connect/tls.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { StreamBuilder } from '../shared';
declare const buildStream: StreamBuilder;
export default buildStream;

38
VApp/node_modules/mqtt/build/lib/connect/tls.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tls_1 = __importDefault(require("tls"));
const net_1 = __importDefault(require("net"));
const debug_1 = __importDefault(require("debug"));
const debug = (0, debug_1.default)('mqttjs:tls');
const buildStream = (client, opts) => {
opts.port = opts.port || 8883;
opts.host = opts.hostname || opts.host || 'localhost';
if (net_1.default.isIP(opts.host) === 0) {
opts.servername = opts.host;
}
opts.rejectUnauthorized = opts.rejectUnauthorized !== false;
delete opts.path;
debug('port %d host %s rejectUnauthorized %b', opts.port, opts.host, opts.rejectUnauthorized);
const connection = tls_1.default.connect(opts);
connection.on('secureConnect', () => {
if (opts.rejectUnauthorized && !connection.authorized) {
connection.emit('error', new Error('TLS not authorized'));
}
else {
connection.removeListener('error', handleTLSerrors);
}
});
function handleTLSerrors(err) {
if (opts.rejectUnauthorized) {
client.emit('error', err);
}
connection.end();
}
connection.on('error', handleTLSerrors);
return connection;
};
exports.default = buildStream;
//# sourceMappingURL=tls.js.map

1
VApp/node_modules/mqtt/build/lib/connect/tls.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"tls.js","sourceRoot":"","sources":["../../../src/lib/connect/tls.ts"],"names":[],"mappings":";;;;;AAAA,8CAAqB;AACrB,8CAAqB;AACrB,kDAA0B;AAG1B,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;AAElC,MAAM,WAAW,GAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAA;IAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,WAAW,CAAA;IAErD,IAAI,aAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAA;KAC3B;IAED,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,KAAK,KAAK,CAAA;IAE3D,OAAO,IAAI,CAAC,IAAI,CAAA;IAEhB,KAAK,CACJ,uCAAuC,EACvC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,kBAAkB,CACvB,CAAA;IAED,MAAM,UAAU,GAAG,aAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,UAAU,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACnC,IAAI,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACtD,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAA;SACzD;aAAM;YACN,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;SACnD;IACF,CAAC,CAAC,CAAA;IAEF,SAAS,eAAe,CAAC,GAAU;QAElC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;SACzB;QAOD,UAAU,CAAC,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IACvC,OAAO,UAAU,CAAA;AAClB,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}

3
VApp/node_modules/mqtt/build/lib/connect/ws.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { StreamBuilder } from '../shared';
declare const _default: StreamBuilder;
export default _default;

215
VApp/node_modules/mqtt/build/lib/connect/ws.js generated vendored Normal file
View File

@ -0,0 +1,215 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer");
const ws_1 = __importDefault(require("ws"));
const debug_1 = __importDefault(require("debug"));
const readable_stream_1 = require("readable-stream");
const is_browser_1 = __importDefault(require("../is-browser"));
const BufferedDuplex_1 = require("../BufferedDuplex");
const debug = (0, debug_1.default)('mqttjs:ws');
const WSS_OPTIONS = [
'rejectUnauthorized',
'ca',
'cert',
'key',
'pfx',
'passphrase',
];
function buildUrl(opts, client) {
let url = `${opts.protocol}://${opts.hostname}:${opts.port}${opts.path}`;
if (typeof opts.transformWsUrl === 'function') {
url = opts.transformWsUrl(url, opts, client);
}
return url;
}
function setDefaultOpts(opts) {
const options = opts;
if (!opts.hostname) {
options.hostname = 'localhost';
}
if (!opts.port) {
if (opts.protocol === 'wss') {
options.port = 443;
}
else {
options.port = 80;
}
}
if (!opts.path) {
options.path = '/';
}
if (!opts.wsOptions) {
options.wsOptions = {};
}
if (!is_browser_1.default && opts.protocol === 'wss') {
WSS_OPTIONS.forEach((prop) => {
if (Object.prototype.hasOwnProperty.call(opts, prop) &&
!Object.prototype.hasOwnProperty.call(opts.wsOptions, prop)) {
options.wsOptions[prop] = opts[prop];
}
});
}
return options;
}
function setDefaultBrowserOpts(opts) {
const options = setDefaultOpts(opts);
if (!options.hostname) {
options.hostname = options.host;
}
if (!options.hostname) {
if (typeof document === 'undefined') {
throw new Error('Could not determine host. Specify host manually.');
}
const parsed = new URL(document.URL);
options.hostname = parsed.hostname;
if (!options.port) {
options.port = Number(parsed.port);
}
}
if (options.objectMode === undefined) {
options.objectMode = !(options.binary === true || options.binary === undefined);
}
return options;
}
function createWebSocket(client, url, opts) {
debug('createWebSocket');
debug(`protocol: ${opts.protocolId} ${opts.protocolVersion}`);
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
? 'mqttv3.1'
: 'mqtt';
debug(`creating new Websocket for url: ${url} and protocol: ${websocketSubProtocol}`);
let socket;
if (opts.createWebsocket) {
socket = opts.createWebsocket(url, [websocketSubProtocol], opts);
}
else {
socket = new ws_1.default(url, [websocketSubProtocol], opts.wsOptions);
}
return socket;
}
function createBrowserWebSocket(client, opts) {
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
? 'mqttv3.1'
: 'mqtt';
const url = buildUrl(opts, client);
let socket;
if (opts.createWebsocket) {
socket = opts.createWebsocket(url, [websocketSubProtocol], opts);
}
else {
socket = new WebSocket(url, [websocketSubProtocol]);
}
socket.binaryType = 'arraybuffer';
return socket;
}
const streamBuilder = (client, opts) => {
debug('streamBuilder');
const options = setDefaultOpts(opts);
const url = buildUrl(options, client);
const socket = createWebSocket(client, url, options);
const webSocketStream = ws_1.default.createWebSocketStream(socket, options.wsOptions);
webSocketStream['url'] = url;
socket.on('close', () => {
webSocketStream.destroy();
});
return webSocketStream;
};
const browserStreamBuilder = (client, opts) => {
debug('browserStreamBuilder');
let stream;
const options = setDefaultBrowserOpts(opts);
const bufferSize = options.browserBufferSize || 1024 * 512;
const bufferTimeout = opts.browserBufferTimeout || 1000;
const coerceToBuffer = !opts.objectMode;
const socket = createBrowserWebSocket(client, opts);
const proxy = buildProxy(opts, socketWriteBrowser, socketEndBrowser);
if (!opts.objectMode) {
proxy._writev = BufferedDuplex_1.writev.bind(proxy);
}
proxy.on('close', () => {
socket.close();
});
const eventListenerSupport = typeof socket.addEventListener !== 'undefined';
if (socket.readyState === socket.OPEN) {
stream = proxy;
stream.socket = socket;
}
else {
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, socket);
if (eventListenerSupport) {
socket.addEventListener('open', onOpen);
}
else {
socket.onopen = onOpen;
}
}
if (eventListenerSupport) {
socket.addEventListener('close', onClose);
socket.addEventListener('error', onError);
socket.addEventListener('message', onMessage);
}
else {
socket.onclose = onClose;
socket.onerror = onError;
socket.onmessage = onMessage;
}
function buildProxy(pOptions, socketWrite, socketEnd) {
const _proxy = new readable_stream_1.Transform({
objectMode: pOptions.objectMode,
});
_proxy._write = socketWrite;
_proxy._flush = socketEnd;
return _proxy;
}
function onOpen() {
debug('WebSocket onOpen');
if (stream instanceof BufferedDuplex_1.BufferedDuplex) {
stream.socketReady();
}
}
function onClose(event) {
debug('WebSocket onClose', event);
stream.end();
stream.destroy();
}
function onError(err) {
debug('WebSocket onError', err);
const error = new Error('WebSocket error');
error['event'] = err;
stream.destroy(error);
}
function onMessage(event) {
let { data } = event;
if (data instanceof ArrayBuffer)
data = buffer_1.Buffer.from(data);
else
data = buffer_1.Buffer.from(data, 'utf8');
proxy.push(data);
}
function socketWriteBrowser(chunk, enc, next) {
if (socket.bufferedAmount > bufferSize) {
setTimeout(socketWriteBrowser, bufferTimeout, chunk, enc, next);
return;
}
if (coerceToBuffer && typeof chunk === 'string') {
chunk = buffer_1.Buffer.from(chunk, 'utf8');
}
try {
socket.send(chunk);
}
catch (err) {
return next(err);
}
next();
}
function socketEndBrowser(done) {
socket.close();
done();
}
return stream;
};
exports.default = is_browser_1.default ? browserStreamBuilder : streamBuilder;
//# sourceMappingURL=ws.js.map

1
VApp/node_modules/mqtt/build/lib/connect/ws.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

6
VApp/node_modules/mqtt/build/lib/connect/wx.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
import { StreamBuilder } from '../shared';
declare global {
const wx: any;
}
declare const buildStream: StreamBuilder;
export default buildStream;

115
VApp/node_modules/mqtt/build/lib/connect/wx.js generated vendored Normal file
View File

@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer");
const readable_stream_1 = require("readable-stream");
const BufferedDuplex_1 = require("../BufferedDuplex");
let socketTask;
let proxy;
let stream;
function buildProxy() {
const _proxy = new readable_stream_1.Transform();
_proxy._write = (chunk, encoding, next) => {
socketTask.send({
data: chunk.buffer,
success() {
next();
},
fail(errMsg) {
next(new Error(errMsg));
},
});
};
_proxy._flush = (done) => {
socketTask.close({
success() {
done();
},
});
};
return _proxy;
}
function setDefaultOpts(opts) {
if (!opts.hostname) {
opts.hostname = 'localhost';
}
if (!opts.path) {
opts.path = '/';
}
if (!opts.wsOptions) {
opts.wsOptions = {};
}
}
function buildUrl(opts, client) {
const protocol = opts.protocol === 'wxs' ? 'wss' : 'ws';
let url = `${protocol}://${opts.hostname}${opts.path}`;
if (opts.port && opts.port !== 80 && opts.port !== 443) {
url = `${protocol}://${opts.hostname}:${opts.port}${opts.path}`;
}
if (typeof opts.transformWsUrl === 'function') {
url = opts.transformWsUrl(url, opts, client);
}
return url;
}
function bindEventHandler() {
socketTask.onOpen(() => {
stream.socketReady();
});
socketTask.onMessage((res) => {
let { data } = res;
if (data instanceof ArrayBuffer)
data = buffer_1.Buffer.from(data);
else
data = buffer_1.Buffer.from(data, 'utf8');
proxy.push(data);
});
socketTask.onClose(() => {
stream.emit('close');
stream.end();
stream.destroy();
});
socketTask.onError((error) => {
const err = new Error(error.errMsg);
stream.destroy(err);
});
}
const buildStream = (client, opts) => {
opts.hostname = opts.hostname || opts.host;
if (!opts.hostname) {
throw new Error('Could not determine host. Specify host manually.');
}
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
? 'mqttv3.1'
: 'mqtt';
setDefaultOpts(opts);
const url = buildUrl(opts, client);
socketTask = wx.connectSocket({
url,
protocols: [websocketSubProtocol],
});
proxy = buildProxy();
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, socketTask);
stream._destroy = (err, cb) => {
socketTask.close({
success() {
if (cb)
cb(err);
},
});
};
const destroyRef = stream.destroy;
stream.destroy = (err, cb) => {
stream.destroy = destroyRef;
setTimeout(() => {
socketTask.close({
fail() {
stream._destroy(err, cb);
},
});
}, 0);
return stream;
};
bindEventHandler();
return stream;
};
exports.default = buildStream;
//# sourceMappingURL=wx.js.map

1
VApp/node_modules/mqtt/build/lib/connect/wx.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"wx.js","sourceRoot":"","sources":["../../../src/lib/connect/wx.ts"],"names":[],"mappings":";;AAEA,mCAA+B;AAC/B,qDAA2C;AAE3C,sDAAkD;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