@marcuspuchalla/nachos 0.1.3 → 0.1.4

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{chunk-5A5T56JB.js → chunk-5IWW5H47.js} +378 -207
  3. package/dist/chunk-5IWW5H47.js.map +1 -0
  4. package/dist/{chunk-PTWN7K3Y.cjs → chunk-RVG2BY32.cjs} +378 -207
  5. package/dist/chunk-RVG2BY32.cjs.map +1 -0
  6. package/dist/{chunk-R62CQQNI.cjs → chunk-S4RXO6IB.cjs} +195 -165
  7. package/dist/chunk-S4RXO6IB.cjs.map +1 -0
  8. package/dist/{chunk-2MTLSQ7E.js → chunk-UMAX5MX5.js} +195 -165
  9. package/dist/chunk-UMAX5MX5.js.map +1 -0
  10. package/dist/encoder/index.cjs +13 -13
  11. package/dist/encoder/index.d.cts +2 -2
  12. package/dist/encoder/index.d.ts +2 -2
  13. package/dist/encoder/index.js +1 -1
  14. package/dist/index.cjs +32 -32
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +28 -19
  17. package/dist/index.d.ts +28 -19
  18. package/dist/index.js +16 -16
  19. package/dist/index.js.map +1 -1
  20. package/dist/metafile-cjs.json +1 -1
  21. package/dist/metafile-esm.json +1 -1
  22. package/dist/parser/index.cjs +14 -14
  23. package/dist/parser/index.d.cts +3 -1
  24. package/dist/parser/index.d.ts +3 -1
  25. package/dist/parser/index.js +1 -1
  26. package/dist/{useCborSimpleEncoder-TVxzNJ_9.d.ts → useCborSimpleEncoder-BoKEmjP9.d.ts} +0 -2
  27. package/dist/{useCborSimpleEncoder-ButVU988.d.cts → useCborSimpleEncoder-C_OHxoB8.d.cts} +0 -2
  28. package/dist/{useCborTag-Cs1CZuXZ.d.cts → useCborTag-BD6Sqp7p.d.ts} +9 -4
  29. package/dist/{useCborTag-xV2Pz2VY.d.ts → useCborTag-QpZR-Er2.d.cts} +9 -4
  30. package/package.json +1 -1
  31. package/src/__tests__/public-api.test.ts +153 -0
  32. package/src/__tests__/roundtrip.test.ts +5 -6
  33. package/src/encoder/__tests__/cbor-collection-encoder.test.ts +103 -5
  34. package/src/encoder/__tests__/cbor-encoder-errors.test.ts +40 -5
  35. package/src/encoder/__tests__/cbor-simple-encoder.test.ts +126 -0
  36. package/src/encoder/composables/useCborCollectionEncoder.ts +28 -25
  37. package/src/encoder/composables/useCborEncoder.ts +21 -0
  38. package/src/encoder/composables/useCborSimpleEncoder.ts +34 -7
  39. package/src/encoder/types.ts +0 -2
  40. package/src/index.ts +29 -20
  41. package/src/parser/__tests__/buffer-native-parsing.test.ts +338 -0
  42. package/src/parser/__tests__/cbor-map-duplicate-keys.test.ts +97 -7
  43. package/src/parser/__tests__/cbor-security-dos-protection.test.ts +164 -31
  44. package/src/parser/__tests__/cbor-standard-tags.test.ts +75 -7
  45. package/src/parser/__tests__/cbor-tag-reparse-fix.test.ts +268 -0
  46. package/src/parser/composables/useCborCollection.ts +45 -42
  47. package/src/parser/composables/useCborFloat.ts +2 -1
  48. package/src/parser/composables/useCborInteger.ts +24 -10
  49. package/src/parser/composables/useCborParser.ts +387 -197
  50. package/src/parser/composables/useCborTag.ts +45 -37
  51. package/src/parser/utils.ts +11 -0
  52. package/dist/chunk-2MTLSQ7E.js.map +0 -1
  53. package/dist/chunk-5A5T56JB.js.map +0 -1
  54. package/dist/chunk-PTWN7K3Y.cjs.map +0 -1
  55. package/dist/chunk-R62CQQNI.cjs.map +0 -1
@@ -1,57 +1,57 @@
1
1
  'use strict';
2
2
 
3
- var chunkR62CQQNI_cjs = require('../chunk-R62CQQNI.cjs');
3
+ var chunkS4RXO6IB_cjs = require('../chunk-S4RXO6IB.cjs');
4
4
  require('../chunk-PD72MVTX.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "DEFAULT_ENCODE_OPTIONS", {
9
9
  enumerable: true,
10
- get: function () { return chunkR62CQQNI_cjs.DEFAULT_ENCODE_OPTIONS; }
10
+ get: function () { return chunkS4RXO6IB_cjs.DEFAULT_ENCODE_OPTIONS; }
11
11
  });
12
12
  Object.defineProperty(exports, "bytesToHex", {
13
13
  enumerable: true,
14
- get: function () { return chunkR62CQQNI_cjs.bytesToHex; }
14
+ get: function () { return chunkS4RXO6IB_cjs.bytesToHex; }
15
15
  });
16
16
  Object.defineProperty(exports, "compareBytes", {
17
17
  enumerable: true,
18
- get: function () { return chunkR62CQQNI_cjs.compareBytes; }
18
+ get: function () { return chunkS4RXO6IB_cjs.compareBytes; }
19
19
  });
20
20
  Object.defineProperty(exports, "concatenateUint8Arrays", {
21
21
  enumerable: true,
22
- get: function () { return chunkR62CQQNI_cjs.concatenateUint8Arrays; }
22
+ get: function () { return chunkS4RXO6IB_cjs.concatenateUint8Arrays; }
23
23
  });
24
24
  Object.defineProperty(exports, "useCborCollectionEncoder", {
25
25
  enumerable: true,
26
- get: function () { return chunkR62CQQNI_cjs.useCborCollectionEncoder; }
26
+ get: function () { return chunkS4RXO6IB_cjs.useCborCollectionEncoder; }
27
27
  });
28
28
  Object.defineProperty(exports, "useCborEncoder", {
29
29
  enumerable: true,
30
- get: function () { return chunkR62CQQNI_cjs.useCborEncoder; }
30
+ get: function () { return chunkS4RXO6IB_cjs.useCborEncoder; }
31
31
  });
32
32
  Object.defineProperty(exports, "useCborIntegerEncoder", {
33
33
  enumerable: true,
34
- get: function () { return chunkR62CQQNI_cjs.useCborIntegerEncoder; }
34
+ get: function () { return chunkS4RXO6IB_cjs.useCborIntegerEncoder; }
35
35
  });
36
36
  Object.defineProperty(exports, "useCborSimpleEncoder", {
37
37
  enumerable: true,
38
- get: function () { return chunkR62CQQNI_cjs.useCborSimpleEncoder; }
38
+ get: function () { return chunkS4RXO6IB_cjs.useCborSimpleEncoder; }
39
39
  });
40
40
  Object.defineProperty(exports, "useCborStringEncoder", {
41
41
  enumerable: true,
42
- get: function () { return chunkR62CQQNI_cjs.useCborStringEncoder; }
42
+ get: function () { return chunkS4RXO6IB_cjs.useCborStringEncoder; }
43
43
  });
44
44
  Object.defineProperty(exports, "useCborTagEncoder", {
45
45
  enumerable: true,
46
- get: function () { return chunkR62CQQNI_cjs.useCborTagEncoder; }
46
+ get: function () { return chunkS4RXO6IB_cjs.useCborTagEncoder; }
47
47
  });
48
48
  Object.defineProperty(exports, "writeBigUint", {
49
49
  enumerable: true,
50
- get: function () { return chunkR62CQQNI_cjs.writeBigUint; }
50
+ get: function () { return chunkS4RXO6IB_cjs.writeBigUint; }
51
51
  });
52
52
  Object.defineProperty(exports, "writeUint", {
53
53
  enumerable: true,
54
- get: function () { return chunkR62CQQNI_cjs.writeUint; }
54
+ get: function () { return chunkS4RXO6IB_cjs.writeUint; }
55
55
  });
56
56
  //# sourceMappingURL=index.cjs.map
57
57
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { E as EncodableValue, b as EncodeResult, T as TaggedValue } from '../useCborSimpleEncoder-ButVU988.cjs';
2
- export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, a as EncodeOptions, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from '../useCborSimpleEncoder-ButVU988.cjs';
1
+ import { E as EncodableValue, b as EncodeResult, T as TaggedValue } from '../useCborSimpleEncoder-C_OHxoB8.cjs';
2
+ export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, a as EncodeOptions, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from '../useCborSimpleEncoder-C_OHxoB8.cjs';
3
3
  import '../types-DvNlfbKB.cjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { E as EncodableValue, b as EncodeResult, T as TaggedValue } from '../useCborSimpleEncoder-TVxzNJ_9.js';
2
- export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, a as EncodeOptions, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from '../useCborSimpleEncoder-TVxzNJ_9.js';
1
+ import { E as EncodableValue, b as EncodeResult, T as TaggedValue } from '../useCborSimpleEncoder-BoKEmjP9.js';
2
+ export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, a as EncodeOptions, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from '../useCborSimpleEncoder-BoKEmjP9.js';
3
3
  import '../types-DvNlfbKB.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- export { DEFAULT_ENCODE_OPTIONS, bytesToHex, compareBytes, concatenateUint8Arrays, useCborCollectionEncoder, useCborEncoder, useCborIntegerEncoder, useCborSimpleEncoder, useCborStringEncoder, useCborTagEncoder, writeBigUint, writeUint } from '../chunk-2MTLSQ7E.js';
1
+ export { DEFAULT_ENCODE_OPTIONS, bytesToHex, compareBytes, concatenateUint8Arrays, useCborCollectionEncoder, useCborEncoder, useCborIntegerEncoder, useCborSimpleEncoder, useCborStringEncoder, useCborTagEncoder, writeBigUint, writeUint } from '../chunk-UMAX5MX5.js';
2
2
  import '../chunk-ZDZ2B5PE.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkPTWN7K3Y_cjs = require('./chunk-PTWN7K3Y.cjs');
4
- var chunkR62CQQNI_cjs = require('./chunk-R62CQQNI.cjs');
3
+ var chunkRVG2BY32_cjs = require('./chunk-RVG2BY32.cjs');
4
+ var chunkS4RXO6IB_cjs = require('./chunk-S4RXO6IB.cjs');
5
5
  var chunkPD72MVTX_cjs = require('./chunk-PD72MVTX.cjs');
6
6
 
7
7
  // src/parser/composables/useCborDiagnostic.ts
@@ -411,28 +411,28 @@ var PathBuilder = {
411
411
  };
412
412
 
413
413
  // src/index.ts
