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

27
VApp/node_modules/mqtt/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,27 @@
# MQTT.js is an OPEN Open Source Project
-----------------------------------------
## What?
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
## Rules
There are a few basic ground-rules for contributors:
1. **No `--force` pushes** or modifying the Git history in any way.
1. **Non-main branches** ought to be used for ongoing work.
1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors.
1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor.
1. Contributors should attempt to adhere to the prevailing code-style.
## Releases
Declaring formal releases remains the prerogative of the project maintainer.
## Changes to this arrangement
This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
-----------------------------------------

15
VApp/node_modules/mqtt/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,15 @@
The MIT License (MIT)
=====================
Copyright (c) 2015-2016 MQTT.js contributors
---------------------------------------
*MQTT.js contributors listed at <https://github.com/mqttjs/MQTT.js#contributors>*
Copyright 2011-2014 by Adam Rudd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

938
VApp/node_modules/mqtt/README.md generated vendored Normal file
View File

@ -0,0 +1,938 @@
# ![mqtt.js](https://raw.githubusercontent.com/mqttjs/MQTT.js/137ee0e3940c1f01049a30248c70f24dc6e6f829/MQTT.js.png)
![Github Test Status](https://github.com/mqttjs/MQTT.js/workflows/MQTT.js%20CI/badge.svg) [![codecov](https://codecov.io/gh/mqttjs/MQTT.js/branch/master/graph/badge.svg)](https://codecov.io/gh/mqttjs/MQTT.js)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/mqttjs/MQTT.js/graphs/commit-activity)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/mqttjs/MQTT.js/pulls)
[![node](https://img.shields.io/node/v/mqtt.svg) ![npm](https://img.shields.io/npm/v/mqtt.svg?logo=npm) ![NPM Downloads](https://img.shields.io/npm/dm/mqtt.svg)](https://www.npmjs.com/package/mqtt)
MQTT.js is a client library for the [MQTT](http://mqtt.org/) protocol, written
in JavaScript for node.js and the browser.
## Table of Contents
- [Upgrade notes](#notes)
- [Installation](#install)
- [Example](#example)
- [Import Styles](#example)
- [Command Line Tools](#cli)
- [API](#api)
- [Browser](#browser)
- [About QoS](#qos)
- [TypeScript](#typescript)
- [Weapp and Ali support](#weapp-alipay)
- [Contributing](#contributing)
- [Sponsor](#sponsor)
- [License](#license)
MQTT.js is an OPEN Open Source Project, see the [Contributing](#contributing) section to find out what this means.
[![JavaScript Style
Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
<a name="notes"></a>
## Important notes for existing users
**v5.0.0** (07/2023)
- Removes support for all end of life node versions (v12 and v14), and now supports node v18 and v20.
- Completely rewritten in Typescript 🚀.
- When creating `MqttClient` instance `new` is now required.
**v4.0.0** (Released 04/2020) removes support for all end of life node versions, and now supports node v12 and v14. It also adds improvements to
debug logging, along with some feature additions.
As a **breaking change**, by default a error handler is built into the MQTT.js client, so if any
errors are emitted and the user has not created an event handler on the client for errors, the client will
not break as a result of unhandled errors. Additionally, typical TLS errors like `ECONNREFUSED`, `ECONNRESET` have been
added to a list of TLS errors that will be emitted from the MQTT.js client, and so can be handled as connection errors.
**v3.0.0** adds support for MQTT 5, support for node v10.x, and many fixes to improve reliability.
**Note:** MQTT v5 support is experimental as it has not been implemented by brokers yet.
**v2.0.0** removes support for node v0.8, v0.10 and v0.12, and it is 3x faster in sending
packets. It also removes all the deprecated functionality in v1.0.0,
mainly `mqtt.createConnection` and `mqtt.Server`. From v2.0.0,
subscriptions are restored upon reconnection if `clean: true`.
v1.x.x is now in _LTS_, and it will keep being supported as long as
there are v0.8, v0.10 and v0.12 users.
As a **breaking change**, the `encoding` option in the old client is
removed, and now everything is UTF-8 with the exception of the
`password` in the CONNECT message and `payload` in the PUBLISH message,
which are `Buffer`.
Another **breaking change** is that MQTT.js now defaults to MQTT v3.1.1,
so to support old brokers, please read the [client options doc](#client).
**v1.0.0** improves the overall architecture of the project, which is now
split into three components: MQTT.js keeps the Client,
[mqtt-connection](http://npm.im/mqtt-connection) includes the barebone
Connection code for server-side usage, and [mqtt-packet](http://npm.im/mqtt-packet)
includes the protocol parser and generator. The new Client improves
performance by a 30% factor, embeds Websocket support
([MOWS](http://npm.im/mows) is now deprecated), and it has a better
support for QoS 1 and 2. The previous API is still supported but
deprecated, as such, it is not documented in this README.
<a name="install"></a>
## Installation
```sh
npm install mqtt --save
```
<a name="example"></a>
## Example
For the sake of simplicity, let's put the subscriber and the publisher in the same file:
```js
const mqtt = require("mqtt");
const client = mqtt.connect("mqtt://test.mosquitto.org");
client.on("connect", () => {
client.subscribe("presence", (err) => {
if (!err) {
client.publish("presence", "Hello mqtt");
}
});
});
client.on("message", (topic, message) => {
// message is Buffer
console.log(message.toString());
client.end();
});
```
output:
```sh
Hello mqtt
```
If you want to run your own MQTT broker, you can use
[Mosquitto](http://mosquitto.org) or
[Aedes-cli](https://github.com/moscajs/aedes-cli), and launch it.
You can also use a test instance: test.mosquitto.org.
If you do not want to install a separate broker, you can try using the
[Aedes](https://github.com/moscajs/aedes).
<a name="import_styles"></a>
## Import styles
### CommonJS (Require)
```js
const mqtt = require("mqtt") // require mqtt
const client = mqtt.connect("test.mosquitto.org") // create a client
```
### ES6 Modules (Import)
#### Default import
```js
import mqtt from "mqtt"; // import namespace "mqtt"
let client = mqtt.connect("mqtt://test.mosquitto.org"); // create a client
```
#### Importing individual components
```js
import { connect } from "mqtt"; // import connect from mqtt
let client = connect("mqtt://test.mosquitto.org"); // create a client
```
<a name="cli"></a>
## Command Line Tools
MQTT.js bundles a command to interact with a broker.
In order to have it available on your path, you should install MQTT.js
globally:
```sh
npm install mqtt -g
```
Then, on one terminal
```sh
mqtt sub -t 'hello' -h 'test.mosquitto.org' -v
```
On another
```sh
mqtt pub -t 'hello' -h 'test.mosquitto.org' -m 'from MQTT.js'
```
See `mqtt help <command>` for the command help.
<a name="debug"></a>
## Debug Logs
MQTT.js uses the [debug](https://www.npmjs.com/package/debug#cmd) package for debugging purposes. To enable debug logs, add the following environment variable on runtime :
```ps
# (example using PowerShell, the VS Code default)
$env:DEBUG='mqttjs*'
```
<a name="reconnecting"></a>
## About Reconnection
An important part of any websocket connection is what to do when a connection
drops off and the client needs to reconnect. MQTT has built-in reconnection
support that can be configured to behave in ways that suit the application.
#### Refresh Authentication Options / Signed Urls with `transformWsUrl` (Websocket Only)
When an mqtt connection drops and needs to reconnect, it's common to require
that any authentication associated with the connection is kept current with
the underlying auth mechanism. For instance some applications may pass an auth
token with connection options on the initial connection, while other cloud
services may require a url be signed with each connection.
By the time the reconnect happens in the application lifecycle, the original
auth data may have expired.
To address this we can use a hook called `transformWsUrl` to manipulate
either of the connection url or the client options at the time of a reconnect.
Example (update clientId & username on each reconnect):
```js
const transformWsUrl = (url, options, client) => {
client.options.username = `token=${this.get_current_auth_token()}`;
client.options.clientId = `${this.get_updated_clientId()}`;
return `${this.get_signed_cloud_url(url)}`;
}
const connection = await mqtt.connectAsync(<wss url>, {
...,
transformWsUrl: transformUrl,
});
```
Now every time a new WebSocket connection is opened (hopefully not too often),
we will get a fresh signed url or fresh auth token data.
Note: Currently this hook does _not_ support promises, meaning that in order to
use the latest auth token, you must have some outside mechanism running that
handles application-level authentication refreshing so that the websocket
connection can simply grab the latest valid token or signed url.
#### Customize Websockets with `createWebsocket` (Websocket Only)
When you need to add a custom websocket subprotocol or header to open a connection
through a proxy with custom authentication this callback allows you to create your own
instance of a websocket which will be used in the mqtt client.
```js
const createWebsocket = createWebsocket(url, websocketSubProtocols, options) => {
const subProtocols = [
websocketSubProtocols[0],
'myCustomSubprotocolOrOAuthToken',
]
return new WebSocket(url, subProtocols)
}
const connection = await mqtt.connectAsync(<wss url>, {
...,
createWebsocket: createWebsocket,
});
```
#### Enabling Reconnection with `reconnectPeriod` option
To ensure that the mqtt client automatically tries to reconnect when the
connection is dropped, you must set the client option `reconnectPeriod` to a
value greater than 0. A value of 0 will disable reconnection and then terminate
the final connection when it drops.
The default value is 1000 ms which means it will try to reconnect 1 second
after losing the connection.
<a name="topicalias"></a>
## About Topic Alias Management
### Enabling automatic Topic Alias using
If the client sets the option `autoUseTopicAlias:true` then MQTT.js uses existing topic alias automatically.
example scenario:
```bash
1. PUBLISH topic:'t1', ta:1 (register)
2. PUBLISH topic:'t1' -> topic:'', ta:1 (auto use existing map entry)
3. PUBLISH topic:'t2', ta:1 (register overwrite)
4. PUBLISH topic:'t2' -> topic:'', ta:1 (auto use existing map entry based on the receent map)
5. PUBLISH topic:'t1' (t1 is no longer mapped to ta:1)
```
User doesn't need to manage which topic is mapped to which topic alias.
If the user want to register topic alias, then publish topic with topic alias.
If the user want to use topic alias, then publish topic without topic alias. If there is a mapped topic alias then added it as a property and update the topic to empty string.
### Enabling automatic Topic Alias assign
If the client sets the option `autoAssignTopicAlias:true` then MQTT.js uses existing topic alias automatically.
If no topic alias exists, then assign a new vacant topic alias automatically. If topic alias is fully used, then LRU(Least Recently Used) topic-alias entry is overwritten.
example scenario:
```bash
The broker returns CONNACK (TopicAliasMaximum:3)
1. PUBLISH topic:'t1' -> 't1', ta:1 (auto assign t1:1 and register)
2. PUBLISH topic:'t1' -> '' , ta:1 (auto use existing map entry)
3. PUBLISH topic:'t2' -> 't2', ta:2 (auto assign t1:2 and register. 2 was vacant)
4. PUBLISH topic:'t3' -> 't3', ta:3 (auto assign t1:3 and register. 3 was vacant)
5. PUBLISH topic:'t4' -> 't4', ta:1 (LRU entry is overwritten)
```
Also user can manually register topic-alias pair using PUBLISH topic:'some', ta:X. It works well with automatic topic alias assign.
<a name="api"></a>
## API
- [`mqtt.connect()`](#connect)
- [`mqtt.connectAsync()`](#connect-async)
- [`mqtt.Client()`](#client)
- [`mqtt.Client#connect()`](#client-connect)
- [`mqtt.Client#publish()`](#publish)
- [`mqtt.Client#publishAsync()`](#publish-async)
- [`mqtt.Client#subscribe()`](#subscribe)
- [`mqtt.Client#subscribeAsync()`](#subscribe-async)
- [`mqtt.Client#unsubscribe()`](#unsubscribe)
- [`mqtt.Client#unsubscribeAsync()`](#unsubscribe-async)
- [`mqtt.Client#end()`](#end)
- [`mqtt.Client#endAsync()`](#end-async)
- [`mqtt.Client#removeOutgoingMessage()`](#removeOutgoingMessage)
- [`mqtt.Client#reconnect()`](#reconnect)
- [`mqtt.Client#handleMessage()`](#handleMessage)
- [`mqtt.Client#connected`](#connected)
- [`mqtt.Client#reconnecting`](#reconnecting)
- [`mqtt.Client#getLastMessageId()`](#getLastMessageId)
- [`mqtt.Store()`](#store)
- [`mqtt.Store#put()`](#put)
- [`mqtt.Store#del()`](#del)
- [`mqtt.Store#createStream()`](#createStream)
- [`mqtt.Store#close()`](#close)
---
<a name="connect"></a>
### mqtt.connect([url], options)
Connects to the broker specified by the given url and options and
returns a [Client](#client).
The URL can be on the following protocols: 'mqtt', 'mqtts', 'tcp',
'tls', 'ws', 'wss', 'wxs', 'alis'. The URL can also be an object as returned by
[`URL.parse()`](http://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost),
in that case the two objects are merged, i.e. you can pass a single
object with both the URL and the connect options.
You can also specify a `servers` options with content: `[{ host:
'localhost', port: 1883 }, ... ]`, in that case that array is iterated
at every connect.
For all MQTT-related options, see the [Client](#client)
constructor.
<a name="connect-async"></a>
### connectAsync([url], options)
Asynchronous wrapper around the [`connect`](#connect) function.
Returns a `Promise` that resolves to a `mqtt.Client` instance when the client
fires a `'connect'` or `'end'` event, or rejects with an error if the `'error'`
is fired.
Note that the `manualConnect` option will cause the promise returned by this
function to never resolve or reject as the underlying client never fires any
events.
---
<a name="client"></a>
### mqtt.Client(streamBuilder, options)
The `Client` class wraps a client connection to an
MQTT broker over an arbitrary transport method (TCP, TLS,
WebSocket, ecc).
`Client` is an [EventEmitter](https://nodejs.dev/en/learn/the-nodejs-event-emitter/) that has it's own [events](#events)
`Client` automatically handles the following:
- Regular server pings
- QoS flow
- Automatic reconnections
- Start publishing before being connected
The arguments are:
- `streamBuilder` is a function that returns a subclass of the `Stream` class that supports
the `connect` event. Typically a `net.Socket`.
- `options` is the client connection options (see: the [connect packet](https://github.com/mcollina/mqtt-packet#connect)). Defaults:
- `wsOptions`: is the WebSocket connection options. Default is `{}`.
It's specific for WebSockets. For possible options have a look at: <https://github.com/websockets/ws/blob/master/doc/ws.md>.
- `keepalive`: `60` seconds, set to `0` to disable
- `reschedulePings`: reschedule ping messages after sending packets (default `true`)
- `clientId`: `'mqttjs_' + Math.random().toString(16).substr(2, 8)`
- `protocolId`: `'MQTT'`
- `protocolVersion`: `4`
- `clean`: `true`, set to false to receive QoS 1 and 2 messages while
offline
- `reconnectPeriod`: `1000` milliseconds, interval between two
reconnections. Disable auto reconnect by setting to `0`.
- `connectTimeout`: `30 * 1000` milliseconds, time to wait before a
CONNACK is received
- `username`: the username required by your broker, if any
- `password`: the password required by your broker, if any
- `incomingStore`: a [Store](#store) for the incoming packets
- `outgoingStore`: a [Store](#store) for the outgoing packets
- `queueQoSZero`: if connection is broken, queue outgoing QoS zero messages (default `true`)
- `customHandleAcks`: MQTT 5 feature of custom handling puback and pubrec packets. Its callback:
```js
customHandleAcks: function(topic, message, packet, done) {/*some logic with calling done(error, reasonCode)*/}
```
- `autoUseTopicAlias`: enabling automatic Topic Alias using functionality
- `autoAssignTopicAlias`: enabling automatic Topic Alias assign functionality
- `properties`: properties MQTT 5.0.
`object` that supports the following properties:
- `sessionExpiryInterval`: representing the Session Expiry Interval in seconds `number`,
- `receiveMaximum`: representing the Receive Maximum value `number`,
- `maximumPacketSize`: representing the Maximum Packet Size the Client is willing to accept `number`,
- `topicAliasMaximum`: representing the Topic Alias Maximum value indicates the highest value that the Client will accept as a Topic Alias sent by the Server `number`,
- `requestResponseInformation`: The Client uses this value to request the Server to return Response Information in the CONNACK `boolean`,
- `requestProblemInformation`: The Client uses this value to indicate whether the Reason String or User Properties are sent in the case of failures `boolean`,
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
- `authenticationMethod`: the name of the authentication method used for extended authentication `string`,
- `authenticationData`: Binary Data containing authentication data `binary`
- `authPacket`: settings for auth packet `object`
- `will`: a message that will sent by the broker automatically when
the client disconnect badly. The format is:
- `topic`: the topic to publish
- `payload`: the message to publish
- `qos`: the QoS
- `retain`: the retain flag
- `properties`: properties of will by MQTT 5.0:
- `willDelayInterval`: representing the Will Delay Interval in seconds `number`,
- `payloadFormatIndicator`: Will Message is UTF-8 Encoded Character Data or not `boolean`,
- `messageExpiryInterval`: value is the lifetime of the Will Message in seconds and is sent as the Publication Expiry Interval when the Server publishes the Will Message `number`,
- `contentType`: describing the content of the Will Message `string`,
- `responseTopic`: String which is used as the Topic Name for a response message `string`,
- `correlationData`: The Correlation Data is used by the sender of the Request Message to identify which request the Response Message is for when it is received `binary`,
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
- `transformWsUrl` : optional `(url, options, client) => url` function
For ws/wss protocols only. Can be used to implement signing
urls which upon reconnect can have become expired.
- `createWebsocket` : optional `url, websocketSubProtocols, options) => Websocket` function
For ws/wss protocols only. Can be used to implement a custom websocket subprotocol or implementation.
- `resubscribe` : if connection is broken and reconnects,
subscribed topics are automatically subscribed again (default `true`)
- `messageIdProvider`: custom messageId provider. when `new UniqueMessageIdProvider()` is set, then non conflict messageId is provided.
- `log`: custom log function. Default uses [debug](https://www.npmjs.com/package/debug) package.
- `manualConnect`: prevents the constructor to call `connect`. In this case after the `mqtt.connect` is called you should call `client.connect` manually.
In case mqtts (mqtt over tls) is required, the `options` object is passed through to [`tls.connect()`](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback). If using a **self-signed certificate**, set `rejectUnauthorized: false`. However, be cautious as this exposes you to potential man in the middle attacks and isn't recommended for production.
For those supporting multiple TLS protocols on a single port, like MQTTS and MQTT over WSS, utilize the `ALPNProtocols` option. This lets you define the Application Layer Protocol Negotiation (ALPN) protocol. You can set `ALPNProtocols` as a string array, Buffer, or Uint8Array based on your setup.
If you are connecting to a broker that supports only MQTT 3.1 (not
3.1.1 compliant), you should pass these additional options:
```js
{
protocolId: 'MQIsdp',
protocolVersion: 3
}
```
This is confirmed on RabbitMQ 3.2.4, and on Mosquitto < 1.3. Mosquitto
version 1.3 and 1.4 works fine without those.
<a name="events"></a>
#### Event `'connect'`
`function (connack) {}`
Emitted on successful (re)connection (i.e. connack rc=0).
- `connack` received connack packet. When `clean` connection option is `false` and server has a previous session
for `clientId` connection option, then `connack.sessionPresent` flag is `true`. When that is the case,
you may rely on stored session and prefer not to send subscribe commands for the client.
#### Event `'reconnect'`
`function () {}`
Emitted when a reconnect starts.
#### Event `'close'`
`function () {}`
Emitted after a disconnection.
#### Event `'disconnect'`
`function (packet) {}`
Emitted after receiving disconnect packet from broker. MQTT 5.0 feature.
#### Event `'offline'`
`function () {}`
Emitted when the client goes offline.
#### Event `'error'`
`function (error) {}`
Emitted when the client cannot connect (i.e. connack rc != 0) or when a
parsing error occurs.
The following TLS errors will be emitted as an `error` event:
- `ECONNREFUSED`
- `ECONNRESET`
- `EADDRINUSE`
- `ENOTFOUND`
#### Event `'end'`
`function () {}`
Emitted when [`mqtt.Client#end()`](#end) is called.
If a callback was passed to `mqtt.Client#end()`, this event is emitted once the
callback returns.
#### Event `'message'`
`function (topic, message, packet) {}`
Emitted when the client receives a publish packet
- `topic` topic of the received packet
- `message` payload of the received packet
- `packet` received packet, as defined in
[mqtt-packet](https://github.com/mcollina/mqtt-packet#publish)
#### Event `'packetsend'`
`function (packet) {}`
Emitted when the client sends any packet. This includes .published() packets
as well as packets used by MQTT for managing subscriptions and connections
- `packet` received packet, as defined in
[mqtt-packet](https://github.com/mcollina/mqtt-packet)
#### Event `'packetreceive'`
`function (packet) {}`
Emitted when the client receives any packet. This includes packets from
subscribed topics as well as packets used by MQTT for managing subscriptions
and connections
- `packet` received packet, as defined in
[mqtt-packet](https://github.com/mcollina/mqtt-packet)
---
<a name="client-connect"></a>
### mqtt.Client#connect()
By default client connects when constructor is called. To prevent this you can set `manualConnect` option to `true` and call `client.connect()` manually.
<a name="publish"></a>
### mqtt.Client#publish(topic, message, [options], [callback])
Publish a message to a topic
- `topic` is the topic to publish to, `String`
- `message` is the message to publish, `Buffer` or `String`
- `options` is the options to publish with, including:
- `qos` QoS level, `Number`, default `0`
- `retain` retain flag, `Boolean`, default `false`
- `dup` mark as duplicate flag, `Boolean`, default `false`
- `properties`: MQTT 5.0 properties `object`
- `payloadFormatIndicator`: Payload is UTF-8 Encoded Character Data or not `boolean`,
- `messageExpiryInterval`: the lifetime of the Application Message in seconds `number`,
- `topicAlias`: value that is used to identify the Topic instead of using the Topic Name `number`,
- `responseTopic`: String which is used as the Topic Name for a response message `string`,
- `correlationData`: used by the sender of the Request Message to identify which request the Response Message is for when it is received `binary`,
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
- `subscriptionIdentifier`: representing the identifier of the subscription `number`,
- `contentType`: String describing the content of the Application Message `string`
- `cbStorePut` - `function ()`, fired when message is put into `outgoingStore` if QoS is `1` or `2`.
- `callback` - `function (err)`, fired when the QoS handling completes,
or at the next tick if QoS 0. An error occurs if client is disconnecting.
<a name="publish-async"></a>
### mqtt.Client#publishAsync(topic, message, [options])
Async [`publish`](#publish). Returns a `Promise<void>`.
---
<a name="subscribe"></a>
### mqtt.Client#subscribe(topic/topic array/topic object, [options], [callback])
Subscribe to a topic or topics
- `topic` is a `String` topic to subscribe to or an `Array` of
topics to subscribe to. It can also be an object, it has as object
keys the topic name and as value the QoS, like `{'test1': {qos: 0}, 'test2': {qos: 1}}`.
MQTT `topic` wildcard characters are supported (`+` - for single level and `#` - for multi level)
- `options` is the options to subscribe with, including:
- `qos` QoS subscription level, default 0
- `nl` No Local MQTT 5.0 flag (If the value is true, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection)
- `rap` Retain as Published MQTT 5.0 flag (If true, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. If false, Application Messages forwarded using this subscription have the RETAIN flag set to 0.)
- `rh` Retain Handling MQTT 5.0 (This option specifies whether retained messages are sent when the subscription is established.)
- `properties`: `object`
- `subscriptionIdentifier`: representing the identifier of the subscription `number`,
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
- `callback` - `function (err, granted)`
callback fired on suback where:
- `err` a subscription error or an error that occurs when client is disconnecting
- `granted` is an array of `{topic, qos}` where:
- `topic` is a subscribed to topic
- `qos` is the granted QoS level on it
<a name="subscribe-async"></a>
### mqtt.Client#subscribeAsync(topic/topic array/topic object, [options])
Async [`subscribe`](#subscribe). Returns a `Promise<granted[]>`.
---
<a name="unsubscribe"></a>
### mqtt.Client#unsubscribe(topic/topic array, [options], [callback])
Unsubscribe from a topic or topics
- `topic` is a `String` topic or an array of topics to unsubscribe from
- `options`: options of unsubscribe.
- `properties`: `object`
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
- `callback` - `function (err)`, fired on unsuback. An error occurs if client is disconnecting.
<a name="unsubscribe-async"></a>
### mqtt.Client#unsubscribeAsync(topic/topic array, [options])
Async [`unsubscribe`](#unsubscribe). Returns a `Promise<void>`.
---
<a name="end"></a>
### mqtt.Client#end([force], [options], [callback])
Close the client, accepts the following options:
- `force`: passing it to true will close the client right away, without
waiting for the in-flight messages to be acked. This parameter is
optional.
- `options`: options of disconnect.
- `reasonCode`: Disconnect Reason Code `number`
- `properties`: `object`
- `sessionExpiryInterval`: representing the Session Expiry Interval in seconds `number`,
- `reasonString`: representing the reason for the disconnect `string`,
- `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
- `serverReference`: String which can be used by the Client to identify another Server to use `string`
- `callback`: will be called when the client is closed. This parameter is
optional.
<a name="end-async"></a>
### mqtt.Client#endAsync([force], [options])
Async [`end`](#end). Returns a `Promise<void>`.
---
<a name="removeOutgoingMessage"></a>
### mqtt.Client#removeOutgoingMessage(mId)
Remove a message from the outgoingStore.
The outgoing callback will be called with Error('Message removed') if the message is removed.
After this function is called, the messageId is released and becomes reusable.
- `mId`: The messageId of the message in the outgoingStore.
---
<a name="reconnect"></a>
### mqtt.Client#reconnect()
Connect again using the same options as connect()
---
<a name="handleMessage"></a>
### mqtt.Client#handleMessage(packet, callback)
Handle messages with backpressure support, one at a time.
Override at will, but **always call `callback`**, or the client
will hang.
---
<a name="connected"></a>
### mqtt.Client#connected
Boolean : set to `true` if the client is connected. `false` otherwise.
---
<a name="getLastMessageId"></a>
### mqtt.Client#getLastMessageId()
Number : get last message id. This is for sent messages only.
---
<a name="reconnecting"></a>
### mqtt.Client#reconnecting
Boolean : set to `true` if the client is trying to reconnect to the server. `false` otherwise.
---
<a name="store"></a>
### mqtt.Store(options)
In-memory implementation of the message store.
- `options` is the store options:
- `clean`: `true`, clean inflight messages when close is called (default `true`)
Other implementations of `mqtt.Store`:
- [mqtt-jsonl-store](https://github.com/robertsLando/mqtt-jsonl-store) which uses
[jsonl-db](https://github.com/AlCalzone/jsonl-db) to store inflight data, it works only on Node.
- [mqtt-level-store](http://npm.im/mqtt-level-store) which uses
[Level-browserify](http://npm.im/level-browserify) to store the inflight
data, making it usable both in Node and the Browser.
- [mqtt-nedb-store](https://github.com/behrad/mqtt-nedb-store) which
uses [nedb](https://www.npmjs.com/package/nedb) to store the inflight
data.
- [mqtt-localforage-store](http://npm.im/mqtt-localforage-store) which uses
[localForage](http://npm.im/localforage) to store the inflight
data, making it usable in the Browser without browserify.
---
<a name="put"></a>
### mqtt.Store#put(packet, callback)
Adds a packet to the store, a packet is
anything that has a `messageId` property.
The callback is called when the packet has been stored.
---
<a name="createStream"></a>
### mqtt.Store#createStream()
Creates a stream with all the packets in the store.
---
<a name="del"></a>
### mqtt.Store#del(packet, cb)
Removes a packet from the store, a packet is
anything that has a `messageId` property.
The callback is called when the packet has been removed.
---
<a name="close"></a>
### mqtt.Store#close(cb)
Closes the Store.
<a name="browser"></a>
<a name="webpack"></a>
<a name="vite"></a>
## Browser
> [!IMPORTANT]
> The only protocol supported in browsers is MQTT over WebSockets, so you must use `ws://` or `wss://` protocols.
While the [ws](https://www.npmjs.com/package/ws) module is used in NodeJS, [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) is used in browsers. This is totally transparent to users except for the following:
- The `wsOption` is not supported in browsers.
- Browsers doesn't allow to catch many WebSocket errors for [security reasons](https://stackoverflow.com/a/31003057) as:
> Access to this information could allow a malicious Web page to gain information about your network, so they require browsers report all connection-time errors in an indistinguishable way.
So listening for `client.on('error')` may not catch all the errors you would get in NodeJS env.
### Bundle
MQTT.js is bundled using [esbuild](https://esbuild.github.io/). It is tested working with all bundlers like Webpack, Vite and React.
You can find all mqtt bundles versions in `dist` folder:
- `mqtt.js` - iife format, not minified
- `mqtt.min.js` - iife format, minified
- `mqtt.esm.js` - esm format minified
Starting from MQTT.js > 5.2.0 you can import mqtt in your code like this:
```js
import mqtt from 'mqtt'
```
This will be automatically handled by your bundler.
Otherwise you can choose to use a specific bundle like:
```js
import * as mqtt from 'mqtt/dist/mqtt'
import * as mqtt from 'mqtt/dist/mqtt.min'
import mqtt from 'mqtt/dist/mqtt.esm'
```
<a name="cdn"></a>
### Via CDN
The MQTT.js bundle is available through <http://unpkg.com>, specifically
at <https://unpkg.com/mqtt/dist/mqtt.min.js>.
See <http://unpkg.com> for the full documentation on version ranges.
<a name="qos"></a>
## About QoS
Here is how QoS works:
- QoS 0 : received **at most once** : The packet is sent, and that's it. There is no validation about whether it has been received.
- QoS 1 : received **at least once** : The packet is sent and stored as long as the client has not received a confirmation from the server. MQTT ensures that it _will_ be received, but there can be duplicates.
- QoS 2 : received **exactly once** : Same as QoS 1 but there is no duplicates.
About data consumption, obviously, QoS 2 > QoS 1 > QoS 0, if that's a concern to you.
<a name="typescript"></a>
## Usage with TypeScript
Starting from v5 this project is written in TypeScript and the type definitions are included in the package.
Example:
```ts
import { connect } from "mqtt"
const client = connect('mqtt://test.mosquitto.org')
```
<a name="weapp-alipay"></a>
## WeChat and Ali Mini Program support
### WeChat Mini Program
Supports [WeChat Mini Program](https://mp.weixin.qq.com/). Use the `wxs` protocol. See [the WeChat docs](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-socket.html).
```js
const mqtt = require("mqtt");
const client = mqtt.connect("wxs://test.mosquitto.org");
```
### Ali Mini Program
Supports [Ali Mini Program](https://open.alipay.com/channel/miniIndex.htm). Use the `alis` protocol. See [the Alipay docs](https://docs.alipay.com/mini/developer/getting-started).
<a name="example"></a>
```js
const mqtt = require("mqtt");
const client = mqtt.connect("alis://test.mosquitto.org");
```
<a name="contributing"></a>
## Contributing
MQTT.js is an **OPEN Open Source Project**. This means that:
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the [CONTRIBUTING.md](https://github.com/mqttjs/MQTT.js/blob/master/CONTRIBUTING.md) file for more details.
### Contributors
MQTT.js is only possible due to the excellent work of the following contributors:
| Name | GitHub | Twitter |
| ------------------ | -------------------------------------------------- | ---------------------------------------------------------- |
| Adam Rudd | [GitHub/adamvr](https://github.com/adamvr) | [Twitter/@adam_vr](http://twitter.com/adam_vr) |
| Matteo Collina | [GitHub/mcollina](https://github.com/mcollina) | [Twitter/@matteocollina](http://twitter.com/matteocollina) |
| Maxime Agor | [GitHub/4rzael](https://github.com/4rzael) | [Twitter/@4rzael](http://twitter.com/4rzael) |
| Siarhei Buntsevich | [GitHub/scarry1992](https://github.com/scarry1992) | |
| Daniel Lando | [GitHub/robertsLando](https://github.com/robertsLando) | |
<a name="sponsor"></a>
## Sponsor
If you would like to support MQTT.js, please consider sponsoring the author and active maintainers:
- [Matteo Collina](https://github.com/sponsors/mcollina): author of MQTT.js
- [Daniel Lando](https://github.com/sponsors/robertsLando): active maintainer
<a name="license"></a>
## License
MIT

2
VApp/node_modules/mqtt/build/bin/mqtt.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

30
VApp/node_modules/mqtt/build/bin/mqtt.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const commist_1 = __importDefault(require("commist"));
const help_me_1 = __importDefault(require("help-me"));
const pub_1 = __importDefault(require("./pub"));
const sub_1 = __importDefault(require("./sub"));
const version = require('../../package.json').version;
const helpMe = (0, help_me_1.default)({
dir: path_1.default.join(__dirname, '../../', 'help'),
ext: '.txt',
});
const commist = (0, commist_1.default)();
commist.register('publish', pub_1.default);
commist.register('pub', pub_1.default);
commist.register('subscribe', sub_1.default);
commist.register('sub', sub_1.default);
commist.register('version', () => {
console.log('MQTT.js version:', version);
});
commist.register('help', helpMe.toStdout);
if (commist.parse(process.argv.slice(2)) !== null) {
console.log('No such command:', process.argv[2], '\n');
helpMe.toStdout();
}
//# sourceMappingURL=mqtt.js.map

1
VApp/node_modules/mqtt/build/bin/mqtt.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"mqtt.js","sourceRoot":"","sources":["../../src/bin/mqtt.ts"],"names":[],"mappings":";;;;;;AAQA,gDAAuB;AACvB,sDAA6B;AAC7B,sDAA0B;AAC1B,gDAA2B;AAC3B,gDAA6B;AAG7B,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAA;AAErD,MAAM,MAAM,GAAG,IAAA,iBAAI,EAAC;IACnB,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC;IAC3C,GAAG,EAAE,MAAM;CACX,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAA,iBAAO,GAAE,CAAA;AAEzB,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,aAAO,CAAC,CAAA;AACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAO,CAAC,CAAA;AAEhC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAS,CAAC,CAAA;AACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAS,CAAC,CAAA;AAElC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IAChC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC,CAAC,CAAA;AACF,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AAEzC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;IAClD,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IACtD,MAAM,CAAC,QAAQ,EAAE,CAAA;CACjB"}

2
VApp/node_modules/mqtt/build/bin/pub.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
export default function start(args: string[]): any;

147
VApp/node_modules/mqtt/build/bin/pub.js generated vendored Normal file
View File

@ -0,0 +1,147 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const readable_stream_1 = require("readable-stream");
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const concat_stream_1 = __importDefault(require("concat-stream"));
const help_me_1 = __importDefault(require("help-me"));
const minimist_1 = __importDefault(require("minimist"));
const split2_1 = __importDefault(require("split2"));
const mqtt_1 = require("../mqtt");
const stream_1 = require("stream");
const helpMe = (0, help_me_1.default)({
dir: path_1.default.join(__dirname, '../../', 'help'),
});
function send(args) {
const client = (0, mqtt_1.connect)(args);
client.on('connect', () => {
client.publish(args.topic, args.message, args, (err) => {
if (err) {
console.warn(err);
}
client.end();
});
});
client.on('error', (err) => {
console.warn(err);
client.end();
});
}
function multisend(args) {
const client = (0, mqtt_1.connect)(args);
const sender = new readable_stream_1.Writable({
objectMode: true,
});
sender._write = (line, enc, cb) => {
client.publish(args.topic, line.trim(), args, cb);
};
client.on('connect', () => {
(0, stream_1.pipeline)(process.stdin, (0, split2_1.default)(), sender, (err) => {
client.end();
if (err) {
throw err;
}
});
});
}
function start(args) {
var _a, _b;
const parsedArgs = (0, minimist_1.default)(args, {
string: [
'hostname',
'username',
'password',
'key',
'cert',
'ca',
'message',
'clientId',
'i',
'id',
],
boolean: ['stdin', 'retain', 'help', 'insecure', 'multiline'],
alias: {
port: 'p',
hostname: ['h', 'host'],
topic: 't',
message: 'm',
qos: 'q',
clientId: ['i', 'id'],
retain: 'r',
username: 'u',
password: 'P',
stdin: 's',
multiline: 'M',
protocol: ['C', 'l'],
help: 'H',
ca: 'cafile',
},
default: {
host: 'localhost',
qos: 0,
retain: false,
topic: '',
message: '',
},
});
if (parsedArgs.help) {
return helpMe.toStdout('publish');
}
if (parsedArgs.key) {
parsedArgs.key = fs_1.default.readFileSync(parsedArgs.key);
}
if (parsedArgs.cert) {
parsedArgs.cert = fs_1.default.readFileSync(parsedArgs.cert);
}
if (parsedArgs.ca) {
parsedArgs.ca = fs_1.default.readFileSync(parsedArgs.ca);
}
if (parsedArgs.key && parsedArgs.cert && !parsedArgs.protocol) {
parsedArgs.protocol = 'mqtts';
}
if (parsedArgs.port) {
if (typeof parsedArgs.port !== 'number') {
console.warn("# Port: number expected, '%s' was given.", typeof parsedArgs.port);
return;
}
}
if (parsedArgs['will-topic']) {
parsedArgs.will = {};
parsedArgs.will.topic = parsedArgs['will-topic'];
parsedArgs.will.payload = parsedArgs['will-message'];
parsedArgs.will.qos = parsedArgs['will-qos'];
parsedArgs.will.retain = parsedArgs['will-retain'];
}
if (parsedArgs.insecure) {
parsedArgs.rejectUnauthorized = false;
}
parsedArgs.topic = (_a = (parsedArgs.topic || parsedArgs._.shift())) === null || _a === void 0 ? void 0 : _a.toString();
parsedArgs.message = (_b = (parsedArgs.message || parsedArgs._.shift())) === null || _b === void 0 ? void 0 : _b.toString();
if (!parsedArgs.topic) {
console.error('missing topic\n');
return helpMe.toStdout('publish');
}
if (parsedArgs.stdin) {
if (parsedArgs.multiline) {
multisend(parsedArgs);
}
else {
process.stdin.pipe((0, concat_stream_1.default)((data) => {
parsedArgs.message = data;
send(parsedArgs);
}));
}
}
else {
send(parsedArgs);
}
}
exports.default = start;
if (require.main === module) {
start(process.argv.slice(2));
}
//# sourceMappingURL=pub.js.map

1
VApp/node_modules/mqtt/build/bin/pub.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"pub.js","sourceRoot":"","sources":["../../src/bin/pub.ts"],"names":[],"mappings":";;;;;;AAEA,qDAA0C;AAC1C,gDAAuB;AACvB,4CAAmB;AACnB,kEAAkC;A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AAC,KAAK,GAAG,MAAA,CAAC,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,0CAAE,QAAQ,EAAE,CAAA;IACzE,UAAU,CAAC,OAAO,GAAG,MAAA,CACpB,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAC1C,0CAAE,QAAQ,EAAE,CAAA;IAEb,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAChC,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;KACjC;IAED,IAAI,UAAU,CAAC,KAAK,EAAE;QACrB,IAAI,UAAU,CAAC,SAAS,EAAE;YACzB,SAAS,CAAC,UAAU,CAAC,CAAA;SACrB;aAAM;YACN,OAAO,CAAC,KAAK,CAAC,IAAI,CACjB,IAAA,uBAAM,EAAC,CAAC,IAAI,EAAE,EAAE;gBACf,UAAU,CAAC,OAAO,GAAG,IAAI,CAAA;gBACzB,IAAI,CAAC,UAAU,CAAC,CAAA;YACjB,CAAC,CAAC,CACF,CAAA;SACD;KACD;SAAM;QACN,IAAI,CAAC,UAAU,CAAC,CAAA;KAChB;AACF,CAAC;AA1GD,wBA0GC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC5B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5B"}

2
VApp/node_modules/mqtt/build/bin/sub.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
export default function start(args: string[]): any;

121
VApp/node_modules/mqtt/build/bin/sub.js generated vendored Normal file
View File

@ -0,0 +1,121 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const minimist_1 = __importDefault(require("minimist"));
const help_me_1 = __importDefault(require("help-me"));
const mqtt_1 = require("../mqtt");
const helpMe = (0, help_me_1.default)({
dir: path_1.default.join(__dirname, '../../', 'help'),
});
function start(args) {
const parsedArgs = (0, minimist_1.default)(args, {
string: [
'hostname',
'username',
'password',
'key',
'cert',
'ca',
'clientId',
'i',
'id',
],
boolean: ['stdin', 'help', 'clean', 'insecure'],
alias: {
port: 'p',
hostname: ['h', 'host'],
topic: 't',
qos: 'q',
clean: 'c',
keepalive: 'k',
clientId: ['i', 'id'],
username: 'u',
password: 'P',
protocol: ['C', 'l'],
verbose: 'v',
help: '-H',
ca: 'cafile',
},
default: {
host: 'localhost',
qos: 0,
retain: false,
clean: true,
keepAlive: 30,
},
});
if (parsedArgs.help) {
return helpMe.toStdout('subscribe');
}
parsedArgs.topic = parsedArgs.topic || parsedArgs._.shift();
if (!parsedArgs.topic) {
console.error('missing topic\n');
return helpMe.toStdout('subscribe');
}
if (parsedArgs.key) {
parsedArgs.key = fs_1.default.readFileSync(parsedArgs.key);
}
if (parsedArgs.cert) {
parsedArgs.cert = fs_1.default.readFileSync(parsedArgs.cert);
}
if (parsedArgs.ca) {
parsedArgs.ca = fs_1.default.readFileSync(parsedArgs.ca);
}
if (parsedArgs.key && parsedArgs.cert && !parsedArgs.protocol) {
parsedArgs.protocol = 'mqtts';
}
if (parsedArgs.insecure) {
parsedArgs.rejectUnauthorized = false;
}
if (parsedArgs.port) {
if (typeof parsedArgs.port !== 'number') {
console.warn("# Port: number expected, '%s' was given.", typeof parsedArgs.port);
return;
}
}
if (parsedArgs['will-topic']) {
parsedArgs.will = {};
parsedArgs.will.topic = parsedArgs['will-topic'];
parsedArgs.will.payload = parsedArgs['will-message'];
parsedArgs.will.qos = parsedArgs['will-qos'];
parsedArgs.will.retain = parsedArgs['will-retain'];
}
parsedArgs.keepAlive = parsedArgs['keep-alive'];
const client = (0, mqtt_1.connect)(parsedArgs);
client.on('connect', () => {
client.subscribe(parsedArgs.topic, { qos: parsedArgs.qos }, (err, result) => {
if (err) {
console.error(err);
process.exit(1);
}
result.forEach((sub) => {
if (sub.qos > 2) {
console.error('subscription negated to', sub.topic, 'with code', sub.qos);
process.exit(1);
}
});
});
});
client.on('message', (topic, payload) => {
if (parsedArgs.verbose) {
console.log(topic, payload.toString());
}
else {
console.log(payload.toString());
}
});
client.on('error', (err) => {
console.warn(err);
client.end();
});
}
exports.default = start;
if (require.main === module) {
start(process.argv.slice(2));
}
//# sourceMappingURL=sub.js.map

1
VApp/node_modules/mqtt/build/bin/sub.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"sub.js","sourceRoot":"","sources":["../../src/bin/sub.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAuB;AACvB,4CAAmB;AACnB,wDAA+B;AAC/B,sDAA0B;AAC1B,kCAAiC;AAGjC,MAAM,MAAM,GAAG,IAAA,iBAAI,EAAC;IACnB,GAAG,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC;CAC3C,CAAC,CAAA;AAEF,SAAwB,KAAK,CAAC,IAAc;IAC3C,MAAM,UAAU,GAAG,IAAA,kBAAQ,EAAC,IAAI,EAAE;QACjC,MAAM,EAAE;YACP,UAAU;YACV,UAAU;YACV,UAAU;YACV,KAAK;YACL,MAAM;YACN,IAAI;YACJ,UAAU;YACV,GAAG;YACH,IAAI;SACJ;QACD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC;QAC/C,KAAK,EAAE;YACN,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC;YACvB,KAAK,EAAE,GAAG;YACV,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,GAAG;YACV,SAAS,EAAE,GAAG;YACd,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC;YACrB,QAAQ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AAG,CAAC,GAAG,CACP,CAAA;oBACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;iBACf;YACF,CAAC,CAAC,CAAA;QACH,CAAC,CACD,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACvC,IAAI,UAAU,CAAC,OAAO,EAAE;YACvB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;SACtC;aAAM;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;SAC/B;IACF,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjB,MAAM,CAAC,GAAG,EAAE,CAAA;IACb,CAAC,CAAC,CAAA;AACH,CAAC;AAhID,wBAgIC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC5B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5B"}

3
VApp/node_modules/mqtt/build/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import * as mqtt from './mqtt';
export default mqtt;
export * from './mqtt';

32
VApp/node_modules/mqtt/build/index.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
const mqtt = __importStar(require("./mqtt"));
exports.default = mqtt;
__exportStar(require("./mqtt"), exports);
//# sourceMappingURL=index.js.map

1
VApp/node_modules/mqtt/build/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAE9B,kBAAe,IAAI,CAAA;AACnB,yCAAsB"}

19
VApp/node_modules/mqtt/build/lib/BufferedDuplex.d.ts generated vendored Normal file
View File

@ -0,0 +1,19 @@
import { Duplex, Transform } from 'readable-stream';
import { IClientOptions } from './client';
export declare function writev(chunks: {
chunk: any;
encoding: string;
}[], cb: (err?: Error) => void): void;
export declare class BufferedDuplex extends Duplex {
socket: WebSocket;
private proxy;
private isSocketOpen;
private writeQueue;
constructor(opts: IClientOptions, proxy: Transform, socket: WebSocket);
_read(size?: number): void;
_write(chunk: any, encoding: string, cb: (err?: Error) => void): void;
_final(callback: (error?: Error) => void): void;
socketReady(): void;
private writeToProxy;
private processWriteQueue;
}

70
VApp/node_modules/mqtt/build/lib/BufferedDuplex.js generated vendored Normal file
View File

@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BufferedDuplex = exports.writev = void 0;
const readable_stream_1 = require("readable-stream");
function writev(chunks, cb) {
const buffers = new Array(chunks.length);
for (let i = 0; i < chunks.length; i++) {
if (typeof chunks[i].chunk === 'string') {
buffers[i] = Buffer.from(chunks[i].chunk, 'utf8');
}
else {
buffers[i] = chunks[i].chunk;
}
}
this._write(Buffer.concat(buffers), 'binary', cb);
}
exports.writev = writev;
class BufferedDuplex extends readable_stream_1.Duplex {
constructor(opts, proxy, socket) {
super({
objectMode: true,
});
this.proxy = proxy;
this.socket = socket;
this.writeQueue = [];
if (!opts.objectMode) {
this._writev = writev.bind(this);
}
this.isSocketOpen = false;
this.proxy.on('data', (chunk) => {
this.push(chunk);
});
}
_read(size) {
this.proxy.read(size);
}
_write(chunk, encoding, cb) {
if (!this.isSocketOpen) {
this.writeQueue.push({ chunk, encoding, cb });
}
else {
this.writeToProxy(chunk, encoding, cb);
}
}
_final(callback) {
this.writeQueue = [];
this.proxy.end(callback);
}
socketReady() {
this.emit('connect');
this.isSocketOpen = true;
this.processWriteQueue();
}
writeToProxy(chunk, encoding, cb) {
if (this.proxy.write(chunk, encoding) === false) {
this.proxy.once('drain', cb);
}
else {
cb();
}
}
processWriteQueue() {
while (this.writeQueue.length > 0) {
const { chunk, encoding, cb } = this.writeQueue.shift();
this.writeToProxy(chunk, encoding, cb);
}
}
}
exports.BufferedDuplex = BufferedDuplex;
//# sourceMappingURL=BufferedDuplex.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"BufferedDuplex.js","sourceRoot":"","sources":["../../src/lib/BufferedDuplex.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAMnD,SAAgB,MAAM,CACrB,MAA0C,EAC1C,EAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;YACxC,O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,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;SACtC;IACF,CAAC;IAED,MAAM,CAAC,QAAiC;QACvC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACzB,CAAC;IAGD,WAAW;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACzB,CAAC;IAEO,YAAY,CACnB,KAAU,EACV,QAAgB,EAChB,EAAyB;QAEzB,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,KAAK,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;SAC5B;aAAM;YACN,EAAE,EAAE,CAAA;SACJ;IACF,CAAC;IAEO,iBAAiB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YAClC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAG,CAAA;YACxD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;SACtC;IACF,CAAC;CACD;AA3ED,wCA2EC"}

10
VApp/node_modules/mqtt/build/lib/PingTimer.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
export default class PingTimer {
private keepalive;
private timer;
private checkPing;
private _setTimeout;
private _clearTimeout;
constructor(keepalive: number, checkPing: () => void);
clear(): void;
reschedule(): void;
}

55
VApp/node_modules/mqtt/build/lib/PingTimer.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const worker_timers_1 = require("worker-timers");
const is_browser_1 = __importStar(require("./is-browser"));
class PingTimer {
constructor(keepalive, checkPing) {
this._setTimeout = is_browser_1.default && !is_browser_1.isWebWorker
? worker_timers_1.setTimeout
: (func, time) => setTimeout(func, time);
this._clearTimeout = is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.clearTimeout : (timer) => clearTimeout(timer);
this.keepalive = keepalive * 1000;
this.checkPing = checkPing;
this.reschedule();
}
clear() {
if (this.timer) {
this._clearTimeout(this.timer);
this.timer = null;
}
}
reschedule() {
this.clear();
this.timer = this._setTimeout(() => {
this.checkPing();
if (this.timer) {
this.reschedule();
}
}, this.keepalive);
}
}
exports.default = PingTimer;
//# sourceMappingURL=PingTimer.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"PingTimer.js","sourceRoot":"","sources":["../../src/lib/PingTimer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0E;AAC1E,2DAAqD;AAErD,MAAqB,SAAS;IAiB7B,YAAY,SAAiB,EAAE,SAAqB;QAR5C,gBAAW,GAClB,oBAAS,IAAI,CAAC,wBAAW;YACxB,CAAC,CAAC,0BAAI;YACN,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAElC,kBAAa,GACpB,oBAAS,IAAI,CAAC,wBAAW,CAAC,CAAC,CAAC,4BAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QAGnE,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,IAAI,CAAA;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,UAAU,EAAE,CAAA;IAClB,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;SACjB;IACF,CAAC;IAED,UAAU;QACT,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI,CAAC,SAAS,EAAE,CAAA;YAGhB,IAAI,IAAI,CAAC,KAAK,EAAE;gBACf,IAAI,CAAC,UAAU,EAAE,CAAA;aACjB;QACF,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACnB,CAAC;CACD;AAzCD,4BAyCC"}

19
VApp/node_modules/mqtt/build/lib/TypedEmitter.d.ts generated vendored Normal file
View File

@ -0,0 +1,19 @@
export type EventHandler = ((arg1: any, arg2: any, arg3: any, arg4: any) => void) | ((arg1: any, arg2: any, arg3: any) => void) | ((arg1: any, arg2: any) => void) | ((arg1: any) => void) | ((...args: any[]) => void);
export interface TypedEventEmitter<TEvents extends Record<keyof TEvents, EventHandler>> {
on<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
once<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
prependListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
prependOnceListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
removeListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
off<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
removeAllListeners(event?: keyof TEvents): this;
emit<TEvent extends keyof TEvents>(event: TEvent, ...args: Parameters<TEvents[TEvent]>): boolean;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners<TEvent extends keyof TEvents>(eventName: TEvent): TEvents[TEvent][];
rawListeners<TEvent extends keyof TEvents>(eventName: TEvent): TEvents[TEvent][];
listenerCount<TEvent extends keyof TEvents>(event: TEvent, listener?: TEvents[TEvent]): number;
eventNames(): Array<keyof TEvents>;
}
export declare class TypedEventEmitter<TEvents extends Record<keyof TEvents, EventHandler>> {
}

13
VApp/node_modules/mqtt/build/lib/TypedEmitter.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedEventEmitter = void 0;
const events_1 = __importDefault(require("events"));
const shared_1 = require("./shared");
class TypedEventEmitter {
}
exports.TypedEventEmitter = TypedEventEmitter;
(0, shared_1.applyMixin)(TypedEventEmitter, events_1.default);
//# sourceMappingURL=TypedEmitter.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"TypedEmitter.js","sourceRoot":"","sources":["../../src/lib/TypedEmitter.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAiC;AACjC,qCAAqC;AAgErC,MAAa,iBAAiB;CAE1B;AAFJ,8CAEI;AAGJ,IAAA,mBAAU,EAAC,iBAAiB,EAAE,gBAAY,CAAC,CAAA"}

223
VApp/node_modules/mqtt/build/lib/client.d.ts generated vendored Normal file
View File

@ -0,0 +1,223 @@
/// <reference types="node" />
/// <reference types="node" />
import { IAuthPacket, IConnackPacket, IDisconnectPacket, IPublishPacket, ISubscribePacket, Packet, QoS, IConnectPacket } from 'mqtt-packet';
import { IMessageIdProvider } from './default-message-id-provider';
import { DuplexOptions } from 'readable-stream';
import Store, { IStore } from './store';
import { ClientOptions } from 'ws';
import { ClientRequestArgs } from 'http';
import { DoneCallback, ErrorWithReasonCode, IStream, StreamBuilder, VoidCallback } from './shared';
import { TypedEventEmitter } from './TypedEmitter';
import PingTimer from './PingTimer';
export type MqttProtocol = 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs' | 'ali' | 'alis';
export type StorePutCallback = () => void;
export interface ISecureClientOptions {
key?: string | string[] | Buffer | Buffer[] | any[];
keyPath?: string;
cert?: string | string[] | Buffer | Buffer[];
certPath?: string;
ca?: string | string[] | Buffer | Buffer[];
caPaths?: string | string[];
rejectUnauthorized?: boolean;
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
}
export type AckHandler = (topic: string, message: Buffer, packet: any, cb: (error: Error | number, code?: number) => void) => void;
export interface IClientOptions extends ISecureClientOptions {
encoding?: BufferEncoding;
browserBufferSize?: number;
binary?: boolean;
my?: any;
manualConnect?: boolean;
authPacket?: Partial<IAuthPacket>;
writeCache?: boolean;
servername?: string;
defaultProtocol?: MqttProtocol;
query?: Record<string, string>;
auth?: string;
customHandleAcks?: AckHandler;
port?: number;
host?: string;
hostname?: string;
path?: string;
protocol?: MqttProtocol;
wsOptions?: ClientOptions | ClientRequestArgs | DuplexOptions;
reconnectPeriod?: number;
connectTimeout?: number;
incomingStore?: IStore;
outgoingStore?: IStore;
queueQoSZero?: boolean;
log?: (...args: any[]) => void;
autoUseTopicAlias?: boolean;
autoAssignTopicAlias?: boolean;
reschedulePings?: boolean;
servers?: Array<{
host: string;
port: number;
protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';
}>;
resubscribe?: boolean;
transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string;
createWebsocket?: (url: string, websocketSubProtocols: string[], options: IClientOptions) => any;
messageIdProvider?: IMessageIdProvider;
browserBufferTimeout?: number;
objectMode?: boolean;
clientId?: string;
protocolVersion?: IConnectPacket['protocolVersion'];
protocolId?: IConnectPacket['protocolId'];
clean?: boolean;
keepalive?: number;
username?: string;
password?: Buffer | string;
will?: IConnectPacket['will'];
properties?: IConnectPacket['properties'];
}
export interface IClientPublishOptions {
qos?: QoS;
retain?: boolean;
dup?: boolean;
properties?: IPublishPacket['properties'];
cbStorePut?: StorePutCallback;
}
export interface IClientReconnectOptions {
incomingStore?: Store;
outgoingStore?: Store;
}
export interface IClientSubscribeProperties {
properties?: ISubscribePacket['properties'];
}
export interface IClientSubscribeOptions extends IClientSubscribeProperties {
qos: QoS;
nl?: boolean;
rap?: boolean;
rh?: number;
}
export interface ISubscriptionRequest extends IClientSubscribeOptions {
topic: string;
}
export interface ISubscriptionGrant extends Omit<ISubscriptionRequest, 'qos' | 'properties'> {
qos: QoS | 128;
}
export type ISubscriptionMap = {
[topic: string]: IClientSubscribeOptions;
} & {
resubscribe?: boolean;
};
export { IConnackPacket, IDisconnectPacket, IPublishPacket, Packet };
export type OnConnectCallback = (packet: IConnackPacket) => void;
export type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
export type ClientSubscribeCallback = (err: Error | null, granted?: ISubscriptionGrant[]) => void;
export type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void;
export type OnPacketCallback = (packet: Packet) => void;
export type OnCloseCallback = () => void;
export type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void;
export type PacketCallback = (error?: Error, packet?: Packet) => any;
export type CloseCallback = (error?: Error) => void;
export interface MqttClientEventCallbacks {
connect: OnConnectCallback;
message: OnMessageCallback;
packetsend: OnPacketCallback;
packetreceive: OnPacketCallback;
disconnect: OnDisconnectCallback;
error: OnErrorCallback;
close: OnCloseCallback;
end: VoidCallback;
reconnect: VoidCallback;
offline: VoidCallback;
outgoingEmpty: VoidCallback;
}
export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {
connected: boolean;
disconnecting: boolean;
disconnected: boolean;
reconnecting: boolean;
incomingStore: IStore;
outgoingStore: IStore;
options: IClientOptions;
queueQoSZero: boolean;
_reconnectCount: number;
log: (...args: any[]) => void;
messageIdProvider: IMessageIdProvider;
pingResp: boolean;
outgoing: Record<number, {
volatile: boolean;
cb: (err: Error, packet?: Packet) => void;
}>;
messageIdToTopic: Record<number, string[]>;
noop: (error?: any) => void;
pingTimer: PingTimer;
stream: IStream;
queue: {
packet: Packet;
cb: PacketCallback;
}[];
private streamBuilder;
private _resubscribeTopics;
private connackTimer;
private reconnectTimer;
private _storeProcessing;
private _packetIdsDuringStoreProcessing;
private _storeProcessingQueue;
private _firstConnection;
private topicAliasRecv;
private topicAliasSend;
private _deferredReconnect;
private connackPacket;
static defaultId(): string;
constructor(streamBuilder: StreamBuilder, options: IClientOptions);
handleAuth(packet: IAuthPacket, callback: PacketCallback): void;
handleMessage(packet: IPublishPacket, callback: DoneCallback): void;
private _nextId;
getLastMessageId(): number;
connect(): this;
publish(topic: string, message: string | Buffer): MqttClient;
publish(topic: string, message: string | Buffer, callback?: PacketCallback): MqttClient;
publish(topic: string, message: string | Buffer, opts?: IClientPublishOptions, callback?: PacketCallback): MqttClient;
publishAsync(topic: string, message: string | Buffer): Promise<Packet | undefined>;
publishAsync(topic: string, message: string | Buffer, opts?: IClientPublishOptions): Promise<Packet | undefined>;
subscribe(topicObject: string | string[] | ISubscriptionMap): MqttClient;
subscribe(topicObject: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback): MqttClient;
subscribe(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties): MqttClient;
subscribe(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties, callback?: ClientSubscribeCallback): MqttClient;
subscribeAsync(topicObject: string | string[] | ISubscriptionMap): Promise<ISubscriptionGrant[]>;
subscribeAsync(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties): Promise<ISubscriptionGrant[]>;
unsubscribe(topic: string | string[]): MqttClient;
unsubscribe(topic: string | string[], opts?: IClientSubscribeOptions): MqttClient;
unsubscribe(topic: string | string[], callback?: PacketCallback): MqttClient;
unsubscribe(topic: string | string[], opts?: IClientSubscribeOptions, callback?: PacketCallback): MqttClient;
unsubscribeAsync(topic: string | string[]): Promise<Packet | undefined>;
unsubscribeAsync(topic: string | string[], opts?: IClientSubscribeOptions): Promise<Packet | undefined>;
end(cb?: DoneCallback): MqttClient;
end(force?: boolean): MqttClient;
end(opts?: Partial<IDisconnectPacket>, cb?: DoneCallback): MqttClient;
end(force?: boolean, cb?: DoneCallback): MqttClient;
end(force?: boolean, opts?: Partial<IDisconnectPacket>, cb?: DoneCallback): MqttClient;
endAsync(): Promise<void>;
endAsync(force?: boolean): Promise<void>;
endAsync(opts?: Partial<IDisconnectPacket>): Promise<void>;
endAsync(force?: boolean, opts?: Partial<IDisconnectPacket>): Promise<void>;
removeOutgoingMessage(messageId: number): MqttClient;
reconnect(opts?: Pick<IClientOptions, 'incomingStore' | 'outgoingStore'>): MqttClient;
private _flushVolatile;
private _flush;
private _removeTopicAliasAndRecoverTopicName;
private _checkDisconnecting;
private _reconnect;
private _setupReconnect;
private _clearReconnect;
private _cleanUp;
private _storeAndSend;
private _applyTopicAlias;
private _noop;
private _writePacket;
private _sendPacket;
private _storePacket;
private _setupPingTimer;
private _shiftPingInterval;
private _checkPing;
private _resubscribe;
private _onConnect;
private _invokeStoreProcessingQueue;
private _invokeAllStoreProcessingQueue;
private _flushStoreProcessingQueue;
private _removeOutgoingAndStoreMessage;
}

1194
VApp/node_modules/mqtt/build/lib/client.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

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

File diff suppressed because one or more lines are too long

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,CAAC,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,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;AAG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,EAAE,CAAC,CAAA;gBACzB,CAAC;aACD,CAAC,CAAA;QACH,CAAC,EAAE,CAAC,CAAC,CAAA;QAEL,OAAO,MAAM,CAAA;IACd,CAAC,CAAA;IAED,gBAAgB,EAAE,CAAA;IAElB,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}

View File

@ -0,0 +1,16 @@
export interface IMessageIdProvider {
allocate(): number | null;
getLastAllocated(): number | null;
register(num: number): boolean;
deallocate(num: number): void;
clear(): void;
}
export default class DefaultMessageIdProvider implements IMessageIdProvider {
private nextId;
constructor();
allocate(): number;
getLastAllocated(): number;
register(messageId: number): boolean;
deallocate(messageId: number): void;
clear(): void;
}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class DefaultMessageIdProvider {
constructor() {
this.nextId = Math.max(1, Math.floor(Math.random() * 65535));
}
allocate() {
const id = this.nextId++;
if (this.nextId === 65536) {
this.nextId = 1;
}
return id;
}
getLastAllocated() {
return this.nextId === 1 ? 65535 : this.nextId - 1;
}
register(messageId) {
return true;
}
deallocate(messageId) { }
clear() { }
}
exports.default = DefaultMessageIdProvider;
//# sourceMappingURL=default-message-id-provider.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"default-message-id-provider.js","sourceRoot":"","sources":["../../src/lib/default-message-id-provider.ts"],"names":[],"mappings":";;AAwCA,MAAqB,wBAAwB;IAG5C;QAKC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAA;IAC7D,CAAC;IAQD,QAAQ;QAEP,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAExB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE;YAC1B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;SACf;QACD,OAAO,EAAE,CAAA;IACV,CAAC;IAOD,gBAAgB;QACf,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IACnD,CAAC;IAQD,QAAQ,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAA;IACZ,CAAC;IAOD,UAAU,CAAC,SAAiB,IAAG,CAAC;IAMhC,KAAK,KAAI,CAAC;CACV;AA1DD,2CA0DC"}

48
VApp/node_modules/mqtt/build/lib/handlers/ack.d.ts generated vendored Normal file
View File

@ -0,0 +1,48 @@
import { PacketHandler } from '../shared';
export declare const ReasonCodes: {
0: string;
1: string;
2: string;
3: string;
4: string;
5: string;
16: string;
17: string;
128: string;
129: string;
130: string;
131: string;
132: string;
133: string;
134: string;
135: string;
136: string;
137: string;
138: string;
139: string;
140: string;
141: string;
142: string;
143: string;
144: string;
145: string;
146: string;
147: string;
148: string;
149: string;
150: string;
151: string;
152: string;
153: string;
154: string;
155: string;
156: string;
157: string;
158: string;
159: string;
160: string;
161: string;
162: string;
};
declare const handleAck: PacketHandler;
export default handleAck;

129
VApp/node_modules/mqtt/build/lib/handlers/ack.js generated vendored Normal file
View File

@ -0,0 +1,129 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReasonCodes = void 0;
exports.ReasonCodes = {
0: '',
1: 'Unacceptable protocol version',
2: 'Identifier rejected',
3: 'Server unavailable',
4: 'Bad username or password',
5: 'Not authorized',
16: 'No matching subscribers',
17: 'No subscription existed',
128: 'Unspecified error',
129: 'Malformed Packet',
130: 'Protocol Error',
131: 'Implementation specific error',
132: 'Unsupported Protocol Version',
133: 'Client Identifier not valid',
134: 'Bad User Name or Password',
135: 'Not authorized',
136: 'Server unavailable',
137: 'Server busy',
138: 'Banned',
139: 'Server shutting down',
140: 'Bad authentication method',
141: 'Keep Alive timeout',
142: 'Session taken over',
143: 'Topic Filter invalid',
144: 'Topic Name invalid',
145: 'Packet identifier in use',
146: 'Packet Identifier not found',
147: 'Receive Maximum exceeded',
148: 'Topic Alias invalid',
149: 'Packet too large',
150: 'Message rate too high',
151: 'Quota exceeded',
152: 'Administrative action',
153: 'Payload format invalid',
154: 'Retain not supported',
155: 'QoS not supported',
156: 'Use another server',
157: 'Server moved',
158: 'Shared Subscriptions not supported',
159: 'Connection rate exceeded',
160: 'Maximum connect time',
161: 'Subscription Identifiers not supported',
162: 'Wildcard Subscriptions not supported',
};
const handleAck = (client, packet) => {
const { messageId } = packet;
const type = packet.cmd;
let response = null;
const cb = client.outgoing[messageId] ? client.outgoing[messageId].cb : null;
let err;
if (!cb) {
client.log('_handleAck :: Server sent an ack in error. Ignoring.');
return;
}
client.log('_handleAck :: packet type', type);
switch (type) {
case 'pubcomp':
case 'puback': {
const pubackRC = packet.reasonCode;
if (pubackRC && pubackRC > 0 && pubackRC !== 16) {
err = new Error(`Publish error: ${exports.ReasonCodes[pubackRC]}`);
err.code = pubackRC;
client['_removeOutgoingAndStoreMessage'](messageId, () => {
cb(err, packet);
});
}
else {
client['_removeOutgoingAndStoreMessage'](messageId, cb);
}
break;
}
case 'pubrec': {
response = {
cmd: 'pubrel',
qos: 2,
messageId,
};
const pubrecRC = packet.reasonCode;
if (pubrecRC && pubrecRC > 0 && pubrecRC !== 16) {
err = new Error(`Publish error: ${exports.ReasonCodes[pubrecRC]}`);
err.code = pubrecRC;
client['_removeOutgoingAndStoreMessage'](messageId, () => {
cb(err, packet);
});
}
else {
client['_sendPacket'](response);
}
break;
}
case 'suback': {
delete client.outgoing[messageId];
client.messageIdProvider.deallocate(messageId);
const granted = packet.granted;
for (let grantedI = 0; grantedI < granted.length; grantedI++) {
if ((granted[grantedI] & 0x80) !== 0) {
const topics = client.messageIdToTopic[messageId];
if (topics) {
topics.forEach((topic) => {
delete client['_resubscribeTopics'][topic];
});
}
}
}
delete client.messageIdToTopic[messageId];
client['_invokeStoreProcessingQueue']();
cb(null, packet);
break;
}
case 'unsuback': {
delete client.outgoing[messageId];
client.messageIdProvider.deallocate(messageId);
client['_invokeStoreProcessingQueue']();
cb(null);
break;
}
default:
client.emit('error', new Error('unrecognized packet type'));
}
if (client.disconnecting && Object.keys(client.outgoing).length === 0) {
client.emit('outgoingEmpty');
}
};
exports.default = handleAck;
//# sourceMappingURL=ack.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"ack.js","sourceRoot":"","sources":["../../../src/lib/handlers/ack.ts"],"names":[],"mappings":";;;AAIa,QAAA,WAAW,GAAG;IAC1B,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,+BAA+B;IAClC,CAAC,EAAE,qBAAqB;IACxB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,0BAA0B;IAC7B,CAAC,EAAE,gBAAgB;IACnB,EAAE,EAAE,yBAAyB;IAC7B,EAAE,EAAE,yBAAyB;IAC7B,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,8BAA8B;IACnC,GAAG,EAAE,6BAA6B;IAClC,GAAG,EAAE,2BAA2B;IAChC,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,2BAA2B;IAChC,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,0BAA0B;IAC/B,GAAG,EAAE,6BAA6B;IAClC,GAAG,EAAE,0BAA0B;IAC/B,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,uBAAuB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BACjD,IAAI,MAAM,EAAE;wBACX,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;4BACxB,OAAO,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,CAAA;wBAC3C,CAAC,CAAC,CAAA;qBACF;iBACD;aACD;YACD,OAAO,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;YACzC,MAAM,CAAC,6BAA6B,CAAC,EAAE,CAAA;YACvC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAChB,MAAK;SACL;QACD,KAAK,UAAU,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YACjC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;YAC9C,MAAM,CAAC,6BAA6B,CAAC,EAAE,CAAA;YACvC,EAAE,CAAC,IAAI,CAAC,CAAA;YACR,MAAK;SACL;QACD;YACC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAA;KAC5D;IAED,IAAI,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACtE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;KAC5B;AACF,CAAC,CAAA;AAED,kBAAe,SAAS,CAAA"}

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

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

30
VApp/node_modules/mqtt/build/lib/handlers/auth.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_1 = require("../shared");
const ack_1 = require("./ack");
const handleAuth = (client, packet) => {
const { options } = client;
const version = options.protocolVersion;
const rc = version === 5 ? packet.reasonCode : packet.returnCode;
if (version !== 5) {
const err = new shared_1.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${version}`, rc);
client.emit('error', err);
return;
}
client.handleAuth(packet, (err, packet2) => {
if (err) {
client.emit('error', err);
return;
}
if (rc === 24) {
client.reconnecting = false;
client['_sendPacket'](packet2);
}
else {
const error = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
client.emit('error', error);
}
});
};
exports.default = handleAuth;
//# sourceMappingURL=auth.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/handlers/auth.ts"],"names":[],"mappings":";;AACA,sCAA8D;AAC9D,+BAAmC;AAEnC,MAAM,UAAU,GAAkB,CACjC,MAAM,EACN,MAA4C,EAC3C,EAAE;IACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAA;IACvC,MAAM,EAAE,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAA;IAEhE,IAAI,OAAO,KAAK,CAAC,EAAE;QAClB,MAAM,GAAG,GAAG,IAAI,4BAAmB,CAClC,2EAA2E,OAAO,EAAE,EACpF,EAAE,CACF,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzB,OAAM;KACN;IAED,MAAM,CAAC,UAAU,CAChB,MAAM,EACN,CAAC,GAAwB,EAAE,OAAoB,EAAE,EAAE;QAClD,IAAI,GAAG,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YACzB,OAAM;SACN;QAED,IAAI,EAAE,KAAK,EAAE,EAAE;YACd,MAAM,CAAC,YAAY,GAAG,KAAK,CAAA;YAC3B,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA;SAC9B;aAAM;YACN,MAAM,KAAK,GAAG,IAAI,4BAAmB,CACpC,uBAAuB,iBAAW,CAAC,EAAE,CAAC,EAAE,EACxC,EAAE,CACF,CAAA;YACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;SAC3B;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AAED,kBAAe,UAAU,CAAA"}

View File

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

48
VApp/node_modules/mqtt/build/lib/handlers/connack.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ack_1 = require("./ack");
const topic_alias_send_1 = __importDefault(require("../topic-alias-send"));
const shared_1 = require("../shared");
const handleConnack = (client, packet) => {
client.log('_handleConnack');
const { options } = client;
const version = options.protocolVersion;
const rc = version === 5 ? packet.reasonCode : packet.returnCode;
clearTimeout(client['connackTimer']);
delete client['topicAliasSend'];
if (packet.properties) {
if (packet.properties.topicAliasMaximum) {
if (packet.properties.topicAliasMaximum > 0xffff) {
client.emit('error', new Error('topicAliasMaximum from broker is out of range'));
return;
}
if (packet.properties.topicAliasMaximum > 0) {
client['topicAliasSend'] = new topic_alias_send_1.default(packet.properties.topicAliasMaximum);
}
}
if (packet.properties.serverKeepAlive && options.keepalive) {
options.keepalive = packet.properties.serverKeepAlive;
client['_shiftPingInterval']();
}
if (packet.properties.maximumPacketSize) {
if (!options.properties) {
options.properties = {};
}
options.properties.maximumPacketSize =
packet.properties.maximumPacketSize;
}
}
if (rc === 0) {
client.reconnecting = false;
client['_onConnect'](packet);
}
else if (rc > 0) {
const err = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
client.emit('error', err);
}
};
exports.default = handleConnack;
//# sourceMappingURL=connack.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BAAiB,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;gBACxB,OAAO,CAAC,UAAU,GAAG,EAAE,CAAA;aACvB;YACD,OAAO,CAAC,UAAU,CAAC,iBAAiB;gBACnC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAA;SACpC;KACD;IAED,IAAI,EAAE,KAAK,CAAC,EAAE;QACb,MAAM,CAAC,YAAY,GAAG,KAAK,CAAA;QAC3B,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;KAC5B;SAAM,IAAI,EAAE,GAAG,CAAC,EAAE;QAClB,MAAM,GAAG,GAAG,IAAI,4BAAmB,CAClC,uBAAuB,iBAAW,CAAC,EAAE,CAAC,EAAE,EACxC,EAAE,CACF,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;KACzB;AACF,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA"}

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

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

64
VApp/node_modules/mqtt/build/lib/handlers/index.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const publish_1 = __importDefault(require("./publish"));
const auth_1 = __importDefault(require("./auth"));
const connack_1 = __importDefault(require("./connack"));
const ack_1 = __importDefault(require("./ack"));
const pubrel_1 = __importDefault(require("./pubrel"));
const handle = (client, packet, done) => {
const { options } = client;
if (options.protocolVersion === 5 &&
options.properties &&
options.properties.maximumPacketSize &&
options.properties.maximumPacketSize < packet.length) {
client.emit('error', new Error(`exceeding packets size ${packet.cmd}`));
client.end({
reasonCode: 149,
properties: { reasonString: 'Maximum packet size was exceeded' },
});
return client;
}
client.log('_handlePacket :: emitting packetreceive');
client.emit('packetreceive', packet);
switch (packet.cmd) {
case 'publish':
(0, publish_1.default)(client, packet, done);
break;
case 'puback':
case 'pubrec':
case 'pubcomp':
case 'suback':
case 'unsuback':
(0, ack_1.default)(client, packet);
done();
break;
case 'pubrel':
(0, pubrel_1.default)(client, packet, done);
break;
case 'connack':
(0, connack_1.default)(client, packet);
done();
break;
case 'auth':
(0, auth_1.default)(client, packet);
done();
break;
case 'pingresp':
client.pingResp = true;
done();
break;
case 'disconnect':
client.emit('disconnect', packet);
done();
break;
default:
client.log('_handlePacket :: unknown command');
done();
break;
}
};
exports.default = handle;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/handlers/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAqC;AACrC,kDAA+B;AAC/B,wDAAqC;AACrC,gDAA6B;AAC7B,sDAAmC;AAGnC,MAAM,MAAM,GAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IACtD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1B,IACC,OAAO,CAAC,eAAe,KAAK,CAAC;QAC7B,OAAO,CAAC,UAAU;QAClB,OAAO,CAAC,UAAU,CAAC,iBAAiB;QACpC,OAAO,CAAC,UAAU,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,EACnD;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACvE,MAAM,CAAC,GAAG,CAAC;YACV,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,EAAE,YAAY,EAAE,kCAAkC,EAAE;SAChE,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;KACb;IACD,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA;IACrD,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAEpC,QAAQ,MAAM,CAAC,GAAG,EAAE;QACnB,KAAK,SAAS;YACb,IAAA,iBAAa,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YACnC,MAAK;QACN,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU;YACd,IAAA,aAAS,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACzB,IAAI,EAAE,CAAA;YACN,MAAK;QACN,KAAK,QAAQ;YACZ,IAAA,gBAAY,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YAClC,MAAK;QACN,KAAK,SAAS;YACb,IAAA,iBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YAC7B,IAAI,EAAE,CAAA;YACN,MAAK;QACN,KAAK,MAAM;YACV,IAAA,cAAU,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YAC1B,IAAI,EAAE,CAAA;YACN,MAAK;QACN,KAAK,UAAU;YAEd,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAA;YACtB,IAAI,EAAE,CAAA;YACN,MAAK;QACN,KAAK,YAAY;YAChB,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;YACjC,IAAI,EAAE,CAAA;YACN,MAAK;QACN;YAEC,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;YAC9C,IAAI,EAAE,CAAA;YACN,MAAK;KACN;AACF,CAAC,CAAA;AAED,kBAAe,MAAM,CAAA"}

View File

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

106
VApp/node_modules/mqtt/build/lib/handlers/publish.js generated vendored Normal file
View File

@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const validReasonCodes = [0, 16, 128, 131, 135, 144, 145, 151, 153];
const handlePublish = (client, packet, done) => {
client.log('handlePublish: packet %o', packet);
done = typeof done !== 'undefined' ? done : client.noop;
let topic = packet.topic.toString();
const message = packet.payload;
const { qos } = packet;
const { messageId } = packet;
const { options } = client;
if (client.options.protocolVersion === 5) {
let alias;
if (packet.properties) {
alias = packet.properties.topicAlias;
}
if (typeof alias !== 'undefined') {
if (topic.length === 0) {
if (alias > 0 && alias <= 0xffff) {
const gotTopic = client['topicAliasRecv'].getTopicByAlias(alias);
if (gotTopic) {
topic = gotTopic;
client.log('handlePublish :: topic complemented by alias. topic: %s - alias: %d', topic, alias);
}
else {
client.log('handlePublish :: unregistered topic alias. alias: %d', alias);
client.emit('error', new Error('Received unregistered Topic Alias'));
return;
}
}
else {
client.log('handlePublish :: topic alias out of range. alias: %d', alias);
client.emit('error', new Error('Received Topic Alias is out of range'));
return;
}
}
else if (client['topicAliasRecv'].put(topic, alias)) {
client.log('handlePublish :: registered topic: %s - alias: %d', topic, alias);
}
else {
client.log('handlePublish :: topic alias out of range. alias: %d', alias);
client.emit('error', new Error('Received Topic Alias is out of range'));
return;
}
}
}
client.log('handlePublish: qos %d', qos);
switch (qos) {
case 2: {
options.customHandleAcks(topic, message, packet, (error, code) => {
if (typeof error === 'number') {
code = error;
error = null;
}
if (error) {
return client.emit('error', error);
}
if (validReasonCodes.indexOf(code) === -1) {
return client.emit('error', new Error('Wrong reason code for pubrec'));
}
if (code) {
client['_sendPacket']({ cmd: 'pubrec', messageId, reasonCode: code }, done);
}
else {
client.incomingStore.put(packet, () => {
client['_sendPacket']({ cmd: 'pubrec', messageId }, done);
});
}
});
break;
}
case 1: {
options.customHandleAcks(topic, message, packet, (error, code) => {
if (typeof error === 'number') {
code = error;
error = null;
}
if (error) {
return client.emit('error', error);
}
if (validReasonCodes.indexOf(code) === -1) {
return client.emit('error', new Error('Wrong reason code for puback'));
}
if (!code) {
client.emit('message', topic, message, packet);
}
client.handleMessage(packet, (err) => {
if (err) {
return done && done(err);
}
client['_sendPacket']({ cmd: 'puback', messageId, reasonCode: code }, done);
});
});
break;
}
case 0:
client.emit('message', topic, message, packet);
client.handleMessage(packet, done);
break;
default:
client.log('handlePublish: unknown QoS. Doing nothing.');
break;
}
};
exports.default = handlePublish;
//# sourceMappingURL=publish.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/lib/handlers/publish.ts"],"names":[],"mappings":";;AAGA,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AA0BnE,MAAM,aAAa,GAAkB,CAAC,MAAM,EAAE,MAAsB,EAAE,IAAI,EAAE,EAAE;IAC7E,MAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IAC9C,IAAI,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;IACvD,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;IACtB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,KAAK,CAAC,EAAE;QACzC,IAAI,KAAa,CAAA;QACjB,IAAI,MAAM,CAAC,UAAU,EAAE;YACtB,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAA;SACpC;QACD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBACvB,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,MAAM,EAAE;oBACjC,MAAM,QAAQ,G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MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAiB,EAAE,MAAM,CAAC,CAAA;iBACxD;gBACD,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;oBACpC,IAAI,GAAG,EAAE;wBACR,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;qBACxB;oBACD,MAAM,CAAC,aAAa,CAAC,CACpB,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAC9C,IAAI,CACJ,CAAA;gBACF,CAAC,CAAC,CAAA;YACH,CAAC,CACD,CAAA;YACD,MAAK;SACL;QACD,KAAK,CAAC;YAEL,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAiB,EAAE,MAAM,CAAC,CAAA;YACxD,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAClC,MAAK;QACN;YAEC,MAAM,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YAExD,MAAK;KACN;AACF,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA"}

View File

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

25
VApp/node_modules/mqtt/build/lib/handlers/pubrel.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const handlePubrel = (client, packet, done) => {
client.log('handling pubrel packet');
const callback = typeof done !== 'undefined' ? done : client.noop;
const { messageId } = packet;
const comp = { cmd: 'pubcomp', messageId };
client.incomingStore.get(packet, (err, pub) => {
if (!err) {
client.emit('message', pub.topic, pub.payload, pub);
client.handleMessage(pub, (err2) => {
if (err2) {
return callback(err2);
}
client.incomingStore.del(pub, client.noop);
client['_sendPacket'](comp, callback);
});
}
else {
client['_sendPacket'](comp, callback);
}
});
};
exports.default = handlePubrel;
//# sourceMappingURL=pubrel.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"pubrel.js","sourceRoot":"","sources":["../../../src/lib/handlers/pubrel.ts"],"names":[],"mappings":";;AAGA,MAAM,YAAY,GAAkB,CAAC,MAAM,EAAE,MAAqB,EAAE,IAAI,EAAE,EAAE;IAC3E,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;IACjE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAE5B,MAAM,IAAI,GAAmB,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;IAE1D,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAmB,EAAE,EAAE;QAC7D,IAAI,CAAC,GAAG,EAAE;YACT,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAiB,EAAE,GAAG,CAAC,CAAA;YAC7D,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,IAAI,EAAE;oBACT,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;iBACrB;gBACD,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC1C,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YACtC,CAAC,CAAC,CAAA;SACF;aAAM;YACN,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;SACrC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,YAAY,CAAA"}

3
VApp/node_modules/mqtt/build/lib/is-browser.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
declare const isBrowser: boolean;
export declare const isWebWorker: boolean;
export default isBrowser;

14
VApp/node_modules/mqtt/build/lib/is-browser.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWebWorker = void 0;
const isStandardBrowserEnv = () => typeof window !== 'undefined' && typeof window.document !== 'undefined';
const isWebWorkerEnv = () => {
var _a, _b;
return Boolean(typeof self === 'object' &&
((_b = (_a = self === null || self === void 0 ? void 0 : self.constructor) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes('WorkerGlobalScope')));
};
const isReactNativeEnv = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
const isBrowser = isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv();
exports.isWebWorker = isWebWorkerEnv();
exports.default = isBrowser;
//# sourceMappingURL=is-browser.js.map

1
VApp/node_modules/mqtt/build/lib/is-browser.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"is-browser.js","sourceRoot":"","sources":["../../src/lib/is-browser.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG,GAAG,EAAE,CACjC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAA;AAExE,MAAM,cAAc,GAAG,GAAG,EAAE;;IAC3B,OAAA,OAAO,CAEN,OAAO,IAAI,KAAK,QAAQ;SAEvB,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,0CAAE,IAAI,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,CACvD,CAAA;CAAA,CAAA;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC7B,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,CAAA;AAExE,MAAM,SAAS,GACd,oBAAoB,EAAE,IAAI,cAAc,EAAE,IAAI,gBAAgB,EAAE,CAAA;AAEpD,QAAA,WAAW,GAAG,cAAc,EAAE,CAAA;AAE3C,kBAAe,SAAS,CAAA"}

21
VApp/node_modules/mqtt/build/lib/shared.d.ts generated vendored Normal file
View File

@ -0,0 +1,21 @@
/// <reference types="node" />
import type { Packet } from 'mqtt-packet';
import type { Duplex } from 'stream';
import type MqttClient from './client';
import type { IClientOptions } from './client';
export type DoneCallback = (error?: Error) => void;
export type GenericCallback<T> = (error?: Error, result?: T) => void;
export type VoidCallback = () => void;
export type IStream = Duplex & {
socket?: any;
};
export type StreamBuilder = (client: MqttClient, opts?: IClientOptions) => IStream;
export type Callback = () => void;
export type PacketHandler = (client: MqttClient, packet: Packet, done?: DoneCallback) => void;
export declare class ErrorWithReasonCode extends Error {
code: number;
constructor(message: string, code: number);
}
export type Constructor<T = {}> = new (...args: any[]) => T;
export declare function applyMixin(target: Constructor, mixin: Constructor, includeConstructor?: boolean): void;
export declare const nextTick: (callback: Function, ...args: any[]) => void;

40
VApp/node_modules/mqtt/build/lib/shared.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nextTick = exports.applyMixin = exports.ErrorWithReasonCode = void 0;
class ErrorWithReasonCode extends Error {
constructor(message, code) {
super(message);
this.code = code;
Object.setPrototypeOf(this, ErrorWithReasonCode.prototype);
Object.getPrototypeOf(this).name = 'ErrorWithReasonCode';
}
}
exports.ErrorWithReasonCode = ErrorWithReasonCode;
function applyMixin(target, mixin, includeConstructor = false) {
var _a;
const inheritanceChain = [mixin];
while (true) {
const current = inheritanceChain[0];
const base = Object.getPrototypeOf(current);
if (base === null || base === void 0 ? void 0 : base.prototype) {
inheritanceChain.unshift(base);
}
else {
break;
}
}
for (const ctor of inheritanceChain) {
for (const prop of Object.getOwnPropertyNames(ctor.prototype)) {
if (includeConstructor || prop !== 'constructor') {
Object.defineProperty(target.prototype, prop, (_a = Object.getOwnPropertyDescriptor(ctor.prototype, prop)) !== null && _a !== void 0 ? _a : Object.create(null));
}
}
}
}
exports.applyMixin = applyMixin;
exports.nextTick = process
? process.nextTick
: (callback) => {
setTimeout(callback, 0);
};
//# sourceMappingURL=shared.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/lib/shared.ts"],"names":[],"mappings":";;;AA6BA,MAAa,mBAAoB,SAAQ,KAAK;IAG7C,YAAmB,OAAe,EAAE,IAAY;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAGhB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAC1D,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACzD,CAAC;CACD;AAXD,kDAWC;AAKD,SAAgB,UAAU,CACzB,MAAmB,EACnB,KAAkB,EAClB,kBAAkB,GAAG,KAAK;;IAG1B,MAAM,gBAAgB,GAAkB,CAAC,KAAK,CAAC,CAAA;IAE/C,OAAO,IAAI,EAAE;QACZ,MAAM,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA;QACnC,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAC3C,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,EAAE;YACpB,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAC9B;aAAM;YACN,MAAK;SACL;KACD;IACD,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE;QACpC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAE9D,IAAI,kBAAkB,IAAI,IAAI,KAAK,aAAa,EAAE;gBACjD,MAAM,CAAC,cAAc,CACpB,MAAM,CAAC,SAAS,EAChB,IAAI,EACJ,MAAA,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,mCACpD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACpB,CAAA;aACD;SACD;KACD;AACF,CAAC;AA9BD,gCA8BC;AACY,QAAA,QAAQ,GAAG,OAAO;IAC9B,CAAC,CAAC,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,CAAC,QAAoB,EAAE,EAAE;QACzB,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACvB,CAAC,CAAA"}

24
VApp/node_modules/mqtt/build/lib/store.d.ts generated vendored Normal file
View File

@ -0,0 +1,24 @@
import { Readable } from 'readable-stream';
import { Packet } from 'mqtt-packet';
import { DoneCallback } from './shared';
export interface IStoreOptions {
clean?: boolean;
}
export type PacketCallback = (error?: Error, packet?: Packet) => void;
export interface IStore {
put(packet: Packet, cb: DoneCallback): IStore;
createStream(): Readable;
del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
close(cb: DoneCallback): void;
}
export default class Store implements IStore {
private options;
private _inflights;
constructor(options?: IStoreOptions);
put(packet: Packet, cb: DoneCallback): this;
createStream(): Readable;
del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
close(cb: DoneCallback): void;
}

80
VApp/node_modules/mqtt/build/lib/store.js generated vendored Normal file
View File

@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const readable_stream_1 = require("readable-stream");
const streamsOpts = { objectMode: true };
const defaultStoreOptions = {
clean: true,
};
class Store {
constructor(options) {
this.options = options || {};
this.options = Object.assign(Object.assign({}, defaultStoreOptions), options);
this._inflights = new Map();
}
put(packet, cb) {
this._inflights.set(packet.messageId, packet);
if (cb) {
cb();
}
return this;
}
createStream() {
const stream = new readable_stream_1.Readable(streamsOpts);
const values = [];
let destroyed = false;
let i = 0;
this._inflights.forEach((value, key) => {
values.push(value);
});
stream._read = () => {
if (!destroyed && i < values.length) {
stream.push(values[i++]);
}
else {
stream.push(null);
}
};
stream.destroy = (err) => {
if (destroyed) {
return;
}
destroyed = true;
setTimeout(() => {
stream.emit('close');
}, 0);
return stream;
};
return stream;
}
del(packet, cb) {
const toDelete = this._inflights.get(packet.messageId);
if (toDelete) {
this._inflights.delete(packet.messageId);
cb(null, toDelete);
}
else if (cb) {
cb(new Error('missing packet'));
}
return this;
}
get(packet, cb) {
const storedPacket = this._inflights.get(packet.messageId);
if (storedPacket) {
cb(null, storedPacket);
}
else if (cb) {
cb(new Error('missing packet'));
}
return this;
}
close(cb) {
if (this.options.clean) {
this._inflights = null;
}
if (cb) {
cb();
}
}
}
exports.default = Store;
//# sourceMappingURL=store.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/lib/store.ts"],"names":[],"mappings":";;AAGA,qDAA0C;AAI1C,MAAM,WAAW,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;AACxC,MAAM,mBAAmB,GAAG;IAC3B,KAAK,EAAE,IAAI;CACX,CAAA;AA+CD,MAAqB,KAAK;IAKzB,YAAY,OAAuB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;QAG5B,IAAI,CAAC,OAAO,mCAAQ,mBAAmB,GAAK,OAAO,CAAE,CAAA;QAErD,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;IAC5B,CAAC;IAOD,GAAG,CAAC,MAAc,EAAE,EAAgB;QACnC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAE7C,IAAI,EAAE,EAAE;YACP,EAAE,EAAE,CAAA;SACJ;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAMD,YAAY;QAC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AC,gBAAgB,CAAC,CAAC,CAAA;SAC/B;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAKD,GAAG,CAAC,MAAiC,EAAE,EAAkB;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC1D,IAAI,YAAY,EAAE;YACjB,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;SACtB;aAAM,IAAI,EAAE,EAAE;YACd,EAAE,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;SAC/B;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAKD,KAAK,CAAC,EAAgB;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;SACtB;QACD,IAAI,EAAE,EAAE;YACP,EAAE,EAAE,CAAA;SACJ;IACF,CAAC;CACD;AA5GD,wBA4GC"}

View File

@ -0,0 +1,9 @@
export default class TopicAliasRecv {
private aliasToTopic;
max: number;
length: number;
constructor(max: number);
put(topic: string, alias: number): boolean;
getTopicByAlias(alias: number): string;
clear(): void;
}

24
VApp/node_modules/mqtt/build/lib/topic-alias-recv.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class TopicAliasRecv {
constructor(max) {
this.aliasToTopic = {};
this.max = max;
}
put(topic, alias) {
if (alias === 0 || alias > this.max) {
return false;
}
this.aliasToTopic[alias] = topic;
this.length = Object.keys(this.aliasToTopic).length;
return true;
}
getTopicByAlias(alias) {
return this.aliasToTopic[alias];
}
clear() {
this.aliasToTopic = {};
}
}
exports.default = TopicAliasRecv;
//# sourceMappingURL=topic-alias-recv.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"topic-alias-recv.js","sourceRoot":"","sources":["../../src/lib/topic-alias-recv.ts"],"names":[],"mappings":";;AAKA,MAAqB,cAAc;IAOlC,YAAY,GAAW;QACtB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IACf,CAAC;IAQD,GAAG,CAAC,KAAa,EAAE,KAAa;QAC/B,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;YACpC,OAAO,KAAK,CAAA;SACZ;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAA;QACnD,OAAO,IAAI,CAAA;IACZ,CAAC;IAOD,eAAe,CAAC,KAAa;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAKD,KAAK;QACJ,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;IACvB,CAAC;CACD;AA1CD,iCA0CC"}

13
VApp/node_modules/mqtt/build/lib/topic-alias-send.d.ts generated vendored Normal file
View File

@ -0,0 +1,13 @@
export default class TopicAliasSend {
private aliasToTopic;
private topicToAlias;
private max;
private numberAllocator;
length: number;
constructor(max: number);
put(topic: string, alias: number): boolean;
getTopicByAlias(alias: number): string;
getAliasByTopic(topic: string): number | undefined;
clear(): void;
getLruAlias(): number;
}

53
VApp/node_modules/mqtt/build/lib/topic-alias-send.js generated vendored Normal file
View File

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lru_cache_1 = require("lru-cache");
const number_allocator_1 = require("number-allocator");
class TopicAliasSend {
constructor(max) {
if (max > 0) {
this.aliasToTopic = new lru_cache_1.LRUCache({ max });
this.topicToAlias = {};
this.numberAllocator = new number_allocator_1.NumberAllocator(1, max);
this.max = max;
this.length = 0;
}
}
put(topic, alias) {
if (alias === 0 || alias > this.max) {
return false;
}
const entry = this.aliasToTopic.get(alias);
if (entry) {
delete this.topicToAlias[entry];
}
this.aliasToTopic.set(alias, topic);
this.topicToAlias[topic] = alias;
this.numberAllocator.use(alias);
this.length = this.aliasToTopic.size;
return true;
}
getTopicByAlias(alias) {
return this.aliasToTopic.get(alias);
}
getAliasByTopic(topic) {
const alias = this.topicToAlias[topic];
if (typeof alias !== 'undefined') {
this.aliasToTopic.get(alias);
}
return alias;
}
clear() {
this.aliasToTopic.clear();
this.topicToAlias = {};
this.numberAllocator.clear();
this.length = 0;
}
getLruAlias() {
const alias = this.numberAllocator.firstVacant();
if (alias)
return alias;
return [...this.aliasToTopic.keys()][this.aliasToTopic.size - 1];
}
}
exports.default = TopicAliasSend;
//# sourceMappingURL=topic-alias-send.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"topic-alias-send.js","sourceRoot":"","sources":["../../src/lib/topic-alias-send.ts"],"names":[],"mappings":";;AAGA,yCAAoC;AACpC,uDAAkD;AAOlD,MAAqB,cAAc;IAWlC,YAAY,GAAW;QACtB,IAAI,GAAG,GAAG,CAAC,EAAE;YACZ,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAQ,CAAiB,EAAE,GAAG,EAAE,CAAC,CAAA;YACzD,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;YACtB,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAe,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YAClD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;YACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;SACf;IACF,CAAC;IAQD,GAAG,CAAC,KAAa,EAAE,KAAa;QAC/B,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;YACpC,OAAO,KAAK,CAAA;SACZ;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC1C,IAAI,KAAK,EAAE;YACV,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;SAC/B;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;QAChC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAA;QACpC,OAAO,IAAI,CAAA;IACZ,CAAC;IAOD,eAAe,CAAC,KAAa;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAOD,eAAe,CAAC,KAAa;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;SAC5B;QACD,OAAO,KAAK,CAAA;IACb,CAAC;IAKD,KAAK;QACJ,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAChB,CAAC;IAMD,WAAW;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,CAAA;QAChD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAA;QAEvB,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;IACjE,CAAC;CACD;AApFD,iCAoFC"}

View File

@ -0,0 +1,11 @@
import { IMessageIdProvider } from './default-message-id-provider';
export default class UniqueMessageIdProvider implements IMessageIdProvider {
private numberAllocator;
private lastId;
constructor();
allocate(): number;
getLastAllocated(): number;
register(messageId: number): boolean;
deallocate(messageId: number): void;
clear(): void;
}

View File

@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const number_allocator_1 = require("number-allocator");
class UniqueMessageIdProvider {
constructor() {
this.numberAllocator = new number_allocator_1.NumberAllocator(1, 65535);
}
allocate() {
this.lastId = this.numberAllocator.alloc();
return this.lastId;
}
getLastAllocated() {
return this.lastId;
}
register(messageId) {
return this.numberAllocator.use(messageId);
}
deallocate(messageId) {
this.numberAllocator.free(messageId);
}
clear() {
this.numberAllocator.clear();
}
}
exports.default = UniqueMessageIdProvider;
//# sourceMappingURL=unique-message-id-provider.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unique-message-id-provider.js","sourceRoot":"","sources":["../../src/lib/unique-message-id-provider.ts"],"names":[],"mappings":";;AAAA,uDAAkD;AAOlD,MAAqB,uBAAuB;IAK3C;QACC,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IASD,QAAQ;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;IAOD,gBAAgB;QACf,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;IAQD,QAAQ,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAY,CAAA;IACtD,CAAC;IAOD,UAAU,CAAC,SAAiB;QAC3B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAMD,KAAK;QACJ,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;CACD;AAxDD,0CAwDC"}

2
VApp/node_modules/mqtt/build/lib/validations.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export declare function validateTopic(topic: string): boolean;
export declare function validateTopics(topics: string[]): string;

32
VApp/node_modules/mqtt/build/lib/validations.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateTopics = exports.validateTopic = void 0;
function validateTopic(topic) {
const parts = topic.split('/');
for (let i = 0; i < parts.length; i++) {
if (parts[i] === '+') {
continue;
}
if (parts[i] === '#') {
return i === parts.length - 1;
}
if (parts[i].indexOf('+') !== -1 || parts[i].indexOf('#') !== -1) {
return false;
}
}
return true;
}
exports.validateTopic = validateTopic;
function validateTopics(topics) {
if (topics.length === 0) {
return 'empty_topic_list';
}
for (let i = 0; i < topics.length; i++) {
if (!validateTopic(topics[i])) {
return topics[i];
}
}
return null;
}
exports.validateTopics = validateTopics;
//# sourceMappingURL=validations.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../src/lib/validations.ts"],"names":[],"mappings":";;;AASA,SAAgB,aAAa,CAAC,KAAa;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACrB,SAAQ;SACR;QAED,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAErB,OAAO,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;SAC7B;QAED,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YACjE,OAAO,KAAK,CAAA;SACZ;KACD;IAED,OAAO,IAAI,CAAA;AACZ,CAAC;AAnBD,sCAmBC;AAOD,SAAgB,cAAc,CAAC,MAAgB;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,kBAAkB,CAAA;KACzB;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YAC9B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;SAChB;KACD;IACD,OAAO,IAAI,CAAA;AACZ,CAAC;AAVD,wCAUC"}

10
VApp/node_modules/mqtt/build/mqtt.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import MqttClient from './lib/client';
import DefaultMessageIdProvider from './lib/default-message-id-provider';
import UniqueMessageIdProvider from './lib/unique-message-id-provider';
import Store, { IStore } from './lib/store';
import connect, { connectAsync } from './lib/connect';
export declare const Client: typeof MqttClient;
export { connect, connectAsync, MqttClient, Store, DefaultMessageIdProvider, UniqueMessageIdProvider, IStore, };
export * from './lib/client';
export * from './lib/shared';
export { ReasonCodes } from './lib/handlers/ack';

49
VApp/node_modules/mqtt/build/mqtt.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReasonCodes = exports.UniqueMessageIdProvider = exports.DefaultMessageIdProvider = exports.Store = exports.MqttClient = exports.connectAsync = exports.connect = exports.Client = void 0;
const client_1 = __importDefault(require("./lib/client"));
exports.MqttClient = client_1.default;
const default_message_id_provider_1 = __importDefault(require("./lib/default-message-id-provider"));
exports.DefaultMessageIdProvider = default_message_id_provider_1.default;
const unique_message_id_provider_1 = __importDefault(require("./lib/unique-message-id-provider"));
exports.UniqueMessageIdProvider = unique_message_id_provider_1.default;
const store_1 = __importDefault(require("./lib/store"));
exports.Store = store_1.default;
const connect_1 = __importStar(require("./lib/connect"));
exports.connect = connect_1.default;
Object.defineProperty(exports, "connectAsync", { enumerable: true, get: function () { return connect_1.connectAsync; } });
exports.Client = client_1.default;
__exportStar(require("./lib/client"), exports);
__exportStar(require("./lib/shared"), exports);
var ack_1 = require("./lib/handlers/ack");
Object.defineProperty(exports, "ReasonCodes", { enumerable: true, get: function () { return ack_1.ReasonCodes; } });
//# sourceMappingURL=mqtt.js.map

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

@ -0,0 +1 @@
{"version":3,"file":"mqtt.js","sourceRoot":"","sources":["../src/mqtt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,0DAAqC;AAUpC,qBAVM,gBAAU,CAUN;AATX,oGAAwE;AAWvE,mCAXM,qCAAwB,CAWN;AAVzB,kGAAsE;AAWrE,kCAXM,oCAAuB,CAWN;AAVxB,wDAA2C;AAQ1C,gBARM,eAAK,CAQN;AAPN,yDAAqD;AAIpD,kBAJM,iBAAO,CAIN;AACP,6FALiB,sBAAY,OAKjB;AAHA,QAAA,MAAM,GAAG,gBAAU,CAAA;AAUhC,+CAA4B;AAC5B,+CAA4B;AAC5B,0CAAgD;AAAvC,kGAAA,WAAW,OAAA"}

File diff suppressed because one or more lines are too long

10
VApp/node_modules/mqtt/dist/mqtt.esm.js generated vendored Normal file

File diff suppressed because one or more lines are too long

21530
VApp/node_modules/mqtt/dist/mqtt.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

10
VApp/node_modules/mqtt/dist/mqtt.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

8
VApp/node_modules/mqtt/help/help.txt generated vendored Normal file
View File

@ -0,0 +1,8 @@
MQTT.js command line interface, available commands are:
* publish publish a message to the broker
* subscribe subscribe for updates from the broker
* version the current MQTT.js version
* help help about commands
Launch 'mqtt help [command]' to know more about the commands.

26
VApp/node_modules/mqtt/help/publish.txt generated vendored Normal file
View File

@ -0,0 +1,26 @@
Usage: mqtt publish [opts] topic [message]
Available options:
-h/--hostname HOST the broker host
-p/--port PORT the broker port
-i/--client-id ID the client id
-q/--qos 0/1/2 the QoS of the message
-t/--topic TOPIC the message topic
-m/--message MSG the message body
-r/--retain send a retained message
-s/--stdin read the message body from stdin
-M/--multiline read lines from stdin as multiple messages
-u/--username USER the username
-P/--password PASS the password
-C/--protocol PROTO the protocol to use, 'mqtt',
'mqtts', 'ws' or 'wss'
--key PATH path to the key file
--cert PATH path to the cert file
--ca PATH path to the ca certificate
--insecure do not verify the server certificate
--will-topic TOPIC the will topic
--will-payload BODY the will message
--will-qos 0/1/2 the will qos
--will-retain send a will retained message
-H/--help show this

26
VApp/node_modules/mqtt/help/subscribe.txt generated vendored Normal file
View File

@ -0,0 +1,26 @@
Usage: mqtt subscribe [opts] [topic]
Available options:
-h/--hostname HOST the broker host
-p/--port PORT the broker port
-i/--clientId ID the client id
-q/--qos 0/1/2 the QoS of the message
--no-clean do not discard any pending message for
the given id
-t/--topic TOPIC the message topic
-k/--keepalive SEC send a ping every SEC seconds
-u/--username USER the username
-P/--password PASS the password
-l/--protocol PROTO the protocol to use, 'mqtt',
'mqtts', 'ws' or 'wss'
--key PATH path to the key file
--cert PATH path to the cert file
--ca PATH path to the ca certificate
--insecure do not verify the server certificate
--will-topic TOPIC the will topic
--will-message BODY the will message
--will-qos 0/1/2 the will qos
--will-retain send a will retained message
-v/--verbose print the topic before the message
-H/--help show this

15
VApp/node_modules/mqtt/node_modules/lru-cache/LICENSE generated vendored Normal file
View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

1204
VApp/node_modules/mqtt/node_modules/lru-cache/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,856 @@
/**
* @module LRUCache
*/
declare const TYPE: unique symbol;
export type PosInt = number & {
[TYPE]: 'Positive Integer';
};
export type Index = number & {
[TYPE]: 'LRUCache Index';
};
export type UintArray = Uint8Array | Uint16Array | Uint32Array;
export type NumberArray = UintArray | number[];
declare class ZeroArray extends Array<number> {
constructor(size: number);
}
export type { ZeroArray };
export type { Stack };
export type StackLike = Stack | Index[];
declare class Stack {
#private;
heap: NumberArray;
length: number;
static create(max: number): StackLike;
constructor(max: number, HeapCls: {
new (n: number): NumberArray;
});
push(n: Index): void;
pop(): Index;
}
/**
* Promise representing an in-progress {@link LRUCache#fetch} call
*/
export type BackgroundFetch<V> = Promise<V | undefined> & {
__returned: BackgroundFetch<V> | undefined;
__abortController: AbortController;
__staleWhileFetching: V | undefined;
};
export type DisposeTask<K, V> = [
value: V,
key: K,
reason: LRUCache.DisposeReason
];
export declare namespace LRUCache {
/**
* An integer greater than 0, reflecting the calculated size of items
*/
type Size = number;
/**
* Integer greater than 0, representing some number of milliseconds, or the
* time at which a TTL started counting from.
*/
type Milliseconds = number;
/**
* An integer greater than 0, reflecting a number of items
*/
type Count = number;
/**
* The reason why an item was removed from the cache, passed
* to the {@link Disposer} methods.
*/
type DisposeReason = 'evict' | 'set' | 'delete';
/**
* A method called upon item removal, passed as the
* {@link OptionsBase.dispose} and/or
* {@link OptionsBase.disposeAfter} options.
*/
type Disposer<K, V> = (value: V, key: K, reason: DisposeReason) => void;
/**
* A function that returns the effective calculated size
* of an entry in the cache.
*/
type SizeCalculator<K, V> = (value: V, key: K) => Size;
/**
* Options provided to the
* {@link OptionsBase.fetchMethod} function.
*/
interface FetcherOptions<K, V, FC = unknown> {
signal: AbortSignal;
options: FetcherFetchOptions<K, V, FC>;
/**
* Object provided in the {@link FetchOptions.context} option to
* {@link LRUCache#fetch}
*/
context: FC;
}
/**
* Status object that may be passed to {@link LRUCache#fetch},
* {@link LRUCache#get}, {@link LRUCache#set}, and {@link LRUCache#has}.
*/
interface Status<V> {
/**
* The status of a set() operation.
*
* - add: the item was not found in the cache, and was added
* - update: the item was in the cache, with the same value provided
* - replace: the item was in the cache, and replaced
* - miss: the item was not added to the cache for some reason
*/
set?: 'add' | 'update' | 'replace' | 'miss';
/**
* the ttl stored for the item, or undefined if ttls are not used.
*/
ttl?: Milliseconds;
/**
* the start time for the item, or undefined if ttls are not used.
*/
start?: Milliseconds;
/**
* The timestamp used for TTL calculation
*/
now?: Milliseconds;
/**
* the remaining ttl for the item, or undefined if ttls are not used.
*/
remainingTTL?: Milliseconds;
/**
* The calculated size for the item, if sizes are used.
*/
entrySize?: Size;
/**
* The total calculated size of the cache, if sizes are used.
*/
totalCalculatedSize?: Size;
/**
* A flag indicating that the item was not stored, due to exceeding the
* {@link OptionsBase.maxEntrySize}
*/
maxEntrySizeExceeded?: true;
/**
* The old value, specified in the case of `set:'update'` or
* `set:'replace'`
*/
oldValue?: V;
/**
* The results of a {@link LRUCache#has} operation
*
* - hit: the item was found in the cache
* - stale: the item was found in the cache, but is stale
* - miss: the item was not found in the cache
*/
has?: 'hit' | 'stale' | 'miss';
/**
* The status of a {@link LRUCache#fetch} operation.
* Note that this can change as the underlying fetch() moves through
* various states.
*
* - inflight: there is another fetch() for this key which is in process
* - get: there is no fetchMethod, so {@link LRUCache#get} was called.
* - miss: the item is not in cache, and will be fetched.
* - hit: the item is in the cache, and was resolved immediately.
* - stale: the item is in the cache, but stale.
* - refresh: the item is in the cache, and not stale, but
* {@link FetchOptions.forceRefresh} was specified.
*/
fetch?: 'get' | 'inflight' | 'miss' | 'hit' | 'stale' | 'refresh';
/**
* The {@link OptionsBase.fetchMethod} was called
*/
fetchDispatched?: true;
/**
* The cached value was updated after a successful call to
* {@link OptionsBase.fetchMethod}
*/
fetchUpdated?: true;
/**
* The reason for a fetch() rejection. Either the error raised by the
* {@link OptionsBase.fetchMethod}, or the reason for an
* AbortSignal.
*/
fetchError?: Error;
/**
* The fetch received an abort signal
*/
fetchAborted?: true;
/**
* The abort signal received was ignored, and the fetch was allowed to
* continue.
*/
fetchAbortIgnored?: true;
/**
* The fetchMethod promise resolved successfully
*/
fetchResolved?: true;
/**
* The fetchMethod promise was rejected
*/
fetchRejected?: true;
/**
* The status of a {@link LRUCache#get} operation.
*
* - fetching: The item is currently being fetched. If a previous value
* is present and allowed, that will be returned.
* - stale: The item is in the cache, and is stale.
* - hit: the item is in the cache
* - miss: the item is not in the cache
*/
get?: 'stale' | 'hit' | 'miss';
/**
* A fetch or get operation returned a stale value.
*/
returnedStale?: true;
}
/**
* options which override the options set in the LRUCache constructor
* when calling {@link LRUCache#fetch}.
*
* This is the union of {@link GetOptions} and {@link SetOptions}, plus
* {@link OptionsBase.noDeleteOnFetchRejection},
* {@link OptionsBase.allowStaleOnFetchRejection},
* {@link FetchOptions.forceRefresh}, and
* {@link FetcherOptions.context}
*
* Any of these may be modified in the {@link OptionsBase.fetchMethod}
* function, but the {@link GetOptions} fields will of course have no
* effect, as the {@link LRUCache#get} call already happened by the time
* the fetchMethod is called.
*/
interface FetcherFetchOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
status?: Status<V>;
size?: Size;
}
/**
* Options that may be passed to the {@link LRUCache#fetch} method.
*/
interface FetchOptions<K, V, FC> extends FetcherFetchOptions<K, V, FC> {
/**
* Set to true to force a re-load of the existing data, even if it
* is not yet stale.
*/
forceRefresh?: boolean;
/**
* Context provided to the {@link OptionsBase.fetchMethod} as
* the {@link FetcherOptions.context} param.
*
* If the FC type is specified as unknown (the default),
* undefined or void, then this is optional. Otherwise, it will
* be required.
*/
context?: FC;
signal?: AbortSignal;
status?: Status<V>;
}
/**
* Options provided to {@link LRUCache#fetch} when the FC type is something
* other than `unknown`, `undefined`, or `void`
*/
interface FetchOptionsWithContext<K, V, FC> extends FetchOptions<K, V, FC> {
context: FC;
}
/**
* Options provided to {@link LRUCache#fetch} when the FC type is
* `undefined` or `void`
*/
interface FetchOptionsNoContext<K, V> extends FetchOptions<K, V, undefined> {
context?: undefined;
}
/**
* Options that may be passed to the {@link LRUCache#has} method.
*/
interface HasOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'updateAgeOnHas'> {
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#get} method.
*/
interface GetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet'> {
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#peek} method.
*/
interface PeekOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale'> {
}
/**
* Options that may be passed to the {@link LRUCache#set} method.
*/
interface SetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
/**
* If size tracking is enabled, then setting an explicit size
* in the {@link LRUCache#set} call will prevent calling the
* {@link OptionsBase.sizeCalculation} function.
*/
size?: Size;
/**
* If TTL tracking is enabled, then setting an explicit start
* time in the {@link LRUCache#set} call will override the
* default time from `performance.now()` or `Date.now()`.
*
* Note that it must be a valid value for whichever time-tracking
* method is in use.
*/
start?: Milliseconds;
status?: Status<V>;
}
/**
* The type signature for the {@link OptionsBase.fetchMethod} option.
*/
type Fetcher<K, V, FC = unknown> = (key: K, staleValue: V | undefined, options: FetcherOptions<K, V, FC>) => Promise<V | undefined | void> | V | undefined | void;
/**
* Options which may be passed to the {@link LRUCache} constructor.
*
* Most of these may be overridden in the various options that use
* them.
*
* Despite all being technically optional, the constructor requires that
* a cache is at minimum limited by one or more of {@link OptionsBase.max},
* {@link OptionsBase.ttl}, or {@link OptionsBase.maxSize}.
*
* If {@link OptionsBase.ttl} is used alone, then it is strongly advised
* (and in fact required by the type definitions here) that the cache
* also set {@link OptionsBase.ttlAutopurge}, to prevent potentially
* unbounded storage.
*/
interface OptionsBase<K, V, FC> {
/**
* The maximum number of items to store in the cache before evicting
* old entries. This is read-only on the {@link LRUCache} instance,
* and may not be overridden.
*
* If set, then storage space will be pre-allocated at construction
* time, and the cache will perform significantly faster.
*
* Note that significantly fewer items may be stored, if
* {@link OptionsBase.maxSize} and/or {@link OptionsBase.ttl} are also
* set.
*/
max?: Count;
/**
* Max time in milliseconds for items to live in cache before they are
* considered stale. Note that stale items are NOT preemptively removed
* by default, and MAY live in the cache long after they have expired.
*
* Also, as this cache is optimized for LRU/MRU operations, some of
* the staleness/TTL checks will reduce performance, as they will incur
* overhead by deleting items.
*
* Must be an integer number of ms. If set to 0, this indicates "no TTL"
*
* @default 0
*/
ttl?: Milliseconds;
/**
* Minimum amount of time in ms in which to check for staleness.
* Defaults to 1, which means that the current time is checked
* at most once per millisecond.
*
* Set to 0 to check the current time every time staleness is tested.
* (This reduces performance, and is theoretically unnecessary.)
*
* Setting this to a higher value will improve performance somewhat
* while using ttl tracking, albeit at the expense of keeping stale
* items around a bit longer than their TTLs would indicate.
*
* @default 1
*/
ttlResolution?: Milliseconds;
/**
* Preemptively remove stale items from the cache.
* Note that this may significantly degrade performance,
* especially if the cache is storing a large number of items.
* It is almost always best to just leave the stale items in
* the cache, and let them fall out as new items are added.
*
* Note that this means that {@link OptionsBase.allowStale} is a bit
* pointless, as stale items will be deleted almost as soon as they
* expire.
*
* @default false
*/
ttlAutopurge?: boolean;
/**
* Update the age of items on {@link LRUCache#get}, renewing their TTL
*
* Has no effect if {@link OptionsBase.ttl} is not set.
*
* @default false
*/
updateAgeOnGet?: boolean;
/**
* Update the age of items on {@link LRUCache#has}, renewing their TTL
*
* Has no effect if {@link OptionsBase.ttl} is not set.
*
* @default false
*/
updateAgeOnHas?: boolean;
/**
* Allow {@link LRUCache#get} and {@link LRUCache#fetch} calls to return
* stale data, if available.
*/
allowStale?: boolean;
/**
* Function that is called on items when they are dropped from the cache.
* This can be handy if you want to close file descriptors or do other
* cleanup tasks when items are no longer accessible. Called with `key,
* value`. It's called before actually removing the item from the
* internal cache, so it is *NOT* safe to re-add them.
*
* Use {@link OptionsBase.disposeAfter} if you wish to dispose items after
* they have been full removed, when it is safe to add them back to the
* cache.
*/
dispose?: Disposer<K, V>;
/**
* The same as {@link OptionsBase.dispose}, but called *after* the entry
* is completely removed and the cache is once again in a clean state.
* It is safe to add an item right back into the cache at this point.
* However, note that it is *very* easy to inadvertently create infinite
* recursion this way.
*/
disposeAfter?: Disposer<K, V>;
/**
* Set to true to suppress calling the
* {@link OptionsBase.dispose} function if the entry key is
* still accessible within the cache.
* This may be overridden by passing an options object to
* {@link LRUCache#set}.
*/
noDisposeOnSet?: boolean;
/**
* Boolean flag to tell the cache to not update the TTL when
* setting a new value for an existing key (ie, when updating a value
* rather than inserting a new value). Note that the TTL value is
* _always_ set (if provided) when adding a new entry into the cache.
*
* Has no effect if a {@link OptionsBase.ttl} is not set.
*/
noUpdateTTL?: boolean;
/**
* If you wish to track item size, you must provide a maxSize
* note that we still will only keep up to max *actual items*,
* if max is set, so size tracking may cause fewer than max items
* to be stored. At the extreme, a single item of maxSize size
* will cause everything else in the cache to be dropped when it
* is added. Use with caution!
*
* Note also that size tracking can negatively impact performance,
* though for most cases, only minimally.
*/
maxSize?: Size;
/**
* The maximum allowed size for any single item in the cache.
*
* If a larger item is passed to {@link LRUCache#set} or returned by a
* {@link OptionsBase.fetchMethod}, then it will not be stored in the
* cache.
*/
maxEntrySize?: Size;
/**
* A function that returns a number indicating the item's size.
*
* If not provided, and {@link OptionsBase.maxSize} or
* {@link OptionsBase.maxEntrySize} are set, then all
* {@link LRUCache#set} calls **must** provide an explicit
* {@link SetOptions.size} or sizeCalculation param.
*/
sizeCalculation?: SizeCalculator<K, V>;
/**
* Method that provides the implementation for {@link LRUCache#fetch}
*/
fetchMethod?: Fetcher<K, V, FC>;
/**
* Set to true to suppress the deletion of stale data when a
* {@link OptionsBase.fetchMethod} returns a rejected promise.
*/
noDeleteOnFetchRejection?: boolean;
/**
* Do not delete stale items when they are retrieved with
* {@link LRUCache#get}.
*
* Note that the `get` return value will still be `undefined`
* unless {@link OptionsBase.allowStale} is true.
*/
noDeleteOnStaleGet?: boolean;
/**
* Set to true to allow returning stale data when a
* {@link OptionsBase.fetchMethod} throws an error or returns a rejected
* promise.
*
* This differs from using {@link OptionsBase.allowStale} in that stale
* data will ONLY be returned in the case that the
* {@link LRUCache#fetch} fails, not any other times.
*/
allowStaleOnFetchRejection?: boolean;
/**
* Set to true to return a stale value from the cache when the
* `AbortSignal` passed to the {@link OptionsBase.fetchMethod} dispatches an `'abort'`
* event, whether user-triggered, or due to internal cache behavior.
*
* Unless {@link OptionsBase.ignoreFetchAbort} is also set, the underlying
* {@link OptionsBase.fetchMethod} will still be considered canceled, and
* any value it returns will be ignored and not cached.
*
* Caveat: since fetches are aborted when a new value is explicitly
* set in the cache, this can lead to fetch returning a stale value,
* since that was the fallback value _at the moment the `fetch()` was
* initiated_, even though the new updated value is now present in
* the cache.
*
* For example:
*
* ```ts
* const cache = new LRUCache<string, any>({
* ttl: 100,
* fetchMethod: async (url, oldValue, { signal }) => {
* const res = await fetch(url, { signal })
* return await res.json()
* }
* })
* cache.set('https://example.com/', { some: 'data' })
* // 100ms go by...
* const result = cache.fetch('https://example.com/')
* cache.set('https://example.com/', { other: 'thing' })
* console.log(await result) // { some: 'data' }
* console.log(cache.get('https://example.com/')) // { other: 'thing' }
* ```
*/
allowStaleOnFetchAbort?: boolean;
/**
* Set to true to ignore the `abort` event emitted by the `AbortSignal`
* object passed to {@link OptionsBase.fetchMethod}, and still cache the
* resulting resolution value, as long as it is not `undefined`.
*
* When used on its own, this means aborted {@link LRUCache#fetch} calls are not
* immediately resolved or rejected when they are aborted, and instead
* take the full time to await.
*
* When used with {@link OptionsBase.allowStaleOnFetchAbort}, aborted
* {@link LRUCache#fetch} calls will resolve immediately to their stale
* cached value or `undefined`, and will continue to process and eventually
* update the cache when they resolve, as long as the resulting value is
* not `undefined`, thus supporting a "return stale on timeout while
* refreshing" mechanism by passing `AbortSignal.timeout(n)` as the signal.
*
* **Note**: regardless of this setting, an `abort` event _is still
* emitted on the `AbortSignal` object_, so may result in invalid results
* when passed to other underlying APIs that use AbortSignals.
*
* This may be overridden in the {@link OptionsBase.fetchMethod} or the
* call to {@link LRUCache#fetch}.
*/
ignoreFetchAbort?: boolean;
}
interface OptionsMaxLimit<K, V, FC> extends OptionsBase<K, V, FC> {
max: Count;
}
interface OptionsTTLLimit<K, V, FC> extends OptionsBase<K, V, FC> {
ttl: Milliseconds;
ttlAutopurge: boolean;
}
interface OptionsSizeLimit<K, V, FC> extends OptionsBase<K, V, FC> {
maxSize: Size;
}
/**
* The valid safe options for the {@link LRUCache} constructor
*/
type Options<K, V, FC> = OptionsMaxLimit<K, V, FC> | OptionsSizeLimit<K, V, FC> | OptionsTTLLimit<K, V, FC>;
/**
* Entry objects used by {@link LRUCache#load} and {@link LRUCache#dump},
* and returned by {@link LRUCache#info}.
*/
interface Entry<V> {
value: V;
ttl?: Milliseconds;
size?: Size;
start?: Milliseconds;
}
}
/**
* Default export, the thing you're using this module to get.
*
* All properties from the options object (with the exception of
* {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as
* normal public members. (`max` and `maxBase` are read-only getters.)
* Changing any of these will alter the defaults for subsequent method calls,
* but is otherwise safe.
*/
export declare class LRUCache<K extends {}, V extends {}, FC = unknown> implements Map<K, V> {
#private;
/**
* {@link LRUCache.OptionsBase.ttl}
*/
ttl: LRUCache.Milliseconds;
/**
* {@link LRUCache.OptionsBase.ttlResolution}
*/
ttlResolution: LRUCache.Milliseconds;
/**
* {@link LRUCache.OptionsBase.ttlAutopurge}
*/
ttlAutopurge: boolean;
/**
* {@link LRUCache.OptionsBase.updateAgeOnGet}
*/
updateAgeOnGet: boolean;
/**
* {@link LRUCache.OptionsBase.updateAgeOnHas}
*/
updateAgeOnHas: boolean;
/**
* {@link LRUCache.OptionsBase.allowStale}
*/
allowStale: boolean;
/**
* {@link LRUCache.OptionsBase.noDisposeOnSet}
*/
noDisposeOnSet: boolean;
/**
* {@link LRUCache.OptionsBase.noUpdateTTL}
*/
noUpdateTTL: boolean;
/**
* {@link LRUCache.OptionsBase.maxEntrySize}
*/
maxEntrySize: LRUCache.Size;
/**
* {@link LRUCache.OptionsBase.sizeCalculation}
*/
sizeCalculation?: LRUCache.SizeCalculator<K, V>;
/**
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
*/
noDeleteOnFetchRejection: boolean;
/**
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
*/
noDeleteOnStaleGet: boolean;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
*/
allowStaleOnFetchAbort: boolean;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
*/
allowStaleOnFetchRejection: boolean;
/**
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
ignoreFetchAbort: boolean;
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
* object is modified in any way, strange breakage may occur.
*
* These fields are private for a reason!
*
* @internal
*/
static unsafeExposeInternals<K extends {}, V extends {}, FC extends unknown = unknown>(c: LRUCache<K, V, FC>): {
starts: ZeroArray | undefined;
ttls: ZeroArray | undefined;
sizes: ZeroArray | undefined;
keyMap: Map<K, number>;
keyList: (K | undefined)[];
valList: (V | BackgroundFetch<V> | undefined)[];
next: NumberArray;
prev: NumberArray;
readonly head: Index;
readonly tail: Index;
free: StackLike;
isBackgroundFetch: (p: any) => boolean;
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>;
moveToTail: (index: number) => void;
indexes: (options?: {
allowStale: boolean;
}) => Generator<Index, void, unknown>;
rindexes: (options?: {
allowStale: boolean;
}) => Generator<Index, void, unknown>;
isStale: (index: number | undefined) => boolean;
};
/**
* {@link LRUCache.OptionsBase.max} (read-only)
*/
get max(): LRUCache.Count;
/**
* {@link LRUCache.OptionsBase.maxSize} (read-only)
*/
get maxSize(): LRUCache.Count;
/**
* The total computed size of items in the cache (read-only)
*/
get calculatedSize(): LRUCache.Size;
/**
* The number of items stored in the cache (read-only)
*/
get size(): LRUCache.Count;
/**
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
*/
get fetchMethod(): LRUCache.Fetcher<K, V, FC> | undefined;
/**
* {@link LRUCache.OptionsBase.dispose} (read-only)
*/
get dispose(): LRUCache.Disposer<K, V> | undefined;
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
get disposeAfter(): LRUCache.Disposer<K, V> | undefined;
constructor(options: LRUCache.Options<K, V, FC> | LRUCache<K, V, FC>);
/**
* Return the remaining TTL time for a given entry key
*/
getRemainingTTL(key: K): number;
/**
* Return a generator yielding `[key, value]` pairs,
* in order from most recently used to least recently used.
*/
entries(): Generator<[K, V], void, unknown>;
/**
* Inverse order version of {@link LRUCache.entries}
*
* Return a generator yielding `[key, value]` pairs,
* in order from least recently used to most recently used.
*/
rentries(): Generator<(K | V | BackgroundFetch<V> | undefined)[], void, unknown>;
/**
* Return a generator yielding the keys in the cache,
* in order from most recently used to least recently used.
*/
keys(): Generator<K, void, unknown>;
/**
* Inverse order version of {@link LRUCache.keys}
*
* Return a generator yielding the keys in the cache,
* in order from least recently used to most recently used.
*/
rkeys(): Generator<K, void, unknown>;
/**
* Return a generator yielding the values in the cache,
* in order from most recently used to least recently used.
*/
values(): Generator<V, void, unknown>;
/**
* Inverse order version of {@link LRUCache.values}
*
* Return a generator yielding the values in the cache,
* in order from least recently used to most recently used.
*/
rvalues(): Generator<V | BackgroundFetch<V> | undefined, void, unknown>;
/**
* Iterating over the cache itself yields the same results as
* {@link LRUCache.entries}
*/
[Symbol.iterator](): Generator<[K, V], void, unknown>;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
[Symbol.toStringTag]: string;
/**
* Find a value for which the supplied fn method returns a truthy value,
* similar to Array.find(). fn is called as fn(value, key, cache).
*/
find(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => boolean, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
/**
* Call the supplied function on each item in the cache, in order from
* most recently used to least recently used. fn is called as
* fn(value, key, cache). Does not update age or recenty of use.
* Does not iterate over stale values.
*/
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* The same as {@link LRUCache.forEach} but items are iterated over in
* reverse order. (ie, less recently used items are iterated over first.)
*/
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* Delete any stale entries. Returns true if anything was removed,
* false otherwise.
*/
purgeStale(): boolean;
/**
* Get the extended info about a given entry, to get its value, size, and
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
* single key. Always returns stale values, if their info is found in the
* cache, so be sure to check for expired TTLs if relevant.
*/
info(key: K): LRUCache.Entry<V> | undefined;
/**
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
* passed to cache.load()
*/
dump(): [K, LRUCache.Entry<V>][];
/**
* Reset the cache and load in the items in entries in the order listed.
* Note that the shape of the resulting cache may be different if the
* same options are not used in both caches.
*/
load(arr: [K, LRUCache.Entry<V>][]): void;
/**
* Add a value to the cache.
*
* Note: if `undefined` is specified as a value, this is an alias for
* {@link LRUCache#delete}
*/
set(k: K, v: V | BackgroundFetch<V> | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
/**
* Evict the least recently used item, returning its value or
* `undefined` if cache is empty.
*/
pop(): V | undefined;
/**
* Check if a key is in the cache, without updating the recency of use.
* Will return false if the item is stale, even though it is technically
* in the cache.
*
* Will not update item age unless
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
*/
has(k: K, hasOptions?: LRUCache.HasOptions<K, V, FC>): boolean;
/**
* Like {@link LRUCache#get} but doesn't update recency or delete stale
* items.
*
* Returns `undefined` if the item is stale, unless
* {@link LRUCache.OptionsBase.allowStale} is set.
*/
peek(k: K, peekOptions?: LRUCache.PeekOptions<K, V, FC>): V | undefined;
/**
* Make an asynchronous cached fetch using the
* {@link LRUCache.OptionsBase.fetchMethod} function.
*
* If multiple fetches for the same key are issued, then they will all be
* coalesced into a single call to fetchMethod.
*
* Note that this means that handling options such as
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort},
* {@link LRUCache.FetchOptions.signal},
* and {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} will be
* determined by the FIRST fetch() call for a given key.
*
* This is a known (fixable) shortcoming which will be addresed on when
* someone complains about it, as the fix would involve added complexity and
* may not be worth the costs for this edge case.
*/
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<undefined | V>;
/**
* Return a value from the cache. Will update the recency of the cache
* entry found.
*
* If the key is not found, get() will return `undefined`.
*/
get(k: K, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
/**
* Deletes a key out of the cache.
* Returns true if the key was deleted, false otherwise.
*/
delete(k: K): boolean;
/**
* Clear the cache entirely, throwing away all values.
*/
clear(): void;
}
//# sourceMappingURL=index.d.ts.map

Some files were not shown because too many files have changed in this diff Show More