@cbortech/cbor 0.23.0 → 0.23.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 (57) hide show
  1. package/README.ja.md +6 -3
  2. package/README.md +7 -4
  3. package/dist/ast/CborArray.d.ts +17 -0
  4. package/dist/ast/CborBignum.d.ts +36 -0
  5. package/dist/ast/CborByteString.d.ts +20 -0
  6. package/dist/ast/CborEllipsis.d.ts +11 -0
  7. package/dist/ast/CborEmbeddedCBOR.d.ts +22 -0
  8. package/dist/ast/CborFloat.d.ts +27 -0
  9. package/dist/ast/CborIndefiniteByteString.d.ts +13 -0
  10. package/dist/ast/CborIndefiniteTextString.d.ts +13 -0
  11. package/dist/ast/CborItem.d.ts +91 -0
  12. package/dist/ast/CborMap.d.ts +17 -0
  13. package/dist/ast/CborNint.d.ts +27 -0
  14. package/dist/ast/CborSimple.d.ts +22 -0
  15. package/dist/ast/CborTag.d.ts +16 -0
  16. package/dist/ast/CborTextString.d.ts +15 -0
  17. package/dist/ast/CborUint.d.ts +14 -0
  18. package/dist/ast/CborUnresolvedAppExt.d.ts +16 -0
  19. package/dist/ast/index.cjs +1 -0
  20. package/dist/ast/index.d.ts +15 -0
  21. package/dist/ast/index.js +2 -0
  22. package/dist/cbor/constants.d.ts +14 -0
  23. package/dist/cbor/decoder.d.ts +11 -0
  24. package/dist/cbor/encode.d.ts +35 -0
  25. package/dist/cbor/encoder.d.ts +7 -0
  26. package/dist/cbor.d.ts +129 -0
  27. package/dist/edn/parser.d.ts +7 -0
  28. package/dist/edn/serialize-utils.d.ts +48 -0
  29. package/dist/edn/serializer.d.ts +7 -0
  30. package/dist/edn/tokenizer.d.ts +176 -0
  31. package/dist/extensions/bignum.d.ts +3 -0
  32. package/dist/extensions/builtins.d.ts +2 -0
  33. package/dist/extensions/cbordata.d.ts +4 -0
  34. package/dist/extensions/cri.d.ts +32 -0
  35. package/dist/extensions/dt.d.ts +109 -0
  36. package/dist/extensions/hash.d.ts +17 -0
  37. package/dist/extensions/ip.d.ts +41 -0
  38. package/dist/extensions/types.d.ts +70 -0
  39. package/dist/index.cjs +2 -31
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +8 -695
  42. package/dist/index.js +30 -3913
  43. package/dist/index.js.map +1 -1
  44. package/dist/js/fromJS.d.ts +25 -0
  45. package/dist/js/toJS.d.ts +6 -0
  46. package/dist/mapEntries-C73nWM8o.cjs +31 -0
  47. package/dist/mapEntries-C73nWM8o.cjs.map +1 -0
  48. package/dist/mapEntries-CSjvgq1X.js +3887 -0
  49. package/dist/mapEntries-CSjvgq1X.js.map +1 -0
  50. package/dist/mapEntries.d.ts +3 -0
  51. package/dist/simple.d.ts +25 -0
  52. package/dist/tag.d.ts +45 -0
  53. package/dist/types.d.ts +352 -0
  54. package/dist/utils/float16.d.ts +38 -0
  55. package/dist/utils/hexfloat.d.ts +27 -0
  56. package/dist/utils/ip.d.ts +9 -0
  57. package/package.json +12 -1