414
- function decode(hexString, options) {
415
- const { parse } = chunkPTWN7K3Y_cjs.useCborParser();
416
- return parse(hexString, options);
414
+ function decode(input, options) {
415
+ const { parse } = chunkRVG2BY32_cjs.useCborParser();
416
+ return parse(input, options);
417
417
  }
418
- function decodeWithSourceMap(hexString, options) {
419
- const { parseWithSourceMap } = chunkPTWN7K3Y_cjs.useCborParser();
420
- return parseWithSourceMap(hexString, options);
418
+ function decodeWithSourceMap(input, options) {
419
+ const { parseWithSourceMap } = chunkRVG2BY32_cjs.useCborParser();
420
+ return parseWithSourceMap(input, options);
421
421
  }
422
422
  function encode(value, options) {
423
- const { encode: encodeValue } = chunkR62CQQNI_cjs.useCborEncoder(options);
423
+ const { encode: encodeValue } = chunkS4RXO6IB_cjs.useCborEncoder(options);
424
424
  return encodeValue(value);
425
425
  }
426
426
  function encodeToHex(value, options) {
427
- const { encodeToHex: encodeValueToHex } = chunkR62CQQNI_cjs.useCborEncoder(options);
427
+ const { encodeToHex: encodeValueToHex } = chunkS4RXO6IB_cjs.useCborEncoder(options);
428
428
  return encodeValueToHex(value);
429
429
  }
430
430
  function encodeToBytes(value, options) {
431
- const { encodeToBytes: encodeValueToBytes } = chunkR62CQQNI_cjs.useCborEncoder(options);
431
+ const { encodeToBytes: encodeValueToBytes } = chunkS4RXO6IB_cjs.useCborEncoder(options);
432
432
  return encodeValueToBytes(value);
433
433
  }
434
434
  function encodeSequence(values, options) {
435
- const { encodeSequence: encodeSeq } = chunkR62CQQNI_cjs.useCborEncoder(options);
435
+ const { encodeSequence: encodeSeq } = chunkS4RXO6IB_cjs.useCborEncoder(options);
436
436
  return encodeSeq(values);
437
437
  }
438
438
  var CborDecoder = class {
@@ -445,22 +445,22 @@ var CborDecoder = class {
445
445
  this.options = options || {};
446
446
  }
447
447
  /**
448
- * Decode CBOR hex string
448
+ * Decode CBOR data
449
449
  *
450
- * @param hexString - CBOR data as hex string
450
+ * @param input - CBOR data as hex string or Uint8Array
451
451
  * @returns Decoded value and byte count
452
452
  */
453
- decode(hexString) {
454
- return decode(hexString, this.options);
453
+ decode(input) {
454
+ return decode(input, this.options);
455
455
  }
456
456
  /**
457
- * Decode CBOR hex string with source map
457
+ * Decode CBOR data with source map
458
458
  *
459
- * @param hexString - CBOR data as hex string
459
+ * @param input - CBOR data as hex string or Uint8Array
460
460
  * @returns Decoded value, byte count, and source map
461
461
  */
462
- decodeWithSourceMap(hexString) {
463
- return decodeWithSourceMap(hexString, this.options);
462
+ decodeWithSourceMap(input) {
463
+ return decodeWithSourceMap(input, this.options);
464
464
  }
465
465
  };
466
466
  var CborEncoder = class {
@@ -520,51 +520,51 @@ function decodeToDiagnostic(hexString, options) {
520
520
 
521
521
  Object.defineProperty(exports, "useCborCollection", {
522
522
  enumerable: true,
523
- get: function () { return chunkPTWN7K3Y_cjs.useCborCollection; }
523
+ get: function () { return chunkRVG2BY32_cjs.useCborCollection; }
524
524
  });
525
525
  Object.defineProperty(exports, "useCborFloat", {
526
526
  enumerable: true,
527
- get: function () { return chunkPTWN7K3Y_cjs.useCborFloat; }
527
+ get: function () { return chunkRVG2BY32_cjs.useCborFloat; }
528
528
  });
529
529
  Object.defineProperty(exports, "useCborInteger", {
530
530
  enumerable: true,
531
- get: function () { return chunkPTWN7K3Y_cjs.useCborInteger; }
531
+ get: function () { return chunkRVG2BY32_cjs.useCborInteger; }
532
532
  });
533
533
  Object.defineProperty(exports, "useCborParser", {
534
534
  enumerable: true,
535
- get: function () { return chunkPTWN7K3Y_cjs.useCborParser; }
535
+ get: function () { return chunkRVG2BY32_cjs.useCborParser; }
536
536
  });
537
537
  Object.defineProperty(exports, "useCborString", {
538
538
  enumerable: true,
539
- get: function () { return chunkPTWN7K3Y_cjs.useCborString; }
539
+ get: function () { return chunkRVG2BY32_cjs.useCborString; }
540
540
  });
541
541
  Object.defineProperty(exports, "useCborTag", {
542
542
  enumerable: true,
543
- get: function () { return chunkPTWN7K3Y_cjs.useCborTag; }
543
+ get: function () { return chunkRVG2BY32_cjs.useCborTag; }
544
544
  });
545
545
  Object.defineProperty(exports, "DEFAULT_ENCODE_OPTIONS", {
546
546
  enumerable: true,
547
- get: function () { return chunkR62CQQNI_cjs.DEFAULT_ENCODE_OPTIONS; }
547
+ get: function () { return chunkS4RXO6IB_cjs.DEFAULT_ENCODE_OPTIONS; }
548
548
  });
549
549
  Object.defineProperty(exports, "useCborCollectionEncoder", {
550
550
  enumerable: true,
551
- get: function () { return chunkR62CQQNI_cjs.useCborCollectionEncoder; }
551
+ get: function () { return chunkS4RXO6IB_cjs.useCborCollectionEncoder; }
552
552
  });
553
553
  Object.defineProperty(exports, "useCborEncoder", {
554
554
  enumerable: true,
555
- get: function () { return chunkR62CQQNI_cjs.useCborEncoder; }
555
+ get: function () { return chunkS4RXO6IB_cjs.useCborEncoder; }
556
556
  });
557
557
  Object.defineProperty(exports, "useCborIntegerEncoder", {
558
558
  enumerable: true,
559
- get: function () { return chunkR62CQQNI_cjs.useCborIntegerEncoder; }
559
+ get: function () { return chunkS4RXO6IB_cjs.useCborIntegerEncoder; }
560
560
  });
561
561
  Object.defineProperty(exports, "useCborSimpleEncoder", {
562
562
  enumerable: true,
563
- get: function () { return chunkR62CQQNI_cjs.useCborSimpleEncoder; }
563
+ get: function () { return chunkS4RXO6IB_cjs.useCborSimpleEncoder; }
564
564
  });
565
565
  Object.defineProperty(exports, "useCborStringEncoder", {
566
566
  enumerable: true,
567
- get: function () { return chunkR62CQQNI_cjs.useCborStringEncoder; }
567
+ get: function () { return chunkS4RXO6IB_cjs.useCborStringEncoder; }
568
568
  });
569
569
  Object.defineProperty(exports, "CborAdditionalInfo", {
570
570
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parser/composables/useCborDiagnostic.ts","../src/parser/utils/pathBuilder.ts","../src/index.ts"],"names":["toDiagnostic","useCborParser","useCborEncoder"],"mappings":";;;;;;;AA4CA,SAAS,cAAc,KAAA,EAAsC;AAC3D,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KA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,GAAI,iBAAA,EAAkB;AACpD,EAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC/B;AAkBO,SAAS,kBAAA,CAAmB,WAAmB,OAAA,EAAqC;AACzF,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,MAAA,CAAO,SAAS,CAAA;AAClC,EAAA,OAAO,YAAA,CAAa,OAAO,OAAO,CAAA;AACpC","file":"index.cjs","sourcesContent":["/**\n * useCborDiagnostic - RFC 8949 Appendix B Diagnostic Notation\n *\n * Converts CBOR values to human-readable diagnostic notation as defined\n * in RFC 8949 (Concise Binary Object Representation).\n *\n * @example\n * ```typescript\n * const { toDiagnostic } = useCborDiagnostic()\n *\n * toDiagnostic(100) // \"100\"\n * toDiagnostic(new Uint8Array([1,2])) // \"h'0102'\"\n * toDiagnostic([1, 2, 3]) // \"[1, 2, 3]\"\n * toDiagnostic({a: 1}) // '{\"a\": 1}'\n * ```\n */\n\n/**\n * Options for diagnostic notation output\n */\nexport interface DiagnosticOptions {\n /** Pretty print with indentation (default: false) */\n pretty?: boolean\n /** Indentation string for pretty printing (default: ' ') */\n indent?: string\n /** Maximum depth for nested structures (default: 100) */\n maxDepth?: number\n /** Mark as indefinite-length (default: false) */\n indefinite?: boolean\n /** Show byte offsets as comments (default: false) */\n showOffsets?: boolean\n}\n\n/**\n * Tagged value interface (CBOR Major Type 6)\n */\ninterface TaggedValue {\n tag: number\n value: unknown\n}\n\n/**\n * Check if value is a tagged value\n */\nfunction isTaggedValue(value: unknown): value is TaggedValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tag' in value &&\n 'value' in value &&\n typeof (value as TaggedValue).tag === 'number'\n )\n}\n\n/**\n * Check if value is a plain object (not array, not special type)\n */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Uint8Array) &&\n !(value instanceof Map) &&\n !(value instanceof Set) &&\n !isTaggedValue(value) &&\n value.constructor === Object\n )\n}\n\n/**\n * Escape string for diagnostic notation (JSON-style escaping)\n */\nfunction escapeString(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t')\n .replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, (char) => {\n const code = char.charCodeAt(0)\n return `\\\\u${code.toString(16).padStart(4, '0')}`\n })\n}\n\n/**\n * Convert Uint8Array to hex string\n */\nfunction bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/**\n * Composable for CBOR diagnostic notation\n */\nexport function useCborDiagnostic() {\n /**\n * Convert a CBOR value to RFC 8949 diagnostic notation\n *\n * @param value - The CBOR value to convert\n * @param options - Formatting options\n * @returns Diagnostic notation string\n */\n const toDiagnostic = (\n value: unknown,\n options: DiagnosticOptions = {}\n ): string => {\n const {\n pretty = false,\n indent = ' ',\n maxDepth = 100,\n indefinite = false\n } = options\n\n return formatValue(value, 0, pretty, indent, maxDepth, indefinite)\n }\n\n /**\n * Internal recursive formatter\n */\n const formatValue = (\n value: unknown,\n depth: number,\n pretty: boolean,\n indent: string,\n maxDepth: number,\n indefinite: boolean\n ): string => {\n // Check depth limit\n if (depth > maxDepth) {\n return '...'\n }\n\n // Handle null/undefined\n if (value === null) {\n return 'null'\n }\n if (value === undefined) {\n return 'undefined'\n }\n\n // Handle booleans\n if (typeof value === 'boolean') {\n return value ? 'true' : 'false'\n }\n\n // Handle numbers\n if (typeof value === 'number') {\n // Special float values\n if (Number.isNaN(value)) {\n return 'NaN'\n }\n if (value === Infinity) {\n return 'Infinity'\n }\n if (value === -Infinity) {\n return '-Infinity'\n }\n // Negative zero\n if (Object.is(value, -0)) {\n return '-0.0'\n }\n // Regular numbers\n if (Number.isInteger(value)) {\n return value.toString()\n }\n // Floats - preserve precision\n return value.toString()\n }\n\n // Handle BigInt\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n // Handle strings\n if (typeof value === 'string') {\n return `\"${escapeString(value)}\"`\n }\n\n // Handle byte strings (Uint8Array)\n if (value instanceof Uint8Array) {\n return `h'${bytesToHex(value)}'`\n }\n\n // Handle tagged values\n if (isTaggedValue(value)) {\n const taggedContent = formatValue(\n value.value,\n depth + 1,\n pretty,\n indent,\n maxDepth,\n false\n )\n return `${value.tag}(${taggedContent})`\n }\n\n // Handle arrays\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return indefinite ? '[_ ]' : '[]'\n }\n\n const items = value.map(item =>\n formatValue(item, depth + 1, pretty, indent, maxDepth, false)\n )\n\n if (pretty) {\n const prefix = indefinite ? '[_ ' : '['\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${items.join(`,\\n${lineIndent}`)}\\n${closeIndent}]`\n } else {\n const prefix = indefinite ? '[_ ' : '['\n return `${prefix}${items.join(', ')}]`\n }\n }\n\n // Handle Maps\n if (value instanceof Map) {\n if (value.size === 0) {\n return indefinite ? '{_ }' : '{}'\n }\n\n const entries: string[] = []\n for (const [k, v] of value) {\n const keyStr = formatValue(k, depth + 1, pretty, indent, maxDepth, false)\n const valueStr = formatValue(v, depth + 1, pretty, indent, maxDepth, false)\n entries.push(`${keyStr}: ${valueStr}`)\n }\n\n if (pretty) {\n const prefix = indefinite ? '{_ ' : '{'\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${entries.join(`,\\n${lineIndent}`)}\\n${closeIndent}}`\n } else {\n const prefix = indefinite ? '{_ ' : '{'\n return `${prefix}${entries.join(', ')}}`\n }\n }\n\n // Handle Sets (convert to array)\n if (value instanceof Set) {\n const items = Array.from(value).map(item =>\n formatValue(item, depth + 1, pretty, indent, maxDepth, false)\n )\n\n if (pretty) {\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `[\\n${lineIndent}${items.join(`,\\n${lineIndent}`)}\\n${closeIndent}]`\n } else {\n return `[${items.join(', ')}]`\n }\n }\n\n // Handle plain objects (as CBOR maps with string keys)\n if (isPlainObject(value)) {\n const keys = Object.keys(value)\n if (keys.length === 0) {\n return indefinite ? '{_ }' : '{}'\n }\n\n const entries = keys.map(key => {\n const keyStr = `\"${escapeString(key)}\"`\n const valueStr = formatValue(\n value[key],\n depth + 1,\n pretty,\n indent,\n maxDepth,\n false\n )\n return `${keyStr}: ${valueStr}`\n })\n\n if (pretty) {\n const prefix = indefinite ? '{_ ' : '{'\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${entries.join(`,\\n${lineIndent}`)}\\n${closeIndent}}`\n } else {\n const prefix = indefinite ? '{_ ' : '{'\n return `${prefix}${entries.join(', ')}}`\n }\n }\n\n // Fallback for unknown types\n return String(value)\n }\n\n /**\n * Parse diagnostic notation back to CBOR value\n * (Not fully implemented - for future use)\n */\n const fromDiagnostic = (diag: string): unknown => {\n // Basic parsing for common cases\n const trimmed = diag.trim()\n\n // Null/undefined\n if (trimmed === 'null') return null\n if (trimmed === 'undefined') return undefined\n\n // Booleans\n if (trimmed === 'true') return true\n if (trimmed === 'false') return false\n\n // Special floats\n if (trimmed === 'NaN') return NaN\n if (trimmed === 'Infinity') return Infinity\n if (trimmed === '-Infinity') return -Infinity\n\n // Numbers (including negative zero)\n if (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n const num = Number(trimmed)\n if (trimmed === '-0.0' || trimmed === '-0') {\n return -0\n }\n return num\n }\n\n // Byte strings h'...'\n const hexMatch = trimmed.match(/^h'([0-9a-fA-F]*)'$/)\n if (hexMatch && hexMatch[1] !== undefined) {\n const hex = hexMatch[1]\n const bytes = new Uint8Array(hex.length / 2)\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16)\n }\n return bytes\n }\n\n // Strings \"...\"\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n // Basic unescape - full implementation would handle all escapes\n return trimmed.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, '\\\\')\n }\n\n // For arrays, maps, tags - would need full parser\n // Return as string for now\n return trimmed\n }\n\n /**\n * Format value with type annotation (extended notation)\n */\n const toDiagnosticWithType = (\n value: unknown,\n majorType: number,\n options: DiagnosticOptions = {}\n ): string => {\n const typeNames: Record<number, string> = {\n 0: 'uint',\n 1: 'nint',\n 2: 'bstr',\n 3: 'tstr',\n 4: 'array',\n 5: 'map',\n 6: 'tag',\n 7: 'simple'\n }\n\n const typeName = typeNames[majorType] || 'unknown'\n const diag = toDiagnostic(value, options)\n\n return `${typeName}(${diag})`\n }\n\n return {\n toDiagnostic,\n fromDiagnostic,\n toDiagnosticWithType\n }\n}\n\nexport default useCborDiagnostic\n","/**\n * PathBuilder - Utilities for creating and manipulating source map paths\n *\n * Path format follows JSON Pointer (RFC 6901) with CBOR-specific extensions:\n * - Array indices: [0], [1], [2]\n * - Object/Map keys: .key, .nested.key\n * - Special markers: [#header], [#content], [#value]\n *\n * @example\n * ```typescript\n * import { PathBuilder } from './pathBuilder'\n *\n * const path = PathBuilder.arrayIndex('', 0) // \"[0]\"\n * const nested = PathBuilder.arrayIndex(path, 1) // \"[0][1]\"\n * const key = PathBuilder.mapKey(nested, 'amount') // \"[0][1].amount\"\n * const header = PathBuilder.header(key) // \"[0][1].amount[#header]\"\n * ```\n */\n\n/**\n * PathBuilder utility object with methods for creating and manipulating paths\n */\nexport const PathBuilder = {\n /**\n * Create root path (empty string)\n */\n root: (): string => '',\n\n /**\n * Create path for array index\n * @param parent - Parent path\n * @param index - Array index (0-based)\n * @returns Path string like \"[0]\" or \"[0][1]\"\n */\n arrayIndex: (parent: string, index: number): string => `${parent}[${index}]`,\n\n /**\n * Create path for map/object key\n * @param parent - Parent path\n * @param key - Key name (string or number)\n * @returns Path string like \".key\" or \"[0].key\"\n */\n mapKey: (parent: string, key: string | number): string => {\n const keyStr = String(key)\n // Escape special characters in key names\n const escapedKey = keyStr.replace(/[.\\[\\]\\\\]/g, '\\\\$&')\n return parent ? `${parent}.${escapedKey}` : `.${escapedKey}`\n },\n\n /**\n * Create path for map key by index (for non-string keys)\n * @param parent - Parent path\n * @param index - Key index in map\n * @returns Path string like \"[#key:0]\"\n */\n mapKeyIndex: (parent: string, index: number): string =>\n `${parent}[#key:${index}]`,\n\n /**\n * Create path for header portion of a value\n * Used for byte strings, text strings, arrays, maps, tags\n * @param parent - Parent path\n * @returns Path string like \"[0][#header]\"\n */\n header: (parent: string): string => `${parent}[#header]`,\n\n /**\n * Create path for content portion of a value\n * Used for byte strings and text strings\n * @param parent - Parent path\n * @returns Path string like \"[0][#content]\"\n */\n content: (parent: string): string => `${parent}[#content]`,\n\n /**\n * Create path for tagged value\n * @param parent - Parent path\n * @returns Path string like \"[0][#value]\"\n */\n tagValue: (parent: string): string => `${parent}[#value]`,\n\n /**\n * Normalize a path by removing special markers (#header, #content, #value)\n * Used for matching paths across different representations\n * @param path - Path to normalize\n * @returns Normalized path without special markers\n */\n normalize: (path: string): string => {\n return path.replace(/\\[#(header|content|value)\\]$/, '')\n },\n\n /**\n * Check if path is a header path\n * @param path - Path to check\n * @returns True if path ends with [#header]\n */\n isHeader: (path: string): boolean => path.endsWith('[#header]'),\n\n /**\n * Check if path is a content path\n * @param path - Path to check\n * @returns True if path ends with [#content]\n */\n isContent: (path: string): boolean => path.endsWith('[#content]'),\n\n /**\n * Check if path is a tag value path\n * @param path - Path to check\n * @returns True if path ends with [#value]\n */\n isTagValue: (path: string): boolean => path.endsWith('[#value]'),\n\n /**\n * Check if path has any special marker\n * @param path - Path to check\n * @returns True if path ends with any special marker\n */\n hasMarker: (path: string): boolean =>\n /\\[#(header|content|value)\\]$/.test(path),\n\n /**\n * Get parent path (one level up)\n * @param path - Path to get parent of\n * @returns Parent path or null if already at root\n */\n getParent: (path: string): string | null => {\n // First normalize to remove markers\n const normalized = PathBuilder.normalize(path)\n if (normalized === '') return null\n\n // Match array index or object key at end\n const arrayMatch = normalized.match(/^(.+)\\[\\d+\\]$/)\n if (arrayMatch && arrayMatch[1] !== undefined) return arrayMatch[1]\n\n const keyMatch = normalized.match(/^(.+)\\.[^.]+$/)\n if (keyMatch && keyMatch[1] !== undefined) return keyMatch[1]\n\n // Root level item\n if (normalized.startsWith('[') || normalized.startsWith('.')) {\n return ''\n }\n\n return null\n },\n\n /**\n * Get the depth (nesting level) of a path\n * @param path - Path to measure\n * @returns Number indicating nesting depth (0 for root)\n */\n getDepth: (path: string): number => {\n const normalized = PathBuilder.normalize(path)\n if (normalized === '') return 0\n\n // Count array indices and object keys\n const arrayDepth = (normalized.match(/\\[\\d+\\]/g) || []).length\n const keyDepth = (normalized.match(/\\./g) || []).length\n\n return arrayDepth + keyDepth\n },\n\n /**\n * Parse a path into its components\n * @param path - Path to parse\n * @returns Array of path segments\n */\n parse: (path: string): Array<{ type: 'index' | 'key' | 'marker'; value: string | number }> => {\n const normalized = PathBuilder.normalize(path)\n const segments: Array<{ type: 'index' | 'key' | 'marker'; value: string | number }> = []\n\n // Check for marker\n const markerMatch = path.match(/\\[#(header|content|value)\\]$/)\n\n // Parse the normalized path\n let remaining = normalized\n while (remaining) {\n // Array index\n const indexMatch = remaining.match(/^\\[(\\d+)\\]/)\n if (indexMatch && indexMatch[1] !== undefined) {\n segments.push({ type: 'index', value: parseInt(indexMatch[1], 10) })\n remaining = remaining.slice(indexMatch[0].length)\n continue\n }\n\n // Object key\n const keyMatch = remaining.match(/^\\.([^.\\[\\]]+)/)\n if (keyMatch && keyMatch[1] !== undefined) {\n // Unescape special characters\n const key = keyMatch[1].replace(/\\\\(.)/g, '$1')\n segments.push({ type: 'key', value: key })\n remaining = remaining.slice(keyMatch[0].length)\n continue\n }\n\n // Unknown format, break to avoid infinite loop\n break\n }\n\n // Add marker if present\n if (markerMatch && markerMatch[1] !== undefined) {\n segments.push({ type: 'marker', value: markerMatch[1] })\n }\n\n return segments\n },\n\n /**\n * Build a path from segments\n * @param segments - Array of path segments\n * @returns Path string\n */\n build: (segments: Array<{ type: 'index' | 'key' | 'marker'; value: string | number }>): string => {\n let path = ''\n\n for (const segment of segments) {\n if (segment.type === 'index') {\n path += `[${segment.value}]`\n } else if (segment.type === 'key') {\n const escapedKey = String(segment.value).replace(/[.\\[\\]\\\\]/g, '\\\\$&')\n path += `.${escapedKey}`\n } else if (segment.type === 'marker') {\n path += `[#${segment.value}]`\n }\n }\n\n return path\n },\n\n /**\n * Join multiple path segments\n * @param paths - Path segments to join\n * @returns Combined path\n */\n join: (...paths: string[]): string => {\n return paths.filter(p => p !== '').join('')\n },\n\n /**\n * Check if a path is a descendant of another path\n * @param path - Path to check\n * @param ancestor - Potential ancestor path\n * @returns True if path is a descendant of ancestor\n */\n isDescendantOf: (path: string, ancestor: string): boolean => {\n const normalizedPath = PathBuilder.normalize(path)\n const normalizedAncestor = PathBuilder.normalize(ancestor)\n\n if (normalizedAncestor === '') {\n return normalizedPath !== ''\n }\n\n return normalizedPath.startsWith(normalizedAncestor) &&\n normalizedPath.length > normalizedAncestor.length &&\n (normalizedPath[normalizedAncestor.length] === '[' ||\n normalizedPath[normalizedAncestor.length] === '.')\n }\n}\n\nexport default PathBuilder\n","/**\n * NACHOS - Not Another CBOR Handling Object System\n *\n * RFC 8949 CBOR (Concise Binary Object Representation) encoder and decoder\n * with full source map support for interactive debugging.\n *\n * @module @marcuspuchalla/nachos\n * @see https://datatracker.ietf.org/doc/html/rfc8949\n *\n * @example\n * ```typescript\n * // Simple decoding\n * import { decode } from '@marcuspuchalla/nachos'\n * const result = decode('1864') // { value: 100, bytesRead: 2 }\n *\n * // Simple encoding\n * import { encode } from '@marcuspuchalla/nachos'\n * const { hex, bytes } = encode(100) // hex: \"1864\"\n *\n * // With source maps for debugging\n * import { decodeWithSourceMap } from '@marcuspuchalla/nachos'\n * const { value, sourceMap } = decodeWithSourceMap('d87980')\n * // sourceMap links hex bytes to decoded values\n * ```\n */\n\n// Re-export from parser (decoder)\nexport { useCborParser } from './parser/composables/useCborParser'\nexport { useCborInteger } from './parser/composables/useCborInteger'\nexport { useCborString } from './parser/composables/useCborString'\nexport { useCborCollection } from './parser/composables/useCborCollection'\nexport { useCborFloat } from './parser/composables/useCborFloat'\nexport { useCborTag } from './parser/composables/useCborTag'\nexport { useCborDiagnostic } from './parser/composables/useCborDiagnostic'\nexport type { DiagnosticOptions } from './parser/composables/useCborDiagnostic'\n\n// Re-export utilities\nexport { PathBuilder } from './parser/utils/pathBuilder'\n\n// Re-export from encoder\nexport { useCborEncoder } from './encoder/composables/useCborEncoder'\nexport { useCborIntegerEncoder } from './encoder/composables/useCborIntegerEncoder'\nexport { useCborStringEncoder } from './encoder/composables/useCborStringEncoder'\nexport { useCborCollectionEncoder } from './encoder/composables/useCborCollectionEncoder'\nexport { useCborSimpleEncoder } from './encoder/composables/useCborSimpleEncoder'\n\n// Re-export types\nexport type {\n // Parser types\n ParseResult,\n ParseResultWithMap,\n ParseOptions,\n ParseError,\n ParserLimits,\n CborContext,\n CborValue,\n CborMap,\n TaggedValue,\n PlutusData,\n PlutusConstr,\n PlutusMap,\n PlutusList,\n PlutusInt,\n PlutusBytes,\n SourceMapEntry,\n Result\n} from './parser/types'\n\nexport {\n // Default options\n DEFAULT_OPTIONS,\n DEFAULT_LIMITS,\n // Enums\n CborMajorType,\n CborAdditionalInfo,\n CborSimpleValue,\n CborTag\n} from './parser/types'\n\nexport type {\n // Encoder types\n EncodeResult,\n EncodeOptions,\n EncodableValue,\n EncodeContext\n} from './encoder/types'\n\nexport {\n DEFAULT_ENCODE_OPTIONS\n} from './encoder/types'\n\n// Convenience exports with cleaner names for library users\nimport { useCborParser } from './parser/composables/useCborParser'\nimport { useCborEncoder } from './encoder/composables/useCborEncoder'\nimport type { ParseResult, ParseResultWithMap, ParseOptions } from './parser/types'\nimport type { EncodeResult, EncodeOptions, EncodableValue } from './encoder/types'\n\n/**\n * Decode CBOR hex string to JavaScript value\n *\n * @param hexString - CBOR data as hex string (e.g., \"1864\" for integer 100)\n * @param options - Optional parser configuration\n * @returns Decoded value and number of bytes consumed\n *\n * @throws {Error} If input is invalid or malformed CBOR\n *\n * @example\n * ```typescript\n * // Decode integer\n * decode('1864') // { value: 100, bytesRead: 2 }\n *\n * // Decode string\n * decode('6449455446') // { value: \"IETF\", bytesRead: 5 }\n *\n * // Decode array\n * decode('83010203') // { value: [1, 2, 3], bytesRead: 4 }\n *\n * // With strict validation\n * decode('1864', { strict: true })\n *\n * // With canonical validation\n * decode('a16161 01', { validateCanonical: true })\n * ```\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8949 | RFC 8949}\n */\nexport function decode(hexString: string, options?: ParseOptions): ParseResult {\n const { parse } = useCborParser()\n return parse(hexString, options)\n}\n\n/**\n * Decode CBOR hex string with source map generation\n *\n * Source maps provide bidirectional linking between hex bytes and decoded values,\n * enabling interactive debugging visualizations.\n *\n * @param hexString - CBOR data as hex string\n * @param options - Optional parser configuration\n * @returns Decoded value, byte count, and source map\n *\n * @example\n * ```typescript\n * const { value, sourceMap } = decodeWithSourceMap('d87980')\n * // value: { tag: 121, value: [] }\n * // sourceMap: [\n * // { path: '', start: 0, end: 3, majorType: 6, type: 'Tag 121', children: ['.value'] },\n * // { path: '.value', start: 2, end: 3, majorType: 4, type: 'Array', parent: '' }\n * // ]\n *\n * // Use source map for hex-to-JSON linking\n * const entry = sourceMap.find(e => e.path === '.value')\n * console.log(`Value is at bytes ${entry.start}-${entry.end}`)\n * ```\n */\nexport function decodeWithSourceMap(hexString: string, options?: ParseOptions): ParseResultWithMap {\n const { parseWithSourceMap } = useCborParser()\n return parseWithSourceMap(hexString, options)\n}\n\n/**\n * Encode JavaScript value to CBOR\n *\n * Automatically detects value type and uses appropriate CBOR encoding.\n * Supports: numbers, bigints, strings, booleans, null, undefined, Uint8Arrays, arrays, objects, and tagged values.\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR bytes and hex string\n *\n * @throws {Error} If value type is unsupported or encoding fails\n *\n * @example\n * ```typescript\n * // Encode number\n * encode(100) // { hex: \"1864\", bytes: Uint8Array[0x18, 0x64] }\n *\n * // Encode string\n * encode(\"IETF\") // { hex: \"6449455446\", bytes: ... }\n *\n * // Encode array\n * encode([1, 2, 3]) // { hex: \"83010203\", bytes: ... }\n *\n * // Encode map (canonical - sorted keys)\n * encode({ z: 1, a: 2 }, { canonical: true })\n * // Keys will be sorted: { a: 2, z: 1 }\n *\n * // Encode tagged value\n * encode({ tag: 121, value: [] }) // { hex: \"d87980\", bytes: ... }\n * ```\n */\nexport function encode(value: EncodableValue, options?: Partial<EncodeOptions>): EncodeResult {\n const { encode: encodeValue } = useCborEncoder(options)\n return encodeValue(value)\n}\n\n/**\n * Encode JavaScript value to CBOR hex string\n *\n * Convenience function that returns only the hex string (not the bytes).\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR hex string\n *\n * @example\n * ```typescript\n * encodeToHex(100) // \"1864\"\n * encodeToHex([1, 2, 3]) // \"83010203\"\n * encodeToHex({ a: 1 }, { canonical: true }) // \"a16161 01\"\n * ```\n */\nexport function encodeToHex(value: EncodableValue, options?: Partial<EncodeOptions>): string {\n const { encodeToHex: encodeValueToHex } = useCborEncoder(options)\n return encodeValueToHex(value)\n}\n\n/**\n * Encode JavaScript value to CBOR bytes\n *\n * Convenience function that returns only the bytes (not the hex string).\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR bytes as Uint8Array\n *\n * @example\n * ```typescript\n * const bytes = encodeToBytes(100) // Uint8Array[0x18, 0x64]\n * const bytes = encodeToBytes([1, 2, 3]) // Uint8Array[0x83, 0x01, 0x02, 0x03]\n * ```\n */\nexport function encodeToBytes(value: EncodableValue, options?: Partial<EncodeOptions>): Uint8Array {\n const { encodeToBytes: encodeValueToBytes } = useCborEncoder(options)\n return encodeValueToBytes(value)\n}\n\n/**\n * Encode multiple values as CBOR sequence\n *\n * Creates a CBOR sequence (RFC 8742) by concatenating multiple encoded values.\n * Useful for streaming or batch encoding.\n *\n * @param values - Array of values to encode\n * @param options - Optional encoder configuration\n * @returns Concatenated CBOR bytes and hex string\n *\n * @example\n * ```typescript\n * encodeSequence([1, \"hello\", [2, 3]])\n * // Returns concatenated encoding: 0x01 + 0x6568656c6c6f + 0x820203\n * ```\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8742 | RFC 8742 - CBOR Sequences}\n */\nexport function encodeSequence(values: EncodableValue[], options?: Partial<EncodeOptions>): EncodeResult {\n const { encodeSequence: encodeSeq } = useCborEncoder(options)\n return encodeSeq(values)\n}\n\n/**\n * Class-based CBOR decoder\n *\n * Provides an object-oriented interface for CBOR decoding.\n * Useful when you need to maintain decoder state or configuration.\n *\n * @example\n * ```typescript\n * const decoder = new CborDecoder({ strict: true })\n *\n * const result1 = decoder.decode('1864')\n * const result2 = decoder.decode('6449455446')\n *\n * const withMap = decoder.decodeWithSourceMap('d87980')\n * ```\n */\nexport class CborDecoder {\n private options: ParseOptions\n\n /**\n * Create a new CBOR decoder\n *\n * @param options - Parser configuration\n */\n constructor(options?: ParseOptions) {\n this.options = options || {}\n }\n\n /**\n * Decode CBOR hex string\n *\n * @param hexString - CBOR data as hex string\n * @returns Decoded value and byte count\n */\n decode(hexString: string): ParseResult {\n return decode(hexString, this.options)\n }\n\n /**\n * Decode CBOR hex string with source map\n *\n * @param hexString - CBOR data as hex string\n * @returns Decoded value, byte count, and source map\n */\n decodeWithSourceMap(hexString: string): ParseResultWithMap {\n return decodeWithSourceMap(hexString, this.options)\n }\n}\n\n/**\n * Class-based CBOR encoder\n *\n * Provides an object-oriented interface for CBOR encoding.\n * Useful when you need to maintain encoder state or configuration.\n *\n * @example\n * ```typescript\n * const encoder = new CborEncoder({ canonical: true })\n *\n * const result1 = encoder.encode(100)\n * const result2 = encoder.encode([1, 2, 3])\n *\n * const hex = encoder.encodeToHex({ a: 1 }) // Keys will be sorted\n * ```\n */\nexport class CborEncoder {\n private options: Partial<EncodeOptions>\n\n /**\n * Create a new CBOR encoder\n *\n * @param options - Encoder configuration\n */\n constructor(options?: Partial<EncodeOptions>) {\n this.options = options || {}\n }\n\n /**\n * Encode value to CBOR\n *\n * @param value - JavaScript value to encode\n * @returns CBOR bytes and hex string\n */\n encode(value: EncodableValue): EncodeResult {\n return encode(value, this.options)\n }\n\n /**\n * Encode value to CBOR hex string\n *\n * @param value - JavaScript value to encode\n * @returns CBOR hex string\n */\n encodeToHex(value: EncodableValue): string {\n return encodeToHex(value, this.options)\n }\n\n /**\n * Encode value to CBOR bytes\n *\n * @param value - JavaScript value to encode\n * @returns CBOR bytes\n */\n encodeToBytes(value: EncodableValue): Uint8Array {\n return encodeToBytes(value, this.options)\n }\n\n /**\n * Encode multiple values as CBOR sequence\n *\n * @param values - Array of values to encode\n * @returns Concatenated CBOR encoding\n */\n encodeSequence(values: EncodableValue[]): EncodeResult {\n return encodeSequence(values, this.options)\n }\n}\n\n// Import diagnostic notation utilities\nimport { useCborDiagnostic } from './parser/composables/useCborDiagnostic'\nimport type { DiagnosticOptions } from './parser/composables/useCborDiagnostic'\n\n/**\n * Convert a JavaScript value to RFC 8949 diagnostic notation\n *\n * Diagnostic notation is a human-readable representation of CBOR data\n * as defined in RFC 8949 Appendix B.\n *\n * @param value - JavaScript value to convert\n * @param options - Optional formatting options\n * @returns Diagnostic notation string\n *\n * @example\n * ```typescript\n * toDiagnostic(100) // \"100\"\n * toDiagnostic(new Uint8Array([1,2])) // \"h'0102'\"\n * toDiagnostic([1, 2, 3]) // \"[1, 2, 3]\"\n * toDiagnostic({a: 1}) // '{\"a\": 1}'\n * toDiagnostic({tag: 1, value: 123}) // \"1(123)\"\n *\n * // Pretty print\n * toDiagnostic([1, 2], { pretty: true })\n * // \"[\\n 1,\\n 2\\n]\"\n *\n * // Indefinite length\n * toDiagnostic([1, 2], { indefinite: true })\n * // \"[_ 1, 2]\"\n * ```\n */\nexport function toDiagnostic(value: unknown, options?: DiagnosticOptions): string {\n const { toDiagnostic: convert } = useCborDiagnostic()\n return convert(value, options)\n}\n\n/**\n * Decode CBOR and return diagnostic notation\n *\n * Combines decoding and diagnostic conversion in one step.\n *\n * @param hexString - CBOR data as hex string\n * @param options - Optional formatting options\n * @returns Diagnostic notation string\n *\n * @example\n * ```typescript\n * decodeToDiagnostic('1864') // \"100\"\n * decodeToDiagnostic('83010203') // \"[1, 2, 3]\"\n * decodeToDiagnostic('d87980') // \"121([])\"\n * ```\n */\nexport function decodeToDiagnostic(hexString: string, options?: DiagnosticOptions): string {\n const { value } = decode(hexString)\n return toDiagnostic(value, options)\n}\n"]}
1
+ {"version":3,"sources":["../src/parser/composables/useCborDiagnostic.ts","../src/parser/utils/pathBuilder.ts","../src/index.ts"],"names":["toDiagnostic","useCborParser","useCborEncoder"],"mappings":";;;;;;;AA4CA,SAAS,cAAc,KAAA,EAAsC;AAC3D,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,KAAA,IAAS,KAAA,IACT,OAAA,IAAW,KAAA,IACX,OAAQ,KAAA,CAAsB,GAAA,KAAQ,QAAA;AAE1C;AAKA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,IACpB,EAAE,KAAA,YAAiB,eACnB,EAAE,KAAA,YAAiB,GAAA,CAAA,IACnB,EAAE,KAAA,YAAiB,GAAA,CAAA,IACnB,CAAC,aAAA,CAAc,KAAK,CAAA,IACpB,KAAA,CAAM,WAAA,KAAgB,MAAA;AAE1B;AAKA,SAAS,aAAa,GAAA,EAAqB;AACzC,EAAA,OAAO,GAAA,CACJ,OAAA,CAAQ,KAAA,EAAO,MAAM,CAAA,CACrB,QAAQ,IAAA,EAAM,KAAK,CAAA,CACnB,OAAA,CA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A;AAAA,EAQA,OAAO,KAAA,EAAqC;AAC1C,IAAA,OAAO,MAAA,CAAO,KAAA,EAAO,IAAA,CAAK,OAAO,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,KAAA,EAA+B;AACzC,IAAA,OAAO,WAAA,CAAY,KAAA,EAAO,IAAA,CAAK,OAAO,CAAA;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAc,KAAA,EAAmC;AAC/C,IAAA,OAAO,aAAA,CAAc,KAAA,EAAO,IAAA,CAAK,OAAO,CAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,MAAA,EAAwC;AACrD,IAAA,OAAO,cAAA,CAAe,MAAA,EAAQ,IAAA,CAAK,OAAO,CAAA;AAAA,EAC5C;AACF;AAiCO,SAAS,YAAA,CAAa,OAAgB,OAAA,EAAqC;AAChF,EAAA,MAAM,EAAE,YAAA,EAAc,OAAA,EAAQ,GAAI,iBAAA,EAAkB;AACpD,EAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC/B;AAkBO,SAAS,kBAAA,CAAmB,WAAmB,OAAA,EAAqC;AACzF,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,MAAA,CAAO,SAAS,CAAA;AAClC,EAAA,OAAO,YAAA,CAAa,OAAO,OAAO,CAAA;AACpC","file":"index.cjs","sourcesContent":["/**\n * useCborDiagnostic - RFC 8949 Appendix B Diagnostic Notation\n *\n * Converts CBOR values to human-readable diagnostic notation as defined\n * in RFC 8949 (Concise Binary Object Representation).\n *\n * @example\n * ```typescript\n * const { toDiagnostic } = useCborDiagnostic()\n *\n * toDiagnostic(100) // \"100\"\n * toDiagnostic(new Uint8Array([1,2])) // \"h'0102'\"\n * toDiagnostic([1, 2, 3]) // \"[1, 2, 3]\"\n * toDiagnostic({a: 1}) // '{\"a\": 1}'\n * ```\n */\n\n/**\n * Options for diagnostic notation output\n */\nexport interface DiagnosticOptions {\n /** Pretty print with indentation (default: false) */\n pretty?: boolean\n /** Indentation string for pretty printing (default: ' ') */\n indent?: string\n /** Maximum depth for nested structures (default: 100) */\n maxDepth?: number\n /** Mark as indefinite-length (default: false) */\n indefinite?: boolean\n /** Show byte offsets as comments (default: false) */\n showOffsets?: boolean\n}\n\n/**\n * Tagged value interface (CBOR Major Type 6)\n */\ninterface TaggedValue {\n tag: number\n value: unknown\n}\n\n/**\n * Check if value is a tagged value\n */\nfunction isTaggedValue(value: unknown): value is TaggedValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tag' in value &&\n 'value' in value &&\n typeof (value as TaggedValue).tag === 'number'\n )\n}\n\n/**\n * Check if value is a plain object (not array, not special type)\n */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Uint8Array) &&\n !(value instanceof Map) &&\n !(value instanceof Set) &&\n !isTaggedValue(value) &&\n value.constructor === Object\n )\n}\n\n/**\n * Escape string for diagnostic notation (JSON-style escaping)\n */\nfunction escapeString(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t')\n .replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, (char) => {\n const code = char.charCodeAt(0)\n return `\\\\u${code.toString(16).padStart(4, '0')}`\n })\n}\n\n/**\n * Convert Uint8Array to hex string\n */\nfunction bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/**\n * Composable for CBOR diagnostic notation\n */\nexport function useCborDiagnostic() {\n /**\n * Convert a CBOR value to RFC 8949 diagnostic notation\n *\n * @param value - The CBOR value to convert\n * @param options - Formatting options\n * @returns Diagnostic notation string\n */\n const toDiagnostic = (\n value: unknown,\n options: DiagnosticOptions = {}\n ): string => {\n const {\n pretty = false,\n indent = ' ',\n maxDepth = 100,\n indefinite = false\n } = options\n\n return formatValue(value, 0, pretty, indent, maxDepth, indefinite)\n }\n\n /**\n * Internal recursive formatter\n */\n const formatValue = (\n value: unknown,\n depth: number,\n pretty: boolean,\n indent: string,\n maxDepth: number,\n indefinite: boolean\n ): string => {\n // Check depth limit\n if (depth > maxDepth) {\n return '...'\n }\n\n // Handle null/undefined\n if (value === null) {\n return 'null'\n }\n if (value === undefined) {\n return 'undefined'\n }\n\n // Handle booleans\n if (typeof value === 'boolean') {\n return value ? 'true' : 'false'\n }\n\n // Handle numbers\n if (typeof value === 'number') {\n // Special float values\n if (Number.isNaN(value)) {\n return 'NaN'\n }\n if (value === Infinity) {\n return 'Infinity'\n }\n if (value === -Infinity) {\n return '-Infinity'\n }\n // Negative zero\n if (Object.is(value, -0)) {\n return '-0.0'\n }\n // Regular numbers\n if (Number.isInteger(value)) {\n return value.toString()\n }\n // Floats - preserve precision\n return value.toString()\n }\n\n // Handle BigInt\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n // Handle strings\n if (typeof value === 'string') {\n return `\"${escapeString(value)}\"`\n }\n\n // Handle byte strings (Uint8Array)\n if (value instanceof Uint8Array) {\n return `h'${bytesToHex(value)}'`\n }\n\n // Handle tagged values\n if (isTaggedValue(value)) {\n const taggedContent = formatValue(\n value.value,\n depth + 1,\n pretty,\n indent,\n maxDepth,\n false\n )\n return `${value.tag}(${taggedContent})`\n }\n\n // Handle arrays\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return indefinite ? '[_ ]' : '[]'\n }\n\n const items = value.map(item =>\n formatValue(item, depth + 1, pretty, indent, maxDepth, false)\n )\n\n if (pretty) {\n const prefix = indefinite ? '[_ ' : '['\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${items.join(`,\\n${lineIndent}`)}\\n${closeIndent}]`\n } else {\n const prefix = indefinite ? '[_ ' : '['\n return `${prefix}${items.join(', ')}]`\n }\n }\n\n // Handle Maps\n if (value instanceof Map) {\n if (value.size === 0) {\n return indefinite ? '{_ }' : '{}'\n }\n\n const entries: string[] = []\n for (const [k, v] of value) {\n const keyStr = formatValue(k, depth + 1, pretty, indent, maxDepth, false)\n const valueStr = formatValue(v, depth + 1, pretty, indent, maxDepth, false)\n entries.push(`${keyStr}: ${valueStr}`)\n }\n\n if (pretty) {\n const prefix = indefinite ? '{_ ' : '{'\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${entries.join(`,\\n${lineIndent}`)}\\n${closeIndent}}`\n } else {\n const prefix = indefinite ? '{_ ' : '{'\n return `${prefix}${entries.join(', ')}}`\n }\n }\n\n // Handle Sets (convert to array)\n if (value instanceof Set) {\n const items = Array.from(value).map(item =>\n formatValue(item, depth + 1, pretty, indent, maxDepth, false)\n )\n\n if (pretty) {\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `[\\n${lineIndent}${items.join(`,\\n${lineIndent}`)}\\n${closeIndent}]`\n } else {\n return `[${items.join(', ')}]`\n }\n }\n\n // Handle plain objects (as CBOR maps with string keys)\n if (isPlainObject(value)) {\n const keys = Object.keys(value)\n if (keys.length === 0) {\n return indefinite ? '{_ }' : '{}'\n }\n\n const entries = keys.map(key => {\n const keyStr = `\"${escapeString(key)}\"`\n const valueStr = formatValue(\n value[key],\n depth + 1,\n pretty,\n indent,\n maxDepth,\n false\n )\n return `${keyStr}: ${valueStr}`\n })\n\n if (pretty) {\n const prefix = indefinite ? '{_ ' : '{'\n const lineIndent = indent.repeat(depth + 1)\n const closeIndent = indent.repeat(depth)\n return `${prefix}\\n${lineIndent}${entries.join(`,\\n${lineIndent}`)}\\n${closeIndent}}`\n } else {\n const prefix = indefinite ? '{_ ' : '{'\n return `${prefix}${entries.join(', ')}}`\n }\n }\n\n // Fallback for unknown types\n return String(value)\n }\n\n /**\n * Parse diagnostic notation back to CBOR value\n * (Not fully implemented - for future use)\n */\n const fromDiagnostic = (diag: string): unknown => {\n // Basic parsing for common cases\n const trimmed = diag.trim()\n\n // Null/undefined\n if (trimmed === 'null') return null\n if (trimmed === 'undefined') return undefined\n\n // Booleans\n if (trimmed === 'true') return true\n if (trimmed === 'false') return false\n\n // Special floats\n if (trimmed === 'NaN') return NaN\n if (trimmed === 'Infinity') return Infinity\n if (trimmed === '-Infinity') return -Infinity\n\n // Numbers (including negative zero)\n if (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n const num = Number(trimmed)\n if (trimmed === '-0.0' || trimmed === '-0') {\n return -0\n }\n return num\n }\n\n // Byte strings h'...'\n const hexMatch = trimmed.match(/^h'([0-9a-fA-F]*)'$/)\n if (hexMatch && hexMatch[1] !== undefined) {\n const hex = hexMatch[1]\n const bytes = new Uint8Array(hex.length / 2)\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16)\n }\n return bytes\n }\n\n // Strings \"...\"\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n // Basic unescape - full implementation would handle all escapes\n return trimmed.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, '\\\\')\n }\n\n // For arrays, maps, tags - would need full parser\n // Return as string for now\n return trimmed\n }\n\n /**\n * Format value with type annotation (extended notation)\n */\n const toDiagnosticWithType = (\n value: unknown,\n majorType: number,\n options: DiagnosticOptions = {}\n ): string => {\n const typeNames: Record<number, string> = {\n 0: 'uint',\n 1: 'nint',\n 2: 'bstr',\n 3: 'tstr',\n 4: 'array',\n 5: 'map',\n 6: 'tag',\n 7: 'simple'\n }\n\n const typeName = typeNames[majorType] || 'unknown'\n const diag = toDiagnostic(value, options)\n\n return `${typeName}(${diag})`\n }\n\n return {\n toDiagnostic,\n fromDiagnostic,\n toDiagnosticWithType\n }\n}\n\nexport default useCborDiagnostic\n","/**\n * PathBuilder - Utilities for creating and manipulating source map paths\n *\n * Path format follows JSON Pointer (RFC 6901) with CBOR-specific extensions:\n * - Array indices: [0], [1], [2]\n * - Object/Map keys: .key, .nested.key\n * - Special markers: [#header], [#content], [#value]\n *\n * @example\n * ```typescript\n * import { PathBuilder } from './pathBuilder'\n *\n * const path = PathBuilder.arrayIndex('', 0) // \"[0]\"\n * const nested = PathBuilder.arrayIndex(path, 1) // \"[0][1]\"\n * const key = PathBuilder.mapKey(nested, 'amount') // \"[0][1].amount\"\n * const header = PathBuilder.header(key) // \"[0][1].amount[#header]\"\n * ```\n */\n\n/**\n * PathBuilder utility object with methods for creating and manipulating paths\n */\nexport const PathBuilder = {\n /**\n * Create root path (empty string)\n */\n root: (): string => '',\n\n /**\n * Create path for array index\n * @param parent - Parent path\n * @param index - Array index (0-based)\n * @returns Path string like \"[0]\" or \"[0][1]\"\n */\n arrayIndex: (parent: string, index: number): string => `${parent}[${index}]`,\n\n /**\n * Create path for map/object key\n * @param parent - Parent path\n * @param key - Key name (string or number)\n * @returns Path string like \".key\" or \"[0].key\"\n */\n mapKey: (parent: string, key: string | number): string => {\n const keyStr = String(key)\n // Escape special characters in key names\n const escapedKey = keyStr.replace(/[.\\[\\]\\\\]/g, '\\\\$&')\n return parent ? `${parent}.${escapedKey}` : `.${escapedKey}`\n },\n\n /**\n * Create path for map key by index (for non-string keys)\n * @param parent - Parent path\n * @param index - Key index in map\n * @returns Path string like \"[#key:0]\"\n */\n mapKeyIndex: (parent: string, index: number): string =>\n `${parent}[#key:${index}]`,\n\n /**\n * Create path for header portion of a value\n * Used for byte strings, text strings, arrays, maps, tags\n * @param parent - Parent path\n * @returns Path string like \"[0][#header]\"\n */\n header: (parent: string): string => `${parent}[#header]`,\n\n /**\n * Create path for content portion of a value\n * Used for byte strings and text strings\n * @param parent - Parent path\n * @returns Path string like \"[0][#content]\"\n */\n content: (parent: string): string => `${parent}[#content]`,\n\n /**\n * Create path for tagged value\n * @param parent - Parent path\n * @returns Path string like \"[0][#value]\"\n */\n tagValue: (parent: string): string => `${parent}[#value]`,\n\n /**\n * Normalize a path by removing special markers (#header, #content, #value)\n * Used for matching paths across different representations\n * @param path - Path to normalize\n * @returns Normalized path without special markers\n */\n normalize: (path: string): string => {\n return path.replace(/\\[#(header|content|value)\\]$/, '')\n },\n\n /**\n * Check if path is a header path\n * @param path - Path to check\n * @returns True if path ends with [#header]\n */\n isHeader: (path: string): boolean => path.endsWith('[#header]'),\n\n /**\n * Check if path is a content path\n * @param path - Path to check\n * @returns True if path ends with [#content]\n */\n isContent: (path: string): boolean => path.endsWith('[#content]'),\n\n /**\n * Check if path is a tag value path\n * @param path - Path to check\n * @returns True if path ends with [#value]\n */\n isTagValue: (path: string): boolean => path.endsWith('[#value]'),\n\n /**\n * Check if path has any special marker\n * @param path - Path to check\n * @returns True if path ends with any special marker\n */\n hasMarker: (path: string): boolean =>\n /\\[#(header|content|value)\\]$/.test(path),\n\n /**\n * Get parent path (one level up)\n * @param path - Path to get parent of\n * @returns Parent path or null if already at root\n */\n getParent: (path: string): string | null => {\n // First normalize to remove markers\n const normalized = PathBuilder.normalize(path)\n if (normalized === '') return null\n\n // Match array index or object key at end\n const arrayMatch = normalized.match(/^(.+)\\[\\d+\\]$/)\n if (arrayMatch && arrayMatch[1] !== undefined) return arrayMatch[1]\n\n const keyMatch = normalized.match(/^(.+)\\.[^.]+$/)\n if (keyMatch && keyMatch[1] !== undefined) return keyMatch[1]\n\n // Root level item\n if (normalized.startsWith('[') || normalized.startsWith('.')) {\n return ''\n }\n\n return null\n },\n\n /**\n * Get the depth (nesting level) of a path\n * @param path - Path to measure\n * @returns Number indicating nesting depth (0 for root)\n */\n getDepth: (path: string): number => {\n const normalized = PathBuilder.normalize(path)\n if (normalized === '') return 0\n\n // Count array indices and object keys\n const arrayDepth = (normalized.match(/\\[\\d+\\]/g) || []).length\n const keyDepth = (normalized.match(/\\./g) || []).length\n\n return arrayDepth + keyDepth\n },\n\n /**\n * Parse a path into its components\n * @param path - Path to parse\n * @returns Array of path segments\n */\n parse: (path: string): Array<{ type: 'index' | 'key' | 'marker'; value: string | number }> => {\n const normalized = PathBuilder.normalize(path)\n const segments: Array<{ type: 'index' | 'key' | 'marker'; value: string | number }> = []\n\n // Check for marker\n const markerMatch = path.match(/\\[#(header|content|value)\\]$/)\n\n // Parse the normalized path\n let remaining = normalized\n while (remaining) {\n // Array index\n const indexMatch = remaining.match(/^\\[(\\d+)\\]/)\n if (indexMatch && indexMatch[1] !== undefined) {\n segments.push({ type: 'index', value: parseInt(indexMatch[1], 10) })\n remaining = remaining.slice(indexMatch[0].length)\n continue\n }\n\n // Object key\n const keyMatch = remaining.match(/^\\.([^.\\[\\]]+)/)\n if (keyMatch && keyMatch[1] !== undefined) {\n // Unescape special characters\n const key = keyMatch[1].replace(/\\\\(.)/g, '$1')\n segments.push({ type: 'key', value: key })\n remaining = remaining.slice(keyMatch[0].length)\n continue\n }\n\n // Unknown format, break to avoid infinite loop\n break\n }\n\n // Add marker if present\n if (markerMatch && markerMatch[1] !== undefined) {\n segments.push({ type: 'marker', value: markerMatch[1] })\n }\n\n return segments\n },\n\n /**\n * Build a path from segments\n * @param segments - Array of path segments\n * @returns Path string\n */\n build: (segments: Array<{ type: 'index' | 'key' | 'marker'; value: string | number }>): string => {\n let path = ''\n\n for (const segment of segments) {\n if (segment.type === 'index') {\n path += `[${segment.value}]`\n } else if (segment.type === 'key') {\n const escapedKey = String(segment.value).replace(/[.\\[\\]\\\\]/g, '\\\\$&')\n path += `.${escapedKey}`\n } else if (segment.type === 'marker') {\n path += `[#${segment.value}]`\n }\n }\n\n return path\n },\n\n /**\n * Join multiple path segments\n * @param paths - Path segments to join\n * @returns Combined path\n */\n join: (...paths: string[]): string => {\n return paths.filter(p => p !== '').join('')\n },\n\n /**\n * Check if a path is a descendant of another path\n * @param path - Path to check\n * @param ancestor - Potential ancestor path\n * @returns True if path is a descendant of ancestor\n */\n isDescendantOf: (path: string, ancestor: string): boolean => {\n const normalizedPath = PathBuilder.normalize(path)\n const normalizedAncestor = PathBuilder.normalize(ancestor)\n\n if (normalizedAncestor === '') {\n return normalizedPath !== ''\n }\n\n return normalizedPath.startsWith(normalizedAncestor) &&\n normalizedPath.length > normalizedAncestor.length &&\n (normalizedPath[normalizedAncestor.length] === '[' ||\n normalizedPath[normalizedAncestor.length] === '.')\n }\n}\n\nexport default PathBuilder\n","/**\n * NACHOS - Not Another CBOR Handling Object System\n *\n * RFC 8949 CBOR (Concise Binary Object Representation) encoder and decoder\n * with full source map support for interactive debugging.\n *\n * @module @marcuspuchalla/nachos\n * @see https://datatracker.ietf.org/doc/html/rfc8949\n *\n * @example\n * ```typescript\n * // Simple decoding\n * import { decode } from '@marcuspuchalla/nachos'\n * const result = decode('1864') // { value: 100, bytesRead: 2 }\n *\n * // Simple encoding\n * import { encode } from '@marcuspuchalla/nachos'\n * const { hex, bytes } = encode(100) // hex: \"1864\"\n *\n * // With source maps for debugging\n * import { decodeWithSourceMap } from '@marcuspuchalla/nachos'\n * const { value, sourceMap } = decodeWithSourceMap('d87980')\n * // sourceMap links hex bytes to decoded values\n * ```\n */\n\n// Re-export from parser (decoder)\nexport { useCborParser } from './parser/composables/useCborParser'\nexport { useCborInteger } from './parser/composables/useCborInteger'\nexport { useCborString } from './parser/composables/useCborString'\nexport { useCborCollection } from './parser/composables/useCborCollection'\nexport { useCborFloat } from './parser/composables/useCborFloat'\nexport { useCborTag } from './parser/composables/useCborTag'\nexport { useCborDiagnostic } from './parser/composables/useCborDiagnostic'\nexport type { DiagnosticOptions } from './parser/composables/useCborDiagnostic'\n\n// Re-export utilities\nexport { PathBuilder } from './parser/utils/pathBuilder'\n\n// Re-export from encoder\nexport { useCborEncoder } from './encoder/composables/useCborEncoder'\nexport { useCborIntegerEncoder } from './encoder/composables/useCborIntegerEncoder'\nexport { useCborStringEncoder } from './encoder/composables/useCborStringEncoder'\nexport { useCborCollectionEncoder } from './encoder/composables/useCborCollectionEncoder'\nexport { useCborSimpleEncoder } from './encoder/composables/useCborSimpleEncoder'\n\n// Re-export types\nexport type {\n // Parser types\n ParseResult,\n ParseResultWithMap,\n ParseOptions,\n ParseError,\n ParserLimits,\n CborContext,\n CborValue,\n CborMap,\n TaggedValue,\n PlutusData,\n PlutusConstr,\n PlutusMap,\n PlutusList,\n PlutusInt,\n PlutusBytes,\n SourceMapEntry,\n Result\n} from './parser/types'\n\nexport {\n // Default options\n DEFAULT_OPTIONS,\n DEFAULT_LIMITS,\n // Enums\n CborMajorType,\n CborAdditionalInfo,\n CborSimpleValue,\n CborTag\n} from './parser/types'\n\nexport type {\n // Encoder types\n EncodeResult,\n EncodeOptions,\n EncodableValue,\n EncodeContext\n} from './encoder/types'\n\nexport {\n DEFAULT_ENCODE_OPTIONS\n} from './encoder/types'\n\n// Convenience exports with cleaner names for library users\nimport { useCborParser } from './parser/composables/useCborParser'\nimport { useCborEncoder } from './encoder/composables/useCborEncoder'\nimport type { ParseResult, ParseResultWithMap, ParseOptions } from './parser/types'\nimport type { EncodeResult, EncodeOptions, EncodableValue } from './encoder/types'\n\n/**\n * Decode CBOR data to JavaScript value\n *\n * Accepts either a hex string or a Uint8Array of raw CBOR bytes.\n * When passing a Uint8Array, the bytes are used directly without\n * hex conversion, which is more efficient for binary sources\n * (WebSocket, fetch, file I/O, etc.).\n *\n * @param input - CBOR data as hex string (e.g., \"1864\") or Uint8Array\n * @param options - Optional parser configuration\n * @returns Decoded value and number of bytes consumed\n *\n * @throws {Error} If input is invalid or malformed CBOR\n *\n * @example\n * ```typescript\n * // Decode from hex string\n * decode('1864') // { value: 100, bytesRead: 2 }\n *\n * // Decode from Uint8Array (zero-copy, no hex conversion)\n * decode(new Uint8Array([0x18, 0x64])) // { value: 100, bytesRead: 2 }\n *\n * // Decode string\n * decode('6449455446') // { value: \"IETF\", bytesRead: 5 }\n *\n * // Decode array\n * decode('83010203') // { value: [1, 2, 3], bytesRead: 4 }\n *\n * // With strict validation\n * decode('1864', { strict: true })\n *\n * // With canonical validation\n * decode('a16161 01', { validateCanonical: true })\n * ```\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8949 | RFC 8949}\n */\nexport function decode(input: string | Uint8Array, options?: ParseOptions): ParseResult {\n const { parse } = useCborParser()\n return parse(input, options)\n}\n\n/**\n * Decode CBOR data with source map generation\n *\n * Source maps provide bidirectional linking between hex bytes and decoded values,\n * enabling interactive debugging visualizations.\n *\n * Accepts either a hex string or a Uint8Array of raw CBOR bytes.\n *\n * @param input - CBOR data as hex string or Uint8Array\n * @param options - Optional parser configuration\n * @returns Decoded value, byte count, and source map\n *\n * @example\n * ```typescript\n * const { value, sourceMap } = decodeWithSourceMap('d87980')\n * // value: { tag: 121, value: [] }\n * // sourceMap: [\n * // { path: '', start: 0, end: 3, majorType: 6, type: 'Tag 121', children: ['.value'] },\n * // { path: '.value', start: 2, end: 3, majorType: 4, type: 'Array', parent: '' }\n * // ]\n *\n * // From Uint8Array\n * const { value, sourceMap } = decodeWithSourceMap(new Uint8Array([0xd8, 0x79, 0x80]))\n * ```\n */\nexport function decodeWithSourceMap(input: string | Uint8Array, options?: ParseOptions): ParseResultWithMap {\n const { parseWithSourceMap } = useCborParser()\n return parseWithSourceMap(input, options)\n}\n\n/**\n * Encode JavaScript value to CBOR\n *\n * Automatically detects value type and uses appropriate CBOR encoding.\n * Supports: numbers, bigints, strings, booleans, null, undefined, Uint8Arrays, arrays, objects, and tagged values.\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR bytes and hex string\n *\n * @throws {Error} If value type is unsupported or encoding fails\n *\n * @example\n * ```typescript\n * // Encode number\n * encode(100) // { hex: \"1864\", bytes: Uint8Array[0x18, 0x64] }\n *\n * // Encode string\n * encode(\"IETF\") // { hex: \"6449455446\", bytes: ... }\n *\n * // Encode array\n * encode([1, 2, 3]) // { hex: \"83010203\", bytes: ... }\n *\n * // Encode map (canonical - sorted keys)\n * encode({ z: 1, a: 2 }, { canonical: true })\n * // Keys will be sorted: { a: 2, z: 1 }\n *\n * // Encode tagged value\n * encode({ tag: 121, value: [] }) // { hex: \"d87980\", bytes: ... }\n * ```\n */\nexport function encode(value: EncodableValue, options?: Partial<EncodeOptions>): EncodeResult {\n const { encode: encodeValue } = useCborEncoder(options)\n return encodeValue(value)\n}\n\n/**\n * Encode JavaScript value to CBOR hex string\n *\n * Convenience function that returns only the hex string (not the bytes).\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR hex string\n *\n * @example\n * ```typescript\n * encodeToHex(100) // \"1864\"\n * encodeToHex([1, 2, 3]) // \"83010203\"\n * encodeToHex({ a: 1 }, { canonical: true }) // \"a16161 01\"\n * ```\n */\nexport function encodeToHex(value: EncodableValue, options?: Partial<EncodeOptions>): string {\n const { encodeToHex: encodeValueToHex } = useCborEncoder(options)\n return encodeValueToHex(value)\n}\n\n/**\n * Encode JavaScript value to CBOR bytes\n *\n * Convenience function that returns only the bytes (not the hex string).\n *\n * @param value - JavaScript value to encode\n * @param options - Optional encoder configuration\n * @returns CBOR bytes as Uint8Array\n *\n * @example\n * ```typescript\n * const bytes = encodeToBytes(100) // Uint8Array[0x18, 0x64]\n * const bytes = encodeToBytes([1, 2, 3]) // Uint8Array[0x83, 0x01, 0x02, 0x03]\n * ```\n */\nexport function encodeToBytes(value: EncodableValue, options?: Partial<EncodeOptions>): Uint8Array {\n const { encodeToBytes: encodeValueToBytes } = useCborEncoder(options)\n return encodeValueToBytes(value)\n}\n\n/**\n * Encode multiple values as CBOR sequence\n *\n * Creates a CBOR sequence (RFC 8742) by concatenating multiple encoded values.\n * Useful for streaming or batch encoding.\n *\n * @param values - Array of values to encode\n * @param options - Optional encoder configuration\n * @returns Concatenated CBOR bytes and hex string\n *\n * @example\n * ```typescript\n * encodeSequence([1, \"hello\", [2, 3]])\n * // Returns concatenated encoding: 0x01 + 0x6568656c6c6f + 0x820203\n * ```\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8742 | RFC 8742 - CBOR Sequences}\n */\nexport function encodeSequence(values: EncodableValue[], options?: Partial<EncodeOptions>): EncodeResult {\n const { encodeSequence: encodeSeq } = useCborEncoder(options)\n return encodeSeq(values)\n}\n\n/**\n * Class-based CBOR decoder\n *\n * Provides an object-oriented interface for CBOR decoding.\n * Useful when you need to maintain decoder state or configuration.\n *\n * @example\n * ```typescript\n * const decoder = new CborDecoder({ strict: true })\n *\n * const result1 = decoder.decode('1864')\n * const result2 = decoder.decode('6449455446')\n *\n * const withMap = decoder.decodeWithSourceMap('d87980')\n * ```\n */\nexport class CborDecoder {\n private options: ParseOptions\n\n /**\n * Create a new CBOR decoder\n *\n * @param options - Parser configuration\n */\n constructor(options?: ParseOptions) {\n this.options = options || {}\n }\n\n /**\n * Decode CBOR data\n *\n * @param input - CBOR data as hex string or Uint8Array\n * @returns Decoded value and byte count\n */\n decode(input: string | Uint8Array): ParseResult {\n return decode(input, this.options)\n }\n\n /**\n * Decode CBOR data with source map\n *\n * @param input - CBOR data as hex string or Uint8Array\n * @returns Decoded value, byte count, and source map\n */\n decodeWithSourceMap(input: string | Uint8Array): ParseResultWithMap {\n return decodeWithSourceMap(input, this.options)\n }\n}\n\n/**\n * Class-based CBOR encoder\n *\n * Provides an object-oriented interface for CBOR encoding.\n * Useful when you need to maintain encoder state or configuration.\n *\n * @example\n * ```typescript\n * const encoder = new CborEncoder({ canonical: true })\n *\n * const result1 = encoder.encode(100)\n * const result2 = encoder.encode([1, 2, 3])\n *\n * const hex = encoder.encodeToHex({ a: 1 }) // Keys will be sorted\n * ```\n */\nexport class CborEncoder {\n private options: Partial<EncodeOptions>\n\n /**\n * Create a new CBOR encoder\n *\n * @param options - Encoder configuration\n */\n constructor(options?: Partial<EncodeOptions>) {\n this.options = options || {}\n }\n\n /**\n * Encode value to CBOR\n *\n * @param value - JavaScript value to encode\n * @returns CBOR bytes and hex string\n */\n encode(value: EncodableValue): EncodeResult {\n return encode(value, this.options)\n }\n\n /**\n * Encode value to CBOR hex string\n *\n * @param value - JavaScript value to encode\n * @returns CBOR hex string\n */\n encodeToHex(value: EncodableValue): string {\n return encodeToHex(value, this.options)\n }\n\n /**\n * Encode value to CBOR bytes\n *\n * @param value - JavaScript value to encode\n * @returns CBOR bytes\n */\n encodeToBytes(value: EncodableValue): Uint8Array {\n return encodeToBytes(value, this.options)\n }\n\n /**\n * Encode multiple values as CBOR sequence\n *\n * @param values - Array of values to encode\n * @returns Concatenated CBOR encoding\n */\n encodeSequence(values: EncodableValue[]): EncodeResult {\n return encodeSequence(values, this.options)\n }\n}\n\n// Import diagnostic notation utilities\nimport { useCborDiagnostic } from './parser/composables/useCborDiagnostic'\nimport type { DiagnosticOptions } from './parser/composables/useCborDiagnostic'\n\n/**\n * Convert a JavaScript value to RFC 8949 diagnostic notation\n *\n * Diagnostic notation is a human-readable representation of CBOR data\n * as defined in RFC 8949 Appendix B.\n *\n * @param value - JavaScript value to convert\n * @param options - Optional formatting options\n * @returns Diagnostic notation string\n *\n * @example\n * ```typescript\n * toDiagnostic(100) // \"100\"\n * toDiagnostic(new Uint8Array([1,2])) // \"h'0102'\"\n * toDiagnostic([1, 2, 3]) // \"[1, 2, 3]\"\n * toDiagnostic({a: 1}) // '{\"a\": 1}'\n * toDiagnostic({tag: 1, value: 123}) // \"1(123)\"\n *\n * // Pretty print\n * toDiagnostic([1, 2], { pretty: true })\n * // \"[\\n 1,\\n 2\\n]\"\n *\n * // Indefinite length\n * toDiagnostic([1, 2], { indefinite: true })\n * // \"[_ 1, 2]\"\n * ```\n */\nexport function toDiagnostic(value: unknown, options?: DiagnosticOptions): string {\n const { toDiagnostic: convert } = useCborDiagnostic()\n return convert(value, options)\n}\n\n/**\n * Decode CBOR and return diagnostic notation\n *\n * Combines decoding and diagnostic conversion in one step.\n *\n * @param hexString - CBOR data as hex string\n * @param options - Optional formatting options\n * @returns Diagnostic notation string\n *\n * @example\n * ```typescript\n * decodeToDiagnostic('1864') // \"100\"\n * decodeToDiagnostic('83010203') // \"[1, 2, 3]\"\n * decodeToDiagnostic('d87980') // \"121([])\"\n * ```\n */\nexport function decodeToDiagnostic(hexString: string, options?: DiagnosticOptions): string {\n const { value } = decode(hexString)\n return toDiagnostic(value, options)\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- export { c as useCborCollection, d as useCborFloat, a as useCborInteger, u as useCborParser, b as useCborString, e as useCborTag } from './useCborTag-Cs1CZuXZ.cjs';
2
- import { E as EncodableValue, a as EncodeOptions, b as EncodeResult } from './useCborSimpleEncoder-ButVU988.cjs';
3
- export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from './useCborSimpleEncoder-ButVU988.cjs';
1
+ export { c as useCborCollection, d as useCborFloat, a as useCborInteger, u as useCborParser, b as useCborString, e as useCborTag } from './useCborTag-QpZR-Er2.cjs';
2
+ import { E as EncodableValue, a as EncodeOptions, b as EncodeResult } from './useCborSimpleEncoder-C_OHxoB8.cjs';
3
+ export { D as DEFAULT_ENCODE_OPTIONS, g as EncodeContext, e as useCborCollectionEncoder, u as useCborEncoder, c as useCborIntegerEncoder, f as useCborSimpleEncoder, d as useCborStringEncoder } from './useCborSimpleEncoder-C_OHxoB8.cjs';
4
4
  import { P as ParseOptions, a as ParseResult, b as ParseResultWithMap } from './types-DvNlfbKB.cjs';
5
5
  export { o as CborAdditionalInfo, C as CborContext, n as CborMajorType, f as CborMap, p as CborSimpleValue, q as CborTag, e as CborValue, m as DEFAULT_LIMITS, D as DEFAULT_OPTIONS, c as ParseError, d as ParserLimits, l as PlutusBytes, h as PlutusConstr, g as PlutusData, k as PlutusInt, j as PlutusList, i as PlutusMap, R as Result, S as SourceMapEntry, T as TaggedValue } from './types-DvNlfbKB.cjs';
6
6
 
@@ -214,9 +214,14 @@ declare const PathBuilder: {
214
214
  */
215
215
 
216
216
  /**
217
- * Decode CBOR hex string to JavaScript value
217
+ * Decode CBOR data to JavaScript value
218
218
  *
219
- * @param hexString - CBOR data as hex string (e.g., "1864" for integer 100)
219
+ * Accepts either a hex string or a Uint8Array of raw CBOR bytes.
220
+ * When passing a Uint8Array, the bytes are used directly without
221
+ * hex conversion, which is more efficient for binary sources
222
+ * (WebSocket, fetch, file I/O, etc.).
223
+ *
224
+ * @param input - CBOR data as hex string (e.g., "1864") or Uint8Array
220
225
  * @param options - Optional parser configuration
221
226
  * @returns Decoded value and number of bytes consumed
222
227
  *
@@ -224,9 +229,12 @@ declare const PathBuilder: {
224
229
  *
225
230
  * @example
226
231
  * ```typescript
227
- * // Decode integer
232
+ * // Decode from hex string
228
233
  * decode('1864') // { value: 100, bytesRead: 2 }
229
234
  *
235
+ * // Decode from Uint8Array (zero-copy, no hex conversion)
236
+ * decode(new Uint8Array([0x18, 0x64])) // { value: 100, bytesRead: 2 }
237
+ *
230
238
  * // Decode string
231
239
  * decode('6449455446') // { value: "IETF", bytesRead: 5 }
232
240
  *
@@ -242,14 +250,16 @@ declare const PathBuilder: {
242
250
  *
243
251
  * @see {@link https://datatracker.ietf.org/doc/html/rfc8949 | RFC 8949}
244
252
  */
245
- declare function decode(hexString: string, options?: ParseOptions): ParseResult;
253
+ declare function decode(input: string | Uint8Array, options?: ParseOptions): ParseResult;
246
254
  /**
247
- * Decode CBOR hex string with source map generation
255
+ * Decode CBOR data with source map generation
248
256
  *
249
257
  * Source maps provide bidirectional linking between hex bytes and decoded values,
250
258
  * enabling interactive debugging visualizations.
251
259
  *
252
- * @param hexString - CBOR data as hex string
260
+ * Accepts either a hex string or a Uint8Array of raw CBOR bytes.
261
+ *
262
+ * @param input - CBOR data as hex string or Uint8Array
253
263
  * @param options - Optional parser configuration
254
264
  * @returns Decoded value, byte count, and source map
255
265
  *
@@ -262,12 +272,11 @@ declare function decode(hexString: string, options?: ParseOptions): ParseResult;
262
272
  * // { path: '.value', start: 2, end: 3, majorType: 4, type: 'Array', parent: '' }
263
273
  * // ]
264
274
  *
265
- * // Use source map for hex-to-JSON linking
266
- * const entry = sourceMap.find(e => e.path === '.value')
267
- * console.log(`Value is at bytes ${entry.start}-${entry.end}`)
275
+ * // From Uint8Array
276
+ * const { value, sourceMap } = decodeWithSourceMap(new Uint8Array([0xd8, 0x79, 0x80]))
268
277
  * ```
269
278
  */
270
- declare function decodeWithSourceMap(hexString: string, options?: ParseOptions): ParseResultWithMap;
279
+ declare function decodeWithSourceMap(input: string | Uint8Array, options?: ParseOptions): ParseResultWithMap;
271
280
  /**
272
281
  * Encode JavaScript value to CBOR
273
282
  *
@@ -377,19 +386,19 @@ declare class CborDecoder {
377
386
  */
378
387
  constructor(options?: ParseOptions);
379
388
  /**
380
- * Decode CBOR hex string
389
+ * Decode CBOR data
381
390
  *
382
- * @param hexString - CBOR data as hex string
391
+ * @param input - CBOR data as hex string or Uint8Array
383
392
  * @returns Decoded value and byte count
384
393
  */
385
- decode(hexString: string): ParseResult;
394
+ decode(input: string | Uint8Array): ParseResult;
386
395
  /**
387
- * Decode CBOR hex string with source map
396
+ * Decode CBOR data with source map
388
397
  *
389
- * @param hexString - CBOR data as hex string
398
+ * @param input - CBOR data as hex string or Uint8Array
390
399
  * @returns Decoded value, byte count, and source map
391
400
  */
392
- decodeWithSourceMap(hexString: string): ParseResultWithMap;
401
+ decodeWithSourceMap(input: string | Uint8Array): ParseResultWithMap;
393
402
  }
394
403
  /**
395
404
  * Class-based CBOR encoder