@cbortech/cbor 0.24.0 → 0.25.1

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 (54) hide show
  1. package/README.ja.md +127 -49
  2. package/README.md +128 -49
  3. package/dist/ast/CborAppSeqResult.d.ts +20 -0
  4. package/dist/ast/CborArray.d.ts +3 -3
  5. package/dist/ast/CborBignum.d.ts +5 -5
  6. package/dist/ast/CborByteString.d.ts +2 -2
  7. package/dist/ast/CborEllipsis.d.ts +2 -2
  8. package/dist/ast/CborEmbeddedCBOR.d.ts +3 -3
  9. package/dist/ast/CborFloat.d.ts +8 -2
  10. package/dist/ast/CborIndefiniteByteString.d.ts +3 -3
  11. package/dist/ast/CborIndefiniteTextString.d.ts +3 -3
  12. package/dist/ast/CborItem.d.ts +22 -10
  13. package/dist/ast/CborMap.d.ts +3 -3
  14. package/dist/ast/CborNint.d.ts +2 -2
  15. package/dist/ast/CborSimple.d.ts +2 -2
  16. package/dist/ast/CborTag.d.ts +3 -3
  17. package/dist/ast/CborTextString.d.ts +2 -2
  18. package/dist/ast/CborUint.d.ts +2 -2
  19. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  20. package/dist/ast/index.cjs +1 -1
  21. package/dist/ast/index.js +2 -2
  22. package/dist/cbor.d.ts +44 -26
  23. package/dist/cdn/parser.d.ts +7 -0
  24. package/dist/{edn → cdn}/serialize-utils.d.ts +20 -7
  25. package/dist/cdn/serializer.d.ts +7 -0
  26. package/dist/cdn/test-vectors/runner.d.ts +22 -0
  27. package/dist/{edn → cdn}/tokenizer.d.ts +28 -25
  28. package/dist/extensions/b32.d.ts +5 -0
  29. package/dist/extensions/cri.d.ts +7 -7
  30. package/dist/extensions/dt.d.ts +10 -19
  31. package/dist/extensions/float.d.ts +7 -0
  32. package/dist/extensions/ip.d.ts +8 -8
  33. package/dist/extensions/same.d.ts +7 -0
  34. package/dist/extensions/types.d.ts +30 -8
  35. package/dist/index.cjs +5 -2
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.ts +4 -1
  38. package/dist/index.js +244 -77
  39. package/dist/index.js.map +1 -1
  40. package/dist/mapEntries-BccT62HT.cjs +36 -0
  41. package/dist/mapEntries-BccT62HT.cjs.map +1 -0
  42. package/dist/{mapEntries-D5MWtXqq.js → mapEntries-ZR8QJ0Yj.js} +1157 -853
  43. package/dist/mapEntries-ZR8QJ0Yj.js.map +1 -0
  44. package/dist/simple.d.ts +2 -2
  45. package/dist/tag.d.ts +1 -1
  46. package/dist/types.d.ts +141 -30
  47. package/dist/utils/hexfloat.d.ts +2 -2
  48. package/dist/utils/strip-comments.d.ts +12 -0
  49. package/package.json +13 -11
  50. package/dist/edn/parser.d.ts +0 -7
  51. package/dist/edn/serializer.d.ts +0 -7
  52. package/dist/mapEntries-D5MWtXqq.js.map +0 -1
  53. package/dist/mapEntries-bihZ3yks.cjs +0 -31
  54. package/dist/mapEntries-bihZ3yks.cjs.map +0 -1
