Conexio amb la api
This commit is contained in:
parent
207c0ba819
commit
b12369cb47
48513 changed files with 7391639 additions and 7 deletions
123
node_modules/engine.io-parser/CHANGELOG.md
generated
vendored
Executable file
123
node_modules/engine.io-parser/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,123 @@
|
|||
## [5.0.1](https://github.com/socketio/engine.io-parser/compare/5.0.0...5.0.1) (2021-10-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix vite build ([900346e](https://github.com/socketio/engine.io-parser/commit/900346ea34ddc178d80eaabc8ea516d929457855))
|
||||
|
||||
|
||||
|
||||
# [5.0.0](https://github.com/socketio/engine.io-parser/compare/4.0.3...5.0.0) (2021-10-04)
|
||||
|
||||
This release includes the migration to TypeScript. The major bump is due to the new "exports" field in the package.json file.
|
||||
|
||||
See also: https://nodejs.org/api/packages.html#packages_package_entry_points
|
||||
|
||||
## [4.0.3](https://github.com/socketio/engine.io-parser/compare/4.0.2...4.0.3) (2021-08-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* respect the offset and length of TypedArray objects ([6d7dd76](https://github.com/socketio/engine.io-parser/commit/6d7dd76130690afda6c214d5c04305d2bbc4eb4d))
|
||||
|
||||
|
||||
## [4.0.2](https://github.com/socketio/engine.io-parser/compare/4.0.1...4.0.2) (2020-12-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add base64-arraybuffer as prod dependency ([2ccdeb2](https://github.com/socketio/engine.io-parser/commit/2ccdeb277955bed8742a29f2dcbbf57ca95eb12a))
|
||||
|
||||
|
||||
## [2.2.1](https://github.com/socketio/engine.io-parser/compare/2.2.0...2.2.1) (2020-09-30)
|
||||
|
||||
|
||||
## [4.0.1](https://github.com/socketio/engine.io-parser/compare/4.0.0...4.0.1) (2020-09-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use a terser-compatible representation of the separator ([886f9ea](https://github.com/socketio/engine.io-parser/commit/886f9ea7c4e717573152c31320f6fb6c6664061b))
|
||||
|
||||
|
||||
# [4.0.0](https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.1...4.0.0) (2020-09-08)
|
||||
|
||||
This major release contains the necessary changes for the version 4 of the Engine.IO protocol. More information about the new version can be found [there](https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4).
|
||||
|
||||
Encoding changes between v3 and v4:
|
||||
|
||||
- encodePacket with string
|
||||
- input: `{ type: "message", data: "hello" }`
|
||||
- output in v3: `"4hello"`
|
||||
- output in v4: `"4hello"`
|
||||
|
||||
- encodePacket with binary
|
||||
- input: `{ type: 'message', data: <Buffer 01 02 03> }`
|
||||
- output in v3: `<Buffer 04 01 02 03>`
|
||||
- output in v4: `<Buffer 01 02 03>`
|
||||
|
||||
- encodePayload with strings
|
||||
- input: `[ { type: 'message', data: 'hello' }, { type: 'message', data: '€€€' } ]`
|
||||
- output in v3: `"6:4hello4:4€€€"`
|
||||
- output in v4: `"4hello\x1e4€€€"`
|
||||
|
||||
- encodePayload with string and binary
|
||||
- input: `[ { type: 'message', data: 'hello' }, { type: 'message', data: <Buffer 01 02 03> } ]`
|
||||
- output in v3: `<Buffer 00 06 ff 34 68 65 6c 6c 6f 01 04 ff 04 01 02 03>`
|
||||
- output in v4: `"4hello\x1ebAQID"`
|
||||
|
||||
Please note that the parser is now dependency-free! This should help reduce the size of the browser bundle.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* keep track of the buffer initial length ([8edf2d1](https://github.com/socketio/engine.io-parser/commit/8edf2d1478026da442f519c2d2521af43ba01832))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* restore the upgrade mechanism ([6efedfa](https://github.com/socketio/engine.io-parser/commit/6efedfa0f3048506a4ba99e70674ddf4c0732e0c))
|
||||
|
||||
|
||||
|
||||
# [4.0.0-alpha.1](https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.0...v4.0.0-alpha.1) (2020-05-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* implement the version 4 of the protocol ([cab7db0](https://github.com/socketio/engine.io-parser/commit/cab7db0404e0a69f86a05ececd62c8c31f4d97d5))
|
||||
|
||||
|
||||
|
||||
# [4.0.0-alpha.0](https://github.com/socketio/engine.io-parser/compare/2.2.0...v4.0.0-alpha.0) (2020-02-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* properly decode binary packets ([5085373](https://github.com/socketio/engine.io-parser/commit/50853738e0c6c16f9cee0d7887651155f4b78240))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* remove packet type when encoding binary packets ([a947ae5](https://github.com/socketio/engine.io-parser/commit/a947ae59a2844e4041db58ff36b270d1528b3bee))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* the packet containing binary data will now be sent without any transformation
|
||||
|
||||
Protocol v3: { type: 'message', data: <Buffer 01 02 03> } => <Buffer 04 01 02 03>
|
||||
Protocol v4: { type: 'message', data: <Buffer 01 02 03> } => <Buffer 01 02 03>
|
||||
|
||||
|
||||
|
||||
# [2.2.0](https://github.com/socketio/engine.io-parser/compare/2.1.3...2.2.0) (2019-09-13)
|
||||
|
||||
|
||||
* [refactor] Use `Buffer.allocUnsafe` instead of `new Buffer` (#104) ([aedf8eb](https://github.com/socketio/engine.io-parser/commit/aedf8eb29e8bf6aeb5c6cc68965d986c4c958ae2)), closes [#104](https://github.com/socketio/engine.io-parser/issues/104)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* drop support for Node.js 4 (since Buffer.allocUnsafe was added in v5.10.0)
|
||||
|
||||
Reference: https://nodejs.org/docs/latest/api/buffer.html#buffer_class_method_buffer_allocunsafe_size
|
||||
22
node_modules/engine.io-parser/LICENSE
generated
vendored
Executable file
22
node_modules/engine.io-parser/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Guillermo Rauch (@rauchg)
|
||||
|
||||
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.
|
||||
158
node_modules/engine.io-parser/Readme.md
generated
vendored
Executable file
158
node_modules/engine.io-parser/Readme.md
generated
vendored
Executable file
|
|
@ -0,0 +1,158 @@
|
|||
|
||||
# engine.io-parser
|
||||
|
||||
[](https://github.com/socketio/engine.io-parser/actions)
|
||||
[](https://npmjs.com/package/engine.io-parser)
|
||||
|
||||
This is the JavaScript parser for the engine.io protocol encoding,
|
||||
shared by both
|
||||
[engine.io-client](https://github.com/socketio/engine.io-client) and
|
||||
[engine.io](https://github.com/socketio/engine.io).
|
||||
|
||||
## How to use
|
||||
|
||||
### Standalone
|
||||
|
||||
The parser can encode/decode packets, payloads, and payloads as binary
|
||||
with the following methods: `encodePacket`, `decodePacket`, `encodePayload`,
|
||||
`decodePayload`.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const parser = require("engine.io-parser");
|
||||
const data = Buffer.from([ 1, 2, 3, 4 ]);
|
||||
|
||||
parser.encodePacket({ type: "message", data }, encoded => {
|
||||
const decodedData = parser.decodePacket(encoded); // decodedData === data
|
||||
});
|
||||
```
|
||||
|
||||
### With browserify
|
||||
|
||||
Engine.IO Parser is a commonjs module, which means you can include it by using
|
||||
`require` on the browser and package using [browserify](http://browserify.org/):
|
||||
|
||||
1. install the parser package
|
||||
|
||||
```shell
|
||||
npm install engine.io-parser
|
||||
```
|
||||
|
||||
1. write your app code
|
||||
|
||||
```js
|
||||
const parser = require("engine.io-parser");
|
||||
|
||||
const testBuffer = new Int8Array(10);
|
||||
for (let i = 0; i < testBuffer.length; i++) testBuffer[i] = i;
|
||||
|
||||
const packets = [{ type: "message", data: testBuffer.buffer }, { type: "message", data: "hello" }];
|
||||
|
||||
parser.encodePayload(packets, encoded => {
|
||||
parser.decodePayload(encoded,
|
||||
(packet, index, total) => {
|
||||
const isLast = index + 1 == total;
|
||||
if (!isLast) {
|
||||
const buffer = new Int8Array(packet.data); // testBuffer
|
||||
} else {
|
||||
const message = packet.data; // "hello"
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
1. build your app bundle
|
||||
|
||||
```bash
|
||||
$ browserify app.js > bundle.js
|
||||
```
|
||||
|
||||
1. include on your page
|
||||
|
||||
```html
|
||||
<script src="/path/to/bundle.js"></script>
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Runs on browser and node.js seamlessly
|
||||
- Runs inside HTML5 WebWorker
|
||||
- Can encode and decode packets
|
||||
- Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node
|
||||
|
||||
## API
|
||||
|
||||
Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called.
|
||||
|
||||
### Node
|
||||
|
||||
- `encodePacket`
|
||||
- Encodes a packet.
|
||||
- **Parameters**
|
||||
- `Object`: the packet to encode, has `type` and `data`.
|
||||
- `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer`
|
||||
- `Boolean`: binary support
|
||||
- `Function`: callback, returns the encoded packet (`cb(String)`)
|
||||
- `decodePacket`
|
||||
- Decodes a packet. Data also available as an ArrayBuffer if requested.
|
||||
- Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node)
|
||||
- **Parameters**
|
||||
- `String` | `ArrayBuffer`: the packet to decode, has `type` and `data`
|
||||
- `String`: optional, the binary type
|
||||
|
||||
- `encodePayload`
|
||||
- Encodes multiple messages (payload).
|
||||
- If any contents are binary, they will be encoded as base64 strings. Base64
|
||||
encoded strings are marked with a b before the length specifier
|
||||
- **Parameters**
|
||||
- `Array`: an array of packets
|
||||
- `Function`: callback, returns the encoded payload (`cb(String)`)
|
||||
- `decodePayload`
|
||||
- Decodes data when a payload is maybe expected. Possible binary contents are
|
||||
decoded from their base64 representation.
|
||||
- **Parameters**
|
||||
- `String`: the payload
|
||||
- `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))
|
||||
|
||||
## Tests
|
||||
|
||||
Standalone tests can be run with `npm test` which will run the node.js tests.
|
||||
|
||||
Browser tests are run using [zuul](https://github.com/defunctzombie/zuul).
|
||||
(You must have zuul setup with a saucelabs account.)
|
||||
|
||||
You can run the tests locally using the following command:
|
||||
|
||||
```
|
||||
npm run test:browser
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
The support channels for `engine.io-parser` are the same as `socket.io`:
|
||||
- irc.freenode.net **#socket.io**
|
||||
- [Github Discussions](https://github.com/socketio/socket.io/discussions)
|
||||
- [Website](https://socket.io)
|
||||
|
||||
## Development
|
||||
|
||||
To contribute patches, run tests or benchmarks, make sure to clone the
|
||||
repository:
|
||||
|
||||
```bash
|
||||
git clone git://github.com/socketio/engine.io-parser.git
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
cd engine.io-parser
|
||||
npm ci
|
||||
```
|
||||
|
||||
See the `Tests` section above for how to run tests before submitting any patches.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
19
node_modules/engine.io-parser/build/cjs/commons.js
generated
vendored
Executable file
19
node_modules/engine.io-parser/build/cjs/commons.js
generated
vendored
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;
|
||||
const PACKET_TYPES = Object.create(null); // no Map = no polyfill
|
||||
exports.PACKET_TYPES = PACKET_TYPES;
|
||||
PACKET_TYPES["open"] = "0";
|
||||
PACKET_TYPES["close"] = "1";
|
||||
PACKET_TYPES["ping"] = "2";
|
||||
PACKET_TYPES["pong"] = "3";
|
||||
PACKET_TYPES["message"] = "4";
|
||||
PACKET_TYPES["upgrade"] = "5";
|
||||
PACKET_TYPES["noop"] = "6";
|
||||
const PACKET_TYPES_REVERSE = Object.create(null);
|
||||
exports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;
|
||||
Object.keys(PACKET_TYPES).forEach(key => {
|
||||
PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
|
||||
});
|
||||
const ERROR_PACKET = { type: "error", data: "parser error" };
|
||||
exports.ERROR_PACKET = ERROR_PACKET;
|
||||
51
node_modules/engine.io-parser/build/cjs/decodePacket.browser.js
generated
vendored
Executable file
51
node_modules/engine.io-parser/build/cjs/decodePacket.browser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commons_js_1 = require("./commons.js");
|
||||
const base64_arraybuffer_1 = require("base64-arraybuffer");
|
||||
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
||||
const decodePacket = (encodedPacket, binaryType) => {
|
||||
if (typeof encodedPacket !== "string") {
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(encodedPacket, binaryType)
|
||||
};
|
||||
}
|
||||
const type = encodedPacket.charAt(0);
|
||||
if (type === "b") {
|
||||
return {
|
||||
type: "message",
|
||||
data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
|
||||
};
|
||||
}
|
||||
const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];
|
||||
if (!packetType) {
|
||||
return commons_js_1.ERROR_PACKET;
|
||||
}
|
||||
return encodedPacket.length > 1
|
||||
? {
|
||||
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
||||
data: encodedPacket.substring(1)
|
||||
}
|
||||
: {
|
||||
type: commons_js_1.PACKET_TYPES_REVERSE[type]
|
||||
};
|
||||
};
|
||||
const decodeBase64Packet = (data, binaryType) => {
|
||||
if (withNativeArrayBuffer) {
|
||||
const decoded = (0, base64_arraybuffer_1.decode)(data);
|
||||
return mapBinary(decoded, binaryType);
|
||||
}
|
||||
else {
|
||||
return { base64: true, data }; // fallback for old browsers
|
||||
}
|
||||
};
|
||||
const mapBinary = (data, binaryType) => {
|
||||
switch (binaryType) {
|
||||
case "blob":
|
||||
return data instanceof ArrayBuffer ? new Blob([data]) : data;
|
||||
case "arraybuffer":
|
||||
default:
|
||||
return data; // assuming the data is already an ArrayBuffer
|
||||
}
|
||||
};
|
||||
exports.default = decodePacket;
|
||||
49
node_modules/engine.io-parser/build/cjs/decodePacket.js
generated
vendored
Executable file
49
node_modules/engine.io-parser/build/cjs/decodePacket.js
generated
vendored
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commons_js_1 = require("./commons.js");
|
||||
const decodePacket = (encodedPacket, binaryType) => {
|
||||
if (typeof encodedPacket !== "string") {
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(encodedPacket, binaryType)
|
||||
};
|
||||
}
|
||||
const type = encodedPacket.charAt(0);
|
||||
if (type === "b") {
|
||||
const buffer = Buffer.from(encodedPacket.substring(1), "base64");
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(buffer, binaryType)
|
||||
};
|
||||
}
|
||||
if (!commons_js_1.PACKET_TYPES_REVERSE[type]) {
|
||||
return commons_js_1.ERROR_PACKET;
|
||||
}
|
||||
return encodedPacket.length > 1
|
||||
? {
|
||||
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
||||
data: encodedPacket.substring(1)
|
||||
}
|
||||
: {
|
||||
type: commons_js_1.PACKET_TYPES_REVERSE[type]
|
||||
};
|
||||
};
|
||||
const mapBinary = (data, binaryType) => {
|
||||
const isBuffer = Buffer.isBuffer(data);
|
||||
switch (binaryType) {
|
||||
case "arraybuffer":
|
||||
return isBuffer ? toArrayBuffer(data) : data;
|
||||
case "nodebuffer":
|
||||
default:
|
||||
return data; // assuming the data is already a Buffer
|
||||
}
|
||||
};
|
||||
const toArrayBuffer = buffer => {
|
||||
const arrayBuffer = new ArrayBuffer(buffer.length);
|
||||
const view = new Uint8Array(arrayBuffer);
|
||||
for (let i = 0; i < buffer.length; i++) {
|
||||
view[i] = buffer[i];
|
||||
}
|
||||
return arrayBuffer;
|
||||
};
|
||||
exports.default = decodePacket;
|
||||
43
node_modules/engine.io-parser/build/cjs/encodePacket.browser.js
generated
vendored
Executable file
43
node_modules/engine.io-parser/build/cjs/encodePacket.browser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commons_js_1 = require("./commons.js");
|
||||
const withNativeBlob = typeof Blob === "function" ||
|
||||
(typeof Blob !== "undefined" &&
|
||||
Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
|
||||
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
||||
// ArrayBuffer.isView method is not defined in IE10
|
||||
const isView = obj => {
|
||||
return typeof ArrayBuffer.isView === "function"
|
||||
? ArrayBuffer.isView(obj)
|
||||
: obj && obj.buffer instanceof ArrayBuffer;
|
||||
};
|
||||
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
||||
if (withNativeBlob && data instanceof Blob) {
|
||||
if (supportsBinary) {
|
||||
return callback(data);
|
||||
}
|
||||
else {
|
||||
return encodeBlobAsBase64(data, callback);
|
||||
}
|
||||
}
|
||||
else if (withNativeArrayBuffer &&
|
||||
(data instanceof ArrayBuffer || isView(data))) {
|
||||
if (supportsBinary) {
|
||||
return callback(data);
|
||||
}
|
||||
else {
|
||||
return encodeBlobAsBase64(new Blob([data]), callback);
|
||||
}
|
||||
}
|
||||
// plain string
|
||||
return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
|
||||
};
|
||||
const encodeBlobAsBase64 = (data, callback) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function () {
|
||||
const content = fileReader.result.split(",")[1];
|
||||
callback("b" + content);
|
||||
};
|
||||
return fileReader.readAsDataURL(data);
|
||||
};
|
||||
exports.default = encodePacket;
|
||||
27
node_modules/engine.io-parser/build/cjs/encodePacket.js
generated
vendored
Executable file
27
node_modules/engine.io-parser/build/cjs/encodePacket.js
generated
vendored
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commons_js_1 = require("./commons.js");
|
||||
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
||||
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
|
||||
const buffer = toBuffer(data);
|
||||
return callback(encodeBuffer(buffer, supportsBinary));
|
||||
}
|
||||
// plain string
|
||||
return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
|
||||
};
|
||||
const toBuffer = data => {
|
||||
if (Buffer.isBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
else if (data instanceof ArrayBuffer) {
|
||||
return Buffer.from(data);
|
||||
}
|
||||
else {
|
||||
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
};
|
||||
// only 'message' packets can contain binary, so the type prefix is not needed
|
||||
const encodeBuffer = (data, supportsBinary) => {
|
||||
return supportsBinary ? data : "b" + data.toString("base64");
|
||||
};
|
||||
exports.default = encodePacket;
|
||||
38
node_modules/engine.io-parser/build/cjs/index.js
generated
vendored
Executable file
38
node_modules/engine.io-parser/build/cjs/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0;
|
||||
const encodePacket_js_1 = require("./encodePacket.js");
|
||||
exports.encodePacket = encodePacket_js_1.default;
|
||||
const decodePacket_js_1 = require("./decodePacket.js");
|
||||
exports.decodePacket = decodePacket_js_1.default;
|
||||
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
|
||||
const encodePayload = (packets, callback) => {
|
||||
// some packets may be added to the array while encoding, so the initial length must be saved
|
||||
const length = packets.length;
|
||||
const encodedPackets = new Array(length);
|
||||
let count = 0;
|
||||
packets.forEach((packet, i) => {
|
||||
// force base64 encoding for binary packets
|
||||
(0, encodePacket_js_1.default)(packet, false, encodedPacket => {
|
||||
encodedPackets[i] = encodedPacket;
|
||||
if (++count === length) {
|
||||
callback(encodedPackets.join(SEPARATOR));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
exports.encodePayload = encodePayload;
|
||||
const decodePayload = (encodedPayload, binaryType) => {
|
||||
const encodedPackets = encodedPayload.split(SEPARATOR);
|
||||
const packets = [];
|
||||
for (let i = 0; i < encodedPackets.length; i++) {
|
||||
const decodedPacket = (0, decodePacket_js_1.default)(encodedPackets[i], binaryType);
|
||||
packets.push(decodedPacket);
|
||||
if (decodedPacket.type === "error") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return packets;
|
||||
};
|
||||
exports.decodePayload = decodePayload;
|
||||
exports.protocol = 4;
|
||||
7
node_modules/engine.io-parser/build/cjs/package.json
generated
vendored
Executable file
7
node_modules/engine.io-parser/build/cjs/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "commonjs",
|
||||
"browser": {
|
||||
"./encodePacket.js": "./encodePacket.browser.js",
|
||||
"./decodePacket.js": "./decodePacket.browser.js"
|
||||
}
|
||||
}
|
||||
7
node_modules/engine.io-parser/build/esm/commons.d.ts
generated
vendored
Executable file
7
node_modules/engine.io-parser/build/esm/commons.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
declare const PACKET_TYPES: any;
|
||||
declare const PACKET_TYPES_REVERSE: any;
|
||||
declare const ERROR_PACKET: {
|
||||
type: string;
|
||||
data: string;
|
||||
};
|
||||
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET };
|
||||
14
node_modules/engine.io-parser/build/esm/commons.js
generated
vendored
Executable file
14
node_modules/engine.io-parser/build/esm/commons.js
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
const PACKET_TYPES = Object.create(null); // no Map = no polyfill
|
||||
PACKET_TYPES["open"] = "0";
|
||||
PACKET_TYPES["close"] = "1";
|
||||
PACKET_TYPES["ping"] = "2";
|
||||
PACKET_TYPES["pong"] = "3";
|
||||
PACKET_TYPES["message"] = "4";
|
||||
PACKET_TYPES["upgrade"] = "5";
|
||||
PACKET_TYPES["noop"] = "6";
|
||||
const PACKET_TYPES_REVERSE = Object.create(null);
|
||||
Object.keys(PACKET_TYPES).forEach(key => {
|
||||
PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
|
||||
});
|
||||
const ERROR_PACKET = { type: "error", data: "parser error" };
|
||||
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET };
|
||||
11
node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts
generated
vendored
Executable file
11
node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
declare const decodePacket: (encodedPacket: any, binaryType: any) => {
|
||||
type: string;
|
||||
data: any;
|
||||
} | {
|
||||
type: any;
|
||||
data: string;
|
||||
} | {
|
||||
type: any;
|
||||
data?: undefined;
|
||||
};
|
||||
export default decodePacket;
|
||||
49
node_modules/engine.io-parser/build/esm/decodePacket.browser.js
generated
vendored
Executable file
49
node_modules/engine.io-parser/build/esm/decodePacket.browser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
import { ERROR_PACKET, PACKET_TYPES_REVERSE } from "./commons.js";
|
||||
import { decode } from "base64-arraybuffer";
|
||||
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
||||
const decodePacket = (encodedPacket, binaryType) => {
|
||||
if (typeof encodedPacket !== "string") {
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(encodedPacket, binaryType)
|
||||
};
|
||||
}
|
||||
const type = encodedPacket.charAt(0);
|
||||
if (type === "b") {
|
||||
return {
|
||||
type: "message",
|
||||
data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
|
||||
};
|
||||
}
|
||||
const packetType = PACKET_TYPES_REVERSE[type];
|
||||
if (!packetType) {
|
||||
return ERROR_PACKET;
|
||||
}
|
||||
return encodedPacket.length > 1
|
||||
? {
|
||||
type: PACKET_TYPES_REVERSE[type],
|
||||
data: encodedPacket.substring(1)
|
||||
}
|
||||
: {
|
||||
type: PACKET_TYPES_REVERSE[type]
|
||||
};
|
||||
};
|
||||
const decodeBase64Packet = (data, binaryType) => {
|
||||
if (withNativeArrayBuffer) {
|
||||
const decoded = decode(data);
|
||||
return mapBinary(decoded, binaryType);
|
||||
}
|
||||
else {
|
||||
return { base64: true, data }; // fallback for old browsers
|
||||
}
|
||||
};
|
||||
const mapBinary = (data, binaryType) => {
|
||||
switch (binaryType) {
|
||||
case "blob":
|
||||
return data instanceof ArrayBuffer ? new Blob([data]) : data;
|
||||
case "arraybuffer":
|
||||
default:
|
||||
return data; // assuming the data is already an ArrayBuffer
|
||||
}
|
||||
};
|
||||
export default decodePacket;
|
||||
11
node_modules/engine.io-parser/build/esm/decodePacket.d.ts
generated
vendored
Executable file
11
node_modules/engine.io-parser/build/esm/decodePacket.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
declare const decodePacket: (encodedPacket: any, binaryType?: any) => {
|
||||
type: string;
|
||||
data: any;
|
||||
} | {
|
||||
type: any;
|
||||
data: string;
|
||||
} | {
|
||||
type: any;
|
||||
data?: undefined;
|
||||
};
|
||||
export default decodePacket;
|
||||
47
node_modules/engine.io-parser/build/esm/decodePacket.js
generated
vendored
Executable file
47
node_modules/engine.io-parser/build/esm/decodePacket.js
generated
vendored
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
import { ERROR_PACKET, PACKET_TYPES_REVERSE } from "./commons.js";
|
||||
const decodePacket = (encodedPacket, binaryType) => {
|
||||
if (typeof encodedPacket !== "string") {
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(encodedPacket, binaryType)
|
||||
};
|
||||
}
|
||||
const type = encodedPacket.charAt(0);
|
||||
if (type === "b") {
|
||||
const buffer = Buffer.from(encodedPacket.substring(1), "base64");
|
||||
return {
|
||||
type: "message",
|
||||
data: mapBinary(buffer, binaryType)
|
||||
};
|
||||
}
|
||||
if (!PACKET_TYPES_REVERSE[type]) {
|
||||
return ERROR_PACKET;
|
||||
}
|
||||
return encodedPacket.length > 1
|
||||
? {
|
||||
type: PACKET_TYPES_REVERSE[type],
|
||||
data: encodedPacket.substring(1)
|
||||
}
|
||||
: {
|
||||
type: PACKET_TYPES_REVERSE[type]
|
||||
};
|
||||
};
|
||||
const mapBinary = (data, binaryType) => {
|
||||
const isBuffer = Buffer.isBuffer(data);
|
||||
switch (binaryType) {
|
||||
case "arraybuffer":
|
||||
return isBuffer ? toArrayBuffer(data) : data;
|
||||
case "nodebuffer":
|
||||
default:
|
||||
return data; // assuming the data is already a Buffer
|
||||
}
|
||||
};
|
||||
const toArrayBuffer = buffer => {
|
||||
const arrayBuffer = new ArrayBuffer(buffer.length);
|
||||
const view = new Uint8Array(arrayBuffer);
|
||||
for (let i = 0; i < buffer.length; i++) {
|
||||
view[i] = buffer[i];
|
||||
}
|
||||
return arrayBuffer;
|
||||
};
|
||||
export default decodePacket;
|
||||
5
node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts
generated
vendored
Executable file
5
node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
declare const encodePacket: ({ type, data }: {
|
||||
type: any;
|
||||
data: any;
|
||||
}, supportsBinary: any, callback: any) => any;
|
||||
export default encodePacket;
|
||||
41
node_modules/engine.io-parser/build/esm/encodePacket.browser.js
generated
vendored
Executable file
41
node_modules/engine.io-parser/build/esm/encodePacket.browser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
import { PACKET_TYPES } from "./commons.js";
|
||||
const withNativeBlob = typeof Blob === "function" ||
|
||||
(typeof Blob !== "undefined" &&
|
||||
Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
|
||||
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
||||
// ArrayBuffer.isView method is not defined in IE10
|
||||
const isView = obj => {
|
||||
return typeof ArrayBuffer.isView === "function"
|
||||
? ArrayBuffer.isView(obj)
|
||||
: obj && obj.buffer instanceof ArrayBuffer;
|
||||
};
|
||||
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
||||
if (withNativeBlob && data instanceof Blob) {
|
||||
if (supportsBinary) {
|
||||
return callback(data);
|
||||
}
|
||||
else {
|
||||
return encodeBlobAsBase64(data, callback);
|
||||
}
|
||||
}
|
||||
else if (withNativeArrayBuffer &&
|
||||
(data instanceof ArrayBuffer || isView(data))) {
|
||||
if (supportsBinary) {
|
||||
return callback(data);
|
||||
}
|
||||
else {
|
||||
return encodeBlobAsBase64(new Blob([data]), callback);
|
||||
}
|
||||
}
|
||||
// plain string
|
||||
return callback(PACKET_TYPES[type] + (data || ""));
|
||||
};
|
||||
const encodeBlobAsBase64 = (data, callback) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = function () {
|
||||
const content = fileReader.result.split(",")[1];
|
||||
callback("b" + content);
|
||||
};
|
||||
return fileReader.readAsDataURL(data);
|
||||
};
|
||||
export default encodePacket;
|
||||
5
node_modules/engine.io-parser/build/esm/encodePacket.d.ts
generated
vendored
Executable file
5
node_modules/engine.io-parser/build/esm/encodePacket.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
declare const encodePacket: ({ type, data }: {
|
||||
type: any;
|
||||
data: any;
|
||||
}, supportsBinary: any, callback: any) => any;
|
||||
export default encodePacket;
|
||||
25
node_modules/engine.io-parser/build/esm/encodePacket.js
generated
vendored
Executable file
25
node_modules/engine.io-parser/build/esm/encodePacket.js
generated
vendored
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
import { PACKET_TYPES } from "./commons.js";
|
||||
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
||||
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
|
||||
const buffer = toBuffer(data);
|
||||
return callback(encodeBuffer(buffer, supportsBinary));
|
||||
}
|
||||
// plain string
|
||||
return callback(PACKET_TYPES[type] + (data || ""));
|
||||
};
|
||||
const toBuffer = data => {
|
||||
if (Buffer.isBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
else if (data instanceof ArrayBuffer) {
|
||||
return Buffer.from(data);
|
||||
}
|
||||
else {
|
||||
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
};
|
||||
// only 'message' packets can contain binary, so the type prefix is not needed
|
||||
const encodeBuffer = (data, supportsBinary) => {
|
||||
return supportsBinary ? data : "b" + data.toString("base64");
|
||||
};
|
||||
export default encodePacket;
|
||||
6
node_modules/engine.io-parser/build/esm/index.d.ts
generated
vendored
Executable file
6
node_modules/engine.io-parser/build/esm/index.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
import encodePacket from "./encodePacket.js";
|
||||
import decodePacket from "./decodePacket.js";
|
||||
declare const encodePayload: (packets: any, callback: any) => void;
|
||||
declare const decodePayload: (encodedPayload: any, binaryType?: any) => any[];
|
||||
export declare const protocol = 4;
|
||||
export { encodePacket, encodePayload, decodePacket, decodePayload };
|
||||
32
node_modules/engine.io-parser/build/esm/index.js
generated
vendored
Executable file
32
node_modules/engine.io-parser/build/esm/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
import encodePacket from "./encodePacket.js";
|
||||
import decodePacket from "./decodePacket.js";
|
||||
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
|
||||
const encodePayload = (packets, callback) => {
|
||||
// some packets may be added to the array while encoding, so the initial length must be saved
|
||||
const length = packets.length;
|
||||
const encodedPackets = new Array(length);
|
||||
let count = 0;
|
||||
packets.forEach((packet, i) => {
|
||||
// force base64 encoding for binary packets
|
||||
encodePacket(packet, false, encodedPacket => {
|
||||
encodedPackets[i] = encodedPacket;
|
||||
if (++count === length) {
|
||||
callback(encodedPackets.join(SEPARATOR));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
const decodePayload = (encodedPayload, binaryType) => {
|
||||
const encodedPackets = encodedPayload.split(SEPARATOR);
|
||||
const packets = [];
|
||||
for (let i = 0; i < encodedPackets.length; i++) {
|
||||
const decodedPacket = decodePacket(encodedPackets[i], binaryType);
|
||||
packets.push(decodedPacket);
|
||||
if (decodedPacket.type === "error") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return packets;
|
||||
};
|
||||
export const protocol = 4;
|
||||
export { encodePacket, encodePayload, decodePacket, decodePayload };
|
||||
7
node_modules/engine.io-parser/build/esm/package.json
generated
vendored
Executable file
7
node_modules/engine.io-parser/build/esm/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "module",
|
||||
"browser": {
|
||||
"./encodePacket.js": "./encodePacket.browser.js",
|
||||
"./decodePacket.js": "./decodePacket.browser.js"
|
||||
}
|
||||
}
|
||||
87
node_modules/engine.io-parser/package.json
generated
vendored
Executable file
87
node_modules/engine.io-parser/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"_from": "engine.io-parser@~5.0.0",
|
||||
"_id": "engine.io-parser@5.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-j4p3WwJrG2k92VISM0op7wiq60vO92MlF3CRGxhKHy9ywG1/Dkc72g0dXeDQ+//hrcDn8gqQzoEkdO9FN0d9AA==",
|
||||
"_location": "/engine.io-parser",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "engine.io-parser@~5.0.0",
|
||||
"name": "engine.io-parser",
|
||||
"escapedName": "engine.io-parser",
|
||||
"rawSpec": "~5.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~5.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/engine.io"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.1.tgz",
|
||||
"_shasum": "6695fc0f1e6d76ad4a48300ff80db5f6b3654939",
|
||||
"_spec": "engine.io-parser@~5.0.0",
|
||||
"_where": "/home/jack/Documents/JDA/m14/projecte_janmaroto/node_modules/engine.io",
|
||||
"browser": {
|
||||
"./test/node": "./test/browser",
|
||||
"./build/esm/encodePacket.js": "./build/esm/encodePacket.browser.js",
|
||||
"./build/esm/decodePacket.js": "./build/esm/decodePacket.browser.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/socketio/engine.io-parser/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"base64-arraybuffer": "~1.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Parser for the client for the realtime Engine",
|
||||
"devDependencies": {
|
||||
"@babel/core": "~7.9.6",
|
||||
"@babel/preset-env": "~7.9.6",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.9.6",
|
||||
"babelify": "^10.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"expect.js": "0.3.1",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "~15.0.1",
|
||||
"prettier": "^1.19.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"socket.io-browsers": "^1.0.4",
|
||||
"ts-node": "^10.2.1",
|
||||
"tsify": "^5.0.4",
|
||||
"typescript": "^4.4.3",
|
||||
"zuul": "3.11.1",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"exports": {
|
||||
"import": "./build/esm/index.js",
|
||||
"require": "./build/cjs/index.js"
|
||||
},
|
||||
"files": [
|
||||
"build/"
|
||||
],
|
||||
"homepage": "https://github.com/socketio/engine.io-parser",
|
||||
"license": "MIT",
|
||||
"main": "./build/cjs/index.js",
|
||||
"module": "./build/esm/index.js",
|
||||
"name": "engine.io-parser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/socketio/engine.io-parser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh",
|
||||
"format:check": "prettier --check 'lib/**/*.ts' 'test/**/*.ts'",
|
||||
"format:fix": "prettier --write 'lib/**/*.ts' 'test/**/*.ts'",
|
||||
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
|
||||
"test:browser": "zuul test/index.ts --no-coverage",
|
||||
"test:node": "nyc mocha -r ts-node/register test/index.ts"
|
||||
},
|
||||
"types": "build/esm/index.d.ts",
|
||||
"version": "5.0.1"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue