@cbortech/cbor 0.26.8 → 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.
- package/README.ja.md +120 -28
- package/README.md +121 -29
- package/dist/ast/CborAppSeqResult.d.ts +22 -0
- package/dist/ast/CborByteString.d.ts +16 -0
- package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
- package/dist/ast/CborFloat.d.ts +1 -1
- package/dist/ast/CborIndefiniteByteString.d.ts +24 -0
- package/dist/ast/CborIndefiniteTextString.d.ts +16 -0
- package/dist/ast/CborItem.d.ts +44 -4
- package/dist/ast/CborTag.d.ts +27 -0
- package/dist/ast/CborTextString.d.ts +2 -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 +207 -8
- package/dist/cdn/tokenizer.d.ts +12 -11
- package/dist/extensions/builtins.d.ts +5 -5
- package/dist/extensions/cri.d.ts +2 -2
- package/dist/extensions/ip.d.ts +1 -1
- package/dist/extensions/types.d.ts +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +158 -158
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-C1f7G0AM.cjs +13 -0
- package/dist/mapEntries-C1f7G0AM.cjs.map +1 -0
- package/dist/{mapEntries-Ci_dppP6.js → mapEntries-CvLdiN0h.js} +1362 -1219
- package/dist/mapEntries-CvLdiN0h.js.map +1 -0
- package/dist/{schema-y8G5mDIS.js → schema-CNfrVRYp.js} +294 -294
- package/dist/{schema-y8G5mDIS.js.map → schema-CNfrVRYp.js.map} +1 -1
- package/dist/schema-iXpYtKQl.cjs +63 -0
- package/dist/{schema-DgnkH0P6.cjs.map → schema-iXpYtKQl.cjs.map} +1 -1
- package/dist/{tokenizer-N-vAvRdj.js → serialize-utils-BuIZPaUc.js} +626 -358
- package/dist/serialize-utils-BuIZPaUc.js.map +1 -0
- package/dist/serialize-utils-CjTqQivB.cjs +37 -0
- package/dist/serialize-utils-CjTqQivB.cjs.map +1 -0
- package/dist/types.d.ts +235 -58
- package/dist/utils/base64.d.ts +1 -1
- package/dist/utils/hexfloat.d.ts +1 -1
- package/dist/utils/strip-comments.d.ts +1 -1
- package/package.json +8 -6
- 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/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { D as e } from "./
|
|
2
|
-
import { n
|
|
3
|
-
import { B as
|
|
1
|
+
import { D as e, I as t } from "./serialize-utils-BuIZPaUc.js";
|
|
2
|
+
import { n, s as r } from "./schema-CNfrVRYp.js";
|
|
3
|
+
import { B as i, H as a, L as o, R as s, S as c, V as l, a as u, c as d, d as f, f as p, g as m, i as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, t as C, u as w, x as T, z as E } from "./mapEntries-CvLdiN0h.js";
|
|
4
4
|
//#region src/extensions/same.ts
|
|
5
|
-
function
|
|
5
|
+
function D(e, t) {
|
|
6
6
|
if (e.length !== t.length) return !1;
|
|
7
7
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
8
8
|
return !0;
|
|
9
9
|
}
|
|
10
|
-
var
|
|
10
|
+
var O = {
|
|
11
11
|
appStringPrefixes: ["same"],
|
|
12
12
|
preserveAppSeqSource: !0,
|
|
13
13
|
parseAppSequence(e, t, n) {
|
|
14
14
|
if (t.length === 0) throw SyntaxError("same<<...>> requires at least one item");
|
|
15
15
|
let r = t[0], i = r.toCBOR();
|
|
16
|
-
for (let e = 1; e < t.length; e++) if (!
|
|
16
|
+
for (let e = 1; e < t.length; e++) if (!D(i, t[e].toCBOR())) {
|
|
17
17
|
let t = `same<<...>>: item ${e} produces different CBOR bytes than item 0`;
|
|
18
18
|
if (n) n(t);
|
|
19
19
|
else throw SyntaxError(t);
|
|
20
20
|
}
|
|
21
21
|
return r;
|
|
22
22
|
}
|
|
23
|
-
},
|
|
24
|
-
function
|
|
23
|
+
}, k = /* @__PURE__ */ new Map(), A = 64;
|
|
24
|
+
function j(e) {
|
|
25
25
|
if (typeof e != "string") return e;
|
|
26
|
-
let
|
|
27
|
-
return
|
|
26
|
+
let t = k.get(e);
|
|
27
|
+
return t || (t = n(e), k.size >= A && k.delete(k.keys().next().value), k.set(e, t)), t;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function M(e, t, n) {
|
|
30
30
|
if (t) {
|
|
31
|
-
let i = t.validate(e,
|
|
32
|
-
if (!i.valid) throw new
|
|
31
|
+
let i = t.validate(e, n);
|
|
32
|
+
if (!i.valid) throw new r(i.errors, i.warnings);
|
|
33
33
|
}
|
|
34
34
|
return e;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function N(e, t) {
|
|
37
|
+
return M(e, j(t?.cddl), t?.cddlValidationOptions);
|
|
38
38
|
}
|
|
39
|
-
var
|
|
40
|
-
static OMIT =
|
|
41
|
-
static TAG =
|
|
42
|
-
static Tag =
|
|
39
|
+
var P = class n {
|
|
40
|
+
static OMIT = s;
|
|
41
|
+
static TAG = E;
|
|
42
|
+
static Tag = l;
|
|
43
43
|
static Simple = o;
|
|
44
44
|
static MapEntries = C;
|
|
45
45
|
static dt_as_Date = _;
|
|
@@ -53,191 +53,191 @@ var N = class t {
|
|
|
53
53
|
...e ?? {}
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
fromCBOR(e,
|
|
57
|
-
let r =
|
|
56
|
+
fromCBOR(e, t) {
|
|
57
|
+
let r = n.fromCBOR(e, this.#t(t));
|
|
58
58
|
return r._defaults = this.#e, r;
|
|
59
59
|
}
|
|
60
|
-
fromCDN(e,
|
|
61
|
-
let r =
|
|
60
|
+
fromCDN(e, t) {
|
|
61
|
+
let r = n.fromCDN(e, this.#t(t));
|
|
62
62
|
return r._defaults = this.#e, r;
|
|
63
63
|
}
|
|
64
64
|
fromEDN(e, t) {
|
|
65
65
|
return this.fromCDN(e, t);
|
|
66
66
|
}
|
|
67
|
-
fromJS(e,
|
|
68
|
-
let r =
|
|
67
|
+
fromJS(e, t) {
|
|
68
|
+
let r = n.fromJS(e, this.#t(t));
|
|
69
69
|
return r._defaults = this.#e, r;
|
|
70
70
|
}
|
|
71
|
-
fromHexDump(e,
|
|
72
|
-
let r =
|
|
71
|
+
fromHexDump(e, t) {
|
|
72
|
+
let r = n.fromHexDump(e, this.#t(t));
|
|
73
73
|
return r._defaults = this.#e, r;
|
|
74
74
|
}
|
|
75
|
-
*fromCBORSeq(e,
|
|
76
|
-
for (let r of
|
|
75
|
+
*fromCBORSeq(e, t) {
|
|
76
|
+
for (let r of n.fromCBORSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
|
|
77
77
|
}
|
|
78
|
-
*fromCDNSeq(e,
|
|
79
|
-
for (let r of
|
|
78
|
+
*fromCDNSeq(e, t) {
|
|
79
|
+
for (let r of n.fromCDNSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
|
|
80
80
|
}
|
|
81
|
-
*fromHexDumpSeq(e,
|
|
82
|
-
for (let r of
|
|
81
|
+
*fromHexDumpSeq(e, t) {
|
|
82
|
+
for (let r of n.fromHexDumpSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
|
|
83
83
|
}
|
|
84
|
-
decode(e,
|
|
85
|
-
return
|
|
84
|
+
decode(e, t) {
|
|
85
|
+
return n.decode(e, this.#t(t));
|
|
86
86
|
}
|
|
87
|
-
*decodeSeq(e,
|
|
88
|
-
yield*
|
|
87
|
+
*decodeSeq(e, t) {
|
|
88
|
+
yield* n.decodeSeq(e, this.#t(t));
|
|
89
89
|
}
|
|
90
|
-
*parseSeq(e,
|
|
91
|
-
yield*
|
|
90
|
+
*parseSeq(e, t) {
|
|
91
|
+
yield* n.parseSeq(e, this.#t(t));
|
|
92
92
|
}
|
|
93
|
-
encode(e,
|
|
94
|
-
return
|
|
93
|
+
encode(e, t) {
|
|
94
|
+
return n.encode(e, this.#t(t));
|
|
95
95
|
}
|
|
96
|
-
compile(e,
|
|
97
|
-
return
|
|
96
|
+
compile(e, t) {
|
|
97
|
+
return n.compile(e, this.#t(t));
|
|
98
98
|
}
|
|
99
|
-
decompile(e,
|
|
100
|
-
return
|
|
99
|
+
decompile(e, t) {
|
|
100
|
+
return n.decompile(e, this.#t(t));
|
|
101
101
|
}
|
|
102
|
-
toHex(e,
|
|
103
|
-
return
|
|
102
|
+
toHex(e, t) {
|
|
103
|
+
return n.toHex(e, this.#t(t));
|
|
104
104
|
}
|
|
105
|
-
fromHex(e,
|
|
106
|
-
return
|
|
105
|
+
fromHex(e, t) {
|
|
106
|
+
return n.fromHex(e, this.#t(t));
|
|
107
107
|
}
|
|
108
|
-
validate(e,
|
|
109
|
-
return
|
|
108
|
+
validate(e, t) {
|
|
109
|
+
return n.validate(e, this.#t(t));
|
|
110
110
|
}
|
|
111
111
|
cborToCborEdn(e, t) {
|
|
112
112
|
return this.cborToCdn(e, t);
|
|
113
113
|
}
|
|
114
|
-
cborToCdn(e,
|
|
115
|
-
let r = this.#t(
|
|
114
|
+
cborToCdn(e, t) {
|
|
115
|
+
let r = this.#t(t), i = n.fromCBOR(e, r);
|
|
116
116
|
return i._defaults = this.#e, i.toCDN(r);
|
|
117
117
|
}
|
|
118
118
|
cborEdnToCbor(e, t) {
|
|
119
119
|
return this.cdnToCbor(e, t);
|
|
120
120
|
}
|
|
121
|
-
cdnToCbor(e,
|
|
122
|
-
let r = this.#t(
|
|
123
|
-
return
|
|
121
|
+
cdnToCbor(e, t) {
|
|
122
|
+
let r = this.#t(t);
|
|
123
|
+
return n.fromCDN(e, r).toCBOR(r);
|
|
124
124
|
}
|
|
125
|
-
parse(e,
|
|
126
|
-
if (typeof
|
|
127
|
-
let r = this.#t({ reviver:
|
|
128
|
-
return
|
|
125
|
+
parse(e, t) {
|
|
126
|
+
if (typeof t == "function") {
|
|
127
|
+
let r = this.#t({ reviver: t });
|
|
128
|
+
return n.fromCDN(e, r).toJS(r);
|
|
129
129
|
}
|
|
130
|
-
let r = this.#t(
|
|
131
|
-
return
|
|
130
|
+
let r = this.#t(t);
|
|
131
|
+
return n.fromCDN(e, r).toJS(r);
|
|
132
132
|
}
|
|
133
|
-
stringify(e,
|
|
134
|
-
if (typeof
|
|
133
|
+
stringify(e, t, r) {
|
|
134
|
+
if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && r !== void 0) {
|
|
135
135
|
let i = { ...this.#e };
|
|
136
|
-
return
|
|
136
|
+
return t === null ? i.replacer = void 0 : (typeof t == "function" || Array.isArray(t)) && (i.replacer = t), r !== void 0 && (i.indent = V(r)), n.stringify(e, i);
|
|
137
137
|
}
|
|
138
|
-
return
|
|
138
|
+
return n.stringify(e, this.#t(t ?? void 0));
|
|
139
139
|
}
|
|
140
|
-
format(e,
|
|
141
|
-
return
|
|
140
|
+
format(e, t) {
|
|
141
|
+
return n.format(e, this.#t(t));
|
|
142
142
|
}
|
|
143
143
|
static fromCBOR(e, t) {
|
|
144
|
-
return
|
|
144
|
+
return N(w(e, t), t);
|
|
145
145
|
}
|
|
146
146
|
static fromCDN(e, t) {
|
|
147
|
-
return
|
|
147
|
+
return N(m(e, t), t);
|
|
148
148
|
}
|
|
149
|
-
static fromEDN(e,
|
|
150
|
-
return
|
|
149
|
+
static fromEDN(e, t) {
|
|
150
|
+
return n.fromCDN(e, t);
|
|
151
151
|
}
|
|
152
|
-
static *fromHexDumpSeq(e,
|
|
153
|
-
let r = [], i =
|
|
152
|
+
static *fromHexDumpSeq(e, t) {
|
|
153
|
+
let r = [], i = F(e).trim().split(/\s+/).filter(Boolean);
|
|
154
154
|
for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) r.push(parseInt(e, 16));
|
|
155
155
|
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));
|
|
156
156
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
157
|
-
yield*
|
|
157
|
+
yield* n.fromCBORSeq(new Uint8Array(r), t);
|
|
158
158
|
}
|
|
159
159
|
static *fromCBORSeq(e, t) {
|
|
160
|
-
let n =
|
|
160
|
+
let n = j(t?.cddl), r = e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), i = 0;
|
|
161
161
|
for (; i < r.byteLength;) {
|
|
162
162
|
let e = w(r, {
|
|
163
163
|
...t,
|
|
164
164
|
offset: i,
|
|
165
165
|
allowTrailing: !0
|
|
166
166
|
});
|
|
167
|
-
yield
|
|
167
|
+
yield M(e, n, t?.cddlValidationOptions), i = e.end;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
static *fromCDNSeq(
|
|
171
|
-
let
|
|
170
|
+
static *fromCDNSeq(n, r) {
|
|
171
|
+
let i = j(r?.cddl), a = e(r) || !!r?.preserveAll, o = 0, s = !0;
|
|
172
172
|
for (;;) {
|
|
173
|
-
let { offset:
|
|
174
|
-
if (
|
|
173
|
+
let { offset: e, hadSeparator: c, commaOffset: l } = B(n, o, r, a ? s ? "all" : "after-newline" : "none");
|
|
174
|
+
if (s && l >= 0) {
|
|
175
175
|
let e = "leading comma in CDN sequence";
|
|
176
|
-
if (
|
|
177
|
-
|
|
176
|
+
if (r?.strict !== !1) throw SyntaxError(e);
|
|
177
|
+
R(e, l, r);
|
|
178
178
|
}
|
|
179
|
-
if (
|
|
180
|
-
if (!
|
|
181
|
-
let
|
|
182
|
-
if (
|
|
183
|
-
|
|
179
|
+
if (e >= n.length || a && z(n, e) && B(n, e, r).offset >= n.length) break;
|
|
180
|
+
if (!s && !c) {
|
|
181
|
+
let t = "CDN sequence items must be separated by whitespace, comma, or comment";
|
|
182
|
+
if (r?.strict !== !1) throw SyntaxError(t);
|
|
183
|
+
R(t, e, r);
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
o = e;
|
|
186
186
|
let u;
|
|
187
187
|
try {
|
|
188
|
-
u = m(
|
|
189
|
-
...
|
|
190
|
-
offset:
|
|
188
|
+
u = m(n, {
|
|
189
|
+
...r,
|
|
190
|
+
offset: o,
|
|
191
191
|
allowTrailing: !0,
|
|
192
192
|
_skipRS: !0
|
|
193
193
|
});
|
|
194
|
-
} catch (
|
|
195
|
-
if (
|
|
196
|
-
|
|
194
|
+
} catch (e) {
|
|
195
|
+
if (r?.strict !== !1) throw e;
|
|
196
|
+
R(e instanceof Error ? e.message : String(e), o, r, !0, e instanceof t ? e : void 0);
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
|
-
yield
|
|
199
|
+
yield M(u, i, r?.cddlValidationOptions), o = u.end, s = !1;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
static fromJS(e, t) {
|
|
203
|
-
return
|
|
203
|
+
return N(x(e, t), t);
|
|
204
204
|
}
|
|
205
205
|
static fromHexDump(e, t) {
|
|
206
|
-
let n = [], r =
|
|
206
|
+
let n = [], r = F(e).trim().split(/\s+/).filter(Boolean);
|
|
207
207
|
for (let e of r) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
|
|
208
208
|
else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) n.push(parseInt(e.slice(t, t + 2), 16));
|
|
209
209
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
210
|
-
return
|
|
210
|
+
return N(w(new Uint8Array(n), t), t);
|
|
211
211
|
}
|
|
212
|
-
static decode(e,
|
|
213
|
-
return
|
|
212
|
+
static decode(e, t) {
|
|
213
|
+
return n.fromCBOR(e, t).toJS(t);
|
|
214
214
|
}
|
|
215
|
-
static *decodeSeq(e,
|
|
216
|
-
for (let r of
|
|
215
|
+
static *decodeSeq(e, t) {
|
|
216
|
+
for (let r of n.fromCBORSeq(e, t)) yield r.toJS(t);
|
|
217
217
|
}
|
|
218
|
-
static *parseSeq(e,
|
|
219
|
-
for (let r of
|
|
218
|
+
static *parseSeq(e, t) {
|
|
219
|
+
for (let r of n.fromCDNSeq(e, t)) yield r.toJS(t);
|
|
220
220
|
}
|
|
221
|
-
static encode(e,
|
|
222
|
-
return
|
|
221
|
+
static encode(e, t) {
|
|
222
|
+
return n.fromJS(e, t).toCBOR(t);
|
|
223
223
|
}
|
|
224
|
-
static compile(e,
|
|
225
|
-
let r = [...
|
|
224
|
+
static compile(e, t) {
|
|
225
|
+
let r = [...n.fromCDNSeq(e, t)].map((e) => e.toCBOR(t)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
|
|
226
226
|
for (let e of r) a.set(e, o), o += e.length;
|
|
227
227
|
return a;
|
|
228
228
|
}
|
|
229
|
-
static decompile(e,
|
|
230
|
-
return [...
|
|
229
|
+
static decompile(e, t) {
|
|
230
|
+
return [...n.fromCBORSeq(e, t)].map((e) => e.toCDN(t)).join("\n");
|
|
231
231
|
}
|
|
232
|
-
static toHex(e,
|
|
233
|
-
return [...
|
|
232
|
+
static toHex(e, t) {
|
|
233
|
+
return [...n.fromCBORSeq(e, t)].map((e) => e.toHexDump(t)).join("\n");
|
|
234
234
|
}
|
|
235
|
-
static fromHex(e,
|
|
236
|
-
let r = [...
|
|
235
|
+
static fromHex(e, t) {
|
|
236
|
+
let r = [...n.fromHexDumpSeq(e, t)].map((e) => e.toCBOR(t)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
|
|
237
237
|
for (let e of r) a.set(e, o), o += e.length;
|
|
238
238
|
return a;
|
|
239
239
|
}
|
|
240
|
-
static validate(
|
|
240
|
+
static validate(e, r) {
|
|
241
241
|
let i = [], a = [], o, s = {
|
|
242
242
|
strict: !1,
|
|
243
243
|
extensions: r?.extensions,
|
|
@@ -253,7 +253,7 @@ var N = class t {
|
|
|
253
253
|
}
|
|
254
254
|
i.push(e);
|
|
255
255
|
}
|
|
256
|
-
}, c =
|
|
256
|
+
}, c = j(r?.cddl), l = [], u = [], d = (e) => {
|
|
257
257
|
if (!c) return;
|
|
258
258
|
let t = c.validate(e, r?.cddlValidationOptions);
|
|
259
259
|
l.push(...t.errors), t.warnings && u.push(...t.warnings);
|
|
@@ -262,15 +262,15 @@ var N = class t {
|
|
|
262
262
|
cddlWarnings: u
|
|
263
263
|
} : {}, p = 0;
|
|
264
264
|
try {
|
|
265
|
-
let
|
|
266
|
-
if (
|
|
267
|
-
let
|
|
265
|
+
let t = r?.type ?? "cbor";
|
|
266
|
+
if (t === "cdn") {
|
|
267
|
+
let t = {
|
|
268
268
|
...s,
|
|
269
269
|
unresolvedExtension: r?.unresolvedExtension
|
|
270
270
|
};
|
|
271
|
-
for (let r of
|
|
272
|
-
} else if (
|
|
273
|
-
else for (let
|
|
271
|
+
for (let r of n.fromCDNSeq(e, t)) p++, d(r);
|
|
272
|
+
} else if (t === "hex") for (let t of n.fromHexDumpSeq(e, s)) p++, d(t);
|
|
273
|
+
else for (let t of n.fromCBORSeq(e, s)) p++, d(t);
|
|
274
274
|
} catch (e) {
|
|
275
275
|
return {
|
|
276
276
|
valid: !1,
|
|
@@ -282,13 +282,13 @@ var N = class t {
|
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
if (o) {
|
|
285
|
-
let
|
|
285
|
+
let e = o.cause instanceof Error ? o.cause : new t(o.message, { offset: o.offset });
|
|
286
286
|
return {
|
|
287
287
|
valid: !1,
|
|
288
288
|
count: p,
|
|
289
289
|
warnings: i,
|
|
290
290
|
hints: a,
|
|
291
|
-
error:
|
|
291
|
+
error: e,
|
|
292
292
|
...f
|
|
293
293
|
};
|
|
294
294
|
}
|
|
@@ -300,98 +300,98 @@ var N = class t {
|
|
|
300
300
|
...f
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
|
-
static cborToCdn(e,
|
|
304
|
-
return
|
|
303
|
+
static cborToCdn(e, t) {
|
|
304
|
+
return n.fromCBOR(e, t).toCDN(t);
|
|
305
305
|
}
|
|
306
|
-
static cborToCborEdn(e,
|
|
307
|
-
return
|
|
306
|
+
static cborToCborEdn(e, t) {
|
|
307
|
+
return n.fromCBOR(e, t).toCDN(t);
|
|
308
308
|
}
|
|
309
|
-
static cdnToCbor(e,
|
|
310
|
-
return
|
|
309
|
+
static cdnToCbor(e, t) {
|
|
310
|
+
return n.fromCDN(e, t).toCBOR(t);
|
|
311
311
|
}
|
|
312
|
-
static cborEdnToCbor(e,
|
|
313
|
-
return
|
|
312
|
+
static cborEdnToCbor(e, t) {
|
|
313
|
+
return n.fromCDN(e, t).toCBOR(t);
|
|
314
314
|
}
|
|
315
|
-
static parse(e,
|
|
316
|
-
return typeof
|
|
315
|
+
static parse(e, t) {
|
|
316
|
+
return typeof t == "function" ? n.fromCDN(e).toJS({ reviver: t }) : n.fromCDN(e, t).toJS(t);
|
|
317
317
|
}
|
|
318
318
|
static stringify(e, t, n) {
|
|
319
319
|
if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
|
|
320
|
-
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i =
|
|
320
|
+
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = V(n);
|
|
321
321
|
if (r) {
|
|
322
322
|
let t = v(e, r);
|
|
323
|
-
return t === void 0 || t ===
|
|
323
|
+
return t === void 0 || t === s ? void 0 : x(t).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
324
324
|
}
|
|
325
325
|
return x(e).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
326
326
|
}
|
|
327
327
|
let r = t;
|
|
328
328
|
if (r?.replacer) {
|
|
329
329
|
let t = v(e, r.replacer, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
330
|
-
if (t === void 0 || t ===
|
|
330
|
+
if (t === void 0 || t === s) return;
|
|
331
331
|
let { replacer: n, ...i } = r;
|
|
332
|
-
return
|
|
332
|
+
return N(x(t, Object.keys(i).length > 0 ? i : void 0), r).toCDN(r);
|
|
333
333
|
}
|
|
334
|
-
return
|
|
334
|
+
return N(x(e, r), r).toCDN(r);
|
|
335
335
|
}
|
|
336
|
-
static format(e,
|
|
337
|
-
return
|
|
336
|
+
static format(e, t) {
|
|
337
|
+
return n.fromCDN(e, t).toCDN(t);
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
|
-
function
|
|
340
|
+
function F(e) {
|
|
341
341
|
let t = "", n = 0;
|
|
342
342
|
for (; n < e.length;) {
|
|
343
343
|
let r = e[n], i = e[n + 1] ?? "";
|
|
344
344
|
if (r === "-" && i === "-") {
|
|
345
|
-
n =
|
|
345
|
+
n = I(e, n + 2), t += " ";
|
|
346
346
|
continue;
|
|
347
347
|
}
|
|
348
348
|
if (r === "—") {
|
|
349
|
-
n =
|
|
349
|
+
n = I(e, n + 1), t += " ";
|
|
350
350
|
continue;
|
|
351
351
|
}
|
|
352
352
|
if (r === "#") {
|
|
353
|
-
n =
|
|
353
|
+
n = I(e, n + 1), t += " ";
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
356
356
|
if (r === "/" && i === "/") {
|
|
357
|
-
n =
|
|
357
|
+
n = I(e, n + 2), t += " ";
|
|
358
358
|
continue;
|
|
359
359
|
}
|
|
360
360
|
if (r === "/" && i === "*") {
|
|
361
361
|
let r = e.indexOf("*/", n + 2);
|
|
362
362
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
363
|
-
t +=
|
|
363
|
+
t += L(e.slice(n, r + 2)), n = r + 2;
|
|
364
364
|
continue;
|
|
365
365
|
}
|
|
366
366
|
if (r === "/") {
|
|
367
367
|
let r = e.indexOf("/", n + 1);
|
|
368
368
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
369
|
-
t +=
|
|
369
|
+
t += L(e.slice(n, r + 1)), n = r + 1;
|
|
370
370
|
continue;
|
|
371
371
|
}
|
|
372
372
|
t += r, n++;
|
|
373
373
|
}
|
|
374
374
|
return t;
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function I(e, t) {
|
|
377
377
|
let n = e.indexOf("\n", t);
|
|
378
378
|
return n < 0 ? e.length : n;
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function L(e) {
|
|
381
381
|
return e.replace(/[^\r\n]/g, " ");
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function R(e, t, n, r, i) {
|
|
384
384
|
let a = i?.offset ?? t, o = {
|
|
385
385
|
message: e,
|
|
386
386
|
offset: a
|
|
387
387
|
};
|
|
388
388
|
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}`);
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function z(e, t) {
|
|
391
391
|
let n = e[t];
|
|
392
392
|
return n === "#" || n === "/";
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function B(e, t, n, r = "none") {
|
|
395
395
|
let i = t, a = !1, o = !1, s = !1, c = -1, l = () => r === "all" || r === "after-newline" && s;
|
|
396
396
|
for (; i < e.length;) {
|
|
397
397
|
let t = e[i];
|
|
@@ -421,7 +421,7 @@ function z(e, t, n, r = "none") {
|
|
|
421
421
|
if (t < 0) {
|
|
422
422
|
let t = "unterminated /* comment in CDN sequence";
|
|
423
423
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
424
|
-
|
|
424
|
+
R(t, i, n, !0), i = e.length;
|
|
425
425
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 2;
|
|
426
426
|
continue;
|
|
427
427
|
}
|
|
@@ -431,7 +431,7 @@ function z(e, t, n, r = "none") {
|
|
|
431
431
|
if (t < 0) {
|
|
432
432
|
let t = "unterminated / comment in CDN sequence";
|
|
433
433
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
434
|
-
|
|
434
|
+
R(t, i, n, !0), i = e.length;
|
|
435
435
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 1;
|
|
436
436
|
continue;
|
|
437
437
|
}
|
|
@@ -447,7 +447,7 @@ function z(e, t, n, r = "none") {
|
|
|
447
447
|
commaOffset: c
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function V(e) {
|
|
451
451
|
if (typeof e == "number") {
|
|
452
452
|
let t = Math.floor(Math.min(10, Math.max(0, e)));
|
|
453
453
|
return t === 0 ? void 0 : t;
|
|
@@ -455,6 +455,6 @@ function B(e) {
|
|
|
455
455
|
if (typeof e == "string") return e.slice(0, 10) || void 0;
|
|
456
456
|
}
|
|
457
457
|
//#endregion
|
|
458
|
-
export { h as BUILTIN_EXTENSIONS,
|
|
458
|
+
export { h as BUILTIN_EXTENSIONS, P as CBOR, P as default, s as CBOR_OMIT, E as CBOR_TAG, r as CddlMismatchError, t as CdnSyntaxError, C as MapEntries, i as Null, o as Simple, l as Tag, a as Undefined, d as b1, T as b32, f as cri, b as dt, _ as dt_as_Date, u as float, c as h32, y as ilbs, S as ilts, p as ip, O as same, g as t1 };
|
|
459
459
|
|
|
460
460
|
//# sourceMappingURL=index.js.map
|