@cbortech/cbor 0.26.1 → 0.26.3
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 +55 -1
- package/README.md +56 -1
- package/dist/ast/CborAppSeqResult.d.ts +1 -0
- package/dist/ast/CborArray.d.ts +1 -0
- package/dist/ast/CborEmbeddedCBOR.d.ts +1 -0
- package/dist/ast/CborIndefiniteByteString.d.ts +1 -1
- package/dist/ast/CborItem.d.ts +8 -0
- package/dist/ast/CborMap.d.ts +1 -0
- package/dist/ast/CborTag.d.ts +1 -0
- package/dist/ast/CborTextString.d.ts +9 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cdn/serialize-utils.d.ts +9 -3
- package/dist/extensions/builtins.d.ts +4 -4
- package/dist/extensions/ellipsis.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{mapEntries-ClxYqDPp.js → mapEntries-BZCOgqIt.js} +838 -703
- package/dist/mapEntries-BZCOgqIt.js.map +1 -0
- package/dist/mapEntries-CV9kf2OS.cjs +15 -0
- package/dist/mapEntries-CV9kf2OS.cjs.map +1 -0
- package/dist/types.d.ts +29 -0
- package/package.json +10 -11
- package/dist/mapEntries-Bys9cXgV.cjs +0 -14
- package/dist/mapEntries-Bys9cXgV.cjs.map +0 -1
- package/dist/mapEntries-ClxYqDPp.js.map +0 -1
package/README.ja.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @cbortech/cbor
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@cbortech/cbor)
|
|
4
|
+

