@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.
- package/README.ja.md +127 -49
- package/README.md +128 -49
- package/dist/ast/CborAppSeqResult.d.ts +20 -0
- package/dist/ast/CborArray.d.ts +3 -3
- package/dist/ast/CborBignum.d.ts +5 -5
- package/dist/ast/CborByteString.d.ts +2 -2
- package/dist/ast/CborEllipsis.d.ts +2 -2
- package/dist/ast/CborEmbeddedCBOR.d.ts +3 -3
- package/dist/ast/CborFloat.d.ts +8 -2
- package/dist/ast/CborIndefiniteByteString.d.ts +3 -3
- package/dist/ast/CborIndefiniteTextString.d.ts +3 -3
- package/dist/ast/CborItem.d.ts +22 -10
- package/dist/ast/CborMap.d.ts +3 -3
- package/dist/ast/CborNint.d.ts +2 -2
- package/dist/ast/CborSimple.d.ts +2 -2
- package/dist/ast/CborTag.d.ts +3 -3
- package/dist/ast/CborTextString.d.ts +2 -2
- package/dist/ast/CborUint.d.ts +2 -2
- package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cbor.d.ts +44 -26
- package/dist/cdn/parser.d.ts +7 -0
- package/dist/{edn → cdn}/serialize-utils.d.ts +20 -7
- package/dist/cdn/serializer.d.ts +7 -0
- package/dist/cdn/test-vectors/runner.d.ts +22 -0
- package/dist/{edn → cdn}/tokenizer.d.ts +28 -25
- package/dist/extensions/b32.d.ts +5 -0
- package/dist/extensions/cri.d.ts +7 -7
- package/dist/extensions/dt.d.ts +10 -19
- package/dist/extensions/float.d.ts +7 -0
- package/dist/extensions/ip.d.ts +8 -8
- package/dist/extensions/same.d.ts +7 -0
- package/dist/extensions/types.d.ts +30 -8
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +244 -77
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-BccT62HT.cjs +36 -0
- package/dist/mapEntries-BccT62HT.cjs.map +1 -0
- package/dist/{mapEntries-D5MWtXqq.js → mapEntries-ZR8QJ0Yj.js} +1157 -853
- package/dist/mapEntries-ZR8QJ0Yj.js.map +1 -0
- package/dist/simple.d.ts +2 -2
- package/dist/tag.d.ts +1 -1
- package/dist/types.d.ts +141 -30
- package/dist/utils/hexfloat.d.ts +2 -2
- package/dist/utils/strip-comments.d.ts +12 -0
- package/package.json +13 -11
- package/dist/edn/parser.d.ts +0 -7
- package/dist/edn/serializer.d.ts +0 -7
- package/dist/mapEntries-D5MWtXqq.js.map +0 -1
- package/dist/mapEntries-bihZ3yks.cjs +0 -31
- 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
|
+
}
|
package/dist/ast/CborArray.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
15
|
-
_toHexDump(depth: number, options?:
|
|
14
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
15
|
+
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
16
16
|
_toJS(options?: ToJSOptions): unknown;
|
|
17
17
|
}
|
package/dist/ast/CborBignum.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
34
|
+
_toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
|
|
35
35
|
_toJS(_options?: ToJSOptions): bigint;
|
|
36
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
18
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
19
19
|
_toJS(_options?: ToJSOptions): unknown;
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
10
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
20
|
-
_toHexDump(depth: number, options?:
|
|
19
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
20
|
+
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
21
21
|
_toJS(_options?: ToJSOptions): unknown;
|
|
22
22
|
}
|
package/dist/ast/CborFloat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
31
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
26
32
|
_toJS(_options?: ToJSOptions): unknown;
|
|
27
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
11
|
-
_toHexDump(depth: number, options?:
|
|
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 {
|
|
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
|
-
|
|
11
|
-
_toHexDump(depth: number, options?:
|
|
10
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
11
|
+
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
12
12
|
_toJS(_options?: ToJSOptions): unknown;
|
|
13
13
|
}
|
package/dist/ast/CborItem.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CBOROptions,
|
|
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,
|
|
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
|
|
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
|
|
42
|
-
|
|
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.
|
|
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
|
|
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.
|
|
86
|
+
* `child._toCDN(options, depth + 1)` when recursing.
|
|
75
87
|
*/
|
|
76
|
-
abstract
|
|
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?:
|
|
102
|
+
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
91
103
|
}
|
package/dist/ast/CborMap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
15
|
-
_toHexDump(depth: number, options?:
|
|
14
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
15
|
+
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
16
16
|
_toJS(options?: ToJSOptions): unknown;
|
|
17
17
|
}
|
package/dist/ast/CborNint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
25
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
26
26
|
_toJS(options?: ToJSOptions): unknown;
|
|
27
27
|
}
|
package/dist/ast/CborSimple.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
20
|
+
_toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
|
|
21
21
|
_toJS(_options?: ToJSOptions): unknown;
|
|
22
22
|
}
|
package/dist/ast/CborTag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
14
|
-
_toHexDump(depth: number, options?:
|
|
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 {
|
|
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
|
-
|
|
13
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
14
14
|
_toJS(_options?: ToJSOptions): unknown;
|
|
15
15
|
}
|
package/dist/ast/CborUint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
12
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
13
13
|
_toJS(options?: ToJSOptions): unknown;
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
15
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
16
16
|
}
|
package/dist/ast/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
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 {
|
|
2
|
-
export {
|
|
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,
|
|
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
|
|
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
|
-
|
|
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).
|
|
64
|
+
* @deprecated Use `cborToCdn()` or `fromCBOR(input, options).toCDN(options)` instead.
|
|
63
65
|
*/
|
|
64
|
-
cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions &
|
|
66
|
+
cborToCborEdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
|
|
67
|
+
cborToCdn(input: ArrayBufferView | ArrayBufferLike, options?: FromCBOROptions & ToCDNOptions): string;
|
|
65
68
|
/**
|
|
66
|
-
* @deprecated Use `
|
|
69
|
+
* @deprecated Use `cdnToCbor()` or `fromCDN(text, options).toCBOR(options)` instead.
|
|
67
70
|
*/
|
|
68
|
-
cborEdnToCbor(text: string, options?:
|
|
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:
|
|
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 &
|
|
75
|
-
format(text: string, options?:
|
|
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
|
|
79
|
-
static
|
|
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
|
|
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).
|
|
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
|
|
121
|
+
static cdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
|
|
104
122
|
/**
|
|
105
|
-
* Convert a
|
|
123
|
+
* Convert a CDN text string directly to CBOR binary data.
|
|
106
124
|
*
|
|
107
|
-
* @deprecated Use `CBOR.
|
|
125
|
+
* @deprecated Use `CBOR.cdnToCbor()` or `CBOR.fromCDN(text, options).toCBOR(options)` instead.
|
|
108
126
|
*/
|
|
109
|
-
static cborEdnToCbor(text: string, options?:
|
|
127
|
+
static cborEdnToCbor(text: string, options?: FromCDNOptions & ToCBOROptions): Uint8Array;
|
|
110
128
|
/**
|
|
111
|
-
* Parse a
|
|
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
|
|
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:
|
|
143
|
+
static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;
|
|
126
144
|
/**
|
|
127
|
-
* Serialize a JavaScript value directly to a
|
|
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 `
|
|
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 &
|
|
141
|
-
/** Normalize a
|
|
142
|
-
static format(text: string, options?:
|
|
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,
|
|
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:
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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:
|
|
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 `
|
|
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;
|