@@ -0,0 +1,20 @@
1
+ import { ToCDNOptions, ToCBOROptions, ToJSOptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ /**
4
+ * Wraps a resolved app-sequence result and preserves the original EDN source
5
+ * text for round-trip fidelity.
6
+ *
7
+ * When `appStrings !== false`, `_toCDN` returns the stored source text verbatim.
8
+ * Otherwise it delegates to the wrapped item so the caller gets a plain value.
9
+ *
10
+ * CBOR encoding and JS conversion always delegate to the inner item so the
11
+ * wrapper is fully transparent for those operations.
12
+ */
13
+ export declare class CborAppSeqResult extends CborItem {
14
+ readonly inner: CborItem;
15
+ readonly ednSource: string;
16
+ constructor(inner: CborItem, ednSource: string);
17
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
18
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
19
+ _toJS(options?: ToJSOptions): unknown;
20
+ }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 4 — array (definite- or indefinite-length). */
@@ -11,7 +11,7 @@ export declare class CborArray extends CborItem {
11
11
  encodingWidth?: EncodingWidth;
12
12
  });
13
13
  _toCBOR(options?: ToCBOROptions): Uint8Array;
14
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
14
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
15
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
16
16
  _toJS(options?: ToJSOptions): unknown;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  export declare const BIGNUM_UINT_TAG = 2n;
4
4
  export declare const BIGNUM_NINT_TAG = 3n;
@@ -15,22 +15,22 @@ export declare function bytesToBigint(bytes: Uint8Array): bigint;
15
15
  /**
16
16
  * Unsigned bignum — integers ≥ 2^64.
17
17
  * Wire format: tag(2, big-endian byte string).
18
- * toEDN() emits the plain decimal integer.
18
+ * toCDN() emits the plain decimal integer.
19
19
  */
20
20
  export declare class CborBigUint extends CborTag {
21
21
  readonly bigValue: bigint;
22
22
  constructor(value: bigint);
23
- _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
23
+ _toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
24
24
  _toJS(_options?: ToJSOptions): bigint;
25
25
  }
26
26
  /**
27
27
  * Negative bignum — integers ≤ -(2^64 + 1).
28
28
  * Wire format: tag(3, big-endian byte string of (-1 - value)).
29
- * toEDN() emits the plain decimal integer.
29
+ * toCDN() emits the plain decimal integer.
30
30
  */
31
31
  export declare class CborBigNint extends CborTag {
32
32
  readonly bigValue: bigint;
33
33
  constructor(value: bigint);
34
- _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
34
+ _toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
35
35
  _toJS(_options?: ToJSOptions): bigint;
36
36
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 2 — definite-length byte string. */
@@ -15,6 +15,6 @@ export declare class CborByteString extends CborItem {
15
15
  ednSource?: string;
16
16
  });
17
17
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
18
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
18
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
19
19
  _toJS(_options?: ToJSOptions): unknown;
