@cbortech/cbor 0.26.7 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.ja.md +120 -47
  2. package/README.md +121 -48
  3. package/dist/ast/CborAppSeqResult.d.ts +22 -0
  4. package/dist/ast/CborByteString.d.ts +27 -0
  5. package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
  6. package/dist/ast/CborFloat.d.ts +1 -1
  7. package/dist/ast/CborIndefiniteByteString.d.ts +24 -0
  8. package/dist/ast/CborIndefiniteTextString.d.ts +16 -0
  9. package/dist/ast/CborItem.d.ts +44 -4
  10. package/dist/ast/CborTag.d.ts +27 -0
  11. package/dist/ast/CborTextString.d.ts +18 -1
  12. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  13. package/dist/ast/index.cjs +1 -1
  14. package/dist/ast/index.d.ts +1 -0
  15. package/dist/ast/index.js +2 -2
  16. package/dist/cddl/index.cjs +1 -1
  17. package/dist/cddl/index.js +1 -1
  18. package/dist/cdn/index.cjs +2 -2
  19. package/dist/cdn/index.cjs.map +1 -1
  20. package/dist/cdn/index.d.ts +2 -0
  21. package/dist/cdn/index.js +15 -15
  22. package/dist/cdn/index.js.map +1 -1
  23. package/dist/cdn/serialize-utils.d.ts +241 -21
  24. package/dist/cdn/tokenizer.d.ts +12 -11
  25. package/dist/extensions/builtins.d.ts +5 -5
  26. package/dist/extensions/cri.d.ts +2 -2
  27. package/dist/extensions/ip.d.ts +1 -1
  28. package/dist/extensions/types.d.ts +4 -4
  29. package/dist/index.cjs +3 -3
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +158 -158
  33. package/dist/index.js.map +1 -1
  34. package/dist/mapEntries-C1f7G0AM.cjs +13 -0
  35. package/dist/mapEntries-C1f7G0AM.cjs.map +1 -0
  36. package/dist/{mapEntries-DxrDre2P.js → mapEntries-CvLdiN0h.js} +1479 -1558
  37. package/dist/mapEntries-CvLdiN0h.js.map +1 -0
  38. package/dist/{schema-Bofmsptw.js → schema-CNfrVRYp.js} +294 -294
  39. package/dist/{schema-Bofmsptw.js.map → schema-CNfrVRYp.js.map} +1 -1
  40. package/dist/schema-iXpYtKQl.cjs +63 -0
  41. package/dist/{schema-t_bdPk8_.cjs.map → schema-iXpYtKQl.cjs.map} +1 -1
  42. package/dist/{tokenizer-CeuixxXi.js → serialize-utils-BuIZPaUc.js} +634 -30
  43. package/dist/serialize-utils-BuIZPaUc.js.map +1 -0
  44. package/dist/serialize-utils-CjTqQivB.cjs +37 -0
  45. package/dist/serialize-utils-CjTqQivB.cjs.map +1 -0
  46. package/dist/types.d.ts +248 -64
  47. package/dist/utils/base64.d.ts +1 -1
  48. package/dist/utils/hexfloat.d.ts +1 -1
  49. package/dist/utils/strip-comments.d.ts +1 -1
  50. package/package.json +8 -7
  51. package/dist/mapEntries-D2NyeCX3.cjs +0 -17
  52. package/dist/mapEntries-D2NyeCX3.cjs.map +0 -1
  53. package/dist/mapEntries-DxrDre2P.js.map +0 -1
  54. package/dist/schema-t_bdPk8_.cjs +0 -63
  55. package/dist/tokenizer-CeuixxXi.js.map +0 -1
  56. package/dist/tokenizer-EciPlN0n.cjs +0 -30
  57. package/dist/tokenizer-EciPlN0n.cjs.map +0 -1
@@ -9,6 +9,17 @@ export interface CborByteStringPart {
9
9
  source?: string;
10
10
  /** Which comment syntax `source` recognizes, if any — see `ednCommentSyntax`. */
11
11
  commentSyntax?: ByteCommentSyntax;
12
+ /**
13
+ * Source span of this part's own literal token, when known — used to place
14
+ * a comment sitting between two `+`-joined parts (attached to the whole
15
+ * `CborByteString` as a `dangling` comment, since there is no per-part AST
16
+ * node for it to attach to) at the right gap in `_toCDN`'s
17
+ * `preserveConcatenation` branch. `undefined` for a part merged from a
18
+ * single elided literal's own internal segments, which cannot have a
19
+ * comment between them.
20
+ */
21
+ start?: number;
22
+ end?: number;
12
23
  }
