@cbortech/cbor 0.26.6 → 0.26.7
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 +144 -0
- package/README.md +143 -0
- package/dist/ast/CborByteString.d.ts +14 -0
- package/dist/ast/CborEllipsis.d.ts +94 -2
- package/dist/ast/CborFloat.d.ts +10 -0
- package/dist/ast/CborItem.d.ts +93 -4
- package/dist/ast/CborNint.d.ts +9 -0
- package/dist/ast/CborSimple.d.ts +11 -2
- package/dist/ast/CborTag.d.ts +8 -0
- package/dist/ast/CborTextString.d.ts +20 -0
- package/dist/ast/CborUint.d.ts +8 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cddl/index.cjs +1 -1
- package/dist/cddl/index.js +1 -1
- package/dist/cdn/serialize-utils.d.ts +186 -8
- package/dist/extensions/dt.d.ts +3 -0
- package/dist/extensions/types.d.ts +31 -9
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -98
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-D2NyeCX3.cjs +17 -0
- package/dist/mapEntries-D2NyeCX3.cjs.map +1 -0
- package/dist/{mapEntries-Czxt-cmd.js → mapEntries-DxrDre2P.js} +1461 -959
- package/dist/mapEntries-DxrDre2P.js.map +1 -0
- package/dist/{schema-BxkgvUY6.js → schema-Bofmsptw.js} +247 -247
- package/dist/{schema-BxkgvUY6.js.map → schema-Bofmsptw.js.map} +1 -1
- package/dist/{schema-BmGsaEaW.cjs → schema-t_bdPk8_.cjs} +5 -5
- package/dist/{schema-BmGsaEaW.cjs.map → schema-t_bdPk8_.cjs.map} +1 -1
- package/dist/types.d.ts +169 -7
- package/package.json +2 -2
- package/dist/mapEntries-BhMlCwYo.cjs +0 -15
- package/dist/mapEntries-BhMlCwYo.cjs.map +0 -1
- package/dist/mapEntries-Czxt-cmd.js.map +0 -1
|
@@ -10,16 +10,36 @@ export declare class CborTextString extends CborItem {
|
|
|
10
10
|
readonly ednParts: readonly string[] | undefined;
|
|
11
11
|
/** Original raw-string source text, when parsed from a single backtick literal. */
|
|
12
12
|
readonly ednSource: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Original double-quoted source text (including its escape sequences),
|
|
15
|
+
* when parsed from a single non-concatenated `"..."` literal. Used by
|
|
16
|
+
* `_toCDN()` to round-trip the literal's exact spelling when
|
|
17
|
+
* `preserveTextString` is set.
|
|
18
|
+
*/
|
|
19
|
+
readonly quotedEdnSource: string | undefined;
|
|
13
20
|
/**
|
|
14
21
|
* Original source text per `ednParts` entry, aligned by index; `undefined`
|
|
15
22
|
* for parts that were not raw backtick literals.
|
|
16
23
|
*/
|
|
17
24
|
readonly ednPartSources: readonly (string | undefined)[] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* `true` at index `i`, aligned with `ednParts`, when that part came from a
|
|
27
|
+
* byte-string literal on the right of a text-leading `+` concatenation
|
|
28
|
+
* (decoded as UTF-8 and merged in per §5.1) rather than a double-quoted
|
|
29
|
+
* `"..."` literal. Both cases leave `ednPartSources[i]` `undefined` (byte
|
|
30
|
+
* strings have no preserved raw source here, same as an unpreserved
|
|
31
|
+
* double-quoted literal), so this is what lets `appSeqSourceFeatures`
|
|
32
|
+
* attribute the part to `byteString` instead of the unpreservable
|
|
33
|
+
* `textString`.
|
|
34
|
+
*/
|
|
35
|
+
readonly ednPartIsByteString: readonly boolean[] | undefined;
|
|
18
36
|
constructor(value: string, options?: {
|
|
19
37
|
encodingWidth?: EncodingWidth;
|
|
20
38
|
ednParts?: readonly string[];
|
|
21
39
|
ednSource?: string;
|
|
40
|
+
quotedEdnSource?: string;
|
|
22
41
|
ednPartSources?: readonly (string | undefined)[];
|
|
42
|
+
ednPartIsByteString?: readonly boolean[];
|
|
23
43
|
});
|
|
24
44
|
_encodeTo(writer: CborWriter, _options?: ToCBOROptions): void;
|
|
25
45
|
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
package/dist/ast/CborUint.d.ts
CHANGED
|
@@ -5,8 +5,16 @@ import { CborWriter, EncodingWidth } from '../cbor/encode';
|
|
|
5
5
|
export declare class CborUint extends CborItem {
|
|
6
6
|
readonly value: bigint;
|
|
7
7
|
encodingWidth: EncodingWidth | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Original CDN digit spelling (base + digits, without the encoding-
|
|
10
|
+
* indicator suffix), set by the parser when this value came from CDN
|
|
11
|
+
* text. Used by `_toCDN()` to round-trip the literal's base (`0xff`,
|
|
12
|
+
* `0o377`, `0b101`, decimal) when `preserveNumberFormat` is set.
|
|
13
|
+
*/
|
|
14
|
+
readonly ednSource?: string;
|
|
8
15
|
constructor(value: number | bigint, options?: {
|
|
9
16
|
encodingWidth?: EncodingWidth;
|
|
17
|
+
ednSource?: string;
|
|
10
18
|
});
|
|
11
19
|
_encodeTo(writer: CborWriter, _options?: ToCBOROptions): void;
|
|
12
20
|
_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-D2NyeCX3.cjs");exports.CborArray=e.D,exports.CborBigNint=e._,exports.CborBigUint=e.v,exports.CborByteString=e.A,exports.CborEmbeddedCBOR=e.w,exports.CborFloat=e.M,exports.CborIndefiniteByteString=e.k,exports.CborIndefiniteTextString=e.O,exports.CborItem=e.I,exports.CborMap=e.E,exports.CborNint=e.P,exports.CborSimple=e.T,exports.CborTag=e.j,exports.CborTextString=e.h,exports.CborUint=e.F;
|
package/dist/ast/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e,
|
|
2
|
-
export {
|
|
1
|
+
import { A as e, D as t, E as n, F as r, I as i, M as a, O as o, P as s, T as c, _ as l, h as u, j as d, k as f, v as p, w as m } from "../mapEntries-DxrDre2P.js";
|
|
2
|
+
export { t as CborArray, l as CborBigNint, p as CborBigUint, e as CborByteString, m as CborEmbeddedCBOR, a as CborFloat, f as CborIndefiniteByteString, o as CborIndefiniteTextString, i as CborItem, n as CborMap, s as CborNint, c as CborSimple, d as CborTag, u as CborTextString, r as CborUint };
|
package/dist/cddl/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../schema-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../schema-t_bdPk8_.cjs");function t(e,t){let n=Math.max(0,Math.min(t,e.length)),r=1,i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===10&&(r++,i=t+1);return{line:r,column:n-i+1}}var n=class{static compile(t,n){return e.n(t,n)}};function r(t){let n=new e.o(t),r=[];for(;;){let e=n.consume();if(e.type===`EOF`)break;r.push(e)}return{tokens:r,comments:n.comments}}function i(t){let n=new e.o(t),r=[];try{for(;;){let e=n.consume();if(e.type===`EOF`)break;r.push(e)}return{tokens:r,comments:n.comments}}catch(i){let a=i instanceof e.l?i:new e.l(i instanceof Error?i.message:String(i)),o=n.lastEndOffset;if(o<t.length){let e=1,n=1;for(let r=0;r<o;r++)t[r]===`
|
|
2
2
|
`?(e++,n=1):n++;r.push({type:`ERROR`,value:t.slice(o),raw:t.slice(o),line:e,col:n,offset:o,endOffset:t.length})}return{tokens:r,comments:n.comments,error:a}}}exports.CDDL=n,exports.default=n,exports.CddlMismatchError=e.s,exports.CddlSchema=e.t,exports.CddlSemanticError=e.c,exports.CddlSyntaxError=e.l,exports.PRELUDE_CDDL=e.r,exports.getPreludeRules=e.i,exports.parseCDDL=e.a,exports.positionAt=t,exports.tokenize=r,exports.tokenizeLenient=i;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cddl/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../schema-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../schema-Bofmsptw.js";
|
|
2
2
|
//#region src/cddl/position.ts
|
|
3
3
|
function l(e, t) {
|
|
4
4
|
let n = Math.max(0, Math.min(t, e.length)), r = 1, i = 0;
|
|
@@ -13,6 +13,7 @@ export declare function indentOf(indentStr: string, depth: number): string;
|
|
|
13
13
|
export declare function joinConcatParts(literals: readonly string[], indentStr: string | null, depth: number): string;
|
|
14
14
|
export interface Commented {
|
|
15
15
|
comments?: CborComments;
|
|
16
|
+
blankLineBefore?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare function hasPreservedComments(item: Commented): boolean;
|
|
18
19
|
export declare function hasContainerLayoutComments(item: Commented): boolean;
|
|
@@ -29,7 +30,24 @@ export declare function hasContainerLayoutComments(item: Commented): boolean;
|
|
|
29
30
|
* this (e.g. `/**…*\/` → `/ *…/`).
|
|
30
31
|
*/
|
|
31
32
|
export declare function convertCommentText(comment: CborComment, style: 'c-style' | 'cdn-style' | undefined): string;
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Split an item's leading comments into ones that get their own line above
|
|
35
|
+
* it, and a trailing run of comments the parser found on the same source
|
|
36
|
+
* line as the item itself (`CborComment.sameLine`) — e.g.
|
|
37
|
+
* `/ protected / << ... >>,` in an RFC 9052-style annotated array. Since
|
|
38
|
+
* comments and the item they lead up to appear in strictly increasing
|
|
39
|
+
* source order, `sameLine` comments always form a contiguous run at the end
|
|
40
|
+
* of the list (nothing can sit between a same-line comment and the item
|
|
41
|
+
* without itself being on that same line).
|
|
42
|
+
*
|
|
43
|
+
* `ownLines` renders like `formatLeadingComments` used to; `inlinePrefix` is
|
|
44
|
+
* meant to be prepended directly to the item's own rendered line (already
|
|
45
|
+
* includes a trailing space per comment, or `''` when there is none).
|
|
46
|
+
*/
|
|
47
|
+
export declare function splitLeadingComments(item: Commented, indent: string, style?: 'c-style' | 'cdn-style' | undefined): {
|
|
48
|
+
ownLines: string[];
|
|
49
|
+
inlinePrefix: string;
|
|
50
|
+
};
|
|
33
51
|
export declare function formatTrailingComments(item: Commented, style?: 'c-style' | 'cdn-style' | undefined): string;
|
|
34
52
|
export declare function formatDanglingComments(item: Commented, indent: string, style?: 'c-style' | 'cdn-style' | undefined): string[];
|
|
35
53
|
/**
|
|
@@ -59,26 +77,46 @@ export declare function resolveSeparators(options: ToCDNOptions | undefined, com
|
|
|
59
77
|
* comments — line comments can only be terminated by a newline.
|
|
60
78
|
*
|
|
61
79
|
* Entries are accessed through per-index callbacks (not materialised entry
|
|
62
|
-
* objects) so the common no-comments path allocates nothing
|
|
63
|
-
* `hasEntryComments
|
|
64
|
-
*
|
|
65
|
-
* `
|
|
80
|
+
* objects) so the common no-comments/no-blank-line path allocates nothing
|
|
81
|
+
* per entry. `hasEntryComments` and `entryTrailing` are consulted only when
|
|
82
|
+
* `preserveComments` is set; `entryLeadingNode` is also consulted when
|
|
83
|
+
* `preserveBlankLines` is set, independently of `preserveComments`, to read
|
|
84
|
+
* its `blankLineBefore` flag. `renderEntry` receives the resolved `colSep`
|
|
85
|
+
* (': ' or ':' depending on compact mode) for rendering map pairs.
|
|
66
86
|
*/
|
|
67
87
|
export declare function serializeContainer(p: {
|
|
68
88
|
node: Commented;
|
|
69
89
|
options: ToCDNOptions | undefined;
|
|
70
90
|
depth: number;
|
|
71
|
-
openChar:
|
|
72
|
-
closeChar:
|
|
91
|
+
openChar: string;
|
|
92
|
+
closeChar: string;
|
|
73
93
|
count: number;
|
|
74
94
|
indefiniteLength: boolean;
|
|
75
95
|
encodingWidth: EncodingWidth | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Where the resolved encoding-indicator suffix is placed.
|
|
98
|
+
* - `'open'` (default): right after `openChar`, before the content
|
|
99
|
+
* (`[_2 1,2,3]`) — the head this indicator describes encodes entry count.
|
|
100
|
+
* - `'close'`: right after `closeChar`, with no separating space
|
|
101
|
+
* (`<<1,2>>_1`) — for `CborEmbeddedCBOR`, whose byte-string head encodes
|
|
102
|
+
* content byte length, not entry count.
|
|
103
|
+
*/
|
|
104
|
+
eiPosition?: 'open' | 'close';
|
|
105
|
+
/**
|
|
106
|
+
* Basis for canonical-encoding-width detection (`encodingIndicators:
|
|
107
|
+
* 'auto'`/`'always'` with no explicit `encodingWidth`). Defaults to
|
|
108
|
+
* `count`, matching the CBOR array/map head. `CborEmbeddedCBOR` overrides
|
|
109
|
+
* this to its encoded content's byte length instead.
|
|
110
|
+
*/
|
|
111
|
+
canonicalCount?: () => bigint;
|
|
76
112
|
hasEntryComments: () => boolean;
|
|
77
113
|
/** Render entry `i` at child depth (`item` or `key: value`). */
|
|
78
114
|
renderEntry: (i: number, colSep: string) => string;
|
|
79
115
|
/**
|
|
80
116
|
* Whether entry `i` contains no nested array/map, so it may stay on the
|
|
81
|
-
* container's line under `inlineLeafContainers`. Omitted = always a leaf
|
|
117
|
+
* container's line under `inlineLeafContainers`. Omitted = always a leaf
|
|
118
|
+
* (used by `CborEmbeddedCBOR`, where an entry that is itself a container
|
|
119
|
+
* still inlines as long as its own rendering fits on one line).
|
|
82
120
|
*/
|
|
83
121
|
entryIsLeaf?: (i: number) => boolean;
|
|
84
122
|
/** Node whose leading comments are emitted above entry `i` (item / map key). */
|
|
@@ -86,7 +124,63 @@ export declare function serializeContainer(p: {
|
|
|
86
124
|
/** Pre-formatted trailing comment text for entry `i` (starts with ' ', or ''). */
|
|
87
125
|
entryTrailing: (i: number, style: 'c-style' | 'cdn-style' | undefined) => string;
|
|
88
126
|
}): string;
|
|
127
|
+
/**
|
|
128
|
+
* Single-child counterpart to `serializeContainer`, for a wrapper that
|
|
129
|
+
* holds exactly one child inside `openChar`/`closeChar` (currently just
|
|
130
|
+
* `CborTag`'s `(content)`) rather than a comma-separated list of entries.
|
|
131
|
+
*
|
|
132
|
+
* Emits the child's own leading/trailing comments, and the wrapper node's
|
|
133
|
+
* `dangling` comments (a comment positioned after the child but still
|
|
134
|
+
* inside the brackets, with nothing following it to attach to as leading —
|
|
135
|
+
* mirroring how `serializeContainer` handles a container's own dangling
|
|
136
|
+
* comments). Falls back to the plain single-line `(content)` form — the
|
|
137
|
+
* common, zero-allocation-beyond-string-concat path — when comments aren't
|
|
138
|
+
* requested/applicable (no indent, no `preserveComments`, or neither the
|
|
139
|
+
* child nor the wrapper has any).
|
|
140
|
+
*
|
|
141
|
+
* `renderChild` is called with the child's depth exactly once, resolved
|
|
142
|
+
* *before* calling it: `depth + 1` when comments force multi-line
|
|
143
|
+
* rendering, `depth` otherwise (matching a plain value's existing
|
|
144
|
+
* "transparent" nesting — `tag(content)` doesn't indent `content` an extra
|
|
145
|
+
* level when there's nothing to justify going multi-line for).
|
|
146
|
+
*/
|
|
147
|
+
export declare function renderSingleChildWithComments(child: Commented, wrapper: Commented, options: ToCDNOptions | undefined, depth: number, renderChild: (childDepth: number) => string, openChar: '(', closeChar: ')'): string;
|
|
89
148
|
export declare function serializeBytes(bytes: Uint8Array, encoding?: 'hex' | 'base64' | 'base64url' | 'base32' | 'base32hex', sqstr?: 'printable-string' | 'string' | 'none'): string;
|
|
149
|
+
/**
|
|
150
|
+
* Which comment syntax a byte-string literal's raw source recognizes —
|
|
151
|
+
* `undefined` when it has none at all (its content is data, not a comment
|
|
152
|
+
* host). Set once, at parse time, by whoever actually knows the literal's
|
|
153
|
+
* real origin (the tokenizer for `h'...'`/`b64'...'`/bare sqstr, or the
|
|
154
|
+
* parser comparing the resolved extension against the specific built-in
|
|
155
|
+
* `b32`/`h32` objects by reference — never guessed later from the prefix
|
|
156
|
+
* string, since a user extension can register under any prefix, including
|
|
157
|
+
* one a built-in also uses; see `CborByteString.ednCommentSyntax`).
|
|
158
|
+
* - `'full'`: `#`, `//`, `/* *\/`, and `/ /` (§5.2.1/§5.3.3) — `h'...'`
|
|
159
|
+
* and its backtick form, and the built-in `b32'...'`/`h32'...'`
|
|
160
|
+
* extensions, which share hex's comment syntax (`utils/strip-comments.ts`).
|
|
161
|
+
* - `'hash-only'`: only `#` line comments — standard base64 (`b64'...'`),
|
|
162
|
+
* where `/` is valid data (e.g. `//8=` decodes to 0xFFFF), never a
|
|
163
|
+
* comment marker (see Tokenizer._readByteContent, §5.2.2).
|
|
164
|
+
*/
|
|
165
|
+
export type ByteCommentSyntax = 'full' | 'hash-only';
|
|
166
|
+
/**
|
|
167
|
+
* Strip comments from inside a preserved byte-string literal's raw source,
|
|
168
|
+
* keeping everything else — case, whitespace, `...` — untouched. Used when
|
|
169
|
+
* `preserveByteString` is set but `preserveComments` is not: the preserved
|
|
170
|
+
* spelling should still drop comments, the same as an unpreserved literal
|
|
171
|
+
* re-derived from its decoded value would. `syntax` selects the comment
|
|
172
|
+
* rules to apply (see `ByteCommentSyntax`); the caller is responsible for
|
|
173
|
+
* knowing which one is correct — this function does not guess from `raw`.
|
|
174
|
+
*
|
|
175
|
+
* Only scans the quote-delimited content (not the prefix or a trailing
|
|
176
|
+
* encoding-indicator suffix), and mirrors the tokenizer's own
|
|
177
|
+
* comment-recognition closely enough for realistic input; a comment
|
|
178
|
+
* containing a literal copy of the delimiter quote character is not
|
|
179
|
+
* specially handled (the input is already known-valid, so at worst this
|
|
180
|
+
* shifts where the content/comment boundary is drawn, never produces
|
|
181
|
+
* unparseable output).
|
|
182
|
+
*/
|
|
183
|
+
export declare function stripByteLiteralComments(raw: string, syntax: ByteCommentSyntax): string;
|
|
90
184
|
/**
|
|
91
185
|
* Produce a single-quoted EDN app-string content `'...'` from a string value.
|
|
92
186
|
* Exported for use by app-extension `_toCDN` implementations.
|
|
@@ -114,3 +208,87 @@ export declare function canonicalEncodingWidth(n: bigint): EncodingWidth;
|
|
|
114
208
|
* @param getCanonical - lazily compute the canonical width (only called in 'always' mode)
|
|
115
209
|
*/
|
|
116
210
|
export declare function resolveEiSuffix(options: ToCDNOptions | undefined, encodingWidth: EncodingWidth | undefined, getCanonical: () => EncodingWidth): string;
|
|
211
|
+
/** How a node should render under `preserveAppSequence`. */
|
|
212
|
+
export type AppSeqRenderDecision = 'verbatim' | 'adjusted' | 'source' | 'structural' | 'normal';
|
|
213
|
+
interface AppSeqSourceFeatures {
|
|
214
|
+
byteString?: boolean;
|
|
215
|
+
textString?: boolean;
|
|
216
|
+
rawString?: boolean;
|
|
217
|
+
concatenation?: boolean;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Decide how an extension result node — from a `prefix'...'` /
|
|
221
|
+
* `` prefix`...` `` / `prefix<<...>>` source, or (for a tag-wrapper node
|
|
222
|
+
* that also has a generic `CborTag` fallback to delegate to) a raw tag
|
|
223
|
+
* literal `N(...)` — should render under `ToCDNOptions.preserveAppSequence`.
|
|
224
|
+
*
|
|
225
|
+
* A raw-tag source is recognised by `ednSource !== undefined`: the parser
|
|
226
|
+
* only ever sets a tag-wrapper's `ednSource` (the tag *number's* digit
|
|
227
|
+
* spelling) when it was reached via `N(...)`, never via one of the
|
|
228
|
+
* app-string/-sequence forms. Leaf (non-tag-wrapper) nodes have no raw-tag
|
|
229
|
+
* form at all — always pass `undefined` for `ednSource` there.
|
|
230
|
+
*
|
|
231
|
+
* Returns:
|
|
232
|
+
* - `'verbatim'`: re-emit `appSeqSource` as-is. Only reachable for a
|
|
233
|
+
* raw-tag source: its encoding-indicator suffixes are nested at two
|
|
234
|
+
* independent positions (tag number and inner content), so this is only
|
|
235
|
+
* safe in `'auto'` mode with no relevant sibling option overridden.
|
|
236
|
+
* - `'source'`: keep a raw-tag source structurally verbatim, applying
|
|
237
|
+
* comment and encoding-indicator changes by their captured source spans.
|
|
238
|
+
* This avoids changing unrelated literal spelling or layout.
|
|
239
|
+
* - `'adjusted'`: for an app-string/-sequence source, strip whatever
|
|
240
|
+
* *outer* indicator suffix is already at the end of `appSeqSource` (or,
|
|
241
|
+
* under `'never'`, also an *inner* one immediately before `<<...>>`'s
|
|
242
|
+
* closing `>>` — the app-sequence's sole item's own indicator) and let
|
|
243
|
+
* the caller append one recomputed via `resolveEiSuffix`/`floatSuffix`
|
|
244
|
+
* for the current mode via `adjustAppSeqIndicator` — correct in every
|
|
245
|
+
* mode, without losing the source's notation family. (An inner indicator
|
|
246
|
+
* can only be *stripped*, not *recomputed*: the item's own encoding
|
|
247
|
+
* width isn't tracked once resolved to a plain date/address string, so
|
|
248
|
+
* `'always'` cannot add a missing one — it is left absent.)
|
|
249
|
+
* - `'structural'`: keep the raw-tag notation *family* (as opposed to
|
|
250
|
+
* upgrading to `prefix'...'`) but re-derive it structurally — via the
|
|
251
|
+
* node's own `CborTag` rendering — instead of using `appSeqSource`
|
|
252
|
+
* verbatim. Needed whenever verbatim text would ignore a sibling option
|
|
253
|
+
* that must apply per nested node: an explicit `preserveNumberFormat` /
|
|
254
|
+
* `preserveByteString` / `preserveTextString` / `preserveRawString` /
|
|
255
|
+
* `preserveConcatenation` override.
|
|
256
|
+
* Verbatim raw-tag text inherently contains the nested literal spelling.
|
|
257
|
+
* - `'normal'`: fall through to the class's own notation regeneration
|
|
258
|
+
* (`prefix'...'`), unaffected by `preserveAppSequence`. For `<<...>>`,
|
|
259
|
+
* this is also used when replaying its sole inner item would defeat an
|
|
260
|
+
* explicitly disabled, relevant literal-preservation option.
|
|
261
|
+
*
|
|
262
|
+
* `editsComplete` (from `CborItem.appSeqEncodingEditsComplete`, raw-tag
|
|
263
|
+
* sources only) is `false` when the tag's content contains a node type
|
|
264
|
+
* `collectContentEncodingEdits` doesn't cover (e.g. a `CborMap` nested in an
|
|
265
|
+
* `ip` array's raw-tag content). `'source'` relies on those edits to apply
|
|
266
|
+
* `encodingIndicators: 'always'`/`'never'`, so incomplete coverage would
|
|
267
|
+
* silently leave the uncovered node's own indicator unchanged; `'structural'`
|
|
268
|
+
* is used instead, since it re-derives every nested indicator recursively.
|
|
269
|
+
*/
|
|
270
|
+
export declare function decideTaggedAppSeqRendering(options: ToCDNOptions | undefined, appSeqSource: string | undefined, ednSource: string | undefined, sourceFeatures?: AppSeqSourceFeatures, editsComplete?: boolean): AppSeqRenderDecision;
|
|
271
|
+
/** Apply comment/EI options directly to a preserved raw-tag source. */
|
|
272
|
+
export declare function adjustRawAppSeqSource(appSeqSource: string, options: ToCDNOptions | undefined, comments: readonly CborComment[] | undefined, encodingEdits: readonly {
|
|
273
|
+
start: number;
|
|
274
|
+
end: number;
|
|
275
|
+
always: string;
|
|
276
|
+
never: string;
|
|
277
|
+
}[] | undefined): string;
|
|
278
|
+
/**
|
|
279
|
+
* Adjust an `'adjusted'` app-string/-sequence source: apply requested comment
|
|
280
|
+
* conversion/removal by captured source span, strip the existing
|
|
281
|
+
* encoding-indicator suffix(es), then append `newSuffix` (the outer/wrapper
|
|
282
|
+
* indicator recomputed for the current mode) — see
|
|
283
|
+
* `decideTaggedAppSeqRendering`.
|
|
284
|
+
*
|
|
285
|
+
* Under `encodingIndicators: 'never'`, an inner (item-level) indicator is
|
|
286
|
+
* also stripped, using
|
|
287
|
+
* `innerItemEnd` (see `CborItem.appSeqInnerEnd`) to find it by its actual
|
|
288
|
+
* parsed position rather than by pattern-matching text near the closing
|
|
289
|
+
* `>>` — whitespace, a trailing comma, and/or a comment can all separate
|
|
290
|
+
* the two, in any combination, so a position-based cut is the only fully
|
|
291
|
+
* reliable way to locate it.
|
|
292
|
+
*/
|
|
293
|
+
export declare function adjustAppSeqIndicator(appSeqSource: string, newSuffix: string, options: ToCDNOptions | undefined, innerItemEnd: number | undefined, comments: readonly CborComment[] | undefined): string;
|
|
294
|
+
export {};
|
package/dist/extensions/dt.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const TAG_EPOCH = 1n;
|
|
|
30
30
|
export declare class CborEpochDtExtUint extends CborUint {
|
|
31
31
|
constructor(value: number | bigint, options?: {
|
|
32
32
|
encodingWidth?: EncodingWidth;
|
|
33
|
+
ednSource?: string;
|
|
33
34
|
});
|
|
34
35
|
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
35
36
|
}
|
|
@@ -40,6 +41,7 @@ export declare class CborEpochDtExtUint extends CborUint {
|
|
|
40
41
|
export declare class CborEpochDtExtNint extends CborNint {
|
|
41
42
|
constructor(value: number | bigint, options?: {
|
|
42
43
|
encodingWidth?: EncodingWidth;
|
|
44
|
+
ednSource?: string;
|
|
43
45
|
});
|
|
44
46
|
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
45
47
|
}
|
|
@@ -50,6 +52,7 @@ export declare class CborEpochDtExtNint extends CborNint {
|
|
|
50
52
|
export declare class CborEpochDtExtFloat extends CborFloat {
|
|
51
53
|
constructor(value: number, options?: {
|
|
52
54
|
precision?: 'half' | 'single' | 'double';
|
|
55
|
+
literalSource?: string;
|
|
53
56
|
});
|
|
54
57
|
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
55
58
|
}
|
|
@@ -52,17 +52,39 @@ export interface CborExtension {
|
|
|
52
52
|
*/
|
|
53
53
|
parseAppSequence?(prefix: string, items: CborItem[], onError?: (msg: string) => void): CborItem;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* `prefix
|
|
58
|
-
*
|
|
59
|
-
* back to serializing the resolved item instead.
|
|
55
|
+
* Controls how the CDN parser preserves the original application-string
|
|
56
|
+
* / -sequence / raw-tag source text — `prefix'...'`, `` prefix`...` ``,
|
|
57
|
+
* `prefix<<...>>`, or a raw tag literal `N(...)` resolved via `parseTag`
|
|
58
|
+
* — for round-tripping through `toCDN()`.
|
|
60
59
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* - `true`: the parser wraps the result of `parseAppSequence` (only —
|
|
61
|
+
* `parseAppString` and `parseTag` results are unaffected) in a
|
|
62
|
+
* `CborAppSeqResult`, which round-trips the original `<<...>>` notation
|
|
63
|
+
* unconditionally whenever `appStrings !== false` (no extra option
|
|
64
|
+
* needed). Use this when the result has no dedicated subclass whose
|
|
65
|
+
* identity callers rely on (e.g. `instanceof` checks) — the wrapper
|
|
66
|
+
* changes the returned node's type.
|
|
67
|
+
* - `'optional'`: for `parseAppString`, `parseAppSequence`, and `parseTag`
|
|
68
|
+
* results alike, the parser instead sets `appSeqSource` directly on the
|
|
69
|
+
* *same* result node (preserving its class/identity) and leaves it to
|
|
70
|
+
* the node's own `_toCDN()` override to decide whether to use it — by
|
|
71
|
+
* convention, only when `ToCDNOptions.preserveAppSequence` is set, so
|
|
72
|
+
* the default output keeps regenerating `prefix'...'` form from the
|
|
73
|
+
* resolved value. This covers a `` prefix`...` `` (backtick) source, a
|
|
74
|
+
* non-canonically-spelled `prefix'...'` source, and a raw tag literal
|
|
75
|
+
* (e.g. `1(1749772800)`) that would otherwise be upgraded to
|
|
76
|
+
* `prefix'...'` notation — not just `<<...>>`. Use this when the result
|
|
77
|
+
* is a dedicated subclass whose default behavior is to regenerate its
|
|
78
|
+
* notation from the resolved value on every call.
|
|
79
|
+
* - `undefined` (default): neither happens. Extensions whose result
|
|
80
|
+
* already handles source preservation itself (e.g. `CborFloat` via its
|
|
81
|
+
* own `ednSource` property) should leave this unset.
|
|
82
|
+
*
|
|
83
|
+
* In single-line output (no `indent`), a source spelling that spans
|
|
84
|
+
* multiple lines always falls back to serializing the resolved item,
|
|
85
|
+
* regardless of mode.
|
|
64
86
|
*/
|
|
65
|
-
readonly preserveAppSeqSource?: boolean;
|
|
87
|
+
readonly preserveAppSeqSource?: boolean | 'optional';
|
|
66
88
|
/**
|
|
67
89
|
* Called when a `CborTag` is encountered during CBOR decode (`fromCBOR`)
|
|
68
90
|
* or EDN integer-tag parsing (`fromCDN`).
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./schema-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./schema-t_bdPk8_.cjs"),n=require("./mapEntries-D2NyeCX3.cjs");function r(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 i={appStringPrefixes:[`same`],preserveAppSeqSource:!0,parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`same<<...>> requires at least one item`);let i=t[0],a=i.toCBOR();for(let e=1;e<t.length;e++)if(!r(a,t[e].toCBOR())){let t=`same<<...>>: item ${e} produces different CBOR bytes than item 0`;if(n)n(t);else throw SyntaxError(t)}return i}},a=new Map,o=64;function s(e){if(typeof e!=`string`)return e;let n=a.get(e);return n||(n=t.n(e),a.size>=o&&a.delete(a.keys().next().value),a.set(e,n)),n}function c(e,n,r){if(n){let i=n.validate(e,r);if(!i.valid)throw new t.s(i.errors,i.warnings)}return e}function l(e,t){return c(e,s(t?.cddl),t?.cddlValidationOptions)}var u=class t{static OMIT=n.z;static TAG=n.B;static Tag=n.H;static Simple=n.R;static MapEntries=n.t;static dt_as_Date=n.m;#e;constructor(e){this.#e=e??{}}#t(e){return{...this.#e,...e??{}}}fromCBOR(e,n){let r=t.fromCBOR(e,this.#t(n));return r._defaults=this.#e,r}fromCDN(e,n){let r=t.fromCDN(e,this.#t(n));return r._defaults=this.#e,r}fromEDN(e,t){return this.fromCDN(e,t)}fromJS(e,n){let r=t.fromJS(e,this.#t(n));return r._defaults=this.#e,r}fromHexDump(e,n){let r=t.fromHexDump(e,this.#t(n));return r._defaults=this.#e,r}*fromCBORSeq(e,n){for(let r of t.fromCBORSeq(e,this.#t(n)))r._defaults=this.#e,yield r}*fromCDNSeq(e,n){for(let r of t.fromCDNSeq(e,this.#t(n)))r._defaults=this.#e,yield r}*fromHexDumpSeq(e,n){for(let r of t.fromHexDumpSeq(e,this.#t(n)))r._defaults=this.#e,yield r}decode(e,n){return t.decode(e,this.#t(n))}*decodeSeq(e,n){yield*t.decodeSeq(e,this.#t(n))}*parseSeq(e,n){yield*t.parseSeq(e,this.#t(n))}encode(e,n){return t.encode(e,this.#t(n))}compile(e,n){return t.compile(e,this.#t(n))}decompile(e,n){return t.decompile(e,this.#t(n))}toHex(e,n){return t.toHex(e,this.#t(n))}fromHex(e,n){return t.fromHex(e,this.#t(n))}validate(e,n){return t.validate(e,this.#t(n))}cborToCborEdn(e,t){return this.cborToCdn(e,t)}cborToCdn(e,n){let r=this.#t(n),i=t.fromCBOR(e,r);return i._defaults=this.#e,i.toCDN(r)}cborEdnToCbor(e,t){return this.cdnToCbor(e,t)}cdnToCbor(e,n){let r=this.#t(n);return t.fromCDN(e,r).toCBOR(r)}parse(e,n){if(typeof n==`function`){let r=this.#t({reviver:n});return t.fromCDN(e,r).toJS(r)}let r=this.#t(n);return t.fromCDN(e,r).toJS(r)}stringify(e,n,r){if(typeof n==`function`||Array.isArray(n)||n===null||n===void 0&&r!==void 0){let i={...this.#e};return n===null?i.replacer=void 0:(typeof n==`function`||Array.isArray(n))&&(i.replacer=n),r!==void 0&&(i.indent=_(r)),t.stringify(e,i)}return t.stringify(e,this.#t(n??void 0))}format(e,n){return t.format(e,this.#t(n))}static fromCBOR(e,t){return l(n.u(e,t),t)}static fromCDN(e,t){return l(n.g(e,t),t)}static fromEDN(e,n){return t.fromCDN(e,n)}static*fromHexDumpSeq(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)}`);yield*t.fromCBORSeq(new Uint8Array(r),n)}static*fromCBORSeq(e,t){let r=s(t?.cddl),i=e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=0;for(;a<i.byteLength;){let e=n.u(i,{...t,offset:a,allowTrailing:!0});yield c(e,r,t?.cddlValidationOptions),a=e.end}}static*fromCDNSeq(t,r){let i=s(r?.cddl),a=!!r?.preserveComments,o=0,l=!0;for(;;){let{offset:s,hadSeparator:u,commaOffset:d}=g(t,o,r,a?l?`all`:`after-newline`:`none`);if(l&&d>=0){let e=`leading comma in CDN sequence`;if(r?.strict!==!1)throw SyntaxError(e);m(e,d,r)}if(s>=t.length||a&&h(t,s)&&g(t,s,r).offset>=t.length)break;if(!l&&!u){let e=`CDN sequence items must be separated by whitespace, comma, or comment`;if(r?.strict!==!1)throw SyntaxError(e);m(e,s,r)}o=s;let f;try{f=n.g(t,{...r,offset:o,allowTrailing:!0,_skipRS:!0})}catch(t){if(r?.strict!==!1)throw t;m(t instanceof Error?t.message:String(t),o,r,!0,t instanceof e.o?t:void 0);break}yield c(f,i,r?.cddlValidationOptions),o=f.end,l=!1}}static fromJS(e,t){return l(n.r(e,t),t)}static fromHexDump(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)}`);return l(n.u(new Uint8Array(r),t),t)}static decode(e,n){return t.fromCBOR(e,n).toJS(n)}static*decodeSeq(e,n){for(let r of t.fromCBORSeq(e,n))yield r.toJS(n)}static*parseSeq(e,n){for(let r of t.fromCDNSeq(e,n))yield r.toJS(n)}static encode(e,n){return t.fromJS(e,n).toCBOR(n)}static compile(e,n){let r=[...t.fromCDNSeq(e,n)].map(e=>e.toCBOR(n)),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,n){return[...t.fromCBORSeq(e,n)].map(e=>e.toCDN(n)).join(`
|
|
2
2
|
`)}static toHex(e,n){return[...t.fromCBORSeq(e,n)].map(e=>e.toHexDump(n)).join(`
|
|
3
|
-
`)}static fromHex(e,n){let r=[...t.fromHexDumpSeq(e,n)].map(e=>e.toCBOR(n)),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 validate(n,r){let i=[],a=[],o,
|
|
4
|
-
`,t);return n<0?e.length:n}function
|
|
3
|
+
`)}static fromHex(e,n){let r=[...t.fromHexDumpSeq(e,n)].map(e=>e.toCBOR(n)),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 validate(n,r){let i=[],a=[],o,c={strict:!1,extensions:r?.extensions,builtinExtensions:r?.builtinExtensions,onWarning:e=>{if(`hint`in e&&e.hint){a.push(e);return}if(`fatal`in e&&e.fatal){o=e;return}i.push(e)}},l=s(r?.cddl),u=[],d=[],f=e=>{if(!l)return;let t=l.validate(e,r?.cddlValidationOptions);u.push(...t.errors),t.warnings&&d.push(...t.warnings)},p=l?{cddlErrors:u,cddlWarnings:d}:{},m=0;try{let e=r?.type??`cbor`;if(e===`cdn`){let e={...c,unresolvedExtension:r?.unresolvedExtension};for(let r of t.fromCDNSeq(n,e))m++,f(r)}else if(e===`hex`)for(let e of t.fromHexDumpSeq(n,c))m++,f(e);else for(let e of t.fromCBORSeq(n,c))m++,f(e)}catch(e){return{valid:!1,count:m,warnings:i,hints:a,error:e instanceof Error?e:Error(String(e)),...p}}if(o){let t=o.cause instanceof Error?o.cause:new e.o(o.message,{offset:o.offset});return{valid:!1,count:m,warnings:i,hints:a,error:t,...p}}return{valid:i.length===0&&u.length===0,count:m,warnings:i,hints:a,...p}}static cborToCdn(e,n){return t.fromCBOR(e,n).toCDN(n)}static cborToCborEdn(e,n){return t.fromCBOR(e,n).toCDN(n)}static cdnToCbor(e,n){return t.fromCDN(e,n).toCBOR(n)}static cborEdnToCbor(e,n){return t.fromCDN(e,n).toCBOR(n)}static parse(e,n){return typeof n==`function`?t.fromCDN(e).toJS({reviver:n}):t.fromCDN(e,n).toJS(n)}static stringify(e,t,r){if(typeof t==`function`||Array.isArray(t)||t===null||t===void 0&&r!==void 0){let i=typeof t==`function`||Array.isArray(t)?t:void 0,a=_(r);if(i){let t=n.n(e,i);return t===void 0||t===n.z?void 0:n.r(t).toCDN(a===void 0?void 0:{indent:a})}return n.r(e).toCDN(a===void 0?void 0:{indent:a})}let i=t;if(i?.replacer){let t=n.n(e,i.replacer,i.extensions,i.undefinedOmits,i.builtinExtensions);if(t===void 0||t===n.z)return;let{replacer:r,...a}=i;return l(n.r(t,Object.keys(a).length>0?a:void 0),i).toCDN(i)}return l(n.r(e,i),i).toCDN(i)}static format(e,n){return t.fromCDN(e,n).toCDN(n)}};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
|
+
`,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&&(o.cause=i),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===`
|
|
5
5
|
`){a=!0,s=!0,i++;continue}if(t===`#`){if(a=!0,l())break;let t=e.indexOf(`
|
|
6
6
|
`,i+1);i=t<0?e.length:t+1,s=!0;continue}if(t===`/`&&e[i+1]===`/`){if(a=!0,l())break;let t=e.indexOf(`
|
|
7
|
-
`,i+2);i=t<0?e.length:t+1,s=!0;continue}if(t===`/`&&e[i+1]===`*`){if(a=!0,l())break;let t=e.indexOf(`*/`,i+2);if(t<0){let t=`unterminated /* comment in CDN sequence`;if(n?.strict!==!1)throw SyntaxError(t);
|
|
8
|
-
`)&&(s=!0),i=t+2;continue}if(t===`/`&&e[i+1]!==`/`){if(a=!0,l())break;let t=e.indexOf(`/`,i+1);if(t<0){let t=`unterminated / comment in CDN sequence`;if(n?.strict!==!1)throw SyntaxError(t);
|
|
9
|
-
`)&&(s=!0),i=t+1;continue}if(t===`,`&&!o){a=!0,o=!0,c=i,i++;continue}break}return{offset:i,hadSeparator:a,commaOffset:c}}function
|
|
7
|
+
`,i+2);i=t<0?e.length:t+1,s=!0;continue}if(t===`/`&&e[i+1]===`*`){if(a=!0,l())break;let t=e.indexOf(`*/`,i+2);if(t<0){let t=`unterminated /* comment in CDN sequence`;if(n?.strict!==!1)throw SyntaxError(t);m(t,i,n,!0),i=e.length}else e.slice(i,t).includes(`
|
|
8
|
+
`)&&(s=!0),i=t+2;continue}if(t===`/`&&e[i+1]!==`/`){if(a=!0,l())break;let t=e.indexOf(`/`,i+1);if(t<0){let t=`unterminated / comment in CDN sequence`;if(n?.strict!==!1)throw SyntaxError(t);m(t,i,n,!0),i=e.length}else e.slice(i,t).includes(`
|
|
9
|
+
`)&&(s=!0),i=t+1;continue}if(t===`,`&&!o){a=!0,o=!0,c=i,i++;continue}break}return{offset:i,hadSeparator:a,commaOffset:c}}function _(e){if(typeof e==`number`){let t=Math.floor(Math.min(10,Math.max(0,e)));return t===0?void 0:t}if(typeof e==`string`)return e.slice(0,10)||void 0}exports.BUILTIN_EXTENSIONS=n.i,exports.CBOR=u,exports.default=u,exports.CBOR_OMIT=n.z,exports.CBOR_TAG=n.B,exports.CddlMismatchError=t.s,exports.CdnSyntaxError=e.o,exports.MapEntries=n.t,exports.Null=n.V,exports.Simple=n.R,exports.Tag=n.H,exports.Undefined=n.U,exports.b1=n.c,exports.b32=n.S,exports.cri=n.d,exports.dt=n.p,exports.dt_as_Date=n.m,exports.float=n.a,exports.h32=n.C,exports.ilbs=n.o,exports.ilts=n.s,exports.ip=n.f,exports.same=i,exports.t1=n.l;
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|