update
This commit is contained in:
5
APP/nexus-remote/node_modules/@msgpack/msgpack/LICENSE
generated
vendored
Normal file
5
APP/nexus-remote/node_modules/@msgpack/msgpack/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
Copyright 2019 The MessagePack Community.
|
||||
|
||||
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.
|
||||
621
APP/nexus-remote/node_modules/@msgpack/msgpack/README.md
generated
vendored
Normal file
621
APP/nexus-remote/node_modules/@msgpack/msgpack/README.md
generated
vendored
Normal file
@@ -0,0 +1,621 @@
|
||||
# MessagePack for JavaScript/ECMA-262 <!-- omit in toc -->
|
||||
|
||||
[](https://www.npmjs.com/package/@msgpack/msgpack)  [](https://codecov.io/gh/msgpack/msgpack-javascript) [](https://bundlephobia.com/result?p=@msgpack/msgpack) [](https://bundlephobia.com/result?p=@msgpack/msgpack)
|
||||
|
||||
This is a JavaScript/ECMA-262 implementation of **MessagePack**, an efficient binary serilization format:
|
||||
|
||||
https://msgpack.org/
|
||||
|
||||
This library is a universal JavaScript, meaning it is compatible with all the major browsers and NodeJS. In addition, because it is implemented in [TypeScript](https://www.typescriptlang.org/), type definition files (`d.ts`) are always up-to-date and bundled in the distribution.
|
||||
|
||||
*Note that this is the second version of MessagePack for JavaScript. The first version, which was implemented in ES5 and was never released to npmjs.com, is tagged as [classic](https://github.com/msgpack/msgpack-javascript/tree/classic).*
|
||||
|
||||
## Synopsis
|
||||
|
||||
```typescript
|
||||
import { deepStrictEqual } from "assert";
|
||||
import { encode, decode } from "@msgpack/msgpack";
|
||||
|
||||
const object = {
|
||||
nil: null,
|
||||
integer: 1,
|
||||
float: Math.PI,
|
||||
string: "Hello, world!",
|
||||
binary: Uint8Array.from([1, 2, 3]),
|
||||
array: [10, 20, 30],
|
||||
map: { foo: "bar" },
|
||||
timestampExt: new Date(),
|
||||
};
|
||||
|
||||
const encoded: Uint8Array = encode(object);
|
||||
|
||||
deepStrictEqual(decode(encoded), object);
|
||||
```
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Synopsis](#synopsis)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Install](#install)
|
||||
- [API](#api)
|
||||
- [`encode(data: unknown, options?: EncodeOptions): Uint8Array`](#encodedata-unknown-options-encodeoptions-uint8array)
|
||||
- [`EncodeOptions`](#encodeoptions)
|
||||
- [`decode(buffer: ArrayLike<number> | BufferSource, options?: DecodeOptions): unknown`](#decodebuffer-arraylikenumber--buffersource-options-decodeoptions-unknown)
|
||||
- [`DecodeOptions`](#decodeoptions)
|
||||
- [`decodeMulti(buffer: ArrayLike<number> | BufferSource, options?: DecodeOptions): Generator<unknown, void, unknown>`](#decodemultibuffer-arraylikenumber--buffersource-options-decodeoptions-generatorunknown-void-unknown)
|
||||
- [`decodeAsync(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): Promise<unknown>`](#decodeasyncstream-readablestreamlikearraylikenumber--buffersource-options-decodeasyncoptions-promiseunknown)
|
||||
- [`decodeArrayStream(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`](#decodearraystreamstream-readablestreamlikearraylikenumber--buffersource-options-decodeasyncoptions-asynciterableunknown)
|
||||
- [`decodeMultiStream(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`](#decodemultistreamstream-readablestreamlikearraylikenumber--buffersource-options-decodeasyncoptions-asynciterableunknown)
|
||||
- [Reusing Encoder and Decoder instances](#reusing-encoder-and-decoder-instances)
|
||||
- [Extension Types](#extension-types)
|
||||
- [ExtensionCodec context](#extensioncodec-context)
|
||||
- [Handling BigInt with ExtensionCodec](#handling-bigint-with-extensioncodec)
|
||||
- [The temporal module as timestamp extensions](#the-temporal-module-as-timestamp-extensions)
|
||||
- [Decoding a Blob](#decoding-a-blob)
|
||||
- [MessagePack Specification](#messagepack-specification)
|
||||
- [MessagePack Mapping Table](#messagepack-mapping-table)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [ECMA-262](#ecma-262)
|
||||
- [NodeJS](#nodejs)
|
||||
- [TypeScript Compiler / Type Definitions](#typescript-compiler--type-definitions)
|
||||
- [Benchmark](#benchmark)
|
||||
- [Distribution](#distribution)
|
||||
- [NPM / npmjs.com](#npm--npmjscom)
|
||||
- [CDN / unpkg.com](#cdn--unpkgcom)
|
||||
- [Deno Support](#deno-support)
|
||||
- [Maintenance](#maintenance)
|
||||
- [Testing](#testing)
|
||||
- [Continuous Integration](#continuous-integration)
|
||||
- [Release Engineering](#release-engineering)
|
||||
- [Updating Dependencies](#updating-dependencies)
|
||||
- [License](#license)
|
||||
|
||||
## Install
|
||||
|
||||
This library is published to `npmjs.com` as [@msgpack/msgpack](https://www.npmjs.com/package/@msgpack/msgpack).
|
||||
|
||||
```shell
|
||||
npm install @msgpack/msgpack
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `encode(data: unknown, options?: EncodeOptions): Uint8Array`
|
||||
|
||||
It encodes `data` into a single MessagePack-encoded object, and returns a byte array as `Uint8Array`. It throws errors if `data` is, or includes, a non-serializable object such as a `function` or a `symbol`.
|
||||
|
||||
for example:
|
||||
|
||||
```typescript
|
||||
import { encode } from "@msgpack/msgpack";
|
||||
|
||||
const encoded: Uint8Array = encode({ foo: "bar" });
|
||||
console.log(encoded);
|
||||
```
|
||||
|
||||
If you'd like to convert an `uint8array` to a NodeJS `Buffer`, use `Buffer.from(arrayBuffer, offset, length)` in order not to copy the underlying `ArrayBuffer`, while `Buffer.from(uint8array)` copies it:
|
||||
|
||||
```typescript
|
||||
import { encode } from "@msgpack/msgpack";
|
||||
|
||||
const encoded: Uint8Array = encode({ foo: "bar" });
|
||||
|
||||
// `buffer` refers the same ArrayBuffer as `encoded`.
|
||||
const buffer: Buffer = Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
|
||||
console.log(buffer);
|
||||
```
|
||||
|
||||
#### `EncodeOptions`
|
||||
|
||||
Name|Type|Default
|
||||
----|----|----
|
||||
extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec`
|
||||
maxDepth | number | `100`
|
||||
initialBufferSize | number | `2048`
|
||||
sortKeys | boolean | false
|
||||
forceFloat32 | boolean | false
|
||||
forceIntegerToFloat | boolean | false
|
||||
ignoreUndefined | boolean | false
|
||||
context | user-defined | -
|
||||
|
||||
### `decode(buffer: ArrayLike<number> | BufferSource, options?: DecodeOptions): unknown`
|
||||
|
||||
It decodes `buffer` that includes a MessagePack-encoded object, and returns the decoded object typed `unknown`.
|
||||
|
||||
`buffer` must be an array of bytes, which is typically `Uint8Array` or `ArrayBuffer`. `BufferSource` is defined as `ArrayBuffer | ArrayBufferView`.
|
||||
|
||||
The `buffer` must include a single encoded object. If the `buffer` includes extra bytes after an object or the `buffer` is empty, it throws `RangeError`. To decode `buffer` that includes multiple encoded objects, use `decodeMulti()` or `decodeMultiStream()` (recommended) instead.
|
||||
|
||||
for example:
|
||||
|
||||
```typescript
|
||||
import { decode } from "@msgpack/msgpack";
|
||||
|
||||
const encoded: Uint8Array;
|
||||
const object = decode(encoded);
|
||||
console.log(object);
|
||||
```
|
||||
|
||||
NodeJS `Buffer` is also acceptable because it is a subclass of `Uint8Array`.
|
||||
|
||||
#### `DecodeOptions`
|
||||
|
||||
Name|Type|Default
|
||||
----|----|----
|
||||
extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec`
|
||||
maxStrLength | number | `4_294_967_295` (UINT32_MAX)
|
||||
maxBinLength | number | `4_294_967_295` (UINT32_MAX)
|
||||
maxArrayLength | number | `4_294_967_295` (UINT32_MAX)
|
||||
maxMapLength | number | `4_294_967_295` (UINT32_MAX)
|
||||
maxExtLength | number | `4_294_967_295` (UINT32_MAX)
|
||||
context | user-defined | -
|
||||
|
||||
You can use `max${Type}Length` to limit the length of each type decoded.
|
||||
|
||||
### `decodeMulti(buffer: ArrayLike<number> | BufferSource, options?: DecodeOptions): Generator<unknown, void, unknown>`
|
||||
|
||||
It decodes `buffer` that includes multiple MessagePack-encoded objects, and returns decoded objects as a generator. See also `decodeMultiStream()`, which is an asynchronous variant of this function.
|
||||
|
||||
This function is not recommended to decode a MessagePack binary via I/O stream including sockets because it's synchronous. Instead, `decodeMultiStream()` decodes a binary stream asynchronously, typically spending less CPU and memory.
|
||||
|
||||
for example:
|
||||
|
||||
```typescript
|
||||
import { decode } from "@msgpack/msgpack";
|
||||
|
||||
const encoded: Uint8Array;
|
||||
|
||||
for (const object of decodeMulti(encoded)) {
|
||||
console.log(object);
|
||||
}
|
||||
```
|
||||
|
||||
### `decodeAsync(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): Promise<unknown>`
|
||||
|
||||
It decodes `stream`, where `ReadableStreamLike<T>` is defined as `ReadableStream<T> | AsyncIterable<T>`, in an async iterable of byte arrays, and returns decoded object as `unknown` type, wrapped in `Promise`.
|
||||
|
||||
This function works asynchronously, and might CPU resources more efficiently compared with synchronous `decode()`, because it doesn't wait for the completion of downloading.
|
||||
|
||||
`DecodeAsyncOptions` is the same as `DecodeOptions` for `decode()`.
|
||||
|
||||
This function is designed to work with whatwg `fetch()` like this:
|
||||
|
||||
```typescript
|
||||
import { decodeAsync } from "@msgpack/msgpack";
|
||||
|
||||
const MSGPACK_TYPE = "application/x-msgpack";
|
||||
|
||||
const response = await fetch(url);
|
||||
const contentType = response.headers.get("Content-Type");
|
||||
if (contentType && contentType.startsWith(MSGPACK_TYPE) && response.body != null) {
|
||||
const object = await decodeAsync(response.body);
|
||||
// do something with object
|
||||
} else { /* handle errors */ }
|
||||
```
|
||||
|
||||
### `decodeArrayStream(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`
|
||||
|
||||
It is alike to `decodeAsync()`, but only accepts a `stream` that includes an array of items, and emits a decoded item one by one.
|
||||
|
||||
for example:
|
||||
|
||||
```typescript
|
||||
import { decodeArrayStream } from "@msgpack/msgpack";
|
||||
|
||||
const stream: AsyncIterator<Uint8Array>;
|
||||
|
||||
// in an async function:
|
||||
for await (const item of decodeArrayStream(stream)) {
|
||||
console.log(item);
|
||||
}
|
||||
```
|
||||
|
||||
### `decodeMultiStream(stream: ReadableStreamLike<ArrayLike<number> | BufferSource>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`
|
||||
|
||||
It is alike to `decodeAsync()` and `decodeArrayStream()`, but the input `stream` must consist of multiple MessagePack-encoded items. This is an asynchronous variant for `decodeMulti()`.
|
||||
|
||||
In other words, it could decode an unlimited stream and emits a decoded item one by one.
|
||||
|
||||
for example:
|
||||
|
||||
```typescript
|
||||
import { decodeMultiStream } from "@msgpack/msgpack";
|
||||
|
||||
const stream: AsyncIterator<Uint8Array>;
|
||||
|
||||
// in an async function:
|
||||
for await (const item of decodeMultiStream(stream)) {
|
||||
console.log(item);
|
||||
}
|
||||
```
|
||||
|
||||
This function is available since v2.4.0; previously it was called as `decodeStream()`.
|
||||
|
||||
### Reusing Encoder and Decoder instances
|
||||
|
||||
`Encoder` and `Decoder` classes is provided to have better performance by reusing instances:
|
||||
|
||||
```typescript
|
||||
import { deepStrictEqual } from "assert";
|
||||
import { Encoder, Decoder } from "@msgpack/msgpack";
|
||||
|
||||
const encoder = new Encoder();
|
||||
const decoder = new Decoder();
|
||||
|
||||
const encoded: Uint8Array = encoder.encode(object);
|
||||
deepStrictEqual(decoder.decode(encoded), object);
|
||||
```
|
||||
|
||||
According to our benchmark, reusing `Encoder` instance is about 20% faster
|
||||
than `encode()` function, and reusing `Decoder` instance is about 2% faster
|
||||
than `decode()` function. Note that the result should vary in environments
|
||||
and data structure.
|
||||
|
||||
## Extension Types
|
||||
|
||||
To handle [MessagePack Extension Types](https://github.com/msgpack/msgpack/blob/master/spec.md#extension-types), this library provides `ExtensionCodec` class.
|
||||
|
||||
This is an example to setup custom extension types that handles `Map` and `Set` classes in TypeScript:
|
||||
|
||||
```typescript
|
||||
import { encode, decode, ExtensionCodec } from "@msgpack/msgpack";
|
||||
|
||||
const extensionCodec = new ExtensionCodec();
|
||||
|
||||
// Set<T>
|
||||
const SET_EXT_TYPE = 0 // Any in 0-127
|
||||
extensionCodec.register({
|
||||
type: SET_EXT_TYPE,
|
||||
encode: (object: unknown): Uint8Array | null => {
|
||||
if (object instanceof Set) {
|
||||
return encode([...object]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
decode: (data: Uint8Array) => {
|
||||
const array = decode(data) as Array<unknown>;
|
||||
return new Set(array);
|
||||
},
|
||||
});
|
||||
|
||||
// Map<T>
|
||||
const MAP_EXT_TYPE = 1; // Any in 0-127
|
||||
extensionCodec.register({
|
||||
type: MAP_EXT_TYPE,
|
||||
encode: (object: unknown): Uint8Array => {
|
||||
if (object instanceof Map) {
|
||||
return encode([...object]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
decode: (data: Uint8Array) => {
|
||||
const array = decode(data) as Array<[unknown, unknown]>;
|
||||
return new Map(array);
|
||||
},
|
||||
});
|
||||
|
||||
const encoded = encode([new Set<any>(), new Map<any, any>()], { extensionCodec });
|
||||
const decoded = decode(encoded, { extensionCodec });
|
||||
```
|
||||
|
||||
Not that extension types for custom objects must be `[0, 127]`, while `[-1, -128]` is reserved for MessagePack itself.
|
||||
|
||||
#### ExtensionCodec context
|
||||
|
||||
When you use an extension codec, it might be necessary to have encoding/decoding state to keep track of which objects got encoded/re-created. To do this, pass a `context` to the `EncodeOptions` and `DecodeOptions`:
|
||||
|
||||
```typescript
|
||||
import { encode, decode, ExtensionCodec } from "@msgpack/msgpack";
|
||||
|
||||
class MyContext {
|
||||
track(object: any) { /*...*/ }
|
||||
}
|
||||
|
||||
class MyType { /* ... */ }
|
||||
|
||||
const extensionCodec = new ExtensionCodec<MyContext>();
|
||||
|
||||
// MyType
|
||||
const MYTYPE_EXT_TYPE = 0 // Any in 0-127
|
||||
extensionCodec.register({
|
||||
type: MYTYPE_EXT_TYPE,
|
||||
encode: (object, context) => {
|
||||
if (object instanceof MyType) {
|
||||
context.track(object); // <-- like this
|
||||
return encode(object.toJSON(), { extensionCodec, context });
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
decode: (data, extType, context) => {
|
||||
const decoded = decode(data, { extensionCodec, context });
|
||||
const my = new MyType(decoded);
|
||||
context.track(my); // <-- and like this
|
||||
return my;
|
||||
},
|
||||
});
|
||||
|
||||
// and later
|
||||
import { encode, decode } from "@msgpack/msgpack";
|
||||
|
||||
const context = new MyContext();
|
||||
|
||||
const encoded = = encode({myType: new MyType<any>()}, { extensionCodec, context });
|
||||
const decoded = decode(encoded, { extensionCodec, context });
|
||||
```
|
||||
|
||||
#### Handling BigInt with ExtensionCodec
|
||||
|
||||
This library does not handle BigInt by default, but you can handle it with `ExtensionCodec` like this:
|
||||
|
||||
```typescript
|
||||
import { deepStrictEqual } from "assert";
|
||||
import { encode, decode, ExtensionCodec } from "@msgpack/msgpack";
|
||||
|
||||
const BIGINT_EXT_TYPE = 0; // Any in 0-127
|
||||
const extensionCodec = new ExtensionCodec();
|
||||
extensionCodec.register({
|
||||
type: BIGINT_EXT_TYPE,
|
||||
encode: (input: unknown) => {
|
||||
if (typeof input === "bigint") {
|
||||
if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
|
||||
return encode(parseInt(input.toString(), 10));
|
||||
} else {
|
||||
return encode(input.toString());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
decode: (data: Uint8Array) => {
|
||||
return BigInt(decode(data));
|
||||
},
|
||||
});
|
||||
|
||||
const value = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1);
|
||||
const encoded: = encode(value, { extensionCodec });
|
||||
deepStrictEqual(decode(encoded, { extensionCodec }), value);
|
||||
```
|
||||
|
||||
#### The temporal module as timestamp extensions
|
||||
|
||||
There is a proposal for a new date/time representations in JavaScript:
|
||||
|
||||
* https://github.com/tc39/proposal-temporal
|
||||
|
||||
This library maps `Date` to the MessagePack timestamp extension by default, but you can re-map the temporal module (or [Temporal Polyfill](https://github.com/tc39/proposal-temporal/tree/main/polyfill)) to the timestamp extension like this:
|
||||
|
||||
```typescript
|
||||
import { Instant } from "@std-proposal/temporal";
|
||||
import { deepStrictEqual } from "assert";
|
||||
import {
|
||||
encode,
|
||||
decode,
|
||||
ExtensionCodec,
|
||||
EXT_TIMESTAMP,
|
||||
encodeTimeSpecToTimestamp,
|
||||
decodeTimestampToTimeSpec,
|
||||
} from "@msgpack/msgpack";
|
||||
|
||||
const extensionCodec = new ExtensionCodec();
|
||||
extensionCodec.register({
|
||||
type: EXT_TIMESTAMP, // override the default behavior!
|
||||
encode: (input: any) => {
|
||||
if (input instanceof Instant) {
|
||||
const sec = input.seconds;
|
||||
const nsec = Number(input.nanoseconds - BigInt(sec) * BigInt(1e9));
|
||||
return encodeTimeSpecToTimestamp({ sec, nsec });
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
decode: (data: Uint8Array) => {
|
||||
const timeSpec = decodeTimestampToTimeSpec(data);
|
||||
const sec = BigInt(timeSpec.sec);
|
||||
const nsec = BigInt(timeSpec.nsec);
|
||||
return Instant.fromEpochNanoseconds(sec * BigInt(1e9) + nsec);
|
||||
},
|
||||
});
|
||||
|
||||
const instant = Instant.fromEpochMilliseconds(Date.now());
|
||||
const encoded = encode(instant, { extensionCodec });
|
||||
const decoded = decode(encoded, { extensionCodec });
|
||||
deepStrictEqual(decoded, instant);
|
||||
```
|
||||
|
||||
This will become default in this library with major-version increment, if the temporal module is standardized.
|
||||
|
||||
## Decoding a Blob
|
||||
|
||||
[`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) is a binary data container provided by browsers. To read its contents, you can use `Blob#arrayBuffer()` or `Blob#stream()`. `Blob#stream()`
|
||||
is recommended if your target platform support it. This is because streaming
|
||||
decode should be faster for large objects. In both ways, you need to use
|
||||
asynchronous API.
|
||||
|
||||
```typescript
|
||||
async function decodeFromBlob(blob: Blob): unknown {
|
||||
if (blob.stream) {
|
||||
// Blob#stream(): ReadableStream<Uint8Array> (recommended)
|
||||
return await decodeAsync(blob.stream());
|
||||
} else {
|
||||
// Blob#arrayBuffer(): Promise<ArrayBuffer> (if stream() is not available)
|
||||
return decode(await blob.arrayBuffer());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## MessagePack Specification
|
||||
|
||||
This library is compatible with the "August 2017" revision of MessagePack specification at the point where timestamp ext was added:
|
||||
|
||||
* [x] str/bin separation, added at August 2013
|
||||
* [x] extension types, added at August 2013
|
||||
* [x] timestamp ext type, added at August 2017
|
||||
|
||||
The living specification is here:
|
||||
|
||||
https://github.com/msgpack/msgpack
|
||||
|
||||
Note that as of June 2019 there're no official "version" on the MessagePack specification. See https://github.com/msgpack/msgpack/issues/195 for the discussions.
|
||||
|
||||
### MessagePack Mapping Table
|
||||
|
||||
The following table shows how JavaScript values are mapped to [MessagePack formats](https://github.com/msgpack/msgpack/blob/master/spec.md) and vice versa.
|
||||
|
||||
Source Value|MessagePack Format|Value Decoded
|
||||
----|----|----
|
||||
null, undefined|nil|null (*1)
|
||||
boolean (true, false)|bool family|boolean (true, false)
|
||||
number (53-bit int)|int family|number (53-bit int)
|
||||
number (64-bit float)|float family|number (64-bit float)
|
||||
string|str family|string
|
||||
ArrayBufferView |bin family|Uint8Array (*2)
|
||||
Array|array family|Array
|
||||
Object|map family|Object (*3)
|
||||
Date|timestamp ext family|Date (*4)
|
||||
|
||||
* *1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
|
||||
* *2 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
|
||||
* *3 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
|
||||
* *4 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This is a universal JavaScript library that supports major browsers and NodeJS.
|
||||
|
||||
### ECMA-262
|
||||
|
||||
* ES5 language features
|
||||
* ES2018 standard library, including:
|
||||
* Typed arrays (ES2015)
|
||||
* Async iterations (ES2018)
|
||||
* Features added in ES2015-ES2018
|
||||
|
||||
ES2018 standard library used in this library can be polyfilled with [core-js](https://github.com/zloirock/core-js).
|
||||
|
||||
If you support IE11, import `core-js` in your application entrypoints, as this library does in testing for browsers.
|
||||
|
||||
### NodeJS
|
||||
|
||||
NodeJS v10 is required, but NodeJS v12 or later is recommended because it includes the V8 feature of [Improving DataView performance in V8](https://v8.dev/blog/dataview).
|
||||
|
||||
NodeJS before v10 will work by importing `@msgpack/msgpack/dist.es5+umd/msgpack`.
|
||||
|
||||
### TypeScript Compiler / Type Definitions
|
||||
|
||||
This module requires type definitions of `AsyncIterator`, `SourceBuffer`, whatwg streams, and so on. They are provided by `"lib": ["ES2021", "DOM"]` in `tsconfig.json`.
|
||||
|
||||
Regarding the TypeScript compiler version, only the latest TypeScript is tested in development.
|
||||
|
||||
## Benchmark
|
||||
|
||||
Run-time performance is not the only reason to use MessagePack, but it's important to choose MessagePack libraries, so a benchmark suite is provided to monitor the performance of this library.
|
||||
|
||||
V8's built-in JSON has been improved for years, esp. `JSON.parse()` is [significantly improved in V8/7.6](https://v8.dev/blog/v8-release-76), it is the fastest deserializer as of 2019, as the benchmark result bellow suggests.
|
||||
|
||||
However, MessagePack can handles binary data effectively, actual performance depends on situations. You'd better take benchmark on your own use-case if performance matters.
|
||||
|
||||
Benchmark on NodeJS/v18.1.0 (V8/10.1)
|
||||
|
||||
operation | op | ms | op/s
|
||||
----------------------------------------------------------------- | ------: | ----: | ------:
|
||||
buf = Buffer.from(JSON.stringify(obj)); | 902100 | 5000 | 180420
|
||||
obj = JSON.parse(buf.toString("utf-8")); | 898700 | 5000 | 179740
|
||||
buf = require("msgpack-lite").encode(obj); | 411000 | 5000 | 82200
|
||||
obj = require("msgpack-lite").decode(buf); | 246200 | 5001 | 49230
|
||||
buf = require("@msgpack/msgpack").encode(obj); | 843300 | 5000 | 168660
|
||||
obj = require("@msgpack/msgpack").decode(buf); | 489300 | 5000 | 97860
|
||||
buf = /* @msgpack/msgpack */ encoder.encode(obj); | 1154200 | 5000 | 230840
|
||||
obj = /* @msgpack/msgpack */ decoder.decode(buf); | 448900 | 5000 | 89780
|
||||
|
||||
Note that `JSON` cases use `Buffer` to emulate I/O where a JavaScript string must be converted into a byte array encoded in UTF-8, whereas MessagePack modules deal with byte arrays.
|
||||
|
||||
## Distribution
|
||||
|
||||
### NPM / npmjs.com
|
||||
|
||||
The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:
|
||||
|
||||
* `dist/` is compiled into ES2019 with CommomJS, provided for NodeJS v10
|
||||
* `dist.es5+umd/` is compiled into ES5 with UMD
|
||||
* `dist.es5+umd/msgpack.min.js` - the minified file
|
||||
* `dist.es5+umd/msgpack.js` - the non-minified file
|
||||
* `dist.es5+esm/` is compiled into ES5 with ES modules, provided for webpack-like bundlers and NodeJS's ESM-mode
|
||||
|
||||
If you use NodeJS and/or webpack, their module resolvers use the suitable one automatically.
|
||||
|
||||
### CDN / unpkg.com
|
||||
|
||||
This library is available via CDN:
|
||||
|
||||
```html
|
||||
<script crossorigin src="https://unpkg.com/@msgpack/msgpack"></script>
|
||||
```
|
||||
|
||||
It loads `MessagePack` module to the global object.
|
||||
|
||||
|
||||
## Deno Support
|
||||
|
||||
You can use this module on Deno.
|
||||
|
||||
See `example/deno-*.ts` for examples.
|
||||
|
||||
`deno.land/x` is not supported yet.
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Testing
|
||||
|
||||
For simple testing:
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
### Continuous Integration
|
||||
|
||||
This library uses Travis CI.
|
||||
|
||||
test matrix:
|
||||
|
||||
* TypeScript targets
|
||||
* `target=es2019` / `target=es5`
|
||||
* JavaScript engines
|
||||
* NodeJS, browsers (Chrome, Firefox, Safari, IE11, and so on)
|
||||
|
||||
See [test:* in package.json](./package.json) and [.travis.yml](./.travis.yml) for details.
|
||||
|
||||
### Release Engineering
|
||||
|
||||
```console
|
||||
# run tests on NodeJS, Chrome, and Firefox
|
||||
make test-all
|
||||
|
||||
# edit the changelog
|
||||
code CHANGELOG.md
|
||||
|
||||
# bump version
|
||||
npm version patch|minor|major
|
||||
|
||||
# run the publishing task
|
||||
make publish
|
||||
```
|
||||
|
||||
### Updating Dependencies
|
||||
|
||||
```console
|
||||
npm run update-dependencies
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2019 The MessagePack community.
|
||||
|
||||
This software uses the ISC license:
|
||||
|
||||
https://opensource.org/licenses/ISC
|
||||
|
||||
See [LICENSE](./LICENSE) for details.
|
||||
64
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/CachedKeyDecoder.mjs
generated
vendored
Normal file
64
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/CachedKeyDecoder.mjs
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import { utf8DecodeJs } from "./utils/utf8.mjs";
|
||||
var DEFAULT_MAX_KEY_LENGTH = 16;
|
||||
var DEFAULT_MAX_LENGTH_PER_KEY = 16;
|
||||
var CachedKeyDecoder = /** @class */ (function () {
|
||||
function CachedKeyDecoder(maxKeyLength, maxLengthPerKey) {
|
||||
if (maxKeyLength === void 0) { maxKeyLength = DEFAULT_MAX_KEY_LENGTH; }
|
||||
if (maxLengthPerKey === void 0) { maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY; }
|
||||
this.maxKeyLength = maxKeyLength;
|
||||
this.maxLengthPerKey = maxLengthPerKey;
|
||||
this.hit = 0;
|
||||
this.miss = 0;
|
||||
// avoid `new Array(N)`, which makes a sparse array,
|
||||
// because a sparse array is typically slower than a non-sparse array.
|
||||
this.caches = [];
|
||||
for (var i = 0; i < this.maxKeyLength; i++) {
|
||||
this.caches.push([]);
|
||||
}
|
||||
}
|
||||
CachedKeyDecoder.prototype.canBeCached = function (byteLength) {
|
||||
return byteLength > 0 && byteLength <= this.maxKeyLength;
|
||||
};
|
||||
CachedKeyDecoder.prototype.find = function (bytes, inputOffset, byteLength) {
|
||||
var records = this.caches[byteLength - 1];
|
||||
FIND_CHUNK: for (var _i = 0, records_1 = records; _i < records_1.length; _i++) {
|
||||
var record = records_1[_i];
|
||||
var recordBytes = record.bytes;
|
||||
for (var j = 0; j < byteLength; j++) {
|
||||
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
||||
continue FIND_CHUNK;
|
||||
}
|
||||
}
|
||||
return record.str;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
CachedKeyDecoder.prototype.store = function (bytes, value) {
|
||||
var records = this.caches[bytes.length - 1];
|
||||
var record = { bytes: bytes, str: value };
|
||||
if (records.length >= this.maxLengthPerKey) {
|
||||
// `records` are full!
|
||||
// Set `record` to an arbitrary position.
|
||||
records[(Math.random() * records.length) | 0] = record;
|
||||
}
|
||||
else {
|
||||
records.push(record);
|
||||
}
|
||||
};
|
||||
CachedKeyDecoder.prototype.decode = function (bytes, inputOffset, byteLength) {
|
||||
var cachedValue = this.find(bytes, inputOffset, byteLength);
|
||||
if (cachedValue != null) {
|
||||
this.hit++;
|
||||
return cachedValue;
|
||||
}
|
||||
this.miss++;
|
||||
var str = utf8DecodeJs(bytes, inputOffset, byteLength);
|
||||
// Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer.
|
||||
var slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
|
||||
this.store(slicedCopyOfBytes, str);
|
||||
return str;
|
||||
};
|
||||
return CachedKeyDecoder;
|
||||
}());
|
||||
export { CachedKeyDecoder };
|
||||
//# sourceMappingURL=CachedKeyDecoder.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/CachedKeyDecoder.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/CachedKeyDecoder.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CachedKeyDecoder.mjs","sourceRoot":"","sources":["../src/CachedKeyDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,IAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,IAAM,0BAA0B,GAAG,EAAE,CAAC;AAWtC;IAKE,0BAAqB,YAAqC,EAAW,eAA4C;QAA5F,6BAAA,EAAA,qCAAqC;QAAW,gCAAA,EAAA,4CAA4C;QAA5F,iBAAY,GAAZ,YAAY,CAAyB;QAAW,oBAAe,GAAf,eAAe,CAA6B;QAJjH,QAAG,GAAG,CAAC,CAAC;QACR,SAAI,GAAG,CAAC,CAAC;QAIP,oDAAoD;QACpD,sEAAsE;QACtE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACtB;IACH,CAAC;IAEM,sCAAW,GAAlB,UAAmB,UAAkB;QACnC,OAAO,UAAU,GAAG,CAAC,IAAI,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC;IAC3D,CAAC;IAEO,+BAAI,GAAZ,UAAa,KAAiB,EAAE,WAAmB,EAAE,UAAkB;QACrE,IAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAE,CAAC;QAE7C,UAAU,EAAE,KAAqB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;YAAzB,IAAM,MAAM,gBAAA;YAC3B,IAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;YAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;gBACnC,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;oBAC7C,SAAS,UAAU,CAAC;iBACrB;aACF;YACD,OAAO,MAAM,CAAC,GAAG,CAAC;SACnB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,gCAAK,GAAb,UAAc,KAAiB,EAAE,KAAa;QAC5C,IAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;QAC/C,IAAM,MAAM,GAAmB,EAAE,KAAK,OAAA,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAErD,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,eAAe,EAAE;YAC1C,sBAAsB;YACtB,yCAAyC;YACzC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;SACxD;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACtB;IACH,CAAC;IAEM,iCAAM,GAAb,UAAc,KAAiB,EAAE,WAAmB,EAAE,UAAkB;QACtE,IAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,WAAW,CAAC;SACpB;QACD,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,IAAM,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACzD,4IAA4I;QAC5I,IAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC;QACxG,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uBAAC;AAAD,CAAC,AA7DD,IA6DC"}
|
||||
33
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/DecodeError.mjs
generated
vendored
Normal file
33
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/DecodeError.mjs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var DecodeError = /** @class */ (function (_super) {
|
||||
__extends(DecodeError, _super);
|
||||
function DecodeError(message) {
|
||||
var _this = _super.call(this, message) || this;
|
||||
// fix the prototype chain in a cross-platform way
|
||||
var proto = Object.create(DecodeError.prototype);
|
||||
Object.setPrototypeOf(_this, proto);
|
||||
Object.defineProperty(_this, "name", {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: DecodeError.name,
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
return DecodeError;
|
||||
}(Error));
|
||||
export { DecodeError };
|
||||
//# sourceMappingURL=DecodeError.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/DecodeError.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/DecodeError.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DecodeError.mjs","sourceRoot":"","sources":["../src/DecodeError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;IAAiC,+BAAK;IACpC,qBAAY,OAAe;QAA3B,YACE,kBAAM,OAAO,CAAC,SAWf;QATC,kDAAkD;QAClD,IAAM,KAAK,GAAiC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACjF,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,KAAK,CAAC,CAAC;QAEnC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,MAAM,EAAE;YAClC,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,WAAW,CAAC,IAAI;SACxB,CAAC,CAAC;;IACL,CAAC;IACH,kBAAC;AAAD,CAAC,AAdD,CAAiC,KAAK,GAcrC"}
|
||||
734
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Decoder.mjs
generated
vendored
Normal file
734
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Decoder.mjs
generated
vendored
Normal file
@@ -0,0 +1,734 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
import { prettyByte } from "./utils/prettyByte.mjs";
|
||||
import { ExtensionCodec } from "./ExtensionCodec.mjs";
|
||||
import { getInt64, getUint64, UINT32_MAX } from "./utils/int.mjs";
|
||||
import { utf8DecodeJs, TEXT_DECODER_THRESHOLD, utf8DecodeTD } from "./utils/utf8.mjs";
|
||||
import { createDataView, ensureUint8Array } from "./utils/typedArrays.mjs";
|
||||
import { CachedKeyDecoder } from "./CachedKeyDecoder.mjs";
|
||||
import { DecodeError } from "./DecodeError.mjs";
|
||||
var isValidMapKeyType = function (key) {
|
||||
var keyType = typeof key;
|
||||
return keyType === "string" || keyType === "number";
|
||||
};
|
||||
var HEAD_BYTE_REQUIRED = -1;
|
||||
var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
||||
var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
||||
// IE11: Hack to support IE11.
|
||||
// IE11: Drop this hack and just use RangeError when IE11 is obsolete.
|
||||
export var DataViewIndexOutOfBoundsError = (function () {
|
||||
try {
|
||||
// IE11: The spec says it should throw RangeError,
|
||||
// IE11: but in IE11 it throws TypeError.
|
||||
EMPTY_VIEW.getInt8(0);
|
||||
}
|
||||
catch (e) {
|
||||
return e.constructor;
|
||||
}
|
||||
throw new Error("never reached");
|
||||
})();
|
||||
var MORE_DATA = new DataViewIndexOutOfBoundsError("Insufficient data");
|
||||
var sharedCachedKeyDecoder = new CachedKeyDecoder();
|
||||
var Decoder = /** @class */ (function () {
|
||||
function Decoder(extensionCodec, context, maxStrLength, maxBinLength, maxArrayLength, maxMapLength, maxExtLength, keyDecoder) {
|
||||
if (extensionCodec === void 0) { extensionCodec = ExtensionCodec.defaultCodec; }
|
||||
if (context === void 0) { context = undefined; }
|
||||
if (maxStrLength === void 0) { maxStrLength = UINT32_MAX; }
|
||||
if (maxBinLength === void 0) { maxBinLength = UINT32_MAX; }
|
||||
if (maxArrayLength === void 0) { maxArrayLength = UINT32_MAX; }
|
||||
if (maxMapLength === void 0) { maxMapLength = UINT32_MAX; }
|
||||
if (maxExtLength === void 0) { maxExtLength = UINT32_MAX; }
|
||||
if (keyDecoder === void 0) { keyDecoder = sharedCachedKeyDecoder; }
|
||||
this.extensionCodec = extensionCodec;
|
||||
this.context = context;
|
||||
this.maxStrLength = maxStrLength;
|
||||
this.maxBinLength = maxBinLength;
|
||||
this.maxArrayLength = maxArrayLength;
|
||||
this.maxMapLength = maxMapLength;
|
||||
this.maxExtLength = maxExtLength;
|
||||
this.keyDecoder = keyDecoder;
|
||||
this.totalPos = 0;
|
||||
this.pos = 0;
|
||||
this.view = EMPTY_VIEW;
|
||||
this.bytes = EMPTY_BYTES;
|
||||
this.headByte = HEAD_BYTE_REQUIRED;
|
||||
this.stack = [];
|
||||
}
|
||||
Decoder.prototype.reinitializeState = function () {
|
||||
this.totalPos = 0;
|
||||
this.headByte = HEAD_BYTE_REQUIRED;
|
||||
this.stack.length = 0;
|
||||
// view, bytes, and pos will be re-initialized in setBuffer()
|
||||
};
|
||||
Decoder.prototype.setBuffer = function (buffer) {
|
||||
this.bytes = ensureUint8Array(buffer);
|
||||
this.view = createDataView(this.bytes);
|
||||
this.pos = 0;
|
||||
};
|
||||
Decoder.prototype.appendBuffer = function (buffer) {
|
||||
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
||||
this.setBuffer(buffer);
|
||||
}
|
||||
else {
|
||||
var remainingData = this.bytes.subarray(this.pos);
|
||||
var newData = ensureUint8Array(buffer);
|
||||
// concat remainingData + newData
|
||||
var newBuffer = new Uint8Array(remainingData.length + newData.length);
|
||||
newBuffer.set(remainingData);
|
||||
newBuffer.set(newData, remainingData.length);
|
||||
this.setBuffer(newBuffer);
|
||||
}
|
||||
};
|
||||
Decoder.prototype.hasRemaining = function (size) {
|
||||
return this.view.byteLength - this.pos >= size;
|
||||
};
|
||||
Decoder.prototype.createExtraByteError = function (posToShow) {
|
||||
var _a = this, view = _a.view, pos = _a.pos;
|
||||
return new RangeError("Extra ".concat(view.byteLength - pos, " of ").concat(view.byteLength, " byte(s) found at buffer[").concat(posToShow, "]"));
|
||||
};
|
||||
/**
|
||||
* @throws {@link DecodeError}
|
||||
* @throws {@link RangeError}
|
||||
*/
|
||||
Decoder.prototype.decode = function (buffer) {
|
||||
this.reinitializeState();
|
||||
this.setBuffer(buffer);
|
||||
var object = this.doDecodeSync();
|
||||
if (this.hasRemaining(1)) {
|
||||
throw this.createExtraByteError(this.pos);
|
||||
}
|
||||
return object;
|
||||
};
|
||||
Decoder.prototype.decodeMulti = function (buffer) {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this.reinitializeState();
|
||||
this.setBuffer(buffer);
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
if (!this.hasRemaining(1)) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, this.doDecodeSync()];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [3 /*break*/, 1];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
};
|
||||
Decoder.prototype.decodeAsync = function (stream) {
|
||||
var stream_1, stream_1_1;
|
||||
var e_1, _a;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var decoded, object, buffer, e_1_1, _b, headByte, pos, totalPos;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
decoded = false;
|
||||
_c.label = 1;
|
||||
case 1:
|
||||
_c.trys.push([1, 6, 7, 12]);
|
||||
stream_1 = __asyncValues(stream);
|
||||
_c.label = 2;
|
||||
case 2: return [4 /*yield*/, stream_1.next()];
|
||||
case 3:
|
||||
if (!(stream_1_1 = _c.sent(), !stream_1_1.done)) return [3 /*break*/, 5];
|
||||
buffer = stream_1_1.value;
|
||||
if (decoded) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
this.appendBuffer(buffer);
|
||||
try {
|
||||
object = this.doDecodeSync();
|
||||
decoded = true;
|
||||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof DataViewIndexOutOfBoundsError)) {
|
||||
throw e; // rethrow
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
this.totalPos += this.pos;
|
||||
_c.label = 4;
|
||||
case 4: return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
e_1_1 = _c.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 12];
|
||||
case 7:
|
||||
_c.trys.push([7, , 10, 11]);
|
||||
if (!(stream_1_1 && !stream_1_1.done && (_a = stream_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, _a.call(stream_1)];
|
||||
case 8:
|
||||
_c.sent();
|
||||
_c.label = 9;
|
||||
case 9: return [3 /*break*/, 11];
|
||||
case 10:
|
||||
if (e_1) throw e_1.error;
|
||||
return [7 /*endfinally*/];
|
||||
case 11: return [7 /*endfinally*/];
|
||||
case 12:
|
||||
if (decoded) {
|
||||
if (this.hasRemaining(1)) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
return [2 /*return*/, object];
|
||||
}
|
||||
_b = this, headByte = _b.headByte, pos = _b.pos, totalPos = _b.totalPos;
|
||||
throw new RangeError("Insufficient data in parsing ".concat(prettyByte(headByte), " at ").concat(totalPos, " (").concat(pos, " in the current buffer)"));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Decoder.prototype.decodeArrayStream = function (stream) {
|
||||
return this.decodeMultiAsync(stream, true);
|
||||
};
|
||||
Decoder.prototype.decodeStream = function (stream) {
|
||||
return this.decodeMultiAsync(stream, false);
|
||||
};
|
||||
Decoder.prototype.decodeMultiAsync = function (stream, isArray) {
|
||||
return __asyncGenerator(this, arguments, function decodeMultiAsync_1() {
|
||||
var isArrayHeaderRequired, arrayItemsLeft, stream_2, stream_2_1, buffer, e_2, e_3_1;
|
||||
var e_3, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
isArrayHeaderRequired = isArray;
|
||||
arrayItemsLeft = -1;
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 13, 14, 19]);
|
||||
stream_2 = __asyncValues(stream);
|
||||
_b.label = 2;
|
||||
case 2: return [4 /*yield*/, __await(stream_2.next())];
|
||||
case 3:
|
||||
if (!(stream_2_1 = _b.sent(), !stream_2_1.done)) return [3 /*break*/, 12];
|
||||
buffer = stream_2_1.value;
|
||||
if (isArray && arrayItemsLeft === 0) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
this.appendBuffer(buffer);
|
||||
if (isArrayHeaderRequired) {
|
||||
arrayItemsLeft = this.readArraySize();
|
||||
isArrayHeaderRequired = false;
|
||||
this.complete();
|
||||
}
|
||||
_b.label = 4;
|
||||
case 4:
|
||||
_b.trys.push([4, 9, , 10]);
|
||||
_b.label = 5;
|
||||
case 5:
|
||||
if (!true) return [3 /*break*/, 8];
|
||||
return [4 /*yield*/, __await(this.doDecodeSync())];
|
||||
case 6: return [4 /*yield*/, _b.sent()];
|
||||
case 7:
|
||||
_b.sent();
|
||||
if (--arrayItemsLeft === 0) {
|
||||
return [3 /*break*/, 8];
|
||||
}
|
||||
return [3 /*break*/, 5];
|
||||
case 8: return [3 /*break*/, 10];
|
||||
case 9:
|
||||
e_2 = _b.sent();
|
||||
if (!(e_2 instanceof DataViewIndexOutOfBoundsError)) {
|
||||
throw e_2; // rethrow
|
||||
}
|
||||
return [3 /*break*/, 10];
|
||||
case 10:
|
||||
this.totalPos += this.pos;
|
||||
_b.label = 11;
|
||||
case 11: return [3 /*break*/, 2];
|
||||
case 12: return [3 /*break*/, 19];
|
||||
case 13:
|
||||
e_3_1 = _b.sent();
|
||||
e_3 = { error: e_3_1 };
|
||||
return [3 /*break*/, 19];
|
||||
case 14:
|
||||
_b.trys.push([14, , 17, 18]);
|
||||
if (!(stream_2_1 && !stream_2_1.done && (_a = stream_2.return))) return [3 /*break*/, 16];
|
||||
return [4 /*yield*/, __await(_a.call(stream_2))];
|
||||
case 15:
|
||||
_b.sent();
|
||||
_b.label = 16;
|
||||
case 16: return [3 /*break*/, 18];
|
||||
case 17:
|
||||
if (e_3) throw e_3.error;
|
||||
return [7 /*endfinally*/];
|
||||
case 18: return [7 /*endfinally*/];
|
||||
case 19: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Decoder.prototype.doDecodeSync = function () {
|
||||
DECODE: while (true) {
|
||||
var headByte = this.readHeadByte();
|
||||
var object = void 0;
|
||||
if (headByte >= 0xe0) {
|
||||
// negative fixint (111x xxxx) 0xe0 - 0xff
|
||||
object = headByte - 0x100;
|
||||
}
|
||||
else if (headByte < 0xc0) {
|
||||
if (headByte < 0x80) {
|
||||
// positive fixint (0xxx xxxx) 0x00 - 0x7f
|
||||
object = headByte;
|
||||
}
|
||||
else if (headByte < 0x90) {
|
||||
// fixmap (1000 xxxx) 0x80 - 0x8f
|
||||
var size = headByte - 0x80;
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = {};
|
||||
}
|
||||
}
|
||||
else if (headByte < 0xa0) {
|
||||
// fixarray (1001 xxxx) 0x90 - 0x9f
|
||||
var size = headByte - 0x90;
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = [];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// fixstr (101x xxxx) 0xa0 - 0xbf
|
||||
var byteLength = headByte - 0xa0;
|
||||
object = this.decodeUtf8String(byteLength, 0);
|
||||
}
|
||||
}
|
||||
else if (headByte === 0xc0) {
|
||||
// nil
|
||||
object = null;
|
||||
}
|
||||
else if (headByte === 0xc2) {
|
||||
// false
|
||||
object = false;
|
||||
}
|
||||
else if (headByte === 0xc3) {
|
||||
// true
|
||||
object = true;
|
||||
}
|
||||
else if (headByte === 0xca) {
|
||||
// float 32
|
||||
object = this.readF32();
|
||||
}
|
||||
else if (headByte === 0xcb) {
|
||||
// float 64
|
||||
object = this.readF64();
|
||||
}
|
||||
else if (headByte === 0xcc) {
|
||||
// uint 8
|
||||
object = this.readU8();
|
||||
}
|
||||
else if (headByte === 0xcd) {
|
||||
// uint 16
|
||||
object = this.readU16();
|
||||
}
|
||||
else if (headByte === 0xce) {
|
||||
// uint 32
|
||||
object = this.readU32();
|
||||
}
|
||||
else if (headByte === 0xcf) {
|
||||
// uint 64
|
||||
object = this.readU64();
|
||||
}
|
||||
else if (headByte === 0xd0) {
|
||||
// int 8
|
||||
object = this.readI8();
|
||||
}
|
||||
else if (headByte === 0xd1) {
|
||||
// int 16
|
||||
object = this.readI16();
|
||||
}
|
||||
else if (headByte === 0xd2) {
|
||||
// int 32
|
||||
object = this.readI32();
|
||||
}
|
||||
else if (headByte === 0xd3) {
|
||||
// int 64
|
||||
object = this.readI64();
|
||||
}
|
||||
else if (headByte === 0xd9) {
|
||||
// str 8
|
||||
var byteLength = this.lookU8();
|
||||
object = this.decodeUtf8String(byteLength, 1);
|
||||
}
|
||||
else if (headByte === 0xda) {
|
||||
// str 16
|
||||
var byteLength = this.lookU16();
|
||||
object = this.decodeUtf8String(byteLength, 2);
|
||||
}
|
||||
else if (headByte === 0xdb) {
|
||||
// str 32
|
||||
var byteLength = this.lookU32();
|
||||
object = this.decodeUtf8String(byteLength, 4);
|
||||
}
|
||||
else if (headByte === 0xdc) {
|
||||
// array 16
|
||||
var size = this.readU16();
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = [];
|
||||
}
|
||||
}
|
||||
else if (headByte === 0xdd) {
|
||||
// array 32
|
||||
var size = this.readU32();
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = [];
|
||||
}
|
||||
}
|
||||
else if (headByte === 0xde) {
|
||||
// map 16
|
||||
var size = this.readU16();
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = {};
|
||||
}
|
||||
}
|
||||
else if (headByte === 0xdf) {
|
||||
// map 32
|
||||
var size = this.readU32();
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
object = {};
|
||||
}
|
||||
}
|
||||
else if (headByte === 0xc4) {
|
||||
// bin 8
|
||||
var size = this.lookU8();
|
||||
object = this.decodeBinary(size, 1);
|
||||
}
|
||||
else if (headByte === 0xc5) {
|
||||
// bin 16
|
||||
var size = this.lookU16();
|
||||
object = this.decodeBinary(size, 2);
|
||||
}
|
||||
else if (headByte === 0xc6) {
|
||||
// bin 32
|
||||
var size = this.lookU32();
|
||||
object = this.decodeBinary(size, 4);
|
||||
}
|
||||
else if (headByte === 0xd4) {
|
||||
// fixext 1
|
||||
object = this.decodeExtension(1, 0);
|
||||
}
|
||||
else if (headByte === 0xd5) {
|
||||
// fixext 2
|
||||
object = this.decodeExtension(2, 0);
|
||||
}
|
||||
else if (headByte === 0xd6) {
|
||||
// fixext 4
|
||||
object = this.decodeExtension(4, 0);
|
||||
}
|
||||
else if (headByte === 0xd7) {
|
||||
// fixext 8
|
||||
object = this.decodeExtension(8, 0);
|
||||
}
|
||||
else if (headByte === 0xd8) {
|
||||
// fixext 16
|
||||
object = this.decodeExtension(16, 0);
|
||||
}
|
||||
else if (headByte === 0xc7) {
|
||||
// ext 8
|
||||
var size = this.lookU8();
|
||||
object = this.decodeExtension(size, 1);
|
||||
}
|
||||
else if (headByte === 0xc8) {
|
||||
// ext 16
|
||||
var size = this.lookU16();
|
||||
object = this.decodeExtension(size, 2);
|
||||
}
|
||||
else if (headByte === 0xc9) {
|
||||
// ext 32
|
||||
var size = this.lookU32();
|
||||
object = this.decodeExtension(size, 4);
|
||||
}
|
||||
else {
|
||||
throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(headByte)));
|
||||
}
|
||||
this.complete();
|
||||
var stack = this.stack;
|
||||
while (stack.length > 0) {
|
||||
// arrays and maps
|
||||
var state = stack[stack.length - 1];
|
||||
if (state.type === 0 /* State.ARRAY */) {
|
||||
state.array[state.position] = object;
|
||||
state.position++;
|
||||
if (state.position === state.size) {
|
||||
stack.pop();
|
||||
object = state.array;
|
||||
}
|
||||
else {
|
||||
continue DECODE;
|
||||
}
|
||||
}
|
||||
else if (state.type === 1 /* State.MAP_KEY */) {
|
||||
if (!isValidMapKeyType(object)) {
|
||||
throw new DecodeError("The type of key must be string or number but " + typeof object);
|
||||
}
|
||||
if (object === "__proto__") {
|
||||
throw new DecodeError("The key __proto__ is not allowed");
|
||||
}
|
||||
state.key = object;
|
||||
state.type = 2 /* State.MAP_VALUE */;
|
||||
continue DECODE;
|
||||
}
|
||||
else {
|
||||
// it must be `state.type === State.MAP_VALUE` here
|
||||
state.map[state.key] = object;
|
||||
state.readCount++;
|
||||
if (state.readCount === state.size) {
|
||||
stack.pop();
|
||||
object = state.map;
|
||||
}
|
||||
else {
|
||||
state.key = null;
|
||||
state.type = 1 /* State.MAP_KEY */;
|
||||
continue DECODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
};
|
||||
Decoder.prototype.readHeadByte = function () {
|
||||
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
||||
this.headByte = this.readU8();
|
||||
// console.log("headByte", prettyByte(this.headByte));
|
||||
}
|
||||
return this.headByte;
|
||||
};
|
||||
Decoder.prototype.complete = function () {
|
||||
this.headByte = HEAD_BYTE_REQUIRED;
|
||||
};
|
||||
Decoder.prototype.readArraySize = function () {
|
||||
var headByte = this.readHeadByte();
|
||||
switch (headByte) {
|
||||
case 0xdc:
|
||||
return this.readU16();
|
||||
case 0xdd:
|
||||
return this.readU32();
|
||||
default: {
|
||||
if (headByte < 0xa0) {
|
||||
return headByte - 0x90;
|
||||
}
|
||||
else {
|
||||
throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(headByte)));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Decoder.prototype.pushMapState = function (size) {
|
||||
if (size > this.maxMapLength) {
|
||||
throw new DecodeError("Max length exceeded: map length (".concat(size, ") > maxMapLengthLength (").concat(this.maxMapLength, ")"));
|
||||
}
|
||||
this.stack.push({
|
||||
type: 1 /* State.MAP_KEY */,
|
||||
size: size,
|
||||
key: null,
|
||||
readCount: 0,
|
||||
map: {},
|
||||
});
|
||||
};
|
||||
Decoder.prototype.pushArrayState = function (size) {
|
||||
if (size > this.maxArrayLength) {
|
||||
throw new DecodeError("Max length exceeded: array length (".concat(size, ") > maxArrayLength (").concat(this.maxArrayLength, ")"));
|
||||
}
|
||||
this.stack.push({
|
||||
type: 0 /* State.ARRAY */,
|
||||
size: size,
|
||||
array: new Array(size),
|
||||
position: 0,
|
||||
});
|
||||
};
|
||||
Decoder.prototype.decodeUtf8String = function (byteLength, headerOffset) {
|
||||
var _a;
|
||||
if (byteLength > this.maxStrLength) {
|
||||
throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(byteLength, ") > maxStrLength (").concat(this.maxStrLength, ")"));
|
||||
}
|
||||
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
||||
throw MORE_DATA;
|
||||
}
|
||||
var offset = this.pos + headerOffset;
|
||||
var object;
|
||||
if (this.stateIsMapKey() && ((_a = this.keyDecoder) === null || _a === void 0 ? void 0 : _a.canBeCached(byteLength))) {
|
||||
object = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
||||
}
|
||||
else if (byteLength > TEXT_DECODER_THRESHOLD) {
|
||||
object = utf8DecodeTD(this.bytes, offset, byteLength);
|
||||
}
|
||||
else {
|
||||
object = utf8DecodeJs(this.bytes, offset, byteLength);
|
||||
}
|
||||
this.pos += headerOffset + byteLength;
|
||||
return object;
|
||||
};
|
||||
Decoder.prototype.stateIsMapKey = function () {
|
||||
if (this.stack.length > 0) {
|
||||
var state = this.stack[this.stack.length - 1];
|
||||
return state.type === 1 /* State.MAP_KEY */;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Decoder.prototype.decodeBinary = function (byteLength, headOffset) {
|
||||
if (byteLength > this.maxBinLength) {
|
||||
throw new DecodeError("Max length exceeded: bin length (".concat(byteLength, ") > maxBinLength (").concat(this.maxBinLength, ")"));
|
||||
}
|
||||
if (!this.hasRemaining(byteLength + headOffset)) {
|
||||
throw MORE_DATA;
|
||||
}
|
||||
var offset = this.pos + headOffset;
|
||||
var object = this.bytes.subarray(offset, offset + byteLength);
|
||||
this.pos += headOffset + byteLength;
|
||||
return object;
|
||||
};
|
||||
Decoder.prototype.decodeExtension = function (size, headOffset) {
|
||||
if (size > this.maxExtLength) {
|
||||
throw new DecodeError("Max length exceeded: ext length (".concat(size, ") > maxExtLength (").concat(this.maxExtLength, ")"));
|
||||
}
|
||||
var extType = this.view.getInt8(this.pos + headOffset);
|
||||
var data = this.decodeBinary(size, headOffset + 1 /* extType */);
|
||||
return this.extensionCodec.decode(data, extType, this.context);
|
||||
};
|
||||
Decoder.prototype.lookU8 = function () {
|
||||
return this.view.getUint8(this.pos);
|
||||
};
|
||||
Decoder.prototype.lookU16 = function () {
|
||||
return this.view.getUint16(this.pos);
|
||||
};
|
||||
Decoder.prototype.lookU32 = function () {
|
||||
return this.view.getUint32(this.pos);
|
||||
};
|
||||
Decoder.prototype.readU8 = function () {
|
||||
var value = this.view.getUint8(this.pos);
|
||||
this.pos++;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readI8 = function () {
|
||||
var value = this.view.getInt8(this.pos);
|
||||
this.pos++;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readU16 = function () {
|
||||
var value = this.view.getUint16(this.pos);
|
||||
this.pos += 2;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readI16 = function () {
|
||||
var value = this.view.getInt16(this.pos);
|
||||
this.pos += 2;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readU32 = function () {
|
||||
var value = this.view.getUint32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readI32 = function () {
|
||||
var value = this.view.getInt32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readU64 = function () {
|
||||
var value = getUint64(this.view, this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readI64 = function () {
|
||||
var value = getInt64(this.view, this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readF32 = function () {
|
||||
var value = this.view.getFloat32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
};
|
||||
Decoder.prototype.readF64 = function () {
|
||||
var value = this.view.getFloat64(this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
};
|
||||
return Decoder;
|
||||
}());
|
||||
export { Decoder };
|
||||
//# sourceMappingURL=Decoder.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Decoder.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Decoder.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
417
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Encoder.mjs
generated
vendored
Normal file
417
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Encoder.mjs
generated
vendored
Normal file
@@ -0,0 +1,417 @@
|
||||
import { utf8EncodeJs, utf8Count, TEXT_ENCODER_THRESHOLD, utf8EncodeTE } from "./utils/utf8.mjs";
|
||||
import { ExtensionCodec } from "./ExtensionCodec.mjs";
|
||||
import { setInt64, setUint64 } from "./utils/int.mjs";
|
||||
import { ensureUint8Array } from "./utils/typedArrays.mjs";
|
||||
export var DEFAULT_MAX_DEPTH = 100;
|
||||
export var DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
||||
var Encoder = /** @class */ (function () {
|
||||
function Encoder(extensionCodec, context, maxDepth, initialBufferSize, sortKeys, forceFloat32, ignoreUndefined, forceIntegerToFloat) {
|
||||
if (extensionCodec === void 0) { extensionCodec = ExtensionCodec.defaultCodec; }
|
||||
if (context === void 0) { context = undefined; }
|
||||
if (maxDepth === void 0) { maxDepth = DEFAULT_MAX_DEPTH; }
|
||||
if (initialBufferSize === void 0) { initialBufferSize = DEFAULT_INITIAL_BUFFER_SIZE; }
|
||||
if (sortKeys === void 0) { sortKeys = false; }
|
||||
if (forceFloat32 === void 0) { forceFloat32 = false; }
|
||||
if (ignoreUndefined === void 0) { ignoreUndefined = false; }
|
||||
if (forceIntegerToFloat === void 0) { forceIntegerToFloat = false; }
|
||||
this.extensionCodec = extensionCodec;
|
||||
this.context = context;
|
||||
this.maxDepth = maxDepth;
|
||||
this.initialBufferSize = initialBufferSize;
|
||||
this.sortKeys = sortKeys;
|
||||
this.forceFloat32 = forceFloat32;
|
||||
this.ignoreUndefined = ignoreUndefined;
|
||||
this.forceIntegerToFloat = forceIntegerToFloat;
|
||||
this.pos = 0;
|
||||
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
||||
this.bytes = new Uint8Array(this.view.buffer);
|
||||
}
|
||||
Encoder.prototype.reinitializeState = function () {
|
||||
this.pos = 0;
|
||||
};
|
||||
/**
|
||||
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
||||
*
|
||||
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
||||
*/
|
||||
Encoder.prototype.encodeSharedRef = function (object) {
|
||||
this.reinitializeState();
|
||||
this.doEncode(object, 1);
|
||||
return this.bytes.subarray(0, this.pos);
|
||||
};
|
||||
/**
|
||||
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
||||
*/
|
||||
Encoder.prototype.encode = function (object) {
|
||||
this.reinitializeState();
|
||||
this.doEncode(object, 1);
|
||||
return this.bytes.slice(0, this.pos);
|
||||
};
|
||||
Encoder.prototype.doEncode = function (object, depth) {
|
||||
if (depth > this.maxDepth) {
|
||||
throw new Error("Too deep objects in depth ".concat(depth));
|
||||
}
|
||||
if (object == null) {
|
||||
this.encodeNil();
|
||||
}
|
||||
else if (typeof object === "boolean") {
|
||||
this.encodeBoolean(object);
|
||||
}
|
||||
else if (typeof object === "number") {
|
||||
this.encodeNumber(object);
|
||||
}
|
||||
else if (typeof object === "string") {
|
||||
this.encodeString(object);
|
||||
}
|
||||
else {
|
||||
this.encodeObject(object, depth);
|
||||
}
|
||||
};
|
||||
Encoder.prototype.ensureBufferSizeToWrite = function (sizeToWrite) {
|
||||
var requiredSize = this.pos + sizeToWrite;
|
||||
if (this.view.byteLength < requiredSize) {
|
||||
this.resizeBuffer(requiredSize * 2);
|
||||
}
|
||||
};
|
||||
Encoder.prototype.resizeBuffer = function (newSize) {
|
||||
var newBuffer = new ArrayBuffer(newSize);
|
||||
var newBytes = new Uint8Array(newBuffer);
|
||||
var newView = new DataView(newBuffer);
|
||||
newBytes.set(this.bytes);
|
||||
this.view = newView;
|
||||
this.bytes = newBytes;
|
||||
};
|
||||
Encoder.prototype.encodeNil = function () {
|
||||
this.writeU8(0xc0);
|
||||
};
|
||||
Encoder.prototype.encodeBoolean = function (object) {
|
||||
if (object === false) {
|
||||
this.writeU8(0xc2);
|
||||
}
|
||||
else {
|
||||
this.writeU8(0xc3);
|
||||
}
|
||||
};
|
||||
Encoder.prototype.encodeNumber = function (object) {
|
||||
if (Number.isSafeInteger(object) && !this.forceIntegerToFloat) {
|
||||
if (object >= 0) {
|
||||
if (object < 0x80) {
|
||||
// positive fixint
|
||||
this.writeU8(object);
|
||||
}
|
||||
else if (object < 0x100) {
|
||||
// uint 8
|
||||
this.writeU8(0xcc);
|
||||
this.writeU8(object);
|
||||
}
|
||||
else if (object < 0x10000) {
|
||||
// uint 16
|
||||
this.writeU8(0xcd);
|
||||
this.writeU16(object);
|
||||
}
|
||||
else if (object < 0x100000000) {
|
||||
// uint 32
|
||||
this.writeU8(0xce);
|
||||
this.writeU32(object);
|
||||
}
|
||||
else {
|
||||
// uint 64
|
||||
this.writeU8(0xcf);
|
||||
this.writeU64(object);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (object >= -0x20) {
|
||||
// negative fixint
|
||||
this.writeU8(0xe0 | (object + 0x20));
|
||||
}
|
||||
else if (object >= -0x80) {
|
||||
// int 8
|
||||
this.writeU8(0xd0);
|
||||
this.writeI8(object);
|
||||
}
|
||||
else if (object >= -0x8000) {
|
||||
// int 16
|
||||
this.writeU8(0xd1);
|
||||
this.writeI16(object);
|
||||
}
|
||||
else if (object >= -0x80000000) {
|
||||
// int 32
|
||||
this.writeU8(0xd2);
|
||||
this.writeI32(object);
|
||||
}
|
||||
else {
|
||||
// int 64
|
||||
this.writeU8(0xd3);
|
||||
this.writeI64(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// non-integer numbers
|
||||
if (this.forceFloat32) {
|
||||
// float 32
|
||||
this.writeU8(0xca);
|
||||
this.writeF32(object);
|
||||
}
|
||||
else {
|
||||
// float 64
|
||||
this.writeU8(0xcb);
|
||||
this.writeF64(object);
|
||||
}
|
||||
}
|
||||
};
|
||||
Encoder.prototype.writeStringHeader = function (byteLength) {
|
||||
if (byteLength < 32) {
|
||||
// fixstr
|
||||
this.writeU8(0xa0 + byteLength);
|
||||
}
|
||||
else if (byteLength < 0x100) {
|
||||
// str 8
|
||||
this.writeU8(0xd9);
|
||||
this.writeU8(byteLength);
|
||||
}
|
||||
else if (byteLength < 0x10000) {
|
||||
// str 16
|
||||
this.writeU8(0xda);
|
||||
this.writeU16(byteLength);
|
||||
}
|
||||
else if (byteLength < 0x100000000) {
|
||||
// str 32
|
||||
this.writeU8(0xdb);
|
||||
this.writeU32(byteLength);
|
||||
}
|
||||
else {
|
||||
throw new Error("Too long string: ".concat(byteLength, " bytes in UTF-8"));
|
||||
}
|
||||
};
|
||||
Encoder.prototype.encodeString = function (object) {
|
||||
var maxHeaderSize = 1 + 4;
|
||||
var strLength = object.length;
|
||||
if (strLength > TEXT_ENCODER_THRESHOLD) {
|
||||
var byteLength = utf8Count(object);
|
||||
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
||||
this.writeStringHeader(byteLength);
|
||||
utf8EncodeTE(object, this.bytes, this.pos);
|
||||
this.pos += byteLength;
|
||||
}
|
||||
else {
|
||||
var byteLength = utf8Count(object);
|
||||
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
||||
this.writeStringHeader(byteLength);
|
||||
utf8EncodeJs(object, this.bytes, this.pos);
|
||||
this.pos += byteLength;
|
||||
}
|
||||
};
|
||||
Encoder.prototype.encodeObject = function (object, depth) {
|
||||
// try to encode objects with custom codec first of non-primitives
|
||||
var ext = this.extensionCodec.tryToEncode(object, this.context);
|
||||
if (ext != null) {
|
||||
this.encodeExtension(ext);
|
||||
}
|
||||
else if (Array.isArray(object)) {
|
||||
this.encodeArray(object, depth);
|
||||
}
|
||||
else if (ArrayBuffer.isView(object)) {
|
||||
this.encodeBinary(object);
|
||||
}
|
||||
else if (typeof object === "object") {
|
||||
this.encodeMap(object, depth);
|
||||
}
|
||||
else {
|
||||
// symbol, function and other special object come here unless extensionCodec handles them.
|
||||
throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(object)));
|
||||
}
|
||||
};
|
||||
Encoder.prototype.encodeBinary = function (object) {
|
||||
var size = object.byteLength;
|
||||
if (size < 0x100) {
|
||||
// bin 8
|
||||
this.writeU8(0xc4);
|
||||
this.writeU8(size);
|
||||
}
|
||||
else if (size < 0x10000) {
|
||||
// bin 16
|
||||
this.writeU8(0xc5);
|
||||
this.writeU16(size);
|
||||
}
|
||||
else if (size < 0x100000000) {
|
||||
// bin 32
|
||||
this.writeU8(0xc6);
|
||||
this.writeU32(size);
|
||||
}
|
||||
else {
|
||||
throw new Error("Too large binary: ".concat(size));
|
||||
}
|
||||
var bytes = ensureUint8Array(object);
|
||||
this.writeU8a(bytes);
|
||||
};
|
||||
Encoder.prototype.encodeArray = function (object, depth) {
|
||||
var size = object.length;
|
||||
if (size < 16) {
|
||||
// fixarray
|
||||
this.writeU8(0x90 + size);
|
||||
}
|
||||
else if (size < 0x10000) {
|
||||
// array 16
|
||||
this.writeU8(0xdc);
|
||||
this.writeU16(size);
|
||||
}
|
||||
else if (size < 0x100000000) {
|
||||
// array 32
|
||||
this.writeU8(0xdd);
|
||||
this.writeU32(size);
|
||||
}
|
||||
else {
|
||||
throw new Error("Too large array: ".concat(size));
|
||||
}
|
||||
for (var _i = 0, object_1 = object; _i < object_1.length; _i++) {
|
||||
var item = object_1[_i];
|
||||
this.doEncode(item, depth + 1);
|
||||
}
|
||||
};
|
||||
Encoder.prototype.countWithoutUndefined = function (object, keys) {
|
||||
var count = 0;
|
||||
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
||||
var key = keys_1[_i];
|
||||
if (object[key] !== undefined) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
};
|
||||
Encoder.prototype.encodeMap = function (object, depth) {
|
||||
var keys = Object.keys(object);
|
||||
if (this.sortKeys) {
|
||||
keys.sort();
|
||||
}
|
||||
var size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
|
||||
if (size < 16) {
|
||||
// fixmap
|
||||
this.writeU8(0x80 + size);
|
||||
}
|
||||
else if (size < 0x10000) {
|
||||
// map 16
|
||||
this.writeU8(0xde);
|
||||
this.writeU16(size);
|
||||
}
|
||||
else if (size < 0x100000000) {
|
||||
// map 32
|
||||
this.writeU8(0xdf);
|
||||
this.writeU32(size);
|
||||
}
|
||||
else {
|
||||
throw new Error("Too large map object: ".concat(size));
|
||||
}
|
||||
for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
|
||||
var key = keys_2[_i];
|
||||
var value = object[key];
|
||||
if (!(this.ignoreUndefined && value === undefined)) {
|
||||
this.encodeString(key);
|
||||
this.doEncode(value, depth + 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
Encoder.prototype.encodeExtension = function (ext) {
|
||||
var size = ext.data.length;
|
||||
if (size === 1) {
|
||||
// fixext 1
|
||||
this.writeU8(0xd4);
|
||||
}
|
||||
else if (size === 2) {
|
||||
// fixext 2
|
||||
this.writeU8(0xd5);
|
||||
}
|
||||
else if (size === 4) {
|
||||
// fixext 4
|
||||
this.writeU8(0xd6);
|
||||
}
|
||||
else if (size === 8) {
|
||||
// fixext 8
|
||||
this.writeU8(0xd7);
|
||||
}
|
||||
else if (size === 16) {
|
||||
// fixext 16
|
||||
this.writeU8(0xd8);
|
||||
}
|
||||
else if (size < 0x100) {
|
||||
// ext 8
|
||||
this.writeU8(0xc7);
|
||||
this.writeU8(size);
|
||||
}
|
||||
else if (size < 0x10000) {
|
||||
// ext 16
|
||||
this.writeU8(0xc8);
|
||||
this.writeU16(size);
|
||||
}
|
||||
else if (size < 0x100000000) {
|
||||
// ext 32
|
||||
this.writeU8(0xc9);
|
||||
this.writeU32(size);
|
||||
}
|
||||
else {
|
||||
throw new Error("Too large extension object: ".concat(size));
|
||||
}
|
||||
this.writeI8(ext.type);
|
||||
this.writeU8a(ext.data);
|
||||
};
|
||||
Encoder.prototype.writeU8 = function (value) {
|
||||
this.ensureBufferSizeToWrite(1);
|
||||
this.view.setUint8(this.pos, value);
|
||||
this.pos++;
|
||||
};
|
||||
Encoder.prototype.writeU8a = function (values) {
|
||||
var size = values.length;
|
||||
this.ensureBufferSizeToWrite(size);
|
||||
this.bytes.set(values, this.pos);
|
||||
this.pos += size;
|
||||
};
|
||||
Encoder.prototype.writeI8 = function (value) {
|
||||
this.ensureBufferSizeToWrite(1);
|
||||
this.view.setInt8(this.pos, value);
|
||||
this.pos++;
|
||||
};
|
||||
Encoder.prototype.writeU16 = function (value) {
|
||||
this.ensureBufferSizeToWrite(2);
|
||||
this.view.setUint16(this.pos, value);
|
||||
this.pos += 2;
|
||||
};
|
||||
Encoder.prototype.writeI16 = function (value) {
|
||||
this.ensureBufferSizeToWrite(2);
|
||||
this.view.setInt16(this.pos, value);
|
||||
this.pos += 2;
|
||||
};
|
||||
Encoder.prototype.writeU32 = function (value) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
this.view.setUint32(this.pos, value);
|
||||
this.pos += 4;
|
||||
};
|
||||
Encoder.prototype.writeI32 = function (value) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
this.view.setInt32(this.pos, value);
|
||||
this.pos += 4;
|
||||
};
|
||||
Encoder.prototype.writeF32 = function (value) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
this.view.setFloat32(this.pos, value);
|
||||
this.pos += 4;
|
||||
};
|
||||
Encoder.prototype.writeF64 = function (value) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
this.view.setFloat64(this.pos, value);
|
||||
this.pos += 8;
|
||||
};
|
||||
Encoder.prototype.writeU64 = function (value) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
setUint64(this.view, this.pos, value);
|
||||
this.pos += 8;
|
||||
};
|
||||
Encoder.prototype.writeI64 = function (value) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
setInt64(this.view, this.pos, value);
|
||||
this.pos += 8;
|
||||
};
|
||||
return Encoder;
|
||||
}());
|
||||
export { Encoder };
|
||||
//# sourceMappingURL=Encoder.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Encoder.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/Encoder.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtData.mjs
generated
vendored
Normal file
12
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtData.mjs
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* ExtData is used to handle Extension Types that are not registered to ExtensionCodec.
|
||||
*/
|
||||
var ExtData = /** @class */ (function () {
|
||||
function ExtData(type, data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
return ExtData;
|
||||
}());
|
||||
export { ExtData };
|
||||
//# sourceMappingURL=ExtData.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtData.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtData.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExtData.mjs","sourceRoot":"","sources":["../src/ExtData.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;IACE,iBAAqB,IAAY,EAAW,IAAgB;QAAvC,SAAI,GAAJ,IAAI,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAClE,cAAC;AAAD,CAAC,AAFD,IAEC"}
|
||||
71
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtensionCodec.mjs
generated
vendored
Normal file
71
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtensionCodec.mjs
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// ExtensionCodec to handle MessagePack extensions
|
||||
import { ExtData } from "./ExtData.mjs";
|
||||
import { timestampExtension } from "./timestamp.mjs";
|
||||
var ExtensionCodec = /** @class */ (function () {
|
||||
function ExtensionCodec() {
|
||||
// built-in extensions
|
||||
this.builtInEncoders = [];
|
||||
this.builtInDecoders = [];
|
||||
// custom extensions
|
||||
this.encoders = [];
|
||||
this.decoders = [];
|
||||
this.register(timestampExtension);
|
||||
}
|
||||
ExtensionCodec.prototype.register = function (_a) {
|
||||
var type = _a.type, encode = _a.encode, decode = _a.decode;
|
||||
if (type >= 0) {
|
||||
// custom extensions
|
||||
this.encoders[type] = encode;
|
||||
this.decoders[type] = decode;
|
||||
}
|
||||
else {
|
||||
// built-in extensions
|
||||
var index = 1 + type;
|
||||
this.builtInEncoders[index] = encode;
|
||||
this.builtInDecoders[index] = decode;
|
||||
}
|
||||
};
|
||||
ExtensionCodec.prototype.tryToEncode = function (object, context) {
|
||||
// built-in extensions
|
||||
for (var i = 0; i < this.builtInEncoders.length; i++) {
|
||||
var encodeExt = this.builtInEncoders[i];
|
||||
if (encodeExt != null) {
|
||||
var data = encodeExt(object, context);
|
||||
if (data != null) {
|
||||
var type = -1 - i;
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// custom extensions
|
||||
for (var i = 0; i < this.encoders.length; i++) {
|
||||
var encodeExt = this.encoders[i];
|
||||
if (encodeExt != null) {
|
||||
var data = encodeExt(object, context);
|
||||
if (data != null) {
|
||||
var type = i;
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (object instanceof ExtData) {
|
||||
// to keep ExtData as is
|
||||
return object;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
ExtensionCodec.prototype.decode = function (data, type, context) {
|
||||
var decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
||||
if (decodeExt) {
|
||||
return decodeExt(data, type, context);
|
||||
}
|
||||
else {
|
||||
// decode() does not fail, returns ExtData instead.
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
};
|
||||
ExtensionCodec.defaultCodec = new ExtensionCodec();
|
||||
return ExtensionCodec;
|
||||
}());
|
||||
export { ExtensionCodec };
|
||||
//# sourceMappingURL=ExtensionCodec.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtensionCodec.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/ExtensionCodec.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExtensionCodec.mjs","sourceRoot":"","sources":["../src/ExtensionCodec.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAkBjD;IAgBE;QARA,sBAAsB;QACL,oBAAe,GAAgE,EAAE,CAAC;QAClF,oBAAe,GAAgE,EAAE,CAAC;QAEnG,oBAAoB;QACH,aAAQ,GAAgE,EAAE,CAAC;QAC3E,aAAQ,GAAgE,EAAE,CAAC;QAG1F,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;IAEM,iCAAQ,GAAf,UAAgB,EAQf;YAPC,IAAI,UAAA,EACJ,MAAM,YAAA,EACN,MAAM,YAAA;QAMN,IAAI,IAAI,IAAI,CAAC,EAAE;YACb,oBAAoB;YACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;SAC9B;aAAM;YACL,sBAAsB;YACtB,IAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YACrC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;SACtC;IACH,CAAC;IAEM,oCAAW,GAAlB,UAAmB,MAAe,EAAE,OAAoB;QACtD,sBAAsB;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpD,IAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YAC1C,IAAI,SAAS,IAAI,IAAI,EAAE;gBACrB,IAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACxC,IAAI,IAAI,IAAI,IAAI,EAAE;oBAChB,IAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;oBACpB,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACF;SACF;QAED,oBAAoB;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,IAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACnC,IAAI,SAAS,IAAI,IAAI,EAAE;gBACrB,IAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACxC,IAAI,IAAI,IAAI,IAAI,EAAE;oBAChB,IAAM,IAAI,GAAG,CAAC,CAAC;oBACf,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAChC;aACF;SACF;QAED,IAAI,MAAM,YAAY,OAAO,EAAE;YAC7B,wBAAwB;YACxB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,+BAAM,GAAb,UAAc,IAAgB,EAAE,IAAY,EAAE,OAAoB;QAChE,IAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnF,IAAI,SAAS,EAAE;YACb,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;SACvC;aAAM;YACL,mDAAmD;YACnD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAChC;IACH,CAAC;IAhFsB,2BAAY,GAAkC,IAAI,cAAc,EAAE,CAAC;IAiF5F,qBAAC;CAAA,AAlFD,IAkFC;SAlFY,cAAc"}
|
||||
3
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/context.mjs
generated
vendored
Normal file
3
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/context.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
export {};
|
||||
//# sourceMappingURL=context.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/context.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/context.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"context.mjs","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,iDAAiD"}
|
||||
29
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs
generated
vendored
Normal file
29
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Decoder } from "./Decoder.mjs";
|
||||
export var defaultDecodeOptions = {};
|
||||
/**
|
||||
* It decodes a single MessagePack object in a buffer.
|
||||
*
|
||||
* This is a synchronous decoding function.
|
||||
* See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
|
||||
*
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decode(buffer, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
||||
return decoder.decode(buffer);
|
||||
}
|
||||
/**
|
||||
* It decodes multiple MessagePack objects in a buffer.
|
||||
* This is corresponding to {@link decodeMultiStream()}.
|
||||
*
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeMulti(buffer, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
||||
return decoder.decodeMulti(buffer);
|
||||
}
|
||||
//# sourceMappingURL=decode.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decode.mjs","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0CpC,MAAM,CAAC,IAAM,oBAAoB,GAAkB,EAAE,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CACpB,MAAwC,EACxC,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,IAAM,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,CACrB,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAAwC,EACxC,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,IAAM,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,CACrB,CAAC;IACF,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
||||
82
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decodeAsync.mjs
generated
vendored
Normal file
82
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decodeAsync.mjs
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
import { Decoder } from "./Decoder.mjs";
|
||||
import { ensureAsyncIterable } from "./utils/stream.mjs";
|
||||
import { defaultDecodeOptions } from "./decode.mjs";
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeAsync(streamLike, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var stream, decoder;
|
||||
return __generator(this, function (_a) {
|
||||
stream = ensureAsyncIterable(streamLike);
|
||||
decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
||||
return [2 /*return*/, decoder.decodeAsync(stream)];
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeArrayStream(streamLike, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
var stream = ensureAsyncIterable(streamLike);
|
||||
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
||||
return decoder.decodeArrayStream(stream);
|
||||
}
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeMultiStream(streamLike, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
var stream = ensureAsyncIterable(streamLike);
|
||||
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
||||
return decoder.decodeStream(stream);
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link decodeMultiStream()} instead.
|
||||
*/
|
||||
export function decodeStream(streamLike, options) {
|
||||
if (options === void 0) { options = defaultDecodeOptions; }
|
||||
return decodeMultiStream(streamLike, options);
|
||||
}
|
||||
//# sourceMappingURL=decodeAsync.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decodeAsync.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/decodeAsync.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decodeAsync.mjs","sourceRoot":"","sources":["../src/decodeAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKhD;;;GAGG;AACF,MAAM,UAAgB,WAAW,CAChC,UAAgE,EAChE,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;;;;YAE3E,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAEzC,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,CACrB,CAAC;YACF,sBAAO,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAC;;;CACpC;AAED;;;GAGG;AACF,MAAM,UAAU,iBAAiB,CAChC,UAAgE,EAChE,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,IAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE/C,IAAM,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,CACrB,CAAC;IAEF,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAgE,EAChE,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,IAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE/C,IAAM,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,YAAY,CACrB,CAAC;IAEF,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,UAAgE,EAChE,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,OAAO,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC"}
|
||||
14
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs
generated
vendored
Normal file
14
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Encoder } from "./Encoder.mjs";
|
||||
var defaultEncodeOptions = {};
|
||||
/**
|
||||
* It encodes `value` in the MessagePack format and
|
||||
* returns a byte buffer.
|
||||
*
|
||||
* The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`.
|
||||
*/
|
||||
export function encode(value, options) {
|
||||
if (options === void 0) { options = defaultEncodeOptions; }
|
||||
var encoder = new Encoder(options.extensionCodec, options.context, options.maxDepth, options.initialBufferSize, options.sortKeys, options.forceFloat32, options.ignoreUndefined, options.forceIntegerToFloat);
|
||||
return encoder.encodeSharedRef(value);
|
||||
}
|
||||
//# sourceMappingURL=encode.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"encode.mjs","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyDpC,IAAM,oBAAoB,GAAkB,EAAE,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CACpB,KAAc,EACd,OAAiF;IAAjF,wBAAA,EAAA,UAAsD,oBAA2B;IAEjF,IAAM,OAAO,GAAG,IAAI,OAAO,CACzB,OAAO,CAAC,cAAc,EACrB,OAA6C,CAAC,OAAO,EACtD,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,iBAAiB,EACzB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,mBAAmB,CAC5B,CAAC;IACF,OAAO,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
||||
20
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/index.mjs
generated
vendored
Normal file
20
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Main Functions:
|
||||
import { encode } from "./encode.mjs";
|
||||
export { encode };
|
||||
import { decode, decodeMulti } from "./decode.mjs";
|
||||
export { decode, decodeMulti };
|
||||
import { decodeAsync, decodeArrayStream, decodeMultiStream, decodeStream } from "./decodeAsync.mjs";
|
||||
export { decodeAsync, decodeArrayStream, decodeMultiStream, decodeStream };
|
||||
import { Decoder, DataViewIndexOutOfBoundsError } from "./Decoder.mjs";
|
||||
import { DecodeError } from "./DecodeError.mjs";
|
||||
export { Decoder, DecodeError, DataViewIndexOutOfBoundsError };
|
||||
import { Encoder } from "./Encoder.mjs";
|
||||
export { Encoder };
|
||||
// Utilitiies for Extension Types:
|
||||
import { ExtensionCodec } from "./ExtensionCodec.mjs";
|
||||
export { ExtensionCodec };
|
||||
import { ExtData } from "./ExtData.mjs";
|
||||
export { ExtData };
|
||||
import { EXT_TIMESTAMP, encodeDateToTimeSpec, encodeTimeSpecToTimestamp, decodeTimestampToTimeSpec, encodeTimestampExtension, decodeTimestampExtension, } from "./timestamp.mjs";
|
||||
export { EXT_TIMESTAMP, encodeDateToTimeSpec, encodeTimeSpecToTimestamp, decodeTimestampToTimeSpec, encodeTimestampExtension, decodeTimestampExtension, };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/index.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,CAAC;AAIlB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAI/B,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,kCAAkC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,CAAC;AAG1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GACzB,CAAC"}
|
||||
97
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/timestamp.mjs
generated
vendored
Normal file
97
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/timestamp.mjs
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
|
||||
import { DecodeError } from "./DecodeError.mjs";
|
||||
import { getInt64, setInt64 } from "./utils/int.mjs";
|
||||
export var EXT_TIMESTAMP = -1;
|
||||
var TIMESTAMP32_MAX_SEC = 0x100000000 - 1; // 32-bit unsigned int
|
||||
var TIMESTAMP64_MAX_SEC = 0x400000000 - 1; // 34-bit unsigned int
|
||||
export function encodeTimeSpecToTimestamp(_a) {
|
||||
var sec = _a.sec, nsec = _a.nsec;
|
||||
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
||||
// Here sec >= 0 && nsec >= 0
|
||||
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
||||
// timestamp 32 = { sec32 (unsigned) }
|
||||
var rv = new Uint8Array(4);
|
||||
var view = new DataView(rv.buffer);
|
||||
view.setUint32(0, sec);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// timestamp 64 = { nsec30 (unsigned), sec34 (unsigned) }
|
||||
var secHigh = sec / 0x100000000;
|
||||
var secLow = sec & 0xffffffff;
|
||||
var rv = new Uint8Array(8);
|
||||
var view = new DataView(rv.buffer);
|
||||
// nsec30 | secHigh2
|
||||
view.setUint32(0, (nsec << 2) | (secHigh & 0x3));
|
||||
// secLow32
|
||||
view.setUint32(4, secLow);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// timestamp 96 = { nsec32 (unsigned), sec64 (signed) }
|
||||
var rv = new Uint8Array(12);
|
||||
var view = new DataView(rv.buffer);
|
||||
view.setUint32(0, nsec);
|
||||
setInt64(view, 4, sec);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
export function encodeDateToTimeSpec(date) {
|
||||
var msec = date.getTime();
|
||||
var sec = Math.floor(msec / 1e3);
|
||||
var nsec = (msec - sec * 1e3) * 1e6;
|
||||
// Normalizes { sec, nsec } to ensure nsec is unsigned.
|
||||
var nsecInSec = Math.floor(nsec / 1e9);
|
||||
return {
|
||||
sec: sec + nsecInSec,
|
||||
nsec: nsec - nsecInSec * 1e9,
|
||||
};
|
||||
}
|
||||
export function encodeTimestampExtension(object) {
|
||||
if (object instanceof Date) {
|
||||
var timeSpec = encodeDateToTimeSpec(object);
|
||||
return encodeTimeSpecToTimestamp(timeSpec);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function decodeTimestampToTimeSpec(data) {
|
||||
var view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
||||
// data may be 32, 64, or 96 bits
|
||||
switch (data.byteLength) {
|
||||
case 4: {
|
||||
// timestamp 32 = { sec32 }
|
||||
var sec = view.getUint32(0);
|
||||
var nsec = 0;
|
||||
return { sec: sec, nsec: nsec };
|
||||
}
|
||||
case 8: {
|
||||
// timestamp 64 = { nsec30, sec34 }
|
||||
var nsec30AndSecHigh2 = view.getUint32(0);
|
||||
var secLow32 = view.getUint32(4);
|
||||
var sec = (nsec30AndSecHigh2 & 0x3) * 0x100000000 + secLow32;
|
||||
var nsec = nsec30AndSecHigh2 >>> 2;
|
||||
return { sec: sec, nsec: nsec };
|
||||
}
|
||||
case 12: {
|
||||
// timestamp 96 = { nsec32 (unsigned), sec64 (signed) }
|
||||
var sec = getInt64(view, 4);
|
||||
var nsec = view.getUint32(0);
|
||||
return { sec: sec, nsec: nsec };
|
||||
}
|
||||
default:
|
||||
throw new DecodeError("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(data.length));
|
||||
}
|
||||
}
|
||||
export function decodeTimestampExtension(data) {
|
||||
var timeSpec = decodeTimestampToTimeSpec(data);
|
||||
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
||||
}
|
||||
export var timestampExtension = {
|
||||
type: EXT_TIMESTAMP,
|
||||
encode: encodeTimestampExtension,
|
||||
decode: decodeTimestampExtension,
|
||||
};
|
||||
//# sourceMappingURL=timestamp.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/timestamp.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/timestamp.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"timestamp.mjs","sourceRoot":"","sources":["../src/timestamp.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,IAAM,aAAa,GAAG,CAAC,CAAC,CAAC;AAOhC,IAAM,mBAAmB,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,sBAAsB;AACnE,IAAM,mBAAmB,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,sBAAsB;AAEnE,MAAM,UAAU,yBAAyB,CAAC,EAAuB;QAArB,GAAG,SAAA,EAAE,IAAI,UAAA;IACnD,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAmB,EAAE;QACvD,6BAA6B;QAC7B,IAAI,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,mBAAmB,EAAE;YAC5C,sCAAsC;YACtC,IAAM,EAAE,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;YACrC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACvB,OAAO,EAAE,CAAC;SACX;aAAM;YACL,yDAAyD;YACzD,IAAM,OAAO,GAAG,GAAG,GAAG,WAAW,CAAC;YAClC,IAAM,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC;YAChC,IAAM,EAAE,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;YACrC,oBAAoB;YACpB,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC;YACjD,WAAW;YACX,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YAC1B,OAAO,EAAE,CAAC;SACX;KACF;SAAM;QACL,uDAAuD;QACvD,IAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACvB,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC7C,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC5B,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;IACnC,IAAM,IAAI,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAEtC,uDAAuD;IACvD,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;IACzC,OAAO;QACL,GAAG,EAAE,GAAG,GAAG,SAAS;QACpB,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,GAAG;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,MAAe;IACtD,IAAI,MAAM,YAAY,IAAI,EAAE;QAC1B,IAAM,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC9C,OAAO,yBAAyB,CAAC,QAAQ,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAgB;IACxD,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAEzE,iCAAiC;IACjC,QAAQ,IAAI,CAAC,UAAU,EAAE;QACvB,KAAK,CAAC,CAAC,CAAC;YACN,2BAA2B;YAC3B,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAM,IAAI,GAAG,CAAC,CAAC;YACf,OAAO,EAAE,GAAG,KAAA,EAAE,IAAI,MAAA,EAAE,CAAC;SACtB;QACD,KAAK,CAAC,CAAC,CAAC;YACN,mCAAmC;YACnC,IAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,IAAM,GAAG,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,GAAG,WAAW,GAAG,QAAQ,CAAC;YAC/D,IAAM,IAAI,GAAG,iBAAiB,KAAK,CAAC,CAAC;YACrC,OAAO,EAAE,GAAG,KAAA,EAAE,IAAI,MAAA,EAAE,CAAC;SACtB;QACD,KAAK,EAAE,CAAC,CAAC;YACP,uDAAuD;YAEvD,IAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC9B,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC/B,OAAO,EAAE,GAAG,KAAA,EAAE,IAAI,MAAA,EAAE,CAAC;SACtB;QACD;YACE,MAAM,IAAI,WAAW,CAAC,uEAAgE,IAAI,CAAC,MAAM,CAAE,CAAC,CAAC;KACxG;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAgB;IACvD,IAAM,QAAQ,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,wBAAwB;IAChC,MAAM,EAAE,wBAAwB;CACjC,CAAC"}
|
||||
27
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/int.mjs
generated
vendored
Normal file
27
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/int.mjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Integer Utility
|
||||
export var UINT32_MAX = 4294967295;
|
||||
// DataView extension to handle int64 / uint64,
|
||||
// where the actual range is 53-bits integer (a.k.a. safe integer)
|
||||
export function setUint64(view, offset, value) {
|
||||
var high = value / 4294967296;
|
||||
var low = value; // high bits are truncated by DataView
|
||||
view.setUint32(offset, high);
|
||||
view.setUint32(offset + 4, low);
|
||||
}
|
||||
export function setInt64(view, offset, value) {
|
||||
var high = Math.floor(value / 4294967296);
|
||||
var low = value; // high bits are truncated by DataView
|
||||
view.setUint32(offset, high);
|
||||
view.setUint32(offset + 4, low);
|
||||
}
|
||||
export function getInt64(view, offset) {
|
||||
var high = view.getInt32(offset);
|
||||
var low = view.getUint32(offset + 4);
|
||||
return high * 4294967296 + low;
|
||||
}
|
||||
export function getUint64(view, offset) {
|
||||
var high = view.getUint32(offset);
|
||||
var low = view.getUint32(offset + 4);
|
||||
return high * 4294967296 + low;
|
||||
}
|
||||
//# sourceMappingURL=int.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/int.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/int.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"int.mjs","sourceRoot":"","sources":["../../src/utils/int.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,MAAM,CAAC,IAAM,UAAU,GAAG,UAAW,CAAC;AAEtC,+CAA+C;AAC/C,kEAAkE;AAElE,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,MAAc,EAAE,KAAa;IACrE,IAAM,IAAI,GAAG,KAAK,GAAG,UAAa,CAAC;IACnC,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,sCAAsC;IACzD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,MAAc,EAAE,KAAa;IACpE,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAa,CAAC,CAAC;IAC/C,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,sCAAsC;IACzD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,MAAc;IACrD,IAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,GAAG,UAAa,GAAG,GAAG,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,MAAc;IACtD,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,GAAG,UAAa,GAAG,GAAG,CAAC;AACpC,CAAC"}
|
||||
4
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/prettyByte.mjs
generated
vendored
Normal file
4
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/prettyByte.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export function prettyByte(byte) {
|
||||
return "".concat(byte < 0 ? "-" : "", "0x").concat(Math.abs(byte).toString(16).padStart(2, "0"));
|
||||
}
|
||||
//# sourceMappingURL=prettyByte.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/prettyByte.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/prettyByte.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"prettyByte.mjs","sourceRoot":"","sources":["../../src/utils/prettyByte.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,UAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,eAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAE,CAAC;AACnF,CAAC"}
|
||||
92
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/stream.mjs
generated
vendored
Normal file
92
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/stream.mjs
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// utility for whatwg streams
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
export function isAsyncIterable(object) {
|
||||
return object[Symbol.asyncIterator] != null;
|
||||
}
|
||||
function assertNonNull(value) {
|
||||
if (value == null) {
|
||||
throw new Error("Assertion Failure: value must not be null nor undefined");
|
||||
}
|
||||
}
|
||||
export function asyncIterableFromStream(stream) {
|
||||
return __asyncGenerator(this, arguments, function asyncIterableFromStream_1() {
|
||||
var reader, _a, done, value;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
reader = stream.getReader();
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, , 9, 10]);
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!true) return [3 /*break*/, 8];
|
||||
return [4 /*yield*/, __await(reader.read())];
|
||||
case 3:
|
||||
_a = _b.sent(), done = _a.done, value = _a.value;
|
||||
if (!done) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, __await(void 0)];
|
||||
case 4: return [2 /*return*/, _b.sent()];
|
||||
case 5:
|
||||
assertNonNull(value);
|
||||
return [4 /*yield*/, __await(value)];
|
||||
case 6: return [4 /*yield*/, _b.sent()];
|
||||
case 7:
|
||||
_b.sent();
|
||||
return [3 /*break*/, 2];
|
||||
case 8: return [3 /*break*/, 10];
|
||||
case 9:
|
||||
reader.releaseLock();
|
||||
return [7 /*endfinally*/];
|
||||
case 10: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
export function ensureAsyncIterable(streamLike) {
|
||||
if (isAsyncIterable(streamLike)) {
|
||||
return streamLike;
|
||||
}
|
||||
else {
|
||||
return asyncIterableFromStream(streamLike);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=stream.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/stream.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/stream.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stream.mjs","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":"AAAA,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ7B,MAAM,UAAU,eAAe,CAAI,MAA6B;IAC9D,OAAQ,MAAc,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;AACvD,CAAC;AAED,SAAS,aAAa,CAAI,KAA2B;IACnD,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;AACH,CAAC;AAED,MAAM,UAAiB,uBAAuB,CAAI,MAAyB;;;;;;oBACnE,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;;;;;;yBAGzB,IAAI;oBACe,6BAAM,MAAM,CAAC,IAAI,EAAE,GAAA;;oBAArC,KAAkB,SAAmB,EAAnC,IAAI,UAAA,EAAE,KAAK,WAAA;yBACf,IAAI,EAAJ,wBAAI;;wBACN,iCAAO;;oBAET,aAAa,CAAC,KAAK,CAAC,CAAC;iDACf,KAAK;wBAAX,gCAAW;;oBAAX,SAAW,CAAC;;;;oBAGd,MAAM,CAAC,WAAW,EAAE,CAAC;;;;;;CAExB;AAED,MAAM,UAAU,mBAAmB,CAAI,UAAiC;IACtE,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,OAAO,uBAAuB,CAAC,UAAU,CAAC,CAAC;KAC5C;AACH,CAAC"}
|
||||
23
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/typedArrays.mjs
generated
vendored
Normal file
23
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/typedArrays.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export function ensureUint8Array(buffer) {
|
||||
if (buffer instanceof Uint8Array) {
|
||||
return buffer;
|
||||
}
|
||||
else if (ArrayBuffer.isView(buffer)) {
|
||||
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
}
|
||||
else if (buffer instanceof ArrayBuffer) {
|
||||
return new Uint8Array(buffer);
|
||||
}
|
||||
else {
|
||||
// ArrayLike<number>
|
||||
return Uint8Array.from(buffer);
|
||||
}
|
||||
}
|
||||
export function createDataView(buffer) {
|
||||
if (buffer instanceof ArrayBuffer) {
|
||||
return new DataView(buffer);
|
||||
}
|
||||
var bufferView = ensureUint8Array(buffer);
|
||||
return new DataView(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);
|
||||
}
|
||||
//# sourceMappingURL=typedArrays.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/typedArrays.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/typedArrays.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"typedArrays.mjs","sourceRoot":"","sources":["../../src/utils/typedArrays.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,MAAsE;IACrG,IAAI,MAAM,YAAY,UAAU,EAAE;QAChC,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACrC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;KAC5E;SAAM,IAAI,MAAM,YAAY,WAAW,EAAE;QACxC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;KAC/B;SAAM;QACL,oBAAoB;QACpB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAChC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAyD;IACtF,IAAI,MAAM,YAAY,WAAW,EAAE;QACjC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;KAC7B;IAED,IAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;AACvF,CAAC"}
|
||||
160
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/utf8.mjs
generated
vendored
Normal file
160
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/utf8.mjs
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
var _a, _b, _c;
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
||||
import { UINT32_MAX } from "./int.mjs";
|
||||
var TEXT_ENCODING_AVAILABLE = (typeof process === "undefined" || ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a["TEXT_ENCODING"]) !== "never") &&
|
||||
typeof TextEncoder !== "undefined" &&
|
||||
typeof TextDecoder !== "undefined";
|
||||
export function utf8Count(str) {
|
||||
var strLength = str.length;
|
||||
var byteLength = 0;
|
||||
var pos = 0;
|
||||
while (pos < strLength) {
|
||||
var value = str.charCodeAt(pos++);
|
||||
if ((value & 0xffffff80) === 0) {
|
||||
// 1-byte
|
||||
byteLength++;
|
||||
continue;
|
||||
}
|
||||
else if ((value & 0xfffff800) === 0) {
|
||||
// 2-bytes
|
||||
byteLength += 2;
|
||||
}
|
||||
else {
|
||||
// handle surrogate pair
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < strLength) {
|
||||
var extra = str.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((value & 0xffff0000) === 0) {
|
||||
// 3-byte
|
||||
byteLength += 3;
|
||||
}
|
||||
else {
|
||||
// 4-byte
|
||||
byteLength += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return byteLength;
|
||||
}
|
||||
export function utf8EncodeJs(str, output, outputOffset) {
|
||||
var strLength = str.length;
|
||||
var offset = outputOffset;
|
||||
var pos = 0;
|
||||
while (pos < strLength) {
|
||||
var value = str.charCodeAt(pos++);
|
||||
if ((value & 0xffffff80) === 0) {
|
||||
// 1-byte
|
||||
output[offset++] = value;
|
||||
continue;
|
||||
}
|
||||
else if ((value & 0xfffff800) === 0) {
|
||||
// 2-bytes
|
||||
output[offset++] = ((value >> 6) & 0x1f) | 0xc0;
|
||||
}
|
||||
else {
|
||||
// handle surrogate pair
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < strLength) {
|
||||
var extra = str.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((value & 0xffff0000) === 0) {
|
||||
// 3-byte
|
||||
output[offset++] = ((value >> 12) & 0x0f) | 0xe0;
|
||||
output[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
||||
}
|
||||
else {
|
||||
// 4-byte
|
||||
output[offset++] = ((value >> 18) & 0x07) | 0xf0;
|
||||
output[offset++] = ((value >> 12) & 0x3f) | 0x80;
|
||||
output[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
||||
}
|
||||
}
|
||||
output[offset++] = (value & 0x3f) | 0x80;
|
||||
}
|
||||
}
|
||||
var sharedTextEncoder = TEXT_ENCODING_AVAILABLE ? new TextEncoder() : undefined;
|
||||
export var TEXT_ENCODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
|
||||
? UINT32_MAX
|
||||
: typeof process !== "undefined" && ((_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b["TEXT_ENCODING"]) !== "force"
|
||||
? 200
|
||||
: 0;
|
||||
function utf8EncodeTEencode(str, output, outputOffset) {
|
||||
output.set(sharedTextEncoder.encode(str), outputOffset);
|
||||
}
|
||||
function utf8EncodeTEencodeInto(str, output, outputOffset) {
|
||||
sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
|
||||
}
|
||||
export var utf8EncodeTE = (sharedTextEncoder === null || sharedTextEncoder === void 0 ? void 0 : sharedTextEncoder.encodeInto) ? utf8EncodeTEencodeInto : utf8EncodeTEencode;
|
||||
var CHUNK_SIZE = 4096;
|
||||
export function utf8DecodeJs(bytes, inputOffset, byteLength) {
|
||||
var offset = inputOffset;
|
||||
var end = offset + byteLength;
|
||||
var units = [];
|
||||
var result = "";
|
||||
while (offset < end) {
|
||||
var byte1 = bytes[offset++];
|
||||
if ((byte1 & 0x80) === 0) {
|
||||
// 1 byte
|
||||
units.push(byte1);
|
||||
}
|
||||
else if ((byte1 & 0xe0) === 0xc0) {
|
||||
// 2 bytes
|
||||
var byte2 = bytes[offset++] & 0x3f;
|
||||
units.push(((byte1 & 0x1f) << 6) | byte2);
|
||||
}
|
||||
else if ((byte1 & 0xf0) === 0xe0) {
|
||||
// 3 bytes
|
||||
var byte2 = bytes[offset++] & 0x3f;
|
||||
var byte3 = bytes[offset++] & 0x3f;
|
||||
units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);
|
||||
}
|
||||
else if ((byte1 & 0xf8) === 0xf0) {
|
||||
// 4 bytes
|
||||
var byte2 = bytes[offset++] & 0x3f;
|
||||
var byte3 = bytes[offset++] & 0x3f;
|
||||
var byte4 = bytes[offset++] & 0x3f;
|
||||
var unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
|
||||
if (unit > 0xffff) {
|
||||
unit -= 0x10000;
|
||||
units.push(((unit >>> 10) & 0x3ff) | 0xd800);
|
||||
unit = 0xdc00 | (unit & 0x3ff);
|
||||
}
|
||||
units.push(unit);
|
||||
}
|
||||
else {
|
||||
units.push(byte1);
|
||||
}
|
||||
if (units.length >= CHUNK_SIZE) {
|
||||
result += String.fromCharCode.apply(String, units);
|
||||
units.length = 0;
|
||||
}
|
||||
}
|
||||
if (units.length > 0) {
|
||||
result += String.fromCharCode.apply(String, units);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var sharedTextDecoder = TEXT_ENCODING_AVAILABLE ? new TextDecoder() : null;
|
||||
export var TEXT_DECODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
|
||||
? UINT32_MAX
|
||||
: typeof process !== "undefined" && ((_c = process === null || process === void 0 ? void 0 : process.env) === null || _c === void 0 ? void 0 : _c["TEXT_DECODER"]) !== "force"
|
||||
? 200
|
||||
: 0;
|
||||
export function utf8DecodeTD(bytes, inputOffset, byteLength) {
|
||||
var stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
|
||||
return sharedTextDecoder.decode(stringBytes);
|
||||
}
|
||||
//# sourceMappingURL=utf8.mjs.map
|
||||
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/utf8.mjs.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+esm/utils/utf8.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2059
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.js
generated
vendored
Normal file
2059
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.js.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.min.js
generated
vendored
Normal file
2
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.min.js.map
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/dist.es5+umd/msgpack.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
APP/nexus-remote/node_modules/@msgpack/msgpack/mod.ts
generated
vendored
Normal file
1
APP/nexus-remote/node_modules/@msgpack/msgpack/mod.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist.es5+esm/index.mjs";
|
||||
100
APP/nexus-remote/node_modules/@msgpack/msgpack/package.json
generated
vendored
Normal file
100
APP/nexus-remote/node_modules/@msgpack/msgpack/package.json
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"name": "@msgpack/msgpack",
|
||||
"version": "2.8.0",
|
||||
"description": "MessagePack for ECMA-262/JavaScript/TypeScript",
|
||||
"author": "The MessagePack community",
|
||||
"license": "ISC",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist.es5+esm/index.mjs",
|
||||
"cdn": "./dist.es5+umd/msgpack.min.js",
|
||||
"unpkg": "./dist.es5+umd/msgpack.min.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "npm publish --dry-run",
|
||||
"prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.json tsconfig.dist.es5+esm.json && ts-node tools/esmify.ts dist.es5+esm/*.js dist.es5+esm/*/*.js",
|
||||
"prepublishOnly": "run-p 'test:dist:*' && npm run test:browser",
|
||||
"clean": "rimraf build dist dist.*",
|
||||
"test": "mocha 'test/**/*.test.ts'",
|
||||
"test:purejs": "TEXT_ENCODING=never mocha 'test/**/*.test.ts'",
|
||||
"test:te": "TEXT_ENCODING=force mocha 'test/**/*.test.ts'",
|
||||
"test:dist:purejs": "TS_NODE_PROJECT=tsconfig.test-dist-es5-purejs.json npm run test:purejs -- --reporter=dot",
|
||||
"test:cover": "npm run cover:clean && npm-run-all 'test:cover:*' && npm run cover:report",
|
||||
"test:cover:purejs": "npx nyc --no-clean npm run test:purejs",
|
||||
"test:cover:te": "npx nyc --no-clean npm run test:te",
|
||||
"test:deno": "deno test test/deno_test.ts",
|
||||
"test:fuzz": "npm exec --yes -- jsfuzz@git+https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz.git --fuzzTime 60 --no-versifier test/decode.jsfuzz.js corpus",
|
||||
"cover:clean": "rimraf .nyc_output coverage/",
|
||||
"cover:report": "npx nyc report --reporter=text-summary --reporter=html --reporter=json",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:browser:firefox": "karma start --single-run --browsers FirefoxHeadless",
|
||||
"test:browser:chrome": "karma start --single-run --browsers ChromeHeadless",
|
||||
"test:watch:browser": "karma start --browsers ChromeHeadless,FirefoxHeadless",
|
||||
"test:watch:nodejs": "mocha -w 'test/**/*.test.ts'",
|
||||
"lint": "eslint --ext .ts src test",
|
||||
"lint:fix": "prettier --loglevel=warn --write 'src/**/*.ts' 'test/**/*.ts' && eslint --fix --ext .ts src test",
|
||||
"lint:print-config": "eslint --print-config .eslintrc.js",
|
||||
"update-dependencies": "npx rimraf node_modules/ package-lock.json ; npm install ; npm audit fix --force ; git restore package.json ; npm install"
|
||||
},
|
||||
"homepage": "https://msgpack.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/msgpack/msgpack-javascript.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/msgpack/msgpack-javascript/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"msgpack",
|
||||
"MessagePack",
|
||||
"serialization",
|
||||
"universal"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bitjourney/check-es-version-webpack-plugin": "latest",
|
||||
"@types/lodash": "latest",
|
||||
"@types/mocha": "latest",
|
||||
"@types/node": "latest",
|
||||
"@typescript-eslint/eslint-plugin": "latest",
|
||||
"@typescript-eslint/parser": "latest",
|
||||
"assert": "latest",
|
||||
"blob-polyfill": "latest",
|
||||
"buffer": "latest",
|
||||
"core-js": "latest",
|
||||
"eslint": "latest",
|
||||
"eslint-config-prettier": "latest",
|
||||
"eslint-plugin-import": "latest",
|
||||
"eslint-plugin-tsdoc": "latest",
|
||||
"ieee754": "latest",
|
||||
"karma": "latest",
|
||||
"karma-chrome-launcher": "latest",
|
||||
"karma-cli": "latest",
|
||||
"karma-firefox-launcher": "latest",
|
||||
"karma-mocha": "latest",
|
||||
"karma-sourcemap-loader": "latest",
|
||||
"karma-webpack": "latest",
|
||||
"lodash": "latest",
|
||||
"mocha": "latest",
|
||||
"msgpack-test-js": "latest",
|
||||
"npm-run-all": "latest",
|
||||
"prettier": "latest",
|
||||
"rimraf": "latest",
|
||||
"ts-loader": "latest",
|
||||
"ts-node": "latest",
|
||||
"tsconfig-paths": "latest",
|
||||
"typescript": "latest",
|
||||
"web-streams-polyfill": "latest",
|
||||
"webpack": "latest",
|
||||
"webpack-cli": "latest"
|
||||
},
|
||||
"files": [
|
||||
"mod.ts",
|
||||
"src/**/*.*",
|
||||
"dist/**/*.*",
|
||||
"dist.es5+umd/**/*.*",
|
||||
"dist.es5+esm/**/*.*"
|
||||
]
|
||||
}
|
||||
76
APP/nexus-remote/node_modules/@msgpack/msgpack/src/CachedKeyDecoder.ts
generated
vendored
Normal file
76
APP/nexus-remote/node_modules/@msgpack/msgpack/src/CachedKeyDecoder.ts
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import { utf8DecodeJs } from "./utils/utf8";
|
||||
|
||||
const DEFAULT_MAX_KEY_LENGTH = 16;
|
||||
const DEFAULT_MAX_LENGTH_PER_KEY = 16;
|
||||
|
||||
export interface KeyDecoder {
|
||||
canBeCached(byteLength: number): boolean;
|
||||
decode(bytes: Uint8Array, inputOffset: number, byteLength: number): string;
|
||||
}
|
||||
interface KeyCacheRecord {
|
||||
readonly bytes: Uint8Array;
|
||||
readonly str: string;
|
||||
}
|
||||
|
||||
export class CachedKeyDecoder implements KeyDecoder {
|
||||
hit = 0;
|
||||
miss = 0;
|
||||
private readonly caches: Array<Array<KeyCacheRecord>>;
|
||||
|
||||
constructor(readonly maxKeyLength = DEFAULT_MAX_KEY_LENGTH, readonly maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
|
||||
// avoid `new Array(N)`, which makes a sparse array,
|
||||
// because a sparse array is typically slower than a non-sparse array.
|
||||
this.caches = [];
|
||||
for (let i = 0; i < this.maxKeyLength; i++) {
|
||||
this.caches.push([]);
|
||||
}
|
||||
}
|
||||
|
||||
public canBeCached(byteLength: number): boolean {
|
||||
return byteLength > 0 && byteLength <= this.maxKeyLength;
|
||||
}
|
||||
|
||||
private find(bytes: Uint8Array, inputOffset: number, byteLength: number): string | null {
|
||||
const records = this.caches[byteLength - 1]!;
|
||||
|
||||
FIND_CHUNK: for (const record of records) {
|
||||
const recordBytes = record.bytes;
|
||||
|
||||
for (let j = 0; j < byteLength; j++) {
|
||||
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
||||
continue FIND_CHUNK;
|
||||
}
|
||||
}
|
||||
return record.str;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private store(bytes: Uint8Array, value: string) {
|
||||
const records = this.caches[bytes.length - 1]!;
|
||||
const record: KeyCacheRecord = { bytes, str: value };
|
||||
|
||||
if (records.length >= this.maxLengthPerKey) {
|
||||
// `records` are full!
|
||||
// Set `record` to an arbitrary position.
|
||||
records[(Math.random() * records.length) | 0] = record;
|
||||
} else {
|
||||
records.push(record);
|
||||
}
|
||||
}
|
||||
|
||||
public decode(bytes: Uint8Array, inputOffset: number, byteLength: number): string {
|
||||
const cachedValue = this.find(bytes, inputOffset, byteLength);
|
||||
if (cachedValue != null) {
|
||||
this.hit++;
|
||||
return cachedValue;
|
||||
}
|
||||
this.miss++;
|
||||
|
||||
const str = utf8DecodeJs(bytes, inputOffset, byteLength);
|
||||
// Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer.
|
||||
const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
|
||||
this.store(slicedCopyOfBytes, str);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
15
APP/nexus-remote/node_modules/@msgpack/msgpack/src/DecodeError.ts
generated
vendored
Normal file
15
APP/nexus-remote/node_modules/@msgpack/msgpack/src/DecodeError.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export class DecodeError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
|
||||
// fix the prototype chain in a cross-platform way
|
||||
const proto: typeof DecodeError.prototype = Object.create(DecodeError.prototype);
|
||||
Object.setPrototypeOf(this, proto);
|
||||
|
||||
Object.defineProperty(this, "name", {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: DecodeError.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
627
APP/nexus-remote/node_modules/@msgpack/msgpack/src/Decoder.ts
generated
vendored
Normal file
627
APP/nexus-remote/node_modules/@msgpack/msgpack/src/Decoder.ts
generated
vendored
Normal file
@@ -0,0 +1,627 @@
|
||||
import { prettyByte } from "./utils/prettyByte";
|
||||
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec";
|
||||
import { getInt64, getUint64, UINT32_MAX } from "./utils/int";
|
||||
import { utf8DecodeJs, TEXT_DECODER_THRESHOLD, utf8DecodeTD } from "./utils/utf8";
|
||||
import { createDataView, ensureUint8Array } from "./utils/typedArrays";
|
||||
import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder";
|
||||
import { DecodeError } from "./DecodeError";
|
||||
|
||||
const enum State {
|
||||
ARRAY,
|
||||
MAP_KEY,
|
||||
MAP_VALUE,
|
||||
}
|
||||
|
||||
type MapKeyType = string | number;
|
||||
|
||||
const isValidMapKeyType = (key: unknown): key is MapKeyType => {
|
||||
const keyType = typeof key;
|
||||
|
||||
return keyType === "string" || keyType === "number";
|
||||
};
|
||||
|
||||
type StackMapState = {
|
||||
type: State.MAP_KEY | State.MAP_VALUE;
|
||||
size: number;
|
||||
key: MapKeyType | null;
|
||||
readCount: number;
|
||||
map: Record<string, unknown>;
|
||||
};
|
||||
|
||||
type StackArrayState = {
|
||||
type: State.ARRAY;
|
||||
size: number;
|
||||
array: Array<unknown>;
|
||||
position: number;
|
||||
};
|
||||
|
||||
type StackState = StackArrayState | StackMapState;
|
||||
|
||||
const HEAD_BYTE_REQUIRED = -1;
|
||||
|
||||
const EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
||||
const EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
||||
|
||||
// IE11: Hack to support IE11.
|
||||
// IE11: Drop this hack and just use RangeError when IE11 is obsolete.
|
||||
export const DataViewIndexOutOfBoundsError: typeof Error = (() => {
|
||||
try {
|
||||
// IE11: The spec says it should throw RangeError,
|
||||
// IE11: but in IE11 it throws TypeError.
|
||||
EMPTY_VIEW.getInt8(0);
|
||||
} catch (e: any) {
|
||||
return e.constructor;
|
||||
}
|
||||
throw new Error("never reached");
|
||||
})();
|
||||
|
||||
const MORE_DATA = new DataViewIndexOutOfBoundsError("Insufficient data");
|
||||
|
||||
const sharedCachedKeyDecoder = new CachedKeyDecoder();
|
||||
|
||||
export class Decoder<ContextType = undefined> {
|
||||
private totalPos = 0;
|
||||
private pos = 0;
|
||||
|
||||
private view = EMPTY_VIEW;
|
||||
private bytes = EMPTY_BYTES;
|
||||
private headByte = HEAD_BYTE_REQUIRED;
|
||||
private readonly stack: Array<StackState> = [];
|
||||
|
||||
public constructor(
|
||||
private readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any,
|
||||
private readonly context: ContextType = undefined as any,
|
||||
private readonly maxStrLength = UINT32_MAX,
|
||||
private readonly maxBinLength = UINT32_MAX,
|
||||
private readonly maxArrayLength = UINT32_MAX,
|
||||
private readonly maxMapLength = UINT32_MAX,
|
||||
private readonly maxExtLength = UINT32_MAX,
|
||||
private readonly keyDecoder: KeyDecoder | null = sharedCachedKeyDecoder,
|
||||
) {}
|
||||
|
||||
private reinitializeState() {
|
||||
this.totalPos = 0;
|
||||
this.headByte = HEAD_BYTE_REQUIRED;
|
||||
this.stack.length = 0;
|
||||
|
||||
// view, bytes, and pos will be re-initialized in setBuffer()
|
||||
}
|
||||
|
||||
private setBuffer(buffer: ArrayLike<number> | BufferSource): void {
|
||||
this.bytes = ensureUint8Array(buffer);
|
||||
this.view = createDataView(this.bytes);
|
||||
this.pos = 0;
|
||||
}
|
||||
|
||||
private appendBuffer(buffer: ArrayLike<number> | BufferSource) {
|
||||
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
||||
this.setBuffer(buffer);
|
||||
} else {
|
||||
const remainingData = this.bytes.subarray(this.pos);
|
||||
const newData = ensureUint8Array(buffer);
|
||||
|
||||
// concat remainingData + newData
|
||||
const newBuffer = new Uint8Array(remainingData.length + newData.length);
|
||||
newBuffer.set(remainingData);
|
||||
newBuffer.set(newData, remainingData.length);
|
||||
this.setBuffer(newBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
private hasRemaining(size: number) {
|
||||
return this.view.byteLength - this.pos >= size;
|
||||
}
|
||||
|
||||
private createExtraByteError(posToShow: number): Error {
|
||||
const { view, pos } = this;
|
||||
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws {@link DecodeError}
|
||||
* @throws {@link RangeError}
|
||||
*/
|
||||
public decode(buffer: ArrayLike<number> | BufferSource): unknown {
|
||||
this.reinitializeState();
|
||||
this.setBuffer(buffer);
|
||||
|
||||
const object = this.doDecodeSync();
|
||||
if (this.hasRemaining(1)) {
|
||||
throw this.createExtraByteError(this.pos);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public *decodeMulti(buffer: ArrayLike<number> | BufferSource): Generator<unknown, void, unknown> {
|
||||
this.reinitializeState();
|
||||
this.setBuffer(buffer);
|
||||
|
||||
while (this.hasRemaining(1)) {
|
||||
yield this.doDecodeSync();
|
||||
}
|
||||
}
|
||||
|
||||
public async decodeAsync(stream: AsyncIterable<ArrayLike<number> | BufferSource>): Promise<unknown> {
|
||||
let decoded = false;
|
||||
let object: unknown;
|
||||
for await (const buffer of stream) {
|
||||
if (decoded) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
|
||||
this.appendBuffer(buffer);
|
||||
|
||||
try {
|
||||
object = this.doDecodeSync();
|
||||
decoded = true;
|
||||
} catch (e) {
|
||||
if (!(e instanceof DataViewIndexOutOfBoundsError)) {
|
||||
throw e; // rethrow
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
this.totalPos += this.pos;
|
||||
}
|
||||
|
||||
if (decoded) {
|
||||
if (this.hasRemaining(1)) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
const { headByte, pos, totalPos } = this;
|
||||
throw new RangeError(
|
||||
`Insufficient data in parsing ${prettyByte(headByte)} at ${totalPos} (${pos} in the current buffer)`,
|
||||
);
|
||||
}
|
||||
|
||||
public decodeArrayStream(
|
||||
stream: AsyncIterable<ArrayLike<number> | BufferSource>,
|
||||
): AsyncGenerator<unknown, void, unknown> {
|
||||
return this.decodeMultiAsync(stream, true);
|
||||
}
|
||||
|
||||
public decodeStream(stream: AsyncIterable<ArrayLike<number> | BufferSource>): AsyncGenerator<unknown, void, unknown> {
|
||||
return this.decodeMultiAsync(stream, false);
|
||||
}
|
||||
|
||||
private async *decodeMultiAsync(stream: AsyncIterable<ArrayLike<number> | BufferSource>, isArray: boolean) {
|
||||
let isArrayHeaderRequired = isArray;
|
||||
let arrayItemsLeft = -1;
|
||||
|
||||
for await (const buffer of stream) {
|
||||
if (isArray && arrayItemsLeft === 0) {
|
||||
throw this.createExtraByteError(this.totalPos);
|
||||
}
|
||||
|
||||
this.appendBuffer(buffer);
|
||||
|
||||
if (isArrayHeaderRequired) {
|
||||
arrayItemsLeft = this.readArraySize();
|
||||
isArrayHeaderRequired = false;
|
||||
this.complete();
|
||||
}
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
yield this.doDecodeSync();
|
||||
if (--arrayItemsLeft === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (!(e instanceof DataViewIndexOutOfBoundsError)) {
|
||||
throw e; // rethrow
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
this.totalPos += this.pos;
|
||||
}
|
||||
}
|
||||
|
||||
private doDecodeSync(): unknown {
|
||||
DECODE: while (true) {
|
||||
const headByte = this.readHeadByte();
|
||||
let object: unknown;
|
||||
|
||||
if (headByte >= 0xe0) {
|
||||
// negative fixint (111x xxxx) 0xe0 - 0xff
|
||||
object = headByte - 0x100;
|
||||
} else if (headByte < 0xc0) {
|
||||
if (headByte < 0x80) {
|
||||
// positive fixint (0xxx xxxx) 0x00 - 0x7f
|
||||
object = headByte;
|
||||
} else if (headByte < 0x90) {
|
||||
// fixmap (1000 xxxx) 0x80 - 0x8f
|
||||
const size = headByte - 0x80;
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = {};
|
||||
}
|
||||
} else if (headByte < 0xa0) {
|
||||
// fixarray (1001 xxxx) 0x90 - 0x9f
|
||||
const size = headByte - 0x90;
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = [];
|
||||
}
|
||||
} else {
|
||||
// fixstr (101x xxxx) 0xa0 - 0xbf
|
||||
const byteLength = headByte - 0xa0;
|
||||
object = this.decodeUtf8String(byteLength, 0);
|
||||
}
|
||||
} else if (headByte === 0xc0) {
|
||||
// nil
|
||||
object = null;
|
||||
} else if (headByte === 0xc2) {
|
||||
// false
|
||||
object = false;
|
||||
} else if (headByte === 0xc3) {
|
||||
// true
|
||||
object = true;
|
||||
} else if (headByte === 0xca) {
|
||||
// float 32
|
||||
object = this.readF32();
|
||||
} else if (headByte === 0xcb) {
|
||||
// float 64
|
||||
object = this.readF64();
|
||||
} else if (headByte === 0xcc) {
|
||||
// uint 8
|
||||
object = this.readU8();
|
||||
} else if (headByte === 0xcd) {
|
||||
// uint 16
|
||||
object = this.readU16();
|
||||
} else if (headByte === 0xce) {
|
||||
// uint 32
|
||||
object = this.readU32();
|
||||
} else if (headByte === 0xcf) {
|
||||
// uint 64
|
||||
object = this.readU64();
|
||||
} else if (headByte === 0xd0) {
|
||||
// int 8
|
||||
object = this.readI8();
|
||||
} else if (headByte === 0xd1) {
|
||||
// int 16
|
||||
object = this.readI16();
|
||||
} else if (headByte === 0xd2) {
|
||||
// int 32
|
||||
object = this.readI32();
|
||||
} else if (headByte === 0xd3) {
|
||||
// int 64
|
||||
object = this.readI64();
|
||||
} else if (headByte === 0xd9) {
|
||||
// str 8
|
||||
const byteLength = this.lookU8();
|
||||
object = this.decodeUtf8String(byteLength, 1);
|
||||
} else if (headByte === 0xda) {
|
||||
// str 16
|
||||
const byteLength = this.lookU16();
|
||||
object = this.decodeUtf8String(byteLength, 2);
|
||||
} else if (headByte === 0xdb) {
|
||||
// str 32
|
||||
const byteLength = this.lookU32();
|
||||
object = this.decodeUtf8String(byteLength, 4);
|
||||
} else if (headByte === 0xdc) {
|
||||
// array 16
|
||||
const size = this.readU16();
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = [];
|
||||
}
|
||||
} else if (headByte === 0xdd) {
|
||||
// array 32
|
||||
const size = this.readU32();
|
||||
if (size !== 0) {
|
||||
this.pushArrayState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = [];
|
||||
}
|
||||
} else if (headByte === 0xde) {
|
||||
// map 16
|
||||
const size = this.readU16();
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = {};
|
||||
}
|
||||
} else if (headByte === 0xdf) {
|
||||
// map 32
|
||||
const size = this.readU32();
|
||||
if (size !== 0) {
|
||||
this.pushMapState(size);
|
||||
this.complete();
|
||||
continue DECODE;
|
||||
} else {
|
||||
object = {};
|
||||
}
|
||||
} else if (headByte === 0xc4) {
|
||||
// bin 8
|
||||
const size = this.lookU8();
|
||||
object = this.decodeBinary(size, 1);
|
||||
} else if (headByte === 0xc5) {
|
||||
// bin 16
|
||||
const size = this.lookU16();
|
||||
object = this.decodeBinary(size, 2);
|
||||
} else if (headByte === 0xc6) {
|
||||
// bin 32
|
||||
const size = this.lookU32();
|
||||
object = this.decodeBinary(size, 4);
|
||||
} else if (headByte === 0xd4) {
|
||||
// fixext 1
|
||||
object = this.decodeExtension(1, 0);
|
||||
} else if (headByte === 0xd5) {
|
||||
// fixext 2
|
||||
object = this.decodeExtension(2, 0);
|
||||
} else if (headByte === 0xd6) {
|
||||
// fixext 4
|
||||
object = this.decodeExtension(4, 0);
|
||||
} else if (headByte === 0xd7) {
|
||||
// fixext 8
|
||||
object = this.decodeExtension(8, 0);
|
||||
} else if (headByte === 0xd8) {
|
||||
// fixext 16
|
||||
object = this.decodeExtension(16, 0);
|
||||
} else if (headByte === 0xc7) {
|
||||
// ext 8
|
||||
const size = this.lookU8();
|
||||
object = this.decodeExtension(size, 1);
|
||||
} else if (headByte === 0xc8) {
|
||||
// ext 16
|
||||
const size = this.lookU16();
|
||||
object = this.decodeExtension(size, 2);
|
||||
} else if (headByte === 0xc9) {
|
||||
// ext 32
|
||||
const size = this.lookU32();
|
||||
object = this.decodeExtension(size, 4);
|
||||
} else {
|
||||
throw new DecodeError(`Unrecognized type byte: ${prettyByte(headByte)}`);
|
||||
}
|
||||
|
||||
this.complete();
|
||||
|
||||
const stack = this.stack;
|
||||
while (stack.length > 0) {
|
||||
// arrays and maps
|
||||
const state = stack[stack.length - 1]!;
|
||||
if (state.type === State.ARRAY) {
|
||||
state.array[state.position] = object;
|
||||
state.position++;
|
||||
if (state.position === state.size) {
|
||||
stack.pop();
|
||||
object = state.array;
|
||||
} else {
|
||||
continue DECODE;
|
||||
}
|
||||
} else if (state.type === State.MAP_KEY) {
|
||||
if (!isValidMapKeyType(object)) {
|
||||
throw new DecodeError("The type of key must be string or number but " + typeof object);
|
||||
}
|
||||
if (object === "__proto__") {
|
||||
throw new DecodeError("The key __proto__ is not allowed");
|
||||
}
|
||||
|
||||
state.key = object;
|
||||
state.type = State.MAP_VALUE;
|
||||
continue DECODE;
|
||||
} else {
|
||||
// it must be `state.type === State.MAP_VALUE` here
|
||||
|
||||
state.map[state.key!] = object;
|
||||
state.readCount++;
|
||||
|
||||
if (state.readCount === state.size) {
|
||||
stack.pop();
|
||||
object = state.map;
|
||||
} else {
|
||||
state.key = null;
|
||||
state.type = State.MAP_KEY;
|
||||
continue DECODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
private readHeadByte(): number {
|
||||
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
||||
this.headByte = this.readU8();
|
||||
// console.log("headByte", prettyByte(this.headByte));
|
||||
}
|
||||
|
||||
return this.headByte;
|
||||
}
|
||||
|
||||
private complete(): void {
|
||||
this.headByte = HEAD_BYTE_REQUIRED;
|
||||
}
|
||||
|
||||
private readArraySize(): number {
|
||||
const headByte = this.readHeadByte();
|
||||
|
||||
switch (headByte) {
|
||||
case 0xdc:
|
||||
return this.readU16();
|
||||
case 0xdd:
|
||||
return this.readU32();
|
||||
default: {
|
||||
if (headByte < 0xa0) {
|
||||
return headByte - 0x90;
|
||||
} else {
|
||||
throw new DecodeError(`Unrecognized array type byte: ${prettyByte(headByte)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private pushMapState(size: number) {
|
||||
if (size > this.maxMapLength) {
|
||||
throw new DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
|
||||
}
|
||||
|
||||
this.stack.push({
|
||||
type: State.MAP_KEY,
|
||||
size,
|
||||
key: null,
|
||||
readCount: 0,
|
||||
map: {},
|
||||
});
|
||||
}
|
||||
|
||||
private pushArrayState(size: number) {
|
||||
if (size > this.maxArrayLength) {
|
||||
throw new DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
|
||||
}
|
||||
|
||||
this.stack.push({
|
||||
type: State.ARRAY,
|
||||
size,
|
||||
array: new Array<unknown>(size),
|
||||
position: 0,
|
||||
});
|
||||
}
|
||||
|
||||
private decodeUtf8String(byteLength: number, headerOffset: number): string {
|
||||
if (byteLength > this.maxStrLength) {
|
||||
throw new DecodeError(
|
||||
`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`,
|
||||
);
|
||||
}
|
||||
|
||||
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
||||
throw MORE_DATA;
|
||||
}
|
||||
|
||||
const offset = this.pos + headerOffset;
|
||||
let object: string;
|
||||
if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
|
||||
object = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
||||
} else if (byteLength > TEXT_DECODER_THRESHOLD) {
|
||||
object = utf8DecodeTD(this.bytes, offset, byteLength);
|
||||
} else {
|
||||
object = utf8DecodeJs(this.bytes, offset, byteLength);
|
||||
}
|
||||
this.pos += headerOffset + byteLength;
|
||||
return object;
|
||||
}
|
||||
|
||||
private stateIsMapKey(): boolean {
|
||||
if (this.stack.length > 0) {
|
||||
const state = this.stack[this.stack.length - 1]!;
|
||||
return state.type === State.MAP_KEY;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private decodeBinary(byteLength: number, headOffset: number): Uint8Array {
|
||||
if (byteLength > this.maxBinLength) {
|
||||
throw new DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
|
||||
}
|
||||
|
||||
if (!this.hasRemaining(byteLength + headOffset)) {
|
||||
throw MORE_DATA;
|
||||
}
|
||||
|
||||
const offset = this.pos + headOffset;
|
||||
const object = this.bytes.subarray(offset, offset + byteLength);
|
||||
this.pos += headOffset + byteLength;
|
||||
return object;
|
||||
}
|
||||
|
||||
private decodeExtension(size: number, headOffset: number): unknown {
|
||||
if (size > this.maxExtLength) {
|
||||
throw new DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
|
||||
}
|
||||
|
||||
const extType = this.view.getInt8(this.pos + headOffset);
|
||||
const data = this.decodeBinary(size, headOffset + 1 /* extType */);
|
||||
return this.extensionCodec.decode(data, extType, this.context);
|
||||
}
|
||||
|
||||
private lookU8() {
|
||||
return this.view.getUint8(this.pos);
|
||||
}
|
||||
|
||||
private lookU16() {
|
||||
return this.view.getUint16(this.pos);
|
||||
}
|
||||
|
||||
private lookU32() {
|
||||
return this.view.getUint32(this.pos);
|
||||
}
|
||||
|
||||
private readU8(): number {
|
||||
const value = this.view.getUint8(this.pos);
|
||||
this.pos++;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readI8(): number {
|
||||
const value = this.view.getInt8(this.pos);
|
||||
this.pos++;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readU16(): number {
|
||||
const value = this.view.getUint16(this.pos);
|
||||
this.pos += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readI16(): number {
|
||||
const value = this.view.getInt16(this.pos);
|
||||
this.pos += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readU32(): number {
|
||||
const value = this.view.getUint32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readI32(): number {
|
||||
const value = this.view.getInt32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readU64(): number {
|
||||
const value = getUint64(this.view, this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readI64(): number {
|
||||
const value = getInt64(this.view, this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readF32() {
|
||||
const value = this.view.getFloat32(this.pos);
|
||||
this.pos += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readF64() {
|
||||
const value = this.view.getFloat64(this.pos);
|
||||
this.pos += 8;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
412
APP/nexus-remote/node_modules/@msgpack/msgpack/src/Encoder.ts
generated
vendored
Normal file
412
APP/nexus-remote/node_modules/@msgpack/msgpack/src/Encoder.ts
generated
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
import { utf8EncodeJs, utf8Count, TEXT_ENCODER_THRESHOLD, utf8EncodeTE } from "./utils/utf8";
|
||||
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec";
|
||||
import { setInt64, setUint64 } from "./utils/int";
|
||||
import { ensureUint8Array } from "./utils/typedArrays";
|
||||
import type { ExtData } from "./ExtData";
|
||||
|
||||
export const DEFAULT_MAX_DEPTH = 100;
|
||||
export const DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
||||
|
||||
export class Encoder<ContextType = undefined> {
|
||||
private pos = 0;
|
||||
private view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
||||
private bytes = new Uint8Array(this.view.buffer);
|
||||
|
||||
public constructor(
|
||||
private readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any,
|
||||
private readonly context: ContextType = undefined as any,
|
||||
private readonly maxDepth = DEFAULT_MAX_DEPTH,
|
||||
private readonly initialBufferSize = DEFAULT_INITIAL_BUFFER_SIZE,
|
||||
private readonly sortKeys = false,
|
||||
private readonly forceFloat32 = false,
|
||||
private readonly ignoreUndefined = false,
|
||||
private readonly forceIntegerToFloat = false,
|
||||
) {}
|
||||
|
||||
private reinitializeState() {
|
||||
this.pos = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
||||
*
|
||||
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
||||
*/
|
||||
public encodeSharedRef(object: unknown): Uint8Array {
|
||||
this.reinitializeState();
|
||||
this.doEncode(object, 1);
|
||||
return this.bytes.subarray(0, this.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
||||
*/
|
||||
public encode(object: unknown): Uint8Array {
|
||||
this.reinitializeState();
|
||||
this.doEncode(object, 1);
|
||||
return this.bytes.slice(0, this.pos);
|
||||
}
|
||||
|
||||
private doEncode(object: unknown, depth: number): void {
|
||||
if (depth > this.maxDepth) {
|
||||
throw new Error(`Too deep objects in depth ${depth}`);
|
||||
}
|
||||
|
||||
if (object == null) {
|
||||
this.encodeNil();
|
||||
} else if (typeof object === "boolean") {
|
||||
this.encodeBoolean(object);
|
||||
} else if (typeof object === "number") {
|
||||
this.encodeNumber(object);
|
||||
} else if (typeof object === "string") {
|
||||
this.encodeString(object);
|
||||
} else {
|
||||
this.encodeObject(object, depth);
|
||||
}
|
||||
}
|
||||
|
||||
private ensureBufferSizeToWrite(sizeToWrite: number) {
|
||||
const requiredSize = this.pos + sizeToWrite;
|
||||
|
||||
if (this.view.byteLength < requiredSize) {
|
||||
this.resizeBuffer(requiredSize * 2);
|
||||
}
|
||||
}
|
||||
|
||||
private resizeBuffer(newSize: number) {
|
||||
const newBuffer = new ArrayBuffer(newSize);
|
||||
const newBytes = new Uint8Array(newBuffer);
|
||||
const newView = new DataView(newBuffer);
|
||||
|
||||
newBytes.set(this.bytes);
|
||||
|
||||
this.view = newView;
|
||||
this.bytes = newBytes;
|
||||
}
|
||||
|
||||
private encodeNil() {
|
||||
this.writeU8(0xc0);
|
||||
}
|
||||
|
||||
private encodeBoolean(object: boolean) {
|
||||
if (object === false) {
|
||||
this.writeU8(0xc2);
|
||||
} else {
|
||||
this.writeU8(0xc3);
|
||||
}
|
||||
}
|
||||
private encodeNumber(object: number) {
|
||||
if (Number.isSafeInteger(object) && !this.forceIntegerToFloat) {
|
||||
if (object >= 0) {
|
||||
if (object < 0x80) {
|
||||
// positive fixint
|
||||
this.writeU8(object);
|
||||
} else if (object < 0x100) {
|
||||
// uint 8
|
||||
this.writeU8(0xcc);
|
||||
this.writeU8(object);
|
||||
} else if (object < 0x10000) {
|
||||
// uint 16
|
||||
this.writeU8(0xcd);
|
||||
this.writeU16(object);
|
||||
} else if (object < 0x100000000) {
|
||||
// uint 32
|
||||
this.writeU8(0xce);
|
||||
this.writeU32(object);
|
||||
} else {
|
||||
// uint 64
|
||||
this.writeU8(0xcf);
|
||||
this.writeU64(object);
|
||||
}
|
||||
} else {
|
||||
if (object >= -0x20) {
|
||||
// negative fixint
|
||||
this.writeU8(0xe0 | (object + 0x20));
|
||||
} else if (object >= -0x80) {
|
||||
// int 8
|
||||
this.writeU8(0xd0);
|
||||
this.writeI8(object);
|
||||
} else if (object >= -0x8000) {
|
||||
// int 16
|
||||
this.writeU8(0xd1);
|
||||
this.writeI16(object);
|
||||
} else if (object >= -0x80000000) {
|
||||
// int 32
|
||||
this.writeU8(0xd2);
|
||||
this.writeI32(object);
|
||||
} else {
|
||||
// int 64
|
||||
this.writeU8(0xd3);
|
||||
this.writeI64(object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// non-integer numbers
|
||||
if (this.forceFloat32) {
|
||||
// float 32
|
||||
this.writeU8(0xca);
|
||||
this.writeF32(object);
|
||||
} else {
|
||||
// float 64
|
||||
this.writeU8(0xcb);
|
||||
this.writeF64(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private writeStringHeader(byteLength: number) {
|
||||
if (byteLength < 32) {
|
||||
// fixstr
|
||||
this.writeU8(0xa0 + byteLength);
|
||||
} else if (byteLength < 0x100) {
|
||||
// str 8
|
||||
this.writeU8(0xd9);
|
||||
this.writeU8(byteLength);
|
||||
} else if (byteLength < 0x10000) {
|
||||
// str 16
|
||||
this.writeU8(0xda);
|
||||
this.writeU16(byteLength);
|
||||
} else if (byteLength < 0x100000000) {
|
||||
// str 32
|
||||
this.writeU8(0xdb);
|
||||
this.writeU32(byteLength);
|
||||
} else {
|
||||
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
||||
}
|
||||
}
|
||||
|
||||
private encodeString(object: string) {
|
||||
const maxHeaderSize = 1 + 4;
|
||||
const strLength = object.length;
|
||||
|
||||
if (strLength > TEXT_ENCODER_THRESHOLD) {
|
||||
const byteLength = utf8Count(object);
|
||||
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
||||
this.writeStringHeader(byteLength);
|
||||
utf8EncodeTE(object, this.bytes, this.pos);
|
||||
this.pos += byteLength;
|
||||
} else {
|
||||
const byteLength = utf8Count(object);
|
||||
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
||||
this.writeStringHeader(byteLength);
|
||||
utf8EncodeJs(object, this.bytes, this.pos);
|
||||
this.pos += byteLength;
|
||||
}
|
||||
}
|
||||
|
||||
private encodeObject(object: unknown, depth: number) {
|
||||
// try to encode objects with custom codec first of non-primitives
|
||||
const ext = this.extensionCodec.tryToEncode(object, this.context);
|
||||
if (ext != null) {
|
||||
this.encodeExtension(ext);
|
||||
} else if (Array.isArray(object)) {
|
||||
this.encodeArray(object, depth);
|
||||
} else if (ArrayBuffer.isView(object)) {
|
||||
this.encodeBinary(object);
|
||||
} else if (typeof object === "object") {
|
||||
this.encodeMap(object as Record<string, unknown>, depth);
|
||||
} else {
|
||||
// symbol, function and other special object come here unless extensionCodec handles them.
|
||||
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
|
||||
}
|
||||
}
|
||||
|
||||
private encodeBinary(object: ArrayBufferView) {
|
||||
const size = object.byteLength;
|
||||
if (size < 0x100) {
|
||||
// bin 8
|
||||
this.writeU8(0xc4);
|
||||
this.writeU8(size);
|
||||
} else if (size < 0x10000) {
|
||||
// bin 16
|
||||
this.writeU8(0xc5);
|
||||
this.writeU16(size);
|
||||
} else if (size < 0x100000000) {
|
||||
// bin 32
|
||||
this.writeU8(0xc6);
|
||||
this.writeU32(size);
|
||||
} else {
|
||||
throw new Error(`Too large binary: ${size}`);
|
||||
}
|
||||
const bytes = ensureUint8Array(object);
|
||||
this.writeU8a(bytes);
|
||||
}
|
||||
|
||||
private encodeArray(object: Array<unknown>, depth: number) {
|
||||
const size = object.length;
|
||||
if (size < 16) {
|
||||
// fixarray
|
||||
this.writeU8(0x90 + size);
|
||||
} else if (size < 0x10000) {
|
||||
// array 16
|
||||
this.writeU8(0xdc);
|
||||
this.writeU16(size);
|
||||
} else if (size < 0x100000000) {
|
||||
// array 32
|
||||
this.writeU8(0xdd);
|
||||
this.writeU32(size);
|
||||
} else {
|
||||
throw new Error(`Too large array: ${size}`);
|
||||
}
|
||||
for (const item of object) {
|
||||
this.doEncode(item, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private countWithoutUndefined(object: Record<string, unknown>, keys: ReadonlyArray<string>): number {
|
||||
let count = 0;
|
||||
|
||||
for (const key of keys) {
|
||||
if (object[key] !== undefined) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private encodeMap(object: Record<string, unknown>, depth: number) {
|
||||
const keys = Object.keys(object);
|
||||
if (this.sortKeys) {
|
||||
keys.sort();
|
||||
}
|
||||
|
||||
const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
|
||||
|
||||
if (size < 16) {
|
||||
// fixmap
|
||||
this.writeU8(0x80 + size);
|
||||
} else if (size < 0x10000) {
|
||||
// map 16
|
||||
this.writeU8(0xde);
|
||||
this.writeU16(size);
|
||||
} else if (size < 0x100000000) {
|
||||
// map 32
|
||||
this.writeU8(0xdf);
|
||||
this.writeU32(size);
|
||||
} else {
|
||||
throw new Error(`Too large map object: ${size}`);
|
||||
}
|
||||
|
||||
for (const key of keys) {
|
||||
const value = object[key];
|
||||
|
||||
if (!(this.ignoreUndefined && value === undefined)) {
|
||||
this.encodeString(key);
|
||||
this.doEncode(value, depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private encodeExtension(ext: ExtData) {
|
||||
const size = ext.data.length;
|
||||
if (size === 1) {
|
||||
// fixext 1
|
||||
this.writeU8(0xd4);
|
||||
} else if (size === 2) {
|
||||
// fixext 2
|
||||
this.writeU8(0xd5);
|
||||
} else if (size === 4) {
|
||||
// fixext 4
|
||||
this.writeU8(0xd6);
|
||||
} else if (size === 8) {
|
||||
// fixext 8
|
||||
this.writeU8(0xd7);
|
||||
} else if (size === 16) {
|
||||
// fixext 16
|
||||
this.writeU8(0xd8);
|
||||
} else if (size < 0x100) {
|
||||
// ext 8
|
||||
this.writeU8(0xc7);
|
||||
this.writeU8(size);
|
||||
} else if (size < 0x10000) {
|
||||
// ext 16
|
||||
this.writeU8(0xc8);
|
||||
this.writeU16(size);
|
||||
} else if (size < 0x100000000) {
|
||||
// ext 32
|
||||
this.writeU8(0xc9);
|
||||
this.writeU32(size);
|
||||
} else {
|
||||
throw new Error(`Too large extension object: ${size}`);
|
||||
}
|
||||
this.writeI8(ext.type);
|
||||
this.writeU8a(ext.data);
|
||||
}
|
||||
|
||||
private writeU8(value: number) {
|
||||
this.ensureBufferSizeToWrite(1);
|
||||
|
||||
this.view.setUint8(this.pos, value);
|
||||
this.pos++;
|
||||
}
|
||||
|
||||
private writeU8a(values: ArrayLike<number>) {
|
||||
const size = values.length;
|
||||
this.ensureBufferSizeToWrite(size);
|
||||
|
||||
this.bytes.set(values, this.pos);
|
||||
this.pos += size;
|
||||
}
|
||||
|
||||
private writeI8(value: number) {
|
||||
this.ensureBufferSizeToWrite(1);
|
||||
|
||||
this.view.setInt8(this.pos, value);
|
||||
this.pos++;
|
||||
}
|
||||
|
||||
private writeU16(value: number) {
|
||||
this.ensureBufferSizeToWrite(2);
|
||||
|
||||
this.view.setUint16(this.pos, value);
|
||||
this.pos += 2;
|
||||
}
|
||||
|
||||
private writeI16(value: number) {
|
||||
this.ensureBufferSizeToWrite(2);
|
||||
|
||||
this.view.setInt16(this.pos, value);
|
||||
this.pos += 2;
|
||||
}
|
||||
|
||||
private writeU32(value: number) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
|
||||
this.view.setUint32(this.pos, value);
|
||||
this.pos += 4;
|
||||
}
|
||||
|
||||
private writeI32(value: number) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
|
||||
this.view.setInt32(this.pos, value);
|
||||
this.pos += 4;
|
||||
}
|
||||
|
||||
private writeF32(value: number) {
|
||||
this.ensureBufferSizeToWrite(4);
|
||||
this.view.setFloat32(this.pos, value);
|
||||
this.pos += 4;
|
||||
}
|
||||
|
||||
private writeF64(value: number) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
this.view.setFloat64(this.pos, value);
|
||||
this.pos += 8;
|
||||
}
|
||||
|
||||
private writeU64(value: number) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
|
||||
setUint64(this.view, this.pos, value);
|
||||
this.pos += 8;
|
||||
}
|
||||
|
||||
private writeI64(value: number) {
|
||||
this.ensureBufferSizeToWrite(8);
|
||||
|
||||
setInt64(this.view, this.pos, value);
|
||||
this.pos += 8;
|
||||
}
|
||||
}
|
||||
6
APP/nexus-remote/node_modules/@msgpack/msgpack/src/ExtData.ts
generated
vendored
Normal file
6
APP/nexus-remote/node_modules/@msgpack/msgpack/src/ExtData.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* ExtData is used to handle Extension Types that are not registered to ExtensionCodec.
|
||||
*/
|
||||
export class ExtData {
|
||||
constructor(readonly type: number, readonly data: Uint8Array) {}
|
||||
}
|
||||
104
APP/nexus-remote/node_modules/@msgpack/msgpack/src/ExtensionCodec.ts
generated
vendored
Normal file
104
APP/nexus-remote/node_modules/@msgpack/msgpack/src/ExtensionCodec.ts
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// ExtensionCodec to handle MessagePack extensions
|
||||
|
||||
import { ExtData } from "./ExtData";
|
||||
import { timestampExtension } from "./timestamp";
|
||||
|
||||
export type ExtensionDecoderType<ContextType> = (
|
||||
data: Uint8Array,
|
||||
extensionType: number,
|
||||
context: ContextType,
|
||||
) => unknown;
|
||||
|
||||
export type ExtensionEncoderType<ContextType> = (input: unknown, context: ContextType) => Uint8Array | null;
|
||||
|
||||
// immutable interface to ExtensionCodec
|
||||
export type ExtensionCodecType<ContextType> = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
__brand?: ContextType;
|
||||
tryToEncode(object: unknown, context: ContextType): ExtData | null;
|
||||
decode(data: Uint8Array, extType: number, context: ContextType): unknown;
|
||||
};
|
||||
|
||||
export class ExtensionCodec<ContextType = undefined> implements ExtensionCodecType<ContextType> {
|
||||
public static readonly defaultCodec: ExtensionCodecType<undefined> = new ExtensionCodec();
|
||||
|
||||
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
||||
// this will make type errors a lot more clear
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
__brand?: ContextType;
|
||||
|
||||
// built-in extensions
|
||||
private readonly builtInEncoders: Array<ExtensionEncoderType<ContextType> | undefined | null> = [];
|
||||
private readonly builtInDecoders: Array<ExtensionDecoderType<ContextType> | undefined | null> = [];
|
||||
|
||||
// custom extensions
|
||||
private readonly encoders: Array<ExtensionEncoderType<ContextType> | undefined | null> = [];
|
||||
private readonly decoders: Array<ExtensionDecoderType<ContextType> | undefined | null> = [];
|
||||
|
||||
public constructor() {
|
||||
this.register(timestampExtension);
|
||||
}
|
||||
|
||||
public register({
|
||||
type,
|
||||
encode,
|
||||
decode,
|
||||
}: {
|
||||
type: number;
|
||||
encode: ExtensionEncoderType<ContextType>;
|
||||
decode: ExtensionDecoderType<ContextType>;
|
||||
}): void {
|
||||
if (type >= 0) {
|
||||
// custom extensions
|
||||
this.encoders[type] = encode;
|
||||
this.decoders[type] = decode;
|
||||
} else {
|
||||
// built-in extensions
|
||||
const index = 1 + type;
|
||||
this.builtInEncoders[index] = encode;
|
||||
this.builtInDecoders[index] = decode;
|
||||
}
|
||||
}
|
||||
|
||||
public tryToEncode(object: unknown, context: ContextType): ExtData | null {
|
||||
// built-in extensions
|
||||
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
||||
const encodeExt = this.builtInEncoders[i];
|
||||
if (encodeExt != null) {
|
||||
const data = encodeExt(object, context);
|
||||
if (data != null) {
|
||||
const type = -1 - i;
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// custom extensions
|
||||
for (let i = 0; i < this.encoders.length; i++) {
|
||||
const encodeExt = this.encoders[i];
|
||||
if (encodeExt != null) {
|
||||
const data = encodeExt(object, context);
|
||||
if (data != null) {
|
||||
const type = i;
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (object instanceof ExtData) {
|
||||
// to keep ExtData as is
|
||||
return object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public decode(data: Uint8Array, type: number, context: ContextType): unknown {
|
||||
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
||||
if (decodeExt) {
|
||||
return decodeExt(data, type, context);
|
||||
} else {
|
||||
// decode() does not fail, returns ExtData instead.
|
||||
return new ExtData(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
APP/nexus-remote/node_modules/@msgpack/msgpack/src/context.ts
generated
vendored
Normal file
14
APP/nexus-remote/node_modules/@msgpack/msgpack/src/context.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
|
||||
export type SplitTypes<T, U> = U extends T ? (Exclude<T, U> extends never ? T : Exclude<T, U>) : T;
|
||||
|
||||
export type SplitUndefined<T> = SplitTypes<T, undefined>;
|
||||
|
||||
export type ContextOf<ContextType> = ContextType extends undefined
|
||||
? {}
|
||||
: {
|
||||
/**
|
||||
* Custom user-defined data, read/writable
|
||||
*/
|
||||
context: ContextType;
|
||||
};
|
||||
91
APP/nexus-remote/node_modules/@msgpack/msgpack/src/decode.ts
generated
vendored
Normal file
91
APP/nexus-remote/node_modules/@msgpack/msgpack/src/decode.ts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import { Decoder } from "./Decoder";
|
||||
import type { ExtensionCodecType } from "./ExtensionCodec";
|
||||
import type { ContextOf, SplitUndefined } from "./context";
|
||||
|
||||
export type DecodeOptions<ContextType = undefined> = Readonly<
|
||||
Partial<{
|
||||
extensionCodec: ExtensionCodecType<ContextType>;
|
||||
|
||||
/**
|
||||
* Maximum string length.
|
||||
*
|
||||
* Defaults to 4_294_967_295 (UINT32_MAX).
|
||||
*/
|
||||
maxStrLength: number;
|
||||
/**
|
||||
* Maximum binary length.
|
||||
*
|
||||
* Defaults to 4_294_967_295 (UINT32_MAX).
|
||||
*/
|
||||
maxBinLength: number;
|
||||
/**
|
||||
* Maximum array length.
|
||||
*
|
||||
* Defaults to 4_294_967_295 (UINT32_MAX).
|
||||
*/
|
||||
maxArrayLength: number;
|
||||
/**
|
||||
* Maximum map length.
|
||||
*
|
||||
* Defaults to 4_294_967_295 (UINT32_MAX).
|
||||
*/
|
||||
maxMapLength: number;
|
||||
/**
|
||||
* Maximum extension length.
|
||||
*
|
||||
* Defaults to 4_294_967_295 (UINT32_MAX).
|
||||
*/
|
||||
maxExtLength: number;
|
||||
}>
|
||||
> &
|
||||
ContextOf<ContextType>;
|
||||
|
||||
export const defaultDecodeOptions: DecodeOptions = {};
|
||||
|
||||
/**
|
||||
* It decodes a single MessagePack object in a buffer.
|
||||
*
|
||||
* This is a synchronous decoding function.
|
||||
* See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
|
||||
*
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decode<ContextType = undefined>(
|
||||
buffer: ArrayLike<number> | BufferSource,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): unknown {
|
||||
const decoder = new Decoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxStrLength,
|
||||
options.maxBinLength,
|
||||
options.maxArrayLength,
|
||||
options.maxMapLength,
|
||||
options.maxExtLength,
|
||||
);
|
||||
return decoder.decode(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* It decodes multiple MessagePack objects in a buffer.
|
||||
* This is corresponding to {@link decodeMultiStream()}.
|
||||
*
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeMulti<ContextType = undefined>(
|
||||
buffer: ArrayLike<number> | BufferSource,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): Generator<unknown, void, unknown> {
|
||||
const decoder = new Decoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxStrLength,
|
||||
options.maxBinLength,
|
||||
options.maxArrayLength,
|
||||
options.maxMapLength,
|
||||
options.maxExtLength,
|
||||
);
|
||||
return decoder.decodeMulti(buffer);
|
||||
}
|
||||
84
APP/nexus-remote/node_modules/@msgpack/msgpack/src/decodeAsync.ts
generated
vendored
Normal file
84
APP/nexus-remote/node_modules/@msgpack/msgpack/src/decodeAsync.ts
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import { Decoder } from "./Decoder";
|
||||
import { ensureAsyncIterable } from "./utils/stream";
|
||||
import { defaultDecodeOptions } from "./decode";
|
||||
import type { ReadableStreamLike } from "./utils/stream";
|
||||
import type { DecodeOptions } from "./decode";
|
||||
import type { SplitUndefined } from "./context";
|
||||
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export async function decodeAsync<ContextType>(
|
||||
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): Promise<unknown> {
|
||||
const stream = ensureAsyncIterable(streamLike);
|
||||
|
||||
const decoder = new Decoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxStrLength,
|
||||
options.maxBinLength,
|
||||
options.maxArrayLength,
|
||||
options.maxMapLength,
|
||||
options.maxExtLength,
|
||||
);
|
||||
return decoder.decodeAsync(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeArrayStream<ContextType>(
|
||||
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): AsyncGenerator<unknown, void, unknown> {
|
||||
const stream = ensureAsyncIterable(streamLike);
|
||||
|
||||
const decoder = new Decoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxStrLength,
|
||||
options.maxBinLength,
|
||||
options.maxArrayLength,
|
||||
options.maxMapLength,
|
||||
options.maxExtLength,
|
||||
);
|
||||
|
||||
return decoder.decodeArrayStream(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
||||
* @throws {@link DecodeError} if the buffer contains invalid data.
|
||||
*/
|
||||
export function decodeMultiStream<ContextType>(
|
||||
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): AsyncGenerator<unknown, void, unknown> {
|
||||
const stream = ensureAsyncIterable(streamLike);
|
||||
|
||||
const decoder = new Decoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxStrLength,
|
||||
options.maxBinLength,
|
||||
options.maxArrayLength,
|
||||
options.maxMapLength,
|
||||
options.maxExtLength,
|
||||
);
|
||||
|
||||
return decoder.decodeStream(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link decodeMultiStream()} instead.
|
||||
*/
|
||||
export function decodeStream<ContextType>(
|
||||
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
|
||||
options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,
|
||||
): AsyncGenerator<unknown, void, unknown> {
|
||||
return decodeMultiStream(streamLike, options);
|
||||
}
|
||||
81
APP/nexus-remote/node_modules/@msgpack/msgpack/src/encode.ts
generated
vendored
Normal file
81
APP/nexus-remote/node_modules/@msgpack/msgpack/src/encode.ts
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Encoder } from "./Encoder";
|
||||
import type { ExtensionCodecType } from "./ExtensionCodec";
|
||||
import type { ContextOf, SplitUndefined } from "./context";
|
||||
|
||||
export type EncodeOptions<ContextType = undefined> = Partial<
|
||||
Readonly<{
|
||||
extensionCodec: ExtensionCodecType<ContextType>;
|
||||
|
||||
/**
|
||||
* The maximum depth in nested objects and arrays.
|
||||
*
|
||||
* Defaults to 100.
|
||||
*/
|
||||
maxDepth: number;
|
||||
|
||||
/**
|
||||
* The initial size of the internal buffer.
|
||||
*
|
||||
* Defaults to 2048.
|
||||
*/
|
||||
initialBufferSize: number;
|
||||
|
||||
/**
|
||||
* If `true`, the keys of an object is sorted. In other words, the encoded
|
||||
* binary is canonical and thus comparable to another encoded binary.
|
||||
*
|
||||
* Defaults to `false`. If enabled, it spends more time in encoding objects.
|
||||
*/
|
||||
sortKeys: boolean;
|
||||
/**
|
||||
* If `true`, non-integer numbers are encoded in float32, not in float64 (the default).
|
||||
*
|
||||
* Only use it if precisions don't matter.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
forceFloat32: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, an object property with `undefined` value are ignored.
|
||||
* e.g. `{ foo: undefined }` will be encoded as `{}`, as `JSON.stringify()` does.
|
||||
*
|
||||
* Defaults to `false`. If enabled, it spends more time in encoding objects.
|
||||
*/
|
||||
ignoreUndefined: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, integer numbers are encoded as floating point numbers,
|
||||
* with the `forceFloat32` option taken into account.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
forceIntegerToFloat: boolean;
|
||||
}>
|
||||
> &
|
||||
ContextOf<ContextType>;
|
||||
|
||||
const defaultEncodeOptions: EncodeOptions = {};
|
||||
|
||||
/**
|
||||
* It encodes `value` in the MessagePack format and
|
||||
* returns a byte buffer.
|
||||
*
|
||||
* The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`.
|
||||
*/
|
||||
export function encode<ContextType = undefined>(
|
||||
value: unknown,
|
||||
options: EncodeOptions<SplitUndefined<ContextType>> = defaultEncodeOptions as any,
|
||||
): Uint8Array {
|
||||
const encoder = new Encoder(
|
||||
options.extensionCodec,
|
||||
(options as typeof options & { context: any }).context,
|
||||
options.maxDepth,
|
||||
options.initialBufferSize,
|
||||
options.sortKeys,
|
||||
options.forceFloat32,
|
||||
options.ignoreUndefined,
|
||||
options.forceIntegerToFloat,
|
||||
);
|
||||
return encoder.encodeSharedRef(value);
|
||||
}
|
||||
47
APP/nexus-remote/node_modules/@msgpack/msgpack/src/index.ts
generated
vendored
Normal file
47
APP/nexus-remote/node_modules/@msgpack/msgpack/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Main Functions:
|
||||
|
||||
import { encode } from "./encode";
|
||||
export { encode };
|
||||
import type { EncodeOptions } from "./encode";
|
||||
export type { EncodeOptions };
|
||||
|
||||
import { decode, decodeMulti } from "./decode";
|
||||
export { decode, decodeMulti };
|
||||
import type { DecodeOptions } from "./decode";
|
||||
export { DecodeOptions };
|
||||
|
||||
import { decodeAsync, decodeArrayStream, decodeMultiStream, decodeStream } from "./decodeAsync";
|
||||
export { decodeAsync, decodeArrayStream, decodeMultiStream, decodeStream };
|
||||
|
||||
import { Decoder, DataViewIndexOutOfBoundsError } from "./Decoder";
|
||||
import { DecodeError } from "./DecodeError";
|
||||
export { Decoder, DecodeError, DataViewIndexOutOfBoundsError };
|
||||
|
||||
import { Encoder } from "./Encoder";
|
||||
export { Encoder };
|
||||
|
||||
// Utilitiies for Extension Types:
|
||||
|
||||
import { ExtensionCodec } from "./ExtensionCodec";
|
||||
export { ExtensionCodec };
|
||||
import type { ExtensionCodecType, ExtensionDecoderType, ExtensionEncoderType } from "./ExtensionCodec";
|
||||
export type { ExtensionCodecType, ExtensionDecoderType, ExtensionEncoderType };
|
||||
import { ExtData } from "./ExtData";
|
||||
export { ExtData };
|
||||
|
||||
import {
|
||||
EXT_TIMESTAMP,
|
||||
encodeDateToTimeSpec,
|
||||
encodeTimeSpecToTimestamp,
|
||||
decodeTimestampToTimeSpec,
|
||||
encodeTimestampExtension,
|
||||
decodeTimestampExtension,
|
||||
} from "./timestamp";
|
||||
export {
|
||||
EXT_TIMESTAMP,
|
||||
encodeDateToTimeSpec,
|
||||
encodeTimeSpecToTimestamp,
|
||||
decodeTimestampToTimeSpec,
|
||||
encodeTimestampExtension,
|
||||
decodeTimestampExtension,
|
||||
};
|
||||
108
APP/nexus-remote/node_modules/@msgpack/msgpack/src/timestamp.ts
generated
vendored
Normal file
108
APP/nexus-remote/node_modules/@msgpack/msgpack/src/timestamp.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
// https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
|
||||
import { DecodeError } from "./DecodeError";
|
||||
import { getInt64, setInt64 } from "./utils/int";
|
||||
|
||||
export const EXT_TIMESTAMP = -1;
|
||||
|
||||
export type TimeSpec = {
|
||||
sec: number;
|
||||
nsec: number;
|
||||
};
|
||||
|
||||
const TIMESTAMP32_MAX_SEC = 0x100000000 - 1; // 32-bit unsigned int
|
||||
const TIMESTAMP64_MAX_SEC = 0x400000000 - 1; // 34-bit unsigned int
|
||||
|
||||
export function encodeTimeSpecToTimestamp({ sec, nsec }: TimeSpec): Uint8Array {
|
||||
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
||||
// Here sec >= 0 && nsec >= 0
|
||||
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
||||
// timestamp 32 = { sec32 (unsigned) }
|
||||
const rv = new Uint8Array(4);
|
||||
const view = new DataView(rv.buffer);
|
||||
view.setUint32(0, sec);
|
||||
return rv;
|
||||
} else {
|
||||
// timestamp 64 = { nsec30 (unsigned), sec34 (unsigned) }
|
||||
const secHigh = sec / 0x100000000;
|
||||
const secLow = sec & 0xffffffff;
|
||||
const rv = new Uint8Array(8);
|
||||
const view = new DataView(rv.buffer);
|
||||
// nsec30 | secHigh2
|
||||
view.setUint32(0, (nsec << 2) | (secHigh & 0x3));
|
||||
// secLow32
|
||||
view.setUint32(4, secLow);
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
// timestamp 96 = { nsec32 (unsigned), sec64 (signed) }
|
||||
const rv = new Uint8Array(12);
|
||||
const view = new DataView(rv.buffer);
|
||||
view.setUint32(0, nsec);
|
||||
setInt64(view, 4, sec);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
export function encodeDateToTimeSpec(date: Date): TimeSpec {
|
||||
const msec = date.getTime();
|
||||
const sec = Math.floor(msec / 1e3);
|
||||
const nsec = (msec - sec * 1e3) * 1e6;
|
||||
|
||||
// Normalizes { sec, nsec } to ensure nsec is unsigned.
|
||||
const nsecInSec = Math.floor(nsec / 1e9);
|
||||
return {
|
||||
sec: sec + nsecInSec,
|
||||
nsec: nsec - nsecInSec * 1e9,
|
||||
};
|
||||
}
|
||||
|
||||
export function encodeTimestampExtension(object: unknown): Uint8Array | null {
|
||||
if (object instanceof Date) {
|
||||
const timeSpec = encodeDateToTimeSpec(object);
|
||||
return encodeTimeSpecToTimestamp(timeSpec);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function decodeTimestampToTimeSpec(data: Uint8Array): TimeSpec {
|
||||
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
||||
|
||||
// data may be 32, 64, or 96 bits
|
||||
switch (data.byteLength) {
|
||||
case 4: {
|
||||
// timestamp 32 = { sec32 }
|
||||
const sec = view.getUint32(0);
|
||||
const nsec = 0;
|
||||
return { sec, nsec };
|
||||
}
|
||||
case 8: {
|
||||
// timestamp 64 = { nsec30, sec34 }
|
||||
const nsec30AndSecHigh2 = view.getUint32(0);
|
||||
const secLow32 = view.getUint32(4);
|
||||
const sec = (nsec30AndSecHigh2 & 0x3) * 0x100000000 + secLow32;
|
||||
const nsec = nsec30AndSecHigh2 >>> 2;
|
||||
return { sec, nsec };
|
||||
}
|
||||
case 12: {
|
||||
// timestamp 96 = { nsec32 (unsigned), sec64 (signed) }
|
||||
|
||||
const sec = getInt64(view, 4);
|
||||
const nsec = view.getUint32(0);
|
||||
return { sec, nsec };
|
||||
}
|
||||
default:
|
||||
throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function decodeTimestampExtension(data: Uint8Array): Date {
|
||||
const timeSpec = decodeTimestampToTimeSpec(data);
|
||||
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
||||
}
|
||||
|
||||
export const timestampExtension = {
|
||||
type: EXT_TIMESTAMP,
|
||||
encode: encodeTimestampExtension,
|
||||
decode: decodeTimestampExtension,
|
||||
};
|
||||
32
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/int.ts
generated
vendored
Normal file
32
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/int.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Integer Utility
|
||||
|
||||
export const UINT32_MAX = 0xffff_ffff;
|
||||
|
||||
// DataView extension to handle int64 / uint64,
|
||||
// where the actual range is 53-bits integer (a.k.a. safe integer)
|
||||
|
||||
export function setUint64(view: DataView, offset: number, value: number): void {
|
||||
const high = value / 0x1_0000_0000;
|
||||
const low = value; // high bits are truncated by DataView
|
||||
view.setUint32(offset, high);
|
||||
view.setUint32(offset + 4, low);
|
||||
}
|
||||
|
||||
export function setInt64(view: DataView, offset: number, value: number): void {
|
||||
const high = Math.floor(value / 0x1_0000_0000);
|
||||
const low = value; // high bits are truncated by DataView
|
||||
view.setUint32(offset, high);
|
||||
view.setUint32(offset + 4, low);
|
||||
}
|
||||
|
||||
export function getInt64(view: DataView, offset: number): number {
|
||||
const high = view.getInt32(offset);
|
||||
const low = view.getUint32(offset + 4);
|
||||
return high * 0x1_0000_0000 + low;
|
||||
}
|
||||
|
||||
export function getUint64(view: DataView, offset: number): number {
|
||||
const high = view.getUint32(offset);
|
||||
const low = view.getUint32(offset + 4);
|
||||
return high * 0x1_0000_0000 + low;
|
||||
}
|
||||
3
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/prettyByte.ts
generated
vendored
Normal file
3
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/prettyByte.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function prettyByte(byte: number): string {
|
||||
return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
|
||||
}
|
||||
42
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/stream.ts
generated
vendored
Normal file
42
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/stream.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// utility for whatwg streams
|
||||
|
||||
// The living standard of whatwg streams says
|
||||
// ReadableStream is also AsyncIterable, but
|
||||
// as of June 2019, no browser implements it.
|
||||
// See https://streams.spec.whatwg.org/ for details
|
||||
export type ReadableStreamLike<T> = AsyncIterable<T> | ReadableStream<T>;
|
||||
|
||||
export function isAsyncIterable<T>(object: ReadableStreamLike<T>): object is AsyncIterable<T> {
|
||||
return (object as any)[Symbol.asyncIterator] != null;
|
||||
}
|
||||
|
||||
function assertNonNull<T>(value: T | null | undefined): asserts value is T {
|
||||
if (value == null) {
|
||||
throw new Error("Assertion Failure: value must not be null nor undefined");
|
||||
}
|
||||
}
|
||||
|
||||
export async function* asyncIterableFromStream<T>(stream: ReadableStream<T>): AsyncIterable<T> {
|
||||
const reader = stream.getReader();
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
assertNonNull(value);
|
||||
yield value;
|
||||
}
|
||||
} finally {
|
||||
reader.releaseLock();
|
||||
}
|
||||
}
|
||||
|
||||
export function ensureAsyncIterable<T>(streamLike: ReadableStreamLike<T>): AsyncIterable<T> {
|
||||
if (isAsyncIterable(streamLike)) {
|
||||
return streamLike;
|
||||
} else {
|
||||
return asyncIterableFromStream(streamLike);
|
||||
}
|
||||
}
|
||||
21
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/typedArrays.ts
generated
vendored
Normal file
21
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/typedArrays.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export function ensureUint8Array(buffer: ArrayLike<number> | Uint8Array | ArrayBufferView | ArrayBuffer): Uint8Array {
|
||||
if (buffer instanceof Uint8Array) {
|
||||
return buffer;
|
||||
} else if (ArrayBuffer.isView(buffer)) {
|
||||
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
} else if (buffer instanceof ArrayBuffer) {
|
||||
return new Uint8Array(buffer);
|
||||
} else {
|
||||
// ArrayLike<number>
|
||||
return Uint8Array.from(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
export function createDataView(buffer: ArrayLike<number> | ArrayBufferView | ArrayBuffer): DataView {
|
||||
if (buffer instanceof ArrayBuffer) {
|
||||
return new DataView(buffer);
|
||||
}
|
||||
|
||||
const bufferView = ensureUint8Array(buffer);
|
||||
return new DataView(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);
|
||||
}
|
||||
170
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/utf8.ts
generated
vendored
Normal file
170
APP/nexus-remote/node_modules/@msgpack/msgpack/src/utils/utf8.ts
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
||||
import { UINT32_MAX } from "./int";
|
||||
|
||||
const TEXT_ENCODING_AVAILABLE =
|
||||
(typeof process === "undefined" || process?.env?.["TEXT_ENCODING"] !== "never") &&
|
||||
typeof TextEncoder !== "undefined" &&
|
||||
typeof TextDecoder !== "undefined";
|
||||
|
||||
export function utf8Count(str: string): number {
|
||||
const strLength = str.length;
|
||||
|
||||
let byteLength = 0;
|
||||
let pos = 0;
|
||||
while (pos < strLength) {
|
||||
let value = str.charCodeAt(pos++);
|
||||
|
||||
if ((value & 0xffffff80) === 0) {
|
||||
// 1-byte
|
||||
byteLength++;
|
||||
continue;
|
||||
} else if ((value & 0xfffff800) === 0) {
|
||||
// 2-bytes
|
||||
byteLength += 2;
|
||||
} else {
|
||||
// handle surrogate pair
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < strLength) {
|
||||
const extra = str.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((value & 0xffff0000) === 0) {
|
||||
// 3-byte
|
||||
byteLength += 3;
|
||||
} else {
|
||||
// 4-byte
|
||||
byteLength += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return byteLength;
|
||||
}
|
||||
|
||||
export function utf8EncodeJs(str: string, output: Uint8Array, outputOffset: number): void {
|
||||
const strLength = str.length;
|
||||
let offset = outputOffset;
|
||||
let pos = 0;
|
||||
while (pos < strLength) {
|
||||
let value = str.charCodeAt(pos++);
|
||||
|
||||
if ((value & 0xffffff80) === 0) {
|
||||
// 1-byte
|
||||
output[offset++] = value;
|
||||
continue;
|
||||
} else if ((value & 0xfffff800) === 0) {
|
||||
// 2-bytes
|
||||
output[offset++] = ((value >> 6) & 0x1f) | 0xc0;
|
||||
} else {
|
||||
// handle surrogate pair
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < strLength) {
|
||||
const extra = str.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((value & 0xffff0000) === 0) {
|
||||
// 3-byte
|
||||
output[offset++] = ((value >> 12) & 0x0f) | 0xe0;
|
||||
output[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
||||
} else {
|
||||
// 4-byte
|
||||
output[offset++] = ((value >> 18) & 0x07) | 0xf0;
|
||||
output[offset++] = ((value >> 12) & 0x3f) | 0x80;
|
||||
output[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
output[offset++] = (value & 0x3f) | 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
const sharedTextEncoder = TEXT_ENCODING_AVAILABLE ? new TextEncoder() : undefined;
|
||||
export const TEXT_ENCODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
|
||||
? UINT32_MAX
|
||||
: typeof process !== "undefined" && process?.env?.["TEXT_ENCODING"] !== "force"
|
||||
? 200
|
||||
: 0;
|
||||
|
||||
function utf8EncodeTEencode(str: string, output: Uint8Array, outputOffset: number): void {
|
||||
output.set(sharedTextEncoder!.encode(str), outputOffset);
|
||||
}
|
||||
|
||||
function utf8EncodeTEencodeInto(str: string, output: Uint8Array, outputOffset: number): void {
|
||||
sharedTextEncoder!.encodeInto(str, output.subarray(outputOffset));
|
||||
}
|
||||
|
||||
export const utf8EncodeTE = sharedTextEncoder?.encodeInto ? utf8EncodeTEencodeInto : utf8EncodeTEencode;
|
||||
|
||||
const CHUNK_SIZE = 0x1_000;
|
||||
|
||||
export function utf8DecodeJs(bytes: Uint8Array, inputOffset: number, byteLength: number): string {
|
||||
let offset = inputOffset;
|
||||
const end = offset + byteLength;
|
||||
|
||||
const units: Array<number> = [];
|
||||
let result = "";
|
||||
while (offset < end) {
|
||||
const byte1 = bytes[offset++]!;
|
||||
if ((byte1 & 0x80) === 0) {
|
||||
// 1 byte
|
||||
units.push(byte1);
|
||||
} else if ((byte1 & 0xe0) === 0xc0) {
|
||||
// 2 bytes
|
||||
const byte2 = bytes[offset++]! & 0x3f;
|
||||
units.push(((byte1 & 0x1f) << 6) | byte2);
|
||||
} else if ((byte1 & 0xf0) === 0xe0) {
|
||||
// 3 bytes
|
||||
const byte2 = bytes[offset++]! & 0x3f;
|
||||
const byte3 = bytes[offset++]! & 0x3f;
|
||||
units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);
|
||||
} else if ((byte1 & 0xf8) === 0xf0) {
|
||||
// 4 bytes
|
||||
const byte2 = bytes[offset++]! & 0x3f;
|
||||
const byte3 = bytes[offset++]! & 0x3f;
|
||||
const byte4 = bytes[offset++]! & 0x3f;
|
||||
let unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
|
||||
if (unit > 0xffff) {
|
||||
unit -= 0x10000;
|
||||
units.push(((unit >>> 10) & 0x3ff) | 0xd800);
|
||||
unit = 0xdc00 | (unit & 0x3ff);
|
||||
}
|
||||
units.push(unit);
|
||||
} else {
|
||||
units.push(byte1);
|
||||
}
|
||||
|
||||
if (units.length >= CHUNK_SIZE) {
|
||||
result += String.fromCharCode(...units);
|
||||
units.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (units.length > 0) {
|
||||
result += String.fromCharCode(...units);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const sharedTextDecoder = TEXT_ENCODING_AVAILABLE ? new TextDecoder() : null;
|
||||
export const TEXT_DECODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
|
||||
? UINT32_MAX
|
||||
: typeof process !== "undefined" && process?.env?.["TEXT_DECODER"] !== "force"
|
||||
? 200
|
||||
: 0;
|
||||
|
||||
export function utf8DecodeTD(bytes: Uint8Array, inputOffset: number, byteLength: number): string {
|
||||
const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
|
||||
return sharedTextDecoder!.decode(stringBytes);
|
||||
}
|
||||
Reference in New Issue
Block a user