UNPKG

@qsocket/protocol

Version:

QSocket Protocol: A versatile protocol for transmitting messages of any type in buffer format, designed exclusively for the QSocket ecosystem. Enables efficient, high-speed data transfer between processes and across client-server connections.

1 lines 26.3 kB
{"version":3,"sources":["../src/index.ts","../src/bin/protocol.enums.ts","../src/bin/protocol.errors.ts","../src/bin/protocol.ts"],"sourcesContent":["// Re-export all types and interfaces\nexport type {\n\tIQSocketProtocolChunk,\n\tIQSocketProtocolMessage,\n\tIQSocketProtocolMessageMetaAck,\n\tIQSocketProtocolMessageMetaControl,\n\tIQSocketProtocolMessageMetaData,\n\tIQSocketProtocolPayload,\n\tTQSocketProtocolPayloadData,\n} from './bin/protocol.types';\n// Re-export all enums\nexport { EQSocketProtocolMessageType, EQSocketProtocolContentType } from './bin/protocol.enums';\n// Re-export all errors\nexport { QSocketProtocolDecodeError, QSocketProtocolEncodeError } from './bin/protocol.errors';\n// Re-export protocol\nexport { from, to } from './bin/protocol';\n","/**\n * Message type options.\n * Defines the primary message type: data transfer or control.\n */\nexport enum EQSocketProtocolMessageType {\n\t/**\n\t * Data transfer protocol. Message carries a payload with data.\n\t * Binary value: 00\n\t */\n\tDATA = 0b00,\n\n\t/**\n\t * Control protocol. Message is intended for connection management.\n\t * Binary value: 01\n\t */\n\tCONTROL = 0b01,\n\n\t/**\n\t * Acknowledgment protocol.\n\t * Confirms delivery of a message.\n\t * Binary value: 10\n\t */\n\tACK = 0b10,\n}\n\n/**\n * Payload content format.\n * Used to specify the type of content in the QSOCKET protocol.\n */\nexport enum EQSocketProtocolContentType {\n\t/**\n\t * No data. Used when payload is not required.\n\t * Binary value: 000\n\t */\n\tUNDEFINED = 0b000,\n\n\t/**\n\t * Null data. Explicitly indicates no value in payload.\n\t * Binary value: 001\n\t */\n\tNULL = 0b001,\n\n\t/**\n\t * Boolean value. Payload is interpreted as a boolean.\n\t * Binary value: 010\n\t */\n\tBOOLEAN = 0b010,\n\n\t/**\n\t * Numeric value. Payload is interpreted as a number.\n\t * Binary value: 011\n\t */\n\tNUMBER = 0b011,\n\n\t/**\n\t * String. Payload is interpreted as a UTF-8 encoded string.\n\t * Binary value: 100\n\t */\n\tSTRING = 0b100,\n\n\t/**\n\t * Object. Payload represents a serialized JSON object.\n\t * Binary value: 101\n\t */\n\tJSON = 0b101,\n\n\t/**\n\t * Buffer. Payload is transmitted as binary data (Buffer).\n\t * Binary value: 110\n\t */\n\tBUFFER = 0b110,\n}\n","/**\n * Represents an error that occurred during the encoding process in the QSocketProtocol.\n * Extends the base `Error` class to provide more context specific to encoding issues.\n */\nexport class QSocketProtocolEncodeError extends Error {\n\t/**\n\t * Creates an instance of QSocketProtocolEncodeError.\n\t *\n\t * @param message - A descriptive error message.\n\t * @param originalError - (Optional) The original error that caused this encoding error, if any.\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic originalError?: Error\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'QSocketProtocolEncodeError';\n\t\tif (originalError) {\n\t\t\tthis.stack += `\\nCaused by: ${originalError.stack}`;\n\t\t}\n\t}\n}\n\n/**\n * Represents an error that occurred during the decoding process in the QSocketProtocol.\n * Extends the base `Error` class to provide more context specific to decoding issues.\n */\nexport class QSocketProtocolDecodeError extends Error {\n\t/**\n\t * Creates an instance of QSocketProtocolDecodeError.\n\t *\n\t * @param message - A descriptive error message.\n\t * @param originalError - (Optional) The original error that caused this decoding error, if any.\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic originalError?: Error\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'QSocketProtocolDecodeError';\n\t\tif (originalError) {\n\t\t\tthis.stack += `\\nCaused by: ${originalError.stack}`;\n\t\t}\n\t}\n}\n","// Import necessary types, enums, and error classes\nimport type { IQSocketProtocolChunk, IQSocketProtocolMessage, TChunkBinary } from './protocol.types';\nimport { EQSocketProtocolContentType } from './protocol.enums';\nimport { QSocketProtocolEncodeError, QSocketProtocolDecodeError } from './protocol.errors';\n\n//#region Text Encoding/Decoding\n\n/**\n * Encodes a string into a Uint8Array using the most efficient available method.\n * Falls back to manual UTF-8 encoding if neither TextEncoder nor Buffer is available.\n *\n * @returns {(str: string) => Uint8Array} A function that takes a string and returns its Uint8Array representation.\n */\nconst encodeString = ((): ((str: string) => Uint8Array) => {\n\t// Use TextEncoder if available (modern browsers and Node.js v11+)\n\tif (typeof TextEncoder !== 'undefined') {\n\t\tconst encoder = new TextEncoder();\n\t\treturn (str: string): Uint8Array => encoder.encode(str);\n\t}\n\n\t// Fallback to Buffer if available (Node.js environment)\n\tif (typeof Buffer !== 'undefined') {\n\t\treturn (str: string): Uint8Array => {\n\t\t\tconst buffer = Buffer.from(str, 'utf8'); // Encode string to Buffer\n\t\t\tconst copy = new Uint8Array(buffer.length); // Create a new Uint8Array with the same length\n\t\t\tcopy.set(buffer); // Copy Buffer contents to Uint8Array\n\t\t\treturn copy; // Return the copied Uint8Array\n\t\t};\n\t}\n\n\t// Manual UTF-8 encoding as a last resort\n\treturn (str: string): Uint8Array => {\n\t\tconst maxLength = str.length * 4; // Maximum possible length (each character can take up to 4 bytes in UTF-8)\n\t\tconst result = new Uint8Array(maxLength); // Initialize the result array\n\t\tlet offset = 0; // Current position in the result array\n\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\tlet charCode = str.charCodeAt(i); // Get UTF-16 code unit\n\n\t\t\tif (charCode < 0x80) {\n\t\t\t\t// 1-byte ASCII character\n\t\t\t\tresult[offset++] = charCode;\n\t\t\t} else if (charCode < 0x800) {\n\t\t\t\t// 2-byte UTF-8 character\n\t\t\t\tresult[offset++] = 0xc0 | (charCode >> 6);\n\t\t\t\tresult[offset++] = 0x80 | (charCode & 0x3f);\n\t\t\t} else if (charCode < 0xd800 || charCode >= 0xe000) {\n\t\t\t\t// 3-byte UTF-8 character (excluding surrogate pairs)\n\t\t\t\tresult[offset++] = 0xe0 | (charCode >> 12);\n\t\t\t\tresult[offset++] = 0x80 | ((charCode >> 6) & 0x3f);\n\t\t\t\tresult[offset++] = 0x80 | (charCode & 0x3f);\n\t\t\t} else {\n\t\t\t\t// 4-byte UTF-8 character (surrogate pairs)\n\t\t\t\tif (++i >= str.length) throw new Error('Invalid surrogate pair in string');\n\t\t\t\t// Combine surrogate pair into a single code point\n\t\t\t\tcharCode = 0x10000 + (((charCode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));\n\t\t\t\tresult[offset++] = 0xf0 | (charCode >> 18);\n\t\t\t\tresult[offset++] = 0x80 | ((charCode >> 12) & 0x3f);\n\t\t\t\tresult[offset++] = 0x80 | ((charCode >> 6) & 0x3f);\n\t\t\t\tresult[offset++] = 0x80 | (charCode & 0x3f);\n\t\t\t}\n\t\t}\n\n\t\t// Slice the result to the actual length used\n\t\tconst resultBuffer = result.slice(0, offset);\n\t\treturn resultBuffer;\n\t};\n})();\n\n/**\n * Decodes a Uint8Array into a string using the most efficient available method.\n * Falls back to manual UTF-8 decoding if neither TextDecoder nor Buffer is available.\n *\n * @returns {(bytes: Uint8Array) => string} A function that takes a Uint8Array and returns its string representation.\n */\nconst decodeString = ((): ((bytes: Uint8Array) => string) => {\n\t// Use TextDecoder if available (modern browsers and Node.js v11+)\n\tif (typeof TextDecoder !== 'undefined') {\n\t\tconst decoder = new TextDecoder('utf-8');\n\t\treturn (bytes: Uint8Array): string => decoder.decode(bytes);\n\t}\n\n\t// Fallback to Buffer if available (Node.js environment)\n\tif (typeof Buffer !== 'undefined') {\n\t\treturn (bytes: Uint8Array): string => Buffer.from(bytes).toString('utf8');\n\t}\n\n\t// Manual UTF-8 decoding as a last resort\n\treturn (bytes: Uint8Array): string => {\n\t\tlet result = ''; // Initialize the result string\n\t\tlet i = 0; // Current position in the byte array\n\n\t\twhile (i < bytes.length) {\n\t\t\tconst byte1 = bytes[i++]; // Read the first byte\n\n\t\t\tif (byte1 < 0x80) {\n\t\t\t\t// 1-byte ASCII character\n\t\t\t\tresult += String.fromCharCode(byte1);\n\t\t\t} else if (byte1 < 0xe0) {\n\t\t\t\t// 2-byte UTF-8 character\n\t\t\t\tconst byte2 = bytes[i++];\n\t\t\t\tif ((byte2 & 0xc0) !== 0x80) throw new Error('Invalid UTF-8 sequence');\n\t\t\t\tresult += String.fromCharCode(((byte1 & 0x1f) << 6) | (byte2 & 0x3f));\n\t\t\t} else if (byte1 < 0xf0) {\n\t\t\t\t// 3-byte UTF-8 character\n\t\t\t\tconst byte2 = bytes[i++];\n\t\t\t\tconst byte3 = bytes[i++];\n\t\t\t\tif ((byte2 & 0xc0) !== 0x80 || (byte3 & 0xc0) !== 0x80) throw new Error('Invalid UTF-8 sequence');\n\t\t\t\tresult += String.fromCharCode(((byte1 & 0x0f) << 12) | ((byte2 & 0x3f) << 6) | (byte3 & 0x3f));\n\t\t\t} else {\n\t\t\t\t// 4-byte UTF-8 character (surrogate pairs)\n\t\t\t\tconst byte2 = bytes[i++];\n\t\t\t\tconst byte3 = bytes[i++];\n\t\t\t\tconst byte4 = bytes[i++];\n\t\t\t\tif ((byte2 & 0xc0) !== 0x80 || (byte3 & 0xc0) !== 0x80 || (byte4 & 0xc0) !== 0x80) throw new Error('Invalid UTF-8 sequence');\n\n\t\t\t\tconst codePoint = ((byte1 & 0x07) << 18) | ((byte2 & 0x3f) << 12) | ((byte3 & 0x3f) << 6) | (byte4 & 0x3f);\n\n\t\t\t\t// Convert code point to surrogate pair for UTF-16\n\t\t\t\tconst highSurrogate = 0xd800 + ((codePoint - 0x10000) >> 10);\n\t\t\t\tconst lowSurrogate = 0xdc00 + ((codePoint - 0x10000) & 0x3ff);\n\n\t\t\t\tresult += String.fromCharCode(highSurrogate, lowSurrogate);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n})();\n\n//#endregion\n\n//#region Integer Encoding/Decoding\n\n/**\n * Writes a 32-bit unsigned integer into a Uint8Array at the specified offset in big-endian format.\n *\n * @param {Uint8Array} buffer - The buffer to write the integer into.\n * @param {number} offset - The position in the buffer to start writing.\n * @param {number} value - The 32-bit unsigned integer to write.\n */\nfunction writeUInt32BE(buffer: Uint8Array, offset: number, value: number): void {\n\tbuffer[offset] = (value >>> 24) & 0xff;\n\tbuffer[offset + 1] = (value >>> 16) & 0xff;\n\tbuffer[offset + 2] = (value >>> 8) & 0xff;\n\tbuffer[offset + 3] = value & 0xff;\n}\n\n/**\n * Reads a 32-bit unsigned integer from a Uint8Array at the specified offset in big-endian format.\n *\n * @param {Uint8Array} buffer - The buffer to read the integer from.\n * @param {number} offset - The position in the buffer to start reading.\n * @returns {number} The 32-bit unsigned integer read from the buffer.\n */\nfunction readUInt32BE(buffer: Uint8Array, offset: number): number {\n\treturn ((buffer[offset] << 24) | (buffer[offset + 1] << 16) | (buffer[offset + 2] << 8) | buffer[offset + 3]) >>> 0;\n}\n\n//#endregion\n\n//#region Floating-Point Number Encoding/Decoding\n\n/**\n * A static buffer used for temporary storage during floating-point number encoding/decoding.\n * This buffer should only be used within the encoding/decoding functions to avoid unintended side effects.\n */\nconst staticDataViewBuffer = new Uint8Array(8);\nconst staticDataView = new DataView(staticDataViewBuffer.buffer);\n\n/**\n * Writes a 64-bit floating-point number into a Uint8Array at the specified offset in big-endian format.\n *\n * @param {Uint8Array} buffer - The buffer to write the floating-point number into.\n * @param {number} offset - The position in the buffer to start writing.\n * @param {number} value - The 64-bit floating-point number to write.\n */\nfunction writeDoubleBE(buffer: Uint8Array, offset: number, value: number): void {\n\tstaticDataView.setFloat64(0, value, false); // false for big-endian\n\tbuffer.set(staticDataViewBuffer, offset); // Copy the bytes into the target buffer\n}\n\n/**\n * Reads a 64-bit floating-point number from a Uint8Array at the specified offset in big-endian format.\n *\n * @param {Uint8Array} buffer - The buffer to read the floating-point number from.\n * @param {number} offset - The position in the buffer to start reading.\n * @returns {number} The 64-bit floating-point number read from the buffer.\n */\nfunction readDoubleBE(buffer: Uint8Array, offset: number): number {\n\tstaticDataViewBuffer.set(buffer.subarray(offset, offset + 8)); // Copy 8 bytes to the static buffer\n\treturn staticDataView.getFloat64(0, false); // false for big-endian\n}\n\n//#endregion\n\n//#region Encoding\n\n/**\n * Serializes an IQSocketProtocolMessage into a single Uint8Array.\n *\n * @param {IQSocketProtocolMessage} message - The message to serialize.\n * @returns {Uint8Array} The serialized binary representation of the message.\n * @throws {QSocketProtocolEncodeError} If an encoding error occurs.\n */\nexport function to(message: IQSocketProtocolMessage): Uint8Array {\n\ttry {\n\t\t// Calculate the total length required for the serialized buffer\n\t\tlet totalLength = 0;\n\t\tconst chunkBinaries: TChunkBinary[] = new Array(message.length);\n\n\t\tlet chunk: IQSocketProtocolChunk;\n\t\tlet meta: Uint8Array;\n\t\tlet data: Uint8Array;\n\n\t\t// Serialize each chunk in the message\n\t\tfor (let i = 0; i < message.length; i++) {\n\t\t\tchunk = message[i];\n\n\t\t\t// Encode metadata and payload\n\t\t\tmeta = encodeString(JSON.stringify(chunk.meta));\n\t\t\tdata = encodePayload(chunk);\n\n\t\t\t// Accumulate the total length:\n\t\t\t// 1 byte for encoding, 4 bytes for meta length, meta.length bytes,\n\t\t\t// 4 bytes for data length, and data.length bytes\n\t\t\ttotalLength += 1 + 4 + meta.length + 4 + data.length;\n\n\t\t\t// Store the serialized chunk data\n\t\t\tchunkBinaries[i] = {\n\t\t\t\tencoding: chunk.payload['Content-Type'],\n\t\t\t\tmeta,\n\t\t\t\tdata,\n\t\t\t};\n\t\t}\n\n\t\t// Create a buffer to hold the entire serialized message\n\t\tconst messageBinary = new Uint8Array(totalLength);\n\t\tlet offset = 0;\n\t\tlet chunkBinary: TChunkBinary;\n\n\t\t// Write each serialized chunk into the buffer\n\t\tfor (let i = 0; i < chunkBinaries.length; i++) {\n\t\t\tchunkBinary = chunkBinaries[i];\n\n\t\t\t// Write the content type encoding (1 byte)\n\t\t\tmessageBinary[offset] = chunkBinary.encoding;\n\t\t\toffset += 1;\n\n\t\t\t// Write the length of the metadata (4 bytes)\n\t\t\twriteUInt32BE(messageBinary, offset, chunkBinary.meta.length);\n\t\t\toffset += 4;\n\n\t\t\t// Write the metadata bytes\n\t\t\tmessageBinary.set(chunkBinary.meta, offset);\n\t\t\toffset += chunkBinary.meta.length;\n\n\t\t\t// Write the length of the payload data (4 bytes)\n\t\t\twriteUInt32BE(messageBinary, offset, chunkBinary.data.length);\n\t\t\toffset += 4;\n\n\t\t\t// Write the payload data bytes\n\t\t\tmessageBinary.set(chunkBinary.data, offset);\n\t\t\toffset += chunkBinary.data.length;\n\t\t}\n\n\t\treturn messageBinary; // Return the fully serialized message\n\t} catch (error) {\n\t\t// Wrap and rethrow any encoding errors\n\t\tthrow new QSocketProtocolEncodeError((error as Error).message);\n\t}\n}\n\n/**\n * Encodes the payload of a protocol chunk into a Uint8Array based on its content type.\n *\n * @param {IQSocketProtocolChunk} chunk - The protocol chunk containing the payload to encode.\n * @returns {Uint8Array} The encoded payload data.\n * @throws {Error} If the content type is unknown or the data type is invalid.\n */\nfunction encodePayload(chunk: IQSocketProtocolChunk): Uint8Array {\n\tconst { data } = chunk.payload;\n\tconst contentType = chunk.payload['Content-Type'];\n\n\tswitch (contentType) {\n\t\tcase EQSocketProtocolContentType.UNDEFINED:\n\t\tcase EQSocketProtocolContentType.NULL:\n\t\t\treturn new Uint8Array(0); // No data for undefined or null\n\n\t\tcase EQSocketProtocolContentType.BOOLEAN:\n\t\t\treturn new Uint8Array([data ? 1 : 0]); // 1 byte representing boolean value\n\n\t\tcase EQSocketProtocolContentType.NUMBER:\n\t\t\tconst numberBuffer = new Uint8Array(8); // 8 bytes for 64-bit float\n\t\t\twriteDoubleBE(numberBuffer, 0, data as number); // Encode the number\n\t\t\treturn numberBuffer;\n\n\t\tcase EQSocketProtocolContentType.STRING:\n\t\t\treturn encodeString(data as string); // Encode the string\n\n\t\tcase EQSocketProtocolContentType.JSON:\n\t\t\treturn encodeString(JSON.stringify(data)); // Encode the JSON string\n\n\t\tcase EQSocketProtocolContentType.BUFFER:\n\t\t\tif (data instanceof Uint8Array) {\n\t\t\t\treturn data; // Return the existing Uint8Array\n\t\t\t} else if (data instanceof Buffer) {\n\t\t\t\treturn new Uint8Array(data); // Convert Buffer to Uint8Array\n\t\t\t} else {\n\t\t\t\tthrow new Error('Invalid data type for BUFFER content type'); // Unsupported data type\n\t\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error('Unknown content type'); // Unsupported content type\n\t}\n}\n\n//#endregion\n\n//#region Decoding\n\n/**\n * Deserializes a Uint8Array into an IQSocketProtocolMessage.\n *\n * @param {Uint8Array} buffer - The binary data to deserialize.\n * @returns {IQSocketProtocolMessage} The deserialized message.\n * @throws {QSocketProtocolDecodeError} If a decoding error occurs.\n */\nexport function from(buffer: Uint8Array): IQSocketProtocolMessage {\n\ttry {\n\t\tconst message: IQSocketProtocolMessage = []; // Initialize the message array\n\t\tlet offset = 0; // Current position in the buffer\n\n\t\t// Iterate through the buffer until all data is processed\n\t\twhile (offset < buffer.length) {\n\t\t\t// Read the content type encoding (1 byte)\n\t\t\tconst contentType = buffer[offset];\n\t\t\toffset += 1;\n\n\t\t\t// Read the length of the metadata (4 bytes)\n\t\t\tconst metaLength = readUInt32BE(buffer, offset);\n\t\t\toffset += 4;\n\n\t\t\t// Read and decode the metadata\n\t\t\tconst metaString = decodeString(buffer.slice(offset, offset + metaLength));\n\t\t\tlet meta: any;\n\t\t\ttry {\n\t\t\t\tmeta = JSON.parse(metaString); // Parse the JSON metadata\n\t\t\t} catch (error) {\n\t\t\t\tconsole.log('Failed to parse metadata');\n\t\t\t\tthrow error; // Rethrow the parsing error\n\t\t\t}\n\n\t\t\toffset += metaLength; // Move the offset past the metadata\n\n\t\t\t// Read the length of the payload data (4 bytes)\n\t\t\tconst dataLength = readUInt32BE(buffer, offset);\n\t\t\toffset += 4;\n\n\t\t\t// Read and decode the payload data\n\t\t\tconst data = decodePayloadData(buffer, contentType, offset, dataLength);\n\t\t\toffset += dataLength; // Move the offset past the payload data\n\n\t\t\t// Push the decoded chunk into the message array\n\t\t\tmessage.push({\n\t\t\t\tmeta,\n\t\t\t\tpayload: {\n\t\t\t\t\tdata,\n\t\t\t\t\t'Content-Type': contentType,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn message; // Return the fully decoded message\n\t} catch (error) {\n\t\t// Wrap and rethrow any decoding errors\n\t\tthrow new QSocketProtocolDecodeError((error as Error).message);\n\t}\n}\n\n/**\n * Decodes the payload data of a protocol chunk based on its content type.\n *\n * @param {Uint8Array} buffer - The binary data containing the payload.\n * @param {EQSocketProtocolContentType} contentType - The content type identifier.\n * @param {number} offset - The position in the buffer where the payload data starts.\n * @param {number} length - The length of the payload data in bytes.\n * @returns {any} The decoded payload data.\n * @throws {Error} If the content type is unknown.\n */\nfunction decodePayloadData(buffer: Uint8Array, contentType: EQSocketProtocolContentType, offset: number, length: number): any {\n\tswitch (contentType) {\n\t\tcase EQSocketProtocolContentType.UNDEFINED:\n\t\t\treturn undefined; // No data for undefined\n\n\t\tcase EQSocketProtocolContentType.NULL:\n\t\t\treturn null; // No data for null\n\n\t\tcase EQSocketProtocolContentType.BOOLEAN:\n\t\t\treturn buffer[offset] !== 0; // Decode boolean value\n\n\t\tcase EQSocketProtocolContentType.NUMBER:\n\t\t\treturn readDoubleBE(buffer, offset); // Decode 64-bit float\n\n\t\tcase EQSocketProtocolContentType.STRING:\n\t\t\treturn decodeString(buffer.slice(offset, offset + length)); // Decode string\n\n\t\tcase EQSocketProtocolContentType.JSON:\n\t\t\treturn JSON.parse(decodeString(buffer.slice(offset, offset + length))); // Decode JSON string\n\n\t\tcase EQSocketProtocolContentType.BUFFER:\n\t\t\treturn buffer.slice(offset, offset + length); // Return a slice of the buffer\n\n\t\tdefault:\n\t\t\tthrow new Error('Unknown content type'); // Unsupported content type\n\t}\n}\n\n//#endregion\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAK,8BAAL,kBAAKA,iCAAL;AAKN,EAAAA,0DAAA,UAAO,KAAP;AAMA,EAAAA,0DAAA,aAAU,KAAV;AAOA,EAAAA,0DAAA,SAAM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