13
24
  /** CBOR Major Type 2 — definite-length byte string. */
14
25
  export declare class CborByteString extends CborItem {
@@ -37,6 +48,22 @@ export declare class CborByteString extends CborItem {
37
48
  ednCommentSyntax?: ByteCommentSyntax;
38
49
  ednParts?: readonly CborByteStringPart[];
39
50
  });
51
+ /**
52
+ * Only the "bare sqstr text with 2+ words" case — the "is this a
53
+ * prefixed literal" question is deliberately *not* predicted here from
54
+ * raw bytes at all (a subclass like `CborIpExt` might override `_toCDN()`
55
+ * to render something else entirely, e.g. a preserved
56
+ * `ip<<'192.0.2.42'>>` app-sequence spelling, that raw-byte prediction
57
+ * knows nothing about — see `isMultiWordByteString`'s doc). That
58
+ * question is instead answered from the *actual rendering*: for a bare
59
+ * entry, `serializeContainer`'s own `isPrefixedLiteralText(s)` check
60
+ * already covers it (this node's render *is* `s`, unobscured); for one
61
+ * wrapped in a `CborTag`, `CborTag._isMultiWordText`'s
62
+ * `isMultiWordRenderedLiteral` check covers it instead. `strict` isn't
63
+ * needed here at all now — it's accepted purely for interface
64
+ * consistency with the base class.
65
+ */
66
+ _isMultiWordText(options: ToCDNOptions | undefined, _strict?: boolean): boolean;
40
67
  _encodeTo(writer: CborWriter, _options?: ToCBOROptions): void;
41
68
  _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
42
69
  _toJS(_options?: ToJSOptions): unknown;
@@ -2,7 +2,7 @@ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { CborWriter, EncodingWidth } from '../cbor/encode';
4
4
  /**
5
- * CBOR Sequence Literal (§2.5.6) — `<<item, item, ...>>`.
5
+ * CBOR Sequence Literal (§2.3.4) — `<<item, item, ...>>`.
6
6
  *
7
7
  * Encodes as a definite-length byte string whose value is the concatenation
8
8
  * of the CBOR encodings of the contained items.
@@ -22,7 +22,7 @@ export declare class CborFloat extends CborItem {
22
22
  /**
23
23
  * Original app-string source (e.g. `float'7e00'`), set by the parser when
24
24
  * this float is the result of a `float'...'` app-string. Used by toCDN()
25
- * to round-trip the literal when `appStrings` is not false.
25
+ * to round-trip the literal when `appPrefix` is not false.
26
26
  */
27
27
  ednSource?: string;
28
28
  /**
@@ -8,6 +8,30 @@ 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
+ /**
12
+ * True when any chunk's own decoded content, if it renders as bare sqstr
13
+ * text, has two or more words. Reachable when this node is a *direct*
14
+ * entry of another container (`[(_ "two words")]`) — though even then,
15
+ * its own `_toCDN()` already self-disqualifies internally in that case
16
+ * (a multi-word chunk forces a multi-line self-render), which the
17
+ * ordinary "entry's own rendering has a line break" check would catch
18
+ * regardless of what this method answers, so this mostly exists for
19
+ * robustness/consistency with `CborTextString`/`CborByteString` rather
20
+ * than because some case is otherwise unreachable.
21
+ *
22
+ * `CborAppSeqResult`, which wraps this node for results like
23
+ * `ilbs<<...>>`, does *not* delegate to this method — it tokenizes its
24
+ * own rendered output directly instead (`isMultiWordRenderedLiteral`),
25
+ * which is exactly why `ilbs<<h'00'>>` stays an ordinary leaf (checked
26
+ * under the loose rule, matching `<<...>>`) while `[h'00']`/`(_ h'00')`
27
+ * still always disqualify — this method's own `_strict` (always `true`,
28
+ * matching how a chunk renders when this container *is* regenerated
29
+ * directly) plays no part in that distinction anymore, and a byte string
30
+ * chunk's own `_isMultiWordText` doesn't consult `strict` at all
31
+ * regardless (see `CborByteString`'s doc — its "prefixed literal" case
32
+ * was removed there too).
33
+ */
34
+ _isMultiWordText(options: ToCDNOptions | undefined, _strict?: boolean): boolean;
11
35
  _toCDN(options: ToCDNOptions | undefined, depth: number): string;