package/README.ja.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [CBOR](#準拠している仕様)、[CBOR-EDN](#準拠している仕様)、JavaScript 値を相互変換するための TypeScript ライブラリです。
4
4
 
5
- このパッケージは、現時点では `CBOR` ファサードを中心にした小さな公開 API だけを提供します。
6
- 低レベルのパーサー、エンコーダー、AST クラスは、まだドキュメント上の公開 API には含めていません。
5
+ このパッケージは `CBOR` ファサードに加えて、extension の実装に必要な CBOR AST ノードクラス用の entrypoint を公開します。
6
+ 低レベルのパーサー、エンコーダー内部は、ドキュメント上の公開 API には含めていません。
7
7
 
8
8
  ## インストール
9
9
 
@@ -175,12 +175,15 @@ console.log(text);
175
175
  ## AST を扱う
176
176
 
177
177
  `CBOR.fromCBOR()`、`CBOR.fromEDN()`、`CBOR.fromJS()` は CBOR item を返します。
178
- 具体的なノードクラスはまだ公開 API としてドキュメント化していませんが、すべての item は次のメソッドを持ちます。
178
+ `CborTextString`、`CborByteString`、`CborArray`、`CborTag` などの具体的なノードクラスは、
179
+ extension 向けに `@cbortech/cbor/ast` から export されています。すべての item は次のメソッドを持ちます。
179
180
 
180
181
  ```ts
181
182
  import { CBOR } from '@cbortech/cbor';
183
+ import { CborItem } from '@cbortech/cbor/ast';
182
184
 
183
185
  const item = CBOR.fromEDN('{ "x": 1 }');
186
+ item satisfies CborItem;
184
187
 
185
188
  const bytes = item.toCBOR();
186
189
  const text = item.toEDN();
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  TypeScript library for converting between [CBOR](#specifications),
4
4
  [CBOR-EDN](#specifications), and JavaScript values.
5
5
 
6
- This package currently exposes a small public API centered on the `CBOR` facade.
7
- Lower-level parser, encoder, and AST classes are intentionally not part of the
8
- documented public API yet.
6
+ This package exposes the `CBOR` facade plus a separate AST entrypoint for the
7
+ CBOR node classes needed by extensions. Lower-level parser and encoder internals
8
+ are not part of the documented public API.
9
9
 
10
10
  ## Install
11
11
 
@@ -177,13 +177,16 @@ console.log(text);
177
177
  ## Working With The AST
178
178
 
179
179
  `CBOR.fromCBOR()`, `CBOR.fromEDN()`, and `CBOR.fromJS()` return a CBOR item.
180
- The concrete node classes are not documented as public API yet, but every item
180
+ Concrete node classes such as `CborTextString`, `CborByteString`, `CborArray`,
181
+ and `CborTag` are exported from `@cbortech/cbor/ast` for extensions. Every item
181
182
  supports these methods:
182
183
 
183
184
  ```ts
184
185
  import { CBOR } from '@cbortech/cbor';
186
+ import { CborItem } from '@cbortech/cbor/ast';
185
187
 
186
188
  const item = CBOR.fromEDN('{ "x": 1 }');
189
+ item satisfies CborItem;
187
190
 
188
191
  const bytes = item.toCBOR();
189
192
  const text = item.toEDN();
@@ -0,0 +1,17 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 4 — array (definite- or indefinite-length). */
5
+ export declare class CborArray extends CborItem {
6
+ readonly items: CborItem[];
7
+ readonly indefiniteLength: boolean;
8
+ readonly encodingWidth: EncodingWidth | undefined;
9
+ constructor(items: CborItem[], options?: {
10
+ indefiniteLength?: boolean;
11
+ encodingWidth?: EncodingWidth;
12
+ });
13
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
14
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
16
+ _toJS(options?: ToJSOptions): unknown;
17
+ }
@@ -0,0 +1,36 @@
1
+ import { ToEDNOptions, ToJSOptions } from '../types';
2
+ import { CborTag } from './CborTag';
3
+ export declare const BIGNUM_UINT_TAG = 2n;
4
+ export declare const BIGNUM_NINT_TAG = 3n;
5
+ /**
6
+ * Encode a non-negative bigint as a minimal big-endian byte string.
7
+ * Zero is encoded as the empty byte string per RFC 8949 §3.4.3.
8
+ */
9
+ export declare function bigintToBytes(n: bigint): Uint8Array;
10
+ /**
11
+ * Decode a big-endian byte string to a non-negative bigint.
12
+ * Empty bytes → 0n.
13
+ */
14
+ export declare function bytesToBigint(bytes: Uint8Array): bigint;
15
+ /**
16
+ * Unsigned bignum — integers ≥ 2^64.
17
+ * Wire format: tag(2, big-endian byte string).
18
+ * toEDN() emits the plain decimal integer.
19
+ */
20
+ export declare class CborBigUint extends CborTag {
21
+ readonly bigValue: bigint;
22
+ constructor(value: bigint);
23
+ _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
24
+ _toJS(_options?: ToJSOptions): bigint;
25
+ }
26
+ /**
27
+ * Negative bignum — integers ≤ -(2^64 + 1).
28
+ * Wire format: tag(3, big-endian byte string of (-1 - value)).
29
+ * toEDN() emits the plain decimal integer.
30
+ */
31
+ export declare class CborBigNint extends CborTag {
32
+ readonly bigValue: bigint;
33
+ constructor(value: bigint);
34
+ _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
35
+ _toJS(_options?: ToJSOptions): bigint;
36
+ }
@@ -0,0 +1,20 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 2 — definite-length byte string. */
5
+ export declare class CborByteString extends CborItem {
6
+ readonly indefiniteLength: false;
7
+ readonly value: Uint8Array;
8
+ /** Preferred EDN encoding for this byte string. */
9
+ readonly ednEncoding: 'hex' | 'base64' | 'base64url' | 'base32' | 'base32hex';
10
+ readonly encodingWidth: EncodingWidth | undefined;
11
+ readonly ednSource: string | undefined;
12
+ constructor(value: Uint8Array, options?: {
13
+ ednEncoding?: 'hex' | 'base64' | 'base64url' | 'base32' | 'base32hex';
14
+ encodingWidth?: EncodingWidth;
15
+ ednSource?: string;
16
+ });
17
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
18
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
19
+ _toJS(_options?: ToJSOptions): unknown;
20
+ }
@@ -0,0 +1,11 @@
1
+ import { ToEDNOptions } from '../types';
2
+ import { CborTag } from './CborTag';
3
+ import { CborItem } from './CborItem';
4
+ export declare const CPA888_TAG = 888n;
5
+ export declare class CborEllipsis extends CborTag {
6
+ /** Subtree elision: 888(null) */
7
+ constructor();
8
+ /** String/bytes elision: 888([items...]) */
9
+ constructor(items: CborItem[]);
10
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
11
+ }
@@ -0,0 +1,22 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ /**
4
+ * CBOR Sequence Literal (§2.5.6) — `<<item, item, ...>>`.
5
+ *
6
+ * Encodes as a definite-length byte string whose value is the concatenation
7
+ * of the CBOR encodings of the contained items.
8
+ *
9
+ * @example
10
+ * // <<1, 2>> → h'0102'
11
+ * new CborEmbeddedCBOR([new CborUint(1n), new CborUint(2n)])
12
+ */
13
+ export declare class CborEmbeddedCBOR extends CborItem {
14
+ readonly items: CborItem[];
15
+ constructor(items: CborItem[]);
16
+ /** The raw concatenated CBOR bytes of all contained items. */
17
+ private _content;
18
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
19
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
20
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
21
+ _toJS(_options?: ToJSOptions): unknown;
22
+ }
@@ -0,0 +1,27 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ export type FloatPrecision = 'half' | 'single' | 'double';
4
+ /**
5
+ * CBOR Major Type 7 — IEEE 754 floating-point number.
6
+ *
7
+ * `precision` records the encoding size from the original CBOR stream so
8
+ * that lossless round-trips are preserved. When constructing from a JS
9
+ * `number`, omit `precision` (`undefined`) and the encoder will choose
10
+ * the smallest encoding that preserves the value exactly.
11
+ */
12
+ export declare class CborFloat extends CborItem {
13
+ readonly value: number;
14
+ /**
15
+ * Encoding size hint.
16
+ * - `'half'` / `'single'` / `'double'`: use exactly this size (set by the
17
+ * decoder to guarantee lossless round-trips).
18
+ * - `undefined`: encoder auto-selects the smallest lossless size.
19
+ */
20
+ readonly precision: FloatPrecision | undefined;
21
+ constructor(value: number, options?: {
22
+ precision?: FloatPrecision;
23
+ });
24
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
25
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
26
+ _toJS(_options?: ToJSOptions): unknown;
27
+ }
@@ -0,0 +1,13 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ import { CborByteString } from './CborByteString';
4
+ /** CBOR Major Type 2 — indefinite-length byte string (chunked). */
5
+ export declare class CborIndefiniteByteString extends CborItem {
6
+ readonly indefiniteLength: true;
7
+ readonly chunks: CborByteString[];
8
+ constructor(chunks: CborByteString[]);
9
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
10
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
12
+ _toJS(_options?: ToJSOptions): unknown;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ import { CborTextString } from './CborTextString';
4
+ /** CBOR Major Type 3 — indefinite-length UTF-8 text string (chunked). */
5
+ export declare class CborIndefiniteTextString extends CborItem {
6
+ readonly indefiniteLength: true;
7
+ readonly chunks: CborTextString[];
8
+ constructor(chunks: CborTextString[]);
9
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
10
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
12
+ _toJS(_options?: ToJSOptions): unknown;
13
+ }
@@ -0,0 +1,91 @@
1
+ import { CBOROptions, ToEDNOptions, ToJSOptions, ToHexDumpOptions, ToCBOROptions, CborComments } from '../types';
2
+ /** @internal One line of an annotated hex dump. */
3
+ export interface AnnotatedLine {
4
+ depth: number;
5
+ hex: string;
6
+ comment: string;
7
+ }
8
+ /**
9
+ * Abstract base class for all CBOR AST nodes.
10
+ *
11
+ * Every node can serialize itself to CBOR binary, CBOR-EDN text, and a
12
+ * plain JavaScript value. Concrete implementations are provided in each
13
+ * subclass (added in later phases).
14
+ */
15
+ export declare abstract class CborItem {
16
+ /**
17
+ * Character offset of the first character of this item in the parsed source.
18
+ * Set by parsers; undefined when the node was constructed directly.
19
+ * For CBOR input this is a byte offset.
20
+ */
21
+ start?: number;
22
+ /**
23
+ * Character offset just past the last character of this item in the parsed source.
24
+ * Set by parsers; undefined when the node was constructed directly.
25
+ * For CBOR input this is a byte offset.
26
+ */
27
+ end?: number;
28
+ /**
29
+ * Comments captured from CBOR-EDN source when `preserveComments` is enabled.
30
+ * They do not affect CBOR bytes or JS conversion.
31
+ */
32
+ comments?: CborComments;
33
+ /**
34
+ * Default options bound by a {@link CBOR} instance factory method.
35
+ * Per-call options always take precedence.
36
+ * @internal
37
+ */
38
+ _defaults?: CBOROptions;
39
+ /** Serialize this node to CBOR binary. */
40
+ toCBOR(options?: ToCBOROptions): Uint8Array;
41
+ /** Serialize this node to a CBOR-EDN text string. */
42
+ toEDN(options?: ToEDNOptions): string;
43
+ /**
44
+ * Convert this CBOR AST node to a plain JavaScript value.
45
+ *
46
+ * If `options.reviver` is supplied it is called with key `''` on the root
47
+ * result after the full tree has been converted (matching the semantics of
48
+ * `JSON.parse`). Container nodes call the reviver on each of their direct
49
+ * children during conversion, so the walk is bottom-up.
50
+ */
51
+ toJS(options?: ToJSOptions): unknown;
52
+ /**
53
+ * Generate an RFC 8949 §3 style annotated hex dump of this value.
54
+ *
55
+ * @example
56
+ * const cbor = CBOR.fromEDN('[_ 1, [2, 3]]');
57
+ * console.log(cbor.toHexDump());
58
+ * // 9F -- Start indefinite-length array
59
+ * // 01 -- 1
60
+ * // 82 -- Array of length 2
61
+ * // 02 -- 2
62
+ * // 03 -- 3
63
+ * // FF -- "break"
64
+ * // FF -- "break"
65
+ */
66
+ toHexDump(options?: ToHexDumpOptions): string;
67
+ /** @internal Subclass CBOR encoding implementation. */
68
+ abstract _toCBOR(options?: ToCBOROptions): Uint8Array;
69
+ /**
70
+ * @internal
71
+ * Depth-aware EDN serialization.
72
+ * Leaf nodes receive `depth` but may ignore it.
73
+ * Container nodes use `depth` for indentation and call
74
+ * `child._toEDN(options, depth + 1)` when recursing.
75
+ */
76
+ abstract _toEDN(options: ToEDNOptions | undefined, depth: number): string;
77
+ /**
78
+ * @internal
79
+ * Core conversion logic implemented by each subclass.
80
+ * Container nodes apply `options.reviver` to their direct children.
81
+ * Do not call this directly — use `toJS()` instead.
82
+ */
83
+ abstract _toJS(options?: ToJSOptions): unknown;
84
+ /**
85
+ * @internal
86
+ * Collect annotated-hex lines for this node.
87
+ * Leaf nodes emit a single line; container nodes override to emit
88
+ * open/close lines with recursively collected children.
89
+ */
90
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
91
+ }
@@ -0,0 +1,17 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 5 — map (definite- or indefinite-length). */
5
+ export declare class CborMap extends CborItem {
6
+ readonly entries: [CborItem, CborItem][];
7
+ readonly indefiniteLength: boolean;
8
+ readonly encodingWidth: EncodingWidth | undefined;
9
+ constructor(entries: [CborItem, CborItem][], options?: {
10
+ indefiniteLength?: boolean;
11
+ encodingWidth?: EncodingWidth;
12
+ });
13
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
14
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
16
+ _toJS(options?: ToJSOptions): unknown;
17
+ }
@@ -0,0 +1,27 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /**
5
+ * CBOR Major Type 1 — negative integer (−2^64 … −1).
6
+ *
7
+ * The constructor accepts the actual negative value (e.g. `-5n`).
8
+ * Internally the CBOR "argument" `n` is stored, where the decoded value
9
+ * equals `−1 − n`. This matches the wire encoding directly.
10
+ *
11
+ * Examples:
12
+ * new CborNint(-1n) → argument = 0n
13
+ * new CborNint(-5n) → argument = 4n
14
+ */
15
+ export declare class CborNint extends CborItem {
16
+ /** CBOR raw argument n, where actual value = −1 − n. */
17
+ readonly argument: bigint;
18
+ readonly encodingWidth: EncodingWidth | undefined;
19
+ constructor(value: number | bigint, options?: {
20
+ encodingWidth?: EncodingWidth;
21
+ });
22
+ /** The actual decoded negative value (−1 − argument). */
23
+ get value(): bigint;
24
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
25
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
26
+ _toJS(options?: ToJSOptions): unknown;
27
+ }
@@ -0,0 +1,22 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ /**
4
+ * CBOR Major Type 7 — simple value (0–255).
5
+ *
6
+ * Well-known values:
7
+ * 20 → false
8
+ * 21 → true
9
+ * 22 → null
10
+ * 23 → undefined
11
+ */
12
+ export declare class CborSimple extends CborItem {
13
+ readonly value: number;
14
+ constructor(value: number);
15
+ static readonly FALSE: CborSimple;
16
+ static readonly TRUE: CborSimple;
17
+ static readonly NULL: CborSimple;
18
+ static readonly UNDEFINED: CborSimple;
19
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
20
+ _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
21
+ _toJS(_options?: ToJSOptions): unknown;
22
+ }
@@ -0,0 +1,16 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem, AnnotatedLine } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 6 — tagged data item. */
5
+ export declare class CborTag extends CborItem {
6
+ readonly tag: bigint;
7
+ readonly content: CborItem;
8
+ readonly encodingWidth: EncodingWidth | undefined;
9
+ constructor(tag: number | bigint, content: CborItem, options?: {
10
+ encodingWidth?: EncodingWidth;
11
+ });
12
+ _toCBOR(options?: ToCBOROptions): Uint8Array;
13
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
14
+ _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
15
+ _toJS(options?: ToJSOptions): unknown;
16
+ }
@@ -0,0 +1,15 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 3 — definite-length UTF-8 text string. */
5
+ export declare class CborTextString extends CborItem {
6
+ readonly indefiniteLength: false;
7
+ readonly value: string;
8
+ readonly encodingWidth: EncodingWidth | undefined;
9
+ constructor(value: string, options?: {
10
+ encodingWidth?: EncodingWidth;
11
+ });
12
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
13
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
14
+ _toJS(_options?: ToJSOptions): unknown;
15
+ }
@@ -0,0 +1,14 @@
1
+ import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
+ import { CborItem } from './CborItem';
3
+ import { EncodingWidth } from '../cbor/encode';
4
+ /** CBOR Major Type 0 — unsigned integer (0 … 2^64−1). */
5
+ export declare class CborUint extends CborItem {
6
+ readonly value: bigint;
7
+ readonly encodingWidth: EncodingWidth | undefined;
8
+ constructor(value: number | bigint, options?: {
9
+ encodingWidth?: EncodingWidth;
10
+ });
11
+ _toCBOR(_options?: ToCBOROptions): Uint8Array;
12
+ _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
13
+ _toJS(options?: ToJSOptions): unknown;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { ToEDNOptions } from '../types';
2
+ import { CborTag } from './CborTag';
3
+ import { CborItem } from './CborItem';
4
+ /** Provisional tag number for the Unresolved Application-Extension stand-in. */
5
+ export declare const CPA999_TAG = 999n;
6
+ /**
7
+ * Stand-in for an unrecognised EDN application-extension literal.
8
+ *
9
+ * Structure:
10
+ * App-string: CPA999([prefix, text])
11
+ * App-sequence: CPA999([prefix, [items...]])
12
+ */
13
+ export declare class CborUnresolvedAppExt extends CborTag {
14
+ constructor(prefix: string, items: CborItem[]);
15
+ _toEDN(options: ToEDNOptions | undefined, depth: number): string;
16
+ }
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../mapEntries-C73nWM8o.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;
@@ -0,0 +1,15 @@
1
+ export { CborItem } from './CborItem';
2
+ export { CborUint } from './CborUint';
3
+ export { CborBigUint, CborBigNint } from './CborBignum';
4
+ export { CborNint } from './CborNint';
5
+ export { CborByteString } from './CborByteString';
6
+ export { CborIndefiniteByteString } from './CborIndefiniteByteString';
7
+ export { CborTextString } from './CborTextString';
8
+ export { CborIndefiniteTextString } from './CborIndefiniteTextString';
9
+ export { CborArray } from './CborArray';
10
+ export { CborEmbeddedCBOR } from './CborEmbeddedCBOR';
11
+ export { CborMap } from './CborMap';
12
+ export { CborTag } from './CborTag';
13
+ export { CborFloat } from './CborFloat';
14
+ export type { FloatPrecision } from './CborFloat';
15
+ export { CborSimple } from './CborSimple';
@@ -0,0 +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-CSjvgq1X.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 };
@@ -0,0 +1,14 @@
1
+ export declare const MT_UINT = 0;
2
+ export declare const MT_NINT = 1;
3
+ export declare const MT_BYTES = 2;
4
+ export declare const MT_TEXT = 3;
5
+ export declare const MT_ARRAY = 4;
6
+ export declare const MT_MAP = 5;
7
+ export declare const MT_TAG = 6;
8
+ export declare const MT_SIMPLE = 7;
9
+ export declare const AI_1BYTE = 24;
10
+ export declare const AI_2BYTE = 25;
11
+ export declare const AI_4BYTE = 26;
12
+ export declare const AI_8BYTE = 27;
13
+ export declare const AI_INDEFINITE = 31;
14
+ export declare const BREAK_CODE = 255;
@@ -0,0 +1,11 @@
1
+ import { FromCBOROptions } from '../types';
2
+ import { CborItem } from '../ast/CborItem';
3
+ /**
4
+ * Decode a CBOR-encoded byte array into a CborItem AST node.
5
+ *
6
+ * Accepts any `ArrayBufferView` (e.g. `Uint8Array`, `DataView`) or
7
+ * `ArrayBufferLike` (e.g. `ArrayBuffer`, `SharedArrayBuffer`).
8
+ *
9
+ * Throws if the input is not well-formed CBOR or contains trailing bytes.
10
+ */
11
+ export declare function decodeCBOR(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions): CborItem;
@@ -0,0 +1,35 @@
1
+ import { FloatPrecision } from '../ast/CborFloat';
2
+ /**
3
+ * EDN encoding indicator, mapping to a specific CBOR AI encoding:
4
+ * 'i' → ai 0–23 (argument in initial byte, value must be 0–23)
5
+ * 0 → AI 24 (1-byte argument, value must be 0–0xFF)
6
+ * 1 → AI 25 (2-byte argument, value must be 0–0xFFFF)
7
+ * 2 → AI 26 (4-byte argument, value must be 0–0xFFFFFFFF)
8
+ * 3 → AI 27 (8-byte argument, value must be 0–0xFFFFFFFFFFFFFFFF)
9
+ */
10
+ export type EncodingWidth = 'i' | 0 | 1 | 2 | 3;
11
+ /**
12
+ * Encode a CBOR initial byte + argument into a Uint8Array.
13
+ *
14
+ * When `encodingWidth` is provided the argument is always written using that
15
+ * many additional bytes (AI = 24 + encodingWidth), even if the value would fit
16
+ * in fewer bytes. Without it the smallest valid encoding is chosen.
17
+ */
18
+ export declare function writeHead(mt: number, value: bigint, encodingWidth?: EncodingWidth): Uint8Array;
19
+ /** Concatenate multiple Uint8Arrays into one. */
20
+ export declare function concat(parts: Uint8Array[]): Uint8Array;
21
+ /**
22
+ * Returns true if `value` can be exactly represented as a float16 without
23
+ * precision loss (including -0, Infinity, -Infinity, NaN identity).
24
+ */
25
+ export declare function canEncodeAsFloat16(value: number): boolean;
26
+ /**
27
+ * Returns true if `value` can be exactly represented as a float32 without
28
+ * precision loss.
29
+ */
30
+ export declare function canEncodeAsFloat32(value: number): boolean;
31
+ /**
32
+ * Choose the smallest float precision that represents `value` exactly.
33
+ * Used by CborFloat.toCBOR() when `precision` is undefined.
34
+ */
35
+ export declare function autoSelectFloatPrecision(value: number): FloatPrecision;
@@ -0,0 +1,7 @@
1
+ import { CborItem } from '../ast/CborItem';
2
+ import { ToCBOROptions } from '../types';
3
+ /**
4
+ * Encode a CborItem AST node to CBOR binary.
5
+ * Equivalent to calling value.toCBOR() directly.
6
+ */
7
+ export declare function encodeCBOR(value: CborItem, options?: ToCBOROptions): Uint8Array;