@schema-pack/message-pack 0.0.0-commit.03ddd0427843dd0e1b45dcd0325ecf52097255a4 → 0.0.0-commit.56d3200cf684346bbdb90bed64d3516657fdaaec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/benchmark/decoderDataTypesFactory.cjs +29 -29
- package/dist/cjs/{bigInt-BdjzezQQ.d.cts → bigInt-ALGpR4Rn.d.cts} +5 -5
- package/dist/cjs/bigInt-ALGpR4Rn.d.cts.map +1 -0
- package/dist/{esm/bufferWithExtensions-DzAs7yX1.d.mts → cjs/bufferWithExtensions-qiA6axeV.d.cts} +2 -2
- package/dist/{esm/bufferWithExtensions-DzAs7yX1.d.mts.map → cjs/bufferWithExtensions-qiA6axeV.d.cts.map} +1 -1
- package/dist/cjs/bufferWithExtensions.d.cts +1 -1
- package/dist/cjs/decoder/decoder.d.cts +1 -1
- package/dist/cjs/decoder/decoderBuffer.d.cts +1 -1
- package/dist/cjs/decoder/index.d.cts +2 -2
- package/dist/cjs/{decoder-3WpVBZjY.d.cts → decoder-BugzrbIU.d.cts} +3 -3
- package/dist/cjs/{decoder-3WpVBZjY.d.cts.map → decoder-BugzrbIU.d.cts.map} +1 -1
- package/dist/cjs/{decoderBuffer-CJU2hdt2.d.cts → decoderBuffer-BFoz1PcE.d.cts} +2 -2
- package/dist/cjs/{decoderBuffer-CJU2hdt2.d.cts.map → decoderBuffer-BFoz1PcE.d.cts.map} +1 -1
- package/dist/cjs/encoder/encode.cjs +3 -3
- package/dist/cjs/encoder/encoder.cjs +593 -26
- package/dist/cjs/encoder/encoder.d.cts +1 -1
- package/dist/cjs/encoder/index.cjs +0 -2
- package/dist/cjs/encoder/index.d.cts +3 -4
- package/dist/cjs/encoder/interfaces/index.d.cts +2 -2
- package/dist/cjs/encoder/interfaces/messagePackEncoder.d.cts +2 -0
- package/dist/cjs/encoder/types.d.cts +2 -2
- package/dist/cjs/{encoderBuffer-3ur0iCYR.d.cts → encoder-BliskZYy.d.cts} +9 -9
- package/dist/cjs/encoder-BliskZYy.d.cts.map +1 -0
- package/dist/cjs/extensions/bigint/bigInt.cjs +5 -5
- package/dist/cjs/extensions/bigint/bigInt.d.cts +1 -1
- package/dist/cjs/extensions/bigint/index.d.cts +1 -1
- package/dist/cjs/extensions/index.d.cts +2 -2
- package/dist/cjs/extensions/interfaces/index.d.cts +1 -1
- package/dist/cjs/extensions/interfaces/messagePackExtension.d.cts +1 -1
- package/dist/cjs/extensions/timestampDate/index.d.cts +1 -1
- package/dist/cjs/extensions/timestampDate/timestampDate.cjs +6 -6
- package/dist/cjs/extensions/timestampDate/timestampDate.d.cts +1 -1
- package/dist/cjs/index.cjs +0 -2
- package/dist/cjs/index.d.cts +8 -9
- package/dist/cjs/interfaces/index.d.cts +1 -1
- package/dist/cjs/interfaces/messagePackBufferWithExtensions.d.cts +1 -1
- package/dist/cjs/{messagePackExtension-Cd99Rw9t.d.cts → messagePackExtension-xBTe48A-.d.cts} +50 -50
- package/dist/cjs/messagePackExtension-xBTe48A-.d.cts.map +1 -0
- package/dist/cjs/{timestampDate-Bi1rnvVd.d.cts → timestampDate-B8IXKYcA.d.cts} +3 -3
- package/dist/cjs/timestampDate-B8IXKYcA.d.cts.map +1 -0
- package/dist/cjs/{untypedExtension-wx6-_4mg.d.cts → untypedExtension-DPZG3pQo.d.cts} +3 -3
- package/dist/cjs/{untypedExtension-wx6-_4mg.d.cts.map → untypedExtension-DPZG3pQo.d.cts.map} +1 -1
- package/dist/cjs/untypedExtension.d.cts +1 -1
- package/dist/esm/benchmark/decoderDataTypesFactory.mjs +29 -29
- package/dist/esm/benchmark/decoderDataTypesFactory.mjs.map +1 -1
- package/dist/esm/{bigInt-D37SPzzB.d.mts → bigInt-lSrNuXkn.d.mts} +5 -5
- package/dist/esm/bigInt-lSrNuXkn.d.mts.map +1 -0
- package/dist/{cjs/bufferWithExtensions-n6DtcUoA.d.cts → esm/bufferWithExtensions-Bc7vjIkw.d.mts} +2 -2
- package/dist/{cjs/bufferWithExtensions-n6DtcUoA.d.cts.map → esm/bufferWithExtensions-Bc7vjIkw.d.mts.map} +1 -1
- package/dist/esm/bufferWithExtensions.d.mts +1 -1
- package/dist/esm/decoder/decoder.d.mts +1 -1
- package/dist/esm/decoder/decoderBuffer.d.mts +1 -1
- package/dist/esm/decoder/index.d.mts +2 -2
- package/dist/esm/{decoder-ByAWOgvm.d.mts → decoder-CQrtmASU.d.mts} +3 -3
- package/dist/esm/{decoder-ByAWOgvm.d.mts.map → decoder-CQrtmASU.d.mts.map} +1 -1
- package/dist/esm/{decoderBuffer-93dMcsbx.d.mts → decoderBuffer-BKic0U2F.d.mts} +2 -2
- package/dist/esm/{decoderBuffer-93dMcsbx.d.mts.map → decoderBuffer-BKic0U2F.d.mts.map} +1 -1
- package/dist/esm/encoder/encode.mjs +4 -4
- package/dist/esm/encoder/encode.mjs.map +1 -1
- package/dist/esm/encoder/encoder.d.mts +1 -1
- package/dist/esm/encoder/encoder.mjs +593 -26
- package/dist/esm/encoder/encoder.mjs.map +1 -1
- package/dist/esm/encoder/index.d.mts +3 -4
- package/dist/esm/encoder/index.mjs +1 -2
- package/dist/esm/encoder/interfaces/index.d.mts +2 -2
- package/dist/esm/encoder/interfaces/messagePackEncoder.d.mts +2 -0
- package/dist/esm/encoder/types.d.mts +2 -2
- package/dist/esm/{encoderBuffer-BZMIF5I2.d.mts → encoder-ZmHoedsB.d.mts} +9 -9
- package/dist/esm/encoder-ZmHoedsB.d.mts.map +1 -0
- package/dist/esm/extensions/bigint/bigInt.d.mts +1 -1
- package/dist/esm/extensions/bigint/bigInt.mjs +5 -5
- package/dist/esm/extensions/bigint/bigInt.mjs.map +1 -1
- package/dist/esm/extensions/bigint/index.d.mts +1 -1
- package/dist/esm/extensions/index.d.mts +2 -2
- package/dist/esm/extensions/interfaces/index.d.mts +1 -1
- package/dist/esm/extensions/interfaces/messagePackExtension.d.mts +1 -1
- package/dist/esm/extensions/timestampDate/index.d.mts +1 -1
- package/dist/esm/extensions/timestampDate/timestampDate.d.mts +1 -1
- package/dist/esm/extensions/timestampDate/timestampDate.mjs +6 -6
- package/dist/esm/extensions/timestampDate/timestampDate.mjs.map +1 -1
- package/dist/esm/index.d.mts +8 -9
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/interfaces/index.d.mts +1 -1
- package/dist/esm/interfaces/messagePackBufferWithExtensions.d.mts +1 -1
- package/dist/esm/{messagePackExtension-fq36EMAg.d.mts → messagePackExtension-Ceq7jzFB.d.mts} +50 -50
- package/dist/esm/messagePackExtension-Ceq7jzFB.d.mts.map +1 -0
- package/dist/esm/{timestampDate-C3Ch8aSB.d.mts → timestampDate-uQGrWim5.d.mts} +3 -3
- package/dist/esm/timestampDate-uQGrWim5.d.mts.map +1 -0
- package/dist/esm/{untypedExtension-Ckk9RwQw.d.mts → untypedExtension-DKgyS2ak.d.mts} +3 -3
- package/dist/esm/{untypedExtension-Ckk9RwQw.d.mts.map → untypedExtension-DKgyS2ak.d.mts.map} +1 -1
- package/dist/esm/untypedExtension.d.mts +1 -1
- package/dist/esm/untypedExtension.mjs.map +1 -1
- package/package.json +4 -8
- package/dist/cjs/bigInt-BdjzezQQ.d.cts.map +0 -1
- package/dist/cjs/encoder/encoderBuffer.cjs +0 -608
- package/dist/cjs/encoder/encoderBuffer.d.cts +0 -2
- package/dist/cjs/encoder/interfaces/messagePackEncoderBuffer.d.cts +0 -2
- package/dist/cjs/encoder-B-rTvI4P.d.cts +0 -23
- package/dist/cjs/encoder-B-rTvI4P.d.cts.map +0 -1
- package/dist/cjs/encoderBuffer-3ur0iCYR.d.cts.map +0 -1
- package/dist/cjs/messagePackExtension-Cd99Rw9t.d.cts.map +0 -1
- package/dist/cjs/timestampDate-Bi1rnvVd.d.cts.map +0 -1
- package/dist/esm/bigInt-D37SPzzB.d.mts.map +0 -1
- package/dist/esm/encoder/encoderBuffer.d.mts +0 -2
- package/dist/esm/encoder/encoderBuffer.mjs +0 -610
- package/dist/esm/encoder/encoderBuffer.mjs.map +0 -1
- package/dist/esm/encoder/interfaces/messagePackEncoderBuffer.d.mts +0 -2
- package/dist/esm/encoder-PfSLnKnK.d.mts +0 -23
- package/dist/esm/encoder-PfSLnKnK.d.mts.map +0 -1
- package/dist/esm/encoderBuffer-BZMIF5I2.d.mts.map +0 -1
- package/dist/esm/messagePackExtension-fq36EMAg.d.mts.map +0 -1
- package/dist/esm/timestampDate-C3Ch8aSB.d.mts.map +0 -1
- /package/dist/cjs/encoder/interfaces/{messagePackEncoderBuffer.cjs → messagePackEncoder.cjs} +0 -0
- /package/dist/esm/encoder/interfaces/{messagePackEncoderBuffer.mjs → messagePackEncoder.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.mjs","names":[],"sources":["../../../src/encoder/encoder.ts"],"sourcesContent":["import type MessagePackExtension from '../extensions/interfaces/messagePackExtension.ts';\nimport EncoderBuffer from './encoderBuffer.ts';\nimport type { EncoderBufferOptions } from './types.ts';\n\n/**\n * The `Encoder` class is responsible for encoding JavaScript values into the\n * MessagePack format.\n *\n * This class is just a wrapper around the buffer, which does the actual\n * encoding. The buffer is responsible for managing the encoding process and\n * handling extensions.\n */\nclass Encoder<TBuffer extends Uint8Array = Uint8Array> {\n buffer: EncoderBuffer<TBuffer>;\n\n constructor(options?: Partial<EncoderBufferOptions<TBuffer>>) {\n this.buffer = new EncoderBuffer<TBuffer>(options);\n }\n\n encode(value: unknown): TBuffer {\n const buffer = this.buffer;\n\n buffer.write(value);\n\n return buffer.flush();\n }\n\n addExtension(extension: MessagePackExtension<unknown, TBuffer>): this {\n this.buffer.addExtension(extension);\n\n return this;\n }\n\n addInternalExtension(\n extension: MessagePackExtension<unknown, TBuffer>,\n ): this {\n this.buffer.addInternalExtension(extension);\n\n return this;\n }\n\n addExtensionType(\n type: number,\n extension: Omit<MessagePackExtension<unknown, TBuffer>, 'type'>,\n ): this {\n this.buffer.addExtension({ type, ...extension });\n\n return this;\n }\n\n fetchExtension(type: number): MessagePackExtension<unknown, TBuffer> {\n return this.buffer.fetchExtension(type);\n }\n}\n\nexport default Encoder;\n"],"mappings":";;;;;;;;;;AAYA,IAAM,UAAN,MAAuD;CACrD;CAEA,YAAY,SAAkD;EAC5D,KAAK,SAAS,IAAI,cAAuB,OAAO;CAClD;CAEA,OAAO,OAAyB;EAC9B,MAAM,SAAS,KAAK;EAEpB,OAAO,MAAM,KAAK;EAElB,OAAO,OAAO,MAAM;CACtB;CAEA,aAAa,WAAyD;EACpE,KAAK,OAAO,aAAa,SAAS;EAElC,OAAO;CACT;CAEA,qBACE,WACM;EACN,KAAK,OAAO,qBAAqB,SAAS;EAE1C,OAAO;CACT;CAEA,iBACE,MACA,WACM;EACN,KAAK,OAAO,aAAa;GAAE;GAAM,GAAG;EAAU,CAAC;EAE/C,OAAO;CACT;CAEA,eAAe,MAAsD;EACnE,OAAO,KAAK,OAAO,eAAe,IAAI;CACxC;AACF"}
|
|
1
|
+
{"version":3,"file":"encoder.mjs","names":["#extensionEncoder"],"sources":["../../../src/encoder/encoder.ts"],"sourcesContent":["// oxlint-disable unicorn/prefer-code-point\nimport BufferWithExtensions from '../bufferWithExtensions.ts';\nimport {\n DEFAULT_ALLOCATION_SIZE,\n INT64_MIN,\n UINT32_MAX,\n UINT64_MAX,\n} from '../constants.ts';\nimport defaultNewBufferFn from '../defaultNewBufferFn.ts';\nimport type MessagePackExtension from '../extensions/interfaces/messagePackExtension.ts';\nimport Symbols from '../symbols.ts';\nimport type { BufferFactory } from '../types.ts';\nimport fitIn7Bits from '../utils/fitIn7Bits.ts';\nimport fitIn8Bits from '../utils/fitIn8Bits.ts';\nimport fitIn16Bits from '../utils/fitIn16Bits.ts';\nimport fitIn32Bits from '../utils/fitIn32Bits.ts';\nimport type {\n MessagePackEncoder,\n MessagePackTextEncoder,\n} from './interfaces/index.ts';\nimport DefaultTextEncoder from './textEncoders/defaultTextEncoder.ts';\nimport type { EncoderOptions, ExtensionEncoder } from './types.ts';\n\nclass Encoder<TBuffer extends Uint8Array = Uint8Array>\n extends BufferWithExtensions<TBuffer>\n implements MessagePackEncoder<TBuffer>\n{\n /** The current offset in the buffer where the next write operation will occur. */\n offset: number;\n\n /**\n * Shared buffer is used to encode strings, to avoid allocating a new buffer\n * for each string. The shared buffer is resized if the string is larger than\n * the current size of the shared buffer. This helps to improve performance by\n * reducing memory allocations and garbage collection overhead.\n */\n protected sharedBuffer: TBuffer;\n\n /**\n * Determines whether the keys of a map should be sorted before encoding.\n * Sorting keys can be useful for ensuring consistent serialization of\n * objects, which is important for tasks like hashing or comparing serialized\n * data.\n */\n readonly sortKeys: boolean;\n\n /**\n * If true, forces the encoder to use 32-bit floating point representation for\n * numbers, even if they could be represented as 64-bit floats. This can be\n * useful for reducing the size of the encoded data when high precision is not\n * required. However, it may lead to loss of precision for very large or very\n * small numbers.\n */\n readonly forceFloat32: boolean;\n\n /**\n * A function that creates a new buffer of the specified size. This function\n * is used to allocate new buffers when the current buffer is not large enough\n * to accommodate the data being written. The function should return a new\n * instance of TBuffer with the specified size.\n */\n protected bufferFactory: BufferFactory<TBuffer>;\n\n readonly textEncoder: MessagePackTextEncoder<TBuffer>;\n\n buffer: TBuffer;\n view: DataView;\n\n /**\n * The extension encoder is used to encode extension types. It is a separate\n * buffer from the main buffer, and is used to encode the extension data\n * before writing it to the main buffer. This allows for efficient encoding of\n * extension types, as the extension data can be encoded in a separate buffer\n * and then written to the main buffer in a single operation.\n *\n * The extension buffer must be resized using ensureCapacity before writing to\n * it, to ensure that there is enough space for the extension data.\n */\n #extensionEncoder?: Encoder<TBuffer>;\n\n constructor(options?: Partial<EncoderOptions<TBuffer>>) {\n super();\n\n this.offset = 0;\n this.textEncoder = options?.textEncoder ?? new DefaultTextEncoder();\n\n this.bufferFactory = options?.bufferFactory ?? defaultNewBufferFn<TBuffer>;\n\n this.buffer = this.bufferFactory(\n options?.initialBufferSize ?? DEFAULT_ALLOCATION_SIZE,\n );\n this.sharedBuffer = this.bufferFactory(\n options?.initialSharedBufferSize ?? DEFAULT_ALLOCATION_SIZE,\n );\n this.view = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength,\n );\n\n this.sortKeys = options?.sortKeys ?? false;\n this.forceFloat32 = options?.forceFloat32 ?? false;\n }\n\n getExtensionEncoder(): Encoder<TBuffer> {\n if (!this.#extensionEncoder) {\n this.#extensionEncoder = new Encoder<TBuffer>({\n bufferFactory: this.bufferFactory,\n initialBufferSize: this.sharedBuffer.byteLength,\n initialSharedBufferSize: 0,\n sortKeys: this.sortKeys,\n textEncoder: this.textEncoder,\n });\n }\n\n return this.#extensionEncoder;\n }\n\n resizeBuffer(newSize: number): this {\n const newBuffer = this.bufferFactory(newSize);\n\n newBuffer.set(this.buffer);\n\n this.buffer = newBuffer;\n this.view = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength,\n );\n\n return this;\n }\n\n ensureCapacity(sizeToWrite: number): this {\n const required = this.offset + sizeToWrite;\n\n if (this.buffer.byteLength < required) {\n this.resizeBuffer(required * 2);\n }\n\n return this;\n }\n\n resetBuffer(): this {\n this.offset = 0;\n\n return this;\n }\n\n flush(): TBuffer {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const buffer = this.buffer.subarray(0, this.offset) as TBuffer;\n\n this.resetBuffer();\n\n return buffer;\n }\n\n writePositiveFixInt(value: number): this {\n this.writeUint8(value);\n\n return this;\n }\n\n writeNegativeFixInt(value: number): this {\n // this.buffer[this.offset++] = NEGATIVE_FIXINT_START | (value + 32);\n this.buffer[this.offset++] = value + 0x1_00;\n\n return this;\n }\n\n writeBin(bytes: Uint8Array): this {\n this.buffer.set(bytes, this.offset);\n\n this.offset += bytes.length;\n\n return this;\n }\n\n writeFloat32(value: number): this {\n this.view.setFloat32(this.offset, value);\n this.offset += 4;\n\n return this;\n }\n\n writeFloat64(value: number): this {\n this.view.setFloat64(this.offset, value);\n this.offset += 8;\n\n return this;\n }\n\n writeUint8(value: number): this {\n this.buffer[this.offset++] = value;\n\n return this;\n }\n\n writeUint16(value: number): this {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n\n return this;\n }\n\n writeUint32(value: number): this {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n\n return this;\n }\n\n writeUint64(value: number): this {\n const high = value / 0x1_00_00_00_00;\n const low = value;\n\n this.view.setUint32(this.offset, high);\n this.offset += 4;\n\n this.view.setUint32(this.offset, low);\n this.offset += 4;\n\n return this;\n }\n\n writeInt8(value: number): this {\n this.view.setInt8(this.offset++, value & 0xff);\n\n return this;\n }\n\n writeInt16(value: number): this {\n this.view.setInt16(this.offset, value);\n this.offset += 2;\n\n return this;\n }\n\n writeInt32(value: number): this {\n this.view.setInt32(this.offset, value);\n this.offset += 4;\n\n return this;\n }\n\n writeInt64(value: number): this {\n const high = Math.floor(value / 0x1_00_00_00_00);\n const low = value;\n\n this.view.setInt32(this.offset, high);\n this.offset += 4;\n this.view.setInt32(this.offset, low);\n this.offset += 4;\n\n return this;\n }\n\n // writeBigInt64(value: bigint): this {\n // this.view.setBigInt64(this.offset, value);\n // this.offset += 8;\n\n // return this;\n // }\n\n // writeBigUint64(value: bigint): this {\n // this.view.setBigUint64(this.offset, value);\n // this.offset += 8;\n\n // return this;\n // }\n\n writeStr(value: string): this {\n this.offset += this.textEncoder.writeBytes(value, this.buffer);\n\n return this;\n }\n\n writeNilSymbol(): this {\n this.buffer[this.offset++] = Symbols.NIL;\n\n return this;\n }\n\n writeFalseSymbol(): this {\n this.buffer[this.offset++] = Symbols.FALSE;\n\n return this;\n }\n\n writeTrueSymbol(): this {\n this.buffer[this.offset++] = Symbols.TRUE;\n\n return this;\n }\n\n writeFixMapSymbol(keysSize: number): this {\n this.buffer[this.offset++] = Symbols.FIXMAP_START | keysSize;\n\n return this;\n }\n\n writeFixArraySymbol(arraySize: number): this {\n this.buffer[this.offset++] = Symbols.FIXARRAY_START | arraySize;\n\n return this;\n }\n\n writeFixStrSymbol(byteLength: number): this {\n this.buffer[this.offset++] = Symbols.FIXSTR_START | byteLength;\n\n return this;\n }\n\n writeBin8Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.BIN8;\n this.buffer[this.offset++] = size;\n\n return this;\n }\n\n writeBin16Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.BIN16;\n this.view.setUint16(this.offset, size);\n this.offset += 2;\n\n return this;\n }\n\n writeBin32Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.BIN32;\n this.view.setUint32(this.offset, size);\n this.offset += 4;\n\n return this;\n }\n\n writeFloat32Symbol(): this {\n this.buffer[this.offset++] = Symbols.FLOAT32;\n\n return this;\n }\n\n writeFloat64Symbol(): this {\n this.buffer[this.offset++] = Symbols.FLOAT64;\n\n return this;\n }\n\n writeUint8Symbol(): this {\n this.buffer[this.offset++] = Symbols.UINT8;\n\n return this;\n }\n\n writeUint16Symbol(): this {\n this.buffer[this.offset++] = Symbols.UINT16;\n\n return this;\n }\n\n writeUint32Symbol(): this {\n this.buffer[this.offset++] = Symbols.UINT32;\n\n return this;\n }\n\n writeUint64Symbol(): this {\n this.buffer[this.offset++] = Symbols.UINT64;\n\n return this;\n }\n\n writeInt8Symbol(): this {\n this.buffer[this.offset++] = Symbols.INT8;\n\n return this;\n }\n\n writeInt16Symbol(): this {\n this.buffer[this.offset++] = Symbols.INT16;\n\n return this;\n }\n\n writeInt32Symbol(): this {\n this.buffer[this.offset++] = Symbols.INT32;\n\n return this;\n }\n\n writeInt64Symbol(): this {\n this.buffer[this.offset++] = Symbols.INT64;\n\n return this;\n }\n\n writeStr8Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.STR8;\n this.buffer[this.offset++] = size;\n\n return this;\n }\n\n writeStr16Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.STR16;\n this.view.setUint16(this.offset, size);\n\n this.offset += 2;\n\n return this;\n }\n\n writeStr32Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.STR32;\n this.view.setUint32(this.offset, size);\n\n this.offset += 4;\n\n return this;\n }\n\n writeArray16Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.ARRAY16;\n this.view.setUint16(this.offset, size);\n\n this.offset += 2;\n\n return this;\n }\n\n writeArray32Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.ARRAY32;\n this.view.setUint32(this.offset, size);\n\n this.offset += 4;\n\n return this;\n }\n\n writeMap16Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.MAP16;\n this.view.setUint16(this.offset, size);\n\n this.offset += 2;\n\n return this;\n }\n\n writeMap32Symbol(size: number): this {\n this.buffer[this.offset++] = Symbols.MAP32;\n this.view.setUint32(this.offset, size);\n\n this.offset += 4;\n\n return this;\n }\n\n writeFixExt1Symbol(type: number): this {\n this.buffer[this.offset++] = Symbols.FIXEXT1;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeFixExt2Symbol(type: number): this {\n this.buffer[this.offset++] = Symbols.FIXEXT2;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeFixExt4Symbol(type: number): this {\n this.buffer[this.offset++] = Symbols.FIXEXT4;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeFixExt8Symbol(type: number): this {\n this.buffer[this.offset++] = Symbols.FIXEXT8;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeFixExt16Symbol(type: number): this {\n this.buffer[this.offset++] = Symbols.FIXEXT16;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeExt8Symbol(type: number, size: number): this {\n this.buffer[this.offset++] = Symbols.EXT8;\n this.buffer[this.offset++] = size;\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeExt16Symbol(type: number, size: number): this {\n this.buffer[this.offset++] = Symbols.EXT16;\n\n this.view.setUint16(this.offset, size);\n this.offset += 2;\n\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeExt32Symbol(type: number, size: number): this {\n this.buffer[this.offset++] = Symbols.EXT32;\n\n this.view.setUint32(this.offset, size);\n this.offset += 4;\n\n this.buffer[this.offset++] = type;\n\n return this;\n }\n\n writeString(value: string): this {\n const valueLength = value.length;\n const requiredSize = value.length * 4;\n\n // optimization for short strings, to avoid the overhead of using\n // a text encoder for small strings\n if (valueLength < 51) {\n this.ensureCapacity(1 + requiredSize);\n\n const initialoffset = this.offset;\n const byteLengthoffset = this.offset++;\n let totalBytes = 0;\n let fitInFixStr = true;\n let fitInStr8 = true;\n let { offset } = this;\n\n for (let index = 0; index < valueLength; index++) {\n const code = value.charCodeAt(index);\n\n if (code < 0x80) {\n this.buffer[offset++] = code;\n totalBytes++;\n } else if (code < 0x8_00) {\n this.buffer[offset++] = 0xc0 | (code >> 6);\n this.buffer[offset++] = 0x80 | (code & 0x3f);\n totalBytes += 2;\n } else if (code < 0xd8_00 || code >= 0xe0_00) {\n this.buffer[offset++] = 0xe0 | (code >> 12);\n this.buffer[offset++] = 0x80 | ((code >> 6) & 0x3f);\n this.buffer[offset++] = 0x80 | (code & 0x3f);\n totalBytes += 3;\n } else {\n // surrogate pair\n index++;\n const nextCode = value.charCodeAt(index);\n\n const surrogatePair =\n (((code & 0x3_ff) << 10) | (nextCode & 0x3_ff)) + 0x1_00_00;\n\n this.buffer[offset++] = 0xf0 | (surrogatePair >> 18);\n this.buffer[offset++] = 0x80 | ((surrogatePair >> 12) & 0x3f);\n this.buffer[offset++] = 0x80 | ((surrogatePair >> 6) & 0x3f);\n this.buffer[offset++] = 0x80 | (surrogatePair & 0x3f);\n totalBytes += 4;\n }\n\n if (totalBytes > 31) {\n fitInFixStr = false;\n } else if (totalBytes > 255) {\n fitInStr8 = false;\n break;\n }\n }\n\n if (fitInFixStr) {\n this.buffer[byteLengthoffset] = Symbols.FIXSTR_START | totalBytes;\n\n this.offset += totalBytes;\n\n return this;\n } else if (fitInStr8) {\n this.buffer[byteLengthoffset] = Symbols.STR8;\n\n const totalBytesPosition = byteLengthoffset + 1;\n\n this.buffer.copyWithin(\n totalBytesPosition + 1,\n totalBytesPosition,\n offset,\n );\n\n this.buffer[totalBytesPosition] = totalBytes;\n this.offset++;\n\n this.offset += totalBytes;\n return this;\n }\n // fallback\n this.offset = initialoffset;\n }\n\n if (this.sharedBuffer.byteLength < requiredSize) {\n this.sharedBuffer = this.bufferFactory(requiredSize);\n }\n\n const sharedBuffer = this.sharedBuffer;\n\n const byteLength = this.textEncoder.writeBytes(value, sharedBuffer);\n\n if (fitIn8Bits(byteLength)) {\n this.ensureCapacity(2 + byteLength);\n this.writeStr8Symbol(byteLength);\n } else if (fitIn16Bits(byteLength)) {\n this.ensureCapacity(3 + byteLength);\n this.writeStr16Symbol(byteLength);\n } else {\n this.ensureCapacity(5 + byteLength);\n this.writeStr32Symbol(byteLength);\n }\n\n this.writeBin(sharedBuffer.subarray(0, byteLength));\n\n return this;\n }\n\n writeNumber(value: number): this {\n if (Number.isInteger(value)) {\n if (value < 0) {\n // siged integers\n if (value > -33) {\n this.ensureCapacity(1);\n return this.writeNegativeFixInt(value);\n } else if (value > -129) {\n this.ensureCapacity(2);\n this.writeInt8Symbol();\n return this.writeInt8(value);\n } else if (value > -32_769) {\n this.ensureCapacity(3);\n this.writeInt16Symbol();\n return this.writeInt16(value);\n } else if (value > -2_147_483_649) {\n this.ensureCapacity(5);\n this.writeInt32Symbol();\n return this.writeInt32(value);\n } else if (value >= INT64_MIN) {\n this.ensureCapacity(9);\n this.writeInt64Symbol();\n return this.writeInt64(value);\n }\n\n throw new Error(\n `Integer too small to encode: ${value}. Consider using BigIntExtension.`,\n );\n } else {\n // unsiged integers\n if (fitIn7Bits(value)) {\n this.ensureCapacity(1);\n return this.writePositiveFixInt(value);\n }\n\n if (fitIn8Bits(value)) {\n this.ensureCapacity(2);\n this.writeUint8Symbol();\n return this.writeUint8(value);\n }\n\n if (fitIn16Bits(value)) {\n this.ensureCapacity(3);\n this.writeUint16Symbol();\n return this.writeUint16(value);\n }\n\n if (fitIn32Bits(value)) {\n this.ensureCapacity(5);\n this.writeUint32Symbol();\n return this.writeUint32(value);\n }\n\n if (value <= UINT64_MAX) {\n this.ensureCapacity(9);\n this.writeUint64Symbol();\n return this.writeUint64(value);\n }\n\n throw new Error(\n `Integer too large to encode: ${value}. Consider using BigIntExtension.`,\n );\n }\n } else if (this.forceFloat32) {\n this.ensureCapacity(5);\n this.writeFloat32Symbol();\n return this.writeFloat32(value);\n }\n\n this.ensureCapacity(9);\n this.writeFloat64Symbol();\n return this.writeFloat64(value);\n }\n\n openMap(keysLength: number): this {\n const requiredSize = keysLength * 4;\n\n if (keysLength < 16) {\n this.ensureCapacity(requiredSize + 1);\n this.writeFixMapSymbol(keysLength);\n } else if (fitIn16Bits(keysLength)) {\n this.ensureCapacity(requiredSize + 3);\n this.writeMap16Symbol(keysLength);\n } else if (fitIn32Bits(keysLength)) {\n this.ensureCapacity(requiredSize + 5);\n this.writeMap32Symbol(keysLength);\n } else {\n throw new Error(\n `Map size ${keysLength} exceeds maximum allowed size of ${UINT32_MAX}`,\n );\n }\n\n return this;\n }\n\n writeMap<TKey extends string | number, TValue>(\n value: Record<TKey, TValue>,\n ): this {\n const keys = Object.keys(value);\n\n if (this.sortKeys) {\n keys.sort();\n }\n\n const keysLength = keys.length;\n\n this.openMap(keysLength);\n\n for (const key of keys) {\n this.writeString(key);\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n this.write(value[key as TKey]);\n }\n\n return this;\n }\n\n openArray(length: number): this {\n const requiredSize = length * 4;\n\n if (length < 16) {\n this.ensureCapacity(requiredSize + 1);\n this.writeFixArraySymbol(length);\n } else if (fitIn16Bits(length)) {\n this.ensureCapacity(requiredSize + 3);\n this.writeArray16Symbol(length);\n } else if (fitIn32Bits(length)) {\n this.ensureCapacity(requiredSize + 5);\n this.writeArray32Symbol(length);\n } else {\n throw new Error(\n `Array size ${length} exceeds maximum allowed size of ${UINT32_MAX}`,\n );\n }\n\n return this;\n }\n\n writeArray(value: unknown[]): this {\n const length = value.length;\n\n this.openArray(length);\n\n for (let index = 0; index < length; ++index) {\n this.write(value[index]);\n }\n\n return this;\n }\n\n // writeBigInt(value: bigint): this {\n // this.ensureCapacity(9);\n\n // if (value < 0n) {\n // this.writeInt64Symbol();\n // return this.writeBigInt64(value);\n // }\n\n // this.writeUint64Symbol();\n // return this.writeBigUint64(value);\n // }\n\n writeUint8Array(value: Uint8Array): this {\n if (fitIn8Bits(value.length)) {\n this.ensureCapacity(2 + value.length);\n this.writeBin8Symbol(value.length);\n } else if (fitIn16Bits(value.length)) {\n this.ensureCapacity(3 + value.length);\n this.writeBin16Symbol(value.length);\n } else if (fitIn32Bits(value.length)) {\n this.ensureCapacity(5 + value.length);\n this.writeBin32Symbol(value.length);\n } else {\n throw new Error(`Uint8Array too large to encode: ${value.length}`);\n }\n\n return this.writeBin(value);\n }\n\n writeExtension(\n extension: MessagePackExtension,\n encoder: ExtensionEncoder<TBuffer>,\n ): this {\n const writtenBytes = encoder.offset;\n\n if (writtenBytes === 1) {\n this.ensureCapacity(3);\n\n this.writeFixExt1Symbol(extension.type);\n } else if (writtenBytes === 2) {\n this.ensureCapacity(4);\n\n this.writeFixExt2Symbol(extension.type);\n } else if (writtenBytes === 4) {\n this.ensureCapacity(6);\n\n this.writeFixExt4Symbol(extension.type);\n } else if (writtenBytes === 8) {\n this.ensureCapacity(10);\n\n this.writeFixExt8Symbol(extension.type);\n } else if (writtenBytes === 16) {\n this.ensureCapacity(18);\n\n this.writeFixExt16Symbol(extension.type);\n } else if (fitIn8Bits(writtenBytes)) {\n this.ensureCapacity(3 + writtenBytes);\n\n this.writeExt8Symbol(extension.type, writtenBytes);\n } else if (fitIn16Bits(writtenBytes)) {\n this.ensureCapacity(4 + writtenBytes);\n\n this.writeExt16Symbol(extension.type, writtenBytes);\n } else if (fitIn32Bits(writtenBytes)) {\n this.ensureCapacity(6 + writtenBytes);\n\n this.writeExt32Symbol(extension.type, writtenBytes);\n } else {\n throw new Error(\n `Extension data too large to encode: ${writtenBytes} bytes`,\n );\n }\n\n this.buffer.set(encoder.buffer.subarray(0, writtenBytes), this.offset);\n\n this.offset += writtenBytes;\n\n return this;\n }\n\n tryToWriteExtensionValue(value: object | bigint): number {\n if (this.extensions.size > 0) {\n const iterator = this.extensions.values();\n const extensionEncoder = this.getExtensionEncoder();\n\n for (const extension of iterator) {\n extensionEncoder.resetBuffer();\n\n extension.encode(value, extensionEncoder);\n\n if (extensionEncoder.offset > 0) {\n this.writeExtension(extension, extensionEncoder);\n\n return extensionEncoder.offset;\n }\n }\n }\n\n return 0;\n }\n\n writeBigInt(value: bigint): this {\n const writtenBytes = this.tryToWriteExtensionValue(value);\n\n if (writtenBytes > 0) {\n return this;\n }\n\n throw new TypeError(\n '\"bigint\" encoding is not supported by default. Consider using BigIntExtension',\n );\n }\n\n writeObject(value: object): this {\n if (Array.isArray(value)) {\n return this.writeArray(value);\n }\n\n const writtenBytes = this.tryToWriteExtensionValue(value);\n\n if (writtenBytes > 0) {\n return this;\n }\n\n if (value instanceof Uint8Array) {\n return this.writeUint8Array(value);\n }\n\n return this.writeMap(value);\n }\n\n write(value: unknown): this {\n // oxlint-disable-next-line typescript/switch-exhaustiveness-check\n switch (typeof value) {\n case 'number': {\n return this.writeNumber(value);\n }\n case 'string': {\n return this.writeString(value);\n }\n case 'boolean': {\n this.ensureCapacity(1);\n\n if (value) {\n return this.writeTrueSymbol();\n }\n\n return this.writeFalseSymbol();\n }\n case 'undefined': {\n this.ensureCapacity(1);\n return this.writeNilSymbol();\n }\n case 'bigint': {\n return this.writeBigInt(value);\n }\n case 'object': {\n if (value === null) {\n this.ensureCapacity(1);\n return this.writeNilSymbol();\n }\n\n return this.writeObject(value);\n }\n default: {\n throw new TypeError(\n `Unsupported type for encoding: ${typeof value}. Consider using an extension.`,\n );\n }\n }\n }\n}\n\nexport default Encoder;\n"],"mappings":";;;;;;;;;;AAuBA,IAAM,UAAN,MAAM,gBACI,qBAEV;;CAEE;;;;;;;CAQA;;;;;;;CAQA;;;;;;;;CASA;;;;;;;CAQA;CAEA;CAEA;CACA;;;;;;;;;;;CA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pC,IAAI,GACjB,OAAO;EAGT,MAAM,IAAI,UACR,iFACF;CACF;CAEA,YAAY,OAAqB;EAC/B,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,KAAK,WAAW,KAAK;EAK9B,IAFqB,KAAK,yBAAyB,KAEpC,IAAI,GACjB,OAAO;EAGT,IAAI,iBAAiB,YACnB,OAAO,KAAK,gBAAgB,KAAK;EAGnC,OAAO,KAAK,SAAS,KAAK;CAC5B;CAEA,MAAM,OAAsB;EAE1B,QAAQ,OAAO,OAAf;GACE,KAAK,UACH,OAAO,KAAK,YAAY,KAAK;GAE/B,KAAK,UACH,OAAO,KAAK,YAAY,KAAK;GAE/B,KAAK;IACH,KAAK,eAAe,CAAC;IAErB,IAAI,OACF,OAAO,KAAK,gBAAgB;IAG9B,OAAO,KAAK,iBAAiB;GAE/B,KAAK;IACH,KAAK,eAAe,CAAC;IACrB,OAAO,KAAK,eAAe;GAE7B,KAAK,UACH,OAAO,KAAK,YAAY,KAAK;GAE/B,KAAK;IACH,IAAI,UAAU,MAAM;KAClB,KAAK,eAAe,CAAC;KACrB,OAAO,KAAK,eAAe;IAC7B;IAEA,OAAO,KAAK,YAAY,KAAK;GAE/B,SACE,MAAM,IAAI,UACR,kCAAkC,OAAO,MAAM,+BACjD;EAEJ;CACF;AACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as MessagePackEncoder, i as OmitByPattern, n as EncoderOptions, r as ExtensionEncoder } from "../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
import { t as MessagePackTextEncoder } from "../messagePackTextEncoder-D7iCft_t.mjs";
|
|
3
3
|
import { t as encode } from "../encode-4SxHVw0M.mjs";
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as Encoder } from "../encoder-PfSLnKnK.mjs";
|
|
4
|
+
import { t as Encoder } from "../encoder-ZmHoedsB.mjs";
|
|
6
5
|
import { t as DefaultTextEncoder } from "../defaultTextEncoder-BkIjtDkg.mjs";
|
|
7
6
|
import { t as NodeTextEncoder } from "../nodeTextEncoder-CegSnA6z.mjs";
|
|
8
|
-
export { DefaultTextEncoder, Encoder,
|
|
7
|
+
export { DefaultTextEncoder, Encoder, type EncoderOptions, type ExtensionEncoder, type MessagePackEncoder, type MessagePackTextEncoder, NodeTextEncoder, type OmitByPattern, encode };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import DefaultTextEncoder from "./textEncoders/defaultTextEncoder.mjs";
|
|
2
|
-
import EncoderBuffer from "./encoderBuffer.mjs";
|
|
3
2
|
import Encoder from "./encoder.mjs";
|
|
4
3
|
import NodeTextEncoder from "./textEncoders/nodeTextEncoder.mjs";
|
|
5
4
|
import encode from "./encode.mjs";
|
|
6
|
-
export { DefaultTextEncoder, Encoder,
|
|
5
|
+
export { DefaultTextEncoder, Encoder, NodeTextEncoder, encode };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as MessagePackEncoder } from "../../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
import { t as MessagePackTextEncoder } from "../../messagePackTextEncoder-D7iCft_t.mjs";
|
|
3
3
|
import "../../index-DMnXy2Rv.mjs";
|
|
4
|
-
export type {
|
|
4
|
+
export type { MessagePackEncoder, MessagePackTextEncoder };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { i as OmitByPattern, n as EncoderOptions, r as ExtensionEncoder } from "../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
|
+
export { EncoderOptions, ExtensionEncoder, OmitByPattern };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as ExtensionEncoderBuffer, n as MessagePackEncoderBuffer, r as EncoderBufferOptions, t as MessagePackExtension } from "./messagePackExtension-fq36EMAg.mjs";
|
|
2
1
|
import { t as BufferFactory } from "./types-DTcs4Mkd.mjs";
|
|
2
|
+
import { a as MessagePackEncoder, n as EncoderOptions, r as ExtensionEncoder, t as MessagePackExtension } from "./messagePackExtension-Ceq7jzFB.mjs";
|
|
3
3
|
import { t as MessagePackTextEncoder } from "./messagePackTextEncoder-D7iCft_t.mjs";
|
|
4
|
-
import { t as BufferWithExtensions } from "./bufferWithExtensions-
|
|
5
|
-
//#region src/encoder/
|
|
6
|
-
declare class
|
|
4
|
+
import { t as BufferWithExtensions } from "./bufferWithExtensions-Bc7vjIkw.mjs";
|
|
5
|
+
//#region src/encoder/encoder.d.ts
|
|
6
|
+
declare class Encoder<TBuffer extends Uint8Array = Uint8Array> extends BufferWithExtensions<TBuffer> implements MessagePackEncoder<TBuffer> {
|
|
7
7
|
#private;
|
|
8
8
|
/** The current offset in the buffer where the next write operation will occur. */
|
|
9
9
|
offset: number;
|
|
@@ -39,8 +39,8 @@ declare class EncoderBuffer<TBuffer extends Uint8Array = Uint8Array> extends Buf
|
|
|
39
39
|
readonly textEncoder: MessagePackTextEncoder<TBuffer>;
|
|
40
40
|
buffer: TBuffer;
|
|
41
41
|
view: DataView;
|
|
42
|
-
constructor(options?: Partial<
|
|
43
|
-
|
|
42
|
+
constructor(options?: Partial<EncoderOptions<TBuffer>>);
|
|
43
|
+
getExtensionEncoder(): Encoder<TBuffer>;
|
|
44
44
|
resizeBuffer(newSize: number): this;
|
|
45
45
|
ensureCapacity(sizeToWrite: number): this;
|
|
46
46
|
resetBuffer(): this;
|
|
@@ -100,12 +100,12 @@ declare class EncoderBuffer<TBuffer extends Uint8Array = Uint8Array> extends Buf
|
|
|
100
100
|
openArray(length: number): this;
|
|
101
101
|
writeArray(value: unknown[]): this;
|
|
102
102
|
writeUint8Array(value: Uint8Array): this;
|
|
103
|
-
writeExtension(extension: MessagePackExtension,
|
|
103
|
+
writeExtension(extension: MessagePackExtension, encoder: ExtensionEncoder<TBuffer>): this;
|
|
104
104
|
tryToWriteExtensionValue(value: object | bigint): number;
|
|
105
105
|
writeBigInt(value: bigint): this;
|
|
106
106
|
writeObject(value: object): this;
|
|
107
107
|
write(value: unknown): this;
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
|
-
export {
|
|
111
|
-
//# sourceMappingURL=
|
|
110
|
+
export { Encoder as t };
|
|
111
|
+
//# sourceMappingURL=encoder-ZmHoedsB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder-ZmHoedsB.d.mts","names":[],"sources":["../../src/encoder/encoder.ts"],"mappings":";;;;;cAuBM,QAAQ,gBAAgB,aAAa,oBACjC,qBAAqB,oBAClB,mBAAmB;;;EAG9B;;;;;;;YAQU,cAAc;;;;;;;WAQf;;;;;;;;WASA;;;;;;;YAQC,eAAe,cAAc;WAE9B,aAAa,uBAAuB;EAE7C,QAAQ;EACR,MAAM;EAcN,YAAY,UAAU,QAAQ,eAAe;EAwB7C,uBAAuB,QAAQ;EAc/B,aAAa;EAeb,eAAe;EAUf;EAMA,SAAS;EAST,oBAAoB;EAMpB,oBAAoB;EAOpB,SAAS,OAAO;EAQhB,aAAa;EAOb,aAAa;EAOb,WAAW;EAMX,YAAY;EAOZ,YAAY;EAOZ,YAAY;EAaZ,UAAU;EAMV,WAAW;EAOX,WAAW;EAOX,WAAW;EA0BX,SAAS;EAMT;EAMA;EAMA;EAMA,kBAAkB;EAMlB,oBAAoB;EAMpB,kBAAkB;EAMlB,gBAAgB;EAOhB,iBAAiB;EAQjB,iBAAiB;EAQjB;EAMA;EAMA;EAMA;EAMA;EAMA;EAMA;EAMA;EAMA;EAMA;EAMA,gBAAgB;EAOhB,iBAAiB;EASjB,iBAAiB;EASjB,mBAAmB;EASnB,mBAAmB;EASnB,iBAAiB;EASjB,iBAAiB;EASjB,mBAAmB;EAOnB,mBAAmB;EAOnB,mBAAmB;EAOnB,mBAAmB;EAOnB,oBAAoB;EAOpB,gBAAgB,cAAc;EAQ9B,iBAAiB,cAAc;EAW/B,iBAAiB,cAAc;EAW/B,YAAY;EAyGZ,YAAY;EA0EZ,QAAQ;EAqBR,SAAS,8BAA8B,QACrC,OAAO,OAAO,MAAM;EAqBtB,UAAU;EAqBV,WAAW;EAwBX,gBAAgB,OAAO;EAiBvB,eACE,WAAW,sBACX,SAAS,iBAAiB;EAiD5B,yBAAyB;EAqBzB,YAAY;EAYZ,YAAY;EAkBZ,MAAM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as BigIntExtension } from "../../bigInt-
|
|
1
|
+
import { t as BigIntExtension } from "../../bigInt-lSrNuXkn.mjs";
|
|
2
2
|
export { BigIntExtension as default };
|
|
@@ -19,17 +19,17 @@ var BigIntExtension = class extends UntypedExtension {
|
|
|
19
19
|
* indicate negativity.
|
|
20
20
|
*
|
|
21
21
|
* @param value - The BigInt value to encode.
|
|
22
|
-
* @param
|
|
22
|
+
* @param encoder - The extension encoder to write the encoded data to.
|
|
23
23
|
*/
|
|
24
|
-
encode(value,
|
|
24
|
+
encode(value, encoder) {
|
|
25
25
|
if (typeof value === "bigint") {
|
|
26
26
|
let magnitude;
|
|
27
27
|
if (value < 0n) magnitude = (-value << 1n) - 1n;
|
|
28
28
|
else magnitude = value << 1n;
|
|
29
29
|
while (magnitude > 0n) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
encoder.ensureCapacity(8);
|
|
31
|
+
encoder.view.setBigUint64(encoder.offset, magnitude & BIGINT_MASK, false);
|
|
32
|
+
encoder.offset += 8;
|
|
33
33
|
magnitude >>= 64n;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigInt.mjs","names":[],"sources":["../../../../src/extensions/bigint/bigInt.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from '../../decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type {
|
|
1
|
+
{"version":3,"file":"bigInt.mjs","names":[],"sources":["../../../../src/extensions/bigint/bigInt.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from '../../decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type { ExtensionEncoder } from '../../encoder/types.ts';\nimport UntypedExtension from '../../untypedExtension.ts';\n\nconst BIGINT_MASK = 0xff_ff_ff_ff_ff_ff_ff_ffn;\n\n/**\n * This class encodes and decodes JavaScript BigInt values that are outside the\n * safe integer range. It encodes and decodes BigInt values using a custom\n * extension type, allowing for the serialization of large integers that cannot\n * be represented as standard JavaScript numbers. The encoding scheme uses a\n * variable-length representation to efficiently store the magnitude of the\n * BigInt value.\n */\nclass BigIntExtension<\n TBuffer extends Uint8Array = Uint8Array,\n> extends UntypedExtension<bigint, TBuffer> {\n /**\n * Encodes a BigInt value into the provided buffer. If the value is within the\n * safe integer range, it is encoded directly following the Message Pack\n * specification. Otherwise, if the value is outside the safe integer range,\n * it is encoded using a variable-length representation. Negative values are\n * handled by encoding their magnitude and using a specific bit pattern to\n * indicate negativity.\n *\n * @param value - The BigInt value to encode.\n * @param encoder - The extension encoder to write the encoded data to.\n */\n encode(value: object | bigint, encoder: ExtensionEncoder<TBuffer>): void {\n if (typeof value === 'bigint') {\n let magnitude: bigint;\n\n if (value < 0n) {\n magnitude = (-value << 1n) - 1n;\n } else {\n magnitude = value << 1n;\n }\n\n while (magnitude > 0n) {\n encoder.ensureCapacity(8);\n encoder.view.setBigUint64(\n encoder.offset,\n magnitude & BIGINT_MASK,\n false,\n );\n encoder.offset += 8;\n magnitude >>= 64n;\n }\n }\n }\n\n /**\n * Decodes a BigInt value from the provided DataView. It reads the encoded\n * data, reconstructs the magnitude, and determines the sign based on the\n * encoding scheme. The method returns the decoded BigInt value.\n */\n decode(buffer: MessagePackDecoderBuffer, size: number): bigint {\n let encoded = 0n;\n let shift = 0n;\n\n for (let offset = buffer.offset; offset < size; offset += 8) {\n encoded |= buffer.view.getBigUint64(offset, false) << shift;\n shift += 64n;\n }\n\n if ((encoded & 1n) === 1n) {\n return -((encoded + 1n) >> 1n);\n }\n\n return encoded >> 1n;\n }\n}\n\nexport default BigIntExtension;\n"],"mappings":";;AAIA,MAAM,cAAc;;;;;;;;;AAUpB,IAAM,kBAAN,cAEU,iBAAkC;;;;;;;;;;;;CAY1C,OAAO,OAAwB,SAA0C;EACvE,IAAI,OAAO,UAAU,UAAU;GAC7B,IAAI;GAEJ,IAAI,QAAQ,IACV,aAAa,CAAC,SAAS,MAAM;QAE7B,YAAY,SAAS;GAGvB,OAAO,YAAY,IAAI;IACrB,QAAQ,eAAe,CAAC;IACxB,QAAQ,KAAK,aACX,QAAQ,QACR,YAAY,aACZ,KACF;IACA,QAAQ,UAAU;IAClB,cAAc;GAChB;EACF;CACF;;;;;;CAOA,OAAO,QAAkC,MAAsB;EAC7D,IAAI,UAAU;EACd,IAAI,QAAQ;EAEZ,KAAK,IAAI,SAAS,OAAO,QAAQ,SAAS,MAAM,UAAU,GAAG;GAC3D,WAAW,OAAO,KAAK,aAAa,QAAQ,KAAK,KAAK;GACtD,SAAS;EACX;EAEA,KAAK,UAAU,QAAQ,IACrB,OAAO,EAAG,UAAU,MAAO;EAG7B,OAAO,WAAW;CACpB;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as MessagePackExtension } from "../messagePackExtension-
|
|
1
|
+
import { t as MessagePackExtension } from "../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
import { t as MessagePackTime } from "../types-B9KMW-kD.mjs";
|
|
3
|
-
import { t as TimestampDateExtension } from "../timestampDate-
|
|
3
|
+
import { t as TimestampDateExtension } from "../timestampDate-uQGrWim5.mjs";
|
|
4
4
|
export { type MessagePackExtension, type MessagePackTime, TimestampDateExtension };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MessagePackExtension } from "../../messagePackExtension-
|
|
1
|
+
import { t as MessagePackExtension } from "../../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
export { MessagePackExtension as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { t as MessagePackTime } from "../../types-B9KMW-kD.mjs";
|
|
2
|
-
import { t as TimestampDateExtension } from "../../timestampDate-
|
|
2
|
+
import { t as TimestampDateExtension } from "../../timestampDate-uQGrWim5.mjs";
|
|
3
3
|
import "../../index-CUX405iZ.mjs";
|
|
4
4
|
export { type MessagePackTime, TimestampDateExtension };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TimestampDateExtension } from "../../timestampDate-
|
|
1
|
+
import { t as TimestampDateExtension } from "../../timestampDate-uQGrWim5.mjs";
|
|
2
2
|
export { TimestampDateExtension as default };
|
|
@@ -33,20 +33,20 @@ var TimestampDateExtension = class {
|
|
|
33
33
|
sec: sec + nsecInSec
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
encode(value,
|
|
36
|
+
encode(value, encoder) {
|
|
37
37
|
if (value instanceof Date) {
|
|
38
38
|
const time = this.parseToMessagePackTime(value);
|
|
39
39
|
if (time.sec >= 0 && time.nsec >= 0 && time.sec <= TIMESTAMP64_MAX_SEC) {
|
|
40
|
-
if (time.nsec === 0 && time.sec <= TIMESTAMP32_MAX_SEC)
|
|
40
|
+
if (time.nsec === 0 && time.sec <= TIMESTAMP32_MAX_SEC) encoder.writeUint32(time.sec);
|
|
41
41
|
else {
|
|
42
42
|
const secHigh = time.sec / 4294967296;
|
|
43
43
|
const secLow = time.sec & 4294967295;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
encoder.writeUint32(time.nsec << 2 | secHigh & 3);
|
|
45
|
+
encoder.writeUint32(secLow);
|
|
46
46
|
}
|
|
47
47
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
encoder.writeUint32(time.nsec);
|
|
49
|
+
encoder.writeInt64(time.sec);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestampDate.mjs","names":[],"sources":["../../../../src/extensions/timestampDate/timestampDate.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from '../../decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type
|
|
1
|
+
{"version":3,"file":"timestampDate.mjs","names":[],"sources":["../../../../src/extensions/timestampDate/timestampDate.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from '../../decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type { ExtensionEncoder } from '../../encoder/types.ts';\nimport type MessagePackExtension from '../interfaces/messagePackExtension.ts';\nimport type { MessagePackTime } from './types.ts';\n\nconst TIMESTAMP32_MAX_SEC = 0x1_00_00_00_00 - 1; // 32-bit unsigned int // 4_294_967_295\nconst TIMESTAMP64_MAX_SEC = 0x4_00_00_00_00 - 1; // 34-bit unsigned int // 17_179_869_183\n\n/**\n * The `TimestampDateExtension` class is responsible for encoding JavaScript\n * `Date` objects into the MessagePack timestamp format.\n *\n * Timestamp extension type is assigned to extension type -1. It defines 3\n * formats: 32-bit format, 64-bit format, and 96-bit format.\n *\n * - Timestamp 32 format can represent a timestamp in [1970-01-01 00:00:00 UTC,\n * 2106-02-07 06:28:16 UTC) range. Nanoseconds part is 0.\n * - Timestamp 64 format can represent a timestamp in [1970-01-01\n * 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC) range.\n * - Timestamp 96 format can represent a timestamp in [-292277022657-01-27\n * 08:29:52 UTC, 292277026596-12-04 15:30:08.000000000 UTC) range.\n * - In timestamp 64 and timestamp 96 formats, nanoseconds must not be larger than\n * 999999999.\n *\n * @see https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type\n * @see https://github.com/msgpack/msgpack-javascript/blob/main/src/timestamp.ts\n * @see https://github.com/msgpack/msgpack-javascript/issues/216\n */\nclass TimestampDateExtension<\n TBuffer extends Uint8Array = Uint8Array,\n> implements MessagePackExtension<Date, TBuffer> {\n readonly type = -1;\n\n parseToMessagePackTime(date: Date): MessagePackTime {\n const msec = date.getTime();\n const sec = Math.floor(msec / 1e3);\n const nsec = (msec - sec * 1e3) * 1e6;\n\n // Normalizes { sec, nsec } to ensure nsec is unsigned.\n const nsecInSec = Math.floor(nsec / 1e9);\n\n return {\n nsec: nsec - nsecInSec * 1e9,\n sec: sec + nsecInSec,\n };\n }\n\n encode(value: object | bigint, encoder: ExtensionEncoder<TBuffer>): void {\n if (value instanceof Date) {\n const time = this.parseToMessagePackTime(value);\n\n if (time.sec >= 0 && time.nsec >= 0 && time.sec <= TIMESTAMP64_MAX_SEC) {\n // Here sec >= 0 && nsec >= 0\n if (time.nsec === 0 && time.sec <= TIMESTAMP32_MAX_SEC) {\n encoder.writeUint32(time.sec);\n } else {\n // timestamp 64 = { nsec30 (unsigned), sec34 (unsigned) }\n const secHigh = time.sec / 0x1_00_00_00_00;\n const secLow = time.sec & 0xff_ff_ff_ff;\n encoder.writeUint32((time.nsec << 2) | (secHigh & 0x3));\n encoder.writeUint32(secLow);\n }\n } else {\n encoder.writeUint32(time.nsec);\n encoder.writeInt64(time.sec);\n }\n }\n }\n\n decode(decoderBuffer: MessagePackDecoderBuffer<TBuffer>, size: number): Date {\n const byteOffset = decoderBuffer.offset;\n\n switch (size) {\n case 4: {\n // timestamp 32 = { sec32 }\n const sec = decoderBuffer.view.getUint32(byteOffset);\n const nsec = 0;\n // return { sec, nsec };\n return new Date(sec * 1e3 + nsec / 1e6);\n }\n case 8: {\n // timestamp 64 = { nsec30, sec34 }\n const nsec30AndSecHigh2 = decoderBuffer.view.getUint32(byteOffset);\n const secLow32 = decoderBuffer.view.getUint32(byteOffset + 4);\n const sec = (nsec30AndSecHigh2 & 0x3) * 0x1_00_00_00_00 + secLow32;\n const nsec = nsec30AndSecHigh2 >>> 2;\n return new Date(sec * 1e3 + nsec / 1e6);\n }\n case 12: {\n // timestamp 96 = { nsec32 (unsigned), sec64 (signed) }\n const high = decoderBuffer.view.getInt32(byteOffset + 4);\n const low = decoderBuffer.view.getUint32(byteOffset + 8);\n\n // const sec = getInt64(view, 4);\n const sec = high * 0x1_00_00_00_00 + low;\n const nsec = decoderBuffer.view.getUint32(byteOffset);\n return new Date(sec * 1e3 + nsec / 1e6);\n }\n default: {\n throw new Error(\n `Unrecognized data size for timestamp (expected 4, 8, or 12): ${decoderB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C1D,MAAM,OAAO,sBAAsB;IACnC,uBAAO,IAAI,KAAK,MAAM,MAAM,OAAO,GAAG;GACxC;GACA,KAAK,IAAI;IAEP,MAAM,OAAO,cAAc,KAAK,SAAS,aAAa,CAAC;IACvD,MAAM,MAAM,cAAc,KAAK,UAAU,aAAa,CAAC;IAGvD,MAAM,MAAM,OAAO,aAAkB;IACrC,MAAM,OAAO,cAAc,KAAK,UAAU,UAAU;IACpD,uBAAO,IAAI,KAAK,MAAM,MAAM,OAAO,GAAG;GACxC;GACA,SACE,MAAM,IAAI,MACR,gEAAgE,cAAc,KAAK,YACrF;EAEJ;CACF;AACF"}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import decoderDataTypesFactory from "./benchmark/decoderDataTypesFactory.mjs";
|
|
2
2
|
import { t as MessagePackTextDecoder } from "./messagePackTextDecoder-J3fr-wQn.mjs";
|
|
3
3
|
import { t as MessagePackDecoderBuffer } from "./messagePackDecoderBuffer-Cqvg0zW7.mjs";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as MessagePackEncoder, i as OmitByPattern, n as EncoderOptions, o as MessagePackBufferWithExtensions, r as ExtensionEncoder, t as MessagePackExtension } from "./messagePackExtension-Ceq7jzFB.mjs";
|
|
5
5
|
import { t as MessagePackTextEncoder } from "./messagePackTextEncoder-D7iCft_t.mjs";
|
|
6
|
-
import { t as BufferWithExtensions } from "./bufferWithExtensions-
|
|
6
|
+
import { t as BufferWithExtensions } from "./bufferWithExtensions-Bc7vjIkw.mjs";
|
|
7
7
|
import { DEFAULT_ALLOCATION_SIZE, INT32_MIN, INT64_MIN, UINT32_MAX, UINT64_MAX } from "./constants.mjs";
|
|
8
8
|
import { t as decode } from "./decode-BraWmoPw.mjs";
|
|
9
9
|
import { t as DefaultTextDecoder } from "./defaultTextDecoder-DztyzoBV.mjs";
|
|
10
|
-
import { t as DecoderBuffer } from "./decoderBuffer-
|
|
11
|
-
import { t as Decoder } from "./decoder-
|
|
10
|
+
import { t as DecoderBuffer } from "./decoderBuffer-BKic0U2F.mjs";
|
|
11
|
+
import { t as Decoder } from "./decoder-CQrtmASU.mjs";
|
|
12
12
|
import { t as NodeTextDecoder } from "./nodeTextDecoder-Dhre7WkB.mjs";
|
|
13
13
|
import { t as encode } from "./encode-4SxHVw0M.mjs";
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as Encoder } from "./encoder-PfSLnKnK.mjs";
|
|
14
|
+
import { t as Encoder } from "./encoder-ZmHoedsB.mjs";
|
|
16
15
|
import { t as DefaultTextEncoder } from "./defaultTextEncoder-BkIjtDkg.mjs";
|
|
17
16
|
import { t as NodeTextEncoder } from "./nodeTextEncoder-CegSnA6z.mjs";
|
|
18
|
-
import { t as UntypedExtension } from "./untypedExtension-
|
|
17
|
+
import { t as UntypedExtension } from "./untypedExtension-DKgyS2ak.mjs";
|
|
19
18
|
import { t as MessagePackTime } from "./types-B9KMW-kD.mjs";
|
|
20
|
-
import { t as TimestampDateExtension } from "./timestampDate-
|
|
19
|
+
import { t as TimestampDateExtension } from "./timestampDate-uQGrWim5.mjs";
|
|
21
20
|
import Symbols from "./symbols.mjs";
|
|
22
21
|
import { t as fitIn7Bits } from "./fitIn7Bits-BVHyKXCg.mjs";
|
|
23
22
|
import { t as fitIn8Bits } from "./fitIn8Bits-DQnQIhdh.mjs";
|
|
24
23
|
import { t as fitIn16Bits } from "./fitIn16Bits-D9lga-sP.mjs";
|
|
25
24
|
import { t as fitIn32Bits } from "./fitIn32Bits-BrGIMOff.mjs";
|
|
26
25
|
import { t as fitInt64Bits } from "./fitInt64Bits-CY7lVKne.mjs";
|
|
27
|
-
export { BufferWithExtensions, DEFAULT_ALLOCATION_SIZE, Decoder, DecoderBuffer, DefaultTextDecoder, DefaultTextEncoder, Encoder,
|
|
26
|
+
export { BufferWithExtensions, DEFAULT_ALLOCATION_SIZE, Decoder, DecoderBuffer, DefaultTextDecoder, DefaultTextEncoder, Encoder, type EncoderOptions, type ExtensionEncoder, INT32_MIN, INT64_MIN, type MessagePackBufferWithExtensions, type MessagePackDecoderBuffer, type MessagePackEncoder, type MessagePackExtension, type MessagePackTextDecoder, type MessagePackTextEncoder, type MessagePackTime, NodeTextDecoder, NodeTextEncoder, type OmitByPattern, Symbols, TimestampDateExtension, UINT32_MAX, UINT64_MAX, UntypedExtension, decode, decoderDataTypesFactory, encode, fitIn16Bits, fitIn32Bits, fitIn7Bits, fitIn8Bits, fitInt64Bits };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import fitIn8Bits from "./utils/fitIn8Bits.mjs";
|
|
|
7
7
|
import fitIn16Bits from "./utils/fitIn16Bits.mjs";
|
|
8
8
|
import fitIn32Bits from "./utils/fitIn32Bits.mjs";
|
|
9
9
|
import DefaultTextEncoder from "./encoder/textEncoders/defaultTextEncoder.mjs";
|
|
10
|
-
import EncoderBuffer from "./encoder/encoderBuffer.mjs";
|
|
11
10
|
import Encoder from "./encoder/encoder.mjs";
|
|
12
11
|
import decoderDataTypesFactory from "./benchmark/decoderDataTypesFactory.mjs";
|
|
13
12
|
import DefaultTextDecoder from "./decoder/textDecoders/defaultTextDecoder.mjs";
|
|
@@ -23,4 +22,4 @@ import TimestampDateExtension from "./extensions/timestampDate/timestampDate.mjs
|
|
|
23
22
|
import "./extensions/index.mjs";
|
|
24
23
|
import fitInt64Bits from "./utils/fitInt64Bits.mjs";
|
|
25
24
|
import "./utils/index.mjs";
|
|
26
|
-
export { BufferWithExtensions, DEFAULT_ALLOCATION_SIZE, Decoder, DecoderBuffer, DefaultTextDecoder, DefaultTextEncoder, Encoder,
|
|
25
|
+
export { BufferWithExtensions, DEFAULT_ALLOCATION_SIZE, Decoder, DecoderBuffer, DefaultTextDecoder, DefaultTextEncoder, Encoder, INT32_MIN, INT64_MIN, NodeTextDecoder, NodeTextEncoder, Symbols, TimestampDateExtension, UINT32_MAX, UINT64_MAX, UntypedExtension, decode, decoderDataTypesFactory, encode, fitIn16Bits, fitIn32Bits, fitIn7Bits, fitIn8Bits, fitInt64Bits };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { o as MessagePackBufferWithExtensions } from "../messagePackExtension-
|
|
1
|
+
import { o as MessagePackBufferWithExtensions } from "../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
export type { MessagePackBufferWithExtensions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { o as MessagePackBufferWithExtensions } from "../messagePackExtension-
|
|
1
|
+
import { o as MessagePackBufferWithExtensions } from "../messagePackExtension-Ceq7jzFB.mjs";
|
|
2
2
|
export { MessagePackBufferWithExtensions as default };
|
package/dist/esm/{messagePackExtension-fq36EMAg.d.mts → messagePackExtension-Ceq7jzFB.d.mts}
RENAMED
|
@@ -13,56 +13,13 @@ interface MessagePackBufferWithExtensions<TBuffer extends Uint8Array = Uint8Arra
|
|
|
13
13
|
addExtension(extension: MessagePackExtension<unknown, TBuffer>): this;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region src/encoder/
|
|
17
|
-
interface EncoderBufferOptions<TBuffer extends Uint8Array = Uint8Array> extends BufferOptions<TBuffer> {
|
|
18
|
-
/**
|
|
19
|
-
* The initial size of the shared buffer. Shared buffer is used to encode
|
|
20
|
-
* strings, to avoid allocating a new buffer for each string. This helps to
|
|
21
|
-
* improve performance by reducing memory allocations and garbage collection
|
|
22
|
-
* overhead.
|
|
23
|
-
*
|
|
24
|
-
* @default 1024
|
|
25
|
-
*/
|
|
26
|
-
initialSharedBufferSize?: number;
|
|
27
|
-
/**
|
|
28
|
-
* A text encoder that will be used to encode strings into bytes.
|
|
29
|
-
*
|
|
30
|
-
* @default DefaultTextEncoder
|
|
31
|
-
*/
|
|
32
|
-
textEncoder?: MessagePackTextEncoder<TBuffer>;
|
|
33
|
-
/**
|
|
34
|
-
* If true, the keys of objects will be sorted before encoding. This can be
|
|
35
|
-
* useful for ensuring consistent encoding of objects with the same keys but
|
|
36
|
-
* in different orders.
|
|
37
|
-
*
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
sortKeys?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* If true, all floats will be encoded as float32, but it may result in loss
|
|
43
|
-
* of precision for some floats (like `1.2`), this is a JavaScript
|
|
44
|
-
* limitation.
|
|
45
|
-
*
|
|
46
|
-
* If false, floats will be encoded as float64, which is more precise but
|
|
47
|
-
* takes up more space.
|
|
48
|
-
*
|
|
49
|
-
* Set to true only if you are sure that your floats can be represented as
|
|
50
|
-
* float32 without loss of precision.
|
|
51
|
-
*
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
forceFloat32?: boolean;
|
|
55
|
-
}
|
|
56
|
-
type OmitByPattern<TRecord, Pattern extends string> = { [TKey in keyof TRecord as TKey extends Pattern ? never : TKey]: TRecord[TKey]; };
|
|
57
|
-
type ExtensionEncoderBuffer<TBuffer extends Uint8Array = Uint8Array> = OmitByPattern<MessagePackEncoderBuffer<TBuffer>, `${string}Extension` | 'resetBuffer' | 'extensions'>;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/encoder/interfaces/messagePackEncoderBuffer.d.ts
|
|
16
|
+
//#region src/encoder/interfaces/messagePackEncoder.d.ts
|
|
60
17
|
/**
|
|
61
18
|
* Defines the core methods for managing a buffer. It serves as the foundation
|
|
62
19
|
* for buffer management in the encoding process, allowing for efficient
|
|
63
20
|
* handling of binary data while adhering to the MessagePack format.
|
|
64
21
|
*/
|
|
65
|
-
interface
|
|
22
|
+
interface MessagePackEncoder<TBuffer extends Uint8Array = Uint8Array> extends MessagePackBufferWithExtensions<TBuffer> {
|
|
66
23
|
/** Buffer management * */
|
|
67
24
|
/**
|
|
68
25
|
* Returns the underlying buffer. This method provides access to the raw data
|
|
@@ -934,9 +891,52 @@ interface MessagePackEncoderBuffer<TBuffer extends Uint8Array = Uint8Array> exte
|
|
|
934
891
|
* type is a signed 8-bit integer.
|
|
935
892
|
* ```
|
|
936
893
|
*/
|
|
937
|
-
writeExtension(extension: MessagePackExtension, buffer:
|
|
894
|
+
writeExtension(extension: MessagePackExtension, buffer: ExtensionEncoder<TBuffer>): this;
|
|
938
895
|
}
|
|
939
896
|
//#endregion
|
|
897
|
+
//#region src/encoder/types.d.ts
|
|
898
|
+
interface EncoderOptions<TBuffer extends Uint8Array = Uint8Array> extends BufferOptions<TBuffer> {
|
|
899
|
+
/**
|
|
900
|
+
* The initial size of the shared buffer. Shared buffer is used to encode
|
|
901
|
+
* strings, to avoid allocating a new buffer for each string. This helps to
|
|
902
|
+
* improve performance by reducing memory allocations and garbage collection
|
|
903
|
+
* overhead.
|
|
904
|
+
*
|
|
905
|
+
* @default 1024
|
|
906
|
+
*/
|
|
907
|
+
initialSharedBufferSize?: number;
|
|
908
|
+
/**
|
|
909
|
+
* A text encoder that will be used to encode strings into bytes.
|
|
910
|
+
*
|
|
911
|
+
* @default DefaultTextEncoder
|
|
912
|
+
*/
|
|
913
|
+
textEncoder?: MessagePackTextEncoder<TBuffer>;
|
|
914
|
+
/**
|
|
915
|
+
* If true, the keys of objects will be sorted before encoding. This can be
|
|
916
|
+
* useful for ensuring consistent encoding of objects with the same keys but
|
|
917
|
+
* in different orders.
|
|
918
|
+
*
|
|
919
|
+
* @default false
|
|
920
|
+
*/
|
|
921
|
+
sortKeys?: boolean;
|
|
922
|
+
/**
|
|
923
|
+
* If true, all floats will be encoded as float32, but it may result in loss
|
|
924
|
+
* of precision for some floats (like `1.2`), this is a JavaScript
|
|
925
|
+
* limitation.
|
|
926
|
+
*
|
|
927
|
+
* If false, floats will be encoded as float64, which is more precise but
|
|
928
|
+
* takes up more space.
|
|
929
|
+
*
|
|
930
|
+
* Set to true only if you are sure that your floats can be represented as
|
|
931
|
+
* float32 without loss of precision.
|
|
932
|
+
*
|
|
933
|
+
* @default false
|
|
934
|
+
*/
|
|
935
|
+
forceFloat32?: boolean;
|
|
936
|
+
}
|
|
937
|
+
type OmitByPattern<TRecord, Pattern extends string> = { [TKey in keyof TRecord as TKey extends Pattern ? never : TKey]: TRecord[TKey]; };
|
|
938
|
+
type ExtensionEncoder<TBuffer extends Uint8Array = Uint8Array> = OmitByPattern<MessagePackEncoder<TBuffer>, `${string}Extension` | 'resetBuffer' | 'extensions'>;
|
|
939
|
+
//#endregion
|
|
940
940
|
//#region src/extensions/interfaces/messagePackExtension.d.ts
|
|
941
941
|
interface MessagePackExtension<TValue = unknown, TBuffer extends Uint8Array = Uint8Array> {
|
|
942
942
|
/**
|
|
@@ -951,9 +951,9 @@ interface MessagePackExtension<TValue = unknown, TBuffer extends Uint8Array = Ui
|
|
|
951
951
|
*
|
|
952
952
|
* @param value - The value to be encoded. This can be of any type, but the
|
|
953
953
|
* implementation should handle specific types as needed.
|
|
954
|
-
* @param
|
|
954
|
+
* @param encoder - The extension encoder where the data will be written.
|
|
955
955
|
*/
|
|
956
|
-
encode(value: object | bigint,
|
|
956
|
+
encode(value: object | bigint, encoder: ExtensionEncoder<TBuffer>): void;
|
|
957
957
|
/**
|
|
958
958
|
* Decodes a value from the provided DataView starting at the specified
|
|
959
959
|
* offset. The method should read the necessary bytes from the DataView,
|
|
@@ -968,5 +968,5 @@ interface MessagePackExtension<TValue = unknown, TBuffer extends Uint8Array = Ui
|
|
|
968
968
|
decode(decoderBuffer: MessagePackDecoderBuffer, size: number): TValue;
|
|
969
969
|
}
|
|
970
970
|
//#endregion
|
|
971
|
-
export {
|
|
972
|
-
//# sourceMappingURL=messagePackExtension-
|
|
971
|
+
export { MessagePackEncoder as a, OmitByPattern as i, EncoderOptions as n, MessagePackBufferWithExtensions as o, ExtensionEncoder as r, MessagePackExtension as t };
|
|
972
|
+
//# sourceMappingURL=messagePackExtension-Ceq7jzFB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messagePackExtension-Ceq7jzFB.d.mts","names":[],"sources":["../../src/interfaces/messagePackBufferWithExtensions.ts","../../src/encoder/interfaces/messagePackEncoder.ts","../../src/encoder/types.ts","../../src/ext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Cqvg0zW7.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { r as ExtensionEncoder, t as MessagePackExtension } from "./messagePackExtension-Ceq7jzFB.mjs";
|
|
3
3
|
import { t as MessagePackTime } from "./types-B9KMW-kD.mjs";
|
|
4
4
|
//#region src/extensions/timestampDate/timestampDate.d.ts
|
|
5
5
|
/**
|
|
@@ -25,9 +25,9 @@ import { t as MessagePackTime } from "./types-B9KMW-kD.mjs";
|
|
|
25
25
|
declare class TimestampDateExtension<TBuffer extends Uint8Array = Uint8Array> implements MessagePackExtension<Date, TBuffer> {
|
|
26
26
|
readonly type = -1;
|
|
27
27
|
parseToMessagePackTime(date: Date): MessagePackTime;
|
|
28
|
-
encode(value: object | bigint,
|
|
28
|
+
encode(value: object | bigint, encoder: ExtensionEncoder<TBuffer>): void;
|
|
29
29
|
decode(decoderBuffer: MessagePackDecoderBuffer<TBuffer>, size: number): Date;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { TimestampDateExtension as t };
|
|
33
|
-
//# sourceMappingURL=timestampDate-
|
|
33
|
+
//# sourceMappingURL=timestampDate-uQGrWim5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestampDate-uQGrWim5.d.mts","names":[],"sources":["../../src/extensions/timestampDate/timestampDate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;cA4BM,uBACJ,gBAAgB,aAAa,uBAClB,qBAAqB,MAAM;WAC7B;EAET,uBAAuB,MAAM,OAAO;EAcpC,OAAO,wBAAwB,SAAS,iBAAiB;EAsBzD,OAAO,eAAe,yBAAyB,UAAU,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as MessagePackDecoderBuffer } from "./messagePackDecoderBuffer-Cqvg0zW7.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { r as ExtensionEncoder, t as MessagePackExtension } from "./messagePackExtension-Ceq7jzFB.mjs";
|
|
3
3
|
//#region src/untypedExtension.d.ts
|
|
4
4
|
declare abstract class UntypedExtension<TValue = unknown, TBuffer extends Uint8Array = Uint8Array> implements MessagePackExtension<TValue, TBuffer> {
|
|
5
5
|
readonly type: number;
|
|
@@ -8,9 +8,9 @@ declare abstract class UntypedExtension<TValue = unknown, TBuffer extends Uint8A
|
|
|
8
8
|
* between 0 and 127, default is 0.
|
|
9
9
|
*/
|
|
10
10
|
constructor(type?: number);
|
|
11
|
-
abstract encode(value: object | bigint,
|
|
11
|
+
abstract encode(value: object | bigint, encoder: ExtensionEncoder<TBuffer>): void;
|
|
12
12
|
abstract decode(decoderBuffer: MessagePackDecoderBuffer, size: number): TValue;
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { UntypedExtension as t };
|
|
16
|
-
//# sourceMappingURL=untypedExtension-
|
|
16
|
+
//# sourceMappingURL=untypedExtension-DKgyS2ak.d.mts.map
|
package/dist/esm/{untypedExtension-Ckk9RwQw.d.mts.map → untypedExtension-DKgyS2ak.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"untypedExtension-
|
|
1
|
+
{"version":3,"file":"untypedExtension-DKgyS2ak.d.mts","names":[],"sources":["../../src/untypedExtension.ts"],"mappings":";;;uBAIe,iBACb,kBACA,gBAAgB,aAAa,uBAClB,qBAAqB,QAAQ;WAC/B;;;;;EAMT,YAAY;WAIH,OACP,wBACA,SAAS,iBAAiB;WAGnB,OACP,eAAe,0BACf,eACC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as UntypedExtension } from "./untypedExtension-
|
|
1
|
+
import { t as UntypedExtension } from "./untypedExtension-DKgyS2ak.mjs";
|
|
2
2
|
export { UntypedExtension as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"untypedExtension.mjs","names":[],"sources":["../../src/untypedExtension.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from './decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type
|
|
1
|
+
{"version":3,"file":"untypedExtension.mjs","names":[],"sources":["../../src/untypedExtension.ts"],"sourcesContent":["import type MessagePackDecoderBuffer from './decoder/interfaces/messagePackDecoderBuffer.ts';\nimport type { ExtensionEncoder } from './encoder/types.ts';\nimport type MessagePackExtension from './extensions/interfaces/messagePackExtension.ts';\n\nabstract class UntypedExtension<\n TValue = unknown,\n TBuffer extends Uint8Array = Uint8Array,\n> implements MessagePackExtension<TValue, TBuffer> {\n readonly type: number;\n\n /**\n * @param type - The extension type for BigInt values. Can be a integer\n * between 0 and 127, default is 0.\n */\n constructor(type = 0) {\n this.type = type;\n }\n\n abstract encode(\n value: object | bigint,\n encoder: ExtensionEncoder<TBuffer>,\n ): void;\n\n abstract decode(\n decoderBuffer: MessagePackDecoderBuffer,\n size: number,\n ): TValue;\n}\n\nexport default UntypedExtension;\n"],"mappings":";AAIA,IAAe,mBAAf,MAGmD;CACjD;;;;;CAMA,YAAY,OAAO,GAAG;EACpB,KAAK,OAAO;CACd;AAWF"}
|