engine.io-parser
Advanced tools
Comparing version 5.2.2 to 5.2.3
@@ -5,4 +5,4 @@ declare const PACKET_TYPES: any; | ||
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET }; | ||
export declare type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error"; | ||
export declare type RawData = any; | ||
export type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error"; | ||
export type RawData = any; | ||
export interface Packet { | ||
@@ -15,2 +15,2 @@ type: PacketType; | ||
} | ||
export declare type BinaryType = "nodebuffer" | "arraybuffer" | "blob"; | ||
export type BinaryType = "nodebuffer" | "arraybuffer" | "blob"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encodePacket = exports.encodePacketToBinary = void 0; | ||
exports.encodePacket = void 0; | ||
exports.encodePacketToBinary = encodePacketToBinary; | ||
const commons_js_1 = require("./commons.js"); | ||
@@ -72,2 +73,1 @@ const withNativeBlob = typeof Blob === "function" || | ||
} | ||
exports.encodePacketToBinary = encodePacketToBinary; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encodePacketToBinary = exports.encodePacket = void 0; | ||
exports.encodePacket = void 0; | ||
exports.encodePacketToBinary = encodePacketToBinary; | ||
const commons_js_1 = require("./commons.js"); | ||
@@ -38,2 +39,1 @@ const encodePacket = ({ type, data }, supportsBinary, callback) => { | ||
} | ||
exports.encodePacketToBinary = encodePacketToBinary; |
@@ -1,11 +0,9 @@ | ||
/// <reference types="node" /> | ||
import { encodePacket } from "./encodePacket.js"; | ||
import { decodePacket } from "./decodePacket.js"; | ||
import { Packet, PacketType, RawData, BinaryType } from "./commons.js"; | ||
import type { TransformStream } from "node:stream/web"; | ||
declare const encodePayload: (packets: Packet[], callback: (encodedPayload: string) => void) => void; | ||
declare const decodePayload: (encodedPayload: string, binaryType?: BinaryType) => Packet[]; | ||
export declare function createPacketEncoderStream(): TransformStream<Packet, any>; | ||
export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>; | ||
export declare function createPacketEncoderStream(): any; | ||
export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): any; | ||
export declare const protocol = 4; | ||
export { encodePacket, encodePayload, decodePacket, decodePayload, Packet, PacketType, RawData, BinaryType, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0; | ||
exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; | ||
exports.createPacketEncoderStream = createPacketEncoderStream; | ||
exports.createPacketDecoderStream = createPacketDecoderStream; | ||
const encodePacket_js_1 = require("./encodePacket.js"); | ||
@@ -40,3 +42,2 @@ Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }); | ||
function createPacketEncoderStream() { | ||
// @ts-expect-error | ||
return new TransformStream({ | ||
@@ -74,3 +75,2 @@ transform(packet, controller) { | ||
} | ||
exports.createPacketEncoderStream = createPacketEncoderStream; | ||
let TEXT_DECODER; | ||
@@ -103,6 +103,5 @@ function totalLength(chunks) { | ||
const chunks = []; | ||
let state = 0 /* READ_HEADER */; | ||
let state = 0 /* State.READ_HEADER */; | ||
let expectedLength = -1; | ||
let isBinary = false; | ||
// @ts-expect-error | ||
return new TransformStream({ | ||
@@ -112,3 +111,3 @@ transform(chunk, controller) { | ||
while (true) { | ||
if (state === 0 /* READ_HEADER */) { | ||
if (state === 0 /* State.READ_HEADER */) { | ||
if (totalLength(chunks) < 1) { | ||
@@ -121,12 +120,12 @@ break; | ||
if (expectedLength < 126) { | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
else if (expectedLength === 126) { | ||
state = 1 /* READ_EXTENDED_LENGTH_16 */; | ||
state = 1 /* State.READ_EXTENDED_LENGTH_16 */; | ||
} | ||
else { | ||
state = 2 /* READ_EXTENDED_LENGTH_64 */; | ||
state = 2 /* State.READ_EXTENDED_LENGTH_64 */; | ||
} | ||
} | ||
else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { | ||
else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { | ||
if (totalLength(chunks) < 2) { | ||
@@ -137,5 +136,5 @@ break; | ||
expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { | ||
else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { | ||
if (totalLength(chunks) < 8) { | ||
@@ -153,3 +152,3 @@ break; | ||
expectedLength = n * Math.pow(2, 32) + view.getUint32(4); | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
@@ -162,3 +161,3 @@ else { | ||
controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); | ||
state = 0 /* READ_HEADER */; | ||
state = 0 /* State.READ_HEADER */; | ||
} | ||
@@ -173,3 +172,2 @@ if (expectedLength === 0 || expectedLength > maxPayload) { | ||
} | ||
exports.createPacketDecoderStream = createPacketDecoderStream; | ||
exports.protocol = 4; |
@@ -5,4 +5,4 @@ declare const PACKET_TYPES: any; | ||
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET }; | ||
export declare type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error"; | ||
export declare type RawData = any; | ||
export type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error"; | ||
export type RawData = any; | ||
export interface Packet { | ||
@@ -15,2 +15,2 @@ type: PacketType; | ||
} | ||
export declare type BinaryType = "nodebuffer" | "arraybuffer" | "blob"; | ||
export type BinaryType = "nodebuffer" | "arraybuffer" | "blob"; |
@@ -1,11 +0,9 @@ | ||
/// <reference types="node" /> | ||
import { encodePacket } from "./encodePacket.js"; | ||
import { decodePacket } from "./decodePacket.js"; | ||
import { Packet, PacketType, RawData, BinaryType } from "./commons.js"; | ||
import type { TransformStream } from "node:stream/web"; | ||
declare const encodePayload: (packets: Packet[], callback: (encodedPayload: string) => void) => void; | ||
declare const decodePayload: (encodedPayload: string, binaryType?: BinaryType) => Packet[]; | ||
export declare function createPacketEncoderStream(): TransformStream<Packet, any>; | ||
export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>; | ||
export declare function createPacketEncoderStream(): any; | ||
export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): any; | ||
export declare const protocol = 4; | ||
export { encodePacket, encodePayload, decodePacket, decodePayload, Packet, PacketType, RawData, BinaryType, }; |
@@ -33,3 +33,2 @@ import { encodePacket, encodePacketToBinary } from "./encodePacket.js"; | ||
export function createPacketEncoderStream() { | ||
// @ts-expect-error | ||
return new TransformStream({ | ||
@@ -94,6 +93,5 @@ transform(packet, controller) { | ||
const chunks = []; | ||
let state = 0 /* READ_HEADER */; | ||
let state = 0 /* State.READ_HEADER */; | ||
let expectedLength = -1; | ||
let isBinary = false; | ||
// @ts-expect-error | ||
return new TransformStream({ | ||
@@ -103,3 +101,3 @@ transform(chunk, controller) { | ||
while (true) { | ||
if (state === 0 /* READ_HEADER */) { | ||
if (state === 0 /* State.READ_HEADER */) { | ||
if (totalLength(chunks) < 1) { | ||
@@ -112,12 +110,12 @@ break; | ||
if (expectedLength < 126) { | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
else if (expectedLength === 126) { | ||
state = 1 /* READ_EXTENDED_LENGTH_16 */; | ||
state = 1 /* State.READ_EXTENDED_LENGTH_16 */; | ||
} | ||
else { | ||
state = 2 /* READ_EXTENDED_LENGTH_64 */; | ||
state = 2 /* State.READ_EXTENDED_LENGTH_64 */; | ||
} | ||
} | ||
else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { | ||
else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { | ||
if (totalLength(chunks) < 2) { | ||
@@ -128,5 +126,5 @@ break; | ||
expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { | ||
else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { | ||
if (totalLength(chunks) < 8) { | ||
@@ -144,3 +142,3 @@ break; | ||
expectedLength = n * Math.pow(2, 32) + view.getUint32(4); | ||
state = 3 /* READ_PAYLOAD */; | ||
state = 3 /* State.READ_PAYLOAD */; | ||
} | ||
@@ -153,3 +151,3 @@ else { | ||
controller.enqueue(decodePacket(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); | ||
state = 0 /* READ_HEADER */; | ||
state = 0 /* State.READ_HEADER */; | ||
} | ||
@@ -156,0 +154,0 @@ if (expectedLength === 0 || expectedLength > maxPayload) { |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.2.2", | ||
"version": "5.2.3", | ||
"main": "./build/cjs/index.js", | ||
@@ -14,21 +14,4 @@ "module": "./build/esm/index.js", | ||
"types": "build/esm/index.d.ts", | ||
"homepage": "https://github.com/socketio/engine.io-parser", | ||
"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": "^3.2.5", | ||
"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" | ||
"prettier": "^3.3.2" | ||
}, | ||
@@ -44,6 +27,10 @@ "scripts": { | ||
}, | ||
"homepage": "https://github.com/socketio/socket.io/tree/main/packages/engine.io-parser#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:socketio/engine.io-parser.git" | ||
"url": "https://github.com/socketio/socket.io.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/socketio/socket.io/issues" | ||
}, | ||
"files": [ | ||
@@ -50,0 +37,0 @@ "build/" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
1
1
45773
969