12
36
  _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
13
37
  _toJS(_options?: ToJSOptions): unknown;
@@ -8,6 +8,22 @@ export declare class CborIndefiniteTextString extends CborItem {
8
8
  readonly chunks: CborTextString[];
9
9
  constructor(chunks: CborTextString[]);
10
10
  _encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
11
+ /**
12
+ * True when any chunk is multi-word. Reachable when this node is a
13
+ * *direct* entry of another container (`[(_ "two words")]`) — though even
14
+ * then, its own `_toCDN()` already self-disqualifies internally in that
15
+ * case, producing a multi-line self-render that the ordinary "entry's own
16
+ * rendering has a line break" check would catch regardless of what this
17
+ * method answers, so this mostly exists for robustness/consistency with
18
+ * `CborTextString`/`CborByteString` rather than because some case is
19
+ * otherwise unreachable. (`CborAppSeqResult`, which wraps this node for
20
+ * results like `ilts<<...>>`, does *not* delegate to this method — it
21
+ * tokenizes its own rendered output directly instead; see its doc for
22
+ * why that turned out to be necessary.) `_strict` is intentionally
23
+ * unused: a chunk is always CborTextString, whose own word count doesn't
24
+ * depend on it.
25
+ */
26
+ _isMultiWordText(options: ToCDNOptions | undefined, _strict?: boolean): boolean;
11
27
  _toCDN(options: ToCDNOptions | undefined, depth: number): string;
12
28
  _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
13
29
  _toJS(_options?: ToJSOptions): unknown;
@@ -19,7 +19,7 @@ export interface AppSeqEncodingEdit {
19
19
  * Original literal features used by the sole item inside a preserved
20
20
  * `prefix<<item>>` source. They let serialization honour an explicitly
21
21
  * disabled sibling `preserve*` option instead of replaying that literal
22
- * verbatim through `preserveAppSequence`.
22
+ * verbatim through `preserveAppPrefix`.
23
23
  */
24
24
  export interface AppSeqSourceFeatures {
25
25
  byteString?: boolean;
@@ -63,11 +63,11 @@ export declare abstract class CborItem {
63
63
  */
64
64
  blankLineBefore?: boolean;
65
65
  /**
66
- * Original application-string/-sequence source text — `prefix'...'`,
66
+ * Original app-string/-sequence source text — `prefix'...'`,
67
67
  * `` prefix`...` ``, or `prefix<<...>>` — set by the parser when the
68
68
  * resolving extension declares `preserveAppSeqSource: 'optional'`. A
69
69
  * subclass's own `_toCDN()` override may check this (gated behind
70
- * `ToCDNOptions.preserveAppSequence`) to round-trip the exact original
70
+ * `ToCDNOptions.preserveAppPrefix`) to round-trip the exact original
71
71
  * spelling instead of always regenerating `prefix'...'` notation from the
72
72
  * resolved value. Left `undefined` for nodes not parsed from one of these
73
73
  * forms.
@@ -77,7 +77,7 @@ export declare abstract class CborItem {
77
77
  * Comments contained within `appSeqSource`, with `start`/`end` offsets
78
78
  * relative to that string. These spans allow comment markers to be
79
79
  * converted (or comments to be removed) without regenerating and thereby
80
- * losing the original application-string/-sequence notation.
80
+ * losing the original app-string/-sequence notation.
81
81
  */
82
82
  appSeqComments?: CborComment[];
83
83
  /**
@@ -140,6 +140,46 @@ export declare abstract class CborItem {
140
140
  * `_toCDN()`, which omits `entryIsLeaf` for that reason.
141
141
  */
142
142
  get _containsCdnContainer(): boolean;
143
+ /**
144
+ * @internal
145
+ * True when this node's own text content (a text string, or a byte
146
+ * string that would render as bare sqstr text) has two or more words —
147
+ * `inlineLeafContainers` never collapses a container whose entries hold
148
+ * such a string onto the container's own line, even though the entry
149
+ * itself has no nested array/map, since a multi-word string reads better
150
+ * with room of its own. See `isMultiWordText()`/`isMultiWordByteString()`
151
+ * in `cdn/serialize-utils.ts`. Takes `options` because whether a byte
152
+ * string even renders as text (`'...'`) rather than a prefixed literal
153
+ * (`h'...'`, `b64'...'`, ...) depends on the `sqstr` option.
154
+ *
155
+ * This method deliberately does *not* also cover the "is this (or does
156
+ * it wrap) a prefixed literal" question — a prefixed literal has no word
157
+ * count to check, but still disqualifies under the strict rule (and, per
158
+ * `strict`, is an ordinary leaf under the loose one). That's handled
159
+ * generically elsewhere instead, from the *actual rendered text* rather
160
+ * than predicted from this node's type: `isPrefixedLiteralText` for a
161
+ * bare entry (`serializeContainer` checks it against the already
162
+ * rendered `s`), or `isMultiWordRenderedLiteral` for `CborTag`, which
163
+ * overrides this method entirely to tokenize its own `_toCDN()` output
164
+ * instead of delegating here — necessary because a `CborTag` subclass
165
+ * (`CborTaggedIpExt`, `CborTaggedEpochDtExt`, ...) may override `_toCDN()`
166
+ * to render something that doesn't look like generic `tagNum(content)`
167
+ * notation at all, which a semantic prediction from `this.content` alone
168
+ * could never know about.
169
+ *
170
+ * `strict` (default `true`) is passed down by whichever container's own
171
+ * `_toCDN` directly holds this entry: `true` for the strict rule
172
+ * (`CborArray`/`CborMap`, and `CborIndefiniteTextString`/
173
+ * `CborIndefiniteByteString` too — all four provide `entryIsLeaf`),
174
+ * `false` only for `CborEmbeddedCBOR` (`<<...>>`), the one container
175
+ * whose collapse isn't gated behind `inlineLeafContainers` at all and
176
+ * the only one that omits `entryIsLeaf`. This base implementation and
177
+ * `CborTextString`/`CborByteString`'s overrides ignore `strict` (a text
178
+ * string's, or byte string's own sqstr-text, word count is unaffected by
179
+ * it either way) — only `CborTag` (and, transitively, `CborAppSeqResult`
180
+ * delegating to its inner value) actually consult it.
181
+ */
182
+ _isMultiWordText(_options: ToCDNOptions | undefined, _strict?: boolean): boolean;
143
183
  /** Serialize this node to CBOR binary. */
144
184
  toCBOR(options?: ToCBOROptions): Uint8Array;
145
185
  /** Serialize this node to a CDN text string. */
@@ -18,6 +18,33 @@ export declare class CborTag extends CborItem {
18
18
  ednSource?: string;
19
19
  });
20
20
  get _containsCdnContainer(): boolean;
21
+ /**
22
+ * Checked by tokenizing `this._toCDN()`'s own actual output — not by
23
+ * delegating to `this.content._isMultiWordText()` (a semantic prediction
24
+ * from the AST) — because a subclass may override `_toCDN()` to render
25
+ * something that doesn't match generic `tagNum(content)` notation at all
26
+ * (`CborTaggedIpExt` renders `IP<<'192.0.2.42'>>`, `CborTaggedEpochDtExt`
27
+ * renders `DT'...'`/`DT<<...>>`, ...); a check based on `this.content`
28
+ * would be looking at the wrong thing entirely for those. Tokenizing the
29
+ * real output instead is exact regardless of which class produced it —
30
+ * see `isMultiWordRenderedLiteral`, which also handles the plain,
31
+ * generic-tag case (peeling `tagNum[_EI](...)` to see what's inside, so
32
+ * `100(dt'...')` and `100("two words")` still work the same as before).
33
+ *
34
+ * Deliberately *not* cached: an earlier version cached this render on
35
+ * the instance keyed by `options` reference alone, which was wrong two
36
+ * ways — (1) `preserveConcatenation`'s continuation-line indentation
37
+ * *does* depend on depth even for leaf content, so a render cached at
38
+ * depth 0 here and reused by `_toCDN`'s real render at a different depth
39
+ * produced under-indented continuation lines; (2) the cache persisted
40
+ * on the node forever and was keyed only by object identity, so
41
+ * mutating the same `options` object between two `toCDN()` calls
42
+ * silently returned the first call's stale result. `this` is re-rendered
43
+ * here and again by the real `_toCDN` call from whatever holds this
44
+ * entry — an accepted, narrow cost (only tag-wrapped entries reach this
45
+ * at all).
46
+ */
47
+ _isMultiWordText(options: ToCDNOptions | undefined, strict?: boolean): boolean;
21
48
  _encodeTo(writer: CborWriter, options?: ToCBOROptions): void;
22
49
  _toCDN(options: ToCDNOptions | undefined, depth: number): string;
23
50
  _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
@@ -25,7 +25,7 @@ export declare class CborTextString extends CborItem {
25
25
  /**
26
26
  * `true` at index `i`, aligned with `ednParts`, when that part came from a
27
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
28
+ * (decoded as UTF-8 and merged in per draft-25 §5.1) rather than a double-quoted
29
29
  * `"..."` literal. Both cases leave `ednPartSources[i]` `undefined` (byte
30
30
  * strings have no preserved raw source here, same as an unpreserved
31
31
  * double-quoted literal), so this is what lets `appSeqSourceFeatures`
@@ -33,6 +33,18 @@ export declare class CborTextString extends CborItem {
33
33
  * `textString`.
34
34
  */
35
35
  readonly ednPartIsByteString: readonly boolean[] | undefined;
36
+ /**
37
+ * Source span of each `ednParts` entry's own literal token, aligned by
38
+ * index — used to place a comment sitting between two `+`-joined parts at
39
+ * the right gap instead of dropping it (there is no per-part AST node for
40
+ * such a comment to attach to; it lands as `dangling` on this whole node
41
+ * instead — see `CborByteString.ednParts`'s equivalent doc). `undefined`
42
+ * for a node not parsed from a `+` chain at all.
43
+ */
44
+ readonly ednPartSpans: readonly {
45
+ start: number;
46
+ end: number;
47
+ }[] | undefined;
36
48
  constructor(value: string, options?: {
37
49
  encodingWidth?: EncodingWidth;
38
50
  ednParts?: readonly string[];
@@ -40,7 +52,12 @@ export declare class CborTextString extends CborItem {
40
52
  quotedEdnSource?: string;
41
53
  ednPartSources?: readonly (string | undefined)[];
42
54
  ednPartIsByteString?: readonly boolean[];
55
+ ednPartSpans?: readonly {
56
+ start: number;
57
+ end: number;
58
+ }[];
43
59
  });
60
+ _isMultiWordText(_options: ToCDNOptions | undefined, _strict?: boolean): boolean;
44
61
  _encodeTo(writer: CborWriter, _options?: ToCBOROptions): void;
45
62
  _toCDN(options: ToCDNOptions | undefined, depth: number): string;
46
63
  _toJS(_options?: ToJSOptions): unknown;
@@ -1,10 +1,10 @@
1
1
  import { ToCDNOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  import { CborItem } from './CborItem';
4
- /** Provisional tag number for the Unresolved Application-Extension stand-in. */
4
+ /** Provisional tag number for the Unresolved App-Extension stand-in. */
5
5
  export declare const CPA999_TAG = 999n;
6
6
  /**
7
- * Stand-in for an unrecognised EDN application-extension literal.
7
+ * Stand-in for an unrecognised EDN app-extension literal.
8
8
  *
9
9
  * Structure:
10
10
  * App-string: CPA999([prefix, text])
@@ -1 +1 @@
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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-C1f7G0AM.cjs");exports.CborArray=e.E,exports.CborBigNint=e._,exports.CborBigUint=e.v,exports.CborByteString=e.k,exports.CborEmbeddedCBOR=e.C,exports.CborFloat=e.j,exports.CborIndefiniteByteString=e.O,exports.CborIndefiniteTextString=e.D,exports.CborItem=e.F,exports.CborMap=e.T,exports.CborNint=e.N,exports.CborSimple=e.w,exports.CborTag=e.A,exports.CborTextString=e.h,exports.CborUint=e.P;
@@ -1,4 +1,5 @@
1
1
  export { CborItem } from './CborItem';
2
+ export type { AppSeqEncodingEdit, AppSeqSourceFeatures } from './CborItem';
2
3
  export { CborUint } from './CborUint';
3
4
  export { CborBigUint, CborBigNint } from './CborBignum';
4
5
  export { CborNint } from './CborNint';
package/dist/ast/index.js CHANGED
@@ -1,2 +1,2 @@
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 };
1
+ import { A as e, C as t, D as n, E as r, F as i, N 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-CvLdiN0h.js";
2
+ export { r as CborArray, l as CborBigNint, p as CborBigUint, f as CborByteString, t as CborEmbeddedCBOR, d as CborFloat, o as CborIndefiniteByteString, n as CborIndefiniteTextString, i as CborItem, c as CborMap, a as CborNint, m as CborSimple, e as CborTag, u as CborTextString, s as CborUint };
@@ -1,3 +1,3 @@
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]===`
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../schema-iXpYtKQl.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
@@ -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-Bofmsptw.js";
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-CNfrVRYp.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;
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../tokenizer-EciPlN0n.cjs");function t(t){let n=new e.t(t),r=[];for(;;){let e=n.consume();if(e.type===`EOF`)break;r.push(e)}return{tokens:r,comments:n.comments}}function n(t){let n=new e.t(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.o?i:new e.o(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
- `?(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.CdnSyntaxError=e.o,exports.tokenize=t,exports.tokenizeLenient=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../serialize-utils-CjTqQivB.cjs");function t(t){let n=new e.A(t),r=[];for(;;){let e=n.consume();if(e.type===`EOF`)break;r.push(e)}return{tokens:r,comments:n.comments}}function n(t){let n=new e.A(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.I?i:new e.I(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
+ `?(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.CdnSyntaxError=e.I,exports.adjustAppSeqIndicator=e.t,exports.adjustRawAppSeqSource=e.n,exports.canonicalEncodingWidth=e.r,exports.decideTaggedAppSeqRendering=e.o,exports.resolveEiSuffix=e.C,exports.tokenize=t,exports.tokenizeLenient=n;
3
3
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/cdn/index.ts"],"sourcesContent":["/**\n * Public lower-level CDN tokenization API (`@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.\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 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":"gHAgCA,SAAgB,EAAS,EAA8B,CACrD,IAAM,EAAY,IAAI,EAAA,EAAU,CAAI,EAC9B,EAAkB,CAAC,EACzB,OAAS,CACP,IAAM,EAAM,EAAU,QAAQ,EAC9B,GAAI,EAAI,OAAS,MAAO,MACxB,EAAO,KAAK,CAAG,CACjB,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,QAAS,CAChD,CAQA,SAAgB,EAAgB,EAAqC,CACnE,IAAM,EAAY,IAAI,EAAA,EAAU,CAAI,EAC9B,EAAkB,CAAC,EACzB,GAAI,CACF,OAAS,CACP,IAAM,EAAM,EAAU,QAAQ,EAC9B,GAAI,EAAI,OAAS,MAAO,MACxB,EAAO,KAAK,CAAG,CACjB,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,QAAS,CAChD,OAAS,EAAG,CACV,IAAM,EACJ,aAAa,EAAA,EACT,EACA,IAAI,EAAA,EAAe,aAAa,MAAQ,EAAE,QAAU,OAAO,CAAC,CAAC,EAC7D,EAAQ,EAAU,cACxB,GAAI,EAAQ,EAAK,OAAQ,CACvB,IAAI,EAAO,EACP,EAAM,EACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IACrB,EAAK,KAAO;GACd,IACA,EAAM,GAEN,IAGJ,EAAO,KAAK,CACV,KAAM,QACN,MAAO,EAAK,MAAM,CAAK,EACvB,IAAK,EAAK,MAAM,CAAK,EACrB,OACA,MACA,OAAQ,EACR,UAAW,EAAK,MAClB,CAAC,CACH,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,SAAU,OAAM,CACvD,CACF"}
1
+ {"version":3,"file":"index.cjs","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":"sHAkDA,SAAgB,EAAS,EAA8B,CACrD,IAAM,EAAY,IAAI,EAAA,EAAU,CAAI,EAC9B,EAAkB,CAAC,EACzB,OAAS,CACP,IAAM,EAAM,EAAU,QAAQ,EAC9B,GAAI,EAAI,OAAS,MAAO,MACxB,EAAO,KAAK,CAAG,CACjB,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,QAAS,CAChD,CAQA,SAAgB,EAAgB,EAAqC,CACnE,IAAM,EAAY,IAAI,EAAA,EAAU,CAAI,EAC9B,EAAkB,CAAC,EACzB,GAAI,CACF,OAAS,CACP,IAAM,EAAM,EAAU,QAAQ,EAC9B,GAAI,EAAI,OAAS,MAAO,MACxB,EAAO,KAAK,CAAG,CACjB,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,QAAS,CAChD,OAAS,EAAG,CACV,IAAM,EACJ,aAAa,EAAA,EACT,EACA,IAAI,EAAA,EAAe,aAAa,MAAQ,EAAE,QAAU,OAAO,CAAC,CAAC,EAC7D,EAAQ,EAAU,cACxB,GAAI,EAAQ,EAAK,OAAQ,CACvB,IAAI,EAAO,EACP,EAAM,EACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IACrB,EAAK,KAAO;GACd,IACA,EAAM,GAEN,IAGJ,EAAO,KAAK,CACV,KAAM,QACN,MAAO,EAAK,MAAM,CAAK,EACvB,IAAK,EAAK,MAAM,CAAK,EACrB,OACA,MACA,OAAQ,EACR,UAAW,EAAK,MAClB,CAAC,CACH,CACA,MAAO,CAAE,SAAQ,SAAU,EAAU,SAAU,OAAM,CACvD,CACF"}
@@ -2,6 +2,8 @@ import { Token, EdnComment } from './tokenizer';
2
2
  import { CdnSyntaxError } from './errors';
3
3
  export type { Token, TokenType, EdnComment } from './tokenizer';
4
4
  export { CdnSyntaxError } from './errors';
5
+ export { resolveEiSuffix, canonicalEncodingWidth, decideTaggedAppSeqRendering, adjustRawAppSeqSource, adjustAppSeqIndicator, } from './serialize-utils';
6
+ export type { AppSeqRenderDecision } from './serialize-utils';
5
7
  export interface TokenizeResult {
6
8
  /** Scanned tokens in source order, excluding the final EOF token. */
7
9
  tokens: Token[];
package/dist/cdn/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { o as e, t } from "../tokenizer-CeuixxXi.js";
1
+ import { A as e, C as t, I as n, n as r, o as i, r as a, t as o } from "../serialize-utils-BuIZPaUc.js";
2
2
  //#region src/cdn/index.ts
3
- function n(e) {
4
- let n = new t(e), r = [];
3
+ function s(t) {
4
+ let n = new e(t), r = [];
5
5
  for (;;) {
6
6
  let e = n.consume();
7
7
  if (e.type === "EOF") break;
@@ -12,8 +12,8 @@ function n(e) {
12
12
  comments: n.comments
13
13
  };
14
14
  }
15
- function r(n) {
16
- let r = new t(n), i = [];
15
+ function c(t) {
16
+ let r = new e(t), i = [];
17
17
  try {
18
18
  for (;;) {
19
19
  let e = r.consume();
@@ -24,19 +24,19 @@ function r(n) {
24
24
  tokens: i,
25
25
  comments: r.comments
26
26
  };
27
- } catch (t) {
28
- let a = t instanceof e ? t : new e(t instanceof Error ? t.message : String(t)), o = r.lastEndOffset;
29
- if (o < n.length) {
30
- let e = 1, t = 1;
31
- for (let r = 0; r < o; r++) n[r] === "\n" ? (e++, t = 1) : t++;
27
+ } catch (e) {
28
+ let a = e instanceof n ? e : new n(e instanceof Error ? e.message : String(e)), o = r.lastEndOffset;
29
+ if (o < t.length) {
30
+ let e = 1, n = 1;
31
+ for (let r = 0; r < o; r++) t[r] === "\n" ? (e++, n = 1) : n++;
32
32
  i.push({
33
33
  type: "ERROR",
34
- value: n.slice(o),
35
- raw: n.slice(o),
34
+ value: t.slice(o),
35
+ raw: t.slice(o),
36
36
  line: e,
37
- col: t,
37
+ col: n,
38
38
  offset: o,
39
- endOffset: n.length
39
+ endOffset: t.length
40
40
  });
41
41
  }
42
42
  return {
@@ -47,6 +47,6 @@ function r(n) {
47
47
  }
48
48
  }
49
49
  //#endregion
50
- export { e as CdnSyntaxError, n as tokenize, r as tokenizeLenient };
50
+ export { n as CdnSyntaxError, o as adjustAppSeqIndicator, r as adjustRawAppSeqSource, a as canonicalEncodingWidth, i as decideTaggedAppSeqRendering, t as resolveEiSuffix, s as tokenize, c as tokenizeLenient };
51
51
 
52
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/cdn/index.ts"],"sourcesContent":["/**\n * Public lower-level CDN tokenization API (`@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.\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 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":";;AAgCA,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
+ {"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"}