@nhtio/encoder 0.1.0-master-9b97505f → 0.1.0-master-492fadb0

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.
@@ -158,7 +158,7 @@ class E_INCOMPATIBLE_VERSION extends BaseException {
158
158
  * @param version - The incompatible version string from the encoded data.
159
159
  */
160
160
  constructor(version) {
161
- const message = `Encoded data version ${version} is not compatible with the current version ${"0.1.0-master-9b97505f"}.`;
161
+ const message = `Encoded data version ${version} is not compatible with the current version ${"0.1.0-master-492fadb0"}.`;
162
162
  super(message, {
163
163
  code: E_INCOMPATIBLE_VERSION.code,
164
164
  status: E_INCOMPATIBLE_VERSION.status
@@ -173,4 +173,4 @@ exports.E_INVALID_VERSION = E_INVALID_VERSION;
173
173
  exports.E_NOT_AN_ENCODED_VALUE = E_NOT_AN_ENCODED_VALUE;
174
174
  exports.E_UNDECODABLE_VALUE = E_UNDECODABLE_VALUE;
175
175
  exports.E_UNENCODABLE_VALUE = E_UNENCODABLE_VALUE;
176
- //# sourceMappingURL=exceptions-vnhPQaJe.js.map
176
+ //# sourceMappingURL=exceptions-BfKyCF4p.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions-vnhPQaJe.js","sources":["../src/private/exceptions.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\nexport interface ErrorOptions {\n cause?: unknown\n}\n\n/**\n * Base exception class that extends the native Error class.\n * Provides a foundation for all custom exceptions with additional metadata\n * like error codes, status codes, and help descriptions.\n */\nexport class BaseException extends Error {\n /**\n * Define the error metadata as static properties to avoid\n * setting them repeatedly on the error instance\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n /**\n * Creates a new BaseException instance.\n *\n * @param message - The error message. If not provided, uses the static message from the constructor.\n * @param options - Additional options including error cause, code, and status.\n */\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof BaseException\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n /**\n * Returns the constructor name for the Symbol.toStringTag property.\n *\n * @returns The name of the exception class.\n */\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n /**\n * Returns a string representation of the exception.\n * Includes the error code in brackets if available.\n *\n * @returns A formatted string representation of the exception.\n */\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Exception thrown when a value cannot be encoded.\n * This indicates that the value type is not supported by the encoder.\n */\nexport class E_UNENCODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNENCODABLE_VALUE'\n\n /**\n * Creates a new E_UNENCODABLE_VALUE exception.\n *\n * @param value - The value that could not be encoded.\n */\n constructor(value: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_UNENCODABLE_VALUE.code,\n status: E_UNENCODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when encoding fails due to an underlying error.\n * This wraps the original error as the cause for better error tracing.\n */\nexport class E_ENCODING_FAILED extends BaseException {\n static status = 500\n static code = 'E_ENCODING_FAILED'\n\n /**\n * Creates a new E_ENCODING_FAILED exception.\n *\n * @param value - The value that failed to encode.\n * @param cause - The underlying error that caused the encoding to fail.\n */\n constructor(value: unknown, cause: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_ENCODING_FAILED.code,\n status: E_ENCODING_FAILED.status,\n cause,\n })\n }\n}\n\n/**\n * Exception thrown when a circular reference is detected during encoding.\n * Circular references cannot be encoded and must be avoided.\n */\nexport class E_CIRCULAR_REFERENCE extends BaseException {\n static status = 500\n static code = 'E_CIRCULAR_REFERENCE'\n\n /**\n * Creates a new E_CIRCULAR_REFERENCE exception.\n */\n constructor() {\n const message = `Circular reference detected.`\n super(message, {\n code: E_CIRCULAR_REFERENCE.code,\n status: E_CIRCULAR_REFERENCE.status,\n })\n }\n}\n\n/**\n * Exception thrown when a value with an unknown or unsupported type cannot be decoded.\n */\nexport class E_UNDECODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNDECODABLE_VALUE'\n\n /**\n * Creates a new E_UNDECODABLE_VALUE exception.\n *\n * @param type - The type string that could not be decoded.\n */\n constructor(type: string) {\n const message = `Value of type ${type} cannot be decoded.`\n super(message, {\n code: E_UNDECODABLE_VALUE.code,\n status: E_UNDECODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode a value that is not a valid encoded value.\n * This indicates the input string is not in the expected encoded format.\n */\nexport class E_NOT_AN_ENCODED_VALUE extends BaseException {\n static status = 500\n static code = 'E_NOT_AN_ENCODED_VALUE'\n\n /**\n * Creates a new E_NOT_AN_ENCODED_VALUE exception.\n *\n * @param value - The string value that is not a valid encoded value.\n */\n constructor(value: string) {\n const message = `Value \"${value}\" is not a valid encoded value.`\n super(message, {\n code: E_NOT_AN_ENCODED_VALUE.code,\n status: E_NOT_AN_ENCODED_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when an invalid version string is encountered.\n */\nexport class E_INVALID_VERSION extends BaseException {\n static status = 500\n static code = 'E_INVALID_VERSION'\n\n /**\n * Creates a new E_INVALID_VERSION exception.\n *\n * @param version - The invalid version string.\n */\n constructor(version: string) {\n const message = `Invalid version \"${version}\"`\n super(message, {\n code: E_INVALID_VERSION.code,\n status: E_INVALID_VERSION.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode data encoded with an incompatible version.\n * This typically occurs when the encoded data is from a newer version than the decoder supports.\n */\nexport class E_INCOMPATIBLE_VERSION extends BaseException {\n static status = 500\n static code = 'E_INCOMPATIBLE_VERSION'\n static help =\n 'This error indicates that the encoded value is from a version which is newer than the version of the decoder.'\n\n /**\n * Creates a new E_INCOMPATIBLE_VERSION exception.\n *\n * @param version - The incompatible version string from the encoded data.\n */\n constructor(version: string) {\n const message = `Encoded data version ${version} is not compatible with the current version ${__VERSION__}.`\n super(message, {\n code: E_INCOMPATIBLE_VERSION.code,\n status: E_INCOMPATIBLE_VERSION.status,\n })\n }\n}\n"],"names":[],"mappings":";AAWO,MAAM,sBAAsB,MAAM;AAAA;AAAA;AAAA;AAAA,EAavC;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,SAAkB,SAA6D;AACzF,UAAM,SAAS,OAAO;AAEtB,UAAM,mBAAmB,KAAK;AAE9B,SAAK,OAAO,iBAAiB;AAC7B,SAAK,UAAU,WAAW,iBAAiB,WAAW;AACtD,SAAK,SAAS,SAAS,UAAU,iBAAiB,UAAU;AAE5D,UAAM,OAAO,SAAS,QAAQ,iBAAiB;AAC/C,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,OAAO,iBAAiB;AAC9B,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,kBAAkB,MAAM,gBAAgB;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,OAAO,WAAW,IAAI;AACzB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,WAAW;AACT,QAAI,KAAK,MAAM;AACb,aAAO,GAAG,KAA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7B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,OAAe;AACzB,UAAM,UAAU,UAAU,KAAK;AAC/B,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;AAKO,MAAM,0BAA0B,cAAc;AAAA,EACnD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,SAAiB;AAC3B,UAAM,UAAU,oBAAoB,OAAO;AAC3C,UAAM,SAAS;AAAA,MACb,MAAM,kBAAkB;AAAA,MACxB,QAAQ,kBAAkB;AAAA,IAAA,CAC3B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA,EACd,OAAO,OACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOF,YAAY,SAAiB;AAC3B,UAAM,UAAU,wBAAwB,OAAO,+CAA+C,uBAAW;AACzG,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"exceptions-BfKyCF4p.js","sources":["../src/private/exceptions.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\nexport interface ErrorOptions {\n cause?: unknown\n}\n\n/**\n * Base exception class that extends the native Error class.\n * Provides a foundation for all custom exceptions with additional metadata\n * like error codes, status codes, and help descriptions.\n */\nexport class BaseException extends Error {\n /**\n * Define the error metadata as static properties to avoid\n * setting them repeatedly on the error instance\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n /**\n * Creates a new BaseException instance.\n *\n * @param message - The error message. If not provided, uses the static message from the constructor.\n * @param options - Additional options including error cause, code, and status.\n */\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof BaseException\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n /**\n * Returns the constructor name for the Symbol.toStringTag property.\n *\n * @returns The name of the exception class.\n */\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n /**\n * Returns a string representation of the exception.\n * Includes the error code in brackets if available.\n *\n * @returns A formatted string representation of the exception.\n */\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Exception thrown when a value cannot be encoded.\n * This indicates that the value type is not supported by the encoder.\n */\nexport class E_UNENCODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNENCODABLE_VALUE'\n\n /**\n * Creates a new E_UNENCODABLE_VALUE exception.\n *\n * @param value - The value that could not be encoded.\n */\n constructor(value: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_UNENCODABLE_VALUE.code,\n status: E_UNENCODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when encoding fails due to an underlying error.\n * This wraps the original error as the cause for better error tracing.\n */\nexport class E_ENCODING_FAILED extends BaseException {\n static status = 500\n static code = 'E_ENCODING_FAILED'\n\n /**\n * Creates a new E_ENCODING_FAILED exception.\n *\n * @param value - The value that failed to encode.\n * @param cause - The underlying error that caused the encoding to fail.\n */\n constructor(value: unknown, cause: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_ENCODING_FAILED.code,\n status: E_ENCODING_FAILED.status,\n cause,\n })\n }\n}\n\n/**\n * Exception thrown when a circular reference is detected during encoding.\n * Circular references cannot be encoded and must be avoided.\n */\nexport class E_CIRCULAR_REFERENCE extends BaseException {\n static status = 500\n static code = 'E_CIRCULAR_REFERENCE'\n\n /**\n * Creates a new E_CIRCULAR_REFERENCE exception.\n */\n constructor() {\n const message = `Circular reference detected.`\n super(message, {\n code: E_CIRCULAR_REFERENCE.code,\n status: E_CIRCULAR_REFERENCE.status,\n })\n }\n}\n\n/**\n * Exception thrown when a value with an unknown or unsupported type cannot be decoded.\n */\nexport class E_UNDECODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNDECODABLE_VALUE'\n\n /**\n * Creates a new E_UNDECODABLE_VALUE exception.\n *\n * @param type - The type string that could not be decoded.\n */\n constructor(type: string) {\n const message = `Value of type ${type} cannot be decoded.`\n super(message, {\n code: E_UNDECODABLE_VALUE.code,\n status: E_UNDECODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode a value that is not a valid encoded value.\n * This indicates the input string is not in the expected encoded format.\n */\nexport class E_NOT_AN_ENCODED_VALUE extends BaseException {\n static status = 500\n static code = 'E_NOT_AN_ENCODED_VALUE'\n\n /**\n * Creates a new E_NOT_AN_ENCODED_VALUE exception.\n *\n * @param value - The string value that is not a valid encoded value.\n */\n constructor(value: string) {\n const message = `Value \"${value}\" is not a valid encoded value.`\n super(message, {\n code: E_NOT_AN_ENCODED_VALUE.code,\n status: E_NOT_AN_ENCODED_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when an invalid version string is encountered.\n */\nexport class E_INVALID_VERSION extends BaseException {\n static status = 500\n static code = 'E_INVALID_VERSION'\n\n /**\n * Creates a new E_INVALID_VERSION exception.\n *\n * @param version - The invalid version string.\n */\n constructor(version: string) {\n const message = `Invalid version \"${version}\"`\n super(message, {\n code: E_INVALID_VERSION.code,\n status: E_INVALID_VERSION.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode data encoded with an incompatible version.\n * This typically occurs when the encoded data is from a newer version than the decoder supports.\n */\nexport class E_INCOMPATIBLE_VERSION extends BaseException {\n static status = 500\n static code = 'E_INCOMPATIBLE_VERSION'\n static help =\n 'This error indicates that the encoded value is from a version which is newer than the version of the decoder.'\n\n /**\n * Creates a new E_INCOMPATIBLE_VERSION exception.\n *\n * @param version - The incompatible version string from the encoded data.\n */\n constructor(version: string) {\n const message = `Encoded data version ${version} is not compatible with the current version ${__VERSION__}.`\n super(message, {\n code: E_INCOMPATIBLE_VERSION.code,\n status: E_INCOMPATIBLE_VERSION.status,\n })\n }\n}\n"],"names":[],"mappings":";AAWO,MAAM,sBAAsB,MAAM;AAAA;AAAA;AAAA;AAAA,EAavC;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,SAAkB,SAA6D;AACzF,UAAM,SAAS,OAAO;AAEtB,UAAM,mBAAmB,KAAK;AAE9B,SAAK,OAAO,iBAAiB;AAC7B,SAAK,UAAU,WAAW,iBAAiB,WAAW;AACtD,SAAK,SAAS,SAAS,UAAU,iBAAiB,UAAU;AAE5D,UAAM,OAAO,SAAS,QAAQ,iBAAiB;AAC/C,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,OAAO,iBAAiB;AAC9B,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,kBAAkB,MAAM,gBAAgB;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,OAAO,WAA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AAA,EAOd,YAAY,MAAc;AACxB,UAAM,UAAU,iBAAiB,IAAI;AACrC,UAAM,SAAS;AAAA,MACb,MAAM,oBAAoB;AAAA,MAC1B,QAAQ,oBAAoB;AAAA,IAAA,CAC7B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,OAAe;AACzB,UAAM,UAAU,UAAU,KAAK;AAC/B,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;AAKO,MAAM,0BAA0B,cAAc;AAAA,EACnD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,SAAiB;AAC3B,UAAM,UAAU,oBAAoB,OAAO;AAC3C,UAAM,SAAS;AAAA,MACb,MAAM,kBAAkB;AAAA,MACxB,QAAQ,kBAAkB;AAAA,IAAA,CAC3B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA,EACd,OAAO,OACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOF,YAAY,SAAiB;AAC3B,UAAM,UAAU,wBAAwB,OAAO,+CAA+C,uBAAW;AACzG,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;;;;;;;;;"}
@@ -157,7 +157,7 @@ class E_INCOMPATIBLE_VERSION extends BaseException {
157
157
  * @param version - The incompatible version string from the encoded data.
158
158
  */
159
159
  constructor(version) {
160
- const message = `Encoded data version ${version} is not compatible with the current version ${"0.1.0-master-9b97505f"}.`;
160
+ const message = `Encoded data version ${version} is not compatible with the current version ${"0.1.0-master-492fadb0"}.`;
161
161
  super(message, {
162
162
  code: E_INCOMPATIBLE_VERSION.code,
163
163
  status: E_INCOMPATIBLE_VERSION.status
@@ -174,4 +174,4 @@ export {
174
174
  E_INVALID_VERSION as e,
175
175
  E_INCOMPATIBLE_VERSION as f
176
176
  };
177
- //# sourceMappingURL=exceptions-P-gXm8Io.mjs.map
177
+ //# sourceMappingURL=exceptions-MW3dkAUt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions-P-gXm8Io.mjs","sources":["../src/private/exceptions.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\nexport interface ErrorOptions {\n cause?: unknown\n}\n\n/**\n * Base exception class that extends the native Error class.\n * Provides a foundation for all custom exceptions with additional metadata\n * like error codes, status codes, and help descriptions.\n */\nexport class BaseException extends Error {\n /**\n * Define the error metadata as static properties to avoid\n * setting them repeatedly on the error instance\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n /**\n * Creates a new BaseException instance.\n *\n * @param message - The error message. If not provided, uses the static message from the constructor.\n * @param options - Additional options including error cause, code, and status.\n */\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof BaseException\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n /**\n * Returns the constructor name for the Symbol.toStringTag property.\n *\n * @returns The name of the exception class.\n */\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n /**\n * Returns a string representation of the exception.\n * Includes the error code in brackets if available.\n *\n * @returns A formatted string representation of the exception.\n */\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Exception thrown when a value cannot be encoded.\n * This indicates that the value type is not supported by the encoder.\n */\nexport class E_UNENCODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNENCODABLE_VALUE'\n\n /**\n * Creates a new E_UNENCODABLE_VALUE exception.\n *\n * @param value - The value that could not be encoded.\n */\n constructor(value: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_UNENCODABLE_VALUE.code,\n status: E_UNENCODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when encoding fails due to an underlying error.\n * This wraps the original error as the cause for better error tracing.\n */\nexport class E_ENCODING_FAILED extends BaseException {\n static status = 500\n static code = 'E_ENCODING_FAILED'\n\n /**\n * Creates a new E_ENCODING_FAILED exception.\n *\n * @param value - The value that failed to encode.\n * @param cause - The underlying error that caused the encoding to fail.\n */\n constructor(value: unknown, cause: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_ENCODING_FAILED.code,\n status: E_ENCODING_FAILED.status,\n cause,\n })\n }\n}\n\n/**\n * Exception thrown when a circular reference is detected during encoding.\n * Circular references cannot be encoded and must be avoided.\n */\nexport class E_CIRCULAR_REFERENCE extends BaseException {\n static status = 500\n static code = 'E_CIRCULAR_REFERENCE'\n\n /**\n * Creates a new E_CIRCULAR_REFERENCE exception.\n */\n constructor() {\n const message = `Circular reference detected.`\n super(message, {\n code: E_CIRCULAR_REFERENCE.code,\n status: E_CIRCULAR_REFERENCE.status,\n })\n }\n}\n\n/**\n * Exception thrown when a value with an unknown or unsupported type cannot be decoded.\n */\nexport class E_UNDECODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNDECODABLE_VALUE'\n\n /**\n * Creates a new E_UNDECODABLE_VALUE exception.\n *\n * @param type - The type string that could not be decoded.\n */\n constructor(type: string) {\n const message = `Value of type ${type} cannot be decoded.`\n super(message, {\n code: E_UNDECODABLE_VALUE.code,\n status: E_UNDECODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode a value that is not a valid encoded value.\n * This indicates the input string is not in the expected encoded format.\n */\nexport class E_NOT_AN_ENCODED_VALUE extends BaseException {\n static status = 500\n static code = 'E_NOT_AN_ENCODED_VALUE'\n\n /**\n * Creates a new E_NOT_AN_ENCODED_VALUE exception.\n *\n * @param value - The string value that is not a valid encoded value.\n */\n constructor(value: string) {\n const message = `Value \"${value}\" is not a valid encoded value.`\n super(message, {\n code: E_NOT_AN_ENCODED_VALUE.code,\n status: E_NOT_AN_ENCODED_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when an invalid version string is encountered.\n */\nexport class E_INVALID_VERSION extends BaseException {\n static status = 500\n static code = 'E_INVALID_VERSION'\n\n /**\n * Creates a new E_INVALID_VERSION exception.\n *\n * @param version - The invalid version string.\n */\n constructor(version: string) {\n const message = `Invalid version \"${version}\"`\n super(message, {\n code: E_INVALID_VERSION.code,\n status: E_INVALID_VERSION.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode data encoded with an incompatible version.\n * This typically occurs when the encoded data is from a newer version than the decoder supports.\n */\nexport class E_INCOMPATIBLE_VERSION extends BaseException {\n static status = 500\n static code = 'E_INCOMPATIBLE_VERSION'\n static help =\n 'This error indicates that the encoded value is from a version which is newer than the version of the decoder.'\n\n /**\n * Creates a new E_INCOMPATIBLE_VERSION exception.\n *\n * @param version - The incompatible version string from the encoded data.\n */\n constructor(version: string) {\n const message = `Encoded data version ${version} is not compatible with the current version ${__VERSION__}.`\n super(message, {\n code: E_INCOMPATIBLE_VERSION.code,\n status: E_INCOMPATIBLE_VERSION.status,\n })\n }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,SAAS;AAAA,MACb,MAAM,kBAAkB;AAAA,MACxB,QAAQ,kBAAkB;AAAA,IAAA,CAC3B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA,EACd,OAAO,OACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOF,YAAY,SAAiB;AAC3B,UAAM,UAAU,wBAAwB,OAAO,+CAA+C,uBAAW;AACzG,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;"}
1
+ {"version":3,"file":"exceptions-MW3dkAUt.mjs","sources":["../src/private/exceptions.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\nexport interface ErrorOptions {\n cause?: unknown\n}\n\n/**\n * Base exception class that extends the native Error class.\n * Provides a foundation for all custom exceptions with additional metadata\n * like error codes, status codes, and help descriptions.\n */\nexport class BaseException extends Error {\n /**\n * Define the error metadata as static properties to avoid\n * setting them repeatedly on the error instance\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n /**\n * Creates a new BaseException instance.\n *\n * @param message - The error message. If not provided, uses the static message from the constructor.\n * @param options - Additional options including error cause, code, and status.\n */\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof BaseException\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n /**\n * Returns the constructor name for the Symbol.toStringTag property.\n *\n * @returns The name of the exception class.\n */\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n /**\n * Returns a string representation of the exception.\n * Includes the error code in brackets if available.\n *\n * @returns A formatted string representation of the exception.\n */\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Exception thrown when a value cannot be encoded.\n * This indicates that the value type is not supported by the encoder.\n */\nexport class E_UNENCODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNENCODABLE_VALUE'\n\n /**\n * Creates a new E_UNENCODABLE_VALUE exception.\n *\n * @param value - The value that could not be encoded.\n */\n constructor(value: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_UNENCODABLE_VALUE.code,\n status: E_UNENCODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when encoding fails due to an underlying error.\n * This wraps the original error as the cause for better error tracing.\n */\nexport class E_ENCODING_FAILED extends BaseException {\n static status = 500\n static code = 'E_ENCODING_FAILED'\n\n /**\n * Creates a new E_ENCODING_FAILED exception.\n *\n * @param value - The value that failed to encode.\n * @param cause - The underlying error that caused the encoding to fail.\n */\n constructor(value: unknown, cause: unknown) {\n const message = `Value of type ${typeof value} (${String(value)}) is not encodable.`\n super(message, {\n code: E_ENCODING_FAILED.code,\n status: E_ENCODING_FAILED.status,\n cause,\n })\n }\n}\n\n/**\n * Exception thrown when a circular reference is detected during encoding.\n * Circular references cannot be encoded and must be avoided.\n */\nexport class E_CIRCULAR_REFERENCE extends BaseException {\n static status = 500\n static code = 'E_CIRCULAR_REFERENCE'\n\n /**\n * Creates a new E_CIRCULAR_REFERENCE exception.\n */\n constructor() {\n const message = `Circular reference detected.`\n super(message, {\n code: E_CIRCULAR_REFERENCE.code,\n status: E_CIRCULAR_REFERENCE.status,\n })\n }\n}\n\n/**\n * Exception thrown when a value with an unknown or unsupported type cannot be decoded.\n */\nexport class E_UNDECODABLE_VALUE extends BaseException {\n static status = 500\n static code = 'E_UNDECODABLE_VALUE'\n\n /**\n * Creates a new E_UNDECODABLE_VALUE exception.\n *\n * @param type - The type string that could not be decoded.\n */\n constructor(type: string) {\n const message = `Value of type ${type} cannot be decoded.`\n super(message, {\n code: E_UNDECODABLE_VALUE.code,\n status: E_UNDECODABLE_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode a value that is not a valid encoded value.\n * This indicates the input string is not in the expected encoded format.\n */\nexport class E_NOT_AN_ENCODED_VALUE extends BaseException {\n static status = 500\n static code = 'E_NOT_AN_ENCODED_VALUE'\n\n /**\n * Creates a new E_NOT_AN_ENCODED_VALUE exception.\n *\n * @param value - The string value that is not a valid encoded value.\n */\n constructor(value: string) {\n const message = `Value \"${value}\" is not a valid encoded value.`\n super(message, {\n code: E_NOT_AN_ENCODED_VALUE.code,\n status: E_NOT_AN_ENCODED_VALUE.status,\n })\n }\n}\n\n/**\n * Exception thrown when an invalid version string is encountered.\n */\nexport class E_INVALID_VERSION extends BaseException {\n static status = 500\n static code = 'E_INVALID_VERSION'\n\n /**\n * Creates a new E_INVALID_VERSION exception.\n *\n * @param version - The invalid version string.\n */\n constructor(version: string) {\n const message = `Invalid version \"${version}\"`\n super(message, {\n code: E_INVALID_VERSION.code,\n status: E_INVALID_VERSION.status,\n })\n }\n}\n\n/**\n * Exception thrown when attempting to decode data encoded with an incompatible version.\n * This typically occurs when the encoded data is from a newer version than the decoder supports.\n */\nexport class E_INCOMPATIBLE_VERSION extends BaseException {\n static status = 500\n static code = 'E_INCOMPATIBLE_VERSION'\n static help =\n 'This error indicates that the encoded value is from a version which is newer than the version of the decoder.'\n\n /**\n * Creates a new E_INCOMPATIBLE_VERSION exception.\n *\n * @param version - The incompatible version string from the encoded data.\n */\n constructor(version: string) {\n const message = `Encoded data version ${version} is not compatible with the current version ${__VERSION__}.`\n super(message, {\n code: E_INCOMPATIBLE_VERSION.code,\n status: E_INCOMPATIBLE_VERSION.status,\n })\n }\n}\n"],"names":[],"mappings":"AAWO,MAAM,sBAAsB,MAAM;AAAA;AAAA;AAAA;AAAA,EAavC;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,SAAkB,SAA6D;AACzF,UAAM,SAAS,OAAO;AAEtB,UAAM,mBAAmB,KAAK;AAE9B,SAAK,OAAO,iBAAiB;AAC7B,SAAK,UAAU,WAAW,iBAAiB,WAAW;AACtD,SAAK,SAAS,SAAS,UAAU,iBAAiB,UAAU;AAE5D,UAAM,OAAO,SAAS,QAAQ,iBAAiB;AAC/C,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,OAAO,iBAAiB;AAC9B,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,kBAAkB,MAAM,gBAAgB;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,OAAO,WAAW,IAAI;AACzB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,WAAW;AACT,QAAI,KAAK,MAAM;AACb,aAAO,GAAG,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO;AAAA,IACrD;AACA,WAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO;AAAA,EACtC;AACF;AAMO,MAAM,4BAA4B,cAAc;AAAA,EACrD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,OAAgB;AAC1B,UAAM,UAAU,iBAAiB,OAAO,KAAK,KAAK,OAAO,KAAK,CAAC;AAC/D,UAA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AAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,YAAY,SAAiB;AAC3B,UAAM,UAAU,oBAAoB,OAAO;AAC3C,UAAM,SAAS;AAAA,MACb,MAAM,kBAAkB;AAAA,MACxB,QAAQ,kBAAkB;AAAA,IAAA,CAC3B;AAAA,EACH;AACF;AAMO,MAAM,+BAA+B,cAAc;AAAA,EACxD,OAAO,SAAS;AAAA,EAChB,OAAO,OAAO;AAAA,EACd,OAAO,OACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOF,YAAY,SAAiB;AAC3B,UAAM,UAAU,wBAAwB,OAAO,+CAA+C,uBAAW;AACzG,UAAM,SAAS;AAAA,MACb,MAAM,uBAAuB;AAAA,MAC7B,QAAQ,uBAAuB;AAAA,IAAA,CAChC;AAAA,EACH;AACF;"}
package/exceptions.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const exceptions = require("./exceptions-vnhPQaJe.js");
3
+ const exceptions = require("./exceptions-BfKyCF4p.js");
4
4
  exports.E_CIRCULAR_REFERENCE = exceptions.E_CIRCULAR_REFERENCE;
5
5
  exports.E_ENCODING_FAILED = exceptions.E_ENCODING_FAILED;
6
6
  exports.E_INCOMPATIBLE_VERSION = exceptions.E_INCOMPATIBLE_VERSION;
package/exceptions.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a, b, f, e, d, c, E } from "./exceptions-P-gXm8Io.mjs";
1
+ import { a, b, f, e, d, c, E } from "./exceptions-MW3dkAUt.mjs";
2
2
  export {
3
3
  a as E_CIRCULAR_REFERENCE,
4
4
  b as E_ENCODING_FAILED,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const type_guards = require("./type_guards-BWmHnIpZ.js");
3
+ const type_guards = require("./type_guards-D1YzZ13G.js");
4
4
  class FunctionSerializer {
5
5
  #namedBindings;
6
6
  #argNames;
@@ -1,4 +1,4 @@
1
- import { i as isObject } from "./type_guards-UkDoe__i.mjs";
1
+ import { i as isObject } from "./type_guards-BAhiOypL.mjs";
2
2
  class FunctionSerializer {
3
3
  #namedBindings;
4
4
  #argNames;
package/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const type_guards = require("./type_guards-BWmHnIpZ.js");
3
+ const type_guards = require("./type_guards-D1YzZ13G.js");
4
4
  const function_serializer = require("./function_serializer.cjs");
5
- const exceptions = require("./exceptions-vnhPQaJe.js");
5
+ const exceptions = require("./exceptions-BfKyCF4p.js");
6
6
  var re = { exports: {} };
7
7
  var constants;
8
8
  var hasRequiredConstants;
@@ -2730,6 +2730,16 @@ const atou = (base64) => {
2730
2730
  }
2731
2731
  return decodeURIComponent(escape(binary));
2732
2732
  };
2733
+ const registry = /* @__PURE__ */ new Map();
2734
+ const registerClass = (ctor) => {
2735
+ if (typeof ctor.name !== "string" || ctor.name === "") {
2736
+ throw new TypeError("Cannot register an anonymous class — give it an explicit name.");
2737
+ }
2738
+ registry.set(ctor.name, ctor);
2739
+ };
2740
+ const getRegisteredClass = (name) => {
2741
+ return registry.get(name);
2742
+ };
2733
2743
  const VOID = -1;
2734
2744
  const PRIMITIVE = 0;
2735
2745
  const ARRAY = 1;
@@ -3027,9 +3037,7 @@ const toStructuredData = (value, seen = /* @__PURE__ */ new WeakSet()) => {
3027
3037
  throw new exceptions.E_CIRCULAR_REFERENCE();
3028
3038
  }
3029
3039
  seen.add(value);
3030
- const dto = value instanceof type_guards.DateTime ? value : type_guards.DateTime.fromObject(value.c, { zone: value.zone }).setLocale(
3031
- value.loc.locale
3032
- );
3040
+ const dto = value;
3033
3041
  return {
3034
3042
  _t: "luxon:DateTime",
3035
3043
  _s: toStructuredData(
@@ -3138,6 +3146,25 @@ const toStructuredData = (value, seen = /* @__PURE__ */ new WeakSet()) => {
3138
3146
  _s: utoa(JSON.stringify(value.map((item) => toStructuredData(item, seen))))
3139
3147
  };
3140
3148
  }
3149
+ case type_guards.isCustomEncodable(value): {
3150
+ if (seen.has(value)) {
3151
+ throw new exceptions.E_CIRCULAR_REFERENCE();
3152
+ }
3153
+ seen.add(value);
3154
+ const className = value.constructor.name;
3155
+ try {
3156
+ const snapshot = value[type_guards.ENCODE_METHOD]();
3157
+ return {
3158
+ _t: `custom:${className}`,
3159
+ _s: toStructuredData(snapshot, seen)
3160
+ };
3161
+ } catch (e) {
3162
+ if (e instanceof exceptions.BaseException) {
3163
+ throw e;
3164
+ }
3165
+ throw new exceptions.E_ENCODING_FAILED(value, e);
3166
+ }
3167
+ }
3141
3168
  case type_guards.isObject(value): {
3142
3169
  if (seen.has(value)) {
3143
3170
  throw new exceptions.E_CIRCULAR_REFERENCE();
@@ -3264,19 +3291,44 @@ const fromStructuredData = (data) => {
3264
3291
  throw err2;
3265
3292
  }
3266
3293
  }
3267
- default:
3294
+ default: {
3295
+ if (data._t.startsWith("custom:")) {
3296
+ const className = data._t.slice("custom:".length);
3297
+ const ctor = getRegisteredClass(className);
3298
+ if (!ctor) {
3299
+ const err2 = new exceptions.E_UNDECODABLE_VALUE(data._t);
3300
+ err2.cause = new Error(
3301
+ `No class registered for "${className}". Call registerClass(${className}) before decoding.`
3302
+ );
3303
+ throw err2;
3304
+ }
3305
+ try {
3306
+ const snapshot = fromStructuredData(data._s);
3307
+ return ctor[type_guards.DECODE_METHOD](snapshot);
3308
+ } catch (e) {
3309
+ if (e instanceof exceptions.BaseException) {
3310
+ throw e;
3311
+ }
3312
+ const err2 = new exceptions.E_UNDECODABLE_VALUE(data._t);
3313
+ if (e instanceof Error) {
3314
+ err2.cause = e;
3315
+ }
3316
+ throw err2;
3317
+ }
3318
+ }
3268
3319
  throw new exceptions.E_UNDECODABLE_VALUE(data._t);
3320
+ }
3269
3321
  }
3270
3322
  };
3271
3323
  const { parse: $parse, stringify: $stringify } = JSON;
3272
3324
  const options = { json: true, lossy: true };
3273
3325
  const parse = (str) => deserialize($parse(str));
3274
3326
  const stringify = (any) => $stringify(serialize(any, options));
3275
- const version = "0.1.0-master-9b97505f";
3327
+ const version = "0.1.0-master-492fadb0";
3276
3328
  const encode = (what) => {
3277
3329
  const structured = toStructuredData(what);
3278
3330
  const serialized = serialize(structured, { lossy: true, json: true });
3279
- const json = stringify({ version: "0.1.0-master-9b97505f", serialized });
3331
+ const json = stringify({ version: "0.1.0-master-492fadb0", serialized });
3280
3332
  return utoa(json);
3281
3333
  };
3282
3334
  const decode = (base64) => {
@@ -3287,11 +3339,11 @@ const decode = (base64) => {
3287
3339
  throw new exceptions.E_NOT_AN_ENCODED_VALUE(base64);
3288
3340
  }
3289
3341
  const { version: payloadVersion, serialized } = parsed;
3290
- if (semverExports.valid("0.1.0-master-9b97505f")) {
3342
+ if (semverExports.valid("0.1.0-master-492fadb0")) {
3291
3343
  if (!semverExports.valid(semverExports.coerce(payloadVersion))) {
3292
3344
  throw new exceptions.E_INVALID_VERSION(payloadVersion);
3293
3345
  }
3294
- if (semverExports.gt(semverExports.coerce(payloadVersion), "0.1.0-master-9b97505f")) {
3346
+ if (semverExports.gt(semverExports.coerce(payloadVersion), "0.1.0-master-492fadb0")) {
3295
3347
  throw new exceptions.E_INCOMPATIBLE_VERSION(payloadVersion);
3296
3348
  }
3297
3349
  }
@@ -3306,7 +3358,10 @@ const decode = (base64) => {
3306
3358
  throw exception;
3307
3359
  }
3308
3360
  };
3361
+ exports.DECODE_METHOD = type_guards.DECODE_METHOD;
3362
+ exports.ENCODE_METHOD = type_guards.ENCODE_METHOD;
3309
3363
  exports.decode = decode;
3310
3364
  exports.encode = encode;
3365
+ exports.registerClass = registerClass;
3311
3366
  exports.version = version;
3312
3367
  //# sourceMappingURL=index.cjs.map