@cbortech/cbor 0.26.8 → 0.27.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 +193 -28
- package/README.md +196 -29
- package/dist/ast/CborAppSeqResult.d.ts +58 -3
- package/dist/ast/CborArray.d.ts +2 -2
- package/dist/ast/CborByteString.d.ts +17 -1
- package/dist/ast/CborEmbeddedCBOR.d.ts +2 -2
- package/dist/ast/CborFloat.d.ts +2 -2
- package/dist/ast/CborIndefiniteByteString.d.ts +25 -1
- package/dist/ast/CborIndefiniteTextString.d.ts +17 -1
- package/dist/ast/CborItem.d.ts +340 -10
- package/dist/ast/CborMap.d.ts +2 -2
- package/dist/ast/CborNint.d.ts +1 -1
- package/dist/ast/CborTag.d.ts +30 -3
- package/dist/ast/CborTextString.d.ts +3 -2
- package/dist/ast/CborUint.d.ts +1 -1
- package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
- 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/index.cjs +2 -2
- package/dist/cdn/index.cjs.map +1 -1
- package/dist/cdn/index.js +18 -18
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/serialize-utils.d.ts +237 -10
- package/dist/cdn/tokenizer.d.ts +12 -11
- package/dist/extensions/builtins.d.ts +5 -5
- package/dist/extensions/cri.d.ts +4 -4
- package/dist/extensions/dt.d.ts +4 -4
- package/dist/extensions/ip.d.ts +4 -4
- package/dist/extensions/types.d.ts +44 -5
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +158 -158
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-Ci_dppP6.js → mapEntries-CCLaJSaJ.js} +1599 -1275
- package/dist/mapEntries-CCLaJSaJ.js.map +1 -0
- package/dist/mapEntries-CZZJScaj.cjs +13 -0
- package/dist/mapEntries-CZZJScaj.cjs.map +1 -0
- package/dist/{schema-y8G5mDIS.js → schema-DN9inJny.js} +294 -294
- package/dist/{schema-y8G5mDIS.js.map → schema-DN9inJny.js.map} +1 -1
- package/dist/schema-zsg5yCPK.cjs +63 -0
- package/dist/{schema-DgnkH0P6.cjs.map → schema-zsg5yCPK.cjs.map} +1 -1
- package/dist/serialize-utils-DhlW61ZX.cjs +37 -0
- package/dist/serialize-utils-DhlW61ZX.cjs.map +1 -0
- package/dist/{tokenizer-N-vAvRdj.js → serialize-utils-h-CVB9rg.js} +636 -358
- package/dist/serialize-utils-h-CVB9rg.js.map +1 -0
- package/dist/types.d.ts +508 -58
- package/dist/utils/base64.d.ts +1 -1
- package/dist/utils/hexfloat.d.ts +11 -3
- package/dist/utils/strip-comments.d.ts +1 -1
- package/package.json +13 -12
- package/dist/mapEntries-BJzyBUH5.cjs +0 -13
- package/dist/mapEntries-BJzyBUH5.cjs.map +0 -1
- package/dist/mapEntries-Ci_dppP6.js.map +0 -1
- package/dist/schema-DgnkH0P6.cjs +0 -63
- package/dist/tokenizer-BD08xbyd.cjs +0 -36
- package/dist/tokenizer-BD08xbyd.cjs.map +0 -1
- package/dist/tokenizer-N-vAvRdj.js.map +0 -1
package/dist/cdn/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cdn/index.ts"],"sourcesContent":["/**\n * Public lower-level CDN tokenization and serialization API\n * (`@cbortech/cbor/cdn`).\n *\n * Exposes the same lexer the parser uses, so tooling such as syntax\n * highlighters stays in exact agreement with parsing behavior. Also exposes\n * the `
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cdn/index.ts"],"sourcesContent":["/**\n * Public lower-level CDN tokenization and serialization API\n * (`@cbortech/cbor/cdn`).\n *\n * Exposes the same lexer the parser uses, so tooling such as syntax\n * highlighters stays in exact agreement with parsing behavior. Also exposes\n * the `preserveAppSeqSource` source-preservation primitives that the built-in\n * `dt`/`ip`/`cri` extensions use, so a third-party `CborExtension` whose\n * result has its own dedicated notation (regenerated from a resolved value,\n * the way `dt'...'`/`ip'...'`/`cri'...'` do) can support `preserveAppSeqSource`\n * too, instead of always discarding the original `` prefix`...` ``,\n * non-canonical `prefix'...'`, or raw-tag `N(...)` source spelling. See the\n * `dt`/`ip`/`cri` extension sources for the pattern these are meant to be\n * used in.\n */\n\nimport { Tokenizer, type Token, type EdnComment } from './tokenizer';\nimport { CdnSyntaxError } from './errors';\n\nexport type { Token, TokenType, EdnComment } from './tokenizer';\nexport { CdnSyntaxError } from './errors';\n\nexport {\n resolveEiSuffix,\n canonicalEncodingWidth,\n decideTaggedAppSeqRendering,\n adjustRawAppSeqSource,\n adjustAppSeqIndicator,\n} from './serialize-utils';\nexport type { AppSeqRenderDecision } from './serialize-utils';\n\nexport interface TokenizeResult {\n /** Scanned tokens in source order, excluding the final EOF token. */\n tokens: Token[];\n /** Comments encountered while scanning, in source order. */\n comments: EdnComment[];\n}\n\nexport interface TokenizeLenientResult extends TokenizeResult {\n /**\n * The scan failure, if any. When set, `tokens` ends with a synthetic\n * `ERROR` token covering the source from the last clean token to the end\n * of the input.\n */\n error?: CdnSyntaxError;\n}\n\n/**\n * Tokenize CDN text. Throws {@link CdnSyntaxError} on invalid input.\n */\nexport function tokenize(text: string): TokenizeResult {\n const tokenizer = new Tokenizer(text);\n const tokens: Token[] = [];\n for (;;) {\n const tok = tokenizer.consume();\n if (tok.type === 'EOF') break;\n tokens.push(tok);\n }\n return { tokens, comments: tokenizer.comments };\n}\n\n/**\n * Error-tolerant tokenization for editors and highlighters: never throws on\n * invalid input. Tokens before the failure are returned as scanned; the\n * remainder of the input is covered by a single synthetic `ERROR` token and\n * the failure is reported in `error`.\n */\nexport function tokenizeLenient(text: string): TokenizeLenientResult {\n const tokenizer = new Tokenizer(text);\n const tokens: Token[] = [];\n try {\n for (;;) {\n const tok = tokenizer.consume();\n if (tok.type === 'EOF') break;\n tokens.push(tok);\n }\n return { tokens, comments: tokenizer.comments };\n } catch (e) {\n const error =\n e instanceof CdnSyntaxError\n ? e\n : new CdnSyntaxError(e instanceof Error ? e.message : String(e));\n const start = tokenizer.lastEndOffset;\n if (start < text.length) {\n let line = 1;\n let col = 1;\n for (let i = 0; i < start; i++) {\n if (text[i] === '\\n') {\n line++;\n col = 1;\n } else {\n col++;\n }\n }\n tokens.push({\n type: 'ERROR',\n value: text.slice(start),\n raw: text.slice(start),\n line,\n col,\n offset: start,\n endOffset: text.length,\n });\n }\n return { tokens, comments: tokenizer.comments, error };\n }\n}\n"],"mappings":";;AAkDA,SAAgB,EAAS,GAA8B;CACrD,IAAM,IAAY,IAAI,EAAU,CAAI,GAC9B,IAAkB,CAAC;CACzB,SAAS;EACP,IAAM,IAAM,EAAU,QAAQ;EAC9B,IAAI,EAAI,SAAS,OAAO;EACxB,EAAO,KAAK,CAAG;CACjB;CACA,OAAO;EAAE;EAAQ,UAAU,EAAU;CAAS;AAChD;AAQA,SAAgB,EAAgB,GAAqC;CACnE,IAAM,IAAY,IAAI,EAAU,CAAI,GAC9B,IAAkB,CAAC;CACzB,IAAI;EACF,SAAS;GACP,IAAM,IAAM,EAAU,QAAQ;GAC9B,IAAI,EAAI,SAAS,OAAO;GACxB,EAAO,KAAK,CAAG;EACjB;EACA,OAAO;GAAE;GAAQ,UAAU,EAAU;EAAS;CAChD,SAAS,GAAG;EACV,IAAM,IACJ,aAAa,IACT,IACA,IAAI,EAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC,GAC7D,IAAQ,EAAU;EACxB,IAAI,IAAQ,EAAK,QAAQ;GACvB,IAAI,IAAO,GACP,IAAM;GACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAO,KACzB,AAAI,EAAK,OAAO,QACd,KACA,IAAM,KAEN;GAGJ,EAAO,KAAK;IACV,MAAM;IACN,OAAO,EAAK,MAAM,CAAK;IACvB,KAAK,EAAK,MAAM,CAAK;IACrB;IACA;IACA,QAAQ;IACR,WAAW,EAAK;GAClB,CAAC;EACH;EACA,OAAO;GAAE;GAAQ,UAAU,EAAU;GAAU;EAAM;CACvD;AACF"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { CborComment, CborComments, ToCDNOptions } from '../types';
|
|
2
2
|
import { EncodingWidth } from '../cbor/encode';
|
|
3
3
|
import { AppSeqEncodingEdit, AppSeqSourceFeatures } from '../ast/CborItem';
|
|
4
|
+
/**
|
|
5
|
+
* Append every element of `source` onto `target` in place.
|
|
6
|
+
*
|
|
7
|
+
* Not `target.push(...source)`: spreading a large array as call arguments
|
|
8
|
+
* can exceed the engine's argument-count limit (observed with hex-dump
|
|
9
|
+
* lines for a deeply nested large array/map, and with CDN reflow
|
|
10
|
+
* breakpoints for a large embedded array — RangeError: Maximum call stack
|
|
11
|
+
* size exceeded).
|
|
12
|
+
*/
|
|
13
|
+
export declare function pushAll<T>(target: T[], source: readonly T[]): void;
|
|
4
14
|
/** Resolve indent option to a string, or null for single-line output. */
|
|
5
15
|
export declare function resolveIndent(options: ToCDNOptions | undefined): string | null;
|
|
6
16
|
/** Build the indent prefix for a given depth. */
|
|
@@ -19,12 +29,59 @@ export declare function indentOf(indentStr: string, depth: number): string;
|
|
|
19
29
|
* other comment kind.
|
|
20
30
|
*/
|
|
21
31
|
export declare function joinConcatParts(literals: readonly string[], indentStr: string | null, depth: number, midComments?: readonly (readonly string[])[]): string;
|
|
32
|
+
/**
|
|
33
|
+
* Serialize string parts as a `t1<<...>>` / `b1<<...>>` app-sequence
|
|
34
|
+
* (draft-ietf-cbor-edn-literals-27 §3.5) — the `modernConcat` replacement
|
|
35
|
+
* for `joinConcatParts`'s `+`-joining. Unlike a `+` chain, this
|
|
36
|
+
* notation has its own closing delimiter, so (matching how `<<...>>`/
|
|
37
|
+
* `CborEmbeddedCBOR` places its own encoding-width indicator, and unlike
|
|
38
|
+
* `emitParts`, which has nowhere else to put it) `suffix` is appended after
|
|
39
|
+
* `>>` rather than onto the last literal — it describes the one merged value
|
|
40
|
+
* `t1<<...>>` denotes as a whole, not any individual argument.
|
|
41
|
+
*
|
|
42
|
+
* Always single-line (an app-sequence is loose/collapsible, like
|
|
43
|
+
* every other `<<...>>` form), except when there's a mid-chain comment to
|
|
44
|
+
* preserve — nothing else forces it multi-line, since (unlike a real `+`
|
|
45
|
+
* chain) there's no risk of an unbounded single line growing unreadable that
|
|
46
|
+
* this format was ever meant to solve; a comment is the one thing a single
|
|
47
|
+
* line genuinely cannot hold, mirroring `joinConcatParts`'s own reason for
|
|
48
|
+
* going multi-line.
|
|
49
|
+
*/
|
|
50
|
+
export declare function joinAppSeqParts(prefix: 't1' | 'b1', literals: readonly string[], suffix: string, indentStr: string | null, depth: number, midComments?: readonly (readonly string[])[]): string;
|
|
22
51
|
export interface Commented {
|
|
23
52
|
comments?: CborComments;
|
|
24
53
|
blankLineBefore?: boolean;
|
|
25
54
|
}
|
|
26
55
|
export declare function hasPreservedComments(item: Commented): boolean;
|
|
27
56
|
export declare function hasContainerLayoutComments(item: Commented): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Subset of `ToCDNOptions` needed to resolve comment on/off + style —
|
|
59
|
+
* accepted structurally so callers with a narrower/wider options type (or a
|
|
60
|
+
* plain `FromCDNOptions`, which shares both fields) don't need a cast.
|
|
61
|
+
*/
|
|
62
|
+
interface CommentOptions {
|
|
63
|
+
preserveComments?: boolean | 'c-style' | 'cdn-style';
|
|
64
|
+
comments?: 'strip' | 'c-style' | 'cdn-style';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether comments should be emitted for freshly-regenerated output (as
|
|
68
|
+
* opposed to a preserved app-sequence/raw-tag source — see
|
|
69
|
+
* `decideTaggedAppSeqRendering`'s own comment handling for that case, which
|
|
70
|
+
* has a different "nothing set" default).
|
|
71
|
+
*
|
|
72
|
+
* `preserveComments: true` always emits (verbatim); otherwise, comments are
|
|
73
|
+
* emitted only when `comments` requests a real style (not `'strip'`,
|
|
74
|
+
* the default when unset) — matching the deprecated `preserveComments:
|
|
75
|
+
* 'c-style'/'cdn-style'` shorthand, which behaves the same as `comments`
|
|
76
|
+
* set to that value.
|
|
77
|
+
*/
|
|
78
|
+
export declare function shouldEmitComments(options: CommentOptions | undefined): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The marker style to normalize emitted comments to, or `undefined` for
|
|
81
|
+
* verbatim (original markers kept as-is). Only meaningful when
|
|
82
|
+
* `shouldEmitComments` is `true`; see its doc for the on/off precedence.
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveCommentStyle(options: CommentOptions | undefined): 'c-style' | 'cdn-style' | undefined;
|
|
28
85
|
/**
|
|
29
86
|
* Convert a single comment's text to the requested marker style.
|
|
30
87
|
*
|
|
@@ -125,6 +182,17 @@ export declare function serializeContainer(p: {
|
|
|
125
182
|
closeChar: string;
|
|
126
183
|
count: number;
|
|
127
184
|
indefiniteLength: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Whether an indefinite-length container shows the `_` marker
|
|
187
|
+
* (`(_ "a", "b")`) before its content. Defaults to `true`; set `false` for
|
|
188
|
+
* a container that denotes an indefinite-length value through some other
|
|
189
|
+
* notation entirely (e.g. `ilts<<"a", "b">>`) rather than through the
|
|
190
|
+
* `_`-marked legacy streamstring form — the value is still genuinely
|
|
191
|
+
* indefinite-length (so `indefiniteLength: true` still correctly
|
|
192
|
+
* suppresses any encoding-width suffix, which has no meaning for it), but
|
|
193
|
+
* that other notation has no `_` marker of its own to show.
|
|
194
|
+
*/
|
|
195
|
+
indefiniteMarker?: boolean;
|
|
128
196
|
encodingWidth: EncodingWidth | undefined;
|
|
129
197
|
/**
|
|
130
198
|
* Where the resolved encoding-indicator suffix is placed.
|
|
@@ -142,20 +210,72 @@ export declare function serializeContainer(p: {
|
|
|
142
210
|
* this to its encoded content's byte length instead.
|
|
143
211
|
*/
|
|
144
212
|
canonicalCount?: () => bigint;
|
|
145
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Whether entry `i` structurally has any captured comments (parse-time
|
|
215
|
+
* presence only — not whether they'll actually be shown; see `hasComments`
|
|
216
|
+
* in the implementation, which additionally consults `entryOptions(i)` so
|
|
217
|
+
* an entry whose own override hides its comments doesn't force multi-line
|
|
218
|
+
* layout, and an entry whose own override *shows* comments the container's
|
|
219
|
+
* own `preserveComments` would otherwise hide still gets the chance to).
|
|
220
|
+
*/
|
|
221
|
+
hasEntryComments: (i: number) => boolean;
|
|
146
222
|
/** Render entry `i` at child depth (`item` or `key: value`). */
|
|
147
223
|
renderEntry: (i: number, colSep: string) => string;
|
|
148
224
|
/**
|
|
149
225
|
* Whether entry `i` contains no nested array/map, so it may stay on the
|
|
150
|
-
* container's line under `inlineLeafContainers
|
|
151
|
-
*
|
|
152
|
-
*
|
|
226
|
+
* container's line under `inlineLeafContainers` (or always, when
|
|
227
|
+
* `alwaysInlineLeaf` is set). Omitted = always a leaf (used by
|
|
228
|
+
* `CborEmbeddedCBOR`, where an entry that is itself a container still
|
|
229
|
+
* inlines as long as its own rendering fits on one line).
|
|
153
230
|
*/
|
|
154
231
|
entryIsLeaf?: (i: number) => boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Whether entry `i` is, or wraps, a text string or byte string with two or
|
|
234
|
+
* more words (`isMultiWordText` / `isMultiWordByteString`). When true,
|
|
235
|
+
* disqualifies the container from staying on one line under
|
|
236
|
+
* `inlineLeafContainers` (or `alwaysInlineLeaf`) even though the entry has
|
|
237
|
+
* no nested array/map — a multi-word string reads better with a line of
|
|
238
|
+
* its own. This does *not* also cover a prefixed literal like `h'...'`
|
|
239
|
+
* (which has no word count to check at all, but still disqualifies under
|
|
240
|
+
* the strict rule) — that's covered separately, generically, by
|
|
241
|
+
* `isPrefixedLiteralText` (checked against the rendered entry `s` below)
|
|
242
|
+
* or, for a `CborTag`, `isMultiWordRenderedLiteral`. Omitted = never
|
|
243
|
+
* disqualifies.
|
|
244
|
+
*/
|
|
245
|
+
entryIsMultiWordText?: (i: number) => boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Always run the one-line collapse probe, regardless of
|
|
248
|
+
* `options.inlineLeafContainers`. Set only by `CborEmbeddedCBOR`
|
|
249
|
+
* (`<<...>>`): unlike `CborArray`/`CborMap`, where spreading entries one
|
|
250
|
+
* per line is a deliberate structural default that `inlineLeafContainers`
|
|
251
|
+
* opts out of, a flat sequence of encoded items has no such structure to
|
|
252
|
+
* display — there's nothing gained by always breaking it, so it
|
|
253
|
+
* collapses onto one line whenever it fits independent of the option.
|
|
254
|
+
* Indefinite-length string groups (`(_ "a", "b")`) do *not* get this
|
|
255
|
+
* treatment — they follow CborArray/CborMap's option-gated default
|
|
256
|
+
* instead, providing `entryIsLeaf` the same way (see `strict` below),
|
|
257
|
+
* despite also being a "loose rule" container in the
|
|
258
|
+
* `_containsCdnContainer`/`entryHasContainer` sense (a chunk can never
|
|
259
|
+
* actually be an array/map, so that distinction is moot for them in
|
|
260
|
+
* practice). This flag and the loose/strict distinction are genuinely
|
|
261
|
+
* independent concerns, not the same thing.
|
|
262
|
+
*/
|
|
263
|
+
alwaysInlineLeaf?: boolean;
|
|
155
264
|
/** Node whose leading comments are emitted above entry `i` (item / map key). */
|
|
156
265
|
entryLeadingNode: (i: number) => Commented;
|
|
157
266
|
/** Pre-formatted trailing comment text for entry `i` (starts with ' ', or ''). */
|
|
158
267
|
entryTrailing: (i: number, style: 'c-style' | 'cdn-style' | undefined) => string;
|
|
268
|
+
/**
|
|
269
|
+
* Per-entry options for entry `i`'s own comment handling (whether to
|
|
270
|
+
* emit its comments at all, and in which style) — distinct from
|
|
271
|
+
* `options` above, which still governs the container-wide layout
|
|
272
|
+
* decisions (single-line vs multi-line, `hasComments`'s own gate, the
|
|
273
|
+
* container's own dangling comments). Omitted when the caller never
|
|
274
|
+
* resolves per-entry options at all (`toCDN()`'s `itemOptions` isn't in
|
|
275
|
+
* play), in which case every entry falls back to `options` — identical
|
|
276
|
+
* to this parameter not existing.
|
|
277
|
+
*/
|
|
278
|
+
entryOptions?: (i: number) => ToCDNOptions | undefined;
|
|
159
279
|
}): string;
|
|
160
280
|
/**
|
|
161
281
|
* Single-child counterpart to `serializeContainer`, for a wrapper that
|
|
@@ -176,9 +296,105 @@ export declare function serializeContainer(p: {
|
|
|
176
296
|
* rendering, `depth` otherwise (matching a plain value's existing
|
|
177
297
|
* "transparent" nesting — `tag(content)` doesn't indent `content` an extra
|
|
178
298
|
* level when there's nothing to justify going multi-line for).
|
|
299
|
+
*
|
|
300
|
+
* `childOptions` — the child's own resolved options, distinct from
|
|
301
|
+
* `options` (the wrapper's) when `toCDN()`'s `itemOptions` has overridden
|
|
302
|
+
* something for the child specifically (see `CborTag._toCDN`) — governs
|
|
303
|
+
* only the child's *own* leading/trailing comments (whether to show them
|
|
304
|
+
* at all, and in which style); `options` still governs whether to go
|
|
305
|
+
* multi-line at all and the wrapper's own dangling comments, the same way
|
|
306
|
+
* `serializeContainer`'s container-wide `options` does for its own
|
|
307
|
+
* dangling comments even when its `entryOptions` resolves per-entry ones.
|
|
179
308
|
*/
|
|
180
|
-
export declare function renderSingleChildWithComments(child: Commented, wrapper: Commented, options: ToCDNOptions | undefined, depth: number, renderChild: (childDepth: number) => string, openChar: '(', closeChar: ')'): string;
|
|
309
|
+
export declare function renderSingleChildWithComments(child: Commented, wrapper: Commented, options: ToCDNOptions | undefined, childOptions: ToCDNOptions | undefined, depth: number, renderChild: (childDepth: number) => string, openChar: '(', closeChar: ')'): string;
|
|
181
310
|
export declare function serializeBytes(bytes: Uint8Array, encoding?: 'hex' | 'base64' | 'base64url' | 'base32' | 'base32hex', sqstr?: 'printable-string' | 'string' | 'none'): string;
|
|
311
|
+
/**
|
|
312
|
+
* True when `bytes` would render as a bare sqstr literal (`'...'`) under
|
|
313
|
+
* `sqstr` *and* its decoded text has two or more words — same rule as a
|
|
314
|
+
* plain text string's own word count. Otherwise (it would render as a
|
|
315
|
+
* prefixed literal like `h'...'`/`b64'...'`, or as something else entirely
|
|
316
|
+
* via a subclass overriding `_toCDN()`) this returns `false`: a prefixed
|
|
317
|
+
* literal has no natural word boundary to predict from raw bytes alone,
|
|
318
|
+
* and — unlike this function, which never renders anything — the actual
|
|
319
|
+
* "does the real output look like a disqualifying prefixed literal, tag
|
|
320
|
+
* wrapping, or app-sequence spelling" question is answered generically
|
|
321
|
+
* from the *rendered* text instead, by `isPrefixedLiteralText` (for a bare
|
|
322
|
+
* entry) or `isMultiWordRenderedLiteral` (for a `CborTag`, which needs to
|
|
323
|
+
* see through its own digits/parens onto whatever they wrap).
|
|
324
|
+
*/
|
|
325
|
+
export declare function isMultiWordByteString(bytes: Uint8Array, sqstr?: 'printable-string' | 'string' | 'none'): boolean;
|
|
326
|
+
/**
|
|
327
|
+
* True when `rendered` — a single entry's own CDN rendering — is shaped
|
|
328
|
+
* like a prefixed literal: an identifier immediately followed by `'` or a
|
|
329
|
+
* backtick (`h'...'`, `b64'...'`, `ip'...'`, `dt'...'`, or any other
|
|
330
|
+
* app-string extension's own spelling, built-in or user-defined). These
|
|
331
|
+
* have no natural word boundary to check, so — like a byte string's own
|
|
332
|
+
* prefixed-literal case in `isMultiWordByteString` — the strict
|
|
333
|
+
* `inlineLeafContainers` rule (`CborArray`/`CborMap`, and the
|
|
334
|
+
* indefinite-length string groups) always disqualifies a container from
|
|
335
|
+
* collapsing onto one line when an entry looks like this; the loose rule
|
|
336
|
+
* (only `CborEmbeddedCBOR`/`<<...>>`) treats it as an ordinary leaf
|
|
337
|
+
* instead.
|
|
338
|
+
*
|
|
339
|
+
* This is a generic, rendering-based catch-all — unlike `isMultiWordByteString`,
|
|
340
|
+
* it doesn't need per-extension-class support, so it also covers any
|
|
341
|
+
* app-string extension (registered under `CborExtension.appStringPrefixes`)
|
|
342
|
+
* without that extension's own `CborItem` subclass needing to know about
|
|
343
|
+
* `inlineLeafContainers` at all. It only sees a *bare* prefixed literal
|
|
344
|
+
* (nothing else in `rendered`); `CborTag` uses `isMultiWordRenderedLiteral`
|
|
345
|
+
* instead to see through its own tag digits/parens onto whatever they wrap.
|
|
346
|
+
*/
|
|
347
|
+
export declare function isPrefixedLiteralText(rendered: string): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* True when `rendered` — a leaf entry's own, already-rendered CDN text —
|
|
350
|
+
* counts as multi-word for `inlineLeafContainers`'s purposes, determined by
|
|
351
|
+
* tokenizing `rendered` itself rather than predicting from whichever
|
|
352
|
+
* `CborItem` subclass produced it. This makes it exact regardless of *how*
|
|
353
|
+
* the text came to look the way it does — a `CborTag` subclass
|
|
354
|
+
* (`CborTaggedIpExt`) overriding `_toCDN()` to render `IP<<'...'>>` instead
|
|
355
|
+
* of generic `52(...)` tag notation, a preserved `preserveByteString`
|
|
356
|
+
* spelling, `encodingIndicators: 'always'` adding an explicit `_N`/`_i`
|
|
357
|
+
* suffix everywhere, or anything else — since it never assumes a rendering
|
|
358
|
+
* path, only reads the result.
|
|
359
|
+
*
|
|
360
|
+
* Recognizes these shapes. Any of them may be followed by one trailing
|
|
361
|
+
* `ENCODING_INDICATOR` token (`_0`.._3`/`_i`) — stripped *before* any shape
|
|
362
|
+
* is recognized (not just for a bare literal), since it can trail a tag or
|
|
363
|
+
* an app-sequence wrapper too and never changes a value's own shape or
|
|
364
|
+
* word count:
|
|
365
|
+
* - A bare quoted literal (`"..."`, `` `...` ``, or a bare `'...'` sqstr):
|
|
366
|
+
* always counts if its *decoded* content has two or more words,
|
|
367
|
+
* regardless of `strict` — matching a text string's own word count.
|
|
368
|
+
* - A prefixed literal (`h'...'`, `b64'...'`, `ip'...'`, `dt'...'`, ...):
|
|
369
|
+
* has no natural word boundary to check, so it counts only when `strict`.
|
|
370
|
+
* - A generic tag wrapper (`tagNum[_EI](...)`) spanning the *entire* input:
|
|
371
|
+
* peels off just that one layer and recurses on what's inside (handling
|
|
372
|
+
* nested tags one layer at a time) — this is what lets a plain `CborTag`
|
|
373
|
+
* whose content is one of the shapes above still count, e.g.
|
|
374
|
+
* `100(dt'...')`, `100("two words")`, or (with `encodingIndicators:
|
|
375
|
+
* 'always'`) `100_0("two words"_i)`.
|
|
376
|
+
* - An app-sequence wrapper (`prefix<<item item ...>>`, tokenized as one
|
|
377
|
+
* `APP_SEQUENCE` opener and a plain `GT_GT` closer) spanning the *entire*
|
|
378
|
+
* input: unlike a tag, its own `<<...>>` is never peeled away — reading
|
|
379
|
+
* fine inline is the whole point of that notation, not a transparent
|
|
380
|
+
* single-value rewrap — but each top-level item inside (items may be
|
|
381
|
+
* separated by a comma, by whitespace alone, or both, per CDN's own
|
|
382
|
+
* grammar — `consumeOneItem` finds each one's extent structurally rather
|
|
383
|
+
* than only splitting at commas) is checked under the *loose* rule
|
|
384
|
+
* (`strict: false`, matching `<<...>>` itself) regardless of the
|
|
385
|
+
* `strict` this function was called with, so a multi-word text item
|
|
386
|
+
* (`ilts<<"two words">>`, or `ilts<<"two words" "x">>` with no comma at
|
|
387
|
+
* all) still always counts, while a prefixed-literal item
|
|
388
|
+
* (`ilbs<<h'00'>>`) — unlike the same literal bare or tag-wrapped —
|
|
389
|
+
* does not.
|
|
390
|
+
* - Anything else (a number, `true`/`false`, multiple top-level tokens that
|
|
391
|
+
* aren't one of the wrappers above, ...) never counts.
|
|
392
|
+
*
|
|
393
|
+
* Tokenizing can throw on malformed input; since `rendered` is always this
|
|
394
|
+
* library's own output, that should never happen, but a failure is treated
|
|
395
|
+
* as "not multi-word" rather than propagating.
|
|
396
|
+
*/
|
|
397
|
+
export declare function isMultiWordRenderedLiteral(rendered: string, strict: boolean): boolean;
|
|
182
398
|
/**
|
|
183
399
|
* Which comment syntax a byte-string literal's raw source recognizes —
|
|
184
400
|
* `undefined` when it has none at all (its content is data, not a comment
|
|
@@ -188,12 +404,12 @@ export declare function serializeBytes(bytes: Uint8Array, encoding?: 'hex' | 'ba
|
|
|
188
404
|
* `b32`/`h32` objects by reference — never guessed later from the prefix
|
|
189
405
|
* string, since a user extension can register under any prefix, including
|
|
190
406
|
* one a built-in also uses; see `CborByteString.ednCommentSyntax`).
|
|
191
|
-
* - `'full'`: `#`, `//`, `/* *\/`, and `/ /` (§
|
|
407
|
+
* - `'full'`: `#`, `//`, `/* *\/`, and `/ /` (§6.2.1/§6.3.3) — `h'...'`
|
|
192
408
|
* and its backtick form, and the built-in `b32'...'`/`h32'...'`
|
|
193
409
|
* extensions, which share hex's comment syntax (`utils/strip-comments.ts`).
|
|
194
410
|
* - `'hash-only'`: only `#` line comments — standard base64 (`b64'...'`),
|
|
195
411
|
* where `/` is valid data (e.g. `//8=` decodes to 0xFFFF), never a
|
|
196
|
-
* comment marker (see Tokenizer._readByteContent, §
|
|
412
|
+
* comment marker (see Tokenizer._readByteContent, §6.2.2).
|
|
197
413
|
*/
|
|
198
414
|
export type ByteCommentSyntax = 'full' | 'hash-only';
|
|
199
415
|
/**
|
|
@@ -223,6 +439,16 @@ export declare function escapeAppString(s: string): string;
|
|
|
223
439
|
* Produce an EDN double-quoted string literal `"..."` from a string value.
|
|
224
440
|
*/
|
|
225
441
|
export declare function escapeString(s: string): string;
|
|
442
|
+
/**
|
|
443
|
+
* True when `value` contains two or more "words" per `Intl.Segmenter`'s
|
|
444
|
+
* word-boundary rules (UAX #29): e.g. `"Hello, World!"` is two words (a
|
|
445
|
+
* comma breaks them), `"3.14"` is one (a decimal point between digits
|
|
446
|
+
* doesn't), and space-less scripts like Japanese/Chinese still split on
|
|
447
|
+
* their own dictionary-based word boundaries. Used by `inlineLeafContainers`
|
|
448
|
+
* to keep a multi-word string entry off the container's shared line even
|
|
449
|
+
* when it would otherwise qualify as a leaf.
|
|
450
|
+
*/
|
|
451
|
+
export declare function isMultiWordText(value: string): boolean;
|
|
226
452
|
/** Produce the numeric string for a float value (with decimal point if needed). */
|
|
227
453
|
export declare function floatValueToString(value: number): string;
|
|
228
454
|
/**
|
|
@@ -241,13 +467,13 @@ export declare function canonicalEncodingWidth(n: bigint): EncodingWidth;
|
|
|
241
467
|
* @param getCanonical - lazily compute the canonical width (only called in 'always' mode)
|
|
242
468
|
*/
|
|
243
469
|
export declare function resolveEiSuffix(options: ToCDNOptions | undefined, encodingWidth: EncodingWidth | undefined, getCanonical: () => EncodingWidth): string;
|
|
244
|
-
/** How a node should render under `
|
|
470
|
+
/** How a node should render under `preserveAppPrefix`. */
|
|
245
471
|
export type AppSeqRenderDecision = 'verbatim' | 'adjusted' | 'source' | 'structural' | 'normal';
|
|
246
472
|
/**
|
|
247
473
|
* Decide how an extension result node — from a `prefix'...'` /
|
|
248
474
|
* `` prefix`...` `` / `prefix<<...>>` source, or (for a tag-wrapper node
|
|
249
475
|
* that also has a generic `CborTag` fallback to delegate to) a raw tag
|
|
250
|
-
* literal `N(...)` — should render under `ToCDNOptions.
|
|
476
|
+
* literal `N(...)` — should render under `ToCDNOptions.preserveAppPrefix`.
|
|
251
477
|
*
|
|
252
478
|
* A raw-tag source is recognised by `ednSource !== undefined`: the parser
|
|
253
479
|
* only ever sets a tag-wrapper's `ednSource` (the tag *number's* digit
|
|
@@ -282,7 +508,7 @@ export type AppSeqRenderDecision = 'verbatim' | 'adjusted' | 'source' | 'structu
|
|
|
282
508
|
* `preserveConcatenation` override.
|
|
283
509
|
* Verbatim raw-tag text inherently contains the nested literal spelling.
|
|
284
510
|
* - `'normal'`: fall through to the class's own notation regeneration
|
|
285
|
-
* (`prefix'...'`), unaffected by `
|
|
511
|
+
* (`prefix'...'`), unaffected by `preserveAppPrefix`. For `<<...>>`,
|
|
286
512
|
* this is also used when replaying its sole inner item would defeat an
|
|
287
513
|
* explicitly disabled, relevant literal-preservation option.
|
|
288
514
|
*
|
|
@@ -313,3 +539,4 @@ export declare function adjustRawAppSeqSource(appSeqSource: string, options: ToC
|
|
|
313
539
|
* reliable way to locate it.
|
|
314
540
|
*/
|
|
315
541
|
export declare function adjustAppSeqIndicator(appSeqSource: string, newSuffix: string, options: ToCDNOptions | undefined, innerItemEnd: number | undefined, comments: readonly CborComment[] | undefined): string;
|
|
542
|
+
export {};
|
package/dist/cdn/tokenizer.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare class Tokenizer {
|
|
|
81
81
|
* Returns true if a comment was consumed, false if the current char is not a
|
|
82
82
|
* comment start. `quote` is the closing delimiter character.
|
|
83
83
|
*
|
|
84
|
-
* Supports / ... /, /* *\/, //, and # comment forms (§2.
|
|
84
|
+
* Supports / ... /, /* *\/, //, and # comment forms (§2.1).
|
|
85
85
|
*/
|
|
86
86
|
private _skipByteStringComment;
|
|
87
87
|
/**
|
|
@@ -98,7 +98,7 @@ export declare class Tokenizer {
|
|
|
98
98
|
* Called with `i` pointing at the comment-start character.
|
|
99
99
|
* Returns the index after the comment, or -1 if no comment was found.
|
|
100
100
|
*
|
|
101
|
-
* Supports / ... /, /* *\/, //, and # comment forms (§2.
|
|
101
|
+
* Supports / ... /, /* *\/, //, and # comment forms (§2.1).
|
|
102
102
|
* `context` is used in unterminated-comment error messages.
|
|
103
103
|
*/
|
|
104
104
|
private _skipRawComment;
|
|
@@ -113,13 +113,13 @@ export declare class Tokenizer {
|
|
|
113
113
|
* - Literal LF (U+000A) is allowed; all other C0 controls and U+007F are rejected.
|
|
114
114
|
* - Literal CR (U+000D) is silently stripped (source-level CRLF normalisation).
|
|
115
115
|
* - Only spec-defined escape sequences are accepted; `\q` etc. throw SyntaxError.
|
|
116
|
-
* - `\/` is valid only in double-quoted strings (not in escapable-s, §
|
|
116
|
+
* - `\/` is valid only in double-quoted strings (not in escapable-s, §6.1).
|
|
117
117
|
* - `\\` (backslash) is valid in both single- and double-quoted strings.
|
|
118
118
|
* - `\uXXXX` for a high surrogate must be immediately followed by `\uXXXX` for
|
|
119
119
|
* the corresponding low surrogate; lone surrogates are rejected.
|
|
120
120
|
* - `\u{N}` … `\u{10FFFF}` extended syntax is supported; surrogates are rejected.
|
|
121
121
|
* - In single-quoted strings, `\u` escapes to printable ASCII (U+0020–U+007E)
|
|
122
|
-
* are forbidden (hexchar-s restriction, draft-
|
|
122
|
+
* are forbidden (hexchar-s restriction, draft-ietf-cbor-edn-literals-27 §6.1).
|
|
123
123
|
*/
|
|
124
124
|
private _readStringContent;
|
|
125
125
|
/**
|
|
@@ -134,13 +134,14 @@ export declare class Tokenizer {
|
|
|
134
134
|
* which is then decoded into the corresponding non-BMP code point.
|
|
135
135
|
*
|
|
136
136
|
* In single-quoted strings (`quote === "'"`), `\u` escapes that resolve to
|
|
137
|
-
* printable ASCII (U+0020–U+007E) are rejected per draft-
|
|
137
|
+
* printable ASCII (U+0020–U+007E) are rejected per draft-ietf-cbor-edn-literals-27
|
|
138
|
+
* §6.1 hexchar-s.
|
|
138
139
|
* Use `\\` for backslash (U+005C) and `\'` for the single-quote delimiter.
|
|
139
140
|
*/
|
|
140
141
|
private _readUnicodeEscape;
|
|
141
142
|
/**
|
|
142
143
|
* Read raw text-string content between N-backtick delimiters
|
|
143
|
-
* (§2.
|
|
144
|
+
* (§2.3.3 of draft-ietf-cbor-edn-literals-27).
|
|
144
145
|
*
|
|
145
146
|
* - The opening delimiter is the maximal run of consecutive backticks (N ≥ 1).
|
|
146
147
|
* - No escape sequences are processed — content is taken verbatim.
|
|
@@ -153,7 +154,7 @@ export declare class Tokenizer {
|
|
|
153
154
|
*/
|
|
154
155
|
private _readRawStringContent;
|
|
155
156
|
/**
|
|
156
|
-
* Post-process raw hex content from a `h``…``\` raw string (§
|
|
157
|
+
* Post-process raw hex content from a `h``…``\` raw string (§6.3.3).
|
|
157
158
|
*
|
|
158
159
|
* Skips:
|
|
159
160
|
* - lblank whitespace (LF, SP; also CR for source-level normalisation)
|
|
@@ -162,13 +163,13 @@ export declare class Tokenizer {
|
|
|
162
163
|
* Detects `...` ellipsis sequences.
|
|
163
164
|
*
|
|
164
165
|
* A trailing `# comment` immediately before the closing delimiter is allowed
|
|
165
|
-
* per §
|
|
166
|
+
* per §6.3.3 `r-app-string-h`.
|
|
166
167
|
*
|
|
167
168
|
* Returns { value: hex-string-with-ellipsis-markers, elided: boolean }
|
|
168
169
|
*/
|
|
169
170
|
private _processRawHexContent;
|
|
170
171
|
/**
|
|
171
|
-
* Post-process raw base64 content from a `b64``…``\` raw string (§
|
|
172
|
+
* Post-process raw base64 content from a `b64``…``\` raw string (§6.3.4).
|
|
172
173
|
*
|
|
173
174
|
* Skips:
|
|
174
175
|
* - lblank whitespace (LF, SP; also CR for source-level normalisation)
|
|
@@ -180,12 +181,12 @@ export declare class Tokenizer {
|
|
|
180
181
|
/**
|
|
181
182
|
* Read raw byte-string content between `quote` chars (b64 / b64url).
|
|
182
183
|
*
|
|
183
|
-
* Strips whitespace and skips `# ...` line comments per §2.
|
|
184
|
+
* Strips whitespace and skips `# ...` line comments per §6.2.2.
|
|
184
185
|
* `/` is NOT treated as a comment delimiter because it is a valid base64 character.
|
|
185
186
|
*/
|
|
186
187
|
private _readByteContent;
|
|
187
188
|
/**
|
|
188
|
-
* Read hex byte-string content, recognising `...` ellipsis sequences (§
|
|
189
|
+
* Read hex byte-string content, recognising `...` ellipsis sequences (§5.2).
|
|
189
190
|
*
|
|
190
191
|
* Returns the raw hex string (with `...` markers embedded) and a flag
|
|
191
192
|
* indicating whether any ellipsis was found.
|
|
@@ -2,17 +2,17 @@ import { CborExtension } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Core data-model extensions (bignum tags 2/3, embedded-CBOR tag 24, and the
|
|
4
4
|
* CPA888 ellipsis tag). These implement base CBOR/EDN representation rather
|
|
5
|
-
* than an
|
|
6
|
-
*
|
|
5
|
+
* than an app-extension, so they are always active and are not affected by
|
|
6
|
+
* the `builtinExtensions` option.
|
|
7
7
|
*/
|
|
8
8
|
export declare const CORE_EXTENSIONS: readonly CborExtension[];
|
|
9
9
|
/**
|
|
10
|
-
* Default
|
|
10
|
+
* Default app-extensions bundled with the library.
|
|
11
11
|
* Overridable per call via `builtinExtensions` (an array to use instead, or
|
|
12
12
|
* `false` to disable all of them).
|
|
13
13
|
*
|
|
14
|
-
* `dt`, `ip`, `t1`, and `b1` are mandatory-to-implement per §
|
|
15
|
-
* draft-ietf-cbor-edn-literals-
|
|
14
|
+
* `dt`, `ip`, `t1`, and `b1` are mandatory-to-implement per §3 of
|
|
15
|
+
* draft-ietf-cbor-edn-literals-27; `cri`, `ilbs`, `ilts`, and `float` are
|
|
16
16
|
* bundled but not mandatory.
|
|
17
17
|
*/
|
|
18
18
|
export declare const BUILTIN_EXTENSIONS: readonly CborExtension[];
|
package/dist/extensions/cri.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CborExtension } from './types';
|
|
|
3
3
|
import { CborArray } from '../ast/CborArray';
|
|
4
4
|
import { CborTag } from '../ast/CborTag';
|
|
5
5
|
/**
|
|
6
|
-
* CBOR tag number for the tagged CRI variant (§3.
|
|
6
|
+
* CBOR tag number for the tagged CRI variant (§3.7 and §6.2.5 of draft-ietf-cbor-edn-literals-27).
|
|
7
7
|
*/
|
|
8
8
|
export declare const TAG_CRI = 99n;
|
|
9
9
|
/**
|
|
@@ -11,7 +11,7 @@ export declare const TAG_CRI = 99n;
|
|
|
11
11
|
* Falls back to generic array notation if the content cannot be expressed as a URI.
|
|
12
12
|
*/
|
|
13
13
|
export declare class CborCriExt extends CborArray {
|
|
14
|
-
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
14
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number, path?: readonly unknown[]): string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* tag(99, CRI array) whose toCDN() emits CRI'…' notation.
|
|
@@ -19,10 +19,10 @@ export declare class CborCriExt extends CborArray {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class CborTaggedCriExt extends CborTag {
|
|
21
21
|
constructor(content: CborArray);
|
|
22
|
-
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
22
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number, path?: readonly unknown[]): string;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Create the cri/CRI CborExtension (§3.
|
|
25
|
+
* Create the cri/CRI CborExtension (§3.7 and §6.2.5 of draft-ietf-cbor-edn-literals-27).
|
|
26
26
|
*
|
|
27
27
|
* - `cri'uri'` → CborCriExt (bare CRI array, no CBOR tag)
|
|
28
28
|
* - `CRI'uri'` → CborTaggedCriExt tag(99, CRI array)
|
package/dist/extensions/dt.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class CborEpochDtExtUint extends CborUint {
|
|
|
32
32
|
encodingWidth?: EncodingWidth;
|
|
33
33
|
ednSource?: string;
|
|
34
34
|
});
|
|
35
|
-
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
35
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number, path?: readonly unknown[]): string;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Negative epoch timestamp whose toCDN() emits dt'…' notation.
|
|
@@ -43,7 +43,7 @@ export declare class CborEpochDtExtNint extends CborNint {
|
|
|
43
43
|
encodingWidth?: EncodingWidth;
|
|
44
44
|
ednSource?: string;
|
|
45
45
|
});
|
|
46
|
-
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
46
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number, path?: readonly unknown[]): string;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Float epoch timestamp whose toCDN() emits dt'…' notation.
|
|
@@ -54,7 +54,7 @@ export declare class CborEpochDtExtFloat extends CborFloat {
|
|
|
54
54
|
precision?: 'half' | 'single' | 'double';
|
|
55
55
|
literalSource?: string;
|
|
56
56
|
});
|
|
57
|
-
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
57
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number, path?: readonly unknown[]): string;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* CBOR tag(1, epoch) whose toCDN() emits DT'…' notation.
|
|
@@ -64,7 +64,7 @@ export declare class CborTaggedEpochDtExt extends CborTag {
|
|
|
64
64
|
constructor(datetimeOrContent: string | CborEpochDtExtUint | CborEpochDtExtNint | CborEpochDtExtFloat, options?: {
|
|
65
65
|
encodingWidth?: EncodingWidth;
|
|
66
66
|
});
|
|
67
|
-
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
67
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number, path?: readonly unknown[]): string;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* CBOR tag(1, epoch) whose toJS() returns a plain Date object.
|
package/dist/extensions/ip.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { CborArray } from '../ast/CborArray';
|
|
|
8
8
|
* Bare IP address byte string whose toCDN() emits ip'…' notation.
|
|
9
9
|
*/
|
|
10
10
|
export declare class CborIpExt extends CborByteString {
|
|
11
|
-
_toCDN(options: ToCDNOptions | undefined, _depth: number): string;
|
|
11
|
+
_toCDN(options: ToCDNOptions | undefined, _depth: number, path?: readonly unknown[]): string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Bare IP address prefix (CIDR) whose toCDN() emits ip'…/prefix' notation.
|
|
@@ -17,7 +17,7 @@ export declare class CborIpExt extends CborByteString {
|
|
|
17
17
|
export declare class CborIpPrefixExt extends CborArray {
|
|
18
18
|
private readonly _isV4;
|
|
19
19
|
constructor(prefixLen: number, truncated: Uint8Array, isV4: boolean);
|
|
20
|
-
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
20
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number, path?: readonly unknown[]): string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* CBOR tag(52/54, …) IP address whose toCDN() emits IP'…' notation.
|
|
@@ -26,10 +26,10 @@ export declare class CborIpPrefixExt extends CborArray {
|
|
|
26
26
|
*/
|
|
27
27
|
export declare class CborTaggedIpExt extends CborTag {
|
|
28
28
|
constructor(tag: bigint, content: CborItem);
|
|
29
|
-
_toCDN(options: ToCDNOptions | undefined, depth: number): string;
|
|
29
|
+
_toCDN(options: ToCDNOptions | undefined, depth: number, path?: readonly unknown[]): string;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Create an ip/IP CborExtension (RFC 9164 / §3.
|
|
32
|
+
* Create an ip/IP CborExtension (RFC 9164 / §3.3 of draft-ietf-cbor-edn-literals-27).
|
|
33
33
|
*
|
|
34
34
|
* - `ip'addr'` → CborIpExt (bare byte string, 4 or 16 bytes)
|
|
35
35
|
* - `IP'addr'` → CborTaggedIpExt tag(52 or 54, bytes)
|