20
20
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions } from '../types';
1
+ import { ToCDNOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  import { CborItem } from './CborItem';
4
4
  export declare const CPA888_TAG = 888n;
@@ -7,5 +7,5 @@ export declare class CborEllipsis extends CborTag {
7
7
  constructor();
8
8
  /** String/bytes elision: 888([items...]) */
9
9
  constructor(items: CborItem[]);
10
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
10
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
11
11
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  /**
4
4
  * CBOR Sequence Literal (§2.5.6) — `<<item, item, ...>>`.
@@ -16,7 +16,7 @@ export declare class CborEmbeddedCBOR extends CborItem {
16
16
  /** The raw concatenated CBOR bytes of all contained items. */
17
17
  private _content;
18
18
  _toCBOR(options?: ToCBOROptions): Uint8Array;
19
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
20
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
19
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
20
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
21
21
  _toJS(_options?: ToJSOptions): unknown;
22
22
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  export type FloatPrecision = 'half' | 'single' | 'double';
4
4
  /**
@@ -18,10 +18,16 @@ export declare class CborFloat extends CborItem {
18
18
  * - `undefined`: encoder auto-selects the smallest lossless size.
19
19
  */
20
20
  readonly precision: FloatPrecision | undefined;
21
+ /**
22
+ * Original app-string source (e.g. `float'7e00'`), set by the parser when
23
+ * this float is the result of a `float'...'` app-string. Used by toCDN()
24
+ * to round-trip the literal when `appStrings` is not false.
25
+ */
26
+ ednSource?: string;
21
27
  constructor(value: number, options?: {
22
28
  precision?: FloatPrecision;
23
29
  });
24
30
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
25
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
31
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
26
32
  _toJS(_options?: ToJSOptions): unknown;
27
33
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { CborByteString } from './CborByteString';
4
4
  /** CBOR Major Type 2 — indefinite-length byte string (chunked). */
@@ -7,7 +7,7 @@ export declare class CborIndefiniteByteString extends CborItem {
7
7
  readonly chunks: CborByteString[];
8
8
  constructor(chunks: CborByteString[]);
9
9
  _toCBOR(options?: ToCBOROptions): Uint8Array;
10
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
10
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
12
12
  _toJS(_options?: ToJSOptions): unknown;
13
13
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { CborTextString } from './CborTextString';
4
4
  /** CBOR Major Type 3 — indefinite-length UTF-8 text string (chunked). */
@@ -7,7 +7,7 @@ export declare class CborIndefiniteTextString extends CborItem {
7
7
  readonly chunks: CborTextString[];
8
8
  constructor(chunks: CborTextString[]);
9
9
  _toCBOR(options?: ToCBOROptions): Uint8Array;
10
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
10
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
12
12
  _toJS(_options?: ToJSOptions): unknown;
13
13
  }
@@ -1,4 +1,4 @@
1
- import { CBOROptions, ToEDNOptions, ToJSOptions, ToHexDumpOptions, ToCBOROptions, CborComments } from '../types';
1
+ import { CBOROptions, ToCDNOptions, ToJSOptions, ToHexDumpOptions, ToCBOROptions, CborComments, DecodeWarning, ParseWarning } from '../types';
2
2
  /** @internal One line of an annotated hex dump. */
3
3
  export interface AnnotatedLine {
4
4
  depth: number;
@@ -8,7 +8,7 @@ export interface AnnotatedLine {
8
8
  /**
9
9
  * Abstract base class for all CBOR AST nodes.
10
10
  *
11
- * Every node can serialize itself to CBOR binary, CBOR-EDN text, and a
11
+ * Every node can serialize itself to CBOR binary, CDN text, and a
12
12
  * plain JavaScript value. Concrete implementations are provided in each
13
13
  * subclass (added in later phases).
14
14
  */
@@ -26,10 +26,16 @@ export declare abstract class CborItem {
26
26
  */
27
27
  end?: number;
28
28
  /**
29
- * Comments captured from CBOR-EDN source when `preserveComments` is enabled.
29
+ * Comments captured from CDN source when `preserveComments` is enabled.
30
30
  * They do not affect CBOR bytes or JS conversion.
31
31
  */
32
32
  comments?: CborComments;
33
+ /**
34
+ * Validity violations detected while decoding or parsing this node.
35
+ * Populated when `strict: false` is set in `FromCBOROptions` or
36
+ * `FromCDNOptions`.
37
+ */
38
+ warnings?: (DecodeWarning | ParseWarning)[];
33
39
  /**
34
40
  * Default options bound by a {@link CBOR} instance factory method.
35
41
  * Per-call options always take precedence.
@@ -38,8 +44,14 @@ export declare abstract class CborItem {
38
44
  _defaults?: CBOROptions;
39
45
  /** Serialize this node to CBOR binary. */
40
46
  toCBOR(options?: ToCBOROptions): Uint8Array;
41
- /** Serialize this node to a CBOR-EDN text string. */
42
- toEDN(options?: ToEDNOptions): string;
47
+ /** Serialize this node to a CDN text string. */
48
+ toCDN(options?: ToCDNOptions): string;
49
+ /**
50
+ * Serialize this node to a CDN text string.
51
+ *
52
+ * @deprecated Use `toCDN()` instead.
53
+ */
54
+ toEDN(options?: ToCDNOptions): string;
43
55
  /**
44
56
  * Convert this CBOR AST node to a plain JavaScript value.
45
57
  *
@@ -53,7 +65,7 @@ export declare abstract class CborItem {
53
65
  * Generate an RFC 8949 §3 style annotated hex dump of this value.
54
66
  *
55
67
  * @example
56
- * const cbor = CBOR.fromEDN('[_ 1, [2, 3]]');
68
+ * const cbor = CBOR.fromCDN('[_ 1, [2, 3]]');
57
69
  * console.log(cbor.toHexDump());
58
70
  * // 9F -- Start indefinite-length array
59
71
  * // 01 -- 1
@@ -68,12 +80,12 @@ export declare abstract class CborItem {
68
80
  abstract _toCBOR(options?: ToCBOROptions): Uint8Array;
69
81
  /**
70
82
  * @internal
71
- * Depth-aware EDN serialization.
83
+ * Depth-aware CDN serialization.
72
84
  * Leaf nodes receive `depth` but may ignore it.
73
85
  * Container nodes use `depth` for indentation and call
74
- * `child._toEDN(options, depth + 1)` when recursing.
86
+ * `child._toCDN(options, depth + 1)` when recursing.
75
87
  */
76
- abstract _toEDN(options: ToEDNOptions | undefined, depth: number): string;
88
+ abstract _toCDN(options: ToCDNOptions | undefined, depth: number): string;
77
89
  /**
78
90
  * @internal
79
91
  * Core conversion logic implemented by each subclass.
@@ -87,5 +99,5 @@ export declare abstract class CborItem {
87
99
  * Leaf nodes emit a single line; container nodes override to emit
88
100
  * open/close lines with recursively collected children.
89
101
  */
90
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
102
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
91
103
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 5 — map (definite- or indefinite-length). */
@@ -11,7 +11,7 @@ export declare class CborMap extends CborItem {
11
11
  encodingWidth?: EncodingWidth;
12
12
  });
13
13
  _toCBOR(options?: ToCBOROptions): Uint8Array;
14
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
14
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
15
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
16
16
  _toJS(options?: ToJSOptions): unknown;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /**
@@ -22,6 +22,6 @@ export declare class CborNint extends CborItem {
22
22
  /** The actual decoded negative value (−1 − argument). */
23
23
  get value(): bigint;
24
24
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
25
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
25
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
26
26
  _toJS(options?: ToJSOptions): unknown;
27
27
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  /**
4
4
  * CBOR Major Type 7 — simple value (0–255).
@@ -17,6 +17,6 @@ export declare class CborSimple extends CborItem {
17
17
  static readonly NULL: CborSimple;
18
18
  static readonly UNDEFINED: CborSimple;
19
19
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
20
- _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
20
+ _toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
21
21
  _toJS(_options?: ToJSOptions): unknown;
22
22
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 6 — tagged data item. */
@@ -10,7 +10,7 @@ export declare class CborTag extends CborItem {
10
10
  encodingWidth?: EncodingWidth;
11
11
  });
12
12
  _toCBOR(options?: ToCBOROptions): Uint8Array;
13
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
14
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
13
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
14
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
15
15
  _toJS(options?: ToJSOptions): unknown;
16
16
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 3 — definite-length UTF-8 text string. */
@@ -10,6 +10,6 @@ export declare class CborTextString extends CborItem {
10
10
  encodingWidth?: EncodingWidth;
11
11
  });
12
12
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
13
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
13
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
14
14
  _toJS(_options?: ToJSOptions): unknown;
15
15
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 0 — unsigned integer (0 … 2^64−1). */
@@ -9,6 +9,6 @@ export declare class CborUint extends CborItem {
9
9
  encodingWidth?: EncodingWidth;
10
10
  });
11
11
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
12
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
12
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
13
13
  _toJS(options?: ToJSOptions): unknown;
14
14
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions } from '../types';
1
+ import { ToCDNOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  import { CborItem } from './CborItem';
4
4
  /** Provisional tag number for the Unresolved Application-Extension stand-in. */
@@ -12,5 +12,5 @@ export declare const CPA999_TAG = 999n;
12
12
  */
13
13
  export declare class CborUnresolvedAppExt extends CborTag {
14
14
  constructor(prefix: string, items: CborItem[]);
15
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
16
16
  }
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../mapEntries-bihZ3yks.cjs`);exports.CborArray=e.p,exports.CborBigNint=e.c,exports.CborBigUint=e.l,exports.CborByteString=e.g,exports.CborEmbeddedCBOR=e.u,exports.CborFloat=e.v,exports.CborIndefiniteByteString=e.h,exports.CborIndefiniteTextString=e.m,exports.CborItem=e.x,exports.CborMap=e.f,exports.CborNint=e.y,exports.CborSimple=e.d,exports.CborTag=e._,exports.CborTextString=e.o,exports.CborUint=e.b;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-BccT62HT.cjs");exports.CborArray=e.p,exports.CborBigNint=e.c,exports.CborBigUint=e.l,exports.CborByteString=e.g,exports.CborEmbeddedCBOR=e.u,exports.CborFloat=e.v,exports.CborIndefiniteByteString=e.h,exports.CborIndefiniteTextString=e.m,exports.CborItem=e.S,exports.CborMap=e.f,exports.CborNint=e.y,exports.CborSimple=e.d,exports.CborTag=e._,exports.CborTextString=e.o,exports.CborUint=e.b;
package/dist/ast/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as e, b as t, c as n, d as r, f as i, g as a, h as o, l as s, m as c, o as l, p as u, u as d, v as f, x as p, y as m } from "../mapEntries-D5MWtXqq.js";
2
- export { u as CborArray, n as CborBigNint, s as CborBigUint, a as CborByteString, d as CborEmbeddedCBOR, f as CborFloat, o as CborIndefiniteByteString, c as CborIndefiniteTextString, p as CborItem, i as CborMap, m as CborNint, r as CborSimple, e as CborTag, l as CborTextString, t as CborUint };
1
+ import { S as e, _ as t, b as n, c as r, d as i, f as a, g as o, h as s, l as c, m as l, o as u, p as d, u as f, v as p, y as m } from "../mapEntries-ZR8QJ0Yj.js";
2
+ export { d as CborArray, r as CborBigNint, c as CborBigUint, o as CborByteString, f as CborEmbeddedCBOR, p as CborFloat, s as CborIndefiniteByteString, l as CborIndefiniteTextString, e as CborItem, a as CborMap, m as CborNint, i as CborSimple, t as CborTag, u as CborTextString, n as CborUint };
package/dist/cbor.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CborItem } from './ast/CborItem';
2
- import { CBOROptions, FromCBOROptions, FromHexDumpOptions, FromEDNOptions, FromJSOptions, ToCBOROptions, ToEDNOptions, ToJSOptions, CBOR_OMIT } from './types';
2
+ import { CBOROptions, FromCBOROptions, FromCDNOptions, FromHexDumpOptions, FromJSOptions, ToCBOROptions, ToCDNOptions, ToJSOptions, CBOR_OMIT } from './types';
3
3
  import { dt_as_Date as _dt_as_Date } from './extensions/dt';
4
4
  import { MapEntries as _MapEntries } from './mapEntries';
5
5
  import { Simple as _Simple } from './simple';
@@ -40,7 +40,7 @@ export declare class CBOR {
40
40
  static readonly Simple: typeof _Simple;
41
41
  /** Array subclass used to preserve CBOR map entries, including duplicates. */
42
42
  static readonly MapEntries: typeof _MapEntries;
43
- /** Extension that maps CBOR-EDN dt/DT values to JavaScript Date objects. */
43
+ /** Extension that maps CDN dt/DT values to JavaScript Date objects. */
44
44
  static readonly dt_as_Date: typeof _dt_as_Date;
45
45
  /**
46
46
  * Create a reusable instance with default options applied to every method call.
@@ -53,30 +53,40 @@ export declare class CBOR {
53
53
  */
54
54
  constructor(defaults?: CBOROptions);
55
55
  fromCBOR(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions): CborItem;
56
- fromEDN(text: string, options?: FromEDNOptions): CborItem;
56
+ fromCDN(text: string, options?: FromCDNOptions): CborItem;
57
+ /** @deprecated Use `fromCDN()` instead. */
58
+ fromEDN(text: string, options?: FromCDNOptions): CborItem;
57
59
  fromJS(value: unknown, options?: FromJSOptions): CborItem;
58
60
  fromHexDump(text: string, options?: FromHexDumpOptions): CborItem;
59
61
  decode(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToJSOptions): unknown;
60
62
  encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array;
61
63
  /**
62
- * @deprecated Use `fromCBOR(input, options).toEDN(options)` instead.
64
+ * @deprecated Use `cborToCdn()` or `fromCBOR(input, options).toCDN(options)` instead.
63
65
  */
64
- cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToEDNOptions): string;
66
+ cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
67
+ cborToCdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
65
68
  /**
66
- * @deprecated Use `fromEDN(text, options).toCBOR(options)` instead.
69
+ * @deprecated Use `cdnToCbor()` or `fromCDN(text, options).toCBOR(options)` instead.
67
70
  */
68
- cborEdnToCbor(text: string, options?: FromEDNOptions & ToCBOROptions): Uint8Array;
71
+ cborEdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
72
+ cdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
69
73
  parse(text: string): unknown;
70
74
  parse(text: string, reviver: (this: unknown, key: unknown, value: unknown) => unknown): unknown;
71
- parse(text: string, options: FromEDNOptions & ToJSOptions): unknown;
75
+ parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;
72
76
  stringify(value: unknown): string;
73
77
  stringify(value: unknown, replacer: ((this: unknown, key: unknown, value: unknown) => unknown) | (string | number)[] | null, space?: string | number): string;
74
- stringify(value: unknown, options: FromJSOptions & ToEDNOptions): string;
75
- format(text: string, options?: FromEDNOptions & ToEDNOptions): string;
78
+ stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;
79
+ format(text: string, options?: FromCDNOptions & ToCDNOptions): string;
76
80
  /** Decode CBOR binary data into an AST node. */
77
81
  static fromCBOR(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions): CborItem;
78
- /** Parse a CBOR-EDN text string into an AST node. */
79
- static fromEDN(text: string, options?: FromEDNOptions): CborItem;
82
+ /** Parse a CDN text string into an AST node. */
83
+ static fromCDN(text: string, options?: FromCDNOptions): CborItem;
84
+ /**
85
+ * Parse a CDN text string into an AST node.
86
+ *
87
+ * @deprecated Use `fromCDN()` instead.
88
+ */
89
+ static fromEDN(text: string, options?: FromCDNOptions): CborItem;
80
90
  /** Convert a JavaScript value into an AST node. */
81
91
  static fromJS(value: unknown, options?: FromJSOptions): CborItem;
82
92
  /**
@@ -96,24 +106,32 @@ export declare class CBOR {
96
106
  /** Encode a JavaScript value directly to CBOR binary data. */
97
107
  static encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array;
98
108
  /**
99
- * Convert CBOR binary data directly to a CBOR-EDN text string.
109
+ * Convert CBOR binary data directly to a CDN text string.
110
+ */
111
+ static cborToCdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
112
+ /**
113
+ * Convert CBOR binary data directly to a CDN text string.
100
114
  *
101
- * @deprecated Use `CBOR.fromCBOR(input, options).toEDN(options)` instead.
115
+ * @deprecated Use `CBOR.cborToCdn()` or `CBOR.fromCBOR(input, options).toCDN(options)` instead.
116
+ */
117
+ static cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
118
+ /**
119
+ * Convert a CDN text string directly to CBOR binary data.
102
120
  */
103
- static cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToEDNOptions): string;
121
+ static cdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
104
122
  /**
105
- * Convert a CBOR-EDN text string directly to CBOR binary data.
123
+ * Convert a CDN text string directly to CBOR binary data.
106
124
  *
107
- * @deprecated Use `CBOR.fromEDN(text, options).toCBOR(options)` instead.
125
+ * @deprecated Use `CBOR.cdnToCbor()` or `CBOR.fromCDN(text, options).toCBOR(options)` instead.
108
126
  */
109
- static cborEdnToCbor(text: string, options?: FromEDNOptions & ToCBOROptions): Uint8Array;
127
+ static cborEdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
110
128
  /**
111
- * Parse a CBOR-EDN text string directly to a JavaScript value.
129
+ * Parse a CDN text string directly to a JavaScript value.
112
130
  *
113
131
  * Accepts either a JSON-compatible `reviver` function as the second argument,
114
132
  * or a plain options object (existing API).
115
133
  *
116
- * When a `reviver` is supplied it is applied bottom-up after the EDN text has
134
+ * When a `reviver` is supplied it is applied bottom-up after the CDN text has
117
135
  * been parsed and converted to a JS value, matching the semantics of
118
136
  * `JSON.parse(text, reviver)`.
119
137
  *
@@ -122,9 +140,9 @@ export declare class CBOR {
122
140
  */
123
141
  static parse(text: string): unknown;
124
142
  static parse(text: string, reviver: (this: unknown, key: unknown, value: unknown) => unknown): unknown;
125
- static parse(text: string, options: FromEDNOptions & ToJSOptions): unknown;
143
+ static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;
126
144
  /**
127
- * Serialize a JavaScript value directly to a CBOR-EDN text string.
145
+ * Serialize a JavaScript value directly to a CDN text string.
128
146
  *
129
147
  * Accepts either JSON-compatible `replacer` + `space` arguments, or a plain
130
148
  * options object (existing API).
@@ -132,12 +150,12 @@ export declare class CBOR {
132
150
  * - `replacer` may be a function (transforms each key/value before encoding)
133
151
  * or an array of strings/numbers (allowlist of object keys to include).
134
152
  * Pass `null` to skip filtering.
135
- * - `space` controls indentation, mapping to `ToEDNOptions.indent`.
153
+ * - `space` controls indentation, mapping to `ToCDNOptions.indent`.
136
154
  * Numbers are clamped to `[0, 10]`; strings are truncated to 10 characters.
137
155
  */
138
156
  static stringify(value: unknown): string;
139
157
  static stringify(value: unknown, replacer: ((this: unknown, key: unknown, value: unknown) => unknown) | (string | number)[] | null, space?: string | number): string;
140
- static stringify(value: unknown, options: FromJSOptions & ToEDNOptions): string;
141
- /** Normalize a CBOR-EDN text string by parsing and re-serializing it. */
142
- static format(text: string, options?: FromEDNOptions & ToEDNOptions): string;
158
+ static stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;
159
+ /** Normalize a CDN text string by parsing and re-serializing it. */
160
+ static format(text: string, options?: FromCDNOptions & ToCDNOptions): string;
143
161
  }
@@ -0,0 +1,7 @@
1
+ import { CborItem } from '../ast/CborItem';
2
+ import { FromCDNOptions } from '../types';
3
+ /**
4
+ * Parse a CDN text string into a CborItem AST node.
5
+ * Throws SyntaxError on invalid input.
6
+ */
7
+ export declare function parseCDN(text: string, options?: FromCDNOptions): CborItem;
@@ -1,6 +1,6 @@
1
- import { CborComments, ToEDNOptions } from '../types';
1
+ import { CborComment, CborComments, ToCDNOptions } from '../types';
2
2
  /** Resolve indent option to a string, or null for single-line output. */
3
- export declare function resolveIndent(options: ToEDNOptions | undefined): string | null;
3
+ export declare function resolveIndent(options: ToCDNOptions | undefined): string | null;
4
4
  /** Build the indent prefix for a given depth. */
5
5
  export declare function indentOf(indentStr: string, depth: number): string;
6
6
  export interface Commented {
@@ -8,9 +8,22 @@ export interface Commented {
8
8
  }
9
9
  export declare function hasPreservedComments(item: Commented): boolean;
10
10
  export declare function hasContainerLayoutComments(item: Commented): boolean;
11
- export declare function formatLeadingComments(item: Commented, indent: string): string[];
12
- export declare function formatTrailingComments(item: Commented): string;
13
- export declare function formatDanglingComments(item: Commented, indent: string): string[];
11
+ /**
12
+ * Convert a single comment's text to the requested marker style.
13
+ *
14
+ * Conversion table:
15
+ * c-style : `#` → `//`, `/ … /` → `/* … *\/`
16
+ * cdn-style: `//` → `#`, `/* … *\/` → `/ … /`
17
+ *
18
+ * Special case for cdn-style: when the inner content of `/* … *\/` starts
19
+ * with `*` or `/` the result would look like `/*…` or `//…` — a different
20
+ * comment form. A single space is inserted after the opening `/` to prevent
21
+ * this (e.g. `/**…*\/` → `/ *…/`).
22
+ */
23
+ export declare function convertCommentText(comment: CborComment, style: 'c-style' | 'cdn-style' | undefined): string;
24
+ export declare function formatLeadingComments(item: Commented, indent: string, style?: 'c-style' | 'cdn-style' | undefined): string[];
25
+ export declare function formatTrailingComments(item: Commented, style?: 'c-style' | 'cdn-style' | undefined): string;
26
+ export declare function formatDanglingComments(item: Commented, indent: string, style?: 'c-style' | 'cdn-style' | undefined): string[];
14
27
  /**
15
28
  * Resolve separator options into concrete strings.
16
29
  *
@@ -23,7 +36,7 @@ export declare function formatDanglingComments(item: Commented, indent: string):
23
36
  * - `trailSep` – appended after the last item (empty string or `,`)
24
37
  * - `colSep` – between map key and value (`': '` or `':'`)
25
38
  */
26
- export declare function resolveSeparators(options: ToEDNOptions | undefined, compact?: boolean): {
39
+ export declare function resolveSeparators(options: ToCDNOptions | undefined, compact?: boolean): {
27
40
  inlineSep: string;
28
41
  multilineSep: string;
29
42
  trailSep: string;
@@ -32,7 +45,7 @@ export declare function resolveSeparators(options: ToEDNOptions | undefined, com
32
45
  export declare function serializeBytes(bytes: Uint8Array, encoding?: 'hex' | 'base64' | 'base64url' | 'base32' | 'base32hex', sqstr?: 'printable-string' | 'string' | 'none'): string;
33
46
  /**
34
47
  * Produce a single-quoted EDN app-string content `'...'` from a string value.
35
- * Exported for use by app-extension `_toEDN` implementations.
48
+ * Exported for use by app-extension `_toCDN` implementations.
36
49
  */
37
50
  export declare function escapeAppString(s: string): string;
38
51
  /**
@@ -0,0 +1,7 @@
1
+ import { CborItem } from '../ast/CborItem';
2
+ import { ToCDNOptions } from '../types';
3
+ /**
4
+ * Serialize a CborItem AST node to CDN text.
5
+ * Equivalent to calling value.toCDN(options) directly.
6
+ */
7
+ export declare function toCDN(value: CborItem, options?: ToCDNOptions): string;
@@ -0,0 +1,22 @@
1
+ import { CborExtension } from '../../extensions/types';
2
+ export declare function hexToBytes(hex: string): Uint8Array;
3
+ /** Decode an h]-prefixed input: hex bytes → UTF-8 string (may contain control chars). */
4
+ export declare function decodeInput(raw: string): string;
5
+ /**
6
+ * Minimal RFC 4180 CSV parser.
7
+ * Returns rows as [op, input, output] triples; comment rows (op starts with #)
8
+ * and the header row are excluded.
9
+ */
10
+ export declare function parseCSV(text: string): [string, string, string][];
11
+ /**
12
+ * Register Vitest tests for one CSV file.
13
+ *
14
+ * @param text - Raw CSV content (already read from disk).
15
+ * @param knownSkip - Map of test label → reason; matching tests are skipped.
16
+ * @param strictNegative - When true (default), a `-` test whose output field
17
+ * cannot be parsed fails rather than passes silently.
18
+ * Set to false only when the corpus is known to include
19
+ * intentionally unparseable output values (corpus-conflict
20
+ * cases should be listed in knownSkip instead).
21
+ */
22
+ export declare function registerTests(text: string, knownSkip?: Map<string, string>, strictNegative?: boolean, extensions?: CborExtension[]): void;