|
|
5
|
+
[](https://www.npmjs.com/package/@cbortech/cbor)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+

|
|
8
|
+
|
|
3
9
|
[CBOR](#準拠している仕様)、[CDN (CBOR-EDN)](#準拠している仕様)、JavaScript 値を相互変換するための TypeScript ライブラリです。
|
|
4
10
|
|
|
5
11
|

|
|
@@ -22,6 +28,9 @@ npm install @cbortech/cbor
|
|
|
22
28
|
npm install -g @cbortech/cbor-cli
|
|
23
29
|
```
|
|
24
30
|
|
|
31
|
+
エディターで利用する場合は、本パッケージを用いて作られた
|
|
32
|
+
[VS Code extension](https://marketplace.visualstudio.com/items?itemName=cbortech.vscode-cdn-extension)もお試しください。
|
|
33
|
+
|
|
25
34
|
## インポート
|
|
26
35
|
|
|
27
36
|
```ts
|
|
@@ -219,6 +228,32 @@ console.log(text);
|
|
|
219
228
|
// }
|
|
220
229
|
```
|
|
221
230
|
|
|
231
|
+
### リーフコンテナを 1 行にまとめる
|
|
232
|
+
|
|
233
|
+
`inlineLeafContainers` は、要素に配列・マップを含まず(タグで包まれて
|
|
234
|
+
いる場合も含みます)、かつすべての要素が改行なしでシリアライズされる
|
|
235
|
+
コンテナを 1 行のまま出力します。ネストした
|
|
236
|
+
リーフコンテナはそれぞれ個別に 1 行へまとまるため、行列のようなデータが
|
|
237
|
+
読みやすくなります。`indent` 指定時に適用されます。
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { CBOR } from '@cbortech/cbor';
|
|
241
|
+
|
|
242
|
+
const text = CBOR.format('{"m": [[1,2],[3,4]], "s": (_ "a", "b")}', {
|
|
243
|
+
indent: 2,
|
|
244
|
+
inlineLeafContainers: true,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
console.log(text);
|
|
248
|
+
// {
|
|
249
|
+
// "m": [
|
|
250
|
+
// [1, 2],
|
|
251
|
+
// [3, 4]
|
|
252
|
+
// ],
|
|
253
|
+
// "s": (_ "a", "b")
|
|
254
|
+
// }
|
|
255
|
+
```
|
|
256
|
+
|
|
222
257
|
### テキスト文字列を分割して整形する
|
|
223
258
|
|
|
224
259
|
`splitNewline` を使うと、長いテキスト文字列を改行文字の位置で CDN の文字列連結として
|
|
@@ -262,6 +297,25 @@ console.log(text);
|
|
|
262
297
|
// }
|
|
263
298
|
```
|
|
264
299
|
|
|
300
|
+
### raw テキスト文字列を保持する
|
|
301
|
+
|
|
302
|
+
デフォルトでは、`CBOR.format()` はバッククォートによる raw 文字列リテラル
|
|
303
|
+
(`` `...` ``、` ``...`` ` など)をダブルクォート形式に変換します。
|
|
304
|
+
`preserveRawString` を指定すると、元のソース表記のまま再出力します。保持された
|
|
305
|
+
raw 文字列はそのまま(verbatim)出力され、再エスケープ・再インデント・
|
|
306
|
+
`splitCdn` / `splitNewline` による分割の対象になりません。
|
|
307
|
+
(`` h`...` `` のような raw バイト文字列形式は `preserveByteString` の対象です。)
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { CBOR } from '@cbortech/cbor';
|
|
311
|
+
|
|
312
|
+
CBOR.format('`\\d+`');
|
|
313
|
+
// '"\\\\d+"'
|
|
314
|
+
|
|
315
|
+
CBOR.format('`\\d+`', { preserveRawString: true });
|
|
316
|
+
// '`\\d+`'
|
|
317
|
+
```
|
|
318
|
+
|
|
265
319
|
### `+` による文字列連結を保持する
|
|
266
320
|
|
|
267
321
|
注意: `+` による文字列連結構文は draft-26 で削除されました。この節は legacy
|
|
@@ -476,7 +530,7 @@ import { CBOR } from '@cbortech/cbor';
|
|
|
476
530
|
|
|
477
531
|
const v = CBOR.fromCDN("ilbs<<'Hello ', 'world'>>");
|
|
478
532
|
console.log(v.toCDN({ appStrings: false }));
|
|
479
|
-
// (_ 'Hello ',
|
|
533
|
+
// (_ 'Hello ','world')
|
|
480
534
|
```
|
|
481
535
|
|
|
482
536
|
> [!NOTE]
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @cbortech/cbor
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@cbortech/cbor)
|
|
4
|
+

|
|
5
|
+
[](https://www.npmjs.com/package/@cbortech/cbor)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+

|
|
8
|
+
|
|
3
9
|
TypeScript library for converting between [CBOR](#specifications),
|
|
4
10
|
[CDN (CBOR-EDN)](#specifications), and JavaScript values.
|
|
5
11
|
|
|
@@ -24,6 +30,10 @@ available as [@cbortech/cbor-cli](https://www.npmjs.com/package/@cbortech/cbor-c
|
|
|
24
30
|
npm install -g @cbortech/cbor-cli
|
|
25
31
|
```
|
|
26
32
|
|
|
33
|
+
For editor integration, try the companion
|
|
34
|
+
[VS Code extension](https://marketplace.visualstudio.com/items?itemName=cbortech.vscode-cdn-extension),
|
|
35
|
+
which is built with this package.
|
|
36
|
+
|
|
27
37
|
## Import
|
|
28
38
|
|
|
29
39
|
```ts
|
|
@@ -221,6 +231,32 @@ console.log(text);
|
|
|
221
231
|
// }
|
|
222
232
|
```
|
|
223
233
|
|
|
234
|
+
### Keep leaf containers on one line
|
|
235
|
+
|
|
236
|
+
`inlineLeafContainers` keeps a container on a single line when none of its
|
|
237
|
+
entries contains an array or map (even wrapped in a tag) and every entry
|
|
238
|
+
serializes without a line break. Nested leaf containers still collapse
|
|
239
|
+
individually, so matrix-like data stays readable. It is applied when
|
|
240
|
+
`indent` is specified.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { CBOR } from '@cbortech/cbor';
|
|
244
|
+
|
|
245
|
+
const text = CBOR.format('{"m": [[1,2],[3,4]], "s": (_ "a", "b")}', {
|
|
246
|
+
indent: 2,
|
|
247
|
+
inlineLeafContainers: true,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
console.log(text);
|
|
251
|
+
// {
|
|
252
|
+
// "m": [
|
|
253
|
+
// [1, 2],
|
|
254
|
+
// [3, 4]
|
|
255
|
+
// ],
|
|
256
|
+
// "s": (_ "a", "b")
|
|
257
|
+
// }
|
|
258
|
+
```
|
|
259
|
+
|
|
224
260
|
### Split text strings while formatting
|
|
225
261
|
|
|
226
262
|
`splitNewline` splits long text strings at newline characters using CDN
|
|
@@ -265,6 +301,25 @@ console.log(text);
|
|
|
265
301
|
// }
|
|
266
302
|
```
|
|
267
303
|
|
|
304
|
+
### Preserve raw text strings
|
|
305
|
+
|
|
306
|
+
By default, `CBOR.format()` converts raw backtick string literals
|
|
307
|
+
(`` `...` ``, ` ``...`` `, …) to double-quoted form. `preserveRawString`
|
|
308
|
+
re-emits them using their original source text instead. Preserved raw
|
|
309
|
+
strings are emitted verbatim: they are never re-escaped, re-indented, or
|
|
310
|
+
split by `splitCdn` / `splitNewline`. (Raw byte string forms such as
|
|
311
|
+
`` h`...` `` are covered by `preserveByteString`.)
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
import { CBOR } from '@cbortech/cbor';
|
|
315
|
+
|
|
316
|
+
CBOR.format('`\\d+`');
|
|
317
|
+
// '"\\\\d+"'
|
|
318
|
+
|
|
319
|
+
CBOR.format('`\\d+`', { preserveRawString: true });
|
|
320
|
+
// '`\\d+`'
|
|
321
|
+
```
|
|
322
|
+
|
|
268
323
|
### Preserve `+` string concatenation
|
|
269
324
|
|
|
270
325
|
Note: `+` string concatenation was removed in draft-26. This section is for
|
|
@@ -481,7 +536,7 @@ import { CBOR } from '@cbortech/cbor';
|
|
|
481
536
|
|
|
482
537
|
const v = CBOR.fromCDN("ilbs<<'Hello ', 'world'>>");
|
|
483
538
|
console.log(v.toCDN({ appStrings: false }));
|
|
484
|
-
// (_ 'Hello ',
|
|
539
|
+
// (_ 'Hello ','world')
|
|
485
540
|
```
|
|
486
541
|
|
|
487
542
|
> [!NOTE]
|
|
@@ -17,6 +17,7 @@ export declare class CborAppSeqResult extends CborItem {
|
|
|
17
17
|
readonly inner: CborItem;
|
|
18
18
|
readonly ednSource: string;
|
|
19
19
|
constructor(inner: CborItem, ednSource: string);
|
|
20
|
+
get _containsCdnContainer(): boolean;
|
|
20
21
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
21
22
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
22
23
|
_toJS(options?: ToJSOptions): unknown;
|
package/dist/ast/CborArray.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class CborArray extends CborItem {
|
|
|
10
10
|
indefiniteLength?: boolean;
|
|
11
11
|
encodingWidth?: EncodingWidth;
|
|
12
12
|
});
|
|
13
|
+
get _containsCdnContainer(): boolean;
|
|
13
14
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
14
15
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
15
16
|
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
@@ -17,6 +17,7 @@ export declare class CborEmbeddedCBOR extends CborItem {
|
|
|
17
17
|
constructor(items: CborItem[], options?: {
|
|
18
18
|
encodingWidth?: EncodingWidth;
|
|
19
19
|
});
|
|
20
|
+
get _containsCdnContainer(): boolean;
|
|
20
21
|
/** The raw concatenated CBOR bytes of all contained items. */
|
|
21
22
|
private _content;
|
|
22
23
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
@@ -8,7 +8,7 @@ export declare class CborIndefiniteByteString extends CborItem {
|
|
|
8
8
|
readonly chunks: CborByteString[];
|
|
9
9
|
constructor(chunks: CborByteString[]);
|
|
10
10
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
11
|
-
_toCDN(options: ToCDNOptions | undefined,
|
|
11
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
12
12
|
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
13
13
|
_toJS(_options?: ToJSOptions): unknown;
|
|
14
14
|
}
|
package/dist/ast/CborItem.d.ts
CHANGED
|
@@ -43,6 +43,14 @@ export declare abstract class CborItem {
|
|
|
43
43
|
* @internal
|
|
44
44
|
*/
|
|
45
45
|
_defaults?: CBOROptions;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
* True when this node is, or contains through wrapper nodes (tags,
|
|
49
|
+
* embedded CBOR, app-sequence results), an array or map.
|
|
50
|
+
* `inlineLeafContainers` never inlines a container whose entries contain
|
|
51
|
+
* another container, even one that renders on a single line.
|
|
52
|
+
*/
|
|
53
|
+
get _containsCdnContainer(): boolean;
|
|
46
54
|
/** Serialize this node to CBOR binary. */
|
|
47
55
|
toCBOR(options?: ToCBOROptions): Uint8Array;
|
|
48
56
|
/** Serialize this node to a CDN text string. */
|
package/dist/ast/CborMap.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class CborMap extends CborItem {
|
|
|
10
10
|
indefiniteLength?: boolean;
|
|
11
11
|
encodingWidth?: EncodingWidth;
|
|
12
12
|
});
|
|
13
|
+
get _containsCdnContainer(): boolean;
|
|
13
14
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
14
15
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
15
16
|
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
package/dist/ast/CborTag.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class CborTag extends CborItem {
|
|
|
9
9
|
constructor(tag: number | bigint, content: CborItem, options?: {
|
|
10
10
|
encodingWidth?: EncodingWidth;
|
|
11
11
|
});
|
|
12
|
+
get _containsCdnContainer(): boolean;
|
|
12
13
|
_encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
|
|
13
14
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
14
15
|
_toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
|
|
@@ -8,9 +8,18 @@ export declare class CborTextString extends CborItem {
|
|
|
8
8
|
encodingWidth: EncodingWidth | undefined;
|
|
9
9
|
/** Part boundaries of the original `+` concatenation chain, if any. */
|
|
10
10
|
readonly ednParts: readonly string[] | undefined;
|
|
11
|
+
/** Original raw-string source text, when parsed from a single backtick literal. */
|
|
12
|
+
readonly ednSource: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Original source text per `ednParts` entry, aligned by index; `undefined`
|
|
15
|
+
* for parts that were not raw backtick literals.
|
|
16
|
+
*/
|
|
17
|
+
readonly ednPartSources: readonly (string | undefined)[] | undefined;
|
|
11
18
|
constructor(value: string, options?: {
|
|
12
19
|
encodingWidth?: EncodingWidth;
|
|
13
20
|
ednParts?: readonly string[];
|
|
21
|
+
ednSource?: string;
|
|
22
|
+
ednPartSources?: readonly (string | undefined)[];
|
|
14
23
|
});
|
|
15
24
|
_encodeTo(writer: CborWriter, _options?: ToCBOROptions): void;
|
|
16
25
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
package/dist/ast/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-CV9kf2OS.cjs");exports.CborArray=e.C,exports.CborBigNint=e.v,exports.CborBigUint=e.y,exports.CborByteString=e.E,exports.CborEmbeddedCBOR=e.b,exports.CborFloat=e.O,exports.CborIndefiniteByteString=e.T,exports.CborIndefiniteTextString=e.w,exports.CborItem=e.j,exports.CborMap=e.S,exports.CborNint=e.k,exports.CborSimple=e.x,exports.CborTag=e.D,exports.CborTextString=e.g,exports.CborUint=e.A;
|
package/dist/ast/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, b as s, g as c, j as l, k as u, v as d, w as f, x as p, y as m } from "../mapEntries-
|
|
1
|
+
import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, b as s, g as c, j as l, k as u, v as d, w as f, x as p, y as m } from "../mapEntries-BZCOgqIt.js";
|
|
2
2
|
export { t as CborArray, d as CborBigNint, m as CborBigUint, r as CborByteString, s as CborEmbeddedCBOR, i as CborFloat, o as CborIndefiniteByteString, f as CborIndefiniteTextString, l as CborItem, a as CborMap, u as CborNint, p as CborSimple, n as CborTag, c as CborTextString, e as CborUint };
|
|
@@ -51,7 +51,8 @@ export declare function resolveSeparators(options: ToCDNOptions | undefined, com
|
|
|
51
51
|
colSep: string;
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* Shared CDN serialization for bracketed containers (CborArray / CborMap
|
|
54
|
+
* Shared CDN serialization for bracketed containers (CborArray / CborMap /
|
|
55
|
+
* indefinite-length string chunks `(_ ...)`):
|
|
55
56
|
* encoding-indicator / `_` prefix resolution, single-line vs multi-line
|
|
56
57
|
* selection (comments force multi-line), separators, and per-entry
|
|
57
58
|
* leading/trailing plus container dangling comments.
|
|
@@ -66,14 +67,19 @@ export declare function serializeContainer(p: {
|
|
|
66
67
|
node: Commented;
|
|
67
68
|
options: ToCDNOptions | undefined;
|
|
68
69
|
depth: number;
|
|
69
|
-
openChar: '[' | '{';
|
|
70
|
-
closeChar: ']' | '}';
|
|
70
|
+
openChar: '[' | '{' | '(';
|
|
71
|
+
closeChar: ']' | '}' | ')';
|
|
71
72
|
count: number;
|
|
72
73
|
indefiniteLength: boolean;
|
|
73
74
|
encodingWidth: EncodingWidth | undefined;
|
|
74
75
|
hasEntryComments: () => boolean;
|
|
75
76
|
/** Render entry `i` at child depth (`item` or `key: value`). */
|
|
76
77
|
renderEntry: (i: number, colSep: string) => string;
|
|
78
|
+
/**
|
|
79
|
+
* Whether entry `i` contains no nested array/map, so it may stay on the
|
|
80
|
+
* container's line under `inlineLeafContainers`. Omitted = always a leaf.
|
|
81
|
+
*/
|
|
82
|
+
entryIsLeaf?: (i: number) => boolean;
|
|
77
83
|
/** Node whose leading comments are emitted above entry `i` (item / map key). */
|
|
78
84
|
entryLeadingNode: (i: number) => Commented;
|
|
79
85
|
/** Pre-formatted trailing comment text for entry `i` (starts with ' ', or ''). */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CborExtension } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Core
|
|
4
|
-
*
|
|
5
|
-
* application-oriented extension, so they are always active and are
|
|
6
|
-
* affected by the `builtinExtensions` option.
|
|
3
|
+
* Core data-model extensions (bignum tags 2/3, embedded-CBOR tag 24, and the
|
|
4
|
+
* CPA888 ellipsis tag). These implement base CBOR/EDN representation rather
|
|
5
|
+
* than an application-oriented extension, so they are always active and are
|
|
6
|
+
* not affected by the `builtinExtensions` option.
|
|
7
7
|
*/
|
|
8
8
|
export declare const CORE_EXTENSIONS: readonly CborExtension[];
|
|
9
9
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./mapEntries-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./mapEntries-CV9kf2OS.cjs");var n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,r=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function i(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===61;)t--;return e.slice(0,t)}function a(e,t,n){let r=i(e).toUpperCase(),a=r.length%8;if(a===1||a===3||a===6)throw SyntaxError(`invalid base32 length: ${r.length} characters`);let o=new Uint8Array(128).fill(255);for(let e=0;e<t.length;e++)o[t.charCodeAt(e)]=e;let s=new Uint8Array(Math.floor(r.length*5/8)),c=0,l=0,u=0;for(let e of r){let t=e.charCodeAt(0),n=t<128?o[t]:255;if(n===255)throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);c=c<<5|n,l+=5,l>=8&&(l-=8,s[u++]=c>>l&255)}if(l>0&&c&(1<<l)-1){let e=`non-zero trailing bits in base32 input`;if(n)n(e);else throw SyntaxError(e)}return s}var o={appStringPrefixes:[`b32`],parseAppString(e,r,i){return new t.E(a(t.o(r),n,i),{ednEncoding:`base32`})}},s={appStringPrefixes:[`h32`],parseAppString(e,n,i){return new t.E(a(t.o(n),r,i),{ednEncoding:`base32hex`})}};function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var l={appStringPrefixes:[`same`],preserveAppSeqSource:!0,parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`same<<...>> requires at least one item`);let r=t[0],i=r.toCBOR();for(let e=1;e<t.length;e++)if(!c(i,t[e].toCBOR())){let t=`same<<...>>: item ${e} produces different CBOR bytes than item 0`;if(n)n(t);else throw SyntaxError(t)}return r}},u=class n{static OMIT=t.N;static TAG=t.P;static Tag=t.I;static Simple=t.M;static MapEntries=t.t;static dt_as_Date=t.h;#e;constructor(e){this.#e=e??{}}#t(e){return{...this.#e,...e??{}}}fromCBOR(e,t){let r=n.fromCBOR(e,this.#t(t));return r._defaults=this.#e,r}fromCDN(e,t){let r=n.fromCDN(e,this.#t(t));return r._defaults=this.#e,r}fromEDN(e,t){return this.fromCDN(e,t)}fromJS(e,t){let r=n.fromJS(e,this.#t(t));return r._defaults=this.#e,r}fromHexDump(e,t){let r=n.fromHexDump(e,this.#t(t));return r._defaults=this.#e,r}*fromCBORSeq(e,t){for(let r of n.fromCBORSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromCDNSeq(e,t){for(let r of n.fromCDNSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromHexDumpSeq(e,t){for(let r of n.fromHexDumpSeq(e,this.#t(t)))r._defaults=this.#e,yield r}decode(e,t){return n.decode(e,this.#t(t))}*decodeSeq(e,t){yield*n.decodeSeq(e,this.#t(t))}*parseSeq(e,t){yield*n.parseSeq(e,this.#t(t))}encode(e,t){return n.encode(e,this.#t(t))}compile(e,t){return n.compile(e,this.#t(t))}decompile(e,t){return n.decompile(e,this.#t(t))}toHex(e,t){return n.toHex(e,this.#t(t))}fromHex(e,t){return n.fromHex(e,this.#t(t))}cborToCborEdn(e,t){return this.cborToCdn(e,t)}cborToCdn(e,t){let r=this.#t(t),i=n.fromCBOR(e,r);return i._defaults=this.#e,i.toCDN(r)}cborEdnToCbor(e,t){return this.cdnToCbor(e,t)}cdnToCbor(e,t){let r=this.#t(t);return n.fromCDN(e,r).toCBOR(r)}parse(e,t){if(typeof t==`function`){let r=this.#t({reviver:t});return n.fromCDN(e,r).toJS(r)}let r=this.#t(t);return n.fromCDN(e,r).toJS(r)}stringify(e,t,r){if(typeof t==`function`||Array.isArray(t)||t===null||t===void 0&&r!==void 0){let i={...this.#e};return t===null?i.replacer=void 0:(typeof t==`function`||Array.isArray(t))&&(i.replacer=t),r!==void 0&&(i.indent=_(r)),n.stringify(e,i)}return n.stringify(e,this.#t(t??void 0))}format(e,t){return n.format(e,this.#t(t))}static fromCBOR(e,n){return t.d(e,n)}static fromCDN(e,n){return t._(e,n)}static fromEDN(e,t){return n.fromCDN(e,t)}static*fromHexDumpSeq(e,t){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);yield*n.fromCBORSeq(new Uint8Array(r),t)}static*fromCBORSeq(e,n){let r=e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;for(;i<r.byteLength;){let e=t.d(r,{...n,offset:i,allowTrailing:!0});yield e,i=e.end}}static*fromCDNSeq(n,r){let i=!!r?.preserveComments,a=0,o=!0;for(;;){let{offset:s,hadSeparator:c,commaOffset:l}=g(n,a,r,i?o?`all`:`after-newline`:`none`);if(o&&l>=0){let e=`leading comma in CDN sequence`;if(r?.strict!==!1)throw SyntaxError(e);m(e,l,r)}if(s>=n.length||i&&h(n,s)&&g(n,s,r).offset>=n.length)break;if(!o&&!c){let e=`CDN sequence items must be separated by whitespace, comma, or comment`;if(r?.strict!==!1)throw SyntaxError(e);m(e,s,r)}a=s;let u;try{u=t._(n,{...r,offset:a,allowTrailing:!0,_skipRS:!0})}catch(t){if(r?.strict!==!1)throw t;m(t instanceof Error?t.message:String(t),a,r,!0,t instanceof e.o?t:void 0);break}yield u,a=u.end,o=!1}}static fromJS(e,n){return t.r(e,n)}static fromHexDump(e,n){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);return t.d(new Uint8Array(r),n)}static decode(e,t){return n.fromCBOR(e,t).toJS(t)}static*decodeSeq(e,t){for(let r of n.fromCBORSeq(e,t))yield r.toJS(t)}static*parseSeq(e,t){for(let r of n.fromCDNSeq(e,t))yield r.toJS(t)}static encode(e,t){return n.fromJS(e,t).toCBOR(t)}static compile(e,t){let r=[...n.fromCDNSeq(e,t)].map(e=>e.toCBOR(t)),i=r.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}static decompile(e,t){return[...n.fromCBORSeq(e,t)].map(e=>e.toCDN(t)).join(`
|
|
2
2
|
`)}static toHex(e,t){return[...n.fromCBORSeq(e,t)].map(e=>e.toHexDump(t)).join(`
|
|
3
3
|
`)}static fromHex(e,t){let r=[...n.fromHexDumpSeq(e,t)].map(e=>e.toCBOR(t)),i=r.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}static cborToCdn(e,t){return n.fromCBOR(e,t).toCDN(t)}static cborToCborEdn(e,t){return n.fromCBOR(e,t).toCDN(t)}static cdnToCbor(e,t){return n.fromCDN(e,t).toCBOR(t)}static cborEdnToCbor(e,t){return n.fromCDN(e,t).toCBOR(t)}static parse(e,t){return typeof t==`function`?n.fromCDN(e).toJS({reviver:t}):n.fromCDN(e,t).toJS(t)}static stringify(e,n,r){if(typeof n==`function`||Array.isArray(n)||n===null||n===void 0&&r!==void 0){let i=typeof n==`function`||Array.isArray(n)?n:void 0,a=_(r);if(i){let n=t.n(e,i);return n===void 0||n===t.N?void 0:t.r(n).toCDN(a===void 0?void 0:{indent:a})}return t.r(e).toCDN(a===void 0?void 0:{indent:a})}let i=n;if(i?.replacer){let n=t.n(e,i.replacer,i.extensions,i.undefinedOmits,i.builtinExtensions);if(n===void 0||n===t.N)return;let{replacer:r,...a}=i;return t.r(n,Object.keys(a).length>0?a:void 0).toCDN(i)}return t.r(e,i).toCDN(i)}static format(e,t){return n.fromCDN(e,t).toCDN(t)}};function d(e){let t=``,n=0;for(;n<e.length;){let r=e[n],i=e[n+1]??``;if(r===`-`&&i===`-`){n=f(e,n+2),t+=` `;continue}if(r===`—`){n=f(e,n+1),t+=` `;continue}if(r===`#`){n=f(e,n+1),t+=` `;continue}if(r===`/`&&i===`/`){n=f(e,n+2),t+=` `;continue}if(r===`/`&&i===`*`){let r=e.indexOf(`*/`,n+2);if(r<0)throw SyntaxError(`Unterminated comment in hex dump`);t+=p(e.slice(n,r+2)),n=r+2;continue}if(r===`/`){let r=e.indexOf(`/`,n+1);if(r<0)throw SyntaxError(`Unterminated comment in hex dump`);t+=p(e.slice(n,r+1)),n=r+1;continue}t+=r,n++}return t}function f(e,t){let n=e.indexOf(`
|
|
4
4
|
`,t);return n<0?e.length:n}function p(e){return e.replace(/[^\r\n]/g,` `)}function m(e,t,n,r,i){let a=i?.offset??t,o={message:e,offset:a};r&&(o.fatal=!0),i?.offset!==void 0&&(o.line=i.line,o.column=i.column,o.endOffset=i.endOffset),n?.onWarning?n.onWarning(o):n?.silent||console.warn(`CDN sequence warning at offset ${a}: ${e}`)}function h(e,t){let n=e[t];return n===`#`||n===`/`}function g(e,t,n,r=`none`){let i=t,a=!1,o=!1,s=!1,c=-1,l=()=>r===`all`||r===`after-newline`&&s;for(;i<e.length;){let t=e[i];if(t===` `||t===` `||t===`\r`||t===``){a=!0,i++;continue}if(t===`
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as e } from "./tokenizer-CeuixxXi.js";
|
|
2
|
-
import { E as t, F as n, I as r, L as i, M as a, N as o, P as s, _ as c, a as l, c as u, d, f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./mapEntries-
|
|
2
|
+
import { E as t, F as n, I as r, L as i, M as a, N as o, P as s, _ as c, a as l, c as u, d, f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./mapEntries-BZCOgqIt.js";
|
|
3
3
|
//#region src/extensions/b32.ts
|
|
4
4
|
var w = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", T = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
5
5
|
function E(e) {
|